Cleanup warnings. Most of these are signed/unsigned warnings, as well as
some added const's.
This commit is contained in:
parent
c2fa9f3e89
commit
4ae4202e70
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64187
@ -57,11 +57,11 @@ struct bcachectl
|
|||||||
static struct bcachectl *bcache_ctl;
|
static struct bcachectl *bcache_ctl;
|
||||||
static caddr_t bcache_data;
|
static caddr_t bcache_data;
|
||||||
static bitstr_t *bcache_miss;
|
static bitstr_t *bcache_miss;
|
||||||
static int bcache_nblks;
|
static u_int bcache_nblks;
|
||||||
static int bcache_blksize;
|
static u_int bcache_blksize;
|
||||||
static int bcache_hits, bcache_misses, bcache_ops, bcache_bypasses;
|
static u_int bcache_hits, bcache_misses, bcache_ops, bcache_bypasses;
|
||||||
static int bcache_flushes;
|
static u_int bcache_flushes;
|
||||||
static int bcache_bcount;
|
static u_int bcache_bcount;
|
||||||
|
|
||||||
static void bcache_insert(caddr_t buf, daddr_t blkno);
|
static void bcache_insert(caddr_t buf, daddr_t blkno);
|
||||||
static int bcache_lookup(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).
|
* Initialise the cache for (nblks) of (bsize).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
bcache_init(int nblks, size_t bsize)
|
bcache_init(u_int nblks, size_t bsize)
|
||||||
{
|
{
|
||||||
/* discard any old contents */
|
/* discard any old contents */
|
||||||
if (bcache_data != NULL) {
|
if (bcache_data != NULL) {
|
||||||
@ -103,9 +103,9 @@ bcache_init(int nblks, size_t bsize)
|
|||||||
* Flush the cache
|
* Flush the cache
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
bcache_flush()
|
bcache_flush(void)
|
||||||
{
|
{
|
||||||
int i;
|
u_int i;
|
||||||
|
|
||||||
bcache_flushes++;
|
bcache_flushes++;
|
||||||
|
|
||||||
@ -125,14 +125,14 @@ bcache_flush()
|
|||||||
* directly to the disk. XXX tune this.
|
* directly to the disk. XXX tune this.
|
||||||
*/
|
*/
|
||||||
int
|
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;
|
static int bcache_unit = -1;
|
||||||
struct bcache_devdata *dd = (struct bcache_devdata *)devdata;
|
struct bcache_devdata *dd = (struct bcache_devdata *)devdata;
|
||||||
int nblk, p_size;
|
int p_size, result;
|
||||||
daddr_t p_blk;
|
daddr_t p_blk, i, j, nblk;
|
||||||
caddr_t p_buf;
|
caddr_t p_buf;
|
||||||
int i, j, result;
|
|
||||||
|
|
||||||
bcache_ops++;
|
bcache_ops++;
|
||||||
|
|
||||||
@ -211,7 +211,8 @@ static void
|
|||||||
bcache_insert(caddr_t buf, daddr_t blkno)
|
bcache_insert(caddr_t buf, daddr_t blkno)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
int i, cand, ocount;
|
int cand, ocount;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
cand = 0; /* assume the first block */
|
cand = 0; /* assume the first block */
|
||||||
@ -246,7 +247,7 @@ static int
|
|||||||
bcache_lookup(caddr_t buf, daddr_t blkno)
|
bcache_lookup(caddr_t buf, daddr_t blkno)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
int i;
|
u_int i;
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
@ -265,7 +266,7 @@ COMMAND_SET(bcachestat, "bcachestat", "get disk block cache stats", command_bcac
|
|||||||
static int
|
static int
|
||||||
command_bcache(int argc, char *argv[])
|
command_bcache(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
u_int i;
|
||||||
|
|
||||||
for (i = 0; i < bcache_nblks; 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);
|
printf("%08x %04x %04x|", bcache_ctl[i].bc_blkno, (unsigned int)bcache_ctl[i].bc_stamp & 0xffff, bcache_ctl[i].bc_count & 0xffff);
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
static char *getbootfile(int try);
|
static char *getbootfile(int try);
|
||||||
|
|
||||||
/* List of kernel names to try (may be overwritten by boot.config) XXX should move from here? */
|
/* 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;
|
static int autoboot_tried;
|
||||||
|
|
||||||
@ -53,7 +53,6 @@ command_boot(int argc, char *argv[])
|
|||||||
struct preloaded_file *fp;
|
struct preloaded_file *fp;
|
||||||
char *cp;
|
char *cp;
|
||||||
int try;
|
int try;
|
||||||
int i;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See if the user has specified an explicit kernel to boot.
|
* See if the user has specified an explicit kernel to boot.
|
||||||
@ -164,7 +163,7 @@ autoboot_maybe()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
autoboot(int delay, char *prompt)
|
autoboot(int timeout, char *prompt)
|
||||||
{
|
{
|
||||||
time_t when, otime, ntime;
|
time_t when, otime, ntime;
|
||||||
int c, yes;
|
int c, yes;
|
||||||
@ -172,19 +171,19 @@ autoboot(int delay, char *prompt)
|
|||||||
|
|
||||||
autoboot_tried = 1;
|
autoboot_tried = 1;
|
||||||
|
|
||||||
if (delay == -1) {
|
if (timeout == -1) {
|
||||||
/* try to get a delay from the environment */
|
/* try to get a delay from the environment */
|
||||||
if ((cp = getenv("autoboot_delay"))) {
|
if ((cp = getenv("autoboot_delay"))) {
|
||||||
delay = strtol(cp, &ep, 0);
|
timeout = strtol(cp, &ep, 0);
|
||||||
if (cp == ep)
|
if (cp == ep)
|
||||||
delay = -1;
|
timeout = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delay == -1) /* all else fails */
|
if (timeout == -1) /* all else fails */
|
||||||
delay = 10;
|
timeout = 10;
|
||||||
|
|
||||||
otime = time(NULL);
|
otime = time(NULL);
|
||||||
when = otime + delay; /* when to boot */
|
when = otime + timeout; /* when to boot */
|
||||||
yes = 0;
|
yes = 0;
|
||||||
|
|
||||||
/* XXX could try to work out what we might boot */
|
/* XXX could try to work out what we might boot */
|
||||||
@ -228,7 +227,7 @@ getbootfile(int try)
|
|||||||
{
|
{
|
||||||
static char *name = NULL;
|
static char *name = NULL;
|
||||||
char *spec, *ep;
|
char *spec, *ep;
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
/* we use dynamic storage */
|
/* we use dynamic storage */
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
|
@ -29,10 +29,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/queue.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
|
* Generic device specifier; architecture-dependant
|
||||||
* versions may be larger, but should be allowed to
|
* versions may be larger, but should be allowed to
|
||||||
@ -55,37 +51,42 @@ extern char command_errbuf[]; /* XXX blah, length */
|
|||||||
#define CMD_ERROR 1
|
#define CMD_ERROR 1
|
||||||
|
|
||||||
/* interp.c */
|
/* interp.c */
|
||||||
extern void interact(void);
|
void interact(void);
|
||||||
extern int include(char *filename);
|
int include(const char *filename);
|
||||||
|
|
||||||
|
/* interp_backslash.c */
|
||||||
|
char *backslash(char *str);
|
||||||
|
|
||||||
/* interp_parse.c */
|
/* interp_parse.c */
|
||||||
extern int parse(int *argc, char ***argv, char *str);
|
int parse(int *argc, char ***argv, char *str);
|
||||||
|
|
||||||
/* interp_forth.c */
|
/* interp_forth.c */
|
||||||
extern void bf_init(void);
|
void bf_init(void);
|
||||||
extern int bf_run(char *line);
|
int bf_run(char *line);
|
||||||
|
|
||||||
/* boot.c */
|
/* boot.c */
|
||||||
extern int autoboot(int delay, char *prompt);
|
int autoboot(int timeout, char *prompt);
|
||||||
extern void autoboot_maybe(void);
|
void autoboot_maybe(void);
|
||||||
extern int getrootmount(char *rootdev);
|
int getrootmount(char *rootdev);
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
extern char *unargv(int argc, char *argv[]);
|
char *unargv(int argc, char *argv[]);
|
||||||
extern void hexdump(caddr_t region, size_t len);
|
void hexdump(caddr_t region, size_t len);
|
||||||
extern size_t strlenout(vm_offset_t str);
|
size_t strlenout(vm_offset_t str);
|
||||||
extern char *strdupout(vm_offset_t str);
|
char *strdupout(vm_offset_t str);
|
||||||
|
|
||||||
/* bcache.c */
|
/* bcache.c */
|
||||||
extern int bcache_init(int nblks, size_t bsize);
|
int bcache_init(u_int nblks, size_t bsize);
|
||||||
extern void bcache_flush();
|
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
|
* Disk block cache
|
||||||
*/
|
*/
|
||||||
struct bcache_devdata
|
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;
|
void *dv_devdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,8 +95,8 @@ struct bcache_devdata
|
|||||||
*/
|
*/
|
||||||
struct console
|
struct console
|
||||||
{
|
{
|
||||||
char *c_name;
|
const char *c_name;
|
||||||
char *c_desc;
|
const char *c_desc;
|
||||||
int c_flags;
|
int c_flags;
|
||||||
#define C_PRESENTIN (1<<0)
|
#define C_PRESENTIN (1<<0)
|
||||||
#define C_PRESENTOUT (1<<1)
|
#define C_PRESENTOUT (1<<1)
|
||||||
@ -108,14 +109,14 @@ struct console
|
|||||||
int (* c_ready)(void); /* return nonzer if input waiting */
|
int (* c_ready)(void); /* return nonzer if input waiting */
|
||||||
};
|
};
|
||||||
extern struct console *consoles[];
|
extern struct console *consoles[];
|
||||||
extern void cons_probe(void);
|
void cons_probe(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Plug-and-play enumerator/configurator interface.
|
* Plug-and-play enumerator/configurator interface.
|
||||||
*/
|
*/
|
||||||
struct pnphandler
|
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 */
|
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 struct pnphandler *pnphandlers[]; /* provided by MD code */
|
||||||
|
|
||||||
extern void pnp_addident(struct pnpinfo *pi, char *ident);
|
void pnp_addident(struct pnpinfo *pi, char *ident);
|
||||||
extern struct pnpinfo *pnp_allocinfo(void);
|
struct pnpinfo *pnp_allocinfo(void);
|
||||||
extern void pnp_freeinfo(struct pnpinfo *pi);
|
void pnp_freeinfo(struct pnpinfo *pi);
|
||||||
extern void pnp_addinfo(struct pnpinfo *pi);
|
void pnp_addinfo(struct pnpinfo *pi);
|
||||||
extern char *pnp_eisaformat(u_int8_t *data);
|
char *pnp_eisaformat(u_int8_t *data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* < 0 - No ISA in system
|
* < 0 - No ISA in system
|
||||||
@ -163,7 +164,7 @@ struct file_metadata
|
|||||||
size_t md_size;
|
size_t md_size;
|
||||||
u_int16_t md_type;
|
u_int16_t md_type;
|
||||||
struct file_metadata *md_next;
|
struct file_metadata *md_next;
|
||||||
char md_data[0]; /* data are immediately appended */
|
char md_data[1]; /* data are immediately appended */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct preloaded_file;
|
struct preloaded_file;
|
||||||
@ -209,8 +210,8 @@ struct file_format
|
|||||||
extern struct file_format *file_formats[]; /* supplied by consumer */
|
extern struct file_format *file_formats[]; /* supplied by consumer */
|
||||||
extern struct preloaded_file *preloaded_files;
|
extern struct preloaded_file *preloaded_files;
|
||||||
|
|
||||||
extern int mod_load(char *name, int argc, char *argv[]);
|
int mod_load(char *name, int argc, char *argv[]);
|
||||||
extern int mod_loadobj(char *type, char *name);
|
int mod_loadobj(char *type, char *name);
|
||||||
|
|
||||||
struct preloaded_file *file_alloc(void);
|
struct preloaded_file *file_alloc(void);
|
||||||
struct preloaded_file *file_findfile(char *name, char *type);
|
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 */
|
/* MI module loaders */
|
||||||
extern int aout_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result);
|
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);
|
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
|
#ifndef NEW_LINKER_SET
|
||||||
#include <sys/linker_set.h>
|
#include <sys/linker_set.h>
|
||||||
@ -284,7 +285,7 @@ struct bootblk_command
|
|||||||
#define COMMAND_SET(tag, key, desc, func) \
|
#define COMMAND_SET(tag, key, desc, func) \
|
||||||
static bootblk_cmd_t func; \
|
static bootblk_cmd_t func; \
|
||||||
static struct bootblk_command _cmd_ ## tag = { key, desc, 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;
|
extern struct linker_set Xcommand_set;
|
||||||
|
|
||||||
@ -297,15 +298,18 @@ extern struct linker_set Xcommand_set;
|
|||||||
struct arch_switch
|
struct arch_switch
|
||||||
{
|
{
|
||||||
/* Automatically load modules as required by detected hardware */
|
/* 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) */
|
/* 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() */
|
/* 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() */
|
/* 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() */
|
/* 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) */
|
/* Perform ISA byte port I/O (only for systems with ISA) */
|
||||||
int (*arch_isainb)(int port);
|
int (*arch_isainb)(int port);
|
||||||
void (*arch_isaoutb)(int port, int value);
|
void (*arch_isaoutb)(int port, int value);
|
||||||
@ -313,6 +317,6 @@ struct arch_switch
|
|||||||
extern struct arch_switch archsw;
|
extern struct arch_switch archsw;
|
||||||
|
|
||||||
/* This must be provided by the MD code, but should it be in the 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);
|
||||||
|
@ -48,38 +48,6 @@ extern FICL_VM *bf_vm;
|
|||||||
|
|
||||||
static void prompt(void);
|
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
|
* Interactive mode
|
||||||
*/
|
*/
|
||||||
@ -157,7 +125,7 @@ command_include(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Since argv is static, we need to save it here.
|
* 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++)
|
for (i = 0; i < argc; i++)
|
||||||
argvbuf[i] = strdup(argv[i]);
|
argvbuf[i] = strdup(argv[i]);
|
||||||
|
|
||||||
@ -183,7 +151,7 @@ struct includeline
|
|||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
include(char *filename)
|
include(const char *filename)
|
||||||
{
|
{
|
||||||
struct includeline *script, *se, *sp;
|
struct includeline *script, *se, *sp;
|
||||||
char input[256]; /* big enough? */
|
char input[256]; /* big enough? */
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "bootstrap.h"
|
||||||
|
|
||||||
#define DIGIT(x) (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
|
#define DIGIT(x) (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ static void
|
|||||||
bf_command(FICL_VM *vm)
|
bf_command(FICL_VM *vm)
|
||||||
{
|
{
|
||||||
char *name, *line, *tail, *cp;
|
char *name, *line, *tail, *cp;
|
||||||
int len;
|
size_t len;
|
||||||
struct bootblk_command **cmdp;
|
struct bootblk_command **cmdp;
|
||||||
bootblk_cmd_t *cmd;
|
bootblk_cmd_t *cmd;
|
||||||
int nstrings, i;
|
int nstrings, i;
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
|
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "bootstrap.h"
|
||||||
/* Forward decls */
|
|
||||||
extern char *backslash(char *str);
|
|
||||||
|
|
||||||
static void clean(void);
|
static void clean(void);
|
||||||
static int insert(int *argcp, char *buf);
|
static int insert(int *argcp, char *buf);
|
||||||
@ -61,7 +59,7 @@ if (expr) { \
|
|||||||
|
|
||||||
/* Accept the usual delimiters for a variable, returning counterpart */
|
/* Accept the usual delimiters for a variable, returning counterpart */
|
||||||
static char
|
static char
|
||||||
isdelim(char ch)
|
isdelim(int ch)
|
||||||
{
|
{
|
||||||
if (ch == '{')
|
if (ch == '{')
|
||||||
return '}';
|
return '}';
|
||||||
@ -71,7 +69,7 @@ isdelim(char ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
isquote(char ch)
|
isquote(int ch)
|
||||||
{
|
{
|
||||||
return (ch == '\'' || ch == '"');
|
return (ch == '\'' || ch == '"');
|
||||||
}
|
}
|
||||||
@ -81,7 +79,7 @@ parse(int *argc, char ***argv, char *str)
|
|||||||
{
|
{
|
||||||
int ac;
|
int ac;
|
||||||
char *val, *p, *q, *copy = NULL;
|
char *val, *p, *q, *copy = NULL;
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
char token, tmp, quote, *buf;
|
char token, tmp, quote, *buf;
|
||||||
enum { STR, VAR, WHITE } state;
|
enum { STR, VAR, WHITE } state;
|
||||||
|
|
||||||
@ -147,7 +145,7 @@ parse(int *argc, char ***argv, char *str)
|
|||||||
tmp = *q;
|
tmp = *q;
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
if ((val = variable_lookup(p)) != NULL) {
|
if ((val = variable_lookup(p)) != NULL) {
|
||||||
int len = strlen(val);
|
size_t len = strlen(val);
|
||||||
|
|
||||||
strncpy(buf + i, val, PARSE_BUFSIZE - (i + 1));
|
strncpy(buf + i, val, PARSE_BUFSIZE - (i + 1));
|
||||||
i += min(len, PARSE_BUFSIZE - 1);
|
i += min(len, PARSE_BUFSIZE - 1);
|
||||||
|
@ -39,9 +39,8 @@
|
|||||||
#define inb(x) (archsw.arch_isainb((x)))
|
#define inb(x) (archsw.arch_isainb((x)))
|
||||||
#define outb(x,y) (archsw.arch_isaoutb((x),(y)))
|
#define outb(x,y) (archsw.arch_isaoutb((x),(y)))
|
||||||
|
|
||||||
static void isapnp_write(int d, u_char r);
|
static void isapnp_write(int d, int r);
|
||||||
static u_char isapnp_read(int d);
|
static void isapnp_send_Initiation_LFSR(void);
|
||||||
static void isapnp_send_Initiation_LFSR();
|
|
||||||
static int isapnp_get_serial(u_int8_t *p);
|
static int isapnp_get_serial(u_int8_t *p);
|
||||||
static int isapnp_isolation_protocol(void);
|
static int isapnp_isolation_protocol(void);
|
||||||
static void isapnp_enumerate(void);
|
static void isapnp_enumerate(void);
|
||||||
@ -58,25 +57,18 @@ struct pnphandler isapnphandler =
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
isapnp_write(int d, u_char r)
|
isapnp_write(int d, int r)
|
||||||
{
|
{
|
||||||
outb (_PNP_ADDRESS, d);
|
outb (_PNP_ADDRESS, d);
|
||||||
outb (_PNP_WRITE_DATA, r);
|
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",
|
* Send Initiation LFSR as described in "Plug and Play ISA Specification",
|
||||||
* Intel May 94.
|
* Intel May 94.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
isapnp_send_Initiation_LFSR()
|
isapnp_send_Initiation_LFSR(void)
|
||||||
{
|
{
|
||||||
int cur, i;
|
int cur, i;
|
||||||
|
|
||||||
@ -167,8 +159,9 @@ static int
|
|||||||
isapnp_scan_resdata(struct pnpinfo *pi)
|
isapnp_scan_resdata(struct pnpinfo *pi)
|
||||||
{
|
{
|
||||||
u_char tag, resinfo[8];
|
u_char tag, resinfo[8];
|
||||||
int large_len, limit;
|
u_int limit;
|
||||||
char *str;
|
size_t large_len;
|
||||||
|
u_char *str;
|
||||||
|
|
||||||
limit = 1000;
|
limit = 1000;
|
||||||
while ((limit-- > 0) && !isapnp_get_resource_info(&tag, 1)) {
|
while ((limit-- > 0) && !isapnp_get_resource_info(&tag, 1)) {
|
||||||
@ -204,13 +197,13 @@ isapnp_scan_resdata(struct pnpinfo *pi)
|
|||||||
|
|
||||||
case ID_STRING_ANSI:
|
case ID_STRING_ANSI:
|
||||||
str = malloc(large_len + 1);
|
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);
|
free(str);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
str[large_len] = 0;
|
str[large_len] = 0;
|
||||||
if (pi->pi_desc == NULL) {
|
if (pi->pi_desc == NULL) {
|
||||||
pi->pi_desc = str;
|
pi->pi_desc = (char *)str;
|
||||||
} else {
|
} else {
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
@ -218,7 +211,7 @@ isapnp_scan_resdata(struct pnpinfo *pi)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
/* Large resource, skip it */
|
/* Large resource, skip it */
|
||||||
if (isapnp_get_resource_info(NULL, large_len))
|
if (isapnp_get_resource_info(NULL, (ssize_t)large_len))
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
static int aout_fixupkldmod(struct preloaded_file *fp, struct exec *ehdr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *aout_kerneltype = "a.out kernel";
|
const char *aout_kerneltype = "a.out kernel";
|
||||||
char *aout_moduletype = "a.out module";
|
const char *aout_moduletype = "a.out module";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attempt to load the file (file) as an a.out module. It will be stored at
|
* 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;
|
u_int pad;
|
||||||
vm_offset_t addr;
|
vm_offset_t addr;
|
||||||
int ss;
|
size_t ss;
|
||||||
|
ssize_t result;
|
||||||
vm_offset_t ssym, esym;
|
vm_offset_t ssym, esym;
|
||||||
|
|
||||||
addr = loadaddr;
|
addr = loadaddr;
|
||||||
lseek(fd, N_TXTOFF(*ehdr), SEEK_SET);
|
lseek(fd, (off_t)N_TXTOFF(*ehdr), SEEK_SET);
|
||||||
|
|
||||||
/* text segment */
|
/* text segment */
|
||||||
printf(" text=0x%lx ", ehdr->a_text);
|
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);
|
return(0);
|
||||||
addr += ehdr->a_text;
|
addr += ehdr->a_text;
|
||||||
|
|
||||||
/* data segment */
|
/* data segment */
|
||||||
printf("data=0x%lx ", ehdr->a_data);
|
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);
|
return(0);
|
||||||
addr += ehdr->a_data;
|
addr += ehdr->a_data;
|
||||||
|
|
||||||
@ -228,7 +231,8 @@ aout_loadimage(struct preloaded_file *fp, int fd, vm_offset_t loadaddr, struct e
|
|||||||
|
|
||||||
/* symbol table */
|
/* symbol table */
|
||||||
printf("symbols=[0x%lx+0x%lx", (long)sizeof(ehdr->a_syms),ehdr->a_syms);
|
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);
|
return(0);
|
||||||
addr += ehdr->a_syms;
|
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);
|
addr += sizeof(ss);
|
||||||
ss -= sizeof(ss);
|
ss -= sizeof(ss);
|
||||||
printf("+0x%lx+0x%x]", (long)sizeof(ss), 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);
|
return(0);
|
||||||
addr += ss;
|
addr += ss;
|
||||||
esym = addr;
|
esym = addr;
|
||||||
|
@ -57,7 +57,7 @@ typedef struct elf_file {
|
|||||||
size_t strsz;
|
size_t strsz;
|
||||||
int fd;
|
int fd;
|
||||||
caddr_t firstpage;
|
caddr_t firstpage;
|
||||||
int firstlen;
|
size_t firstlen;
|
||||||
int kernel;
|
int kernel;
|
||||||
vm_offset_t off;
|
vm_offset_t off;
|
||||||
} *elf_file_t;
|
} *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_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_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 int elf_parse_modmetadata(struct preloaded_file *mp, elf_file_t ef);
|
||||||
|
static char *fake_modname(const char *name);
|
||||||
|
|
||||||
char *elf_kerneltype = "elf kernel";
|
const char *elf_kerneltype = "elf kernel";
|
||||||
char *elf_moduletype = "elf module";
|
const char *elf_moduletype = "elf module";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attempt to load the file (file) as an ELF module. It will be stored at
|
* 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;
|
int err;
|
||||||
u_int pad;
|
u_int pad;
|
||||||
char *s;
|
char *s;
|
||||||
|
ssize_t bytes_read;
|
||||||
|
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
bzero(&ef, sizeof(struct elf_file));
|
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);
|
close(ef.fd);
|
||||||
return(ENOMEM);
|
return(ENOMEM);
|
||||||
}
|
}
|
||||||
ef.firstlen = read(ef.fd, ef.firstpage, PAGE_SIZE);
|
bytes_read = read(ef.fd, ef.firstpage, PAGE_SIZE);
|
||||||
if (ef.firstlen <= sizeof(Elf_Ehdr)) {
|
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 */
|
err = EFTYPE; /* could be EIO, but may be small file */
|
||||||
goto oerr;
|
goto oerr;
|
||||||
}
|
}
|
||||||
@ -224,7 +227,8 @@ elf_loadfile(char *filename, vm_offset_t dest, struct preloaded_file **result)
|
|||||||
static int
|
static int
|
||||||
elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off)
|
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_Ehdr *ehdr;
|
||||||
Elf_Phdr *phdr, *php;
|
Elf_Phdr *phdr, *php;
|
||||||
Elf_Shdr *shdr;
|
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;
|
vm_offset_t lastaddr;
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t resid, chunk;
|
size_t resid, chunk;
|
||||||
|
ssize_t result;
|
||||||
vm_offset_t dest;
|
vm_offset_t dest;
|
||||||
vm_offset_t ssym, esym;
|
vm_offset_t ssym, esym;
|
||||||
Elf_Dyn *dp;
|
Elf_Dyn *dp;
|
||||||
@ -241,7 +246,7 @@ elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off)
|
|||||||
int symstrindex;
|
int symstrindex;
|
||||||
int symtabindex;
|
int symtabindex;
|
||||||
long size;
|
long size;
|
||||||
int fpcopy;
|
u_int fpcopy;
|
||||||
|
|
||||||
dp = NULL;
|
dp = NULL;
|
||||||
shdr = 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);
|
phdr[i].p_vaddr + off, fpcopy);
|
||||||
}
|
}
|
||||||
if (phdr[i].p_filesz > 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");
|
printf("\nelf_loadexec: cannot seek\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (archsw.arch_readin(ef->fd, phdr[i].p_vaddr + off + fpcopy,
|
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");
|
printf("\nelf_loadexec: archsw.readin failed\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -348,11 +354,12 @@ elf_loadimage(struct preloaded_file *fp, elf_file_t ef, vm_offset_t off)
|
|||||||
shdr = malloc(chunk);
|
shdr = malloc(chunk);
|
||||||
if (shdr == NULL)
|
if (shdr == NULL)
|
||||||
goto nosyms;
|
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");
|
printf("\nelf_loadimage: cannot lseek() to section headers");
|
||||||
goto nosyms;
|
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");
|
printf("\nelf_loadimage: read section headers failed");
|
||||||
goto nosyms;
|
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);
|
printf("0x%lx+0x%lx", (long)sizeof(size), size);
|
||||||
#endif
|
#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!");
|
printf("\nelf_loadimage: could not seek for symbols - skipped!");
|
||||||
lastaddr = ssym;
|
lastaddr = ssym;
|
||||||
ssym = 0;
|
ssym = 0;
|
||||||
goto nosyms;
|
goto nosyms;
|
||||||
}
|
}
|
||||||
if (archsw.arch_readin(ef->fd, lastaddr, shdr[i].sh_size) !=
|
result = archsw.arch_readin(ef->fd, lastaddr, shdr[i].sh_size);
|
||||||
shdr[i].sh_size) {
|
if (result < 0 || (size_t)result != shdr[i].sh_size) {
|
||||||
printf("\nelf_loadimage: could not read symbols - skipped!");
|
printf("\nelf_loadimage: could not read symbols - skipped!");
|
||||||
lastaddr = ssym;
|
lastaddr = ssym;
|
||||||
ssym = 0;
|
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";
|
static char invalid_name[] = "bad";
|
||||||
char *
|
char *
|
||||||
fake_modname(char *name) {
|
fake_modname(const char *name) {
|
||||||
char *sp, *ep;
|
char *sp, *ep;
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
sp = strrchr(name, '/');
|
sp = strrchr(name, '/');
|
||||||
if (sp)
|
if (sp)
|
||||||
@ -561,8 +568,7 @@ int
|
|||||||
elf_parse_modmetadata(struct preloaded_file *fp, elf_file_t ef) {
|
elf_parse_modmetadata(struct preloaded_file *fp, elf_file_t ef) {
|
||||||
struct mod_metadata md;
|
struct mod_metadata md;
|
||||||
Elf_Sym sym;
|
Elf_Sym sym;
|
||||||
void **p, *v;
|
char *s, *v, **p;
|
||||||
char *s;
|
|
||||||
long entries;
|
long entries;
|
||||||
int modcnt;
|
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));
|
COPYOUT(sym.st_value + ef->off, &entries, sizeof(entries));
|
||||||
|
|
||||||
modcnt = 0;
|
modcnt = 0;
|
||||||
p = (void*)(sym.st_value + ef->off + sizeof(entries));
|
p = (char **)(sym.st_value + ef->off + sizeof(entries));
|
||||||
while (entries--) {
|
while (entries--) {
|
||||||
COPYOUT(p++, &v, sizeof(v));
|
COPYOUT(p++, &v, sizeof(v));
|
||||||
COPYOUT(v + ef->off, &md, sizeof(md));
|
COPYOUT(v + ef->off, &md, sizeof(md));
|
||||||
|
@ -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) */
|
/* load address should be tweaked by first module loaded (kernel) */
|
||||||
static vm_offset_t loadaddr = 0;
|
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;
|
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;
|
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_size = size;
|
||||||
md->md_type = type;
|
md->md_type = type;
|
||||||
bcopy(p, md->md_data, size);
|
bcopy(p, md->md_data, size);
|
||||||
|
@ -19,8 +19,6 @@ STAILQ_HEAD(,pnpinfo) pnp_devices;
|
|||||||
static int pnp_devices_initted = 0;
|
static int pnp_devices_initted = 0;
|
||||||
|
|
||||||
static void pnp_discard(void);
|
static void pnp_discard(void);
|
||||||
static int pnp_readconf(char *path);
|
|
||||||
static int pnp_scankernel(void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform complete enumeration sweep
|
* Perform complete enumeration sweep
|
||||||
|
@ -8,24 +8,33 @@ BINMODE= 444
|
|||||||
|
|
||||||
M4?= m4
|
M4?= m4
|
||||||
|
|
||||||
# update, packet mode, and all slices enabled by default
|
# The default set of flags compiled into boot0. This enables update (writing
|
||||||
B0FLAGS=0x8f
|
# the modified boot0 back to disk after running so that the selection made is
|
||||||
B0TICKS=0xb6
|
# 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
|
boot0: boot0.o
|
||||||
.if ${OBJFORMAT} == aout
|
.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
|
dd if=boot0.out of=${.TARGET} ibs=32 skip=1
|
||||||
.else
|
.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}
|
objcopy -S -O binary boot0.out ${.TARGET}
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
boot0.o: boot0.s
|
boot0.o: boot0.s
|
||||||
${AS} ${AFLAGS} --defsym FLAGS=${B0FLAGS} --defsym TICKS=${B0TICKS} \
|
${AS} ${AFLAGS} --defsym FLAGS=${BOOT_BOOT0_FLAGS} \
|
||||||
${.IMPSRC} -o ${.TARGET}
|
--defsym TICKS=${BOOT_BOOT0_TICKS} ${.IMPSRC} -o ${.TARGET}
|
||||||
|
|
||||||
CLEANFILES+= boot0.out boot0.o
|
CLEANFILES+= boot0.out boot0.o
|
||||||
|
|
||||||
|
@ -22,8 +22,10 @@ CFLAGS+= -DCOMSPEED=${BOOT_COMCONSOLE_SPEED}
|
|||||||
# the location of libstand
|
# the location of libstand
|
||||||
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
|
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
|
||||||
|
|
||||||
|
.ifdef(BOOT_BIOSDISK_DEBUG)
|
||||||
# Make the disk code more talkative
|
# Make the disk code more talkative
|
||||||
#CFLAGS+= -DDISK_DEBUG
|
CFLAGS+= -DDISK_DEBUG
|
||||||
|
.endif
|
||||||
|
|
||||||
# Include simple terminal emulation (cons25-compatible)
|
# Include simple terminal emulation (cons25-compatible)
|
||||||
CFLAGS+= -DTERM_EMU
|
CFLAGS+= -DTERM_EMU
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <sys/imgact_aout.h>
|
#include <sys/imgact_aout.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
#include <sys/linker.h>
|
#include <sys/linker.h>
|
||||||
#include <string.h>
|
|
||||||
#include <machine/bootinfo.h>
|
#include <machine/bootinfo.h>
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
* Obtain memory configuration information from the BIOS
|
* Obtain memory configuration information from the BIOS
|
||||||
*/
|
*/
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
|
#include "libi386.h"
|
||||||
#include "btxv86.h"
|
#include "btxv86.h"
|
||||||
|
|
||||||
vm_offset_t memtop;
|
vm_offset_t memtop;
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
#include <string.h>
|
|
||||||
#include <machine/stdarg.h>
|
#include <machine/stdarg.h>
|
||||||
#include <bootstrap.h>
|
#include <bootstrap.h>
|
||||||
#include <isapnp.h>
|
#include <isapnp.h>
|
||||||
@ -48,7 +47,7 @@
|
|||||||
struct pci_progif
|
struct pci_progif
|
||||||
{
|
{
|
||||||
int pi_code;
|
int pi_code;
|
||||||
char *pi_name;
|
const char *pi_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct pci_progif progif_null[] = {
|
static struct pci_progif progif_null[] = {
|
||||||
@ -116,7 +115,7 @@ static struct pci_progif progif_parallel[] = {
|
|||||||
struct pci_subclass
|
struct pci_subclass
|
||||||
{
|
{
|
||||||
int ps_subclass;
|
int ps_subclass;
|
||||||
char *ps_name;
|
const char *ps_name;
|
||||||
struct pci_progif *ps_progif; /* if set, use for programming interface value(s) */
|
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
|
static struct pci_class
|
||||||
{
|
{
|
||||||
int pc_class;
|
int pc_class;
|
||||||
char *pc_name;
|
const char *pc_name;
|
||||||
struct pci_subclass *pc_subclass;
|
struct pci_subclass *pc_subclass;
|
||||||
} pci_classes[] = {
|
} pci_classes[] = {
|
||||||
{0x0, "device", subclass_old},
|
{0x0, "device", subclass_old},
|
||||||
@ -199,7 +198,7 @@ struct pnphandler biospcihandler =
|
|||||||
static void
|
static void
|
||||||
biospci_enumerate(void)
|
biospci_enumerate(void)
|
||||||
{
|
{
|
||||||
int index, locator, devid;
|
int device_index, locator, devid;
|
||||||
struct pci_class *pc;
|
struct pci_class *pc;
|
||||||
struct pci_subclass *psc;
|
struct pci_subclass *psc;
|
||||||
struct pci_progif *ppi;
|
struct pci_progif *ppi;
|
||||||
@ -230,14 +229,14 @@ biospci_enumerate(void)
|
|||||||
for (ppi = psc->ps_progif; ppi->pi_code >= 0; ppi++) {
|
for (ppi = psc->ps_progif; ppi->pi_code >= 0; ppi++) {
|
||||||
|
|
||||||
/* Scan for matches */
|
/* Scan for matches */
|
||||||
for (index = 0; ; index++) {
|
for (device_index = 0; ; device_index++) {
|
||||||
|
|
||||||
/* Look for a match */
|
/* Look for a match */
|
||||||
v86.ctl = V86_FLAGS;
|
v86.ctl = V86_FLAGS;
|
||||||
v86.addr = 0x1a;
|
v86.addr = 0x1a;
|
||||||
v86.eax = 0xb103;
|
v86.eax = 0xb103;
|
||||||
v86.ecx = (pc->pc_class << 16) + (psc->ps_subclass << 8) + ppi->pi_code;
|
v86.ecx = (pc->pc_class << 16) + (psc->ps_subclass << 8) + ppi->pi_code;
|
||||||
v86.esi = index;
|
v86.esi = device_index;
|
||||||
v86int();
|
v86int();
|
||||||
/* error/end of matches */
|
/* error/end of matches */
|
||||||
if ((v86.efl & 1) || (v86.eax & 0xff00))
|
if ((v86.efl & 1) || (v86.eax & 0xff00))
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
#include <string.h>
|
|
||||||
#include <machine/stdarg.h>
|
#include <machine/stdarg.h>
|
||||||
#include <bootstrap.h>
|
#include <bootstrap.h>
|
||||||
#include <isapnp.h>
|
#include <isapnp.h>
|
||||||
@ -71,7 +70,7 @@ struct pnp_devNode
|
|||||||
u_int8_t dn_id[4] __attribute__ ((packed));
|
u_int8_t dn_id[4] __attribute__ ((packed));
|
||||||
u_int8_t dn_type[3] __attribute__ ((packed));
|
u_int8_t dn_type[3] __attribute__ ((packed));
|
||||||
u_int16_t dn_attrib __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
|
struct pnp_isaConfiguration
|
||||||
@ -87,10 +86,12 @@ static u_int16_t pnp_NumNodes;
|
|||||||
static u_int16_t pnp_NodeSize;
|
static u_int16_t pnp_NodeSize;
|
||||||
|
|
||||||
static void biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn);
|
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))
|
#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_f00(NumNodes, NodeSize) biospnp_call(0x00, "ll", NumNodes, NodeSize)
|
||||||
#define biospnp_f01(Node, devNodeBuffer, Control) biospnp_call(0x01, "llw", Node, devNodeBuffer, Control)
|
#define biospnp_f01(Node, devNodeBuffer, Control) biospnp_call(0x01, "llw", Node, devNodeBuffer, Control)
|
||||||
@ -186,7 +187,7 @@ biospnp_enumerate(void)
|
|||||||
static void
|
static void
|
||||||
biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn)
|
biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn)
|
||||||
{
|
{
|
||||||
int tag, i, rlen, dlen;
|
u_int tag, i, rlen, dlen;
|
||||||
u_int8_t *p;
|
u_int8_t *p;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
@ -243,10 +244,10 @@ biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn)
|
|||||||
* this evil.
|
* this evil.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
biospnp_call(int func, char *fmt, ...)
|
biospnp_call(int func, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *p;
|
const char *p;
|
||||||
u_int8_t *argp;
|
u_int8_t *argp;
|
||||||
u_int32_t args[4];
|
u_int32_t args[4];
|
||||||
u_int32_t i;
|
u_int32_t i;
|
||||||
|
@ -43,7 +43,7 @@ static struct bootinfo bi;
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *ev;
|
const char *ev;
|
||||||
int mask;
|
int mask;
|
||||||
} howto_names[] = {
|
} howto_names[] = {
|
||||||
{"boot_askname", RB_ASKNAME},
|
{"boot_askname", RB_ASKNAME},
|
||||||
@ -56,6 +56,8 @@ static struct
|
|||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm_offset_t bi_copymodules(vm_offset_t addr);
|
||||||
|
|
||||||
int
|
int
|
||||||
bi_getboothowto(char *kargs)
|
bi_getboothowto(char *kargs)
|
||||||
{
|
{
|
||||||
@ -227,7 +229,7 @@ bi_copymodules(vm_offset_t addr)
|
|||||||
* Load the information expected by an i386 kernel.
|
* Load the information expected by an i386 kernel.
|
||||||
*
|
*
|
||||||
* - The 'boothowto' argument is constructed
|
* - 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 'bootinfo' struct is constructed, and copied into the kernel space.
|
||||||
* - The kernel environment is copied into kernel space.
|
* - The kernel environment is copied into kernel space.
|
||||||
* - Module metadata are formatted and placed in 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 preloaded_file *xp;
|
||||||
struct i386_devdesc *rootdev;
|
struct i386_devdesc *rootdev;
|
||||||
vm_offset_t addr, bootinfo_addr;
|
vm_offset_t addr;
|
||||||
char *rootdevname;
|
char *rootdevname;
|
||||||
int bootdevnr, i;
|
int bootdevnr, i;
|
||||||
u_int pad;
|
u_int pad;
|
||||||
@ -262,6 +264,10 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
|
|||||||
getrootmount(i386_fmtdev((void *)rootdev));
|
getrootmount(i386_fmtdev((void *)rootdev));
|
||||||
|
|
||||||
/* Do legacy rootdev guessing */
|
/* Do legacy rootdev guessing */
|
||||||
|
|
||||||
|
/* XXX - use a default bootdev of 0. Is this ok??? */
|
||||||
|
bootdevnr = 0;
|
||||||
|
|
||||||
switch(rootdev->d_type) {
|
switch(rootdev->d_type) {
|
||||||
case DEVT_DISK:
|
case DEVT_DISK:
|
||||||
/* pass in the BIOS device number of the current disk */
|
/* pass in the BIOS device number of the current disk */
|
||||||
|
@ -43,7 +43,7 @@ static struct bootinfo bi;
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *ev;
|
const char *ev;
|
||||||
int mask;
|
int mask;
|
||||||
} howto_names[] = {
|
} howto_names[] = {
|
||||||
{"boot_askname", RB_ASKNAME},
|
{"boot_askname", RB_ASKNAME},
|
||||||
@ -56,6 +56,8 @@ static struct
|
|||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm_offset_t bi_copymodules(vm_offset_t addr);
|
||||||
|
|
||||||
int
|
int
|
||||||
bi_getboothowto(char *kargs)
|
bi_getboothowto(char *kargs)
|
||||||
{
|
{
|
||||||
@ -227,7 +229,7 @@ bi_copymodules(vm_offset_t addr)
|
|||||||
* Load the information expected by an i386 kernel.
|
* Load the information expected by an i386 kernel.
|
||||||
*
|
*
|
||||||
* - The 'boothowto' argument is constructed
|
* - 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 'bootinfo' struct is constructed, and copied into the kernel space.
|
||||||
* - The kernel environment is copied into kernel space.
|
* - The kernel environment is copied into kernel space.
|
||||||
* - Module metadata are formatted and placed in 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 preloaded_file *xp;
|
||||||
struct i386_devdesc *rootdev;
|
struct i386_devdesc *rootdev;
|
||||||
vm_offset_t addr, bootinfo_addr;
|
vm_offset_t addr;
|
||||||
char *rootdevname;
|
char *rootdevname;
|
||||||
int bootdevnr, i;
|
int bootdevnr, i;
|
||||||
u_int pad;
|
u_int pad;
|
||||||
@ -262,6 +264,10 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
|
|||||||
getrootmount(i386_fmtdev((void *)rootdev));
|
getrootmount(i386_fmtdev((void *)rootdev));
|
||||||
|
|
||||||
/* Do legacy rootdev guessing */
|
/* Do legacy rootdev guessing */
|
||||||
|
|
||||||
|
/* XXX - use a default bootdev of 0. Is this ok??? */
|
||||||
|
bootdevnr = 0;
|
||||||
|
|
||||||
switch(rootdev->d_type) {
|
switch(rootdev->d_type) {
|
||||||
case DEVT_DISK:
|
case DEVT_DISK:
|
||||||
/* pass in the BIOS device number of the current disk */
|
/* pass in the BIOS device number of the current disk */
|
||||||
|
@ -43,7 +43,7 @@ static struct bootinfo bi;
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *ev;
|
const char *ev;
|
||||||
int mask;
|
int mask;
|
||||||
} howto_names[] = {
|
} howto_names[] = {
|
||||||
{"boot_askname", RB_ASKNAME},
|
{"boot_askname", RB_ASKNAME},
|
||||||
@ -56,6 +56,8 @@ static struct
|
|||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm_offset_t bi_copymodules(vm_offset_t addr);
|
||||||
|
|
||||||
int
|
int
|
||||||
bi_getboothowto(char *kargs)
|
bi_getboothowto(char *kargs)
|
||||||
{
|
{
|
||||||
@ -227,7 +229,7 @@ bi_copymodules(vm_offset_t addr)
|
|||||||
* Load the information expected by an i386 kernel.
|
* Load the information expected by an i386 kernel.
|
||||||
*
|
*
|
||||||
* - The 'boothowto' argument is constructed
|
* - 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 'bootinfo' struct is constructed, and copied into the kernel space.
|
||||||
* - The kernel environment is copied into kernel space.
|
* - The kernel environment is copied into kernel space.
|
||||||
* - Module metadata are formatted and placed in 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 preloaded_file *xp;
|
||||||
struct i386_devdesc *rootdev;
|
struct i386_devdesc *rootdev;
|
||||||
vm_offset_t addr, bootinfo_addr;
|
vm_offset_t addr;
|
||||||
char *rootdevname;
|
char *rootdevname;
|
||||||
int bootdevnr, i;
|
int bootdevnr, i;
|
||||||
u_int pad;
|
u_int pad;
|
||||||
@ -262,6 +264,10 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
|
|||||||
getrootmount(i386_fmtdev((void *)rootdev));
|
getrootmount(i386_fmtdev((void *)rootdev));
|
||||||
|
|
||||||
/* Do legacy rootdev guessing */
|
/* Do legacy rootdev guessing */
|
||||||
|
|
||||||
|
/* XXX - use a default bootdev of 0. Is this ok??? */
|
||||||
|
bootdevnr = 0;
|
||||||
|
|
||||||
switch(rootdev->d_type) {
|
switch(rootdev->d_type) {
|
||||||
case DEVT_DISK:
|
case DEVT_DISK:
|
||||||
/* pass in the BIOS device number of the current disk */
|
/* pass in the BIOS device number of the current disk */
|
||||||
|
@ -114,7 +114,7 @@ comc_putchar(int c)
|
|||||||
|
|
||||||
for (wait = COMC_TXWAIT; wait > 0; wait--)
|
for (wait = COMC_TXWAIT; wait > 0; wait--)
|
||||||
if (inb(COMPORT + com_lsr) & LSR_TXRDY) {
|
if (inb(COMPORT + com_lsr) & LSR_TXRDY) {
|
||||||
outb(COMPORT + com_data, c);
|
outb(COMPORT + com_data, (u_char)c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,6 @@ static int elf_exec(struct preloaded_file *amp);
|
|||||||
|
|
||||||
struct file_format i386_elf = { elf_loadfile, elf_exec };
|
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.
|
* 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
|
* We wish to start executing the kernel image, so make such
|
||||||
|
@ -43,8 +43,6 @@ static int elf_exec(struct preloaded_file *amp);
|
|||||||
|
|
||||||
struct file_format i386_elf = { elf_loadfile, elf_exec };
|
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.
|
* 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
|
* We wish to start executing the kernel image, so make such
|
||||||
|
@ -43,8 +43,6 @@ static int elf_exec(struct preloaded_file *amp);
|
|||||||
|
|
||||||
struct file_format i386_elf = { elf_loadfile, elf_exec };
|
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.
|
* 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
|
* We wish to start executing the kernel image, so make such
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
/* extracted from freebsd:sys/i386/boot/biosboot/io.c */
|
/* extracted from freebsd:sys/i386/boot/biosboot/io.c */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <stand.h>
|
||||||
#include <machine/cpufunc.h>
|
#include <machine/cpufunc.h>
|
||||||
|
|
||||||
#include <stand.h>
|
#include <bootstrap.h>
|
||||||
|
|
||||||
#include "libi386.h"
|
#include "libi386.h"
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ void gateA20()
|
|||||||
__asm("pushfl ; cli");
|
__asm("pushfl ; cli");
|
||||||
#ifdef IBM_L40
|
#ifdef IBM_L40
|
||||||
outb(0x92, 0x2);
|
outb(0x92, 0x2);
|
||||||
#else IBM_L40
|
#else /* !IBM_L40 */
|
||||||
while (inb(K_STATUS) & K_IBUF_FUL);
|
while (inb(K_STATUS) & K_IBUF_FUL);
|
||||||
while (inb(K_STATUS) & K_OBUF_FUL)
|
while (inb(K_STATUS) & K_OBUF_FUL)
|
||||||
(void)inb(K_RDWR);
|
(void)inb(K_RDWR);
|
||||||
@ -47,6 +47,6 @@ void gateA20()
|
|||||||
outb(K_RDWR, x_20);
|
outb(K_RDWR, x_20);
|
||||||
delay(100);
|
delay(100);
|
||||||
while (inb(K_STATUS) & K_IBUF_FUL);
|
while (inb(K_STATUS) & K_IBUF_FUL);
|
||||||
#endif IBM_L40
|
#endif /* IBM_L40 */
|
||||||
__asm("popfl");
|
__asm("popfl");
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@
|
|||||||
|
|
||||||
#define READIN_BUF (16 * 1024)
|
#define READIN_BUF (16 * 1024)
|
||||||
|
|
||||||
int
|
ssize_t
|
||||||
i386_copyin(void *src, vm_offset_t dest, size_t len)
|
i386_copyin(const void *src, vm_offset_t dest, const size_t len)
|
||||||
{
|
{
|
||||||
if (dest + len >= memtop) {
|
if (dest + len >= memtop) {
|
||||||
errno = EFBIG;
|
errno = EFBIG;
|
||||||
@ -50,8 +50,8 @@ i386_copyin(void *src, vm_offset_t dest, size_t len)
|
|||||||
return(len);
|
return(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ssize_t
|
||||||
i386_copyout(vm_offset_t src, void *dest, size_t len)
|
i386_copyout(const vm_offset_t src, void *dest, const size_t len)
|
||||||
{
|
{
|
||||||
if (src + len >= memtop) {
|
if (src + len >= memtop) {
|
||||||
errno = EFBIG;
|
errno = EFBIG;
|
||||||
@ -63,8 +63,8 @@ i386_copyout(vm_offset_t src, void *dest, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
ssize_t
|
||||||
i386_readin(int fd, vm_offset_t dest, size_t len)
|
i386_readin(const int fd, vm_offset_t dest, const size_t len)
|
||||||
{
|
{
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t resid, chunk, get;
|
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);
|
got = read(fd, buf, get);
|
||||||
if (got <= 0)
|
if (got <= 0)
|
||||||
break;
|
break;
|
||||||
bcopy(buf, PTOV(dest), got);
|
bcopy(buf, PTOV(dest), (size_t)got);
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
return(len - resid);
|
return(len - resid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ struct i386_devdesc
|
|||||||
} d_kind;
|
} d_kind;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int i386_getdev(void **vdev, const char *devspec, const char **path);
|
int i386_getdev(void **vdev, const char *devspec, const char **path);
|
||||||
extern char *i386_fmtdev(void *vdev);
|
char *i386_fmtdev(void *vdev);
|
||||||
extern int i386_setcurrdev(struct env_var *ev, int flags, void *value);
|
int i386_setcurrdev(struct env_var *ev, int flags, void *value);
|
||||||
|
|
||||||
extern struct devdesc currdev; /* our current device */
|
extern struct devdesc currdev; /* our current device */
|
||||||
|
|
||||||
@ -66,25 +66,25 @@ extern struct devsw pxedisk;
|
|||||||
extern struct fs_ops pxe_fsops;
|
extern struct fs_ops pxe_fsops;
|
||||||
|
|
||||||
u_int32_t bd_getbigeom(int bunit); /* return geometry in bootinfo format */
|
u_int32_t bd_getbigeom(int bunit); /* return geometry in bootinfo format */
|
||||||
extern int bd_bios2unit(int biosdev); /* xlate BIOS device -> biosdisk unit */
|
int bd_bios2unit(int biosdev); /* xlate BIOS device -> biosdisk unit */
|
||||||
extern int bd_unit2bios(int unit); /* xlate biosdisk unit -> BIOS device */
|
int bd_unit2bios(int unit); /* xlate biosdisk unit -> BIOS device */
|
||||||
extern int bd_getdev(struct i386_devdesc *dev); /* return dev_t for (dev) */
|
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);
|
ssize_t i386_copyin(const void *src, vm_offset_t dest, const size_t len);
|
||||||
extern 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);
|
||||||
extern 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);
|
||||||
|
|
||||||
extern void bios_getmem(void);
|
void bios_getmem(void);
|
||||||
extern u_int32_t bios_basemem; /* base memory in bytes */
|
extern u_int32_t bios_basemem; /* base memory in bytes */
|
||||||
extern u_int32_t bios_extmem; /* extended memory in bytes */
|
extern u_int32_t bios_extmem; /* extended memory in bytes */
|
||||||
extern vm_offset_t memtop;
|
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);
|
int bi_getboothowto(char *kargs);
|
||||||
extern vm_offset_t bi_copyenv(vm_offset_t addr);
|
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_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip);
|
||||||
|
|
||||||
extern void pxe_enable(void *pxeinfo);
|
void pxe_enable(void *pxeinfo);
|
||||||
|
@ -59,7 +59,7 @@ static pxenv_t *pxenv_p = NULL; /* PXENV+ */
|
|||||||
static pxe_t *pxe_p = NULL; /* !PXE */
|
static pxe_t *pxe_p = NULL; /* !PXE */
|
||||||
static BOOTPLAYER bootplayer; /* PXE Cached information. */
|
static BOOTPLAYER bootplayer; /* PXE Cached information. */
|
||||||
|
|
||||||
static int debug = 0;
|
static int pxe_debug = 0;
|
||||||
static int pxe_sock = -1;
|
static int pxe_sock = -1;
|
||||||
static int pxe_opens = 0;
|
static int pxe_opens = 0;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ static void bangpxe_call(int func);
|
|||||||
|
|
||||||
static int pxe_init(void);
|
static int pxe_init(void);
|
||||||
static int pxe_strategy(void *devdata, int flag, daddr_t dblk,
|
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_open(struct open_file *f, ...);
|
||||||
static int pxe_close(struct open_file *f);
|
static int pxe_close(struct open_file *f);
|
||||||
static void pxe_print(int verbose);
|
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);
|
static void pxe_netif_end(struct netif *nif);
|
||||||
|
|
||||||
extern struct netif_stats pxe_st[];
|
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 __bangpxeseg;
|
||||||
extern u_int16_t __bangpxeoff;
|
extern u_int16_t __bangpxeoff;
|
||||||
extern void __bangpxeentry(void);
|
extern void __bangpxeentry(void);
|
||||||
@ -241,7 +239,7 @@ pxe_init(void)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
pxe_strategy(void *devdata, int flag, daddr_t dblk, size_t size,
|
pxe_strategy(void *devdata, int flag, daddr_t dblk, size_t size,
|
||||||
void *buf, size_t *rsize)
|
char *buf, size_t *rsize)
|
||||||
{
|
{
|
||||||
return (EIO);
|
return (EIO);
|
||||||
}
|
}
|
||||||
@ -268,7 +266,7 @@ pxe_open(struct open_file *f, ...)
|
|||||||
printf("pxe_open: netif_open() failed\n");
|
printf("pxe_open: netif_open() failed\n");
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
if (debug)
|
if (pxe_debug)
|
||||||
printf("pxe_open: netif_open() succeeded\n");
|
printf("pxe_open: netif_open() succeeded\n");
|
||||||
}
|
}
|
||||||
if (rootip.s_addr == 0) {
|
if (rootip.s_addr == 0) {
|
||||||
@ -307,7 +305,7 @@ pxe_close(struct open_file *f)
|
|||||||
{
|
{
|
||||||
|
|
||||||
#ifdef PXE_DEBUG
|
#ifdef PXE_DEBUG
|
||||||
if (debug)
|
if (pxe_debug)
|
||||||
printf("pxe_close: opens=%d\n", pxe_opens);
|
printf("pxe_close: opens=%d\n", pxe_opens);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -323,7 +321,7 @@ pxe_close(struct open_file *f)
|
|||||||
|
|
||||||
if (pxe_sock >= 0) {
|
if (pxe_sock >= 0) {
|
||||||
#ifdef PXE_DEBUG
|
#ifdef PXE_DEBUG
|
||||||
if (debug)
|
if (pxe_debug)
|
||||||
printf("pxe_close: calling netif_close()\n");
|
printf("pxe_close: calling netif_close()\n");
|
||||||
#endif
|
#endif
|
||||||
netif_close(pxe_sock);
|
netif_close(pxe_sock);
|
||||||
@ -352,10 +350,12 @@ pxe_print(int verbose)
|
|||||||
static void
|
static void
|
||||||
pxe_cleanup(void)
|
pxe_cleanup(void)
|
||||||
{
|
{
|
||||||
|
#ifdef PXE_DEBUG
|
||||||
t_PXENV_UNLOAD_STACK *unload_stack_p =
|
t_PXENV_UNLOAD_STACK *unload_stack_p =
|
||||||
(t_PXENV_UNLOAD_STACK *)scratch_buffer;
|
(t_PXENV_UNLOAD_STACK *)scratch_buffer;
|
||||||
t_PXENV_UNDI_SHUTDOWN *undi_shutdown_p =
|
t_PXENV_UNDI_SHUTDOWN *undi_shutdown_p =
|
||||||
(t_PXENV_UNDI_SHUTDOWN *)scratch_buffer;
|
(t_PXENV_UNDI_SHUTDOWN *)scratch_buffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pxe_call == NULL)
|
if (pxe_call == NULL)
|
||||||
return;
|
return;
|
||||||
@ -363,7 +363,7 @@ pxe_cleanup(void)
|
|||||||
pxe_call(PXENV_UNDI_SHUTDOWN);
|
pxe_call(PXENV_UNDI_SHUTDOWN);
|
||||||
|
|
||||||
#ifdef PXE_DEBUG
|
#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",
|
printf("pxe_cleanup: UNDI_SHUTDOWN failed %x\n",
|
||||||
undi_shutdown_p->Status);
|
undi_shutdown_p->Status);
|
||||||
#endif
|
#endif
|
||||||
@ -371,7 +371,7 @@ pxe_cleanup(void)
|
|||||||
pxe_call(PXENV_UNLOAD_STACK);
|
pxe_call(PXENV_UNLOAD_STACK);
|
||||||
|
|
||||||
#ifdef PXE_DEBUG
|
#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",
|
printf("pxe_cleanup: UNLOAD_STACK failed %x\n",
|
||||||
unload_stack_p->Status);
|
unload_stack_p->Status);
|
||||||
#endif
|
#endif
|
||||||
@ -387,7 +387,7 @@ void
|
|||||||
pxenv_call(int func)
|
pxenv_call(int func)
|
||||||
{
|
{
|
||||||
#ifdef PXE_DEBUG
|
#ifdef PXE_DEBUG
|
||||||
if (debug)
|
if (pxe_debug)
|
||||||
printf("pxenv_call %x\n", func);
|
printf("pxenv_call %x\n", func);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ void
|
|||||||
bangpxe_call(int func)
|
bangpxe_call(int func)
|
||||||
{
|
{
|
||||||
#ifdef PXE_DEBUG
|
#ifdef PXE_DEBUG
|
||||||
if (debug)
|
if (pxe_debug)
|
||||||
printf("bangpxe_call %x\n", func);
|
printf("bangpxe_call %x\n", func);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
#include <btxv86.h>
|
#include <btxv86.h>
|
||||||
|
#include "bootstrap.h"
|
||||||
|
#include "libi386.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the time in seconds since the beginning of the day.
|
* Return the time in seconds since the beginning of the day.
|
||||||
@ -41,7 +43,7 @@ time_t
|
|||||||
time(time_t *t)
|
time(time_t *t)
|
||||||
{
|
{
|
||||||
static time_t lasttime, now;
|
static time_t lasttime, now;
|
||||||
int hr, min, sec;
|
int hr, minute, sec;
|
||||||
|
|
||||||
v86.ctl = 0;
|
v86.ctl = 0;
|
||||||
v86.addr = 0x1a; /* int 0x1a, function 2 */
|
v86.addr = 0x1a; /* int 0x1a, function 2 */
|
||||||
@ -49,10 +51,10 @@ time(time_t *t)
|
|||||||
v86int();
|
v86int();
|
||||||
|
|
||||||
hr = bcd2bin((v86.ecx & 0xff00) >> 8); /* hour in %ch */
|
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 */
|
sec = bcd2bin((v86.edx & 0xff00) >> 8); /* second in %dh */
|
||||||
|
|
||||||
now = hr * 3600 + min * 60 + sec;
|
now = hr * 3600 + minute * 60 + sec;
|
||||||
if (now < lasttime)
|
if (now < lasttime)
|
||||||
now += 24 * 3600;
|
now += 24 * 3600;
|
||||||
lasttime = now;
|
lasttime = now;
|
||||||
|
@ -49,13 +49,14 @@ static int vidc_ischar(void);
|
|||||||
static int vidc_started;
|
static int vidc_started;
|
||||||
|
|
||||||
#ifdef TERM_EMU
|
#ifdef TERM_EMU
|
||||||
void end_term();
|
void end_term(void);
|
||||||
void bail_out(int c);
|
void bail_out(int c);
|
||||||
void vidc_term_emu(int c);
|
void vidc_term_emu(int c);
|
||||||
void get_pos(void);
|
void get_pos(void);
|
||||||
void curs_move(int x, int y);
|
void curs_move(int x, int y);
|
||||||
void write_char(int c, int fg, int bg);
|
void write_char(int c, int fg, int bg);
|
||||||
void scroll_up(int rows, int fg, int bg);
|
void scroll_up(int rows, int fg, int bg);
|
||||||
|
int pow10(int i);
|
||||||
void AB(void);
|
void AB(void);
|
||||||
void AF(void);
|
void AF(void);
|
||||||
void CD(void);
|
void CD(void);
|
||||||
@ -104,7 +105,7 @@ vidc_init(int arg)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (vidc_started && arg == 0)
|
if (vidc_started && arg == 0)
|
||||||
return;
|
return(0);
|
||||||
vidc_started = 1;
|
vidc_started = 1;
|
||||||
#ifdef TERM_EMU
|
#ifdef TERM_EMU
|
||||||
/* Init terminal emulator */
|
/* Init terminal emulator */
|
||||||
@ -234,13 +235,13 @@ curs_move(int x, int y)
|
|||||||
* inserted in the window.
|
* inserted in the window.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
scroll_up(int rows, int fg, int bg)
|
scroll_up(int rows, int fgcol, int bgcol)
|
||||||
{
|
{
|
||||||
if(rows==0) rows=25;
|
if(rows==0) rows=25;
|
||||||
v86.ctl = 0;
|
v86.ctl = 0;
|
||||||
v86.addr = 0x10;
|
v86.addr = 0x10;
|
||||||
v86.eax = 0x0600+(0x00ff & rows);
|
v86.eax = 0x0600+(0x00ff & rows);
|
||||||
v86.ebx = (bg<<12)+(fg<<8);
|
v86.ebx = (bgcol<<12)+(fgcol<<8);
|
||||||
v86.ecx = 0x0;
|
v86.ecx = 0x0;
|
||||||
v86.edx = 0x184f;
|
v86.edx = 0x184f;
|
||||||
v86int();
|
v86int();
|
||||||
@ -248,12 +249,12 @@ scroll_up(int rows, int fg, int bg)
|
|||||||
|
|
||||||
/* Write character and attribute at cursor position. */
|
/* Write character and attribute at cursor position. */
|
||||||
void
|
void
|
||||||
write_char(int c, int fg, int bg)
|
write_char(int c, int fgcol, int bgcol)
|
||||||
{
|
{
|
||||||
v86.ctl=0;
|
v86.ctl=0;
|
||||||
v86.addr = 0x10;
|
v86.addr = 0x10;
|
||||||
v86.eax = 0x0900+(0x00ff & c);
|
v86.eax = 0x0900+(0x00ff & c);
|
||||||
v86.ebx = (bg<<4)+fg;
|
v86.ebx = (bgcol<<4)+fgcol;
|
||||||
v86.ecx = 0x1;
|
v86.ecx = 0x1;
|
||||||
v86int();
|
v86int();
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ struct arch_switch archsw; /* MI/MD interface boundary */
|
|||||||
static void extract_currdev(void);
|
static void extract_currdev(void);
|
||||||
static int isa_inb(int port);
|
static int isa_inb(int port);
|
||||||
static void isa_outb(int port, int value);
|
static void isa_outb(int port, int value);
|
||||||
|
void exit(int code);
|
||||||
|
|
||||||
/* from vers.c */
|
/* from vers.c */
|
||||||
extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
|
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 */
|
/* XXX debugging */
|
||||||
extern char end[];
|
extern char end[];
|
||||||
|
|
||||||
void
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -138,6 +139,9 @@ main(void)
|
|||||||
archsw.arch_isaoutb = isa_outb;
|
archsw.arch_isaoutb = isa_outb;
|
||||||
|
|
||||||
interact(); /* doesn't return */
|
interact(); /* doesn't return */
|
||||||
|
|
||||||
|
/* if we ever get here, it is an error */
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -149,40 +153,41 @@ main(void)
|
|||||||
static void
|
static void
|
||||||
extract_currdev(void)
|
extract_currdev(void)
|
||||||
{
|
{
|
||||||
struct i386_devdesc currdev;
|
struct i386_devdesc new_currdev;
|
||||||
int major, biosdev;
|
int major, biosdev;
|
||||||
|
|
||||||
/* Assume we are booting from a BIOS disk by default */
|
/* Assume we are booting from a BIOS disk by default */
|
||||||
currdev.d_dev = &biosdisk;
|
new_currdev.d_dev = &biosdisk;
|
||||||
currdev.d_type = currdev.d_dev->dv_type;
|
new_currdev.d_type = new_currdev.d_dev->dv_type;
|
||||||
|
|
||||||
/* new-style boot loaders such as pxeldr and cdldr */
|
/* new-style boot loaders such as pxeldr and cdldr */
|
||||||
if (kargs->bootinfo == NULL) {
|
if (kargs->bootinfo == NULL) {
|
||||||
if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) {
|
if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) {
|
||||||
/* we are booting from a CD with cdldr */
|
/* we are booting from a CD with cdldr */
|
||||||
currdev.d_kind.biosdisk.slice = -1;
|
new_currdev.d_kind.biosdisk.slice = -1;
|
||||||
currdev.d_kind.biosdisk.partition = 0;
|
new_currdev.d_kind.biosdisk.partition = 0;
|
||||||
biosdev = initial_bootdev;
|
biosdev = initial_bootdev;
|
||||||
} else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) {
|
} else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) {
|
||||||
/* we are booting from pxeldr */
|
/* we are booting from pxeldr */
|
||||||
currdev.d_dev = &pxedisk;
|
new_currdev.d_dev = &pxedisk;
|
||||||
currdev.d_type = currdev.d_dev->dv_type;
|
new_currdev.d_type = new_currdev.d_dev->dv_type;
|
||||||
currdev.d_kind.netif.unit = 0;
|
new_currdev.d_kind.netif.unit = 0;
|
||||||
|
biosdev = -1;
|
||||||
} else {
|
} else {
|
||||||
/* we don't know what our boot device is */
|
/* we don't know what our boot device is */
|
||||||
currdev.d_kind.biosdisk.slice = -1;
|
new_currdev.d_kind.biosdisk.slice = -1;
|
||||||
currdev.d_kind.biosdisk.partition = 0;
|
new_currdev.d_kind.biosdisk.partition = 0;
|
||||||
biosdev = -1;
|
biosdev = -1;
|
||||||
}
|
}
|
||||||
} else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) {
|
} else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) {
|
||||||
/* The passed-in boot device is bad */
|
/* The passed-in boot device is bad */
|
||||||
currdev.d_kind.biosdisk.slice = -1;
|
new_currdev.d_kind.biosdisk.slice = -1;
|
||||||
currdev.d_kind.biosdisk.partition = 0;
|
new_currdev.d_kind.biosdisk.partition = 0;
|
||||||
biosdev = -1;
|
biosdev = -1;
|
||||||
} else {
|
} else {
|
||||||
currdev.d_kind.biosdisk.slice = (B_ADAPTOR(initial_bootdev) << 4) +
|
new_currdev.d_kind.biosdisk.slice = (B_ADAPTOR(initial_bootdev) << 4) +
|
||||||
B_CONTROLLER(initial_bootdev) - 1;
|
B_CONTROLLER(initial_bootdev) - 1;
|
||||||
currdev.d_kind.biosdisk.partition = B_PARTITION(initial_bootdev);
|
new_currdev.d_kind.biosdisk.partition = B_PARTITION(initial_bootdev);
|
||||||
biosdev = initial_bootinfo->bi_bios_dev;
|
biosdev = initial_bootinfo->bi_bios_dev;
|
||||||
major = B_TYPE(initial_bootdev);
|
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
|
* 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.
|
* which one we booted off of, just use disk0: as a reasonable default.
|
||||||
*/
|
*/
|
||||||
if ((currdev.d_type == devsw[0]->dv_type) &&
|
if ((new_currdev.d_type == devsw[0]->dv_type) &&
|
||||||
((currdev.d_kind.biosdisk.unit = bd_bios2unit(biosdev)) == -1)) {
|
((new_currdev.d_kind.biosdisk.unit = bd_bios2unit(biosdev)) == -1)) {
|
||||||
printf("Can't work out which disk we are booting from.\n"
|
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);
|
"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("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev),
|
||||||
env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&currdev), env_noset, env_nounset);
|
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);
|
COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
|
||||||
|
Loading…
Reference in New Issue
Block a user