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

[XenPPC] [xenppc-unstable] [XEND][POWERPC] nicely display flat device tr

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [xenppc-unstable] [XEND][POWERPC] nicely display flat device tree
From: Xen patchbot-xenppc-unstable <patchbot-xenppc-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Aug 2006 20:01:15 +0000
Delivery-date: Tue, 22 Aug 2006 13:04:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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>
Reply-to: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Node ID 7a77cf4a7428fff092aa94226ed29a6e333c56e7
# Parent  6eccd4911e6c084bcc3d8bc1de8bbdb6e343f132
[XEND][POWERPC] nicely display flat device tree
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
 tools/python/xen/xend/FlatDeviceTree.py |   35 ++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+)

diff -r 6eccd4911e6c -r 7a77cf4a7428 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 14:43:22 2006 -0500
@@ -20,6 +20,7 @@ import os
 import os
 import sys
 import struct
+import re
 
 _OF_DT_HEADER = 0xd00dfeed
 _OF_DT_BEGIN_NODE = 0x1
@@ -50,12 +51,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 +97,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)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [XenPPC] [xenppc-unstable] [XEND][POWERPC] nicely display flat device tree, Xen patchbot-xenppc-unstable <=