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] Fix domU device tree creation for JS20/1

To: Maria Butrico <butrico@xxxxxxxxxxxxxx>
Subject: Re: [XenPPC] [PATCH] Fix domU device tree creation for JS20/1
From: Hollis Blanchard <hollisb@xxxxxxxxxx>
Date: Tue, 22 Aug 2006 11:31:21 -0500
Cc: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 22 Aug 2006 09:31:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <E1GFJHa-00067s-ID@xxxxxxxxxxxxxxxxxxxxx>
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>
Organization: IBM Linux Technology Center
References: <E1GFJHa-00067s-ID@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Mon, 2006-08-21 at 19:34 -0400, Maria Butrico wrote:
> Summary:  Fix device tree creation for domU for js20/1 under SLOF
> 
> The device tree of dom0 on js20 and js21 with SLOF does not have the cpus'
> d and i cache sets nor does it have the l2 cache subdirectory.  

Hi Maria, please try this patch. It's a little noisy (I made printing
work for better debugging), but if it works for you I'll split it up and
check it in.

Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>

diff -r 6eccd4911e6c tools/python/xen/xend/FlatDeviceTree.py
--- a/tools/python/xen/xend/FlatDeviceTree.py   Tue Aug 22 11:17:09 2006 -0400
+++ b/tools/python/xen/xend/FlatDeviceTree.py   Tue Aug 22 11:22:24 2006 -0500
@@ -20,8 +20,10 @@ import os
 import os
 import sys
 import struct
-
-_OF_DT_HEADER = 0xd00dfeed
+import stat
+import re
+
+_OF_DT_HEADER = int("d00dfeed", 16) # avoid signed/unsigned FutureWarning
 _OF_DT_BEGIN_NODE = 0x1
 _OF_DT_END_NODE = 0x2
 _OF_DT_PROP = 0x3
@@ -50,12 +52,40 @@ def _pad(buf, alignment):
     # 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) \
@@ -68,6 +98,12 @@ class _Node:
         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)
@@ -203,6 +239,22 @@ def _getprop(propname):
     f.close()
     return data
 
+def _copynode(node, dirpath, propfilter):
+    '''Extract all properties from a node in the system's device 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)
+            _copytree(child, fullpath, propfilter)
+        elif stat.S_ISREG(st.st_mode) and propfilter(fullpath):
+            node.addprop(dirent, _getprop(fullpath))
+
+def _copytree(node, dirpath, propfilter):
+    path = os.path.join(_host_devtree_root, dirpath)
+    _copynode(node, path, propfilter)
+
 def build(imghandler):
     '''Construct a device tree by combining the domain's configuration and
     the host's device tree.'''
@@ -236,33 +288,20 @@ def build(imghandler):
     cpus.addprop('#size-cells', 0)
     cpus.addprop('#address-cells', 1)
 
-    # create a cpu node for each vcpu
+    # Copy all properties the system firmware gave us, except for 'linux,'
+    # properties, from 'cpus/@0', once for every vcpu. Hopefully all cpus are
+    # identical...
     cpu0 = None
+    def _nolinuxprops(fullpath):
+        if os.path.basename(fullpath).startswith('linux,'):
+            return False
+        return True
     for i in range(imghandler.vm.getVCpuCount()):
         cpu = cpus.addnode('PowerPC,970@0')
+        _copytree(cpu, 'cpus/PowerPC,970@0', _nolinuxprops)
+        # and then overwrite what we need to
         pft_size = imghandler.vm.info.get('pft-size', 0x14)
-        cpu.addprop('ibm,pft-size', 0, pft_size)
-        cpu.addprop('reg', i)
-        cpu.addprop('cpu#', i)
-        cpu.addprop('device_type', 'cpu\0')
-        for prop in ('d-cache-size', 'd-cache-line-size', 'd-cache-sets',
-                     'i-cache-size', 'i-cache-line-size', 'i-cache-sets',
-                     'clock-frequency', 'timebase-frequency',
-                     'timebases-in-sync'):
-            val = _getprop(os.path.join('cpus/PowerPC,970@0', prop))
-            cpu.addprop(prop, val)
-            # XXX 64-bit, more
-
-        # L2 cache
-        l2 = cpu.addnode('l2-cache')
-        l2.addprop('name', 'l2-cache\0')
-        l2.addprop('device_type', 'cache\0')
-        for prop in ('d-cache-size', 'd-cache-sets',
-                     'i-cache-size', 'i-cache-sets',
-                     'cache-unified'):
-            fullprop = os.path.join('cpus/PowerPC,970@%d/l2-cache' % i, prop)
-            val = _getprop(fullprop)
-            l2.addprop(prop, val)
+        cpu.setprop('ibm,pft-size', 0, pft_size)
 
         # set default CPU
         if cpu0 == None:


-- 
Hollis Blanchard
IBM Linux Technology Center


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

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