16 full_mainboard_path = ''
19 global_options_by_order = []
20 global_option_values = {}
21 global_uses_options = {}
22 global_exported_options = []
28 alloptions = 0 # override uses at top level
30 local_path = re.compile(r'^\.')
31 include_pattern = re.compile(r'%%([^%]+)%%')
33 # the cpu type for this mainboard
36 # -----------------------------------------------------------------------------
38 # -----------------------------------------------------------------------------
41 """Used to keep track of the current part or dir"""
43 def __init__ (self, stack):
52 if (self.index < self.len):
53 s = self.stack[self.index]
54 self.index = self.index + 1
62 return len(self.stack)
64 def __getitem__ (self, i):
68 return self.__stack_iter(self.stack)
71 self.stack.append(part)
75 return self.stack.pop()
86 return (len(self.stack) == 0)
100 def __init__(self, *level):
103 def setdebug(self, *level):
106 def level(self, level):
107 return level in self.__level
109 def info(self, level, str):
110 if level in self.__level:
114 debug = debug_info(debug_info.dumptree)
115 debug = debug_info(debug_info.object)
117 # -----------------------------------------------------------------------------
119 # -----------------------------------------------------------------------------
122 """Used to keep track of our current location while parsing
123 configuration files"""
125 def __init__(self, file, line, command):
128 self.command = command
129 def next_line(self, command):
130 self.line = self.line + 1
131 self.command = command
133 return "%s:%d" % (self.file, self.line)
144 s = s + '\n' + p.at()
148 return self.stack.tos().file
151 return self.stack.tos().line
154 return self.stack.tos().command
156 def push(self, file):
157 self.stack.push(self.__place(os.path.normpath(file), 0, ""))
162 def next_line(self, command):
163 self.stack.tos().next_line(command)
166 return self.stack.tos().at()
170 """Print error message"""
173 print "===> ERROR: %s" % string
177 """Print error message and exit"""
182 """Print warning message"""
184 warnings = warnings + 1
185 print "===> WARNING: %s" % string
188 """Print notice message"""
189 #print "===> NOTE: %s" % string
192 """Exit parser if an error has been encountered"""
196 def safe_open(file, mode):
198 return open(file, mode)
200 fatal("Could not open file \"%s\"" % file)
202 # -----------------------------------------------------------------------------
204 # -----------------------------------------------------------------------------
207 """A rom image is the ultimate goal of coreboot"""
208 def __init__ (self, name):
209 # name of this rom image
212 # set by 'arch' directive
215 # set by 'payload' directive
218 # set by 'init' directive
221 # make rules added by 'makerule' directive
222 self.makebaserules = {}
224 # object files added by 'object' directive
225 self.objectrules = {}
227 # init object files added by 'initobject' directive
228 self.initobjectrules = {}
230 # driver files added by 'driver' directive
231 self.driverrules = {}
233 # smm object files added by 'smmobject' directive
234 self.smmobjectrules = {}
236 # loader scripts added by 'ldscript' directive
239 # user defines added by 'makedefine' directive
240 self.userdefines = []
242 # files to be included in crt0.S
243 self.initincludes = {}
245 # as above, but order is preserved
246 self.initincludesorder = []
248 # transitional flag to support old crtinclude format
249 self.useinitincludes = 0
251 # instance counter for parts
252 self.partinstance = 0
254 # chip config files included by the 'config' directive
255 self.configincludes = {}
260 # name of target directory specified by 'target' directive
263 # option values used in rom image
267 self.exported_options = []
278 def setarch(self, arch):
281 def setpayload(self, payload):
283 self.payload = payload
285 rommapping[self.name] = payload
287 def setinitfile(self, initfile):
288 self.initfile = initfile
290 def getinitfile(self):
293 def addmakerule(self, id):
294 o = getdict(self.makebaserules, id)
296 warning("rule %s previously defined" % id)
298 setdict(self.makebaserules, id, o)
300 def getmakerules(self):
301 return self.makebaserules
303 def getmakerule(self, id):
304 o = getdict(self.makebaserules, id)
307 fatal("No such make rule \"%s\"" % id)
309 def addmakeaction(self, id, str):
310 o = getdict(self.makebaserules, id)
315 fatal("No such rule \"%s\" for addmakeaction" % id)
317 def addmakedepend(self, id, str):
318 o = getdict(self.makebaserules, id)
323 fatal("No such rule \"%s\" for addmakedepend" % id)
325 # this is called with an an object name.
326 # the easiest thing to do is add this object to the current
328 # such kludgery. If the name starts with '.' then make the
329 # dependency be on ./thing.x gag me.
330 def addobjectdriver(self, dict, object_name):
332 suffix = object_name[-2:]
335 base = object_name[:-2]
336 type = object_name[-1:]
337 if (object_name[0] == '.'):
338 source = base + suffix
342 rel_base = re.sub(treetop, "", os.path.join(dirstack.tos(), base))
343 source = "$(TOP)/" + rel_base + suffix
344 if (rel_base[0] == '/'):
345 rel_base = re.sub("^/", "", rel_base)
346 object = rel_base + '.o'
348 debug.info(debug.object, "add object %s source %s" % (object, source))
349 l = getdict(dict, rel_base)
351 warning("object/driver %s previously defined" % rel_base)
352 setdict(dict, rel_base, [object, source, type, rel_base])
354 def addinitobjectrule(self, name):
355 self.addobjectdriver(self.initobjectrules, name)
357 def addobjectrule(self, name):
358 self.addobjectdriver(self.objectrules, name)
360 def adddriverrule(self, name):
361 self.addobjectdriver(self.driverrules, name)
363 def addsmmobjectrule(self, name):
364 self.addobjectdriver(self.smmobjectrules, name)
366 def getinitobjectrules(self):
367 return self.initobjectrules
369 def getinitobjectrule(self, name):
370 o = getdict(self.initobjectrules, name)
373 fatal("No such init object rule \"%s\"" % name)
375 def getobjectrules(self):
376 return self.objectrules
378 def getobjectrule(self, name):
379 o = getdict(self.objectrules, name)
382 fatal("No such object rule \"%s\"" % name)
384 def getdriverrules(self):
385 return self.driverrules
387 def getdriverrule(self, name):
388 o = getdict(self.driverrules, name)
391 fatal("No such driver rule \"%s\"" % name)
393 def getsmmobjectrules(self):
394 return self.smmobjectrules
396 def getsmmobjectrule(self, name):
397 o = getdict(self.smmobjectrules, name)
400 fatal("No such smm object rule \"%s\"" % name)
402 def addldscript(self, path):
403 self.ldscripts.append(path)
405 def getldscripts(self):
406 return self.ldscripts
408 def adduserdefine(self, str):
409 self.userdefines.append(str)
411 def getuserdefines(self):
412 return self.userdefines
414 def addinitinclude(self, str, path):
416 self.useinitincludes = 1
418 debug.info(debug.object, "ADDCRT0: %s -> %s" % (str, path))
419 o = getdict(self.initincludes, path)
421 warning("init include for %s previously defined" % path)
422 o = initinclude(str, path)
423 setdict(self.initincludes, path, o)
424 self.initincludesorder.append(path)
426 def getinitincludes(self):
427 return self.initincludesorder
429 def getinitinclude(self, path):
430 o = getdict(self.initincludes, path)
433 fatal("No such init include \"%s\"" % path)
435 def addconfiginclude(self, part, path):
436 setdict(self.configincludes, part, path)
438 def getconfigincludes(self):
439 return self.configincludes
441 def getincludefilename(self):
442 if (self.useinitincludes):
445 return "crt0_includes.h"
448 return self.useinitincludes
451 return self.partinstance
453 def newpartinstance(self):
454 i = self.partinstance
455 self.partinstance = self.partinstance + 1
458 def setroot(self, part):
464 def settargetdir(self, path):
465 self.targetdir = path
467 def gettargetdir(self):
468 return self.targetdir
471 """A buildrom statement"""
472 def __init__ (self, filename, size, roms):
478 return len(self.roms)
480 def __getitem__(self,i):
484 """include file for initialization code"""
485 def __init__ (self, str, path):
496 """Rule to be included in Makefile"""
497 def __init__ (self, target):
502 def addaction(self, action):
503 self.actions.append(action)
505 def adddependency(self, dependency):
506 self.dependency.append(dependency)
511 def gdependency(self):
512 return self.dependency
518 """Configuration option"""
519 def __init__ (self, name):
520 self.name = name # name of option
521 self.loc = 0 # current location
522 self.used = 0 # option has been used
524 self.comment = '' # description of option
525 self.exportable = 0 # option is able to be exported
526 self.format = '%s' # option print format
527 self.write = [] # parts that can set this option
532 def setcomment(self, comment, loc):
533 if (self.comment != ''):
534 print "%s: " % self.name
535 print "Attempt to modify comment at %s" % loc
537 self.comment = comment
539 def setexportable(self):
542 def setnoexport(self):
545 def setformat(self, fmt):
552 if (self.exportable):
556 def setwrite(self, part):
557 self.write.append(part)
559 def isexportable(self):
560 return self.exportable
562 def iswritable(self, part):
563 return (part in self.write)
566 """Value of a configuration option. The option has a default
567 value which can be changed at any time. Once an option has been
568 set the default value is no longer used."""
569 def __init__(self, name, prev):
574 self.value = prev.value
578 def setvalue(self, value):
579 if ((self.set & 2) == 2):
580 warning("Changing option %s" % self.name)
585 def setdefault(self, value):
586 if ((self.set & 1) == 1):
587 notice("Changing default value of %s" % self.name)
589 if ((self.set & 2) == 0):
597 return (self.set & 2) == 2
601 """A configuration part"""
602 def __init__ (self, image, dir, parent, part, type_name, instance_name, chip_or_device):
603 debug.info(debug.object, "partobj dir %s parent %s part %s" \
604 % (dir, parent, part))
606 # romimage that is configuring this part
609 # links for static device tree
611 self.prev_sibling = 0
612 self.next_sibling = 0
615 self.chip_or_device = chip_or_device
617 # list of init code files
620 # initializers for static device tree
621 self.registercode = {}
626 # type name of this part
627 self.type_name = type_name
629 # object files needed to build this part
632 # directory containg part files
635 # instance number, used to distinguish anonymous
636 # instances of this part
637 self.instance = image.newpartinstance()
638 debug.info(debug.object, "INSTANCE %d" % self.instance)
640 # Options used by this part
641 self.uses_options = {}
643 # Name of chip config file (0 if not needed)
646 # Flag to indicate that we have generated type
647 # definitions for this part (only want to do it once)
653 # Resources of the device
657 # Enabled state of the device
660 # Flag if I am a dumplicate device
663 # If no instance name is supplied then generate
665 if (instance_name == 0):
666 self.instance_name = self.type_name + \
667 "_dev%d" % self.instance
668 self.chipinfo_name = "%s_info_%d" \
669 % (self.type_name, self.instance)
671 self.instance_name = instance_name
672 self.chipinfo_name = "%s_info_%d" % (self.instance_name, self.instance)
674 # Link this part into the device list
675 if (self.chip_or_device == 'device'):
676 if (image.last_device):
677 image.last_device.next_device = self
678 self.prev_device = image.last_device
679 image.last_device = self
681 # Link this part into the tree
682 if (parent and (part != 'arch')):
683 debug.info(debug.gencode, "add to parent")
685 # add current child as my sibling,
687 if (parent.children):
688 debug.info(debug.gencode, "add %s (%d) as sibling" % (parent.children.dir, parent.children.instance))
689 youngest = parent.children
690 while(youngest.next_sibling):
691 youngest = youngest.next_sibling
692 youngest.next_sibling = self
693 self.prev_sibling = youngest
695 parent.children = self
701 return "%s: %s" % (self.part, self.type)
703 return self.chip_or_device
705 def readable_name(self):
707 name = "%s_%d" % (self.type_name, self.instance)
708 if (self.chip_or_device == 'chip'):
709 name = "%s %s %s" % (name, self.part, self.dir)
711 name = "%s %s" % (name, self.path)
714 def graph_name(self):
715 name = "{ {_dev%d|" % self.instance
717 name = "%s%s" % (name, self.part)
719 name = "%s%s" % (name, self.chip_or_device)
721 name = "%s}|%s}" % (name, self.type_name)
723 name = "%s}|%s}" % (name, self.parent.type_name)
726 def dumpme(self, lvl):
727 """Dump information about this part for debugging"""
728 print "%d: %s" % (lvl, self.readable_name())
729 print "%d: part %s" % (lvl, self.part)
730 print "%d: instance %d" % (lvl, self.instance)
731 print "%d: chip_or_device %s" % (lvl, self.chip_or_device)
732 print "%d: dir %s" % (lvl,self.dir)
733 print "%d: type_name %s" % (lvl,self.type_name)
734 print "%d: parent: %s" % (lvl, self.parent.readable_name())
736 print "%d: child %s" % (lvl, self.children.readable_name())
737 if (self.next_sibling):
738 print "%d: siblings %s" % (lvl, self.next_sibling.readable_name())
739 print "%d: initcode " % lvl
740 for i in self.initcode:
742 print "%d: registercode " % lvl
743 for f, v in self.registercode.items():
744 print "\t%s = %s" % (f, v)
747 def firstchilddevice(self):
748 """Find the first device in the children link."""
751 if (kid.chip_or_device == 'device'):
757 def firstparentdevice(self):
758 """Find the first device in the parent link."""
760 while (parent and (parent.parent != parent) and (parent.chip_or_device != 'device')):
761 parent = parent.parent
762 if ((parent.parent != parent) and (parent.chip_or_device != 'device')):
764 while(parent and (parent.dup == 1)):
765 parent = parent.prev_sibling
767 fatal("Device %s has no device parent; this is a config file error" % self.readable_name())
770 def firstparentdevicelink(self):
771 """Find the first device in the parent link and record which link it is."""
774 while (parent and (parent.parent != parent) and (parent.chip_or_device != 'device')):
775 parent = parent.parent
776 if ((parent.parent != parent) and (parent.chip_or_device != 'device')):
778 while(parent and (parent.dup == 1)):
779 parent = parent.prev_sibling
782 fatal("Device %s has no device parent; this is a config file error" % self.readable_name())
786 def firstparentchip(self):
787 """Find the first chip in the parent link."""
790 if ((parent.parent == parent) or (parent.chip_or_device == 'chip')):
793 parent = parent.parent
794 fatal("Device %s has no chip parent; this is a config file error" % self.readable_name())
796 def firstsiblingdevice(self):
797 """Find the first device in the sibling link."""
798 sibling = self.next_sibling
799 while(sibling and (sibling.path == self.path)):
800 sibling = sibling.next_sibling
801 if ((not sibling) and (self.parent.chip_or_device == 'chip')):
802 sibling = self.parent.next_sibling
804 if (sibling.chip_or_device == 'device'):
807 sibling = sibling.children
810 def gencode(self, file, pass_num):
811 """Generate static initalizer code for this part. Two passes
812 are used - the first generates type information, and the second
813 generates instance information"""
815 if (self.chip_or_device == 'chip'):
819 file.write("struct device %s;\n" \
820 % self.instance_name)
822 file.write("struct device dev_root;\n")
824 # This is pass the second, which is pass number 1
825 # this is really just a case statement ...
827 if (self.chip_or_device == 'chip'):
828 if (self.chipconfig):
829 debug.info(debug.gencode, "gencode: chipconfig(%d)" % \
831 file.write("struct %s_config %s" % (self.type_name ,\
833 if (self.registercode):
834 file.write("\t= {\n")
835 for f, v in self.registercode.items():
836 file.write( "\t.%s = %s,\n" % (f, v))
842 if (self.instance == 0):
843 self.instance_name = "dev_root"
844 file.write("struct device **last_dev_p = &%s.next;\n" % (self.image.last_device.instance_name))
845 file.write("struct device dev_root = {\n")
846 file.write("\t.ops = &default_dev_ops_root,\n")
847 file.write("\t.bus = &dev_root.link[0],\n")
848 file.write("\t.path = { .type = DEVICE_PATH_ROOT },\n")
849 file.write("\t.enabled = 1,\n\t.links = 1,\n")
850 file.write("\t.on_mainboard = 1,\n")
851 file.write("\t.link = {\n\t\t[0] = {\n")
852 file.write("\t\t\t.dev=&dev_root,\n\t\t\t.link = 0,\n")
853 file.write("\t\t\t.children = &%s,\n" % self.firstchilddevice().instance_name)
854 file.write("\t\t},\n")
856 if (self.chipconfig):
857 file.write("\t.chip_ops = &%s_ops,\n" % self.type_name)
858 file.write("\t.chip_info = &%s_info_%s,\n" % (self.type_name, self.instance))
859 file.write("\t.next = &%s,\n" % self.firstchilddevice().instance_name)
863 # Don't print duplicate devices, just print their children
867 file.write("struct device %s = {\n" % self.instance_name)
868 file.write("\t.ops = 0,\n")
869 file.write("\t.bus = &%s.link[%d],\n" % \
870 (self.firstparentdevice().instance_name, \
871 self.firstparentdevicelink()))
872 file.write("\t.path = {%s},\n" % self.path)
873 file.write("\t.enabled = %d,\n" % self.enabled)
874 file.write("\t.on_mainboard = 1,\n")
876 file.write("\t.resources = %d,\n" % self.resources)
877 file.write("\t.resource = {%s\n\t },\n" % self.resource)
878 file.write("\t.link = {\n");
881 while(bus and (bus.path == self.path)):
882 child = bus.firstchilddevice()
883 if (child or (bus != self) or (bus.next_sibling and (bus.next_sibling.path == self.path))):
884 file.write("\t\t[%d] = {\n" % links)
885 file.write("\t\t\t.link = %d,\n" % links)
886 file.write("\t\t\t.dev = &%s,\n" % self.instance_name)
888 file.write("\t\t\t.children = &%s,\n" %child.instance_name)
889 file.write("\t\t},\n")
892 bus = bus.next_sibling
896 file.write("\t.links = %d,\n" % (links))
897 sibling = self.firstsiblingdevice();
899 file.write("\t.sibling = &%s,\n" % sibling.instance_name)
900 chip = self.firstparentchip()
901 if (chip and chip.chipconfig):
902 file.write("\t.chip_ops = &%s_ops,\n" % chip.type_name)
903 file.write("\t.chip_info = &%s_info_%s,\n" % (chip.type_name, chip.instance))
904 if (self.next_device):
905 file.write("\t.next=&%s\n" % self.next_device.instance_name)
909 def addinit(self, code):
910 """Add init file to this part"""
911 self.initcode.append(code)
913 def addconfig(self, path):
914 """Add chip config file to this part"""
915 self.chipconfig = os.path.join(self.dir, path)
916 self.image.addconfiginclude(self.type_name, self.chipconfig)
918 def addregister(self, field, value):
919 """Register static initialization information"""
920 if (self.chip_or_device != 'chip'):
921 fatal("Only chips can have register values")
922 field = dequote(field)
923 value = dequote(value)
924 setdict(self.registercode, field, value)
926 def set_enabled(self, enabled):
927 self.enabled = enabled
929 def start_resources(self):
933 def end_resources(self):
934 self.resource = "%s" % (self.resource)
936 def add_resource(self, type, index, value):
937 """ Add a resource to a device """
938 self.resource = "%s\n\t\t{ .flags=%s, .index=0x%x, .base=0x%x}," % (self.resource, type, index, value)
939 self.resources = self.resources + 1
941 def set_path(self, path):
943 if (self.prev_sibling and (self.prev_sibling.path == self.path)):
945 if (self.prev_device):
946 self.prev_device.next_device = self.next_device
947 if (self.next_device):
948 self.next_device.prev_device = self.prev_device
949 if (self.image.last_device == self):
950 self.image.last_device = self.prev_device
954 def addpcipath(self, slot, function):
955 """ Add a relative pci style path from our parent to this device """
956 if ((slot < 0) or (slot > 0x1f)):
957 fatal("Invalid device id")
958 if ((function < 0) or (function > 7)):
959 fatal("Invalid pci function %s" % function )
960 self.set_path(".type=DEVICE_PATH_PCI,{.pci={ .devfn = PCI_DEVFN(0x%x,%d)}}" % (slot, function))
962 def addpnppath(self, port, device):
963 """ Add a relative path to a pnp device hanging off our parent """
964 if ((port < 0) or (port > 65536)):
965 fatal("Invalid port")
966 if ((device < 0) or (device > 0xffff)):
967 fatal("Invalid device")
968 self.set_path(".type=DEVICE_PATH_PNP,{.pnp={ .port = 0x%x, .device = 0x%x }}" % (port, device))
970 def addi2cpath(self, device):
971 """ Add a relative path to a i2c device hanging off our parent """
972 if ((device < 0) or (device > 0x7f)):
973 fatal("Invalid device")
974 self.set_path(".type=DEVICE_PATH_I2C,{.i2c={ .device = 0x%x }}" % (device))
976 def addapicpath(self, apic_id):
977 """ Add a relative path to a cpu device hanging off our parent """
978 if ((apic_id < 0) or (apic_id > 255)):
979 fatal("Invalid device")
980 self.set_path(".type=DEVICE_PATH_APIC,{.apic={ .apic_id = 0x%x }}" % (apic_id))
982 def addpci_domainpath(self, pci_domain):
983 """ Add a pci_domain number to a chip """
984 if ((pci_domain < 0) or (pci_domain > 0xffff)):
985 fatal("Invalid pci_domain: 0x%x is out of the range 0 to 0xffff" % pci_domain)
986 self.set_path(".type=DEVICE_PATH_PCI_DOMAIN,{.pci_domain={ .domain = 0x%x }}" % (pci_domain))
988 def addapic_clusterpath(self, cluster):
989 """ Add an apic cluster to a chip """
990 if ((cluster < 0) or (cluster > 15)):
991 fatal("Invalid apic cluster: %d is out of the range 0 to ff" % cluster)
992 self.set_path(".type=DEVICE_PATH_APIC_CLUSTER,{.apic_cluster={ .cluster = 0x%x }}" % (cluster))
994 def addcpupath(self, cpu_id):
995 """ Add a relative path to a cpu device hanging off our parent """
996 if ((cpu_id < 0) or (cpu_id > 255)):
997 fatal("Invalid device")
998 self.set_path(".type=DEVICE_PATH_CPU,{.cpu={ .id = 0x%x }}" % (cpu_id))
1001 def addcpu_buspath(self, id):
1002 """ Add a cpu_bus to a chip """
1003 if ((id < 0) or (id > 255)):
1004 fatal("Invalid device")
1005 self.set_path(".type=DEVICE_PATH_CPU_BUS,{.cpu_bus={ .id = 0x%x }}" % (id))
1007 def usesoption(self, name):
1008 """Declare option that can be used by this part"""
1009 global global_options
1010 o = getdict(global_options, name)
1012 fatal("can't use undefined option %s" % name)
1013 o1 = getdict(self.uses_options, name)
1016 setdict(self.uses_options, name, o)
1017 exportoption(o, self.image.exported_options)
1019 # -----------------------------------------------------------------------------
1021 # -----------------------------------------------------------------------------
1023 def getdict(dict, name):
1024 if name not in dict.keys():
1025 debug.info(debug.dict, "Undefined: %s" % name)
1027 v = dict.get(name, 0)
1028 debug.info(debug.dict, "getdict %s returning %s" % (name, v))
1031 def setdict(dict, name, value):
1032 debug.info(debug.dict, "setdict sets %s to %s" % (name, value))
1033 if name in dict.keys():
1034 print "Duplicate in dict: %s" % name
1038 # to create an option, it has to not exist.
1039 # When an option value is fetched, the fact that it was used is
1041 # Legal things to do:
1042 # set a default value, then set a real value before the option is used.
1043 # set a value, try to set a default, default silently fails.
1045 # use the value, then try to set the value
1047 def newoption(name):
1048 global global_options, global_options_by_order
1049 o = getdict(global_options, name)
1051 fatal("option %s already defined" % name)
1053 setdict(global_options, name, o)
1054 global_options_by_order.append(name)
1056 def newoptionvalue(name, image):
1057 g = getdict(global_option_values, name)
1058 v = option_value(name, g)
1060 setdict(image.getvalues(), name, v)
1062 setdict(global_option_values, name, v)
1065 def getoptionvalue(name, op, image):
1066 global global_option_values
1067 #print "getoptionvalue name %s op %s image %s\n" % (name, op,image)
1069 # we want to debug config files, not the config tool, so no:
1071 fatal("Option %s undefined (missing use command?)" % name)
1073 v = getdict(image.getvalues(), name)
1075 v = getdict(global_option_values, name)
1078 def getoption(name, image):
1079 """option must be declared before being used in a part
1080 if we're not processing a part, then we must
1081 be at the top level where all options are available"""
1083 global global_uses_options, alloptions, curimage
1085 #print "getoption: name %s image %s alloptions %s curimage %s\n\n" % (name, image, alloptions, curimage)
1086 curpart = partstack.tos()
1088 o = getdict(global_options, name)
1090 o = getdict(curpart.uses_options, name)
1092 print "curpart.uses_options is %s\n" % curpart.uses_options
1094 o = getdict(global_uses_options, name)
1095 v = getoptionvalue(name, o, image)
1097 v = getoptionvalue(name, o, 0)
1099 fatal("No value for option %s" % name)
1101 if (not (type(val) is types.StringType)):
1103 if (val == '' or val[0] != '{'):
1107 val = parse('delexpr', val)
1112 def setoption(name, value, imp):
1113 """Set an option from within a configuration file. Normally this
1114 is only permitted in the target (top level) configuration file.
1115 If 'imp' is true, then set an option implicitly (e.g. 'arch'
1116 and 'mainboard' statements). Implicit options can be set anywhere
1117 the statements are legal, but also performs an implicit 'uses'
1120 global loc, global_options, global_option_values, curimage
1122 curpart = partstack.tos()
1123 if (not imp and curpart):
1124 fatal("Options may only be set in target configuration file")
1128 o = getdict(curpart.uses_options, name)
1130 o = getdict(global_uses_options, name)
1132 fatal("Attempt to set nonexistent option %s (missing USES?)" % name)
1133 v = getoptionvalue(name, o, curimage)
1135 v = newoptionvalue(name, curimage)
1138 def exportoption(op, exported_options):
1139 if (not op.isexportable()):
1141 if (not op in exported_options):
1142 exported_options.append(op)
1144 def setdefault(name, value, isdef):
1145 """Set the default value of an option from within a configuration
1146 file. This is permitted from any configuration file, but will
1147 result in a warning if the default is set more than once.
1148 If 'isdef' is set, we're defining the option in Options.lb so
1149 there is no need for 'uses'."""
1151 global loc, global_options, curimage
1154 o = getdict(global_options, name)
1159 curpart = partstack.tos()
1161 o = getdict(curpart.uses_options, name)
1163 o = getdict(global_uses_options, name)
1165 fatal("Attempt to set default for nonexistent option %s (missing USES?)" % name)
1168 v = getoptionvalue(name, o, image)
1170 v = newoptionvalue(name, image)
1173 def setnodefault(name):
1174 global loc, global_options
1175 o = getdict(global_options, name)
1178 v = getdict(global_option_values, name)
1180 warning("removing default for %s" % name)
1181 del global_option_values[name]
1183 def setcomment(name, value):
1184 global loc, global_options
1185 o = getdict(global_options, name)
1187 fatal("setcomment: %s not here" % name)
1188 o.setcomment(value, loc)
1190 def setexported(name):
1191 global global_options
1192 o = getdict(global_options, name)
1194 fatal("setexported: %s not here" % name)
1196 global_exported_options.append(o)
1198 def setnoexport(name):
1199 global global_options
1200 o = getdict(global_options, name)
1202 fatal("setnoexport: %s not here" % name)
1204 if (o in global_exported_options):
1205 global_exported_options.remove(o)
1207 def setexportable(name):
1208 global global_options
1209 o = getdict(global_options, name)
1211 fatal("setexportable: %s not here" % name)
1214 def setformat(name, fmt):
1215 global global_options
1216 o = getdict(global_options, name)
1218 fatal("setformat: %s not here" % name)
1221 def getformated(name, image):
1222 global global_options, global_option_values
1223 o = getdict(global_options, name)
1224 v = getoption(name, image)
1228 def setwrite(name, part):
1229 global global_options
1230 o = getdict(global_options, name)
1232 fatal("setwrite: %s not here" % name)
1235 def hasvalue(name, image):
1236 global global_options
1237 o = getdict(global_options, name)
1242 v = getdict(image.getvalues(), name)
1244 v = getdict(global_option_values, name)
1247 def isset(name, part):
1248 global global_uses_options, global_option_values, curimage
1250 o = getdict(part.uses_options, name)
1252 o = getdict(global_uses_options, name)
1257 v = getdict(curimage.getvalues(), name)
1259 v = getdict(global_option_values, name)
1260 return (v != 0 and v.isset())
1262 def usesoption(name):
1263 global global_options, global_uses_options
1264 curpart = partstack.tos()
1266 curpart.usesoption(name)
1268 o = getdict(global_options, name)
1270 fatal("Can't use undefined option %s" % name)
1271 o1 = getdict(global_uses_options, name)
1274 setdict(global_uses_options, name, o)
1275 exportoption(o, global_exported_options)
1277 def validdef(name, defval):
1278 global global_options
1279 o = getdict(global_options, name)
1281 fatal("validdef: %s not here" % name)
1282 if ((defval & 1) != 1):
1283 fatal("Must specify default value for option %s" % name)
1284 if ((defval & 2) != 2):
1285 fatal("Must specify export for option %s" % name)
1286 if ((defval & 4) != 4):
1287 fatal("Must specify comment for option %s" % name)
1289 def loadoptions(path, file, rule):
1290 file = os.path.join('src', path, file)
1291 optionsfile = os.path.join(treetop, file)
1292 fp = safe_open(optionsfile, 'r')
1294 if (not parse(rule, fp.read())):
1295 fatal("Could not parse file")
1299 global curimage, dirstack
1300 if (path[0] == '/'):
1301 curimage.setinitfile(treetop + '/src/' + path)
1303 curimage.setinitfile(dirstack.tos() + '/' + path)
1304 print "Adding init file: %s" % path
1306 def addconfig(path):
1308 curpart = partstack.tos()
1309 curpart.addconfig(path)
1311 def addregister(field, value):
1313 curpart = partstack.tos()
1314 curpart.addregister(field, value)
1316 def addcrt0include(path):
1317 """we do the crt0include as a dictionary, so that if needed we
1318 can trace who added what when. Also it makes the keys
1321 curimage.addinitinclude(0, path)
1323 def addinitinclude(str, path):
1325 curimage.addinitinclude(dequote(str), path)
1327 def addldscript(path):
1328 global curimage, dirstack
1329 curdir = dirstack.tos()
1330 if (path[0] == '/'):
1331 fullpath = treetop + '/src/' + path
1333 fullpath = curdir + '/' + path
1334 debug.info(debug.statement, "fullpath :%s: curdir :%s: path :%s:" % (fullpath, curdir, path))
1335 curimage.addldscript(fullpath)
1339 curimage.setpayload(path)
1340 adduserdefine("PAYLOAD:=%s"%path)
1342 def startromimage(name):
1343 global romimages, curimage, target_dir, target_name
1344 curpart = partstack.tos()
1345 print "Configuring ROMIMAGE %s Curimage %s" % (name, curimage)
1346 print "Curpart is %s\n" % curpart
1347 o = getdict(romimages, name)
1349 fatal("romimage %s previously defined" % name)
1350 curimage = romimage(name)
1351 curimage.settargetdir(os.path.join(target_dir, name))
1352 #o = partobj(curimage, target_dir, 0, 'board', target_name)
1353 #curimage.setroot(o)
1354 setdict(romimages, name, curimage)
1355 dodir('/config', 'Config.lb')
1359 global bootblocksize
1361 imagesize = getoption("ROM_IMAGE_SIZE", curimage)
1362 bootblocksize += imagesize
1363 print "End ROMIMAGE"
1367 def mainboardsetup(path):
1368 global full_mainboard_path, mainboard_path
1369 mainboard_path = os.path.join('mainboard', path)
1370 loadoptions(mainboard_path, 'Options.lb', 'mainboardvariables')
1371 full_mainboard_path = os.path.join(treetop, 'src', 'mainboard', path)
1372 vendor = re.sub("/.*", "", path)
1373 part_number = re.sub("[^/]*/", "", path)
1374 setdefault('MAINBOARD', full_mainboard_path, 0)
1375 setdefault('MAINBOARD_VENDOR', vendor, 0)
1376 setdefault('MAINBOARD_PART_NUMBER', part_number, 0)
1379 global curimage, dirstack, partstack
1381 partdir = mainboard_path
1382 srcdir = os.path.join(treetop, 'src')
1383 fulldir = os.path.join(srcdir, partdir)
1384 type_name = flatten_name(partdir)
1385 newpart = partobj(curimage, fulldir, partstack.tos(), 'mainboard', \
1386 'mainboard', 0, 'chip')
1387 #print "Configuring PART %s" % (type)
1388 partstack.push(newpart)
1389 #print " new PART tos is now %s\n" %partstack.tos().info()
1390 dirstack.push(fulldir)
1391 loadoptions(mainboard_path, 'Options.lb', 'mainboardvariables')
1392 # special case for 'cpu' parts.
1393 # we could add a new function too, but this is rather trivial.
1394 # if the part is a cpu, and we haven't seen it before,
1395 # arrange to source the directory /cpu/'type'
1396 doconfigfile(srcdir, partdir, file, 'cfgfile')
1397 curimage.setroot(partstack.tos())
1400 def addbuildrom(filename, size, roms):
1402 print "Build ROM size %d" % size
1403 b = buildrom(filename, size, roms)
1406 def addinitobject(object_name):
1408 curimage.addinitobjectrule(object_name)
1410 def addobject(object_name):
1412 curimage.addobjectrule(object_name)
1414 def adddriver(driver_name):
1416 curimage.adddriverrule(driver_name)
1418 def addsmmobject(object_name):
1420 curimage.addsmmobjectrule(object_name)
1423 global target_dir, target_name
1424 print "Configuring TARGET %s" % name
1426 target_dir = os.path.join(os.path.dirname(loc.file()), name)
1427 if not os.path.isdir(target_dir):
1428 print "Creating directory %s" % target_dir
1429 os.makedirs(target_dir)
1430 print "Will place Makefile, crt0.S, etc. in %s" % target_dir
1435 if (cpu_type and (cpu_type != path)):
1436 fatal("Two different CPU types: %s and %s" % (cpu_type, path))
1437 srcdir = "/cpu/%s" % path
1438 dodir(srcdir, "Config.lb")
1441 def devicepart(type):
1442 global curimage, dirstack, partstack
1443 newpart = partobj(curimage, 0, partstack.tos(), type, \
1445 #print "Configuring PART %s" % (type)
1446 partstack.push(newpart)
1447 #print " new PART tos is now %s\n" %partstack.tos().info()
1448 # just push TOS, so that we can pop later.
1449 dirstack.push(dirstack.tos())
1451 def part(type, path, file, name):
1452 global curimage, dirstack, partstack
1453 partdir = os.path.join(type, path)
1454 srcdir = os.path.join(treetop, 'src')
1455 fulldir = os.path.join(srcdir, partdir)
1456 type_name = flatten_name(partdir)
1457 newpart = partobj(curimage, fulldir, partstack.tos(), type, \
1458 type_name, name, 'chip')
1459 #print "Configuring PART %s, path %s" % (type, path)
1460 partstack.push(newpart)
1461 #print " new PART tos is now %s\n" %partstack.tos().info()
1462 dirstack.push(fulldir)
1463 # special case for 'cpu' parts.
1464 # we could add a new function too, but this is rather trivial.
1465 # if the part is a cpu, and we haven't seen it before,
1466 # arrange to source the directory /cpu/'type'
1470 doconfigfile(srcdir, partdir, file, 'cfgfile')
1473 global dirstack, partstack
1474 curpart = partstack.tos()
1476 fatal("Trying to pop non-existent part")
1477 #print "End PART %s" % curpart.part
1478 # Warn if options are used without being set in this part
1479 for op in curpart.uses_options.keys():
1480 if (not isset(op, curpart)):
1481 notice("Option %s using default value %s" % (op, getformated(op, curpart.image)))
1482 oldpart = partstack.pop()
1484 #print "partstack.pop, TOS is now %s\n" % oldpart.info()
1486 def dodir(path, file):
1487 """dodir is like part but there is no new part"""
1489 # if the first char is '/', it is relative to treetop,
1490 # else relative to curdir
1491 # os.path.join screws up if the name starts with '/', sigh.
1492 print "Configuring DIR %s" % os.path.join(path, file)
1493 if (path[0] == '/'):
1494 fullpath = os.path.join(treetop, 'src')
1495 path = re.sub('^/*', '', path)
1497 fullpath = dirstack.tos()
1498 debug.info(debug.statement, "DODIR: path %s, fullpath %s" % (path, fullpath))
1499 dirstack.push(os.path.join(fullpath, path))
1500 doconfigfile(fullpath, path, file, 'cfgfile')
1505 return getoption(name, curimage)
1509 curimage.addmakerule(id)
1511 def adduserdefine(str):
1513 curimage.adduserdefine(str)
1515 def addaction(id, str):
1517 curimage.addmakeaction(id, str)
1519 def adddep(id, str):
1521 curimage.addmakedepend(id, str)
1523 def setarch(my_arch):
1524 """arch is 'different' ... darn it."""
1526 print "SETTING ARCH %s\n" % my_arch
1527 curimage.setarch(my_arch)
1528 setdefault('ARCH', my_arch, 1)
1529 part('arch', my_arch, 'Config.lb', 0)
1531 def doconfigfile(path, confdir, file, rule):
1532 rname = os.path.join(confdir, file)
1534 fullpath = os.path.join(path, rname)
1535 fp = safe_open(fullpath, 'r')
1536 if (not parse(rule, fp.read())):
1537 fatal("Could not parse file")
1541 #=============================================================================
1543 #=============================================================================
1544 def ternary(val, yes, no):
1545 debug.info(debug.statement, "ternary %s" % expr)
1546 debug.info(debug.statement, "expr %s a %d yes %d no %d"% (expr, a, yes, no))
1548 debug.info(debug.statement, "Ternary returns %d" % yes)
1551 debug.info(debug.statement, "Ternary returns %d" % no)
1555 """atoi is in the python library, but not strtol? Weird!"""
1556 return eval('int(%s)' % name)
1559 """ Is the given string an integer?"""
1567 a = re.sub("^\"", "", str)
1568 a = re.sub("\"$", "", a)
1569 # highly un-intuitive, need four \!
1570 a = re.sub("\\\\\"", "\"", a)
1573 def flatten_name(str):
1574 a = re.sub("[/-]", "_", str)
1578 """If the first part of <path> matches treetop, replace
1579 that part with $(TOP)"""
1580 if path[0:len(treetop)] == treetop:
1581 path = path[len(treetop):len(path)]
1582 if (path[0:1] == "/"):
1583 path = path[1:len(path)]
1584 path = "$(TOP)/" + path
1588 # to make if work without 2 passses, we use an old hack from SIMD, the
1589 # context bit. If the bit is 1, then ops get done, otherwise
1590 # ops don't get done. From the top level, context is always
1591 # 1. In an if, context depends on eval of the if condition
1597 # less general tokens should come first, otherwise they get matched
1599 token ACTION: 'action'
1600 token ADDACTION: 'addaction'
1601 token ALWAYS: 'always'
1603 token BUILDROM: 'buildrom'
1604 token COMMENT: 'comment'
1605 token CONFIG: 'config'
1607 token CPU_BUS: 'cpu_bus'
1609 token DEFAULT: 'default'
1610 token DEFINE: 'define'
1611 token DEPENDS: 'depends'
1612 token DEVICE: 'device'
1614 token DRIVER: 'driver'
1620 token EXPORT: 'export'
1621 token FORMAT: 'format'
1624 token INITOBJECT: 'initobject'
1625 token INITINCLUDE: 'initinclude'
1628 token LDSCRIPT: 'ldscript'
1629 token LOADOPTIONS: 'loadoptions'
1630 token MAINBOARD: 'mainboard'
1631 token MAINBOARDINIT: 'mainboardinit'
1632 token MAKEDEFINE: 'makedefine'
1633 token MAKERULE: 'makerule'
1635 token NEVER: 'never'
1637 token NORTHBRIDGE: 'northbridge'
1638 token OBJECT: 'object'
1639 token OPTION: 'option'
1640 token PAYLOAD: 'payload'
1642 token PRINT: 'print'
1643 token REGISTER: 'register'
1644 token ROMIMAGE: 'romimage'
1645 token SMMOBJECT: 'smmobject'
1646 token SOUTHBRIDGE: 'southbridge'
1647 token SUPERIO: 'superio'
1648 token TARGET: 'target'
1651 token WRITE: 'write'
1653 token HEX_NUM: '[0-9a-fA-F]+'
1654 token HEX_PREFIX: '0x'
1655 # Why is path separate? Because paths to resources have to at least
1656 # have a slash, we thinks
1657 token PATH: r'[-a-zA-Z0-9_.][-a-zA-Z0-9/_.]+[-a-zA-Z0-9_.]+'
1658 # Dir's on the other hand are abitrary
1659 # this may all be stupid.
1660 token RULE: r'[-a-zA-Z0-9_$()./]+[-a-zA-Z0-9_ $()./]+[-a-zA-Z0-9_$()./]+'
1661 token DIRPATH: r'[-a-zA-Z0-9_$()./]+'
1662 token ID: r'[a-zA-Z_.]+[a-zA-Z0-9_.]*'
1663 token DELEXPR: r'{([^}]+|\\.)*}'
1664 token STR: r'"([^\\"]+|\\.)*"'
1665 token RAWTEXT: r'.*'
1672 token APIC_CLUSTER: 'apic_cluster'
1674 token CPU_BUS: 'cpu_bus'
1675 token PCI_DOMAIN: 'pci_domain'
1678 rule expr: logical {{ l = logical }}
1679 ( "&&" logical {{ l = l and logical }}
1680 | "||" logical {{ l = l or logical }}
1683 rule logical: factor {{ n = factor }}
1684 ( "[+]" factor {{ n = n+factor }}
1685 | "-" factor {{ n = n-factor }}
1688 rule factor: term {{ v = term }}
1689 ( "[*]" term {{ v = v*term }}
1690 | "/" term {{ v = v/term }}
1691 | "<<" term {{ v = v << term }}
1692 | ">=" term {{ v = (v < term)}}
1695 # A term is a number, variable, or an expression surrounded by parentheses
1696 rule term: NUM {{ return long(NUM, 10) }}
1697 | HEX_PREFIX HEX_NUM {{ return long(HEX_NUM, 16) }}
1698 | ID {{ return lookup(ID) }}
1699 | unop {{ return unop }}
1700 | "\\(" expr "\\)" {{ return expr }}
1702 rule unop: "!" expr {{ return not(expr) }}
1704 rule partend<<C>>: (stmt<<C>>)* END {{ if (C): partpop()}}
1706 # This is needed because the legacy cpu command could not distinguish
1707 # between cpu vendors. It should just be PATH, but getting this change
1708 # into the source tree will be tricky...
1709 # DO NOT USE ID AS IT MAY GO AWAY IN THE FUTURE
1710 rule partid: ID {{ return ID }}
1711 | PATH {{ return PATH }}
1713 # rule parttype: NORTHBRIDGE {{ return 'northbridge' }}
1714 # | SUPERIO {{ return 'superio' }}
1715 # | PMC {{ return 'pmc' }}
1716 # | SOUTHBRIDGE {{ return 'southbridge' }}
1717 # | CPU {{ return 'cpu' }}
1718 # | CHIP {{ return '' }}
1720 rule parttype: CHIP {{ return '' }}
1722 rule partdef<<C>>: {{ name = 0 }}
1724 [ STR {{ name = dequote(STR) }}
1725 ] {{ if (C): part(parttype, partid, 'Config.lb', name) }}
1728 rule arch<<C>>: ARCH ID {{ if (C): setarch(ID) }}
1731 rule mainboardinit<<C>>:
1732 MAINBOARDINIT DIRPATH {{ if (C): addcrt0include(DIRPATH)}}
1734 rule initinclude<<C>>:
1737 DIRPATH {{ if (C): addinitinclude(STR, DIRPATH)}}
1739 rule initobject<<C>>:
1740 INITOBJECT DIRPATH {{ if (C): addinitobject(DIRPATH)}}
1742 rule object<<C>>: OBJECT DIRPATH {{ if (C): addobject(DIRPATH)}}
1744 rule driver<<C>>: DRIVER DIRPATH {{ if (C): adddriver(DIRPATH)}}
1746 rule smmobject<<C>>:
1747 SMMOBJECT DIRPATH {{ if (C): addsmmobject(DIRPATH)}}
1750 rule dir<<C>>: DIR DIRPATH {{ if (C): dodir(DIRPATH, 'Config.lb') }}
1752 rule default<<C>>: DEFAULT ID EQ value {{ if (C): setdefault(ID, value, 0) }}
1754 rule ldscript<<C>>: LDSCRIPT DIRPATH {{ if (C): addldscript(DIRPATH) }}
1756 rule iif<<C>>: IF ID {{ c = lookup(ID) }}
1758 [ ELSE (stmt<<C and not c>>)* ]
1761 rule makerule<<C>>: MAKERULE RULE {{ if (C): addrule(RULE) }}
1762 ( DEPENDS STR {{ if (C): adddep(RULE, STR) }}
1763 | ACTION STR {{ if (C): addaction(RULE, STR) }}
1767 rule makedefine<<C>>:
1768 MAKEDEFINE RAWTEXT {{ if (C): adduserdefine(RAWTEXT) }}
1770 rule addaction<<C>>:
1771 ADDACTION ID STR {{ if (C): addaction(ID, STR) }}
1773 rule init<<C>>: INIT DIRPATH {{ if (C): addinit(DIRPATH) }}
1775 rule field: STR {{ return STR }}
1777 rule register<<C>>: REGISTER field '=' STR {{ if (C): addregister(field, STR) }}
1779 rule enable<<C>>: {{ val = 1 }}
1782 ) {{ if(C): partstack.tos().set_enabled(val) }}
1784 rule resource<<C>>: {{ type = "" }}
1785 ( IO {{ type = "IORESOURCE_FIXED | IORESOURCE_ASSIGNED | IORESOURCE_IO" }}
1786 | MEM {{ type = "IORESOURCE_FIXED | IORESOURCE_ASSIGNED | IORESOURCE_MEM" }}
1787 | IRQ {{ type = "IORESOURCE_FIXED | IORESOURCE_ASSIGNED | IORESOURCE_IRQ" }}
1788 | DRQ {{ type = "IORESOURCE_FIXED | IORESOURCE_ASSIGNED | IORESOURCE_DRQ" }}
1790 term '=' {{ index = term }}
1791 term {{ value = term }}
1792 {{ if (C): partstack.tos().add_resource(type, index, value) }}
1795 rule resources<<C>>: {{ if (C): partstack.tos().start_resources() }}
1797 {{ if (C): partstack.tos().end_resources() }}
1800 rule pci<<C>>: PCI {{ if (C): devicepart('pci') }}
1802 HEX_NUM {{ slot = int(HEX_NUM,16) }}
1803 '.' HEX_NUM {{ function = int(HEX_NUM, 16) }}
1804 {{ if (C): partstack.tos().addpcipath(slot, function) }}
1805 rule pci_domain<<C>>:
1806 PCI_DOMAIN {{ if (C): devicepart('pci_domain') }}
1807 HEX_NUM {{ pci_domain = int(HEX_NUM, 16) }}
1808 {{ if (C): partstack.tos().addpci_domainpath(pci_domain) }}
1810 rule pnp<<C>>: PNP {{ if (C): devicepart('pnp') }}
1811 HEX_NUM {{ port = int(HEX_NUM,16) }}
1812 '.' HEX_NUM {{ device = int(HEX_NUM, 16) }}
1813 {{ if (C): partstack.tos().addpnppath(port, device) }}
1815 rule i2c<<C>>: I2C {{ if (C): devicepart('i2c') }}
1816 HEX_NUM {{ device = int(HEX_NUM, 16) }}
1817 {{ if (C): partstack.tos().addi2cpath(device) }}
1819 rule apic<<C>>: APIC {{ if (C): devicepart('apic') }}
1820 HEX_NUM {{ apic_id = int(HEX_NUM, 16) }}
1821 {{ if (C): partstack.tos().addapicpath(apic_id) }}
1823 rule apic_cluster<<C>>: APIC_CLUSTER {{ if (C): devicepart('apic_cluster') }}
1824 HEX_NUM {{ cluster = int(HEX_NUM, 16) }}
1825 {{ if (C): partstack.tos().addapic_clusterpath(cluster) }}
1827 rule cpu<<C>>: CPU {{ if (C): devicepart('cpu') }}
1828 HEX_NUM {{ id = int(HEX_NUM, 16) }}
1829 {{ if (C): partstack.tos().addcpupath(id) }}
1831 rule cpu_bus<<C>>: CPU_BUS {{ if (C): devicepart('cpu_bus') }}
1832 HEX_NUM {{ id = int(HEX_NUM, 16) }}
1833 {{ if (C): partstack.tos().addcpu_buspath(id) }}
1836 pci<<C>> {{ return pci }}
1837 | pci_domain<<C>> {{ return pci_domain }}
1838 | pnp<<C>> {{ return pnp }}
1839 | i2c<<C>> {{ return i2c }}
1840 | apic<<C>> {{ return apic }}
1841 | apic_cluster<<C>> {{ return apic_cluster }}
1842 | cpu<<C>> {{ return cpu }}
1843 | cpu_bus<<C>> {{ return cpu_bus }}
1845 rule prtval: expr {{ return str(expr) }}
1846 | STR {{ return STR }}
1848 rule prtlist: prtval {{ el = "%(" + prtval }}
1849 ( "," prtval {{ el = el + "," + prtval }}
1850 )* {{ return el + ")" }}
1852 rule prtstmt<<C>>: PRINT STR {{ val = STR }}
1853 [ "," prtlist {{ val = val + prtlist }}
1854 ] {{ if (C): print eval(val) }}
1856 rule config<<C>>: CONFIG PATH {{ if (C): addconfig(PATH) }}
1858 rule device<<C>>: DEVICE dev_path<<C>>
1863 rule stmt<<C>>: arch<<C>> {{ return arch}}
1864 | addaction<<C>> {{ return addaction }}
1865 | config<<C>> {{ return config}}
1866 | default<<C>> {{ return default}}
1867 | dir<<C>> {{ return dir}}
1868 | driver<<C>> {{ return driver }}
1869 | iif<<C>> {{ return iif }}
1870 | init<<C>> {{ return init }}
1871 | initinclude<<C>> {{ return initinclude }}
1872 | initobject<<C>> {{ return initobject }}
1873 | ldscript<<C>> {{ return ldscript}}
1874 | mainboardinit<<C>> {{ return mainboardinit }}
1875 | makedefine<<C>> {{ return makedefine }}
1876 | makerule<<C>> {{ return makerule }}
1877 | object<<C>> {{ return object }}
1878 | option<<C>> {{ return option }}
1879 | partdef<<C>> {{ return partdef }}
1880 | prtstmt<<C>> {{ return prtstmt }}
1881 | register<<C>> {{ return register }}
1882 | device<<C>> {{ return device }}
1883 | smmobject<<C>> {{ return smmobject }}
1885 # ENTRY for parsing Config.lb file
1886 rule cfgfile: (uses<<1>>)*
1890 rule cfgfile: (uses<<1>>)*
1894 rule usesid<<C>>: ID {{ if (C): usesoption(ID) }}
1896 rule uses<<C>>: USES (usesid<<C>>)+
1898 rule mainboardvariables: (uses<<1>>)*
1903 rule value: STR {{ return dequote(STR) }}
1904 | expr {{ return expr }}
1905 | DELEXPR {{ return DELEXPR }}
1907 rule option<<C>>: OPTION ID EQ value {{ if (C): setoption(ID, value, 0) }}
1909 rule opif<<C>>: IF ID {{ c = lookup(ID) }}
1910 (opstmt<<C and c>>)*
1911 [ ELSE (opstmt<<C and not c>>)* ]
1914 rule opstmt<<C>>: option<<C>>
1918 rule payload<<C>>: PAYLOAD DIRPATH {{ if (C): payload(DIRPATH) }}
1921 MAINBOARD PATH {{ mainboardsetup(PATH) }}
1923 rule romif<<C>>: IF ID {{ c = lookup(ID) }}
1924 (romstmt<<C and c>>)*
1925 [ ELSE (romstmt<<C and not c>>)* ]
1928 rule romstmt<<C>>: romif<<C>>
1932 rule romimage: ROMIMAGE STR {{ startromimage(dequote(STR)) }}
1934 END {{ endromimage() }}
1936 rule roms: STR {{ s = '[' + STR }}
1937 ( STR {{ s = s + "," + STR }}
1938 )* {{ return eval(s + ']') }}
1940 rule buildrom: BUILDROM DIRPATH expr roms {{ addbuildrom(DIRPATH, expr, roms) }}
1942 rule romstmts: romimage
1946 # ENTRY for parsing root part
1947 rule board: {{ loadoptions("config", "Options.lb", "options") }}
1948 TARGET DIRPATH {{ target(DIRPATH) }}
1953 # ENTRY for parsing a delayed value
1954 rule delexpr: "{" expr "}" EOF {{ return expr }}
1956 rule wrstr<<ID>>: STR {{ setwrite(ID, dequote(STR)) }}
1958 rule defstmts<<ID>>: {{ d = 0 }}
1960 ( value {{ setdefault(ID, value, 1) }}
1961 | NONE {{ setnodefault(ID) }}
1963 | FORMAT STR {{ setformat(ID, dequote(STR)) }}
1965 ( ALWAYS {{ setexported(ID) }}
1966 | USED {{ setexportable(ID) }}
1967 | NEVER {{ setnoexport(ID) }}
1969 | COMMENT STR {{ setcomment(ID, dequote(STR)); d = d | 4 }}
1970 | WRITE (wrstr<<ID>>)+
1973 rule define: DEFINE ID {{ newoption(ID) }}
1974 defstmts<<ID>> END {{ validdef(ID, defstmts) }}
1976 # ENTRY for parsing Options.lb file
1977 rule options: (define)* EOF {{ return 1 }}
1980 #=============================================================================
1982 #=============================================================================
1983 def writemakefileheader(file, fname):
1984 file.write("# File: %s is autogenerated\n" % fname)
1986 def writemakefilefooter(file, fname):
1987 file.write("\n\n%s: %s %s\n"
1988 % (os.path.basename(fname), os.path.abspath(sys.argv[0]), top_config_file))
1989 file.write("\t(cd %s ; export PYTHONPATH=%s/util/newconfig ; python %s %s %s)\n\n"
1990 % (os.getcwd(), treetop, sys.argv[0], sys.argv[1], sys.argv[2]))
1992 def writemakefilesettings(path):
1993 """ Write Makefile.settings to seperate the settings
1994 from the actual makefile creation."""
1996 global treetop, target_dir
1998 filename = os.path.join(path, "Makefile.settings")
1999 print "Creating", filename
2000 file = safe_open(filename, 'w+')
2001 writemakefileheader(file, filename)
2002 file.write("TOP:=%s\n" % (treetop))
2003 file.write("TARGET_DIR:=%s\n" % target_dir)
2004 writemakefilefooter(file, filename)
2007 def writeimagesettings(image):
2008 """Write Makefile.settings to seperate the settings
2009 from the actual makefile creation."""
2012 global global_options_by_order
2014 filename = os.path.join(image.gettargetdir(), "Makefile.settings")
2015 print "Creating", filename
2016 file = safe_open(filename, 'w+')
2017 writemakefileheader(file, filename)
2018 file.write("TOP:=%s\n" % (treetop))
2019 file.write("TARGET_DIR:=%s\n" % (image.gettargetdir()))
2022 for o in global_exported_options:
2024 for o in image.exported_options:
2025 if (not o in exported):
2028 file.write("export %s:=" % o.name)
2029 if (hasvalue(o.name, image)):
2030 file.write("%s" % getformated(o.name, image))
2033 file.write("export VARIABLES :=\n")
2035 file.write("export VARIABLES += %s\n" % o.name)
2037 writemakefilefooter(file,filename)
2040 # write the romimage makefile
2041 # let's try the Makefile
2042 # first, dump all the -D stuff
2044 def writeimagemakefile(image):
2045 makefilepath = os.path.join(image.gettargetdir(), "Makefile")
2046 print "Creating", makefilepath
2047 file = safe_open(makefilepath, 'w+')
2048 writemakefileheader(file, makefilepath)
2051 file.write("\nall: coreboot.rom\n\n")
2052 file.write(".PHONY: all\n\n")
2053 #file.write("include cpuflags\n")
2054 # Putting "include cpuflags" in the Makefile has the problem that the
2055 # cpuflags file would be generated _after_ we want to include it.
2056 # Instead, let make do the work of computing CPUFLAGS:
2057 file.write("# Get the value of TOP, VARIABLES, and several other variables.\n")
2058 file.write("include Makefile.settings\n\n")
2059 file.write("# Function to create an item like -Di586 or -DCONFIG_MAX_CPUS='1' or -Ui686\n")
2060 file.write("D_item = $(shell echo '$(if $(subst undefined,,$(origin $1)),\\#define $1$(if $($1), $($1),),\\#undef $1)' >> settings.h)\n\n")
2061 file.write("# Compute the value of CPUFLAGS here during make's first pass.\n")
2062 file.write("CPUFLAGS := $(strip $(shell echo '/* autogenerated */' > settings.h)$(foreach _var_,$(VARIABLES),$(call D_item,$(_var_)))--include=settings.h)\n\n")
2064 for i in image.getuserdefines():
2065 file.write("%s\n" %i)
2068 # print out all the object dependencies
2069 file.write("\n# object dependencies (objectrules:)\n")
2070 file.write("INIT-OBJECTS :=\n")
2071 file.write("OBJECTS :=\n")
2072 file.write("DRIVER :=\n")
2073 file.write("\nSOURCES :=\n")
2074 for irule, init in image.getinitobjectrules().items():
2077 file.write("INIT-OBJECTS += %s\n" % (i_name))
2078 file.write("SOURCES += %s\n" % (i_source))
2080 for objrule, obj in image.getobjectrules().items():
2083 file.write("OBJECTS += %s\n" % (obj_name))
2084 file.write("SOURCES += %s\n" % (obj_source))
2086 for srule, smm in image.getsmmobjectrules().items():
2089 file.write("SMM-OBJECTS += %s\n" % (s_name))
2090 file.write("SOURCES += %s\n" % (s_source))
2094 file.write("OBJECTS += static.o\n")
2095 file.write("SOURCES += static.c\n")
2097 for driverrule, driver in image.getdriverrules().items():
2098 obj_name = driver[0]
2099 obj_source = driver[1]
2100 file.write("DRIVER += %s\n" % (obj_name))
2101 file.write("SOURCES += %s\n" % (obj_source))
2103 # Print out all ldscript.ld dependencies.
2104 file.write("\n# ldscript.ld dependencies:\n")
2105 file.write("LDSUBSCRIPTS-1 := \n" )
2106 for script in image.getldscripts():
2107 file.write("LDSUBSCRIPTS-1 += %s\n" % topify(script))
2109 # Print out the dependencies for crt0_includes.h
2110 file.write("\n# Dependencies for crt0_includes.h\n")
2111 file.write("CRT0_INCLUDES:=\n")
2112 for inc in image.getinitincludes():
2113 if (local_path.match(inc)):
2114 file.write("CRT0_INCLUDES += %s\n" % inc)
2116 file.write("CRT0_INCLUDES += $(TOP)/src/%s\n" % inc)
2118 # Print out the user defines.
2119 file.write("\n# userdefines:\n")
2121 # Print out the base rules.
2122 # Need to have a rule that counts on 'all'.
2123 file.write("\n# mainrulelist:")
2125 # Print out any user rules.
2126 file.write("\n# From makerule or docipl commands:\n")
2128 file.write("\n# initobjectrules:\n")
2129 for irule, init in image.getinitobjectrules().items():
2130 source = topify(init[1])
2133 # for .S, .o depends on .s
2134 file.write("%s: %s.s\n" % (init[0], init[3]))
2135 file.write("\t$(CC) -c $(CPU_OPT) -o $@ $<\n")
2136 # and .s depends on .S
2137 file.write("%s.s: %s\n" % (init[3], source))
2138 # Note: next 2 lines are ONE output line!
2139 file.write("\t$(CPP) $(CPPFLAGS) $< ")
2140 file.write(">$@.new && mv $@.new $@\n")
2142 file.write("%s: %s\n" % (init[0], source))
2143 file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
2145 file.write("\n# objectrules:\n")
2146 for objrule, obj in image.getobjectrules().items():
2147 source = topify(obj[1])
2150 # for .S, .o depends on .s
2151 file.write("%s: %s.s\n" % (obj[0], obj[3]))
2152 file.write("\t$(CC) -c $(CPU_OPT) -o $@ $<\n")
2153 # and .s depends on .S
2154 file.write("%s.s: %s\n" % (obj[3], source))
2155 # Note: next 2 lines are ONE output line!
2156 file.write("\t$(CPP) $(CPPFLAGS) $< ")
2157 file.write(">$@.new && mv $@.new $@\n")
2159 file.write("%s: %s\n" % (obj[0], source))
2160 file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
2161 #file.write("%s\n" % objrule[2])
2163 for driverrule, driver in image.getdriverrules().items():
2164 source = topify(driver[1])
2165 file.write("%s: %s\n" % (driver[0], source))
2166 file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
2167 #file.write("%s\n" % objrule[2])
2169 file.write("\n# smmobjectrules:\n")
2170 for irule, smm in image.getsmmobjectrules().items():
2171 source = topify(smm[1])
2174 # for .S, .o depends on .s
2175 file.write("%s: %s.s\n" % (smm[0], smm[3]))
2176 file.write("\t$(CC) -c $(CPU_OPT) -o $@ $<\n")
2177 # and .s depends on .S
2178 file.write("%s.s: %s\n" % (smm[3], source))
2179 # Note: next 2 lines are ONE output line!
2180 file.write("\t$(CPP) $(CPPFLAGS) $< ")
2181 file.write(">$@.new && mv $@.new $@\n")
2183 file.write("%s: %s\n" % (smm[0], source))
2184 file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
2186 # special rule for chip_target.c
2187 file.write("static.o: static.c\n")
2188 file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
2190 # Print out the rules that will make cause the files
2191 # generated by NLBConfig.py to be remade if any dependencies change.
2193 file.write("\n# Remember the automatically generated files\n")
2194 file.write("GENERATED:=\n")
2195 for genfile in ['Makefile',
2198 'corebootDoc.config' ]:
2199 file.write("GENERATED += %s\n" % genfile)
2200 file.write("GENERATED += %s\n" % image.getincludefilename())
2202 keys = global_options_by_order
2204 file.write("\necho:\n")
2206 file.write("\t@echo %s='$(%s)'\n"% (key,key))
2208 for i, m in image.getmakerules().items():
2209 file.write("%s: " %i)
2210 for i in m.dependency:
2211 file.write("%s " % i)
2214 file.write("\t%s\n" % i)
2215 writemakefilefooter(file, makefilepath)
2219 def writemakefile(path):
2221 global bootblocksize
2222 makefilepath = os.path.join(path, "Makefile")
2223 print "Creating", makefilepath
2224 file = safe_open(makefilepath, 'w+')
2225 writemakefileheader(file, makefilepath)
2228 file.write("\nall: romtool")
2230 file.write(" %sfs" % i.name)
2234 file.write("\nromtool:\n\tcd $(TOP)/util/romtool; make\n")
2236 file.write("include Makefile.settings\n\n")
2237 for i, o in romimages.items():
2238 file.write("%s/coreboot.rom:\n" % o.getname())
2239 file.write("\tif (cd %s; \\\n" % o.getname())
2240 file.write("\t\t$(MAKE) coreboot.rom)\\\n")
2241 file.write("\tthen true; else exit 1; fi;\n\n")
2242 file.write("clean: ")
2243 for i in romimages.keys():
2244 file.write(" %s-clean" % i)
2245 file.write(" base-clean")
2247 for i, o in romimages.items():
2248 file.write("%s-clean:\n" % o.getname())
2249 file.write("\t(cd %s; $(MAKE) clean)\n\n" % o.getname())
2250 file.write("base-clean:\n")
2251 file.write("\trm -f romcc*\n\n")
2254 file.write("%s:" % i.name)
2256 file.write(" %s/coreboot.rom " % j)
2258 file.write("\t cat ")
2260 file.write(" %s/coreboot.rom " % j)
2261 file.write("> %s\n\n" %i.name)
2262 # build the bootblock here as well.
2264 file.write("\t cat ")
2266 file.write(" %s/coreboot.strip " % j)
2267 file.write("> %s.bootblock\n\n" %i.name)
2269 romsize = getoption("ROM_SIZE", image)
2270 # i.name? That can not be right, can it?
2271 file.write("%sfs: %s $(TOP)/util/romtool/romtool\n" %(i.name,i.name));
2272 file.write("\trm -f coreboot.romfs\n");
2273 file.write("\t$(TOP)/util/romtool/romtool %sfs create %s %s %s.bootblock\n" % (i.name, romsize, bootblocksize, i.name))
2276 #failover is a hack that will go away soon.
2277 if (j != "failover") and (rommapping[j] != "/dev/null"):
2278 file.write("\t $(TOP)/util/romtool/romtool %sfs add-payload %s %s/payload\n" % (i.name, rommapping[j], j))
2279 file.write("\t $(TOP)/util/romtool/romtool %sfs print\n" % i.name)
2281 file.write(".PHONY: all clean romtool")
2282 for i in romimages.keys():
2283 file.write(" %s-clean" % i)
2284 for i, o in romimages.items():
2285 file.write(" %s/coreboot.rom" % o.getname())
2288 writemakefilefooter(file, makefilepath)
2291 def writeinitincludes(image):
2292 global include_pattern
2293 filepath = os.path.join(image.gettargetdir(), image.getincludefilename())
2294 print "Creating", filepath
2295 outfile = safe_open(filepath, 'w+')
2296 if (image.newformat()):
2297 infile = safe_open(image.getinitfile(), 'r')
2299 line = infile.readline()
2301 p = include_pattern.match(line)
2303 for i in image.getinitincludes():
2304 inc = image.getinitinclude(i)
2305 if (inc.getstring() == p.group(1)):
2306 outfile.write("#include \"%s\"\n" % inc.getpath())
2309 line = infile.readline()
2313 for i in image.getinitincludes():
2314 outfile.write("#include <%s>\n" % i)
2317 def writeldoptions(image):
2318 """Write ldoptions file."""
2319 filename = os.path.join(image.gettargetdir(), "ldoptions")
2320 print "Creating", filename
2321 file = safe_open(filename, 'w+')
2322 for o in global_exported_options:
2323 if (hasvalue(o.name, image) and IsInt(getoption(o.name, image))):
2324 file.write("%s = %s;\n" % (o.name, getformated(o.name, image)))
2325 for o in image.exported_options:
2326 if (not o in global_exported_options and hasvalue(o.name, image) and IsInt(getoption(o.name, image))):
2327 file.write("%s = %s;\n" % (o.name, getformated(o.name, image)))
2330 def dumptree(part, lvl):
2331 debug.info(debug.dumptree, "DUMPTREE ME is")
2333 # dump the siblings -- actually are there any? not sure
2335 debug.info(debug.dumptree, "DUMPTREE SIBLINGS are")
2336 kid = part.next_sibling
2339 kid = kid.next_sibling
2341 debug.info(debug.dumptree, "DUMPTREE KIDS are")
2342 #for kid in part.children:
2344 dumptree(part.children, lvl+1)
2345 kid = part.next_sibling
2348 dumptree(kid.children, lvl + 1)
2349 kid = kid.next_sibling
2350 debug.info(debug.dumptree, "DONE DUMPTREE")
2352 def writecode(image):
2353 filename = os.path.join(img_dir, "static.c")
2354 print "Creating", filename
2355 file = safe_open(filename, 'w+')
2356 file.write("#include <device/device.h>\n")
2357 file.write("#include <device/pci.h>\n")
2358 for path in image.getconfigincludes().values():
2359 file.write("#include \"%s\"\n" % path)
2360 file.write("\n/* pass 0 */\n")
2361 gencode(image.getroot(), file, 0)
2362 file.write("\n/* pass 1 */\n")
2363 gencode(image.getroot(), file, 1)
2366 def gencode(part, file, pass_num):
2367 debug.info(debug.gencode, "GENCODE ME is")
2368 part.gencode(file, pass_num)
2369 # dump the siblings -- actually are there any? not sure
2370 debug.info(debug.gencode, "GENCODE SIBLINGS are")
2371 kid = part.next_sibling
2373 kid.gencode(file, pass_num)
2374 kid = kid.next_sibling
2375 # now dump the children
2376 debug.info(debug.gencode, "GENCODE KIDS are")
2378 gencode(part.children, file, pass_num)
2379 kid = part.next_sibling
2382 gencode(kid.children, file, pass_num)
2383 kid = kid.next_sibling
2384 debug.info(debug.gencode, "DONE GENCODE")
2386 def writegraph(image):
2387 filename = os.path.join(img_dir, "static.dot")
2388 print "Creating", filename
2389 file = safe_open(filename, 'w+')
2390 file.write("digraph devicetree {\n")
2391 file.write(" rankdir=LR\n")
2392 genranks(image.getroot(), file, 0)
2393 gennodes(image.getroot(), file)
2394 gengraph(image.getroot(), file)
2398 def genranks(part, file, level):
2399 #file.write(" # Level %d\n" % level )
2400 file.write(" { rank = same; \"dev_%s_%d\"" % (part.type_name,part.instance ))
2401 sib = part.next_sibling
2403 file.write("; \"dev_%s_%d\"" % (sib.type_name, sib.instance))
2404 sib = sib.next_sibling
2406 # now dump the children
2408 genranks(part.children, file, level + 1)
2410 kid = part.next_sibling
2413 genranks(kid.children, file, level + 1)
2414 kid = kid.next_sibling
2417 def gennodes(part, file):
2418 file.write(" dev_%s_%d[shape=record, label=\"%s\"];\n" % (part.type_name,part.instance,part.graph_name() ))
2419 sib = part.next_sibling
2421 file.write(" dev_%s_%d[shape=record, label=\"%s\"];\n" % (sib.type_name,sib.instance,sib.graph_name() ))
2422 sib = sib.next_sibling
2423 # now dump the children
2425 gennodes(part.children, file)
2427 kid = part.next_sibling
2430 gennodes(kid.children, file)
2431 kid = kid.next_sibling
2434 def gengraph(part, file):
2435 if (part.parent != part):
2436 file.write(" dev_%s_%d -> dev_%s_%d;\n" % \
2437 (part.parent.type_name, part.parent.instance, \
2438 part.type_name, part.instance ))
2439 sib = part.next_sibling
2441 file.write(" dev_%s_%d -> dev_%s_%d;\n" % \
2442 (sib.parent.type_name, sib.parent.instance, \
2443 sib.type_name, sib.instance ))
2444 sib = sib.next_sibling
2446 kid = part.next_sibling
2449 gengraph(kid.children, file)
2450 kid = kid.next_sibling
2453 gengraph(part.children, file)
2456 """Add any run-time checks to verify that parsing the configuration
2459 for image in romimages.values():
2460 print("Verifying ROMIMAGE %s" % image.name)
2461 if (image.newformat() and image.getinitfile() == ''):
2462 fatal("An init file must be specified")
2463 for op in image.exported_options:
2464 if (getoptionvalue(op.name, op, image) == 0 and getoptionvalue(op.name, op, 0) == 0):
2465 warning("Exported option %s has no value (check Options.lb)" % op.name);
2466 print("Verifing global options")
2467 for op in global_exported_options:
2468 if (getoptionvalue(op.name, op, 0) == 0):
2469 notice("Exported option %s has no value (check Options.lb)" % op.name);
2471 #=============================================================================
2473 #=============================================================================
2474 if __name__=='__main__':
2475 from sys import argv
2477 fatal("Args: <file> <path to coreboot>")
2479 top_config_file = os.path.abspath(sys.argv[1])
2481 treetop = os.path.abspath(sys.argv[2])
2483 # Now read in the customizing script...
2485 fp = safe_open(argv[1], 'r')
2486 if (not parse('board', fp.read())):
2487 fatal("Could not parse file")
2492 # no longer need to check if an options has been used
2495 for image_name, image in romimages.items():
2496 if (debug.level(debug.dumptree)):
2497 debug.info(debug.dumptree, "DEVICE TREE:")
2498 dumptree(image.getroot(), 0)
2500 img_dir = image.gettargetdir()
2501 if not os.path.isdir(img_dir):
2502 print "Creating directory %s" % img_dir
2503 os.makedirs(img_dir)
2505 for objrule, obj in image.getobjectrules().items():
2506 sub_dir = img_dir + '/' + os.path.dirname(obj[0])
2507 if not os.path.isdir(sub_dir):
2508 print "Creating sub directory %s" % sub_dir
2509 os.makedirs(sub_dir)
2511 for driverrule, driver in image.getdriverrules().items():
2512 sub_dir = img_dir + '/' + os.path.dirname(driver[0])
2513 if not os.path.isdir(sub_dir):
2514 print "Creating sub directory %s" % sub_dir
2515 os.makedirs(sub_dir)
2517 for srule, smm in image.getsmmobjectrules().items():
2518 sub_dir = img_dir + '/' + os.path.dirname(smm[0])
2519 if not os.path.isdir(sub_dir):
2520 print "Creating sub directory %s" % sub_dir
2521 os.makedirs(sub_dir)
2523 for irule, init in image.getinitobjectrules().items():
2524 sub_dir = img_dir + '/' + os.path.dirname(init[0])
2525 if not os.path.isdir(sub_dir):
2526 print "Creating sub directory %s" % sub_dir
2527 os.makedirs(sub_dir)
2529 if (debug.level(debug.dump)):
2530 for i in image.getinitincludes():
2531 debug.info(debug.dump, "crt0include file %s" % i)
2532 for i in image.getdriverrules().keys():
2533 debug.info(debug.dump, "driver file %s" % i)
2534 for i in image.getldscripts():
2535 debug.info(debug.dump, "ldscript file %s" % i)
2536 for i, m in image.getmakerules().items():
2537 debug.info(debug.dump, " makerule %s dep %s act %s" % (i, m.dependency, m.actions))
2540 writeimagesettings(image)
2541 writeinitincludes(image)
2542 writeimagemakefile(image)
2543 writeldoptions(image)
2546 writemakefilesettings(target_dir)
2547 writemakefile(target_dir)