diff --git a/src/arch/i386/config/make.base b/src/arch/i386/config/make.base index 2a428a0cff..a7c2b79a37 100644 --- a/src/arch/i386/config/make.base +++ b/src/arch/i386/config/make.base @@ -1,6 +1,7 @@ option _ROMBASE=0xf0000 option _RAMBASE=0x4000 option ROM_IMAGE_SIZE=65536 +option PAYLOAD_SIZE=458752 # By default we only have one cpu option MAX_CPUS=1 @@ -24,7 +25,7 @@ dir /src/config makerule all : romimage ; makerule floppy : all ; mcopy -o romimage a: -makerule romimage : linuxbios.rom payload.bin.gz.block ; cat payload.bin.gz.block linuxbios.rom > romimage +makerule romimage : linuxbios.rom payload.block ; cat payload.block linuxbios.rom > romimage makerule linuxbios.rom: linuxbios.strip ; @@ -36,12 +37,13 @@ addaction linuxbios.rom dd if=linuxbios.strip of=linuxbios.rom bs=1 seek=`expr $ makerule mkrom: $(TOP)/mkrom/mkrom.c ; $(CC) -o mkrom $< -makerule payload.bin.gz.block : payload.bin.gz ; dd conv=sync bs=448k if=payload.bin.gz of=payload.bin.gz.block -makerule payload.bin.gz: payload.bin ;gzip -f -3 payload.bin -makerule payload.bin: $(PAYLOAD) ; objcopy -O binary -R .note -R .comment -S $< payload.bin +makerule payload.block : $(if $(PAYLOAD),$(PAYLOAD), linux.bin.gz) ; dd conv=sync bs=$(PAYLOAD_SIZE) if=$< of=$@ + +makerule linux.bin.gz: linux.bin ;gzip -f -3 linux.bin +makerule linux.bin: $(LINUX) ; objcopy -O binary -R .note -R .comment -S $< $@ -addaction clean rm -f romimage mkrom payload.* +addaction clean rm -f romimage mkrom linux.* payload.* # do standard config files that the user need not specify # for now, this is just 'lib', but it may be more later. diff --git a/src/config/Config b/src/config/Config index e074fdf953..3e8134cf14 100644 --- a/src/config/Config +++ b/src/config/Config @@ -25,9 +25,12 @@ addaction linuxbios nm -n linuxbios > linuxbios.map makerule linuxbios.a : $(OBJECTS-1) ; rm -f linuxbios.a addaction linuxbios.a ar cr linuxbios.a $(OBJECTS-1) -makerule crt0.s: crt0.S ; $(CPP) $(CPPFLAGS) -I$(TOP)/src $< > crt0.s +makerule crt0.s: crt0.S ; @echo "$(CPP) ... $< > $crt0.s " +addaction crt0.s @$(CPP) $(CPPFLAGS) -I$(TOP)/src $< > crt0.s + +makerule crt0.o : crt0.s; @echo $(CC) ... -o $@ $< +addaction crt0.o @$(CC) -c $(CPU_OPT) -o $@ $< -makerule crt0.o : crt0.s; $(CC) $(CPU_OPT) -c crt0.s makerule etags: $(SOURCES) ; etags $(SOURCES) makerule tags: $(SOURCES) ; ctags $(SOURCES) diff --git a/src/include/part/fallback_boot.h b/src/include/part/fallback_boot.h index 95b0c210a8..468e5cef67 100644 --- a/src/include/part/fallback_boot.h +++ b/src/include/part/fallback_boot.h @@ -3,11 +3,7 @@ #if !defined(ASSEMBLY) -#if USE_FALLBACK_BOOT void boot_successful(void); -# else -# define boot_successful() -#endif #endif /* ASSEMBLY */ diff --git a/src/lib/Config b/src/lib/Config index 338c78cef8..66ca841250 100644 --- a/src/lib/Config +++ b/src/lib/Config @@ -15,5 +15,5 @@ object elfboot.o object do_inflate.o object floppy_subr.o object delay.o -object fallback_boot.o USE_FALLBACK_BOOT +object fallback_boot.o object compute_ip_checksum.o \ No newline at end of file diff --git a/src/mainboard/intel/l440gx/Config b/src/mainboard/intel/l440gx/Config index 213924401e..48a927aa64 100644 --- a/src/mainboard/intel/l440gx/Config +++ b/src/mainboard/intel/l440gx/Config @@ -12,9 +12,54 @@ mainboardinit superio/NSC/pc87309/setup_serial.inc mainboardinit pc80/serial.inc mainboardinit arch/i386/lib/console.inc + +# +# Inspired by the cache as ram testing... +# + +biosbase 0xffff0000 +rambase 0x00000800 +option XIP_ROM_BASE=0xffff0000 +option XIP_ROM_SIZE=0x10000 +option STACK_SIZE=0x2000 + +####### +## Testing of the cache ram idea on a PIII +####### + +option CACHE_RAM_BASE=0xfff00000 +option CACHE_RAM_SIZE=0x00010000 +option USE_CACHE_RAM=1 +nooption USE_DEFAULT_LAYOUT +option RAMTEST=1 + +mainboardinit cpu/i786/earlymtrr.inc +#mainboardinit ram/ramtest.inc +mainboardinit cpu/p6/cache_ram_init.inc +#mainboardinit mainboard/supermicro/p4dc6/cache_test.inc +mainboardinit cpu/p6/cache_ram_start.inc +mainboardinit cpu/p6/cache_ram_fini.inc + +option USE_GENERIC_SDRAM=1 +option USE_GENERIC_SDRAM_ENABLE=1 +option USE_PIIX4E_SMBUS=1 +option USE_GENERIC_DUMP_SPD=1 +option USE_GENERIC_ZERO_ECC_SDRAM=1 +option USE_RAMTEST=1 +object mainboard_raminit.c + +option SMBUS_MEM_DEVICE_START=0x50 +option SMBUS_MEM_DEVICE_END=0x53 +option SMBUS_MEM_DEVICE_INC=1 +dir /src/sdram +dir /src/ram + + +####### + northbridge intel/440gx southbridge intel/piix4e -mainboardinit cpu/p6/earlymtrr.inc +#mainboardinit cpu/p6/earlymtrr.inc superio NSC/pc87309 diff --git a/src/mainboard/supermicro/p4dc6/Config b/src/mainboard/supermicro/p4dc6/Config index a9b14d0789..f44ef990c6 100644 --- a/src/mainboard/supermicro/p4dc6/Config +++ b/src/mainboard/supermicro/p4dc6/Config @@ -14,21 +14,19 @@ option CACHE_RAM_BASE=0xfff70000 option CACHE_RAM_SIZE=0x00010000 nooption USE_DEFAULT_LAYOUT option STACK_SIZE=0x2000 -option USE_FALLBACK_BOOT=1 +option USE_FALLBACK_IMAGE=0 +option ROM_SIZE=524288 -#option USE_RAMTEST=1 -#dir /src/ram +expr USE_NORMAL_IMAGE=!USE_FALLBACK_IMAGE +expr ROM_SECTION_SIZE =(USE_FALLBACK_IMAGE*65536)+(USE_NORMAL_IMAGE*(ROM_SIZE - 65536)) +expr ROM_SECTION_OFFSET=(USE_FALLBACK_IMAGE*(ROM_SIZE-65536))+(USE_NORMAL_IMAGE*0) + +expr ZKERNEL_START =(0xffffffff - ROM_SIZE + ROM_SECTION_OFFSET + 1) +expr PAYLOAD_SIZE =ROM_SECTION_SIZE - ROM_IMAGE_SIZE +expr _ROMBASE =ZKERNEL_START + PAYLOAD_SIZE +expr XIP_ROM_SIZE = 65536 +expr XIP_ROM_BASE = _ROMBASE + ROM_IMAGE_SIZE - XIP_ROM_SIZE -#/* falback */ -option ZKERNEL_START=0xffff0000 -option _ROMBASE= 0xffff8000 -option XIP_ROM_BASE= 0xffff8000 -option XIP_ROM_SIZE= 0x00008000 -##/* normal image */ -#option ZKERNEL_START=0xfff80000 -#option _ROMBASE= 0xfffe8000 -#option XIP_ROM_BASE= 0xfffe8000 -#option XIP_ROM_SIZE= 0x00008000 mainboardinit northbridge/intel/82860/reset_test.inc mainboardinit arch/i386/lib/noop_failover.inc USE_NORMAL_IMAGE diff --git a/src/mainboard/supermicro/p4dc6/example-fallback.config b/src/mainboard/supermicro/p4dc6/example-fallback.config new file mode 100644 index 0000000000..f52fa1547b --- /dev/null +++ b/src/mainboard/supermicro/p4dc6/example-fallback.config @@ -0,0 +1,37 @@ +# This will make a target directory of ./winfast +# Note that this is RELATIVE TO WHERE YOU ARE WHEN YOU RUN THE +# CONFIG TOOL. Make it absolute if you like +target /home/eric/projects/freebios/p4dc6-build/normal + +mainboard supermicro/p4dc6 + +option USE_FALLBACK_IMAGE=1 +option ROM_SIZE=524288 +#option ROM_SIZE=1048576 +option ROM_IMAGE_SIZE=32768 + + +# Enable Serial Console for debugging +# It will come up at 115200,8n1 +option SERIAL_CONSOLE=1 +#nooption SERIAL_CONSOLE +#option TTYS0_BAUD=9600 +option TTYS0_BAUD=115200 + +# Generate debugging output +option DEFAULT_CONSOLE_LOGLEVEL=9 +option MAXIMUM_CONSOLE_LOGLEVEL=6 +#option DEFAULT_CONSOLE_LOGLEVEL=5 + +# Select the boot device +#option USE_CACHE_RAM=1 +option USE_GENERIC_ROM=1 +#option BOOT_FLOPPY=1 +#option USE_SERIAL_FILL_INBUF=1 +#option BOOT_IDE=1 + +# Use the elf bootloader +option USE_ELF_BOOT=1 + +# Load etherboot with the elf bootloader +payload ../eepro100.ebi diff --git a/src/mainboard/supermicro/p4dc6/example-normal.config b/src/mainboard/supermicro/p4dc6/example-normal.config new file mode 100644 index 0000000000..a619525dc7 --- /dev/null +++ b/src/mainboard/supermicro/p4dc6/example-normal.config @@ -0,0 +1,37 @@ +# This will make a target directory of ./winfast +# Note that this is RELATIVE TO WHERE YOU ARE WHEN YOU RUN THE +# CONFIG TOOL. Make it absolute if you like +target /home/eric/projects/freebios/p4dc6-build/normal + +mainboard supermicro/p4dc6 + +option USE_FALLBACK_IMAGE=0 +option ROM_SIZE=524288 +#option ROM_SIZE=1048576 +option ROM_IMAGE_SIZE=49152 + + +# Enable Serial Console for debugging +# It will come up at 115200,8n1 +option SERIAL_CONSOLE=1 +#nooption SERIAL_CONSOLE +#option TTYS0_BAUD=9600 +option TTYS0_BAUD=115200 + +# Generate debugging output +option DEFAULT_CONSOLE_LOGLEVEL=9 +option MAXIMUM_CONSOLE_LOGLEVEL=8 +#option DEFAULT_CONSOLE_LOGLEVEL=5 + +# Select the boot device +#option USE_CACHE_RAM=1 +option USE_GENERIC_ROM=1 +#option BOOT_FLOPPY=1 +#option USE_SERIAL_FILL_INBUF=1 +#option BOOT_IDE=1 + +# Use the elf bootloader +option USE_ELF_BOOT=1 + +# Load etherboot with the elf bootloader +payload ../eepro100.ebi diff --git a/src/mainboard/supermicro/p4dc6/mainboard.c b/src/mainboard/supermicro/p4dc6/mainboard.c index 4781f7500e..c6a1d3424e 100644 --- a/src/mainboard/supermicro/p4dc6/mainboard.c +++ b/src/mainboard/supermicro/p4dc6/mainboard.c @@ -39,7 +39,6 @@ void mainboard_fixup(void) #endif ich2_power_after_power_fail(1); w832627hf_power_after_power_fail(POWER_ON); - printk_notice("Please add a mainboard_fixup!\n"); return; } diff --git a/src/rom/rom_fill_inbuf.c b/src/rom/rom_fill_inbuf.c index 81249a65e2..8398a306d0 100644 --- a/src/rom/rom_fill_inbuf.c +++ b/src/rom/rom_fill_inbuf.c @@ -67,8 +67,8 @@ static byte_offset_t rom_read_bytes(int cp, void *vdest, byte_offset_t count) return bytes; } length = K64 - block_offset; - if (length > count) { - length = count; + if (length > (count - bytes)) { + length = count - bytes; } if (cp) { memcpy(dest, nvram + block_offset, length); diff --git a/src/southbridge/intel/82801/ich2_cpu.c b/src/southbridge/intel/82801/ich2_cpu.c index 6477815d89..0c1323ef73 100644 --- a/src/southbridge/intel/82801/ich2_cpu.c +++ b/src/southbridge/intel/82801/ich2_cpu.c @@ -2,20 +2,29 @@ #include #include #include +#include +#include #include "82801.h" void ich2_set_cpu_multiplier(unsigned multiplier) { - u32 dword; + u32 dword, old_dword; struct pci_dev *dev; + unsigned old_multiplier; dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_1F0, 0); if (!dev) { printk_err("Cannot find device %08x:%08x\n", PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_1F0); return; } - pci_read_config_dword(dev, GEN_STS, &dword); + pci_read_config_dword(dev, GEN_STS, &old_dword); + dword = old_dword; dword &= ~((1 << 12) - (1 << 8)); dword |= (multiplier & 0xf) << 8; - pci_write_config_dword(dev, GEN_STS, dword); + if (dword != old_dword) { + pci_write_config_dword(dev, GEN_STS, dword); + printk_info("Rebooting to change the cpu multiplier\n"); + boot_successful(); + hard_reset(); + } } diff --git a/util/config/NLBConfig.py b/util/config/NLBConfig.py index 2757fa0840..2d782a8625 100644 --- a/util/config/NLBConfig.py +++ b/util/config/NLBConfig.py @@ -11,7 +11,6 @@ # $Id$ # Author: # Modified by Jan Kok to improve readability of Makefile, etc. - import sys import os import re @@ -31,7 +30,7 @@ crt0base = '' ldscriptbase = '' makeoptions = {} -makenooptions = {} +makeexpressions = [] # Key is the rule name. Value is a mkrule object. makebaserules = {} @@ -45,6 +44,67 @@ target_dir = '' objectrules = [] userdefines = [] + +# ----------------------------------------------------------------------------- +# Error Handling +# ----------------------------------------------------------------------------- + +class location: + class place: + def __init__(self, file, line, command): + self.file = file + self.line = line + self.command = command + def next_line(self, command): + self.line = self.line + 1 + self.command = command + def at(self): + return "%s:%d" % (self.file, self.line) + + def __init__ (self): + self.stack = [] + + def file(self): + return self.stack[-1].file + def line(self): + return self.stack[-1].line + def command(self): + return self.stack[-1].command + + def push_file(self, file): + self.stack.append(self.place(file, 0, "")) + def pop_file(self): + self.stack.pop() + def next_line(self, command): + self.stack[-1].next_line(command) + def at(self): + return self.stack[-1].at() +loc = location() + +def fatal(string): + global loc + size = len(loc.stack) + i = 0 + while(i < size -1): + print loc.stack[i].at() + i = i + 1 + print "%s: %s"% (loc.at(), string) + sys.exit(1) + +def warning(string): + global loc + print "===> Warning:" + size = len(loc.stack) + i = 0 + while(i < size -1): + print loc.stack[i].at() + i = i + 1 + print "%s: %s"% (loc.at(), string) + +# ----------------------------------------------------------------------------- +# Rules +# ----------------------------------------------------------------------------- + # this is the absolute base rule, and so is very special. mainrulelist = "all" @@ -80,15 +140,14 @@ class mkrule: # This defines the function mkrule(target, depends, action). # It creates a makerule object and records it for later recall. def __init__(self, target, depends, actions): - self.whence = current_config_file() + self.whence = loc.file() self.comments = [] # list of strings self.target = target # string self.depends = depends # string of dependency names self.actions = actions # list of strings if makebaserules.has_key(target): - print "===> Warning: makerule for target '%s' in file" % target - print current_config_file(), "is replacing previous definition in file" - print makebaserules[target].whence + warning("makerule for target '%s' is replacing previous defintion in file %s" % + (target, makebaserules[target].whence)) else: # Keep a list of targets so we can output the rules # in the order that they are defined. @@ -127,22 +186,12 @@ class mkrule: # ----------------------------------------------------------------------------- # Command parsing functions # ----------------------------------------------------------------------------- - -# Keep track of nested config files, for error reporting. -config_file_stack = [] -def current_config_file(): - return config_file_stack[-1] - -# The command being processed, for error reporting. -current_command = '' - + # Match a compiled pattern with a string, die if fails, return list of groups. def match(pattern, string): m = pattern.match(string) if not m: - print "\nBad command syntax: ", current_command - print "in file", current_config_file() - sys.exit(1) + fatal("Bad command sytax") return m.groups() # A common pattern: @@ -164,8 +213,7 @@ splitargs_re = re.compile(r'(\S*)\s*(.*)') # instance of the BIOS. The target directory will be $(TOP)/. def target(dir, targ_name): global target_dir - target_dir = os.path.join(os.path.dirname(current_config_file()), - targ_name) + target_dir = os.path.join(os.path.dirname(loc.file()), targ_name) if not os.path.isdir(target_dir): print 'Creating directory', target_dir os.makedirs(target_dir) @@ -179,7 +227,7 @@ def handleconfig(dir): if os.path.isfile(file): doconfigfile(dir, file) else: - print "===> Warning: %s not found" % file + warning("%s not found" % file) # type is the command name, e.g. 'northbridge' # name is the path arg that followed the command @@ -410,7 +458,7 @@ def makerule(dir, rule): def addaction(dir, rule): (target, action) = match(splitargs_re, rule) if not makebaserules.has_key(target): - print "===> Warning: Need 'makerule %s ...' before addaction in %s" % (target, current_config_file()) + warning("Need 'makerule %s ...' before addaction" % (target)) makebaserules[target].addaction(action) # COMMAND: adddepend @@ -420,7 +468,7 @@ def addaction(dir, rule): def adddepend(dir, rule): (target, depend) = match(splitargs_re, rule) if not makebaserules.has_key(target): - print "===> Warning: Need 'makerule %s ...' before adddepend in %s" % (target, current_config_file()) + warning("Need 'makerule %s ...' before adddepend" % (target)) makebaserules[target].adddepend(depend) # COMMAND: makedefine @@ -429,17 +477,197 @@ def adddepend(dir, rule): def makedefine(dir, rule): userdefines.append(rule) + +class mkexpr: + class identifier: + def __init__ (self, name): + self.name = name + def bc(self): + return "($(" + self.name + "))" + def perl(self): + return "($(" + self.name + "))" + + class constant: + def __init__ (self, value): + self.value = value + def bc(self): + return "(" + self.value + ")" + def perl(self): + return "(" + self.value + ")" + + class unary: + def __init__ (self, op, right): + self.op = op + self.right = right + + def bc(self): + rstring = self.right.bc() + if (self.op == "!"): + result = "!" + rstring + elif (self.op == "-"): + result = "-" + rstring + return "(" + result + ")" + + def perl(self): + rstring = self.right.perl() + if (self.op == "!"): + result = "!" + rstring + elif (self.op == "-"): + result = "-" + rstring + return "(" + result + ")" + + class binary: + def __init__(self, op, left, right): + self.op = op + self.left = left + self.right = right + + def bc(self): + lstring = self.left.bc() + rstring = self.right.bc() + if (self.op == "&"): + result = lstring + "&&" + rstring + elif (self.op == "|"): + result = lstring + "||" + rstring + elif (self.op == "+"): + result = lstring + "+" + rstring + elif (self.op == "-"): + result = lstring + "-" + rstring + elif (self.op == "*"): + result = lstring + "*" + rstring + elif (self.op == "/"): + result = lstring + "/" + rstring + elif (self.op == "<<"): + result = lstring + "*(2^" + rstring + ") " + elif (self.op == ">>"): + result = lstring + "/(2^" + rstring + ") " + return "(" + result + ")" + + + def perl(self): + lstring = self.left.perl() + rstring = self.right.perl() + if (self.op == "&"): + result = lstring + "&&" + rstring + elif (self.op == "|"): + result = lstring + "||" + rstring + elif (self.op == "+"): + result = lstring + "+" + rstring + elif (self.op == "-"): + result = lstring + "-" + rstring + elif (self.op == "*"): + result = lstring + "*" + rstring + elif (self.op == "/"): + result = lstring + "/" + rstring + elif (self.op == "<<"): + result = lstring + "<<" + rstring + ") " + elif (self.op == ">>"): + result = lstring + ">>" + rstring + ") " + return "(" + result + ")" + + class expression: + def __init__(self, expr): + self.expr = expr + + def bc(self): + string = self.expr.bc() + return "${shell echo '" + string + "' | bc}" + + def perl(self): + string = self.expr.perl() + return "${shell perl -e 'printf(\"%u\\n\", " + string + ");' }" + + # Tokens: ( ) ! | & + - * / << >> option ) + start_re = re.compile(r"^\s*(([A-Za-z_][A-Za-z_0-9]*)|((0x[0-9A-Za-z]+)|([0-9]+))|(\()|(!))(.*)$") + close_re = re.compile(r"^\s*\)(.*)$") + middle_re = re.compile(r"^\s*((\|)|(&)|(\+)|(-)|(\*)|(/)|(<<)|(>>))(.*)$") + + def __init__(self, expr): + self.orig_expr = expr + self.expr = "" + + def prec(self, op): + if (op == "|"): + result = 1 + elif (op == "&"): + result = 2 + elif (op == "+") or (op == "-"): + result = 3 + elif (op == "*") or (op == "/"): + result = 4 + elif (op == "<<") or (op == ">>"): + result = 5 + + + def _parse_start(self): + #print("start expr: %s"%(self.expr)) + m = self.start_re.match(self.expr) + if m: + (token, self.expr) = (m.group(1), m.group(8)) + if token == "(": + left = self._parse() + #print("close expr: %s"%(self.expr)) + m = self.close_re.match(self.expr) + if m: + self.expr = m.group(1) + else: + fatal("No Matching )"); + elif (token == "!"): + right = self._parse() + left = self.unary(token, right) + elif m.group(2): + if not makeoptions.has_key(token): + fatal("Option %s not defined" % token) + left = self.identifier(token) + elif m.group(3): + left = self.constant(token) + else: + fatal("Invalid expression: %s" % self.expr) + return left + + def _parse_middle(self, left): + #print("middle expr: %s"%(self.expr)) + m = self.middle_re.match(self.expr) + while(m): + (op, self.expr) = (m.group(1),m.group(10)) + right = self._parse_start() + m = self.middle_re.match(self.expr) + if m and (self.prec(op) < self.prec(m.group(1))): + right = self._parse_middle() + left = self.binary(op, left, right) + return left + + def _parse(self): + left = self._parse_start() + return self._parse_middle(left) + + def parse(self): + self.expr = self.orig_expr + result = self._parse() + if self.expr != "": + fatal("Extra tokens: %s"% self.expr) + return self.expression(result) + # Put "