# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Node ID b985b2e85bf343f136ec2ceb55176edb62832f81
# Parent e0973ea10547390bb50722d7622edf5adb2e47de
[XEND][POWERPC] copy all cpu properties from system device tree
- fixes problem with newer versions of SLOF firmware, which don't export all
the properties older versions did
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
tools/python/xen/xend/FlatDeviceTree.py | 48 ++++++++++++++++----------------
1 files changed, 25 insertions(+), 23 deletions(-)
diff -r e0973ea10547 -r b985b2e85bf3 tools/python/xen/xend/FlatDeviceTree.py
--- a/tools/python/xen/xend/FlatDeviceTree.py Tue Aug 22 14:44:11 2006 -0500
+++ b/tools/python/xen/xend/FlatDeviceTree.py Tue Aug 22 14:51:26 2006 -0500
@@ -20,6 +20,7 @@ import os
import os
import sys
import struct
+import stat
import re
_OF_DT_HEADER = int("d00dfeed", 16) # avoid signed/unsigned FutureWarning
@@ -238,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.'''
@@ -271,33 +288,18 @@ 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):
+ return not os.path.basename(fullpath).startswith('linux,'):
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:
_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel
|