fixing trees.
Greg help me, I've screwed up the tree, things are in there more than once, dammit! screwup in partobj. git-svn-id: svn://svn.coreboot.org/coreboot/trunk@937 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
		@@ -219,9 +219,10 @@ class partobj:
 | 
				
			|||||||
		global partinstance
 | 
							global partinstance
 | 
				
			||||||
		if (debug):
 | 
							if (debug):
 | 
				
			||||||
			print "partobj dir %s parent %s type %s" %(dir,parent,type)
 | 
								print "partobj dir %s parent %s type %s" %(dir,parent,type)
 | 
				
			||||||
		self.children = []
 | 
							self.children = 0
 | 
				
			||||||
		self.initcode = []
 | 
							self.initcode = []
 | 
				
			||||||
		self.registercode = []
 | 
							self.registercode = []
 | 
				
			||||||
 | 
							# sibling is not a list. 
 | 
				
			||||||
		self.siblings = 0
 | 
							self.siblings = 0
 | 
				
			||||||
		self.type = type
 | 
							self.type = type
 | 
				
			||||||
		self.objects = []
 | 
							self.objects = []
 | 
				
			||||||
@@ -236,7 +237,10 @@ class partobj:
 | 
				
			|||||||
			if (debug):
 | 
								if (debug):
 | 
				
			||||||
				print "add to parent"
 | 
									print "add to parent"
 | 
				
			||||||
			self.parent   = parent
 | 
								self.parent   = parent
 | 
				
			||||||
			parent.children.append(self)
 | 
								# add current child as my sibling, 
 | 
				
			||||||
 | 
								# me as the child.
 | 
				
			||||||
 | 
								self.siblings = parent.children
 | 
				
			||||||
 | 
								parent.children = self
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			self.parent = self
 | 
								self.parent = self
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -252,18 +256,18 @@ class partobj:
 | 
				
			|||||||
		for i in self.registercode:
 | 
							for i in self.registercode:
 | 
				
			||||||
			print "  %s" % i
 | 
								print "  %s" % i
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def gencode(self):
 | 
						def gencode(self, file):
 | 
				
			||||||
		print "struct cdev dev%d = {" % self.instance
 | 
							file.write("struct cdev dev%d = {\n" % self.instance)
 | 
				
			||||||
		print "/* %s %s */" % (self.type, self.dir)
 | 
							file.write("/* %s %s */\n" % (self.type, self.dir))
 | 
				
			||||||
		print "  .devfn = %d" % self.devfn
 | 
							file.write("  .devfn = %d\n" % self.devfn)
 | 
				
			||||||
		if (self.siblings):
 | 
							if (self.siblings):
 | 
				
			||||||
			print "  .next = &dev%d" % self.sibling.instance
 | 
								file.write("  .next = &dev%d\n" % self.siblings.instance)
 | 
				
			||||||
		if (self.children):
 | 
							if (self.children):
 | 
				
			||||||
			print "  .children = &dev%d" %  \
 | 
								file.write("  .children = &dev%d\n" % \
 | 
				
			||||||
					self.children[0].instance
 | 
										self.children.instance)
 | 
				
			||||||
		if (self.private):
 | 
							if (self.private):
 | 
				
			||||||
			print "  .private = private%d" % self.instance
 | 
								file.write("  .private = private%d\n" % self.instance)
 | 
				
			||||||
		print "};"
 | 
							file.write("};\n")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	def irq(self, irq):
 | 
						def irq(self, irq):
 | 
				
			||||||
@@ -1152,25 +1156,36 @@ def dumptree(part, lvl):
 | 
				
			|||||||
		print "DUMPTREE ME is"
 | 
							print "DUMPTREE ME is"
 | 
				
			||||||
	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:
 | 
				
			||||||
 | 
						kid = part
 | 
				
			||||||
 | 
						#print "First sibling is %d\n" % kid.siblings
 | 
				
			||||||
 | 
						while (kid.siblings):
 | 
				
			||||||
 | 
							kid.dumpme(lvl)
 | 
				
			||||||
 | 
							kid = kid.siblings
 | 
				
			||||||
	# dump the kids
 | 
						# dump the kids
 | 
				
			||||||
	if (debug):
 | 
						if (debug):
 | 
				
			||||||
		print "DUMPTREE KIDS are"
 | 
							print "DUMPTREE KIDS are"
 | 
				
			||||||
	for kid in part.children:
 | 
						#for kid in part.children:
 | 
				
			||||||
		dumptree(kid, lvl+1)
 | 
						if (part.children):
 | 
				
			||||||
 | 
							dumptree(part.children, lvl+1)
 | 
				
			||||||
	if (debug):
 | 
						if (debug):
 | 
				
			||||||
		print "DONE DUMPTREE"
 | 
							print "DONE DUMPTREE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def gencode(part):
 | 
					def gencode(part, file):
 | 
				
			||||||
	if (debug):
 | 
						if (debug):
 | 
				
			||||||
		print "GENCODE ME is"
 | 
							print "GENCODE ME is"
 | 
				
			||||||
	if (debug):
 | 
						part.gencode(file)
 | 
				
			||||||
		part.gencode()
 | 
					 | 
				
			||||||
	# dump the siblings -- actually are there any? not sure
 | 
						# dump the siblings -- actually are there any? not sure
 | 
				
			||||||
	# dump the kids
 | 
						# dump the kids
 | 
				
			||||||
 | 
						kid = part
 | 
				
			||||||
 | 
						while (kid.siblings):
 | 
				
			||||||
 | 
							kid.gencode(file)
 | 
				
			||||||
 | 
							kid = kid.siblings
 | 
				
			||||||
	if (debug):
 | 
						if (debug):
 | 
				
			||||||
		print "GENCODE KIDS are"
 | 
							print "GENCODE KIDS are"
 | 
				
			||||||
	for kid in part.children:
 | 
						#for kid in part.children:
 | 
				
			||||||
		gencode(kid)
 | 
						if (part.children):
 | 
				
			||||||
 | 
							gencode(part.children, file)
 | 
				
			||||||
	if (debug):
 | 
						if (debug):
 | 
				
			||||||
		print "DONE GENCODE"
 | 
							print "DONE GENCODE"
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -1197,11 +1212,15 @@ 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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gencode(root)
 | 
						filename = os.path.join(target_dir, "chips.c")
 | 
				
			||||||
 | 
						print "Creating", filename
 | 
				
			||||||
 | 
						file = open(filename, 'w+')
 | 
				
			||||||
 | 
						gencode(root, file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# crt0 includes
 | 
						# crt0 includes
 | 
				
			||||||
	if (debug):
 | 
						if (debug):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user