[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XenPPC] [xenppc-unstable] [merge] conflict
# HG changeset patch # User Jimi Xenidis <jimix@xxxxxxxxxxxxxx> # Node ID e06e2cca9f39d56344ec96b90ad4a2405b247996 # Parent f2527015891cfd68f4576a8c63d3ee60e99841e2 # Parent b985b2e85bf343f136ec2ceb55176edb62832f81 [merge] conflict --- tools/python/xen/xend/FlatDeviceTree.py | 87 ++++++++++++++++++++++---------- 1 files changed, 62 insertions(+), 25 deletions(-) diff -r f2527015891c -r e06e2cca9f39 tools/python/xen/xend/FlatDeviceTree.py --- a/tools/python/xen/xend/FlatDeviceTree.py Tue Aug 22 17:20:58 2006 -0400 +++ b/tools/python/xen/xend/FlatDeviceTree.py Tue Aug 22 17:26:36 2006 -0400 @@ -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,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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |