summaryrefslogtreecommitdiff
path: root/util/options
diff options
context:
space:
mode:
authorEric Biederman <ebiederm@xmission.com>2004-03-11 15:01:31 +0000
committerEric Biederman <ebiederm@xmission.com>2004-03-11 15:01:31 +0000
commit5cd81730ecef18690f92d193b0381c103a5b3d9b (patch)
treef4d2755177561691661f8d945081df67bcc9cd1a /util/options
parentf31d5542f6e193595da0f66aea68602910984861 (diff)
downloadcoreboot-5cd81730ecef18690f92d193b0381c103a5b3d9b.tar.xz
- Moved hlt() to it's own header.
- Reworked pnp superio device support. Now complete superio support is less than 100 lines. - Added support for hard coding resource assignments in Config.lb - Minor bug fixes to romcc - Initial support for catching the x86 processor BIST error codes. I've only seen this trigger once in production during a very suspcious reset but... - added raminit_test to test the code paths in raminit.c for the Opteron - Removed the IORESOURCE_SET bit and added IORESOURCE_ASSIGNED and IORESOURCE_STORED so we can tell what we have really done. - Added generic AGP/IOMMU setting code to x86 - Added an implementation of memmove and removed reserved identifiers from memcpy - Added minimal support for booting on pre b3 stepping K8 cores - Moved the checksum on amd8111 boards because our default location was on top of extended RTC registers - On the Hdama added support for enabling i2c hub so we can get at the temperature sensors. Not that i2c bus was implemented well enough to make that useful. - Redid the Opteron port so we should only need one reset and most of memory initialization is done in cpu_fixup. This is much, much faster. - Attempted to make the VGA IO region assigment work. The code seems to work now... - Redid the error handling in amdk8/raminit.c to distinguish between a bad value and a smbus error, and moved memory clearing out to cpufixup. - Removed CONFIG_KEYBOARD as it was useless. See pc87360/superio.c for how to setup a legacy keyboard properly. - Reworked the register values for standard hardware, moving the defintions from chip.h into the headers of the initialization routines. This is much saner and is actually implemented. - Made the hdama port an under clockers BIOS. I debuged so many interesting problems. - On amd8111_lpc added setup of architectural/legacy hardware - Enabled PCI error reporting as much as possible. - Enhanded build_opt_tbl to generate a header of the cmos option locations so that romcc compiled code can query the cmos options. - In romcc gracefully handle function names that degenerate into function pointers - Bumped the version to 1.1.6 as we are getting closer to 2.0 TODO finish optimizing the HT links of non dual boards TODO make all Opteron board work again TODO convert all superio devices to use the new helpers TODO convert the via/epia to freebios2 conventions TODO cpu fixup/setup by cpu type git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1390 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/options')
-rw-r--r--util/options/build_opt_tbl.c148
1 files changed, 131 insertions, 17 deletions
diff --git a/util/options/build_opt_tbl.c b/util/options/build_opt_tbl.c
index 183aeab1bd..a6b5cd3062 100644
--- a/util/options/build_opt_tbl.c
+++ b/util/options/build_opt_tbl.c
@@ -3,6 +3,7 @@
#include <sys/io.h>
#include <string.h>
#include <ctype.h>
+#include <errno.h>
#include "../../src/include/pc80/mc146818rtc.h"
#include "../../src/include/boot/linuxbios_tables.h"
@@ -99,9 +100,11 @@ void display_usage(void)
{
printf("Usage build_opt_table [-b] [--option filename]\n");
printf(" [--config filename]\n");
+ printf(" [--header filename]\n");
printf("b = build option_table.c\n");
printf("--option = name of option table output file\n");
printf("--config = build the definitions table from the given file\n");
+ printf("--header = ouput a header file with the definitions\n");
exit(1);
}
@@ -131,6 +134,67 @@ static unsigned long get_number(char *line, char **ptr, int base)
return value;
}
+static int is_ident_digit(int c)
+{
+ int result;
+ switch(c) {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ result = 1;
+ break;
+ default:
+ result = 0;
+ break;
+ }
+ return result;
+}
+
+static int is_ident_nondigit(int c)
+{
+ int result;
+ switch(c) {
+ case 'A': case 'B': case 'C': case 'D':
+ case 'E': case 'F': case 'G': case 'H':
+ case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P':
+ case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ case 'a': case 'b': case 'c': case 'd':
+ case 'e': case 'f': case 'g': case 'h':
+ case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p':
+ case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z':
+ case '_':
+ result = 1;
+ break;
+ default:
+ result = 0;
+ break;
+ }
+ return result;
+}
+
+static int is_ident(char *str)
+{
+ int result;
+ int ch;
+ ch = *str;
+ result = 0;
+ if (is_ident_nondigit(ch)) {
+ do {
+ str++;
+ ch = *str;
+ } while(ch && (is_ident_nondigit(ch) || (is_ident_digit(ch))));
+ result = (ch == '\0');
+ }
+ return result;
+}
+
+
/* This routine builds the cmos definition table from the cmos layout file
input The input comes from the configuration file which contains two parts
entries and enumerations. Each section is started with the key words
@@ -148,6 +212,7 @@ int main(int argc, char **argv)
int i;
char *config=0;
char *option=0;
+ char *header=0;
FILE *fp;
struct cmos_option_table *ct;
struct cmos_entries *ce;
@@ -188,11 +253,18 @@ int main(int argc, char **argv)
}
option=argv[++i];
break;
+ case 'h': /* Output a header file */
+ if (strcmp(&argv[i][2], "header") != 0) {
+ display_usage();
+ }
+ header=argv[++i];
+ break;
default:
display_usage();
break;
}
break;
+
default:
display_usage();
break;
@@ -203,13 +275,13 @@ int main(int argc, char **argv)
/* Has the user specified a configuration file */
if(config) { /* if yes, open it */
if((fp=fopen(config,"r"))==NULL){
- printf("Error - Can not open config file %s\n",config);
+ fprintf(stderr, "Error - Can not open config file %s\n",config);
exit(1); /* exit if it can not be opened */
}
}
else { /* no configuration file specified, so try the default */
if((fp=fopen("cmos.layout","r"))==NULL){
- printf("Error - Can not open cmos.layout\n");
+ fprintf(stderr, "Error - Can not open cmos.layout\n");
exit(1); /* end of no configuration file is found */
}
}
@@ -254,11 +326,17 @@ int main(int argc, char **argv)
ce->config=(int)uc;
/* check bit and length ranges */
if(ce->bit>(CMOS_IMAGE_BUFFER_SIZE*8)) {
- printf("Error - bit is to big in line \n%s\n",line);
+ fprintf(stderr, "Error - bit is to big in line \n%s\n",line);
exit(1);
}
if((ce->length>(MAX_VALUE_BYTE_LENGTH*8))&&(uc!='r')) {
- printf("Error - Length is to long in line \n%s\n",line);
+ fprintf(stderr, "Error - Length is to long in line \n%s\n",line);
+ exit(1);
+ }
+ if (!is_ident(ce->name)) {
+ fprintf(stderr,
+ "Error - Name %s is an invalid identifier in line\n %s\n",
+ ce->name, line);
exit(1);
}
/* put in the record type */
@@ -353,43 +431,43 @@ int main(int argc, char **argv)
skip_spaces(line, &ptr);
if ((cs->range_start%8) != 0) {
- printf("Error - range start is not byte aligned in line\n%s\n", line);
+ fprintf(stderr, "Error - range start is not byte aligned in line\n%s\n", line);
exit(1);
}
if (cs->range_start >= (CMOS_IMAGE_BUFFER_SIZE*8)) {
- printf("Error - range start is to big in line\n%s\n", line);
+ fprintf(stderr, "Error - range start is to big in line\n%s\n", line);
exit(1);
}
if ((cs->range_end%8) != 7) {
- printf("Error - range end is not byte aligned in line\n%s\n", line);
+ fprintf(stderr, "Error - range end is not byte aligned in line\n%s\n", line);
exit(1);
}
if ((cs->range_end) >= (CMOS_IMAGE_BUFFER_SIZE*8)) {
- printf("Error - range end is to long in line\n%s\n", line);
+ fprintf(stderr, "Error - range end is to long in line\n%s\n", line);
exit(1);
}
if ((cs->location%8) != 0) {
- printf("Error - location is not byte aligned in line\n%s\n", line);
+ fprintf(stderr, "Error - location is not byte aligned in line\n%s\n", line);
exit(1);
}
if ((cs->location >= (CMOS_IMAGE_BUFFER_SIZE*8)) ||
((cs->location + 16) > (CMOS_IMAGE_BUFFER_SIZE*8)))
{
- printf("Error - location is to big in line\n%s\n", line);
+ fprintf(stderr, "Error - location is to big in line\n%s\n", line);
exit(1);
}
/* And since we are not ready to be fully general purpose yet.. */
if ((cs->range_start/8) != LB_CKS_RANGE_START) {
- printf("Error - Range start(%d) does not match define(%d) in line\n%s\n",
+ fprintf(stderr, "Error - Range start(%d) does not match define(%d) in line\n%s\n",
cs->range_start/8, LB_CKS_RANGE_START, line);
exit(1);
}
if ((cs->range_end/8) != LB_CKS_RANGE_END) {
- printf("Error - Range end does not match define in line\n%s\n", line);
+ fprintf(stderr, "Error - Range end does not match define in line\n%s\n", line);
exit(1);
}
if ((cs->location/8) != LB_CKS_LOC) {
- printf("Error - Location does not match define in line\n%s\n", line);
+ fprintf(stderr, "Error - Location does not match define in line\n%s\n", line);
exit(1);
}
@@ -407,19 +485,19 @@ int main(int argc, char **argv)
/* test if an alternate file is to be created */
if(option) {
if((fp=fopen(option,"w"))==NULL){
- printf("Error - Can not open %s\n",option);
+ fprintf(stderr, "Error - Can not open %s\n",option);
exit(1);
}
}
else { /* no, so use the default option_table.c */
if((fp=fopen("option_table.c","w"))==NULL){
- printf("Error - Can not open option_table.c\n");
+ fprintf(stderr, "Error - Can not open option_table.c\n");
exit(1);
}
}
/* write the header */
if(!fwrite("unsigned char option_table[] = {",1,32,fp)) {
- printf("Error - Could not write image file\n");
+ fprintf(stderr, "Error - Could not write image file\n");
fclose(fp);
exit(1);
}
@@ -433,12 +511,48 @@ int main(int argc, char **argv)
sprintf(buf,"0x%02x",cmos_table[i]);
fwrite(buf,1,4,fp);
if(!fwrite("};\n",1,3,fp)) {
- printf("Error - Could not write image file\n");
+ fprintf(stderr, "Error - Could not write image file\n");
fclose(fp);
exit(1);
}
fclose(fp);
+
+ /* See if we also want to output a C header file */
+ if (header) {
+ struct cmos_option_table *hdr;
+ struct lb_record *ptr, *end;
+ fp = fopen(header, "w");
+ if (!fp) {
+ fprintf(stderr, "Error Can not open %s: %s\n",
+ header, strerror(errno));
+ exit(1);
+ }
+ /* Get the cmos table header */
+ hdr = (struct cmos_option_table *)cmos_table;
+ /* Walk through the entry records */
+ ptr = (struct lb_record *)(cmos_table + hdr->header_length);
+ end = (struct lb_record *)(cmos_table + hdr->size);
+ for(;ptr < end; ptr = (struct lb_record *)(((char *)ptr) + ptr->size)) {
+ if (ptr->tag != LB_TAG_OPTION) {
+ continue;
+ }
+ ce = (struct cmos_entries *)ptr;
+ if (ce->config == 'r') {
+ continue;
+ }
+ if (!is_ident(ce->name)) {
+ fprintf(stderr, "Invalid identifier: %s\n",
+ ce->name);
+ exit(1);
+ }
+ fprintf(fp, "#define CMOS_VSTART_%s %d\n",
+ ce->name, ce->bit);
+ fprintf(fp, "#define CMOS_VLEN_%s %d\n",
+ ce->name, ce->length);
+ }
+ fclose(fp);
+ }
return(0);
}