WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ppc-devel

Re: [XenPPC] [PATCH 4 of 4] [PATCH] Remove FlatDeviceTree.py, move prose

To: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
Subject: Re: [XenPPC] [PATCH 4 of 4] [PATCH] Remove FlatDeviceTree.py, move prose builder to libxc devtree construction
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Thu, 11 Jan 2007 15:19:43 -0600
Cc: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 11 Jan 2007 13:19:23 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <1B7FF96A-0462-4903-B8E6-8102FCF3DFF2@xxxxxxxxxxxxxx>
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
References: <a2ff54d361f5853ff83a.1168544526@xxxxxxxxxxxxxxxxxxxxx> <1B7FF96A-0462-4903-B8E6-8102FCF3DFF2@xxxxxxxxxxxxxx>
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
* Jimi Xenidis <jimix@xxxxxxxxxxxxxx> [2007-01-11 15:11]:
> Straight off, prose should have no flat tree reference at all.

Respun with devtree refs excised.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@xxxxxxxxxx

diffstat output:
 a/tools/python/xen/xend/FlatDeviceTree.py |  359 ------------------------------
 tools/libxc/powerpc64/xc_prose_build.c    |  125 ----------
 tools/libxc/xenguest.h                    |    3 
 tools/python/xen/lowlevel/xc/xc.c         |   12 -
 tools/python/xen/xend/image.py            |    6 
 5 files changed, 17 insertions(+), 488 deletions(-)

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
---
[PATCH] Remove FlatDeviceTree.py, eliminate devtree from prose builder.

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>

diff -r e4fda6c5e7a9 tools/libxc/powerpc64/xc_prose_build.c
--- a/tools/libxc/powerpc64/xc_prose_build.c    Thu Jan 11 13:39:27 2007 -0600
+++ b/tools/libxc/powerpc64/xc_prose_build.c    Thu Jan 11 15:15:50 2007 -0600
@@ -13,7 +13,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- * Copyright (C) IBM Corporation 2006
+ * Copyright IBM Corporation 2006
  *
  * Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
  *          Jonathan Appavoo <jappavoo@xxxxxxxxxx>
@@ -34,18 +34,14 @@
 #include <xg_private.h>
 #include <xenctrl.h>
 
-#include "flatdevtree_env.h"
-#include "flatdevtree.h"
 #include "utils.h"
 
 #define INITRD_ADDR (24UL << 20)
-#define DEVTREE_ADDR (16UL << 20)
 
 static int init_boot_vcpu(
     int xc_handle,
     int domid,
     struct domain_setup_info *dsi,
-    unsigned long devtree_addr,
     unsigned long kern_addr)
 {
     vcpu_guest_context_t ctxt;
@@ -55,7 +51,7 @@ static int init_boot_vcpu(
     ctxt.user_regs.pc = dsi->v_kernentry;
     ctxt.user_regs.msr = 0;
     ctxt.user_regs.gprs[1] = 0; /* Linux uses its own stack */
-    ctxt.user_regs.gprs[3] = devtree_addr;
+    ctxt.user_regs.gprs[3] = 0;
     ctxt.user_regs.gprs[4] = kern_addr;
     ctxt.user_regs.gprs[5] = 0; /* reserved for specifying OF handler */
     /* There is a buggy kernel that does not zero the "local_paca", so
@@ -79,85 +75,6 @@ static int init_boot_vcpu(
     return rc;
 }
 
-static int load_devtree(
-    int xc_handle,
-    int domid,
-    xen_pfn_t *page_array,
-    void *devtree,
-    unsigned long devtree_addr,
-    uint64_t initrd_base,
-    unsigned long initrd_len,
-    start_info_t *start_info __attribute__((unused)),
-    unsigned long start_info_addr)
-{
-    uint32_t si[4] = {0, start_info_addr, 0, 0x1000};
-    struct boot_param_header *header;
-    void *chosen;
-    void *xen;
-    uint64_t initrd_end = initrd_base + initrd_len;
-    unsigned int devtree_size;
-    int rc = 0;
-
-    DPRINTF("adding initrd props\n");
-
-    chosen = ft_find_node(devtree, "/chosen");
-    if (chosen == NULL) {
-        DPRINTF("couldn't find /chosen\n");
-        return -1;
-    }
-
-    xen = ft_find_node(devtree, "/xen");
-    if (xen == NULL) {
-        DPRINTF("couldn't find /xen\n");
-        return -1;
-    }
-
-    /* initrd-start */
-    rc = ft_set_prop(&devtree, chosen, "linux,initrd-start",
-            &initrd_base, sizeof(initrd_base));
-    if (rc < 0) {
-        DPRINTF("couldn't set /chosen/linux,initrd-start\n");
-        return rc;
-    }
-
-    /* initrd-end */
-    rc = ft_set_prop(&devtree, chosen, "linux,initrd-end",
-            &initrd_end, sizeof(initrd_end));
-    if (rc < 0) {
-        DPRINTF("couldn't set /chosen/linux,initrd-end\n");
-        return rc;
-    }
-
-    rc = ft_set_rsvmap(devtree, 1, initrd_base, initrd_len);
-    if (rc < 0) {
-        DPRINTF("couldn't set initrd reservation\n");
-        return ~0UL;
-    }
-
-    /* start-info (XXX being removed soon) */
-    rc = ft_set_prop(&devtree, xen, "start-info", si, sizeof(si));
-    if (rc < 0) {
-        DPRINTF("couldn't set /xen/start-info\n");
-        return rc;
-    }
-
-    header = devtree;
-    devtree_size = header->totalsize;
-    {
-        static const char dtb[] = "/tmp/xc_domU.dtb";
-        int dfd = creat(dtb, 0666);
-        if (dfd != -1) {
-            write(dfd, devtree, devtree_size);
-            close(dfd);
-        } else
-            DPRINTF("could not open(\"%s\")\n", dtb);
-    }
-
-    DPRINTF("copying device tree to 0x%lx[0x%x]\n", DEVTREE_ADDR, 
devtree_size);
-    return install_image(xc_handle, domid, page_array, devtree, DEVTREE_ADDR,
-                       devtree_size);
-}
-
 static int load_initrd(
     int xc_handle,
     int domid,
@@ -188,7 +105,7 @@ out:
 }
 
 static unsigned long create_start_info(
-       void *devtree, start_info_t *start_info,
+       start_info_t *start_info,
         unsigned int console_evtchn, unsigned int store_evtchn,
        unsigned long nr_pages, unsigned long rma_pages, const char *cmdline)
 {
@@ -213,12 +130,6 @@ static unsigned long create_start_info(
     /* just in case we truncated cmdline with strncpy add 0 at the end */
     start_info->cmd_line[MAX_GUEST_CMDLINE-1]=0;
     start_info_addr = rma_top - 4*PAGE_SIZE;
-
-    rc = ft_set_rsvmap(devtree, 0, start_info_addr, 4*PAGE_SIZE);
-    if (rc < 0) {
-        DPRINTF("couldn't set start_info reservation\n");
-        return ~0UL;
-    }
 
     return start_info_addr;
 }
@@ -239,14 +150,12 @@ int xc_prose_build(int xc_handle,
                    unsigned int store_evtchn,
                    unsigned long *store_mfn,
                    unsigned int console_evtchn,
-                   unsigned long *console_mfn,
-                   void *devtree)
+                   unsigned long *console_mfn)
 {
     start_info_t start_info;
     struct domain_setup_info dsi;
     xen_pfn_t *page_array = NULL;
     unsigned long nr_pages;
-    unsigned long devtree_addr = 0;
     unsigned long kern_addr;
     unsigned long initrd_base = 0;
     unsigned long initrd_len = 0;
@@ -261,11 +170,9 @@ int xc_prose_build(int xc_handle,
     nr_pages = mem_mb << (20 - PAGE_SHIFT);
     DPRINTF("nr_pages 0x%lx\n", nr_pages);
 
-    rma_pages = get_rma_pages(devtree);
-    if (rma_pages == 0) {
-           rc = -1;
-           goto out;
-    }
+    }
+
+    rma_pages = 1 << 26; /* 64 MB */
 
     if (get_rma_page_array(xc_handle, domid, &page_array, rma_pages)) {
         rc = -1;
@@ -289,9 +196,9 @@ int xc_prose_build(int xc_handle,
     }
 
     /* start_info stuff: about to be removed  */
-    start_info_addr = create_start_info(devtree, &start_info, console_evtchn,
+    start_info_addr = create_start_info(&start_info, console_evtchn,
                                         store_evtchn, nr_pages,
-                                       rma_pages, cmdline);
+                                        rma_pages, cmdline);
     *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,
@@ -300,19 +207,7 @@ int xc_prose_build(int xc_handle,
         goto out;
     }
 
-    if (devtree) {
-        DPRINTF("loading flattened device tree\n");
-        devtree_addr = DEVTREE_ADDR;
-        if (load_devtree(xc_handle, domid, page_array, devtree, devtree_addr,
-                         initrd_base, initrd_len, &start_info,
-                         start_info_addr)) {
-            DPRINTF("couldn't load flattened device tree.\n");
-            rc = -1;
-            goto out;
-        }
-    }
-
-    if (init_boot_vcpu(xc_handle, domid, &dsi, devtree_addr, kern_addr)) {
+    if (init_boot_vcpu(xc_handle, domid, &dsi, kern_addr)) {
         rc = -1;
         goto out;
     }
diff -r e4fda6c5e7a9 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.h    Thu Jan 11 13:39:27 2007 -0600
+++ b/tools/libxc/xenguest.h    Thu Jan 11 13:39:27 2007 -0600
@@ -138,7 +138,6 @@ int xc_prose_build(int xc_handle,
                    unsigned int store_evtchn,
                    unsigned long *store_mfn,
                    unsigned int console_evtchn,
-                   unsigned long *console_mfn,
-                   void *arch_args);
+                   unsigned long *console_mfn);
 
 #endif /* XENGUEST_H */
diff -r e4fda6c5e7a9 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Thu Jan 11 13:39:27 2007 -0600
+++ b/tools/python/xen/lowlevel/xc/xc.c Thu Jan 11 13:39:27 2007 -0600
@@ -378,28 +378,26 @@ static PyObject *pyxc_prose_build(XcObje
     unsigned int mem_mb;
     unsigned long store_mfn = 0;
     unsigned long console_mfn = 0;
-    void *arch_args = NULL;
     int unused;
 
     static char *kwd_list[] = { "dom", "store_evtchn", "memsize",
                                 "console_evtchn", "image",
                                 /* optional */
                                 "ramdisk", "cmdline", "flags",
-                                "features", "arch_args", NULL };
-
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssiss#", kwd_list,
+                                "features", NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis#", kwd_list,
                                       &dom, &store_evtchn, &mem_mb,
                                       &console_evtchn, &image,
                                       /* optional */
                                       &ramdisk, &cmdline, &flags,
-                                      &features, &arch_args, &unused) )
+                                      &features, &unused) )
         return NULL;
 
     if ( xc_prose_build(self->xc_handle, dom, mem_mb, image,
                         ramdisk, cmdline, features, flags,
                         store_evtchn, &store_mfn,
-                        console_evtchn, &console_mfn,
-                        arch_args) != 0 ) {
+                        console_evtchn, &console_mfn) != 0 ) {
         if (!errno)
              errno = EINVAL;
         return PyErr_SetFromErrno(xc_error);
diff -r e4fda6c5e7a9 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Thu Jan 11 13:39:27 2007 -0600
+++ b/tools/python/xen/xend/image.py    Thu Jan 11 13:39:27 2007 -0600
@@ -29,7 +29,6 @@ from xen.xend.server.netif import random
 from xen.xend.server.netif import randomMAC
 from xen.xend.xenstore.xswatch import xswatch
 from xen.xend import arch
-from xen.xend import FlatDeviceTree
 
 
 xc = xen.lowlevel.xc.xc()
@@ -276,8 +275,6 @@ class PPC_ProseImageHandler(LinuxImageHa
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
         log.debug("features       = %s", self.vm.getFeatures())
 
-        devtree = FlatDeviceTree.build(self)
-
         return xc.prose_build(dom            = self.vm.getDomid(),
                               memsize        = mem_mb,
                               image          = self.kernel,
@@ -285,8 +282,7 @@ class PPC_ProseImageHandler(LinuxImageHa
                               console_evtchn = console_evtchn,
                               cmdline        = self.cmdline,
                               ramdisk        = self.ramdisk,
-                              features       = self.vm.getFeatures(),
-                              arch_args      = devtree.to_bin())
+                              features       = self.vm.getFeatures())
 
     def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
         """@param shadow_mem_kb The configured shadow memory, in KiB.
diff -r e4fda6c5e7a9 tools/python/xen/xend/FlatDeviceTree.py
--- a/tools/python/xen/xend/FlatDeviceTree.py   Thu Jan 11 13:39:27 2007 -0600
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,359 +0,0 @@
-#!/usr/bin/env python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of version 2.1 of the GNU Lesser General Public
-# License as published by the Free Software Foundation.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-#
-# Copyright (C) IBM Corp. 2006
-#
-# Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
-
-import os
-import sys
-import struct
-import stat
-import re
-import glob
-import math
-
-_host_devtree_root = '/proc/device-tree'
-
-_OF_DT_HEADER = int("d00dfeed", 16) # avoid signed/unsigned FutureWarning
-_OF_DT_BEGIN_NODE = 0x1
-_OF_DT_END_NODE = 0x2
-_OF_DT_PROP = 0x3
-_OF_DT_END = 0x9
-
-def _bincat(seq, separator=''):
-    '''Concatenate the contents of seq into a bytestream.'''
-    strs = []
-    for item in seq:
-        if isinstance(item, int):
-            strs.append(struct.pack(">I", item))
-        elif isinstance(item, long):
-            strs.append(struct.pack(">Q", item))
-        else:
-            try:
-                strs.append(item.to_bin())
-            except AttributeError, e:
-                strs.append(item)
-    return separator.join(strs)
-
-def _alignup(val, alignment):
-    return (val + alignment - 1) & ~(alignment - 1)
-
-def _pad(buf, alignment):
-    '''Pad bytestream with NULLs to specified alignment.'''
-    padlen = _alignup(len(buf), alignment)
-    return buf + '\0' * (padlen - len(buf))
-    # not present in Python 2.3:
-    #return buf.ljust(_padlen, '\0')
-
-def _indent(item):
-    indented = []
-    for line in str(item).splitlines(True):
-        indented.append('    ' + line)
-    return ''.join(indented)
-
-class _Property:
-    _nonprint = re.compile('[\000-\037\200-\377]')
-    def __init__(self, node, name, value):
-        self.node = node
-        self.value = value
-        self.name = name
-        self.node.tree.stradd(name)
-
-    def __str__(self):
-        result = self.name
-        if self.value:
-            searchtext = self.value
-            # it's ok for a string to end in NULL
-            if searchtext.find('\000') == len(searchtext)-1:
-                searchtext = searchtext[:-1]
-            m = self._nonprint.search(searchtext)
-            if m:
-                bytes = struct.unpack("B" * len(self.value), self.value)
-                hexbytes = [ '%02x' % b for b in bytes ]
-                words = []
-                for i in range(0, len(self.value), 4):
-                    words.append(''.join(hexbytes[i:i+4]))
-                v = '<' + ' '.join(words) + '>'
-            else:
-                v = '"%s"' % self.value
-            result += ': ' + v
-        return result
-
-    def to_bin(self):
-        offset = self.node.tree.stroffset(self.name)
-        return struct.pack('>III', _OF_DT_PROP, len(self.value), offset) \
-            + _pad(self.value, 4)
-
-class _Node:
-    def __init__(self, tree, name):
-        self.tree = tree
-        self.name = name
-        self.props = {}
-        self.children = {}
-        self.phandle = 0
-
-    def __str__(self):
-        propstrs = [ _indent(prop) for prop in self.props.values() ]
-        childstrs = [ _indent(child) for child in self.children.values() ]
-        return '%s:\n%s\n%s' % (self.name, '\n'.join(propstrs),
-            '\n'.join(childstrs))
-
-    def to_bin(self):
-        name = _pad(self.name + '\0', 4)
-        return struct.pack('>I', _OF_DT_BEGIN_NODE) + \
-                name + \
-                _bincat(self.props.values()) + \
-                _bincat(self.children.values()) + \
-                struct.pack('>I', _OF_DT_END_NODE)
-
-    def addprop(self, propname, *cells):
-        '''setprop with duplicate error-checking.'''
-        if propname in self.props:
-            raise AttributeError('%s/%s already exists' % (self.name, 
propname))
-        self.setprop(propname, *cells)
-
-    def setprop(self, propname, *cells):
-        self.props[propname] = _Property(self, propname, _bincat(cells))
-
-    def addnode(self, nodename):
-        '''newnode with duplicate error-checking.'''
-        if nodename in self.children:
-            raise AttributeError('%s/%s already exists' % (self.name, 
nodename))
-        return self.newnode(nodename)
-
-    def newnode(self, nodename):
-        node = _Node(self.tree, nodename)
-        self.children[nodename] = node
-        return node
-
-    def getprop(self, propname):
-        return self.props[propname]
-
-    def getchild(self, nodename):
-        return self.children[nodename]
-
-    def get_phandle(self):
-        if self.phandle:
-            return self.phandle
-        self.phandle = self.tree.alloc_phandle()
-        self.addprop('linux,phandle', self.phandle)
-        return self.phandle
-
-class _Header:
-    def __init__(self):
-        self.magic = 0
-        self.totalsize = 0
-        self.off_dt_struct = 0
-        self.off_dt_strings = 0
-        self.off_mem_rsvmap = 0
-        self.version = 0
-        self.last_comp_version = 0
-        self.boot_cpuid_phys = 0
-        self.size_dt_strings = 0
-    def to_bin(self):
-        return struct.pack('>9I',
-            self.magic,
-            self.totalsize,
-            self.off_dt_struct,
-            self.off_dt_strings,
-            self.off_mem_rsvmap,
-            self.version,
-            self.last_comp_version,
-            self.boot_cpuid_phys,
-            self.size_dt_strings)
-
-class _StringBlock:
-    def __init__(self):
-        self.table = []
-    def to_bin(self):
-        return _bincat(self.table, '\0') + '\0'
-    def add(self, str):
-        self.table.append(str)
-    def getoffset(self, str):
-        return self.to_bin().index(str + '\0')
-
-class Tree(_Node):
-    def __init__(self):
-        self.last_phandle = 0
-        self.strings = _StringBlock()
-        self.reserved = [(0, 0)]
-        _Node.__init__(self, self, '\0')
-
-    def alloc_phandle(self):
-        self.last_phandle += 1
-        return self.last_phandle
-
-    def stradd(self, str):
-        return self.strings.add(str)
-
-    def stroffset(self, str):
-        return self.strings.getoffset(str)
-
-    def reserve(self, start, len):
-        self.reserved.insert(0, (start, len))
-
-    def to_bin(self):
-        # layout:
-        #   header
-        #   reservation map
-        #   string block
-        #   data block
-
-        datablock = _Node.to_bin(self)
-
-        r = [ struct.pack('>QQ', rsrv[0], rsrv[1]) for rsrv in self.reserved ]
-        reserved = _bincat(r)
-
-        strblock = _pad(self.strings.to_bin(), 4)
-        strblocklen = len(strblock)
-
-        header = _Header()
-        header.magic = _OF_DT_HEADER
-        header.off_mem_rsvmap = _alignup(len(header.to_bin()), 8)
-        header.off_dt_strings = header.off_mem_rsvmap + len(reserved)
-        header.off_dt_struct = header.off_dt_strings + strblocklen
-        header.version = 0x10
-        header.last_comp_version = 0x10
-        header.boot_cpuid_phys = 0
-        header.size_dt_strings = strblocklen
-
-        payload = reserved + \
-                strblock + \
-                datablock + \
-                struct.pack('>I', _OF_DT_END)
-        header.totalsize = len(payload) + _alignup(len(header.to_bin()), 8)
-        return _pad(header.to_bin(), 8) + payload
-
-def _readfile(fullpath):
-    '''Return full contents of a file.'''
-    f = file(fullpath, 'r')
-    data = f.read()
-    f.close()
-    return data
-
-def _find_first_cpu(dirpath):
-    '''Find the first node of type 'cpu' in a directory tree.'''
-    cpulist = glob.glob(os.path.join(dirpath, 'cpus', '*'))
-    for node in cpulist:
-        try:
-            data = _readfile(os.path.join(node, 'device_type'))
-        except IOError:
-            continue
-        if 'cpu' in data:
-            return node
-    raise IOError("couldn't find any CPU nodes under " + dirpath)
-
-def _copynode(node, dirpath, propfilter):
-    '''Copy all properties and children nodes from a directory tree.'''
-    dirents = os.listdir(dirpath)
-    for dirent in dirents:
-        fullpath = os.path.join(dirpath, dirent)
-        st = os.lstat(fullpath)
-        if stat.S_ISDIR(st.st_mode):
-            child = node.addnode(dirent)
-            _copynode(child, fullpath, propfilter)
-        elif stat.S_ISREG(st.st_mode) and propfilter(fullpath):
-            node.addprop(dirent, _readfile(fullpath))
-
-def build(imghandler):
-    '''Construct a device tree by combining the domain's configuration and
-    the host's device tree.'''
-    root = Tree()
-
-    # 1st reseravtion entry used for start_info, console, store, shared_info
-    root.reserve(0x3ffc000, 0x4000)
-
-    # 2nd reservation enrty used for initrd, later on when we load the
-    # initrd we may fill this in with zeroes which signifies the end
-    # of the reservation map.  So as to avoid adding a zero map now we
-    # put some bogus yet sensible numbers here.
-    root.reserve(0x1000000, 0x1000)
-
-    root.addprop('device_type', 'chrp-but-not-really\0')
-    root.addprop('#size-cells', 2)
-    root.addprop('#address-cells', 2)
-    root.addprop('model', 'Momentum,Maple-D\0')
-    root.addprop('compatible', 'Momentum,Maple\0')
-
-    xen = root.addnode('xen')
-    xen.addprop('start-info', long(0x3ffc000), long(0x1000))
-    xen.addprop('version', 'Xen-3.0-unstable\0')
-    xen.addprop('reg', long(imghandler.vm.domid), long(0))
-    xen.addprop('domain-name', imghandler.vm.getName() + '\0')
-    xencons = xen.addnode('console')
-    xencons.addprop('interrupts', 1, 0)
-
-    # add memory nodes
-    totalmem = imghandler.vm.getMemoryTarget() * 1024
-    rma_log = 26 ### imghandler.vm.info.get('powerpc_rma_log')
-    rma_bytes = 1 << rma_log
-
-    # RMA node
-    rma = root.addnode('memory@0')
-    rma.addprop('reg', long(0), long(rma_bytes))
-    rma.addprop('device_type', 'memory\0')
-
-    # all the rest in a single node
-    remaining = totalmem - rma_bytes
-    if remaining > 0:
-        mem = root.addnode('memory@1')
-        mem.addprop('reg', long(rma_bytes), long(remaining))
-        mem.addprop('device_type', 'memory\0')
-
-    # add CPU nodes
-    cpus = root.addnode('cpus')
-    cpus.addprop('smp-enabled')
-    cpus.addprop('#size-cells', 0)
-    cpus.addprop('#address-cells', 1)
-
-    # Copy all properties the system firmware gave us, except for 'linux,'
-    # properties, from the first CPU node in the device tree. Do this once for
-    # every vcpu. Hopefully all cpus are identical...
-    cpu0 = None
-    cpu0path = _find_first_cpu(_host_devtree_root)
-    def _nolinuxprops(fullpath):
-        return not os.path.basename(fullpath).startswith('linux,')
-    for i in range(imghandler.vm.getVCpuCount()):
-        # create new node and copy all properties
-        cpu = cpus.addnode('PowerPC,970@%d' % i)
-        _copynode(cpu, cpu0path, _nolinuxprops)
-
-        # overwrite what we need to
-        shadow_mb = imghandler.vm.info.get('shadow_memory', 1)
-        shadow_mb_log = int(math.log(shadow_mb, 2))
-        pft_size = shadow_mb_log + 20
-        cpu.setprop('ibm,pft-size', 0, pft_size)
-
-        # set default CPU
-        if cpu0 == None:
-            cpu0 = cpu
-
-    chosen = root.addnode('chosen')
-    chosen.addprop('cpu', cpu0.get_phandle())
-    chosen.addprop('memory', rma.get_phandle())
-    chosen.addprop('linux,stdout-path', '/xen/console\0')
-    chosen.addprop('interrupt-controller', xen.get_phandle())
-    chosen.addprop('bootargs', imghandler.cmdline + '\0')
-    # xc_linux_load.c will overwrite these 64-bit properties later
-    chosen.addprop('linux,initrd-start', long(0))
-    chosen.addprop('linux,initrd-end', long(0))
-
-    if 1:
-        f = file('/tmp/domU.dtb', 'w')
-        f.write(root.to_bin())
-        f.close()
-
-    return root

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

<Prev in Thread] Current Thread [Next in Thread>