summaryrefslogtreecommitdiff
path: root/sys/boot/common
diff options
context:
space:
mode:
Diffstat (limited to 'sys/boot/common')
-rw-r--r--sys/boot/common/bcache.c31
-rw-r--r--sys/boot/common/boot.c19
-rw-r--r--sys/boot/common/bootstrap.h82
-rw-r--r--sys/boot/common/interp.c36
-rw-r--r--sys/boot/common/interp_backslash.c1
-rw-r--r--sys/boot/common/interp_forth.c2
-rw-r--r--sys/boot/common/interp_parse.c18
-rw-r--r--sys/boot/common/isapnp.c27
-rw-r--r--sys/boot/common/load_aout.c21
-rw-r--r--sys/boot/common/load_elf.c3
-rw-r--r--sys/boot/common/module.c2
-rw-r--r--sys/boot/common/pnp.c2
12 files changed, 105 insertions, 139 deletions
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 0e26ec654669..49e73065c2ce 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 loaded_module *km;
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 a4b22d9f9624..9d7c9fcf7580 100644
--- a/sys/boot/common/bootstrap.h
+++ b/sys/boot/common/bootstrap.h
@@ -29,10 +29,6 @@
#include <sys/types.h>
#include <sys/queue.h>
-/* 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
@@ -203,11 +204,9 @@ extern struct module_metadata *mod_findmetadata(struct loaded_module *mp, int ty
extern void mod_discard(struct loaded_module *mp);
extern struct loaded_module *mod_allocmodule(void);
-
/* MI module loaders */
extern int aout_loadmodule(char *filename, vm_offset_t dest, struct loaded_module **result);
extern vm_offset_t aout_findsym(char *name, struct loaded_module *mp);
-
extern int elf_loadmodule(char *filename, vm_offset_t dest, struct loaded_module **result);
#ifndef NEW_LINKER_SET
@@ -267,7 +266,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;
@@ -280,22 +279,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
@@ -49,38 +49,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
*/
void
@@ -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 <stand.h>
#include <string.h>
+#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 <stand.h>
#include <string.h>
+#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 48d5723fb746..aa2f249c1476 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 loaded_module *mp, struct exec *ehdr
static int aout_fixupkldmod(struct loaded_module *mp, 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 loaded_module *mp, int fd, vm_offset_t loadaddr, struct ex
{
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 loaded_module *mp, int fd, vm_offset_t loadaddr, struct ex
/* 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 loaded_module *mp, int fd, vm_offset_t loadaddr, struct ex
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 8fbcf19ac79f..538e1de6bd8a 100644
--- a/sys/boot/common/load_elf.c
+++ b/sys/boot/common/load_elf.c
@@ -208,6 +208,7 @@ elf_loadimage(struct loaded_module *mp, int fd, 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;
@@ -218,7 +219,7 @@ elf_loadimage(struct loaded_module *mp, int fd, vm_offset_t off,
int symstrindex;
int symtabindex;
long size;
- int fpcopy;
+ u_int fpcopy;
dp = NULL;
shdr = NULL;
diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c
index 70224278771e..0d3e5dc8a16b 100644
--- a/sys/boot/common/module.c
+++ b/sys/boot/common/module.c
@@ -47,7 +47,7 @@ static struct module_metadata *metadata_next(struct module_metadata *md, int ty
/* 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 loaded_module *loaded_modules = NULL;
diff --git a/sys/boot/common/pnp.c b/sys/boot/common/pnp.c
index 8761ad02fdb3..78422b4c47be 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