first cut at generating code.
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@938 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
bcdce3cfc7
commit
0d7f46d29e
|
@ -229,6 +229,8 @@ class partobj:
|
||||||
self.dir = dir
|
self.dir = dir
|
||||||
self.irq = 0
|
self.irq = 0
|
||||||
self.instance = partinstance + 1
|
self.instance = partinstance + 1
|
||||||
|
if (debug):
|
||||||
|
print "INSTANCE %d" % self.instance
|
||||||
partinstance = partinstance + 1
|
partinstance = partinstance + 1
|
||||||
self.devfn = 0
|
self.devfn = 0
|
||||||
self.private = 0
|
self.private = 0
|
||||||
|
@ -239,6 +241,9 @@ class partobj:
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
# add current child as my sibling,
|
# add current child as my sibling,
|
||||||
# me as the child.
|
# me as the child.
|
||||||
|
if (debug):
|
||||||
|
if (parent.children):
|
||||||
|
print "add %s (%d) as isbling" % (parent.children.dir, parent.children.instance)
|
||||||
self.siblings = parent.children
|
self.siblings = parent.children
|
||||||
parent.children = self
|
parent.children = self
|
||||||
else:
|
else:
|
||||||
|
@ -246,15 +251,21 @@ class partobj:
|
||||||
|
|
||||||
def dumpme(self, lvl):
|
def dumpme(self, lvl):
|
||||||
print "%d: type %s" % (lvl, self.type)
|
print "%d: type %s" % (lvl, self.type)
|
||||||
|
print "%d: instance %d" % (lvl, self.instance)
|
||||||
print "%d: dir %s" % (lvl,self.dir)
|
print "%d: dir %s" % (lvl,self.dir)
|
||||||
print "%d: parent %s" % (lvl,self.parent.type)
|
print "%d: parent %s" % (lvl,self.parent.type)
|
||||||
print "%d: parent dir %s" % (lvl,self.parent.dir)
|
print "%d: parent dir %s" % (lvl,self.parent.dir)
|
||||||
|
if (self.children):
|
||||||
|
print "%d: child %s" % (lvl, self.children.dir)
|
||||||
|
if (self.siblings):
|
||||||
|
print "%d: siblings %s" % (lvl, self.siblings.dir)
|
||||||
print "%d: initcode " % lvl
|
print "%d: initcode " % lvl
|
||||||
for i in self.initcode:
|
for i in self.initcode:
|
||||||
print " %s" % i
|
print " %s" % i
|
||||||
print "%d: registercode " % lvl
|
print "%d: registercode " % lvl
|
||||||
for i in self.registercode:
|
for i in self.registercode:
|
||||||
print " %s" % i
|
print " %s" % i
|
||||||
|
print "\n"
|
||||||
|
|
||||||
def gencode(self, file):
|
def gencode(self, file):
|
||||||
file.write("struct cdev dev%d = {\n" % self.instance)
|
file.write("struct cdev dev%d = {\n" % self.instance)
|
||||||
|
@ -602,7 +613,7 @@ def part(name, path, file):
|
||||||
dirstack.append(curdir)
|
dirstack.append(curdir)
|
||||||
curdir = os.path.join(treetop, 'src', name, path)
|
curdir = os.path.join(treetop, 'src', name, path)
|
||||||
newpart = partobj(curdir, curpart, name)
|
newpart = partobj(curdir, curpart, name)
|
||||||
print "Configuring PART %s" % name
|
print "Configuring PART %s, path %s\n" % (name,path)
|
||||||
if (debug):
|
if (debug):
|
||||||
print "PUSH part %s %s" % (name, curpart.dir)
|
print "PUSH part %s %s" % (name, curpart.dir)
|
||||||
pstack.push(curpart)
|
pstack.push(curpart)
|
||||||
|
@ -1157,9 +1168,10 @@ def dumptree(part, lvl):
|
||||||
part.dumpme(lvl)
|
part.dumpme(lvl)
|
||||||
# dump the siblings -- actually are there any? not sure
|
# dump the siblings -- actually are there any? not sure
|
||||||
# siblings are:
|
# siblings are:
|
||||||
kid = part
|
if (debug):
|
||||||
#print "First sibling is %d\n" % kid.siblings
|
print "DUMPTREE SIBLINGS are"
|
||||||
while (kid.siblings):
|
kid = part.siblings
|
||||||
|
while (kid):
|
||||||
kid.dumpme(lvl)
|
kid.dumpme(lvl)
|
||||||
kid = kid.siblings
|
kid = kid.siblings
|
||||||
# dump the kids
|
# dump the kids
|
||||||
|
@ -1177,6 +1189,8 @@ def gencode(part, file):
|
||||||
part.gencode(file)
|
part.gencode(file)
|
||||||
# dump the siblings -- actually are there any? not sure
|
# dump the siblings -- actually are there any? not sure
|
||||||
# dump the kids
|
# dump the kids
|
||||||
|
if (debug):
|
||||||
|
print "GENCODE KID is"
|
||||||
kid = part
|
kid = part
|
||||||
while (kid.siblings):
|
while (kid.siblings):
|
||||||
kid.gencode(file)
|
kid.gencode(file)
|
||||||
|
@ -1212,7 +1226,6 @@ if __name__=='__main__':
|
||||||
if (not parse('board', open(argv[1], 'r').read())):
|
if (not parse('board', open(argv[1], 'r').read())):
|
||||||
fatal("Error: Could not parse file")
|
fatal("Error: Could not parse file")
|
||||||
|
|
||||||
debug = 1
|
|
||||||
if (debug):
|
if (debug):
|
||||||
print "DEVICE TREE:"
|
print "DEVICE TREE:"
|
||||||
dumptree(root, 0)
|
dumptree(root, 0)
|
||||||
|
|
Loading…
Reference in New Issue