Thanks _a_lot_ Ryan.. this stuff is really tedious.
Just a few more things.

BTW: what about start_info->flags = SIF_PRIVILEGED or SIF_INITDOMAIN. You will not need properties now but you will need to make sure there absence is recognized in linux/.../setup.c.

On Jan 25, 2007, at 2:16 PM, Ryan Harper wrote:

* Jimi Xenidis <[EMAIL PROTECTED]> [2007-01-24 12:42]:
The data that was in start_info_t should be just simple bindings in "/
xen" since they describe xen, there is no need to create a new node.
many of the props are not needed since they are expressed elsewhere
in the devtree or perhaps differently.
more below.

New rev:

-dropped /xen/start_info_t, hanging new node /xen/store
-fixed up /xen/console/reg to be proper <u64 base><u64 size> value
-fixed up /xen/console/interrupts to use value passed from xend
-renamed property 'shared_info' to 'shared-info'
-fixed 'shared-info' to be a proper <u64 base><u64 size> value
-reduced the number of pages reserved at the end of RMA from 4 to 3
 as we no longer need to reserve a page for start_info_t

--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
[EMAIL PROTECTED]


diffstat output:
 mk_flatdevtree.c |   45 +++++++++++++++++++++++------
 mk_flatdevtree.h |    6 ++-
xc_linux_build.c | 83 +++++++++++++++++++++++++ +-----------------------------
 3 files changed, 80 insertions(+), 54 deletions(-)

Signed-off-by: Ryan Harper <[EMAIL PROTECTED]>
---
diff -r ed5ee9dde0bd tools/libxc/powerpc64/mk_flatdevtree.c
--- a/tools/libxc/powerpc64/mk_flatdevtree.c Sun Jan 21 08:17:46 2007 -0500 +++ b/tools/libxc/powerpc64/mk_flatdevtree.c Thu Jan 25 11:57:41 2007 -0600
@@ -316,13 +316,16 @@ int make_devtree(struct ft_cxt *root,
                  unsigned long shadow_mb,
                  unsigned long initrd_base,
                  unsigned long initrd_len,
-                 const char *bootargs)
+                 const char *bootargs,
+                 unsigned long console_evtchn,
+                 unsigned long store_evtchn,
+                 unsigned long nr_pages)
nr_pages no long needed

Since you later look for the console_mfn and store_mfn later, it would be better in the caller and pass then in. FYI: It is xend that decides where store and console go. shared_info is a hypervisor contract so you can continue to calculate it here if you want.

Also the devtree should not contain MFNs for frame numbers of any kind, simply addresses.

 {
     struct boot_param_header *bph = NULL;
     uint64_t val[2];
     uint32_t val32[2];
     unsigned long remaining;
-    unsigned long rma_reserve = 4 * PAGE_SIZE;
+    unsigned long rma_reserve = 3 * PAGE_SIZE;

base this on MIN(store, console)

     unsigned long initrd_end = initrd_base + initrd_len;
     int64_t shadow_mb_log;
     uint64_t pft_size;
@@ -332,6 +335,9 @@ int make_devtree(struct ft_cxt *root,
     char *cpuname = NULL;
     int saved_errno;
     int dtb_fd = -1;
+    uint64_t shared_info_addr = (rma_bytes - PAGE_SIZE);
+    uint64_t store_mfn = (rma_bytes - (2*PAGE_SIZE)) >> PAGE_SHIFT;
+    uint64_t console_mfn = (rma_bytes - (3*PAGE_SIZE)) >> PAGE_SHIFT;

as above.. not MFNs

     uint32_t cpu0_phandle = get_phandle();
     uint32_t xen_phandle = get_phandle();
     uint32_t rma_phandle = get_phandle();
@@ -419,11 +425,6 @@ int make_devtree(struct ft_cxt *root,
     /* xen = root.addnode('xen') */
     ft_begin_node(root, "xen");

-    /* start-info is the first page in the RMA reserved area */
-    val[0] = cpu_to_be64((u64) (rma_bytes - rma_reserve));
-    val[1] = cpu_to_be64((u64) PAGE_SIZE);
-    ft_prop(root, "start-info", val, sizeof(val));
-
     /*  xen.addprop('version', 'Xen-3.0-unstable\0') */
     ft_prop_str(root, "version", "Xen-3.0-unstable");

This property should be called "compatible"


@@ -432,6 +433,11 @@ int make_devtree(struct ft_cxt *root,
     val[1] = cpu_to_be64((u64) 0);
     ft_prop(root, "reg", val, sizeof(val));

+    /* point to shared_info_t page base addr */
+    val[0] = cpu_to_be64((u64) shared_info_addr);
+    val[1] = cpu_to_be64((u64) PAGE_SIZE);
+    ft_prop(root, "shared-info", val, sizeof(val));
+
     /* xen.addprop('domain-name', imghandler.vm.getName() + '\0') */
/* libxc doesn't know the domain name, that is purely a xend thing */
     /* ft_prop_str(root, "domain-name", domain_name); */
@@ -442,12 +448,33 @@ int make_devtree(struct ft_cxt *root,
     /* xencons = xen.addnode('console') */
     ft_begin_node(root, "console");

-    /* xencons.addprop('interrupts', 1, 0) */
-    val32[0] = cpu_to_be32((u32) 1);
+    /* console_mfn */
+    val[0] = cpu_to_be64((u64) console_mfn);
address

+    val[1] = cpu_to_be64((u64) PAGE_SIZE);
+    ft_prop(root, "reg", val, sizeof(val));
+
+    /* xencons.addprop('interrupts', console_evtchn, 0) */
+    val32[0] = cpu_to_be32((u32) console_evtchn);
     val32[1] = cpu_to_be32((u32) 0);
     ft_prop(root, "interrupts", val32, sizeof(val32));

     /* end of console */
+    ft_end_node(root);
+
+    /* start store node */
+    ft_begin_node(root, "store");
+
+    /* store_mfn */
+    val[0] = cpu_to_be64((u64) store_mfn);
address
+    val[1] = cpu_to_be64((u64) PAGE_SIZE);
+    ft_prop(root, "reg", val, sizeof(val));
+
+    /* store event channel */
+    val32[0] = cpu_to_be32((u32) store_evtchn);
+    val32[1] = cpu_to_be32((u32) 0);
+    ft_prop(root, "interrupts", val32, sizeof(val32));
+
+    /* end of store */
     ft_end_node(root);

     /* end of xen node */
diff -r ed5ee9dde0bd tools/libxc/powerpc64/mk_flatdevtree.h
--- a/tools/libxc/powerpc64/mk_flatdevtree.h Sun Jan 21 08:17:46 2007 -0500 +++ b/tools/libxc/powerpc64/mk_flatdevtree.h Thu Jan 25 11:27:58 2007 -0600
@@ -32,8 +32,10 @@ extern int make_devtree(struct ft_cxt *r
                         unsigned long shadow_mb,
                         unsigned long initrd_base,
                         unsigned long initrd_len,
-                        const char *bootargs);
-
+                        const char *bootargs,
+                        unsigned long console_evtchn,
+                        unsigned long store_evtchn,
+                        unsigned long nr_pages);
 #define MAX_PATH 200
 #define BUFSIZE 1024
 #define BPH_SIZE 16*1024
diff -r ed5ee9dde0bd tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c Sun Jan 21 08:17:46 2007 -0500 +++ b/tools/libxc/powerpc64/xc_linux_build.c Thu Jan 25 11:27:58 2007 -0600
@@ -109,34 +109,6 @@ out:
     return rc;
 }

-static unsigned long create_start_info(
-        start_info_t *start_info,
-        unsigned int console_evtchn,
-        unsigned int store_evtchn,
-        unsigned long nr_pages,
-        unsigned long rma_pages)
-{
-    unsigned long start_info_addr;
-    uint64_t rma_top;
-
-    memset(start_info, 0, sizeof(*start_info));
-    snprintf(start_info->magic, sizeof(start_info->magic),
-             "xen-%d.%d-powerpc64HV", 3, 0);
-
-    rma_top = rma_pages << PAGE_SHIFT;
-    DPRINTF("RMA top = 0x%"PRIX64"\n", rma_top);
-
-    start_info->nr_pages = nr_pages;
-    start_info->shared_info = rma_top - PAGE_SIZE;
-    start_info->store_mfn = (rma_top >> PAGE_SHIFT) - 2;
-    start_info->store_evtchn = store_evtchn;
-    start_info->console.domU.mfn = (rma_top >> PAGE_SHIFT) - 3;
-    start_info->console.domU.evtchn = console_evtchn;
-    start_info_addr = rma_top - 4*PAGE_SIZE;
-
-    return start_info_addr;
-}
-
 static void free_page_array(xen_pfn_t *page_array)
 {
     free(page_array);
@@ -191,7 +163,6 @@ int xc_linux_build(int xc_handle,
                    unsigned int console_evtchn,
                    unsigned long *console_mfn)
 {
-    start_info_t start_info;
     struct domain_setup_info dsi;
     xen_pfn_t *page_array = NULL;
     unsigned long nr_pages;
@@ -199,7 +170,6 @@ int xc_linux_build(int xc_handle,
     unsigned long kern_addr;
     unsigned long initrd_base = 0;
     unsigned long initrd_len = 0;
-    unsigned long start_info_addr;
     unsigned long rma_pages;
     unsigned long shadow_mb;
     u32 remaining_kb;
@@ -208,7 +178,9 @@ int xc_linux_build(int xc_handle,
     int rma_log = 26;  /* 64MB RMA */
     int rc = 0;
     int op;
+    void *node;
     struct ft_cxt devtree;
+    u64 val;

     DPRINTF("%s\n", __func__);

@@ -283,23 +255,48 @@ int xc_linux_build(int xc_handle,

     /* build the devtree here */
     DPRINTF("constructing devtree\n");
- if (make_devtree(&devtree, domid, mem_mb, (rma_pages*PAGE_SIZE), shadow_mb,
-                     initrd_base, initrd_len, cmdline) < 0) {
+ if (make_devtree(&devtree, domid, mem_mb, (rma_pages << 12), shadow_mb, + initrd_base, initrd_len, cmdline, console_evtchn,
+                     store_evtchn, nr_pages) < 0) {
         DPRINTF("failed to create flattened device tree\n");
         rc = -1;
         goto out;
     }
-
-    /* start_info stuff: about to be removed  */
-    start_info_addr = create_start_info(&start_info, console_evtchn,
- store_evtchn, nr_pages, rma_pages);
-    *console_mfn = page_array[start_info.console.domU.mfn];
-    *store_mfn = page_array[start_info.store_mfn];
-    if (install_image(xc_handle, domid, page_array, &start_info,
-                      start_info_addr, sizeof(start_info_t))) {
-        rc = -1;
-        goto out;
-    }
+
+    /* fetch console_mfn from devtree stored in /xen/console/reg */
+    node = ft_find_node((void *)devtree.bph, "/xen/console");
+    if (node == NULL) {
+        DPRINTF("failed to find /xen/console in devtree\n");
+        rc = -1;
+        goto out;
+    }
+
+    if (ft_get_prop((void *)devtree.bph, node, "reg",
+                    &val, sizeof(val)) < 0) {
+        DPRINTF("failed to get /xen/console/reg property\n");
+        rc = -1;
+        goto out;
+    }
+    *console_mfn = page_array[(xen_pfn_t)val];
+
+    /* fetch store_mfn from devtree stored in /xen/store/reg */
+    node = ft_find_node((void *)devtree.bph, "/xen/store");
+    if (node == NULL) {
+        DPRINTF("failed to find /xen/store in devtree\n");
+        rc = -1;
+        goto out;
+    }
+
+    if (ft_get_prop((void *)devtree.bph, node, "reg",
+                    &val, sizeof(val)) < 0) {
+        DPRINTF("failed to get '/xen/store/reg' property\n");
+        rc = -1;
+        goto out;
+    }
+    *store_mfn = page_array[(xen_pfn_t)val];
+
+    DPRINTF("console_mfn->%08lx store_mfn->%08lx\n", *console_mfn,
+            *store_mfn);

     devtree_addr = DEVTREE_ADDR;
     DPRINTF("loading flattened device tree to 0x%lx[0x%x]\n",


_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@lists.xensource.com
http://lists.xensource.com/xen-ppc-devel

Reply via email to