diff --git a/sys/boot/common/bcache.c b/sys/boot/common/bcache.c index efdcbe0f6b5f..e99a677a260b 100644 --- a/sys/boot/common/bcache.c +++ b/sys/boot/common/bcache.c @@ -57,11 +57,11 @@ struct bcachectl static struct bcachectl *bcache_ctl; static caddr_t bcache_data; static bitstr_t *bcache_miss; -static int bcache_nblks; -static int bcache_blksize; -static int bcache_hits, bcache_misses, bcache_ops, bcache_bypasses; -static int bcache_flushes; -static int bcache_bcount; +static u_int bcache_nblks; +static u_int bcache_blksize; +static u_int bcache_hits, bcache_misses, bcache_ops, bcache_bypasses; +static u_int bcache_flushes; +static u_int bcache_bcount; static void bcache_insert(caddr_t buf, daddr_t blkno); static int bcache_lookup(caddr_t buf, daddr_t blkno); @@ -70,7 +70,7 @@ static int bcache_lookup(caddr_t buf, daddr_t blkno); * Initialise the cache for (nblks) of (bsize). */ int -bcache_init(int nblks, size_t bsize) +bcache_init(u_int nblks, size_t bsize) { /* discard any old contents */ if (bcache_data != NULL) { @@ -103,9 +103,9 @@ bcache_init(int nblks, size_t bsize) * Flush the cache */ void -bcache_flush() +bcache_flush(void) { - int i; + u_int i; bcache_flushes++; @@ -125,14 +125,14 @@ bcache_flush() * directly to the disk. XXX tune this. */ int -bcache_strategy(void *devdata, int unit, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize) +bcache_strategy(void *devdata, int unit, int rw, daddr_t blk, size_t size, + char *buf, size_t *rsize) { static int bcache_unit = -1; struct bcache_devdata *dd = (struct bcache_devdata *)devdata; - int nblk, p_size; - daddr_t p_blk; + int p_size, result; + daddr_t p_blk, i, j, nblk; caddr_t p_buf; - int i, j, result; bcache_ops++; @@ -211,7 +211,8 @@ static void bcache_insert(caddr_t buf, daddr_t blkno) { time_t now; - int i, cand, ocount; + int cand, ocount; + u_int i; time(&now); cand = 0; /* assume the first block */ @@ -246,7 +247,7 @@ static int bcache_lookup(caddr_t buf, daddr_t blkno) { time_t now; - int i; + u_int i; time(&now); @@ -265,7 +266,7 @@ COMMAND_SET(bcachestat, "bcachestat", "get disk block cache stats", command_bcac static int command_bcache(int argc, char *argv[]) { - int i; + u_int i; for (i = 0; i < bcache_nblks; i++) { printf("%08x %04x %04x|", bcache_ctl[i].bc_blkno, (unsigned int)bcache_ctl[i].bc_stamp & 0xffff, bcache_ctl[i].bc_count & 0xffff); diff --git a/sys/boot/common/boot.c b/sys/boot/common/boot.c index 7c02e56ccc47..ae3cb7796c99 100644 --- a/sys/boot/common/boot.c +++ b/sys/boot/common/boot.c @@ -38,7 +38,7 @@ static char *getbootfile(int try); /* List of kernel names to try (may be overwritten by boot.config) XXX should move from here? */ -static char *default_bootfiles = "kernel;kernel.old"; +static const char *default_bootfiles = "kernel;kernel.old"; static int autoboot_tried; @@ -53,7 +53,6 @@ command_boot(int argc, char *argv[]) struct preloaded_file *fp; char *cp; int try; - int i; /* * See if the user has specified an explicit kernel to boot. @@ -164,7 +163,7 @@ autoboot_maybe() } int -autoboot(int delay, char *prompt) +autoboot(int timeout, char *prompt) { time_t when, otime, ntime; int c, yes; @@ -172,19 +171,19 @@ autoboot(int delay, char *prompt) autoboot_tried = 1; - if (delay == -1) { + if (timeout == -1) { /* try to get a delay from the environment */ if ((cp = getenv("autoboot_delay"))) { - delay = strtol(cp, &ep, 0); + timeout = strtol(cp, &ep, 0); if (cp == ep) - delay = -1; + timeout = -1; } } - if (delay == -1) /* all else fails */ - delay = 10; + if (timeout == -1) /* all else fails */ + timeout = 10; otime = time(NULL); - when = otime + delay; /* when to boot */ + when = otime + timeout; /* when to boot */ yes = 0; /* XXX could try to work out what we might boot */ @@ -228,7 +227,7 @@ getbootfile(int try) { static char *name = NULL; char *spec, *ep; - int len; + size_t len; /* we use dynamic storage */ if (name != NULL) { diff --git a/sys/boot/common/bootstrap.h b/sys/boot/common/bootstrap.h index 67ca5029f9c8..31ac87a228ca 100644 --- a/sys/boot/common/bootstrap.h +++ b/sys/boot/common/bootstrap.h @@ -29,10 +29,6 @@ #include #include -/* XXX debugging */ -extern struct console vidconsole; -#define MARK(s, c) {vidconsole.c_out(s); vidconsole.c_out(c); while (!vidconsole.c_ready()) ; vidconsole.c_in();} - /* * Generic device specifier; architecture-dependant * versions may be larger, but should be allowed to @@ -55,37 +51,42 @@ extern char command_errbuf[]; /* XXX blah, length */ #define CMD_ERROR 1 /* interp.c */ -extern void interact(void); -extern int include(char *filename); +void interact(void); +int include(const char *filename); + +/* interp_backslash.c */ +char *backslash(char *str); /* interp_parse.c */ -extern int parse(int *argc, char ***argv, char *str); +int parse(int *argc, char ***argv, char *str); /* interp_forth.c */ -extern void bf_init(void); -extern int bf_run(char *line); +void bf_init(void); +int bf_run(char *line); /* boot.c */ -extern int autoboot(int delay, char *prompt); -extern void autoboot_maybe(void); -extern int getrootmount(char *rootdev); +int autoboot(int timeout, char *prompt); +void autoboot_maybe(void); +int getrootmount(char *rootdev); /* misc.c */ -extern char *unargv(int argc, char *argv[]); -extern void hexdump(caddr_t region, size_t len); -extern size_t strlenout(vm_offset_t str); -extern char *strdupout(vm_offset_t str); +char *unargv(int argc, char *argv[]); +void hexdump(caddr_t region, size_t len); +size_t strlenout(vm_offset_t str); +char *strdupout(vm_offset_t str); /* bcache.c */ -extern int bcache_init(int nblks, size_t bsize); -extern void bcache_flush(); +int bcache_init(u_int nblks, size_t bsize); +void bcache_flush(void); +int bcache_strategy(void *devdata, int unit, int rw, daddr_t blk, + size_t size, char *buf, size_t *rsize); /* * Disk block cache */ struct bcache_devdata { - int (*dv_strategy)(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize); + int (*dv_strategy)(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize); void *dv_devdata; }; @@ -94,8 +95,8 @@ struct bcache_devdata */ struct console { - char *c_name; - char *c_desc; + const char *c_name; + const char *c_desc; int c_flags; #define C_PRESENTIN (1<<0) #define C_PRESENTOUT (1<<1) @@ -108,14 +109,14 @@ struct console int (* c_ready)(void); /* return nonzer if input waiting */ }; extern struct console *consoles[]; -extern void cons_probe(void); +void cons_probe(void); /* * Plug-and-play enumerator/configurator interface. */ struct pnphandler { - char *pp_name; /* handler/bus name */ + const char *pp_name; /* handler/bus name */ void (* pp_enumerate)(void); /* enumerate PnP devices, add to chain */ }; @@ -139,11 +140,11 @@ struct pnpinfo extern struct pnphandler *pnphandlers[]; /* provided by MD code */ -extern void pnp_addident(struct pnpinfo *pi, char *ident); -extern struct pnpinfo *pnp_allocinfo(void); -extern void pnp_freeinfo(struct pnpinfo *pi); -extern void pnp_addinfo(struct pnpinfo *pi); -extern char *pnp_eisaformat(u_int8_t *data); +void pnp_addident(struct pnpinfo *pi, char *ident); +struct pnpinfo *pnp_allocinfo(void); +void pnp_freeinfo(struct pnpinfo *pi); +void pnp_addinfo(struct pnpinfo *pi); +char *pnp_eisaformat(u_int8_t *data); /* * < 0 - No ISA in system @@ -163,7 +164,7 @@ struct file_metadata size_t md_size; u_int16_t md_type; struct file_metadata *md_next; - char md_data[0]; /* data are immediately appended */ + char md_data[1]; /* data are immediately appended */ }; struct preloaded_file; @@ -209,8 +210,8 @@ struct file_format extern struct file_format *file_formats[]; /* supplied by consumer */ extern struct preloaded_file *preloaded_files; -extern int mod_load(char *name, int argc, char *argv[]); -extern int mod_loadobj(char *type, char *name); +int mod_load(char *name, int argc, char *argv[]); +int mod_loadobj(char *type, char *name); struct preloaded_file *file_alloc(void); struct preloaded_file *file_findfile(char *name, char *type); @@ -222,10 +223,10 @@ int file_addmodule(struct preloaded_file *fp, char *modname, /* MI module loaders */ -extern int aout_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result); -extern vm_offset_t aout_findsym(char *name, struct preloaded_file *fp); +int aout_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result); +vm_offset_t aout_findsym(char *name, struct preloaded_file *fp); -extern int elf_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result); +int elf_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result); #ifndef NEW_LINKER_SET #include @@ -284,7 +285,7 @@ struct bootblk_command #define COMMAND_SET(tag, key, desc, func) \ static bootblk_cmd_t func; \ static struct bootblk_command _cmd_ ## tag = { key, desc, func }; \ - DATA_SET(Xcommand_set, _cmd_ ## tag); + DATA_SET(Xcommand_set, _cmd_ ## tag) extern struct linker_set Xcommand_set; @@ -297,22 +298,25 @@ extern struct linker_set Xcommand_set; struct arch_switch { /* Automatically load modules as required by detected hardware */ - int (* arch_autoload)(); + int (*arch_autoload)(void); /* Locate the device for (name), return pointer to tail in (*path) */ - int (*arch_getdev)(void **dev, const char *name, const char **path); + int (*arch_getdev)(void **dev, const char *name, const char **path); /* Copy from local address space to module address space, similar to bcopy() */ - int (*arch_copyin)(void *src, vm_offset_t dest, size_t len); + ssize_t (*arch_copyin)(const void *src, vm_offset_t dest, + const size_t len); /* Copy to local address space from module address space, similar to bcopy() */ - int (*arch_copyout)(vm_offset_t src, void *dest, size_t len); + ssize_t (*arch_copyout)(const vm_offset_t src, void *dest, + const size_t len); /* Read from file to module address space, same semantics as read() */ - int (*arch_readin)(int fd, vm_offset_t dest, size_t len); + ssize_t (*arch_readin)(const int fd, vm_offset_t dest, + const size_t len); /* Perform ISA byte port I/O (only for systems with ISA) */ - int (*arch_isainb)(int port); - void (*arch_isaoutb)(int port, int value); + int (*arch_isainb)(int port); + void (*arch_isaoutb)(int port, int value); }; extern struct arch_switch archsw; /* This must be provided by the MD code, but should it be in the archsw? */ -extern void delay(int delay); +void delay(int delay); -extern void dev_cleanup(void); +void dev_cleanup(void); diff --git a/sys/boot/common/interp.c b/sys/boot/common/interp.c index ab0cf258fe95..434992011067 100644 --- a/sys/boot/common/interp.c +++ b/sys/boot/common/interp.c @@ -48,38 +48,6 @@ extern FICL_VM *bf_vm; static void prompt(void); -/* - * Perform the command - */ -int -perform(int argc, char *argv[]) -{ - int result; - struct bootblk_command **cmdp; - bootblk_cmd_t *cmd; - - if (argc < 1) - return(CMD_OK); - - /* set return defaults; a successful command will override these */ - command_errmsg = command_errbuf; - strcpy(command_errbuf, "no error message"); - cmd = NULL; - result = CMD_ERROR; - - /* search the command set for the command */ - SET_FOREACH(cmdp, Xcommand_set) { - if (((*cmdp)->c_name != NULL) && !strcmp(argv[0], (*cmdp)->c_name)) - cmd = (*cmdp)->c_fn; - } - if (cmd != NULL) { - result = (cmd)(argc, argv); - } else { - command_errmsg = "unknown command"; - } - RETURN(result); -} - /* * Interactive mode */ @@ -157,7 +125,7 @@ command_include(int argc, char *argv[]) /* * Since argv is static, we need to save it here. */ - argvbuf = (char**) calloc(argc, sizeof(char*)); + argvbuf = (char**) calloc((u_int)argc, sizeof(char*)); for (i = 0; i < argc; i++) argvbuf[i] = strdup(argv[i]); @@ -183,7 +151,7 @@ struct includeline }; int -include(char *filename) +include(const char *filename) { struct includeline *script, *se, *sp; char input[256]; /* big enough? */ diff --git a/sys/boot/common/interp_backslash.c b/sys/boot/common/interp_backslash.c index 6325e4ef3489..8bbeb347b0f2 100644 --- a/sys/boot/common/interp_backslash.c +++ b/sys/boot/common/interp_backslash.c @@ -18,6 +18,7 @@ #include #include +#include "bootstrap.h" #define DIGIT(x) (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A') diff --git a/sys/boot/common/interp_forth.c b/sys/boot/common/interp_forth.c index 251caf1e8f03..a77fb6cda9f4 100644 --- a/sys/boot/common/interp_forth.c +++ b/sys/boot/common/interp_forth.c @@ -64,7 +64,7 @@ static void bf_command(FICL_VM *vm) { char *name, *line, *tail, *cp; - int len; + size_t len; struct bootblk_command **cmdp; bootblk_cmd_t *cmd; int nstrings, i; diff --git a/sys/boot/common/interp_parse.c b/sys/boot/common/interp_parse.c index 0f83c430766c..c57001ad9c37 100644 --- a/sys/boot/common/interp_parse.c +++ b/sys/boot/common/interp_parse.c @@ -18,13 +18,11 @@ #include #include +#include "bootstrap.h" -/* Forward decls */ -extern char *backslash(char *str); - -static void clean(void); -static int insert(int *argcp, char *buf); -static char *variable_lookup(char *name); +static void clean(void); +static int insert(int *argcp, char *buf); +static char *variable_lookup(char *name); #define PARSE_BUFSIZE 1024 /* maximum size of one element */ #define MAXARGS 20 /* maximum number of elements */ @@ -61,7 +59,7 @@ if (expr) { \ /* Accept the usual delimiters for a variable, returning counterpart */ static char -isdelim(char ch) +isdelim(int ch) { if (ch == '{') return '}'; @@ -71,7 +69,7 @@ isdelim(char ch) } static int -isquote(char ch) +isquote(int ch) { return (ch == '\'' || ch == '"'); } @@ -81,7 +79,7 @@ parse(int *argc, char ***argv, char *str) { int ac; char *val, *p, *q, *copy = NULL; - int i = 0; + size_t i = 0; char token, tmp, quote, *buf; enum { STR, VAR, WHITE } state; @@ -147,7 +145,7 @@ parse(int *argc, char ***argv, char *str) tmp = *q; *q = '\0'; if ((val = variable_lookup(p)) != NULL) { - int len = strlen(val); + size_t len = strlen(val); strncpy(buf + i, val, PARSE_BUFSIZE - (i + 1)); i += min(len, PARSE_BUFSIZE - 1); diff --git a/sys/boot/common/isapnp.c b/sys/boot/common/isapnp.c index 19417068601a..0c5646d0d4c3 100644 --- a/sys/boot/common/isapnp.c +++ b/sys/boot/common/isapnp.c @@ -39,9 +39,8 @@ #define inb(x) (archsw.arch_isainb((x))) #define outb(x,y) (archsw.arch_isaoutb((x),(y))) -static void isapnp_write(int d, u_char r); -static u_char isapnp_read(int d); -static void isapnp_send_Initiation_LFSR(); +static void isapnp_write(int d, int r); +static void isapnp_send_Initiation_LFSR(void); static int isapnp_get_serial(u_int8_t *p); static int isapnp_isolation_protocol(void); static void isapnp_enumerate(void); @@ -58,25 +57,18 @@ struct pnphandler isapnphandler = }; static void -isapnp_write(int d, u_char r) +isapnp_write(int d, int r) { outb (_PNP_ADDRESS, d); outb (_PNP_WRITE_DATA, r); } -static u_char -isapnp_read(int d) -{ - outb (_PNP_ADDRESS, d); - return (inb(isapnp_readport)); -} - /* * Send Initiation LFSR as described in "Plug and Play ISA Specification", * Intel May 94. */ static void -isapnp_send_Initiation_LFSR() +isapnp_send_Initiation_LFSR(void) { int cur, i; @@ -167,8 +159,9 @@ static int isapnp_scan_resdata(struct pnpinfo *pi) { u_char tag, resinfo[8]; - int large_len, limit; - char *str; + u_int limit; + size_t large_len; + u_char *str; limit = 1000; while ((limit-- > 0) && !isapnp_get_resource_info(&tag, 1)) { @@ -204,13 +197,13 @@ isapnp_scan_resdata(struct pnpinfo *pi) case ID_STRING_ANSI: str = malloc(large_len + 1); - if (isapnp_get_resource_info(str, large_len)) { + if (isapnp_get_resource_info(str, (ssize_t)large_len)) { free(str); return(1); } str[large_len] = 0; if (pi->pi_desc == NULL) { - pi->pi_desc = str; + pi->pi_desc = (char *)str; } else { free(str); } @@ -218,7 +211,7 @@ isapnp_scan_resdata(struct pnpinfo *pi) default: /* Large resource, skip it */ - if (isapnp_get_resource_info(NULL, large_len)) + if (isapnp_get_resource_info(NULL, (ssize_t)large_len)) return(1); } } diff --git a/sys/boot/common/load_aout.c b/sys/boot/common/load_aout.c index c36cfac80688..88678154b9e0 100644 --- a/sys/boot/common/load_aout.c +++ b/sys/boot/common/load_aout.c @@ -47,8 +47,8 @@ static vm_offset_t aout_findkldident(struct preloaded_file *fp, struct exec *ehd static int aout_fixupkldmod(struct preloaded_file *fp, struct exec *ehdr); #endif -char *aout_kerneltype = "a.out kernel"; -char *aout_moduletype = "a.out module"; +const char *aout_kerneltype = "a.out kernel"; +const char *aout_moduletype = "a.out module"; /* * Attempt to load the file (file) as an a.out module. It will be stored at @@ -191,21 +191,24 @@ aout_loadimage(struct preloaded_file *fp, int fd, vm_offset_t loadaddr, struct e { u_int pad; vm_offset_t addr; - int ss; + size_t ss; + ssize_t result; vm_offset_t ssym, esym; addr = loadaddr; - lseek(fd, N_TXTOFF(*ehdr), SEEK_SET); + lseek(fd, (off_t)N_TXTOFF(*ehdr), SEEK_SET); /* text segment */ printf(" text=0x%lx ", ehdr->a_text); - if (archsw.arch_readin(fd, addr, ehdr->a_text) != ehdr->a_text) + result = archsw.arch_readin(fd, addr, ehdr->a_text); + if (result < 0 || (size_t)result != ehdr->a_text) return(0); addr += ehdr->a_text; /* data segment */ printf("data=0x%lx ", ehdr->a_data); - if (archsw.arch_readin(fd, addr, ehdr->a_data) != ehdr->a_data) + result = archsw.arch_readin(fd, addr, ehdr->a_data); + if (result < 0 || (size_t)result != ehdr->a_data) return(0); addr += ehdr->a_data; @@ -228,7 +231,8 @@ aout_loadimage(struct preloaded_file *fp, int fd, vm_offset_t loadaddr, struct e /* symbol table */ printf("symbols=[0x%lx+0x%lx", (long)sizeof(ehdr->a_syms),ehdr->a_syms); - if (archsw.arch_readin(fd, addr, ehdr->a_syms) != ehdr->a_syms) + result = archsw.arch_readin(fd, addr, ehdr->a_syms); + if (result < 0 || (size_t)result != ehdr->a_syms) return(0); addr += ehdr->a_syms; @@ -238,7 +242,8 @@ aout_loadimage(struct preloaded_file *fp, int fd, vm_offset_t loadaddr, struct e addr += sizeof(ss); ss -= sizeof(ss); printf("+0x%lx+0x%x]", (long)sizeof(ss), ss); - if (archsw.arch_readin(fd, addr, ss) != ss) + result = archsw.arch_readin(fd, addr, ss); + if (result < 0 || (size_t)result != ss) return(0); addr += ss; esym = addr; diff --git a/sys/boot/common/load_elf.c b/sys/boot/common/load_elf.c index 40a15fd48c6a..388d5a1ccfc4 100644 --- a/sys/boot/common/load_elf.c +++ b/sys/boot/common/load_elf.c @@ -57,7 +57,7 @@ typedef struct elf_file { size_t strsz; int fd; caddr_t firstpage; - int firstlen; + size_t firstlen; int kernel; vm_offset_t off; } *elf_file_t; @@ -65,9 +65,10 @@ typedef struct elf_file { static int elf_loadimage(struct preloaded_file *mp, elf_file_t ef, vm_offset_t loadaddr); static int elf_lookup_symbol(struct preloaded_file *mp, elf_file_t ef, const char* name, Elf_Sym* sym); static int elf_parse_modmetadata(struct preloaded_file *mp, elf_file_t ef); +static char *fake_modname(const char *name); -char *elf_kerneltype = "elf kernel"; -char *elf_moduletype = "elf module"; +const char *elf_kerneltype = "elf kernel"; +const char *elf_moduletype = "elf module"; /* * Attempt to load the file (file) as an ELF module. It will be stored at @@ -83,6 +84,7 @@ elf_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result) int err; u_int pad; char *s; + ssize_t bytes_read; fp = NULL; bzero(&ef, sizeof(struct elf_file)); @@ -99,8 +101,9 @@ elf_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result) close(ef.fd); return(ENOMEM); } - ef.firstlen = read(ef.fd, ef.firstpage, PAGE_SIZE); - if (ef.firstlen <= sizeof(Elf_Ehdr)) { + bytes_read = read(ef.fd, ef.firstpage, PAGE_SIZE); + ef.firstlen = (size_t)bytes_read; + if (bytes_read < 0 || ef.firstlen <= sizeof(Elf_Ehdr)) { err = EFTYPE; /* could be EIO, but may be small file */ goto oerr; } @@ -224,7 +227,8 @@ elf_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result) static int elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off) { - int i, j; + int i; + u_int j; Elf_Ehdr *ehdr; Elf_Phdr *phdr, *php; Elf_Shdr *shdr; @@ -233,6 +237,7 @@ elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off) vm_offset_t lastaddr; void *buf; size_t resid, chunk; + ssize_t result; vm_offset_t dest; vm_offset_t ssym, esym; Elf_Dyn *dp; @@ -241,7 +246,7 @@ elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off) int symstrindex; int symtabindex; long size; - int fpcopy; + u_int fpcopy; dp = NULL; shdr = NULL; @@ -290,12 +295,13 @@ elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off) phdr[i].p_vaddr + off, fpcopy); } if (phdr[i].p_filesz > fpcopy) { - if (lseek(ef->fd, phdr[i].p_offset + fpcopy, SEEK_SET) == -1) { + if (lseek(ef->fd, (off_t)(phdr[i].p_offset + fpcopy), + SEEK_SET) == -1) { printf("\nelf_loadexec: cannot seek\n"); goto out; } if (archsw.arch_readin(ef->fd, phdr[i].p_vaddr + off + fpcopy, - phdr[i].p_filesz - fpcopy) != phdr[i].p_filesz - fpcopy) { + phdr[i].p_filesz - fpcopy) != (ssize_t)(phdr[i].p_filesz - fpcopy)) { printf("\nelf_loadexec: archsw.readin failed\n"); goto out; } @@ -348,11 +354,12 @@ elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off) shdr = malloc(chunk); if (shdr == NULL) goto nosyms; - if (lseek(ef->fd, ehdr->e_shoff, SEEK_SET) == -1) { + if (lseek(ef->fd, (off_t)ehdr->e_shoff, SEEK_SET) == -1) { printf("\nelf_loadimage: cannot lseek() to section headers"); goto nosyms; } - if (read(ef->fd, shdr, chunk) != chunk) { + result = read(ef->fd, shdr, chunk); + if (result < 0 || (size_t)result != chunk) { printf("\nelf_loadimage: read section headers failed"); goto nosyms; } @@ -417,14 +424,14 @@ elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off) printf("0x%lx+0x%lx", (long)sizeof(size), size); #endif - if (lseek(ef->fd, shdr[i].sh_offset, SEEK_SET) == -1) { + if (lseek(ef->fd, (off_t)shdr[i].sh_offset, SEEK_SET) == -1) { printf("\nelf_loadimage: could not seek for symbols - skipped!"); lastaddr = ssym; ssym = 0; goto nosyms; } - if (archsw.arch_readin(ef->fd, lastaddr, shdr[i].sh_size) != - shdr[i].sh_size) { + result = archsw.arch_readin(ef->fd, lastaddr, shdr[i].sh_size); + if (result < 0 || (size_t)result != shdr[i].sh_size) { printf("\nelf_loadimage: could not read symbols - skipped!"); lastaddr = ssym; ssym = 0; @@ -531,9 +538,9 @@ elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off) static char invalid_name[] = "bad"; char * -fake_modname(char *name) { +fake_modname(const char *name) { char *sp, *ep; - int len; + size_t len; sp = strrchr(name, '/'); if (sp) @@ -561,8 +568,7 @@ int elf_parse_modmetadata(struct preloaded_file *fp, elf_file_t ef) { struct mod_metadata md; Elf_Sym sym; - void **p, *v; - char *s; + char *s, *v, **p; long entries; int modcnt; @@ -571,7 +577,7 @@ elf_parse_modmetadata(struct preloaded_file *fp, elf_file_t ef) { COPYOUT(sym.st_value + ef->off, &entries, sizeof(entries)); modcnt = 0; - p = (void*)(sym.st_value + ef->off + sizeof(entries)); + p = (char **)(sym.st_value + ef->off + sizeof(entries)); while (entries--) { COPYOUT(p++, &v, sizeof(v)); COPYOUT(v + ef->off, &md, sizeof(md)); diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c index 8ad0dc092c52..effb848fa0e7 100644 --- a/sys/boot/common/module.c +++ b/sys/boot/common/module.c @@ -49,7 +49,7 @@ struct file_metadata* metadata_next(struct file_metadata *base_mp, int type); /* load address should be tweaked by first module loaded (kernel) */ static vm_offset_t loadaddr = 0; -static char *default_searchpath ="/;/boot;/modules"; +static const char *default_searchpath ="/;/boot;/modules"; struct preloaded_file *preloaded_files = NULL; @@ -434,7 +434,7 @@ file_addmetadata(struct preloaded_file *fp, int type, size_t size, void *p) { struct file_metadata *md; - md = malloc(sizeof(struct file_metadata) + size); + md = malloc(sizeof(struct file_metadata) - sizeof(md->md_data) + size); md->md_size = size; md->md_type = type; bcopy(p, md->md_data, size); diff --git a/sys/boot/common/pnp.c b/sys/boot/common/pnp.c index bb3695be3a8c..b859529a4d11 100644 --- a/sys/boot/common/pnp.c +++ b/sys/boot/common/pnp.c @@ -19,8 +19,6 @@ STAILQ_HEAD(,pnpinfo) pnp_devices; static int pnp_devices_initted = 0; static void pnp_discard(void); -static int pnp_readconf(char *path); -static int pnp_scankernel(void); /* * Perform complete enumeration sweep diff --git a/sys/boot/i386/boot0/Makefile b/sys/boot/i386/boot0/Makefile index a40e78084312..92bba82f6106 100644 --- a/sys/boot/i386/boot0/Makefile +++ b/sys/boot/i386/boot0/Makefile @@ -8,24 +8,33 @@ BINMODE= 444 M4?= m4 -# update, packet mode, and all slices enabled by default -B0FLAGS=0x8f -B0TICKS=0xb6 +# The default set of flags compiled into boot0. This enables update (writing +# the modified boot0 back to disk after running so that the selection made is +# saved), packet mode (detect and use the BIOS EDD extensions if we try to +# boot past the 1024 cylinder liimt), and booting from all valid slices. +BOOT_BOOT0_FLAGS?= 0x8f -ORG= 0x600 +# The number of timer ticks to wait for a keypress before assuming the default +# selection. Since there are 18.2 ticks per second, the default value of +# 0xb6 (182d) corresponds to 10 seconds. +BOOT_BOOT0_TICKS?= 0xb6 + +# The base address that we the boot0 code to to run it. Don't change this +# unless you are glutton for punishment. +BOOT_BOOT0_ORG?= 0x600 boot0: boot0.o .if ${OBJFORMAT} == aout - ${LD} -N -s -T ${ORG} -o boot0.out boot0.o + ${LD} -N -s -T ${BOOT_BOOT0_ORG} -o boot0.out boot0.o dd if=boot0.out of=${.TARGET} ibs=32 skip=1 .else - ${LD} -N -e start -Ttext ${ORG} -o boot0.out boot0.o + ${LD} -N -e start -Ttext ${BOOT_BOOT0_ORG} -o boot0.out boot0.o objcopy -S -O binary boot0.out ${.TARGET} .endif boot0.o: boot0.s - ${AS} ${AFLAGS} --defsym FLAGS=${B0FLAGS} --defsym TICKS=${B0TICKS} \ - ${.IMPSRC} -o ${.TARGET} + ${AS} ${AFLAGS} --defsym FLAGS=${BOOT_BOOT0_FLAGS} \ + --defsym TICKS=${BOOT_BOOT0_TICKS} ${.IMPSRC} -o ${.TARGET} CLEANFILES+= boot0.out boot0.o diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile index 36ec6fddd0ca..b200aed34100 100644 --- a/sys/boot/i386/libi386/Makefile +++ b/sys/boot/i386/libi386/Makefile @@ -22,8 +22,10 @@ CFLAGS+= -DCOMSPEED=${BOOT_COMCONSOLE_SPEED} # the location of libstand CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ +.ifdef(BOOT_BIOSDISK_DEBUG) # Make the disk code more talkative -#CFLAGS+= -DDISK_DEBUG +CFLAGS+= -DDISK_DEBUG +.endif # Include simple terminal emulation (cons25-compatible) CFLAGS+= -DTERM_EMU diff --git a/sys/boot/i386/libi386/aout_freebsd.c b/sys/boot/i386/libi386/aout_freebsd.c index 857dc3a4596e..aed8d6421858 100644 --- a/sys/boot/i386/libi386/aout_freebsd.c +++ b/sys/boot/i386/libi386/aout_freebsd.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/sys/boot/i386/libi386/biosmem.c b/sys/boot/i386/libi386/biosmem.c index 4bab178e4e10..7614e843ce49 100644 --- a/sys/boot/i386/libi386/biosmem.c +++ b/sys/boot/i386/libi386/biosmem.c @@ -30,6 +30,7 @@ * Obtain memory configuration information from the BIOS */ #include +#include "libi386.h" #include "btxv86.h" vm_offset_t memtop; diff --git a/sys/boot/i386/libi386/biospci.c b/sys/boot/i386/libi386/biospci.c index 483384c2c157..356ea126b4af 100644 --- a/sys/boot/i386/libi386/biospci.c +++ b/sys/boot/i386/libi386/biospci.c @@ -31,7 +31,6 @@ */ #include -#include #include #include #include @@ -48,7 +47,7 @@ struct pci_progif { int pi_code; - char *pi_name; + const char *pi_name; }; static struct pci_progif progif_null[] = { @@ -116,7 +115,7 @@ static struct pci_progif progif_parallel[] = { struct pci_subclass { int ps_subclass; - char *ps_name; + const char *ps_name; struct pci_progif *ps_progif; /* if set, use for programming interface value(s) */ }; @@ -171,7 +170,7 @@ static struct pci_subclass subclass_serial[] = { static struct pci_class { int pc_class; - char *pc_name; + const char *pc_name; struct pci_subclass *pc_subclass; } pci_classes[] = { {0x0, "device", subclass_old}, @@ -199,7 +198,7 @@ struct pnphandler biospcihandler = static void biospci_enumerate(void) { - int index, locator, devid; + int device_index, locator, devid; struct pci_class *pc; struct pci_subclass *psc; struct pci_progif *ppi; @@ -230,14 +229,14 @@ biospci_enumerate(void) for (ppi = psc->ps_progif; ppi->pi_code >= 0; ppi++) { /* Scan for matches */ - for (index = 0; ; index++) { + for (device_index = 0; ; device_index++) { /* Look for a match */ v86.ctl = V86_FLAGS; v86.addr = 0x1a; v86.eax = 0xb103; v86.ecx = (pc->pc_class << 16) + (psc->ps_subclass << 8) + ppi->pi_code; - v86.esi = index; + v86.esi = device_index; v86int(); /* error/end of matches */ if ((v86.efl & 1) || (v86.eax & 0xff00)) diff --git a/sys/boot/i386/libi386/biospnp.c b/sys/boot/i386/libi386/biospnp.c index 616a22cdc458..eee77aad5579 100644 --- a/sys/boot/i386/libi386/biospnp.c +++ b/sys/boot/i386/libi386/biospnp.c @@ -31,7 +31,6 @@ */ #include -#include #include #include #include @@ -71,7 +70,7 @@ struct pnp_devNode u_int8_t dn_id[4] __attribute__ ((packed)); u_int8_t dn_type[3] __attribute__ ((packed)); u_int16_t dn_attrib __attribute__ ((packed)); - u_int8_t dn_data[0] __attribute__ ((packed)); + u_int8_t dn_data[1] __attribute__ ((packed)); }; struct pnp_isaConfiguration @@ -87,10 +86,12 @@ static u_int16_t pnp_NumNodes; static u_int16_t pnp_NodeSize; static void biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn); -static int biospnp_call(int func, char *fmt, ...); +static int biospnp_call(int func, const char *fmt, ...); #define vsegofs(vptr) (((u_int32_t)VTOPSEG(vptr) << 16) + VTOPOFF(vptr)) -void (* v86bios)(u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3) = (void *)v86int; + +typedef void v86bios_t(u_int32_t, u_int32_t, u_int32_t, u_int32_t); +v86bios_t *v86bios = (v86bios_t *)v86int; #define biospnp_f00(NumNodes, NodeSize) biospnp_call(0x00, "ll", NumNodes, NodeSize) #define biospnp_f01(Node, devNodeBuffer, Control) biospnp_call(0x01, "llw", Node, devNodeBuffer, Control) @@ -186,7 +187,7 @@ biospnp_enumerate(void) static void biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn) { - int tag, i, rlen, dlen; + u_int tag, i, rlen, dlen; u_int8_t *p; char *str; @@ -243,10 +244,10 @@ biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn) * this evil. */ static int -biospnp_call(int func, char *fmt, ...) +biospnp_call(int func, const char *fmt, ...) { va_list ap; - char *p; + const char *p; u_int8_t *argp; u_int32_t args[4]; u_int32_t i; diff --git a/sys/boot/i386/libi386/bootinfo.c b/sys/boot/i386/libi386/bootinfo.c index 90142654470b..63be83faee3b 100644 --- a/sys/boot/i386/libi386/bootinfo.c +++ b/sys/boot/i386/libi386/bootinfo.c @@ -43,7 +43,7 @@ static struct bootinfo bi; */ static struct { - char *ev; + const char *ev; int mask; } howto_names[] = { {"boot_askname", RB_ASKNAME}, @@ -56,6 +56,8 @@ static struct {NULL, 0} }; +vm_offset_t bi_copymodules(vm_offset_t addr); + int bi_getboothowto(char *kargs) { @@ -227,7 +229,7 @@ bi_copymodules(vm_offset_t addr) * Load the information expected by an i386 kernel. * * - The 'boothowto' argument is constructed - * - The 'botdev' argument is constructed + * - The 'bootdev' argument is constructed * - The 'bootinfo' struct is constructed, and copied into the kernel space. * - The kernel environment is copied into kernel space. * - Module metadata are formatted and placed in kernel space. @@ -237,7 +239,7 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip) { struct preloaded_file *xp; struct i386_devdesc *rootdev; - vm_offset_t addr, bootinfo_addr; + vm_offset_t addr; char *rootdevname; int bootdevnr, i; u_int pad; @@ -262,6 +264,10 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip) getrootmount(i386_fmtdev((void *)rootdev)); /* Do legacy rootdev guessing */ + + /* XXX - use a default bootdev of 0. Is this ok??? */ + bootdevnr = 0; + switch(rootdev->d_type) { case DEVT_DISK: /* pass in the BIOS device number of the current disk */ diff --git a/sys/boot/i386/libi386/bootinfo32.c b/sys/boot/i386/libi386/bootinfo32.c index 90142654470b..63be83faee3b 100644 --- a/sys/boot/i386/libi386/bootinfo32.c +++ b/sys/boot/i386/libi386/bootinfo32.c @@ -43,7 +43,7 @@ static struct bootinfo bi; */ static struct { - char *ev; + const char *ev; int mask; } howto_names[] = { {"boot_askname", RB_ASKNAME}, @@ -56,6 +56,8 @@ static struct {NULL, 0} }; +vm_offset_t bi_copymodules(vm_offset_t addr); + int bi_getboothowto(char *kargs) { @@ -227,7 +229,7 @@ bi_copymodules(vm_offset_t addr) * Load the information expected by an i386 kernel. * * - The 'boothowto' argument is constructed - * - The 'botdev' argument is constructed + * - The 'bootdev' argument is constructed * - The 'bootinfo' struct is constructed, and copied into the kernel space. * - The kernel environment is copied into kernel space. * - Module metadata are formatted and placed in kernel space. @@ -237,7 +239,7 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip) { struct preloaded_file *xp; struct i386_devdesc *rootdev; - vm_offset_t addr, bootinfo_addr; + vm_offset_t addr; char *rootdevname; int bootdevnr, i; u_int pad; @@ -262,6 +264,10 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip) getrootmount(i386_fmtdev((void *)rootdev)); /* Do legacy rootdev guessing */ + + /* XXX - use a default bootdev of 0. Is this ok??? */ + bootdevnr = 0; + switch(rootdev->d_type) { case DEVT_DISK: /* pass in the BIOS device number of the current disk */ diff --git a/sys/boot/i386/libi386/bootinfo64.c b/sys/boot/i386/libi386/bootinfo64.c index 90142654470b..63be83faee3b 100644 --- a/sys/boot/i386/libi386/bootinfo64.c +++ b/sys/boot/i386/libi386/bootinfo64.c @@ -43,7 +43,7 @@ static struct bootinfo bi; */ static struct { - char *ev; + const char *ev; int mask; } howto_names[] = { {"boot_askname", RB_ASKNAME}, @@ -56,6 +56,8 @@ static struct {NULL, 0} }; +vm_offset_t bi_copymodules(vm_offset_t addr); + int bi_getboothowto(char *kargs) { @@ -227,7 +229,7 @@ bi_copymodules(vm_offset_t addr) * Load the information expected by an i386 kernel. * * - The 'boothowto' argument is constructed - * - The 'botdev' argument is constructed + * - The 'bootdev' argument is constructed * - The 'bootinfo' struct is constructed, and copied into the kernel space. * - The kernel environment is copied into kernel space. * - Module metadata are formatted and placed in kernel space. @@ -237,7 +239,7 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip) { struct preloaded_file *xp; struct i386_devdesc *rootdev; - vm_offset_t addr, bootinfo_addr; + vm_offset_t addr; char *rootdevname; int bootdevnr, i; u_int pad; @@ -262,6 +264,10 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip) getrootmount(i386_fmtdev((void *)rootdev)); /* Do legacy rootdev guessing */ + + /* XXX - use a default bootdev of 0. Is this ok??? */ + bootdevnr = 0; + switch(rootdev->d_type) { case DEVT_DISK: /* pass in the BIOS device number of the current disk */ diff --git a/sys/boot/i386/libi386/comconsole.c b/sys/boot/i386/libi386/comconsole.c index ee6fbc8f53a7..9440b3a1f34d 100644 --- a/sys/boot/i386/libi386/comconsole.c +++ b/sys/boot/i386/libi386/comconsole.c @@ -114,7 +114,7 @@ comc_putchar(int c) for (wait = COMC_TXWAIT; wait > 0; wait--) if (inb(COMPORT + com_lsr) & LSR_TXRDY) { - outb(COMPORT + com_data, c); + outb(COMPORT + com_data, (u_char)c); break; } } diff --git a/sys/boot/i386/libi386/elf32_freebsd.c b/sys/boot/i386/libi386/elf32_freebsd.c index a3ad9fb19043..c35cc5acb626 100644 --- a/sys/boot/i386/libi386/elf32_freebsd.c +++ b/sys/boot/i386/libi386/elf32_freebsd.c @@ -43,8 +43,6 @@ static int elf_exec(struct preloaded_file *amp); struct file_format i386_elf = { elf_loadfile, elf_exec }; -static struct bootinfo bi; - /* * There is an a.out kernel and one or more a.out modules loaded. * We wish to start executing the kernel image, so make such diff --git a/sys/boot/i386/libi386/elf64_freebsd.c b/sys/boot/i386/libi386/elf64_freebsd.c index a3ad9fb19043..c35cc5acb626 100644 --- a/sys/boot/i386/libi386/elf64_freebsd.c +++ b/sys/boot/i386/libi386/elf64_freebsd.c @@ -43,8 +43,6 @@ static int elf_exec(struct preloaded_file *amp); struct file_format i386_elf = { elf_loadfile, elf_exec }; -static struct bootinfo bi; - /* * There is an a.out kernel and one or more a.out modules loaded. * We wish to start executing the kernel image, so make such diff --git a/sys/boot/i386/libi386/elf_freebsd.c b/sys/boot/i386/libi386/elf_freebsd.c index a3ad9fb19043..c35cc5acb626 100644 --- a/sys/boot/i386/libi386/elf_freebsd.c +++ b/sys/boot/i386/libi386/elf_freebsd.c @@ -43,8 +43,6 @@ static int elf_exec(struct preloaded_file *amp); struct file_format i386_elf = { elf_loadfile, elf_exec }; -static struct bootinfo bi; - /* * There is an a.out kernel and one or more a.out modules loaded. * We wish to start executing the kernel image, so make such diff --git a/sys/boot/i386/libi386/gatea20.c b/sys/boot/i386/libi386/gatea20.c index b85265489e7d..67971189451d 100644 --- a/sys/boot/i386/libi386/gatea20.c +++ b/sys/boot/i386/libi386/gatea20.c @@ -5,10 +5,10 @@ /* extracted from freebsd:sys/i386/boot/biosboot/io.c */ -#include +#include #include -#include +#include #include "libi386.h" @@ -36,7 +36,7 @@ void gateA20() __asm("pushfl ; cli"); #ifdef IBM_L40 outb(0x92, 0x2); -#else IBM_L40 +#else /* !IBM_L40 */ while (inb(K_STATUS) & K_IBUF_FUL); while (inb(K_STATUS) & K_OBUF_FUL) (void)inb(K_RDWR); @@ -47,6 +47,6 @@ void gateA20() outb(K_RDWR, x_20); delay(100); while (inb(K_STATUS) & K_IBUF_FUL); -#endif IBM_L40 +#endif /* IBM_L40 */ __asm("popfl"); } diff --git a/sys/boot/i386/libi386/i386_copy.c b/sys/boot/i386/libi386/i386_copy.c index 02f8b8702bfd..f7cc2f01e26f 100644 --- a/sys/boot/i386/libi386/i386_copy.c +++ b/sys/boot/i386/libi386/i386_copy.c @@ -38,8 +38,8 @@ #define READIN_BUF (16 * 1024) -int -i386_copyin(void *src, vm_offset_t dest, size_t len) +ssize_t +i386_copyin(const void *src, vm_offset_t dest, const size_t len) { if (dest + len >= memtop) { errno = EFBIG; @@ -50,8 +50,8 @@ i386_copyin(void *src, vm_offset_t dest, size_t len) return(len); } -int -i386_copyout(vm_offset_t src, void *dest, size_t len) +ssize_t +i386_copyout(const vm_offset_t src, void *dest, const size_t len) { if (src + len >= memtop) { errno = EFBIG; @@ -63,8 +63,8 @@ i386_copyout(vm_offset_t src, void *dest, size_t len) } -int -i386_readin(int fd, vm_offset_t dest, size_t len) +ssize_t +i386_readin(const int fd, vm_offset_t dest, const size_t len) { void *buf; size_t resid, chunk, get; @@ -83,10 +83,8 @@ i386_readin(int fd, vm_offset_t dest, size_t len) got = read(fd, buf, get); if (got <= 0) break; - bcopy(buf, PTOV(dest), got); + bcopy(buf, PTOV(dest), (size_t)got); } free(buf); return(len - resid); } - - diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h index 3061dc7e1867..3db8f062f074 100644 --- a/sys/boot/i386/libi386/libi386.h +++ b/sys/boot/i386/libi386/libi386.h @@ -52,9 +52,9 @@ struct i386_devdesc } d_kind; }; -extern int i386_getdev(void **vdev, const char *devspec, const char **path); -extern char *i386_fmtdev(void *vdev); -extern int i386_setcurrdev(struct env_var *ev, int flags, void *value); +int i386_getdev(void **vdev, const char *devspec, const char **path); +char *i386_fmtdev(void *vdev); +int i386_setcurrdev(struct env_var *ev, int flags, void *value); extern struct devdesc currdev; /* our current device */ @@ -65,26 +65,26 @@ extern struct devsw biosdisk; extern struct devsw pxedisk; extern struct fs_ops pxe_fsops; -u_int32_t bd_getbigeom(int bunit); /* return geometry in bootinfo format */ -extern int bd_bios2unit(int biosdev); /* xlate BIOS device -> biosdisk unit */ -extern int bd_unit2bios(int unit); /* xlate biosdisk unit -> BIOS device */ -extern int bd_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */ +u_int32_t bd_getbigeom(int bunit); /* return geometry in bootinfo format */ +int bd_bios2unit(int biosdev); /* xlate BIOS device -> biosdisk unit */ +int bd_unit2bios(int unit); /* xlate biosdisk unit -> BIOS device */ +int bd_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */ -extern int i386_copyin(void *src, vm_offset_t dest, size_t len); -extern int i386_copyout(vm_offset_t src, void *dest, size_t len); -extern int i386_readin(int fd, vm_offset_t dest, size_t len); +ssize_t i386_copyin(const void *src, vm_offset_t dest, const size_t len); +ssize_t i386_copyout(const vm_offset_t src, void *dest, const size_t len); +ssize_t i386_readin(const int fd, vm_offset_t dest, const size_t len); -extern void bios_getmem(void); +void bios_getmem(void); extern u_int32_t bios_basemem; /* base memory in bytes */ extern u_int32_t bios_extmem; /* extended memory in bytes */ extern vm_offset_t memtop; -extern void gateA20(void); +void gateA20(void); -extern int i386_autoload(void); +int i386_autoload(void); -extern int bi_getboothowto(char *kargs); -extern vm_offset_t bi_copyenv(vm_offset_t addr); -extern int bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip); +int bi_getboothowto(char *kargs); +vm_offset_t bi_copyenv(vm_offset_t addr); +int bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip); -extern void pxe_enable(void *pxeinfo); +void pxe_enable(void *pxeinfo); diff --git a/sys/boot/i386/libi386/pxe.c b/sys/boot/i386/libi386/pxe.c index d6737c236b1d..471bd6d1b684 100644 --- a/sys/boot/i386/libi386/pxe.c +++ b/sys/boot/i386/libi386/pxe.c @@ -59,7 +59,7 @@ static pxenv_t *pxenv_p = NULL; /* PXENV+ */ static pxe_t *pxe_p = NULL; /* !PXE */ static BOOTPLAYER bootplayer; /* PXE Cached information. */ -static int debug = 0; +static int pxe_debug = 0; static int pxe_sock = -1; static int pxe_opens = 0; @@ -70,7 +70,7 @@ static void bangpxe_call(int func); static int pxe_init(void); static int pxe_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, void *buf, size_t *rsize); + size_t size, char *buf, size_t *rsize); static int pxe_open(struct open_file *f, ...); static int pxe_close(struct open_file *f); static void pxe_print(int verbose); @@ -86,8 +86,6 @@ static int pxe_netif_put(struct iodesc *desc, void *pkt, size_t len); static void pxe_netif_end(struct netif *nif); extern struct netif_stats pxe_st[]; -extern struct in_addr rootip; -extern char rootpath[FNAME_SIZE]; extern u_int16_t __bangpxeseg; extern u_int16_t __bangpxeoff; extern void __bangpxeentry(void); @@ -241,7 +239,7 @@ pxe_init(void) static int pxe_strategy(void *devdata, int flag, daddr_t dblk, size_t size, - void *buf, size_t *rsize) + char *buf, size_t *rsize) { return (EIO); } @@ -268,7 +266,7 @@ pxe_open(struct open_file *f, ...) printf("pxe_open: netif_open() failed\n"); return (ENXIO); } - if (debug) + if (pxe_debug) printf("pxe_open: netif_open() succeeded\n"); } if (rootip.s_addr == 0) { @@ -307,7 +305,7 @@ pxe_close(struct open_file *f) { #ifdef PXE_DEBUG - if (debug) + if (pxe_debug) printf("pxe_close: opens=%d\n", pxe_opens); #endif @@ -323,7 +321,7 @@ pxe_close(struct open_file *f) if (pxe_sock >= 0) { #ifdef PXE_DEBUG - if (debug) + if (pxe_debug) printf("pxe_close: calling netif_close()\n"); #endif netif_close(pxe_sock); @@ -352,10 +350,12 @@ pxe_print(int verbose) static void pxe_cleanup(void) { +#ifdef PXE_DEBUG t_PXENV_UNLOAD_STACK *unload_stack_p = (t_PXENV_UNLOAD_STACK *)scratch_buffer; t_PXENV_UNDI_SHUTDOWN *undi_shutdown_p = (t_PXENV_UNDI_SHUTDOWN *)scratch_buffer; +#endif if (pxe_call == NULL) return; @@ -363,7 +363,7 @@ pxe_cleanup(void) pxe_call(PXENV_UNDI_SHUTDOWN); #ifdef PXE_DEBUG - if (debug && undi_shutdown_p->Status != 0) + if (pxe_debug && undi_shutdown_p->Status != 0) printf("pxe_cleanup: UNDI_SHUTDOWN failed %x\n", undi_shutdown_p->Status); #endif @@ -371,7 +371,7 @@ pxe_cleanup(void) pxe_call(PXENV_UNLOAD_STACK); #ifdef PXE_DEBUG - if (debug && unload_stack_p->Status != 0) + if (pxe_debug && unload_stack_p->Status != 0) printf("pxe_cleanup: UNLOAD_STACK failed %x\n", unload_stack_p->Status); #endif @@ -387,7 +387,7 @@ void pxenv_call(int func) { #ifdef PXE_DEBUG - if (debug) + if (pxe_debug) printf("pxenv_call %x\n", func); #endif @@ -410,7 +410,7 @@ void bangpxe_call(int func) { #ifdef PXE_DEBUG - if (debug) + if (pxe_debug) printf("bangpxe_call %x\n", func); #endif diff --git a/sys/boot/i386/libi386/time.c b/sys/boot/i386/libi386/time.c index 0a3981fac4ba..8176ebb9eaa3 100644 --- a/sys/boot/i386/libi386/time.c +++ b/sys/boot/i386/libi386/time.c @@ -28,6 +28,8 @@ #include #include +#include "bootstrap.h" +#include "libi386.h" /* * Return the time in seconds since the beginning of the day. @@ -41,7 +43,7 @@ time_t time(time_t *t) { static time_t lasttime, now; - int hr, min, sec; + int hr, minute, sec; v86.ctl = 0; v86.addr = 0x1a; /* int 0x1a, function 2 */ @@ -49,10 +51,10 @@ time(time_t *t) v86int(); hr = bcd2bin((v86.ecx & 0xff00) >> 8); /* hour in %ch */ - min = bcd2bin(v86.ecx & 0xff); /* minute in %cl */ + minute = bcd2bin(v86.ecx & 0xff); /* minute in %cl */ sec = bcd2bin((v86.edx & 0xff00) >> 8); /* second in %dh */ - now = hr * 3600 + min * 60 + sec; + now = hr * 3600 + minute * 60 + sec; if (now < lasttime) now += 24 * 3600; lasttime = now; diff --git a/sys/boot/i386/libi386/vidconsole.c b/sys/boot/i386/libi386/vidconsole.c index a79bb05ce093..56841a5a6771 100644 --- a/sys/boot/i386/libi386/vidconsole.c +++ b/sys/boot/i386/libi386/vidconsole.c @@ -49,13 +49,14 @@ static int vidc_ischar(void); static int vidc_started; #ifdef TERM_EMU -void end_term(); +void end_term(void); void bail_out(int c); void vidc_term_emu(int c); void get_pos(void); void curs_move(int x, int y); void write_char(int c, int fg, int bg); void scroll_up(int rows, int fg, int bg); +int pow10(int i); void AB(void); void AF(void); void CD(void); @@ -104,7 +105,7 @@ vidc_init(int arg) int i; if (vidc_started && arg == 0) - return; + return(0); vidc_started = 1; #ifdef TERM_EMU /* Init terminal emulator */ @@ -234,13 +235,13 @@ curs_move(int x, int y) * inserted in the window. */ void -scroll_up(int rows, int fg, int bg) +scroll_up(int rows, int fgcol, int bgcol) { if(rows==0) rows=25; v86.ctl = 0; v86.addr = 0x10; v86.eax = 0x0600+(0x00ff & rows); - v86.ebx = (bg<<12)+(fg<<8); + v86.ebx = (bgcol<<12)+(fgcol<<8); v86.ecx = 0x0; v86.edx = 0x184f; v86int(); @@ -248,12 +249,12 @@ scroll_up(int rows, int fg, int bg) /* Write character and attribute at cursor position. */ void -write_char(int c, int fg, int bg) +write_char(int c, int fgcol, int bgcol) { v86.ctl=0; v86.addr = 0x10; v86.eax = 0x0900+(0x00ff & c); - v86.ebx = (bg<<4)+fg; + v86.ebx = (bgcol<<4)+fgcol; v86.ecx = 0x1; v86int(); } diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c index a078c6d0b501..f6754750b798 100644 --- a/sys/boot/i386/loader/main.c +++ b/sys/boot/i386/loader/main.c @@ -63,6 +63,7 @@ struct arch_switch archsw; /* MI/MD interface boundary */ static void extract_currdev(void); static int isa_inb(int port); static void isa_outb(int port, int value); +void exit(int code); /* from vers.c */ extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; @@ -70,7 +71,7 @@ extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; /* XXX debugging */ extern char end[]; -void +int main(void) { int i; @@ -138,6 +139,9 @@ main(void) archsw.arch_isaoutb = isa_outb; interact(); /* doesn't return */ + + /* if we ever get here, it is an error */ + return (1); } /* @@ -149,40 +153,41 @@ main(void) static void extract_currdev(void) { - struct i386_devdesc currdev; + struct i386_devdesc new_currdev; int major, biosdev; /* Assume we are booting from a BIOS disk by default */ - currdev.d_dev = &biosdisk; - currdev.d_type = currdev.d_dev->dv_type; + new_currdev.d_dev = &biosdisk; + new_currdev.d_type = new_currdev.d_dev->dv_type; /* new-style boot loaders such as pxeldr and cdldr */ if (kargs->bootinfo == NULL) { if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) { /* we are booting from a CD with cdldr */ - currdev.d_kind.biosdisk.slice = -1; - currdev.d_kind.biosdisk.partition = 0; + new_currdev.d_kind.biosdisk.slice = -1; + new_currdev.d_kind.biosdisk.partition = 0; biosdev = initial_bootdev; } else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) { /* we are booting from pxeldr */ - currdev.d_dev = &pxedisk; - currdev.d_type = currdev.d_dev->dv_type; - currdev.d_kind.netif.unit = 0; + new_currdev.d_dev = &pxedisk; + new_currdev.d_type = new_currdev.d_dev->dv_type; + new_currdev.d_kind.netif.unit = 0; + biosdev = -1; } else { /* we don't know what our boot device is */ - currdev.d_kind.biosdisk.slice = -1; - currdev.d_kind.biosdisk.partition = 0; + new_currdev.d_kind.biosdisk.slice = -1; + new_currdev.d_kind.biosdisk.partition = 0; biosdev = -1; } } else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) { /* The passed-in boot device is bad */ - currdev.d_kind.biosdisk.slice = -1; - currdev.d_kind.biosdisk.partition = 0; + new_currdev.d_kind.biosdisk.slice = -1; + new_currdev.d_kind.biosdisk.partition = 0; biosdev = -1; } else { - currdev.d_kind.biosdisk.slice = (B_ADAPTOR(initial_bootdev) << 4) + - B_CONTROLLER(initial_bootdev) - 1; - currdev.d_kind.biosdisk.partition = B_PARTITION(initial_bootdev); + new_currdev.d_kind.biosdisk.slice = (B_ADAPTOR(initial_bootdev) << 4) + + B_CONTROLLER(initial_bootdev) - 1; + new_currdev.d_kind.biosdisk.partition = B_PARTITION(initial_bootdev); biosdev = initial_bootinfo->bi_bios_dev; major = B_TYPE(initial_bootdev); @@ -200,14 +205,16 @@ extract_currdev(void) * If we are booting off of a BIOS disk and we didn't succeed in determining * which one we booted off of, just use disk0: as a reasonable default. */ - if ((currdev.d_type == devsw[0]->dv_type) && - ((currdev.d_kind.biosdisk.unit = bd_bios2unit(biosdev)) == -1)) { + if ((new_currdev.d_type == devsw[0]->dv_type) && + ((new_currdev.d_kind.biosdisk.unit = bd_bios2unit(biosdev)) == -1)) { printf("Can't work out which disk we are booting from.\n" "Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); - currdev.d_kind.biosdisk.unit = 0; + new_currdev.d_kind.biosdisk.unit = 0; } - env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&currdev), i386_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&currdev), env_noset, env_nounset); + env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev), + i386_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), env_noset, + env_nounset); } COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);