new register format

git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1007 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Greg Watson 2003-07-23 18:13:19 +00:00
parent 3874d40ad6
commit 252d3ff1f6
2 changed files with 38 additions and 27 deletions

View File

@ -34,7 +34,9 @@ end
## ##
southbridge winbond/w83c553 end southbridge winbond/w83c553 end
superio NSC/pc97307 superio NSC/pc97307
register ".com1={1}, .lpt={0}, .port=SIO_COM1_BASE" register "com1" = "{1}"
register "lpt" = "{0}"
register "port" = "SIO_COM1_BASE"
end end
## ##

View File

@ -528,25 +528,19 @@ class partobj:
self.children = 0 self.children = 0
self.siblings = 0 self.siblings = 0
self.initcode = [] self.initcode = []
self.registercode = [] self.registercode = {}
# sibling is not a list. # sibling is not a list.
self.type = type self.type = type
self.objects = [] self.objects = []
self.dir = dir self.dir = dir
self.irq = 0 self.irq = 0
self.instance = image.newpartinstance() self.instance = image.newpartinstance()
self.flatten_name = flatten_name(type + "/" + name) self.flatten_name = flatten_name(os.path.join(type, name))
debug.info(debug.object, "INSTANCE %d" % self.instance) debug.info(debug.object, "INSTANCE %d" % self.instance)
self.devfn = 0 self.devfn = 0
self.private = 0 self.private = 0
self.uses_options = {} self.uses_options = {}
# chip initialization. If there is a chip.h in the self.chipconfig = 0
# directory, generate the structs etc. to
# initialize the code
if (os.path.exists(dir + "/" + "chip.h")):
self.chipconfig = 1
else:
self.chipconfig = 0
if (parent): if (parent):
debug.info(debug.gencode, "add to parent") debug.info(debug.gencode, "add to parent")
@ -575,14 +569,14 @@ class partobj:
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 f, v in self.registercode.items():
print " %s" % i print " %s = %s" % (f, v)
print "\n" print "\n"
def gencode(self, file): def gencode(self, file):
if (self.chipconfig): if (self.chipconfig):
debug.info(debug.gencode, "gencode: chipconfig(%d)" % self.instance) debug.info(debug.gencode, "gencode: chipconfig(%d)" % self.instance)
file.write("#include \"%s/chip.h\"\n" % self.dir) file.write("#include \"%s\"\n" % os.path.join(self.dir, self.chipconfig))
file.write("extern struct chip_control %s_control;\n" % \ file.write("extern struct chip_control %s_control;\n" % \
self.flatten_name) self.flatten_name)
file.write("struct %s_config %s_config_%d" % (\ file.write("struct %s_config %s_config_%d" % (\
@ -591,9 +585,9 @@ class partobj:
self.instance)) self.instance))
if (self.registercode): if (self.registercode):
file.write("\t= {\n") file.write("\t= {\n")
for i in self.registercode: for f, v in self.registercode.items():
file.write( "\t %s" % i) file.write( " .%s = %s;\n" % (f, v))
file.write("\t};\n") file.write("};\n")
else: else:
file.write(";") file.write(";")
file.write("\n"); file.write("\n");
@ -629,9 +623,13 @@ class partobj:
def addinit(self, code): def addinit(self, code):
self.initcode.append(code) self.initcode.append(code)
def addregister(self, code): def addconfig(self, path):
code = dequote(code) self.chipconfig = path
self.registercode.append(code)
def addregister(self, field, value):
field = dequote(field)
value = dequote(value)
setdict(self.registercode, field, value)
def usesoption(self, name): def usesoption(self, name):
global global_options global global_options
@ -865,10 +863,15 @@ def addinit(path):
curimage.setinitfile(dirstack.tos() + '/' + path) curimage.setinitfile(dirstack.tos() + '/' + path)
print "Adding init file: %s" % path print "Adding init file: %s" % path
def addregister(code): def addconfig(path):
global partstack global partstack
curpart = partstack.tos() curpart = partstack.tos()
curpart.addregister(code) curpart.addconfig(path)
def addregister(field, value):
global partstack
curpart = partstack.tos()
curpart.addregister(field, value)
def addcrt0include(path): def addcrt0include(path):
"""we do the crt0include as a dictionary, so that if needed we """we do the crt0include as a dictionary, so that if needed we
@ -1100,6 +1103,7 @@ parser Config:
token ARCH: 'arch' token ARCH: 'arch'
token BUILDROM: 'buildrom' token BUILDROM: 'buildrom'
token COMMENT: 'comment' token COMMENT: 'comment'
token CONFIG: 'config'
token CPU: 'cpu' token CPU: 'cpu'
token DEFAULT: 'default' token DEFAULT: 'default'
token DEFINE: 'define' token DEFINE: 'define'
@ -1239,7 +1243,9 @@ parser Config:
rule init<<C>>: INIT DIRPATH {{ if (C): addinit(DIRPATH) }} rule init<<C>>: INIT DIRPATH {{ if (C): addinit(DIRPATH) }}
rule register<<C>>: REGISTER STR {{ if (C): addregister(STR) }} rule field: STR {{ return STR }}
rule register<<C>>: REGISTER field '=' STR {{ if (C): addregister(field, STR) }}
rule prtval: expr {{ return str(expr) }} rule prtval: expr {{ return str(expr) }}
| STR {{ return STR }} | STR {{ return STR }}
@ -1252,8 +1258,11 @@ parser Config:
[ "," prtlist {{ val = val + prtlist }} [ "," prtlist {{ val = val + prtlist }}
] {{ if (C): print eval(val) }} ] {{ if (C): print eval(val) }}
rule config<<C>>: CONFIG PATH {{ if (C): addconfig(PATH) }}
rule stmt<<C>>: arch<<C>> {{ return arch}} rule stmt<<C>>: arch<<C>> {{ return arch}}
| addaction<<C>> {{ return addaction }} | addaction<<C>> {{ return addaction }}
| config<<C>> {{ return config}}
| cpu<<C>> {{ return cpu}} | cpu<<C>> {{ return cpu}}
| dir<<C>> {{ return dir}} | dir<<C>> {{ return dir}}
| driver<<C>> {{ return driver }} | driver<<C>> {{ return driver }}
@ -1459,8 +1468,8 @@ def writeimagemakefile(image):
file.write("SOURCES += %s\n" % (obj_source)) file.write("SOURCES += %s\n" % (obj_source))
# for chip_target.c # for chip_target.c
file.write("OBJECTS += chip_%s.o\n" % target_name) file.write("OBJECTS += static.o\n")
file.write("SOURCES += chip_%s.c\n" % target_name) file.write("SOURCES += static.c\n")
for driverrule, driver in image.getdriverrules().items(): for driverrule, driver in image.getdriverrules().items():
obj_name = driver[0] obj_name = driver[0]
@ -1527,7 +1536,7 @@ def writeimagemakefile(image):
#file.write("%s\n" % objrule[2]) #file.write("%s\n" % objrule[2])
# special rule for chip_target.c # special rule for chip_target.c
file.write("chip_%s.o: chip_%s.c\n" % (target_name, target_name)) file.write("static.o: static.c\n")
file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n") file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
# Print out the rules that will make cause the files # Print out the rules that will make cause the files
@ -1537,7 +1546,7 @@ def writeimagemakefile(image):
file.write("GENERATED:=\n") file.write("GENERATED:=\n")
for genfile in ['Makefile', for genfile in ['Makefile',
'nsuperio.c', 'nsuperio.c',
'chip_%s.c' % target_name, 'static.c',
'LinuxBIOSDoc.config' ]: 'LinuxBIOSDoc.config' ]:
file.write("GENERATED += %s\n" % genfile) file.write("GENERATED += %s\n" % genfile)
file.write("GENERATED += %s\n" % image.getincludefilename()) file.write("GENERATED += %s\n" % image.getincludefilename())
@ -1649,7 +1658,7 @@ def dumptree(part, lvl):
debug.info(debug.dumptree, "DONE DUMPTREE") debug.info(debug.dumptree, "DONE DUMPTREE")
def writecode(image): def writecode(image):
filename = os.path.join(img_dir, "chip_%s.c" % target_name) filename = os.path.join(img_dir, "static.c")
print "Creating", filename print "Creating", filename
file = open(filename, 'w+') file = open(filename, 'w+')
# gen all the forward references # gen all the forward references