- Support for CMOS options

- Workaround cmos tables overlapping the traditional bios data segment
- Fixes to the p4dc6 examples to be syntactically correct
- Fixes to NLBConfig to fix the previos syntax error ``option foo bar'' is invalid
- Update docmil_fil_inbuf to only be compiled when the appropriate options are set
- Updates NLBConfig.py to export the variables MAINBOARD && TARGET_DIR
  as well as correct specify the generated files
This commit is contained in:
Eric W. Biederman 2002-01-29 20:28:24 +00:00
commit 031d2a1ffd
16 changed files with 702 additions and 118 deletions

View file

@ -2,6 +2,7 @@
#include <boot/linuxbios_tables.h>
#include <boot/linuxbios_table.h>
#include <printk.h>
#include <string.h>
struct lb_header *lb_table_init(unsigned long addr)
{
@ -86,25 +87,16 @@ void lb_memory_range(struct lb_memory *mem,
static void lb_reserve_table_memory(struct lb_header *head)
{
struct lb_record *rec, *last_rec;
struct lb_record *last_rec;
struct lb_memory *mem;
uint64_t start;
uint64_t end;
int i, entries;
last_rec = lb_last_record(head);
mem = 0;
for(rec = lb_first_record(head); rec < last_rec; lb_next_record(rec)) {
if (rec->tag == LB_TAG_MEMORY) {
mem = (struct lb_memory *)rec;
break;
}
}
if (!mem)
return;
printk_debug("head = %p last_rec = %p\n", head, last_rec);
mem = get_lb_mem();
start = (unsigned long)head;
end = (unsigned long)last_rec;
printk_debug("start = 0x%08lx end = 0x%08lx\n", (unsigned long)start, (unsigned long)end);
entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
/* Resize the right two memory areas so this table is in
* a reserved area of memory. Everything has been carefully
@ -137,7 +129,7 @@ unsigned long lb_table_fini(struct lb_header *head)
head->table_checksum = compute_ip_checksum(first_rec, head->table_bytes);
head->header_checksum = 0;
head->header_checksum = compute_ip_checksum(head, sizeof(*head));
printk_debug("Write linuxbios table at: %p - %p\n",
printk_debug("Wrote linuxbios table at: %p - %p\n",
head, rec);
return (unsigned long)rec;
}
@ -162,11 +154,18 @@ unsigned long write_linuxbios_table(
{
struct lb_header *head;
struct lb_memory *mem;
struct lb_record *rec_dest, *rec_src;
head = lb_table_init(low_table_end);
low_table_end = (unsigned long)head;
#if HAVE_OPTION_TABLE == 1
/* Write the option config table... */
rec_dest = lb_new_record(head);
rec_src = (struct lb_record *)&option_table;
memcpy(rec_dest, rec_src, rec_src->size);
#endif
mem = lb_memory(head);
mem_ranges = mem;
/* Reserve our tables in low memory */
lb_memory_range(mem, LB_MEM_RESERVED, low_table_start, low_table_end - low_table_start);
lb_memory_range(mem, LB_MEM_RAM, low_table_end, 640*1024 - low_table_end);
@ -180,6 +179,5 @@ unsigned long write_linuxbios_table(
low_table_end = lb_table_fini(head);
/* Remember where my valid memory ranges are */
mem_ranges = mem;
return low_table_end;
}

View file

@ -181,7 +181,11 @@ void write_tables(unsigned long totalram)
/* The smp table must be in 0-1K, 639K-640K, or 960K-1M */
low_table_end = write_smp_table(low_table_end, processor_map);
/* The linuxbios table must be in 0-1K or 960K-1M */
/* Don't write anything in the traditional x86 BIOS data segment */
if (low_table_end < 0x500) {
low_table_end = 0x500;
}
/* The linuxbios table must be in 0-4K or 960K-1M */
write_linuxbios_table(
processor_map, totalram,
low_table_start, low_table_end,

View file

@ -1,20 +1,26 @@
## This is Architecture independant part of the makefile
makedefine CC:=gcc
makedefine CPP:= gcc -x assembler-with-cpp -DASSEMBLY -E
option CROSS_COMPILE
makedefine CC:=$(CROSS_COMPILE)gcc
makedefine CPP:= $(CROSS_COMPILE)gcc -x assembler-with-cpp -DASSEMBLY -E
makedefine OBJCOPY:=$(CROSS_COMPILE)objcopy
makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin -Wall
makedefine HOSTCC:=gcc
makedefine HOSTCFLAGS:= -Os -Wall
makerule ldscript.ld : ldoptions $(LDSUBSCRIPTS-1) ; echo "INCLUDE ldoptions" > $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo "INCLUDE $$file" >> $@ ; done
makerule cpuflags : Makefile.settings ; perl -e 'print "CPUFLAGS :=\n"; foreach $$var (split(" ", $$ENV{VARIABLES})) { if (exists($$ENV{$$var})) { print "CPUFLAGS += -D$$var" . (length($$ENV{$$var})?"=\x27$$ENV{$$var}\x27":"") ."\n"} else { print "CPUFLAGS += -U$$var\n"} }' > $@
makerule ldoptions : Makefile.settings ; perl -e 'foreach $$var (split(" ", $$ENV{VARIABLES})) { if ($$ENV{$$var} =~ m/^(0x[0-9a-fA-F]+|0[0-7]+|[0-9]+)$$/) { print "$$var = $$ENV{$$var};\n"; }}' > $@
makerule linuxbios.strip: linuxbios ; objcopy -O binary linuxbios linuxbios.strip
makerule linuxbios.strip: linuxbios ; $(OBJCOPY) -O binary linuxbios linuxbios.strip
makerule linuxbios.o : crt0.o $(DRIVERS-1) linuxbios.a $(LIBGCC_FILE_NAME) ; $(CC) -nostdlib -r -o $@ crt0.o $(DRIVERS-1) linuxbios.a $(LIBGCC_FILE_NAME)
@ -39,12 +45,19 @@ makerule etags: $(SOURCES) ; etags $(SOURCES)
makerule tags: $(SOURCES) ; ctags $(SOURCES)
makerule documentation: $(SOURCES) ; doxygen LinuxBIOSDoc.config
makerule build_opt_tbl: $(TOP)/util/options/build_opt_tbl.c ; $(HOSTCC) $(HOSTCFLAGS) $< -o $@
makerule /$(TARGET_DIR)/option_table.c : build_opt_tbl $(MAINBOARD)/cmos.conf ; ./build_opt_tbl -b --config $(MAINBOARD)/cmos.conf
object /$(TARGET_DIR)/option_table.o HAVE_OPTION_TABLE
makerule clean : ; rm -f linuxbios.* *~
addaction clean rm -f linuxbios
addaction clean rm -f ldoptions cpuflags ldscript.ld
addaction clean rm -f a.out *.s *.l *.o
addaction clean rm -f TAGS tags
addaction clean rm -f docipl
addaction clean rm -f build_opt_tbl option_table.c crt0.S
# do standard config files that the user need not specify
# for now, this is just 'lib', but it may be more later.

View file

@ -25,4 +25,6 @@ unsigned long lb_table_fini(struct lb_header *header);
*/
struct lb_memory *get_lb_mem(void);
extern struct cmos_option_table option_table;
#endif /* LINUXBIOS_TABLE_H */

View file

@ -80,4 +80,65 @@ struct lb_hwrpb {
};
/* The following structures are for the cmos definitions table */
#define LB_TAG_CMOS_OPTION_TABLE 200
/* cmos header record */
struct cmos_option_table {
uint32_t tag; /* CMOS definitions table type */
uint32_t size; /* size of the entire table */
uint32_t header_length; /* length of header */
};
/* cmos entry record
This record is variable length. The name field may be
shorter than CMOS_MAX_NAME_LENGTH. The entry may start
anywhere in the byte, but can not span bytes unless it
starts at the beginning of the byte and the length is
fills complete bytes.
*/
#define LB_TAG_OPTION 201
struct cmos_entries {
uint32_t tag; /* entry type */
uint32_t size; /* length of this record */
uint32_t bit; /* starting bit from start of image */
uint32_t length; /* length of field in bits */
uint32_t config; /* e=enumeration, h=hex, r=reserved */
uint32_t config_id; /* a number linking to an enumeration record */
#define CMOS_MAX_NAME_LENGTH 32
uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
variable length int aligned */
};
/* cmos enumerations record
This record is variable length. The text field may be
shorter than CMOS_MAX_TEXT_LENGTH.
*/
#define LB_TAG_OPTION_ENUM 202
struct cmos_enums {
uint32_t tag; /* enumeration type */
uint32_t size; /* length of this record */
uint32_t config_id; /* a number identifying the config id */
uint32_t value; /* the value associated with the text */
#define CMOS_MAX_TEXT_LENGTH 32
uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
variable length int aligned */
};
/* cmos defaults record
This record contains default settings for the cmos ram.
*/
#define LB_TAG_OPTION_DEFAULTS 203
struct cmos_defaults {
uint32_t tag; /* default type */
uint32_t size; /* length of this record */
uint32_t name_length; /* length of the following name field */
uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
#define CMOS_IMAGE_BUFFER_SIZE 128
uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
};
#endif /* LINUXBIOS_TABLES_H */

View file

@ -90,6 +90,11 @@
#if !defined(ASSEMBLY)
void rtc_init(int invalid);
#if USE_OPTION_TABLE == 1
int get_option(void *dest, char *name);
#else
#define get_option(dest, name) (-2)
#endif
#endif
#endif /* PC80_MC146818RTC_H */

View file

@ -73,6 +73,7 @@ object mptable.o HAVE_MP_TABLE
object irq_tables.o HAVE_PIRQ_TABLE
###
### Build options
###
@ -123,6 +124,11 @@ option NO_KEYBOARD
##
option HAVE_MP_TABLE=1
##
## Build code to export a CMOS option tabe table
##
option HAVE_OPTION_TABLE=1
##
## Build code for SMP support
## Only worry about 2 micro processors
@ -198,6 +204,11 @@ option STACK_SIZE=0x2000
##
option HEAP_SIZE=0x2000
##
## Only use the option table in a normal image
##
expr USE_OPTION_TABLE=!USE_FALLBACK_IMAGE
##
## Compute the location and size of where this firmware image
## (linuxBIOS plus bootloader) will linv in the boot rom chip.

View file

@ -79,26 +79,26 @@ payload ../eepro100.ebi
##
## Cpu Speed
##
option CPU_CLOCK_MULTIPLIER XEON_X8
#option CPU_CLOCK_MULTIPLIER XEON_X9
#option CPU_CLOCK_MULTIPLIER XEON_X10
#option CPU_CLOCK_MULTIPLIER XEON_X11
#option CPU_CLOCK_MULTIPLIER XEON_X12
#option CPU_CLOCK_MULTIPLIER XEON_X13
#option CPU_CLOCK_MULTIPLIER XEON_X14
#option CPU_CLOCK_MULTIPLIER XEON_X15
#option CPU_CLOCK_MULTIPLIER XEON_X16
#option CPU_CLOCK_MULTIPLIER XEON_X17
#option CPU_CLOCK_MULTIPLIER XEON_X18
#option CPU_CLOCK_MULTIPLIER XEON_X19
#option CPU_CLOCK_MULTIPLIER XEON_X19
#option CPU_CLOCK_MULTIPLIER XEON_X20
#option CPU_CLOCK_MULTIPLIER XEON_X21
#option CPU_CLOCK_MULTIPLIER XEON_X22
#option CPU_CLOCK_MULTIPLIER XEON_X23
option CPU_CLOCK_MULTIPLIER=XEON_X8
#option CPU_CLOCK_MULTIPLIER=XEON_X9
#option CPU_CLOCK_MULTIPLIER=XEON_X10
#option CPU_CLOCK_MULTIPLIER=XEON_X11
#option CPU_CLOCK_MULTIPLIER=XEON_X12
#option CPU_CLOCK_MULTIPLIER=XEON_X13
#option CPU_CLOCK_MULTIPLIER=XEON_X14
#option CPU_CLOCK_MULTIPLIER=XEON_X15
#option CPU_CLOCK_MULTIPLIER=XEON_X16
#option CPU_CLOCK_MULTIPLIER=XEON_X17
#option CPU_CLOCK_MULTIPLIER=XEON_X18
#option CPU_CLOCK_MULTIPLIER=XEON_X19
#option CPU_CLOCK_MULTIPLIER=XEON_X19
#option CPU_CLOCK_MULTIPLIER=XEON_X20
#option CPU_CLOCK_MULTIPLIER=XEON_X21
#option CPU_CLOCK_MULTIPLIER=XEON_X22
#option CPU_CLOCK_MULTIPLIER=XEON_X23
##
## Select power on after power fail setting
option MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBARD_POWER_ON
#option MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBARD_POWER_ON
option MAINBOARD_POWER_ON_AFTER_POWER_FAIL=MAINBOARD_POWER_ON
#option MAINBOARD_POWER_ON_AFTER_POWER_FAIL=MAINBOARD_POWER_ON

View file

@ -80,26 +80,26 @@ payload ../eepro100.ebi
##
## Cpu Speed
##
#option CPU_CLOCK_MULTIPLIER XEON_X8
#option CPU_CLOCK_MULTIPLIER XEON_X9
#option CPU_CLOCK_MULTIPLIER XEON_X10
#option CPU_CLOCK_MULTIPLIER XEON_X11
#option CPU_CLOCK_MULTIPLIER XEON_X12
#option CPU_CLOCK_MULTIPLIER XEON_X13
#option CPU_CLOCK_MULTIPLIER XEON_X14
#option CPU_CLOCK_MULTIPLIER XEON_X15
#option CPU_CLOCK_MULTIPLIER XEON_X16
option CPU_CLOCK_MULTIPLIER XEON_X17
#option CPU_CLOCK_MULTIPLIER XEON_X18
#option CPU_CLOCK_MULTIPLIER XEON_X19
#option CPU_CLOCK_MULTIPLIER XEON_X19
#option CPU_CLOCK_MULTIPLIER XEON_X20
#option CPU_CLOCK_MULTIPLIER XEON_X21
#option CPU_CLOCK_MULTIPLIER XEON_X22
#option CPU_CLOCK_MULTIPLIER XEON_X23
#option CPU_CLOCK_MULTIPLIER=XEON_X8
#option CPU_CLOCK_MULTIPLIER=XEON_X9
#option CPU_CLOCK_MULTIPLIER=XEON_X10
#option CPU_CLOCK_MULTIPLIER=XEON_X11
#option CPU_CLOCK_MULTIPLIER=XEON_X12
#option CPU_CLOCK_MULTIPLIER=XEON_X13
#option CPU_CLOCK_MULTIPLIER=XEON_X14
#option CPU_CLOCK_MULTIPLIER=XEON_X15
#option CPU_CLOCK_MULTIPLIER=XEON_X16
option CPU_CLOCK_MULTIPLIER=XEON_X17
#option CPU_CLOCK_MULTIPLIER=XEON_X18
#option CPU_CLOCK_MULTIPLIER=XEON_X19
#option CPU_CLOCK_MULTIPLIER=XEON_X19
#option CPU_CLOCK_MULTIPLIER=XEON_X20
#option CPU_CLOCK_MULTIPLIER=XEON_X21
#option CPU_CLOCK_MULTIPLIER=XEON_X22
#option CPU_CLOCK_MULTIPLIER=XEON_X23
##
## Select power on after power fail setting
option MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBARD_POWER_ON
#option MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBARD_POWER_ON
option MAINBOARD_POWER_ON_AFTER_POWER_FAIL=MAINBOARD_POWER_ON
#option MAINBOARD_POWER_ON_AFTER_POWER_FAIL=MAINBOARD_POWER_ON

View file

@ -13,6 +13,7 @@
#include <smbus.h>
#include <ramtest.h>
#include <northbridge/intel/82860/rdram.h>
#include <pc80/mc146818rtc.h>
#define SMBUS_MEM_DEVICE_0 (0xa << 3)
@ -52,6 +53,8 @@ static void set_power_on_after_power_fail(int setting)
}
void mainboard_fixup(void)
{
int cpu_clock_multiplier;
int power_on_after_power_fail;
ich2_enable_ioapic();
ich2_enable_serial_irqs();
ich2_enable_ide(1,1);
@ -59,9 +62,13 @@ void mainboard_fixup(void)
ich2_lpc_route_dma(0xff);
isa_dma_init();
ich2_set_cpu_multiplier(CPU_CLOCK_MULTIPLIER);
cpu_clock_multiplier = CPU_CLOCK_MULTIPLIER;
get_option(&cpu_clock_multiplier, "CPU_clock_speed");
ich2_set_cpu_multiplier(cpu_clock_multiplier);
set_power_on_after_power_fail(MAINBOARD_POWER_ON_AFTER_POWER_FAIL);
power_on_after_power_fail = MAINBOARD_POWER_ON_AFTER_POWER_FAIL;
get_option(&power_on_after_power_fail, "power_on_after_power_fail");
set_power_on_after_power_fail(power_on_after_power_fail);
return;
}

View file

@ -1,6 +1,9 @@
#include <arch/io.h>
#include <printk.h>
#include <pc80/mc146818rtc.h>
#include <boot/linuxbios_tables.h>
#include <boot/linuxbios_table.h>
#include <string.h>
#define CMOS_READ(addr) ({ \
outb_p((addr),RTC_PORT(0)); \
@ -162,3 +165,68 @@ void rtc_init(int invalid)
/* Clear any pending interrupts */
(void) CMOS_READ(RTC_INTR_FLAGS);
}
#if USE_OPTION_TABLE == 1
/* This routine returns the value of the requested bits
input bit = bit count from the beginning of the cmos image
length = number of bits to include in the value
ret = a character pointer to where the value is to be returned
output the value placed in ret
returns 1 = successful, 0 = an error occurred
*/
static int get_cmos_value(unsigned long bit, unsigned long length, void *vret)
{
unsigned char *ret;
unsigned long byte,byte_bit;
unsigned long i;
unsigned char uchar;
/* The table is checked when it is built to ensure all values are valid. */
ret = vret;
byte=bit/8; /* find the byte where the data starts */
byte_bit=bit%8; /* find the bit in the byte where the data starts */
if(length<9) { /* one byte or less */
uchar = CMOS_READ(byte); /* load the byte */
uchar >>= byte_bit; /* shift the bits to byte align */
/* clear unspecified bits */
ret[0] = uchar & ((1 << length) -1);
}
else { /* more that one byte so transfer the whole bytes */
for(i=0;length;i++,length-=8,byte++) {
/* load the byte */
ret[i]=CMOS_READ(byte);
}
}
return 0;
}
int get_option(void *dest, char *name)
{
extern struct cmos_option_table option_table;
struct cmos_option_table *ct;
struct cmos_entries *ce;
size_t namelen;
int found=0;
/* Figure out how long name is */
namelen = strnlen(name, CMOS_MAX_NAME_LENGTH);
/* find the requested entry record */
ct=&option_table;
ce=(struct cmos_entries*)((unsigned char *)ct + ct->header_length);
for(;ce->tag==LB_TAG_OPTION;
ce=(struct cmos_entries*)((unsigned char *)ce + ce->size)) {
if (memcmp(ce->name, name, namelen) == 0) {
found=1;
break;
}
}
if(!found) return(-2);
if(get_cmos_value(ce->bit, ce->length, dest))
return(-3);
return(0);
}
#endif /* USE_OPTION_TABLE */

View file

@ -1,5 +1,9 @@
option USE_DOC_MIL=0
option USE_DOC_2000_TSOP=0
expr USE_DOC = USE_DOC_MIL | USE_DOC_2000_TSOP
driver rom_fill_inbuf.o USE_GENERIC_ROM
driver docmil_fill_inbuf.o
driver docmil_fill_inbuf.o USE_DOC
#driver docplus_fill_inbuf.o
driver tsunami_tigbus_rom_fill_inbuf.o USE_TSUNAMI_TIGBUS_ROM
driver serial_fill_inbuf.o USE_SERIAL_FILL_INBUF

View file

@ -1,5 +1,3 @@
#if defined(USE_DOC_MIL) || defined(USE_DOC_2000_TSOP)
#include <cpu/p5/io.h>
#include <printk.h>
#include <stdlib.h>
@ -157,5 +155,3 @@ static struct stream doc_mil_stream __stream = {
.skip = skip_bytes,
.fini = fini_bytes,
};
#endif /* USE_DOC_MIL */