From f0b5ddae6f18f4e9b5ad66d339e2f6b10f5003fa Mon Sep 17 00:00:00 2001 From: msmith Date: Thu, 17 Sep 1998 23:52:16 +0000 Subject: Initial integration of the i386 bootloader and BTX. - Discard large amounts of BIOS-related code in favour of the more compact BTX vm86 interface. - Build the loader module as ELF, although the resulting object is a.out, make gensetdefs 32/64-bit sensitive and use a single copy of it. - Throw away installboot, as it's no longer required. - Use direct bcopy operations in the i386_copy module, as BTX maps the first 16M of memory. Check operations against the detected size of actual memory. --- sys/boot/alpha/common/gensetdefs.c | 313 ------------ sys/boot/common/gensetdefs.c | 321 ++++++++++++ sys/boot/common/interp_parse.c | 3 +- sys/boot/common/load_aout.c | 3 +- sys/boot/common/panic.c | 4 +- sys/boot/i386/Makefile | 2 +- sys/boot/i386/btx/Makefile | 4 +- sys/boot/i386/btx/btx/Makefile | 4 +- sys/boot/i386/btx/btxldr/Makefile | 5 +- sys/boot/i386/btx/lib/btxv86.h | 16 +- sys/boot/i386/installboot/Makefile | 16 - sys/boot/i386/installboot/bootblks.c | 146 ------ sys/boot/i386/installboot/getmount.c | 156 ------ sys/boot/i386/installboot/installboot.8 | 150 ------ sys/boot/i386/installboot/installboot.c | 433 ----------------- sys/boot/i386/installboot/installboot.h | 9 - sys/boot/i386/libi386/Makefile | 11 +- sys/boot/i386/libi386/aout_freebsd.c | 7 +- sys/boot/i386/libi386/biosdelay.S | 79 --- sys/boot/i386/libi386/biosdisk.c | 132 +++-- sys/boot/i386/libi386/biosdisk_support.S | 114 ----- sys/boot/i386/libi386/biosgetrtc.S | 77 --- sys/boot/i386/libi386/biosmem.S | 99 ---- sys/boot/i386/libi386/biosmem.c | 52 ++ sys/boot/i386/libi386/biosreboot.S | 66 --- sys/boot/i386/libi386/bootinfo.c | 36 +- sys/boot/i386/libi386/bootinfo32.c | 36 +- sys/boot/i386/libi386/bootinfo64.c | 36 +- sys/boot/i386/libi386/comconsole.c | 63 ++- sys/boot/i386/libi386/comconsole_support.S | 147 ------ sys/boot/i386/libi386/crt/Makefile | 3 - sys/boot/i386/libi386/crt/bios_disk.S | 176 ------- sys/boot/i386/libi386/crt/biosdisk_ll.c | 148 ------ sys/boot/i386/libi386/crt/biosdisk_ll.h | 54 --- sys/boot/i386/libi386/crt/bootsect/Makefile | 25 - sys/boot/i386/libi386/crt/bootsect/bbinfo.h | 64 --- sys/boot/i386/libi386/crt/bootsect/bootsectmain.c | 88 ---- sys/boot/i386/libi386/crt/bootsect/fraglist.S | 49 -- .../i386/libi386/crt/bootsect/start_bootsect.S | 540 --------------------- sys/boot/i386/libi386/crt/buffers.S | 27 -- sys/boot/i386/libi386/crt/diskbuf.h | 42 -- sys/boot/i386/libi386/getsecs.c | 40 -- sys/boot/i386/libi386/i386_copy.c | 16 +- sys/boot/i386/libi386/libi386.h | 19 +- sys/boot/i386/libi386/startprog.S | 120 ----- sys/boot/i386/libi386/time.c | 56 +++ sys/boot/i386/libi386/vidconsole.c | 65 ++- sys/boot/i386/libi386/vidconsole_support.S | 103 ---- sys/boot/i386/loader/Makefile | 56 ++- sys/boot/i386/loader/conf.c | 6 +- sys/boot/i386/loader/main.c | 33 +- sys/boot/i386/loader/setdef0.c | 49 ++ sys/boot/i386/loader/setdef1.c | 41 ++ sys/boot/i386/loader/version | 3 +- 54 files changed, 899 insertions(+), 3464 deletions(-) delete mode 100644 sys/boot/alpha/common/gensetdefs.c create mode 100644 sys/boot/common/gensetdefs.c delete mode 100644 sys/boot/i386/installboot/Makefile delete mode 100644 sys/boot/i386/installboot/bootblks.c delete mode 100644 sys/boot/i386/installboot/getmount.c delete mode 100644 sys/boot/i386/installboot/installboot.8 delete mode 100644 sys/boot/i386/installboot/installboot.c delete mode 100644 sys/boot/i386/installboot/installboot.h delete mode 100644 sys/boot/i386/libi386/biosdelay.S delete mode 100644 sys/boot/i386/libi386/biosdisk_support.S delete mode 100644 sys/boot/i386/libi386/biosgetrtc.S delete mode 100644 sys/boot/i386/libi386/biosmem.S create mode 100644 sys/boot/i386/libi386/biosmem.c delete mode 100644 sys/boot/i386/libi386/biosreboot.S delete mode 100644 sys/boot/i386/libi386/comconsole_support.S delete mode 100644 sys/boot/i386/libi386/crt/Makefile delete mode 100644 sys/boot/i386/libi386/crt/bios_disk.S delete mode 100644 sys/boot/i386/libi386/crt/biosdisk_ll.c delete mode 100644 sys/boot/i386/libi386/crt/biosdisk_ll.h delete mode 100644 sys/boot/i386/libi386/crt/bootsect/Makefile delete mode 100644 sys/boot/i386/libi386/crt/bootsect/bbinfo.h delete mode 100644 sys/boot/i386/libi386/crt/bootsect/bootsectmain.c delete mode 100644 sys/boot/i386/libi386/crt/bootsect/fraglist.S delete mode 100644 sys/boot/i386/libi386/crt/bootsect/start_bootsect.S delete mode 100644 sys/boot/i386/libi386/crt/buffers.S delete mode 100644 sys/boot/i386/libi386/crt/diskbuf.h delete mode 100644 sys/boot/i386/libi386/getsecs.c delete mode 100644 sys/boot/i386/libi386/startprog.S create mode 100644 sys/boot/i386/libi386/time.c delete mode 100644 sys/boot/i386/libi386/vidconsole_support.S create mode 100644 sys/boot/i386/loader/setdef0.c create mode 100644 sys/boot/i386/loader/setdef1.c diff --git a/sys/boot/alpha/common/gensetdefs.c b/sys/boot/alpha/common/gensetdefs.c deleted file mode 100644 index b72f78b..0000000 --- a/sys/boot/alpha/common/gensetdefs.c +++ /dev/null @@ -1,313 +0,0 @@ -/*- - * Copyright (c) 1997 John D. Polstra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: gensetdefs.c,v 1.2 1998/06/14 13:44:44 dfr Exp $ - */ - -#include -#include - -#include -#include -#include -#include -#include - -#define HASHSIZE 1009u /* Number of hash chains. */ -#define PREFIX ".set." /* Section name prefix for linker sets. */ - -/* One entry in the hash table. */ -typedef struct hashent { - struct hashent *next; /* Next entry with the same hash. */ - char *name; /* Name of the linker set. */ - size_t size; /* Size in bytes. */ -} hashent; - -/* Allocate storage for "count" objects of type "type". */ -#define NEW(type, count) ((type *) xmalloc((count) * sizeof(type))) - -static hashent *hashtab[HASHSIZE]; /* Hash chain heads. */ - -static void enter(const char *, size_t); -static int enter_sets(const char *); -static unsigned int hash(const char *); -static hashent *merge(void); -static int my_byte_order(void); -static void *xmalloc(size_t); -static char *xstrdup(const char *); - -/* - * This is a special-purpose program to generate the linker set definitions - * needed when building an ELF kernel. Its arguments are the names of - * ELF object files. It scans the section names of the object files, - * building a table of those that begin with ".set.", which represent - * linker sets. Finally, for each set "foo" with "count" elements, it - * writes a line "DEFINE_SET(foo, count);" to the standard output. - */ -int -main(int argc, char **argv) -{ - int i; - int status = EXIT_SUCCESS; - hashent *list; - - for (i = 1; i < argc; i++) - if (enter_sets(argv[i]) == -1) - status = EXIT_FAILURE; - - list = merge(); - while (list != NULL) { - hashent *next; - - printf("DEFINE_SET(%s, %lu);\n", list->name, - (unsigned long) (list->size / sizeof (void *))); - next = list->next; - free(list->name); - free(list); - list = next; - } - - return (status); -} - -/* - * Enter the given string into the hash table, if it is not already there. - * Each hash chain is kept sorted, so that it will be easy to merge the - * chains to get a single sorted list. - */ -static void -enter(const char *name, size_t size) -{ - int c = 0; - hashent *entp; - hashent **linkp; - hashent *newp; - - linkp = &hashtab[hash(name) % HASHSIZE]; - while ((entp = *linkp) != NULL && (c = strcmp(name, entp->name)) > 0) - linkp = &entp->next; - - if (entp == NULL || c != 0) { /* Not found; create a new entry. */ - newp = NEW(hashent, 1); - newp->name = xstrdup(name); - newp->size = 0; - newp->next = entp; - *linkp = newp; - entp = newp; - } - - entp->size += size; -} - -/* - * Return a hash value for the given string. - */ -static unsigned int -hash(const char *s) -{ - unsigned char ch; - unsigned int h = 0; - - while((ch = *s) != '\0') { - h = 9*h + ch; - s++; - } - return (h); -} - -/* - * Enter the linker sets from the given ELF object file. Returns 0 on - * success, or -1 if an error occurred. - */ -static int -enter_sets(const char *filename) -{ - int i; - FILE *iop; - Elf64_Shdr *shdr; - char *shstr; - Elf64_Ehdr ehdr; - - if ((iop = fopen(filename, "rb")) == NULL) { - warn("%s", filename); - return (-1); - } - if (fread(&ehdr, sizeof ehdr, 1, iop) != 1 || - ehdr.e_ident[EI_MAG0] != ELFMAG0 || - ehdr.e_ident[EI_MAG1] != ELFMAG1 || - ehdr.e_ident[EI_MAG2] != ELFMAG2 || - ehdr.e_ident[EI_MAG3] != ELFMAG3) { - warnx("%s: not an ELF file", filename); - fclose(iop); - return (-1); - } - if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) { - warnx("%s: unsupported ELF version", filename); - fclose(iop); - return (-1); - } - if (ehdr.e_ident[EI_DATA] != my_byte_order()) { - warnx("%s: unsupported byte order", filename); - fclose(iop); - return (-1); - } - if (ehdr.e_shoff == 0) { - warnx("%s: no section table", filename); - fclose(iop); - return (-1); - } - if (ehdr.e_shstrndx == SHN_UNDEF) { - warnx("%s: no section name string table", filename); - fclose(iop); - return (-1); - } - - shdr = NEW(Elf64_Shdr, ehdr.e_shnum); - if (fseek(iop, ehdr.e_shoff, SEEK_SET) == -1) { - warn("%s", filename); - free(shdr); - fclose(iop); - return (-1); - } - if (fread(shdr, sizeof *shdr, ehdr.e_shnum, iop) != ehdr.e_shnum) { - warnx("%s: truncated section table", filename); - free(shdr); - fclose(iop); - return (-1); - } - - shstr = NEW(char, shdr[ehdr.e_shstrndx].sh_size); - if (fseek(iop, shdr[ehdr.e_shstrndx].sh_offset, SEEK_SET) == -1) { - warn("%s", filename); - free(shstr); - free(shdr); - fclose(iop); - return (-1); - } - if (fread(shstr, sizeof *shstr, shdr[ehdr.e_shstrndx].sh_size, iop) != - shdr[ehdr.e_shstrndx].sh_size) { - warnx("%s: truncated section name string table", filename); - free(shstr); - free(shdr); - fclose(iop); - return (-1); - } - - for (i = 1; i < ehdr.e_shnum; i++) { - const char *name = shstr + shdr[i].sh_name; - - if (strncmp(name, PREFIX, sizeof (PREFIX) - 1) == 0) - enter(name + sizeof (PREFIX) - 1, shdr[i].sh_size); - } - - free(shstr); - free(shdr); - fclose(iop); - return (0); -} - -/* - * Destructively merge all the sorted hash chains into a single sorted - * list, and return a pointer to its first element. - */ -static hashent * -merge(void) -{ - unsigned int numchains = HASHSIZE; - - while (numchains > 1) { /* More merging to do. */ - unsigned int lo = 0; - /* - * Merge chains pairwise from the outside in, halving the - * number of chains. - */ - while (numchains - lo >= 2) { - hashent **linkp = &hashtab[lo]; - hashent *l1 = hashtab[lo++]; - hashent *l2 = hashtab[--numchains]; - - while (l1 != NULL && l2 != NULL) { - if (strcmp(l1->name, l2->name) < 0) { - *linkp = l1; - linkp = &l1->next; - l1 = l1->next; - } else { - *linkp = l2; - linkp = &l2->next; - l2 = l2->next; - } - } - *linkp = l1==NULL ? l2 : l1; - } - } - - return (hashtab[0]); -} - -/* - * Determine the host byte order. - */ -static int -my_byte_order(void) -{ - static unsigned short s = 0xbbaa; - int byte0; - - byte0 = *(unsigned char *)&s; - if (byte0 == 0xaa) - return (ELFDATA2LSB); - else if (byte0 == 0xbb) - return (ELFDATA2MSB); - else - return (ELFDATANONE); -} - -/* - * Allocate a chunk of memory and return a pointer to it. Die if the - * malloc fails. - */ -static void * -xmalloc(size_t size) -{ - void *p; - - p = malloc(size); - if (p == NULL) - err(EXIT_FAILURE, "malloc"); - return (p); -} - -/* - * Duplicate a string and return a pointer to the copy. Die if there is - * not enough memory. - */ -static char * -xstrdup(const char *s) -{ - int size; - - size = strlen(s) + 1; - return (memcpy(xmalloc(size), s, size)); -} diff --git a/sys/boot/common/gensetdefs.c b/sys/boot/common/gensetdefs.c new file mode 100644 index 0000000..9927e8a --- /dev/null +++ b/sys/boot/common/gensetdefs.c @@ -0,0 +1,321 @@ +/*- + * Copyright (c) 1997 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: gensetdefs.c,v 1.1.1.1 1998/08/21 03:17:42 msmith Exp $ + */ + +#include +#include + +#include +#include +#include +#include +#include + +#define HASHSIZE 1009u /* Number of hash chains. */ +#define PREFIX ".set." /* Section name prefix for linker sets. */ + +#if __ELF_WORD_SIZE == 64 +# define Elf_Shdr Elf64_Shdr +# define Elf_Ehdr Elf64_Ehdr +#else +# define Elf_Shdr Elf32_Shdr +# define Elf_Ehdr Elf32_Ehdr +#endif + +/* One entry in the hash table. */ +typedef struct hashent { + struct hashent *next; /* Next entry with the same hash. */ + char *name; /* Name of the linker set. */ + size_t size; /* Size in bytes. */ +} hashent; + +/* Allocate storage for "count" objects of type "type". */ +#define NEW(type, count) ((type *) xmalloc((count) * sizeof(type))) + +static hashent *hashtab[HASHSIZE]; /* Hash chain heads. */ + +static void enter(const char *, size_t); +static int enter_sets(const char *); +static unsigned int hash(const char *); +static hashent *merge(void); +static int my_byte_order(void); +static void *xmalloc(size_t); +static char *xstrdup(const char *); + +/* + * This is a special-purpose program to generate the linker set definitions + * needed when building an ELF kernel. Its arguments are the names of + * ELF object files. It scans the section names of the object files, + * building a table of those that begin with ".set.", which represent + * linker sets. Finally, for each set "foo" with "count" elements, it + * writes a line "DEFINE_SET(foo, count);" to the standard output. + */ +int +main(int argc, char **argv) +{ + int i; + int status = EXIT_SUCCESS; + hashent *list; + + for (i = 1; i < argc; i++) + if (enter_sets(argv[i]) == -1) + status = EXIT_FAILURE; + + list = merge(); + while (list != NULL) { + hashent *next; + + printf("DEFINE_SET(%s, %lu);\n", list->name, + (unsigned long) (list->size / sizeof (void *))); + next = list->next; + free(list->name); + free(list); + list = next; + } + + return (status); +} + +/* + * Enter the given string into the hash table, if it is not already there. + * Each hash chain is kept sorted, so that it will be easy to merge the + * chains to get a single sorted list. + */ +static void +enter(const char *name, size_t size) +{ + int c = 0; + hashent *entp; + hashent **linkp; + hashent *newp; + + linkp = &hashtab[hash(name) % HASHSIZE]; + while ((entp = *linkp) != NULL && (c = strcmp(name, entp->name)) > 0) + linkp = &entp->next; + + if (entp == NULL || c != 0) { /* Not found; create a new entry. */ + newp = NEW(hashent, 1); + newp->name = xstrdup(name); + newp->size = 0; + newp->next = entp; + *linkp = newp; + entp = newp; + } + + entp->size += size; +} + +/* + * Return a hash value for the given string. + */ +static unsigned int +hash(const char *s) +{ + unsigned char ch; + unsigned int h = 0; + + while((ch = *s) != '\0') { + h = 9*h + ch; + s++; + } + return (h); +} + +/* + * Enter the linker sets from the given ELF object file. Returns 0 on + * success, or -1 if an error occurred. + */ +static int +enter_sets(const char *filename) +{ + int i; + FILE *iop; + Elf_Shdr *shdr; + char *shstr; + Elf_Ehdr ehdr; + + if ((iop = fopen(filename, "rb")) == NULL) { + warn("%s", filename); + return (-1); + } + if (fread(&ehdr, sizeof ehdr, 1, iop) != 1 || + ehdr.e_ident[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 || + ehdr.e_ident[EI_MAG3] != ELFMAG3) { + warnx("%s: not an ELF file", filename); + fclose(iop); + return (-1); + } + if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) { + warnx("%s: unsupported ELF version", filename); + fclose(iop); + return (-1); + } + if (ehdr.e_ident[EI_DATA] != my_byte_order()) { + warnx("%s: unsupported byte order", filename); + fclose(iop); + return (-1); + } + if (ehdr.e_shoff == 0) { + warnx("%s: no section table", filename); + fclose(iop); + return (-1); + } + if (ehdr.e_shstrndx == SHN_UNDEF) { + warnx("%s: no section name string table", filename); + fclose(iop); + return (-1); + } + + shdr = NEW(Elf_Shdr, ehdr.e_shnum); + if (fseek(iop, ehdr.e_shoff, SEEK_SET) == -1) { + warn("%s", filename); + free(shdr); + fclose(iop); + return (-1); + } + if (fread(shdr, sizeof *shdr, ehdr.e_shnum, iop) != ehdr.e_shnum) { + warnx("%s: truncated section table", filename); + free(shdr); + fclose(iop); + return (-1); + } + + shstr = NEW(char, shdr[ehdr.e_shstrndx].sh_size); + if (fseek(iop, shdr[ehdr.e_shstrndx].sh_offset, SEEK_SET) == -1) { + warn("%s", filename); + free(shstr); + free(shdr); + fclose(iop); + return (-1); + } + if (fread(shstr, sizeof *shstr, shdr[ehdr.e_shstrndx].sh_size, iop) != + shdr[ehdr.e_shstrndx].sh_size) { + warnx("%s: truncated section name string table", filename); + free(shstr); + free(shdr); + fclose(iop); + return (-1); + } + + for (i = 1; i < ehdr.e_shnum; i++) { + const char *name = shstr + shdr[i].sh_name; + + if (strncmp(name, PREFIX, sizeof (PREFIX) - 1) == 0) + enter(name + sizeof (PREFIX) - 1, shdr[i].sh_size); + } + + free(shstr); + free(shdr); + fclose(iop); + return (0); +} + +/* + * Destructively merge all the sorted hash chains into a single sorted + * list, and return a pointer to its first element. + */ +static hashent * +merge(void) +{ + unsigned int numchains = HASHSIZE; + + while (numchains > 1) { /* More merging to do. */ + unsigned int lo = 0; + /* + * Merge chains pairwise from the outside in, halving the + * number of chains. + */ + while (numchains - lo >= 2) { + hashent **linkp = &hashtab[lo]; + hashent *l1 = hashtab[lo++]; + hashent *l2 = hashtab[--numchains]; + + while (l1 != NULL && l2 != NULL) { + if (strcmp(l1->name, l2->name) < 0) { + *linkp = l1; + linkp = &l1->next; + l1 = l1->next; + } else { + *linkp = l2; + linkp = &l2->next; + l2 = l2->next; + } + } + *linkp = l1==NULL ? l2 : l1; + } + } + + return (hashtab[0]); +} + +/* + * Determine the host byte order. + */ +static int +my_byte_order(void) +{ + static unsigned short s = 0xbbaa; + int byte0; + + byte0 = *(unsigned char *)&s; + if (byte0 == 0xaa) + return (ELFDATA2LSB); + else if (byte0 == 0xbb) + return (ELFDATA2MSB); + else + return (ELFDATANONE); +} + +/* + * Allocate a chunk of memory and return a pointer to it. Die if the + * malloc fails. + */ +static void * +xmalloc(size_t size) +{ + void *p; + + p = malloc(size); + if (p == NULL) + err(EXIT_FAILURE, "malloc"); + return (p); +} + +/* + * Duplicate a string and return a pointer to the copy. Die if there is + * not enough memory. + */ +static char * +xstrdup(const char *s) +{ + int size; + + size = strlen(s) + 1; + return (memcpy(xmalloc(size), s, size)); +} diff --git a/sys/boot/common/interp_parse.c b/sys/boot/common/interp_parse.c index a985bc5..ef23563 100644 --- a/sys/boot/common/interp_parse.c +++ b/sys/boot/common/interp_parse.c @@ -11,7 +11,7 @@ * Jordan K. Hubbard * 29 August 1998 * - * $Id: interp_parse.c,v 1.2 1998/09/03 06:14:41 jkh Exp $ + * $Id: interp_parse.c,v 1.3 1998/09/04 02:43:26 msmith Exp $ * * The meat of the simple parser. */ @@ -22,7 +22,6 @@ /* Forward decls */ extern char *backslash(char *str); -static void init(int *argcp, char ***argvp); static void clean(void); static int insert(int *argcp, char *buf); static char *variable_lookup(char *name); diff --git a/sys/boot/common/load_aout.c b/sys/boot/common/load_aout.c index 3ecba66..3845a9a 100644 --- a/sys/boot/common/load_aout.c +++ b/sys/boot/common/load_aout.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: load_aout.c,v 1.2 1998/09/03 02:10:07 msmith Exp $ + * $Id: load_aout.c,v 1.3 1998/09/14 18:27:04 msmith Exp $ */ #include @@ -35,6 +35,7 @@ #include #define _AOUT_INCLUDE_ #include +#define FREEBSD_AOUT #include #include "bootstrap.h" diff --git a/sys/boot/common/panic.c b/sys/boot/common/panic.c index 2db5513..9639e06 100644 --- a/sys/boot/common/panic.c +++ b/sys/boot/common/panic.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: panic.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ * From: $NetBSD: panic.c,v 1.2 1997/03/22 01:48:36 thorpej Exp $ */ @@ -39,7 +39,7 @@ #include #include -__dead void +void panic(const char *fmt,...) { va_list ap; diff --git a/sys/boot/i386/Makefile b/sys/boot/i386/Makefile index 72d5627..8361444 100644 --- a/sys/boot/i386/Makefile +++ b/sys/boot/i386/Makefile @@ -1,3 +1,3 @@ -SUBDIR= installboot libi386 loader +SUBDIR= btx libi386 loader .include diff --git a/sys/boot/i386/btx/Makefile b/sys/boot/i386/btx/Makefile index 2da29d0..e1bea3b 100644 --- a/sys/boot/i386/btx/Makefile +++ b/sys/boot/i386/btx/Makefile @@ -1,5 +1,5 @@ -# $Id: Makefile,v 1.2 1998/09/12 06:30:10 rnordier Exp $ +# $Id:$ -SUBDIR= btx btxldr lib +SUBDIR= btx btxldr lib # client ldrtst .include diff --git a/sys/boot/i386/btx/btx/Makefile b/sys/boot/i386/btx/btx/Makefile index 9897217..ad2c438 100644 --- a/sys/boot/i386/btx/btx/Makefile +++ b/sys/boot/i386/btx/btx/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.1.1.1 1998/09/12 04:29:23 rnordier Exp $ +# $Id: Makefile,v 1.2 1998/09/14 18:27:05 msmith Exp $ M4?= m4 @@ -23,4 +23,6 @@ clean: depend: +cleandepend: + install: diff --git a/sys/boot/i386/btx/btxldr/Makefile b/sys/boot/i386/btx/btxldr/Makefile index c7fcecf..fdb623a 100644 --- a/sys/boot/i386/btx/btxldr/Makefile +++ b/sys/boot/i386/btx/btxldr/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.1 1998/09/12 06:30:26 rnordier Exp $ +# $Id: Makefile,v 1.2 1998/09/14 18:27:05 msmith Exp $ ORG=0x100000 @@ -21,5 +21,6 @@ clean: depend: -install: +cleandepend: +install: diff --git a/sys/boot/i386/btx/lib/btxv86.h b/sys/boot/i386/btx/lib/btxv86.h index 70c2187..d01be4f 100644 --- a/sys/boot/i386/btx/lib/btxv86.h +++ b/sys/boot/i386/btx/lib/btxv86.h @@ -14,7 +14,7 @@ */ /* - * $Id:$ + * $Id: btxv86.h,v 1.1 1998/09/14 10:37:00 rnordier Exp $ */ #ifndef _BTXV86_H_ @@ -44,10 +44,20 @@ struct __v86 { }; extern struct __v86 __v86; /* V86 interface structure */ +void __v86int(void); + +#define v86 __v86 +#define v86int __v86int + +extern u_int32_t __base; +extern u_int32_t __args; + +#define PTOV(pa) (caddr_t)((pa) - __base) +#define VTOP(va) (vm_offset_t)((va) + __base) +#define VTOPSEG(va) (u_int16_t)(VTOP(va) >> 4) +#define VTOPOFF(va) (u_int16_t)(VTOP(va) & 0xf) void __exit(int); void __exec(caddr_t, ...); -void __v86int(void); - #endif /* !_BTXV86_H_ */ diff --git a/sys/boot/i386/installboot/Makefile b/sys/boot/i386/installboot/Makefile deleted file mode 100644 index b989f07..0000000 --- a/sys/boot/i386/installboot/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $NetBSD: Makefile,v 1.5 1998/03/02 19:57:01 cgd Exp $ - -.include - -BINDIR= /usr/mdec -PROG= installboot - -SRCS= installboot.c bootblks.c getmount.c - -NOMAN= yes - -CPPFLAGS= -I${.CURDIR}/../libi386/crt/bootsect -CFLAGS+= -Wall ${CPPFLAGS} -LDSTATIC?=-static - -.include diff --git a/sys/boot/i386/installboot/bootblks.c b/sys/boot/i386/installboot/bootblks.c deleted file mode 100644 index cb17b92..0000000 --- a/sys/boot/i386/installboot/bootblks.c +++ /dev/null @@ -1,146 +0,0 @@ -/* $NetBSD: bootblks.c,v 1.2 1997/07/21 18:04:35 drochner Exp $ */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "installboot.h" - -static char bootblkpath[MAXPATHLEN]; -static char backuppath[MAXPATHLEN]; -static char backupext[] = ".bak"; -static int havebackup; - -ino_t -createfileondev(diskdev, bootblkname, bp, size) - char *diskdev, *bootblkname; - char *bp; - int size; -{ - char *mntpoint; - int fd = -1; - struct stat statbuf; - int allok = 0; - - if ((mntpoint = getmountpoint(diskdev)) == NULL) - return ((ino_t) - 1); - - /* - * create file in fs root for bootloader data - * try to rename existing file before - */ - havebackup = 0; - sprintf(bootblkpath, "%s/%s", mntpoint, bootblkname); - sprintf(backuppath, "%s%s", bootblkpath, backupext); - if(rename(bootblkpath, backuppath) == -1) { - if(errno != ENOENT) { - warn("rename old %s", bootblkpath); - goto out; - } - } else { - if(verbose) - fprintf(stderr, "renamed %s -> %s\n", - bootblkpath, backuppath); - havebackup = 1; - } - fd = open(bootblkpath, O_RDWR | O_CREAT | O_EXCL, 0444); - if (fd < 0) { - warn("open %s", bootblkpath); - goto out; - } - /* - * do the write, flush, get inode number - */ - if (write(fd, bp, size) < 0) { - warn("write %s", bootblkpath); - goto out; - } - if (fsync(fd) != 0) { - warn("fsync: %s", bootblkpath); - goto out; - } - if (fstat(fd, &statbuf) != 0) { - warn("fstat: %s", bootblkpath); - goto out; - } - allok = 1; - -out: - if (fd != -1) { - close(fd); - if (!allok) - unlink(bootblkpath); - } - if(!allok && havebackup) - rename(backuppath, bootblkpath); - cleanupmount(mntpoint); - return (allok ? statbuf.st_ino : (ino_t) - 1); -} - -void -cleanupfileondev(diskdev, bootblkname, recover) - char *diskdev, *bootblkname; -{ - char *mntpoint; - - /* save some work if nothing to do */ - if(!(recover || havebackup)) - return; - - if ((mntpoint = getmountpoint(diskdev)) == NULL) - return; - - sprintf(bootblkpath, "%s/%s", mntpoint, bootblkname); - sprintf(backuppath, "%s%s", bootblkpath, backupext); - - if(recover) { - unlink(bootblkpath); - if(havebackup) { - fprintf(stderr, "renaming %s -> %s\n", - backuppath, bootblkpath); - rename(backuppath, bootblkpath); - } - } else if(havebackup) { - if(verbose) - fprintf(stderr, "deleting %s\n", backuppath); - unlink(backuppath); - } - - cleanupmount(mntpoint); -} diff --git a/sys/boot/i386/installboot/getmount.c b/sys/boot/i386/installboot/getmount.c deleted file mode 100644 index 6aa8427..0000000 --- a/sys/boot/i386/installboot/getmount.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: getmount.c,v 1.3 1998/03/01 13:22:55 fvdl Exp $ */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "installboot.h" - -static int tempmounted = 0; - -/* make block device name from character device name */ -static char * -getbdev(dev) - char *dev; -{ - static char bdiskdev[MAXPATHLEN]; - - if (strncmp(dev, "/dev/r", 6)) { - warnx("bad device name %s", dev); - return (0); - } - sprintf(bdiskdev, "/dev/%s", dev + 6); - return (bdiskdev); -} - -/* - * create mountpoint and mount given block device there, return - * mountpoint - */ -static char * -dotempmount(bdiskdev) - char *bdiskdev; -{ - static char dir[] = "/tmp/installbootXXXXXX"; - struct ufs_args data; - - if (mktemp(dir) == NULL) { - warnx("mktemp failed"); - return (0); - } - if (mkdir(dir, 0700)) { - warn("could not create temporary dir %s", dir); - return (0); - } - bzero(&data, sizeof(data)); - data.fspec = bdiskdev; - - /* this code if FFS only */ - if (mount("ufs", dir, 0, &data) == -1) { - warn("mount %s->%s failed", bdiskdev, dir); - rmdir(dir); - return (0); - } - if (verbose) - fprintf(stderr, "mounted %s at %s\n", bdiskdev, dir); - tempmounted = 1; - return (dir); -} - -/* - * Find out if given character device is already mounted. If not, mount it - * temporarily. - */ -char * -getmountpoint(diskdev) - char *diskdev; -{ - char *bdiskdev; - struct statfs *buf; - int num, i; - - bdiskdev = getbdev(diskdev); - if (bdiskdev == NULL) - return (0); - - num = getmntinfo(&buf, MNT_WAIT); - if (num == 0) { - warn("getmntinfo"); - return (0); - } - for (i = 0; i < num; i++) - if (strncmp(bdiskdev, buf[i].f_mntfromname, MNAMELEN) == 0) { - int j; - - /* Device is mounted. If there are more devices mounted - at the same point, the fs could be hidden. Don't think - too much about layering order - simply refuse. */ - for (j = 0; j < num; j++) - if ((i != j) && (strncmp(buf[i].f_mntonname, - buf[j].f_mntonname, - MNAMELEN) == 0)) { - warnx("there is more than 1 mount at %s", - buf[i].f_mntonname); - return (0); - } - /* this code is FFS only */ - if (strncmp(buf[i].f_fstypename, "ufs", MFSNAMELEN)) { - warnx("%s: must be a FFS filesystem", bdiskdev); - return (0); - } - return (buf[i].f_mntonname); - } - if (verbose) - fprintf(stderr, "%s is not mounted\n", bdiskdev); - return (dotempmount(bdiskdev)); -} - -void -cleanupmount(dir) - char *dir; -{ - if (tempmounted) { - if (verbose) - fprintf(stderr, "unmounting\n"); - unmount(dir, 0); - rmdir(dir); - tempmounted = 0; - } -} diff --git a/sys/boot/i386/installboot/installboot.8 b/sys/boot/i386/installboot/installboot.8 deleted file mode 100644 index 776f594..0000000 --- a/sys/boot/i386/installboot/installboot.8 +++ /dev/null @@ -1,150 +0,0 @@ -.\" $NetBSD: installboot.8,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ -.\" -.\" Copyright (c) 1997 Perry E. Metzger. All rights reserved. -.\" Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. -.\" Copyright (c) 1995 Paul Kranenburg. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by Paul Kranenburg. -.\" 3. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd March 14, 1997 -.Dt INSTALLBOOT 8 i386 -.Os -.Sh NAME -.Nm installboot -.Nd install disk bootstrap software -.Sh SYNOPSIS -.Nm installboot -.Op Fl nvf -.Ar bootfile -.Ar rawdiskdevice -.Sh DESCRIPTION -The -.Nm installboot -utility prepares a disk for bootstrapping. -.Pp -The -.Nx /i386 -disk bootstrap software is split into two parts: -a small first-stage boot program that is written into the disklabel -area of a disk and a second-stage boot program that resides in a FFS file -system on the disk (named -.Pa /boot ) . -Both parts of the boot are derived from a single object file -which is split by -.Nm -during the installation process. -The first-stage boot program is loaded into memory by the BIOS. -After receiving control of the system, it loads the -second-stage boot program from a set of filesystem block numbers that -have been hard-coded into it by -.Nm -during execution. -The second-stage boot program then locates and loads the kernel. -.Pp -Note: so that the -.Pa /boot -file can be installed on the bootable partition, the partition must be -mounted before -.Nm -is run. -.Pp -The options recognized by -.Nm installboot -are as follows: -.Bl -tag -width flag -.It Fl n -Do not actually write anything on the disk. -.It Fl v -Verbose mode. -.It Fl f -Force a write of the boot blocks (with the first stage put at offset -zero) even if no disk label is detected. -This is useful if there is no disk label (as is often the case with -floppy or vnode devices). -.El -.Pp -The arguments are: -.Bl -tag -width rawdiskdevice -.It Ar bootfile -The name of the special object file -(typically -.Pa /usr/mdec/biosboot.sym ) -where the first and second stage boot programs to be installed reside. -.It Ar rawdiskdevice -The name of the device corresponding to the raw whole-disk partition (the -.Dq raw partition ) -of the disk on which the first-stage boot program is to be installed. -.El -.Sh EXAMPLES -Assuming the file containing the boot program is in its typical place, -and you wished to make -.Pa /dev/fd0a -bootable. One might first mount -.Pa /dev/fd0a -on -.Pa /mnt , -and in the case that there is already a file named -.Pa boot -in that directory, remove it. -To install the boot blocks, one then would issue the command: -.Bd -literal -offset indent -installboot -f /usr/mdec/biosboot.sym /dev/rfd0a -.Ed -Note that the -f option is needed if the floppy is unlabeled -- see -.Xr disklabel 8 . -.Sh BUGS -The NetBSD/i386 boot blocks can only read from the first 1024 -cylinders of the disk because they use the BIOS to do their I/O. Thus, -it is advisable that -.Dq a -partitions reside entirely within the first 1024 cylinders. -.Pp -.Nm -requires simultaneous access to the mounted file system and -the disks' raw partition. -That is not allowed with the kernel -.Dv securelevel -variable -.Po -see -.Xr sysctl 8 -.Pc -set to a value greater than one, or with -.Dv securelevel -set to one if the -.Dq boot -program resides in a file system on the disk's raw partition. -.Sh "SEE ALSO" -.Xr boot 8 , -.Xr disklabel 8 , -.Xr init 8 , -.Xr sysctl 8 , -.Xr vnd 4 -.Sh HISTORY -The NetBSD/i386 -.Nm -command first appeared in -.Nx 1.3 . diff --git a/sys/boot/i386/installboot/installboot.c b/sys/boot/i386/installboot/installboot.c deleted file mode 100644 index 12e75bc..0000000 --- a/sys/boot/i386/installboot/installboot.c +++ /dev/null @@ -1,433 +0,0 @@ -/* $NetBSD: installboot.c,v 1.5 1997/11/01 06:49:50 lukem Exp $ */ - -/* - * Copyright (c) 1994 Paul Kranenburg - * All rights reserved. - * Copyright (c) 1996, 1997 - * Matthias Drochner. All rights reserved. - * Copyright (c) 1996, 1997 - * Perry E. Metzger. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Paul Kranenburg. - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -/* #include */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "installboot.h" - -#include "bbinfo.h" - -#define DEFBBLKNAME "loader" - -struct fraglist *fraglist; - -struct nlist nl[] = { -#define X_fraglist 0 - {{"_fraglist"}}, - {{NULL}} -}; - -int verbose = 0; - -char * -loadprotoblocks(fname, size) - char *fname; - long *size; -{ - int fd; - size_t tdsize; /* text+data size */ - size_t bbsize; /* boot block size (block aligned) */ - char *bp; - struct nlist *nlp; - struct exec eh; - - fd = -1; - bp = NULL; - - /* Locate block number array in proto file */ - if (nlist(fname, nl) != 0) { - warnx("nlist: %s: symbols not found", fname); - return NULL; - } - /* Validate symbol types (global text!). */ - for (nlp = nl; nlp->n_un.n_name; nlp++) { - if (nlp->n_type != (N_TEXT | N_EXT)) { - warnx("nlist: %s: wrong type", nlp->n_un.n_name); - return NULL; - } - } - - if ((fd = open(fname, O_RDONLY)) < 0) { - warn("open: %s", fname); - return NULL; - } - if (read(fd, &eh, sizeof(eh)) != sizeof(eh)) { - warn("read: %s", fname); - goto bad; - } - if (N_GETMAGIC(eh) != OMAGIC) { - warn("bad magic: 0x%lx", eh.a_midmag); - goto bad; - } - /* - * We need only text and data. - */ - tdsize = eh.a_text + eh.a_data; - bbsize = roundup(tdsize, DEV_BSIZE); - - if ((bp = calloc(bbsize, 1)) == NULL) { - warnx("malloc: %s: no memory", fname); - goto bad; - } - /* read the rest of the file. */ - if (read(fd, bp, tdsize) != tdsize) { - warn("read: %s", fname); - goto bad; - } - *size = bbsize; /* aligned to DEV_BSIZE */ - - fraglist = (struct fraglist *) (bp + nl[X_fraglist].n_value); - - if (fraglist->magic != FRAGLISTMAGIC) { - warnx("invalid bootblock version"); - goto bad; - } - if (verbose) { - fprintf(stderr, "%s: entry point %#lx\n", fname, eh.a_entry); - fprintf(stderr, "proto bootblock size %ld\n", *size); - fprintf(stderr, "room for %d filesystem blocks at %#lx\n", - fraglist->maxentries, nl[X_fraglist].n_value); - } - close(fd); - return bp; - -bad: - if (bp) - free(bp); - if (fd >= 0) - close(fd); - return NULL; -} - -static int -devread(fd, buf, blk, size, msg) - int fd; - void *buf; - daddr_t blk; - size_t size; - char *msg; -{ - if (lseek(fd, dbtob(blk), SEEK_SET) != dbtob(blk)) { - warn("%s: devread: lseek", msg); - return (1); - } - if (read(fd, buf, size) != size) { - warn("%s: devread: read", msg); - return (1); - } - return (0); -} - -/* add file system blocks to fraglist */ -static int -add_fsblk(fs, blk, blcnt) - struct fs *fs; - daddr_t blk; - int blcnt; -{ - int nblk; - - /* convert to disk blocks */ - blk = fsbtodb(fs, blk); - nblk = fs->fs_bsize / DEV_BSIZE; - if (nblk > blcnt) - nblk = blcnt; - - if (verbose) - fprintf(stderr, "dblk: %d, num: %d\n", blk, nblk); - - /* start new entry or append to previous? */ - if (!fraglist->numentries || - (fraglist->entries[fraglist->numentries - 1].offset - + fraglist->entries[fraglist->numentries - 1].num != blk)) { - - /* need new entry */ - if (fraglist->numentries > fraglist->maxentries - 1) { - errx(1, "not enough fragment space in bootcode\n"); - return(-1); - } - - fraglist->entries[fraglist->numentries].offset = blk; - fraglist->entries[fraglist->numentries++].num = 0; - } - fraglist->entries[fraglist->numentries - 1].num += nblk; - - return (blcnt - nblk); -} - -static char sblock[SBSIZE]; - -int -loadblocknums(diskdev, inode) - char *diskdev; - ino_t inode; -{ - int devfd = -1; - struct fs *fs; - char *buf = 0; - daddr_t blk, *ap; - struct dinode *ip; - int i, ndb; - int allok = 0; - - devfd = open(diskdev, O_RDONLY, 0); - if (devfd < 0) { - warn("open raw partition"); - return (1); - } - /* Read superblock */ - if (devread(devfd, sblock, SBLOCK, SBSIZE, "superblock")) - goto out; - fs = (struct fs *) sblock; - - if (fs->fs_magic != FS_MAGIC) { - warnx("invalid super block"); - goto out; - } - /* Read inode */ - if ((buf = malloc(fs->fs_bsize)) == NULL) { - warnx("No memory for filesystem block"); - goto out; - } - blk = fsbtodb(fs, ino_to_fsba(fs, inode)); - if (devread(devfd, buf, blk, fs->fs_bsize, "inode")) - goto out; - ip = (struct dinode *) (buf) + ino_to_fsbo(fs, inode); - - /* - * Have the inode. Figure out how many blocks we need. - */ - ndb = ip->di_size / DEV_BSIZE; /* size is rounded! */ - - if (verbose) - fprintf(stderr, "Will load %d blocks.\n", ndb); - - /* - * Get the block numbers, first direct blocks - */ - ap = ip->di_db; - for (i = 0; i < NDADDR && *ap && ndb > 0; i++, ap++) - ndb = add_fsblk(fs, *ap, ndb); - - if (ndb > 0) { - /* - * Just one level of indirections; there isn't much room - * for more in the 1st-level bootblocks anyway. - */ - blk = fsbtodb(fs, ip->di_ib[0]); - if (devread(devfd, buf, blk, fs->fs_bsize, "indirect block")) - goto out; - ap = (daddr_t *) buf; - for (; i < NINDIR(fs) && *ap && ndb > 0; i++, ap++) { - ndb = add_fsblk(fs, *ap, ndb); - } - } - - if (!ndb) - allok = 1; - else { - if (ndb > 0) - warnx("too many fs blocks"); - /* else, ie ndb < 0, add_fsblk returned error */ - goto out; - } - -out: - if (buf) - free(buf); - if (devfd >= 0) - close(devfd); - return (!allok); -} - -static void -usage() -{ - fprintf(stderr, - "usage: installboot [-n] [-v] [-f] \n"); - exit(1); -} - -int -main(argc, argv) - int argc; - char *argv[]; -{ - char c, *bp = 0; - long size; - ino_t inode = (ino_t) -1; - int devfd = -1; - struct disklabel dl; - int bsdoffs; - int i, res; - int forceifnolabel = 0; - char *bootblkname = DEFBBLKNAME; - int nowrite = 0; - int allok = 0; - - while ((c = getopt(argc, argv, "vnf")) != -1) { - switch (c) { - case 'n': - /* Do not actually write the bootblock to disk */ - nowrite = 1; - break; - case 'v': - /* Chat */ - verbose = 1; - break; - case 'f': - /* assume zero offset if no disklabel */ - forceifnolabel = 1; - break; - default: - usage(); - } - } - - if (argc - optind != 2) { - usage(); - } - - bp = loadprotoblocks(argv[optind], &size); - if (!bp) - errx(1, "error reading bootblocks"); - - fraglist->numentries = 0; - - /* do we need the fraglist? */ - if (size > fraglist->loadsz * DEV_BSIZE) { - - inode = createfileondev(argv[optind + 1], bootblkname, - bp + fraglist->loadsz * DEV_BSIZE, - size - fraglist->loadsz * DEV_BSIZE); - if (inode == (ino_t) - 1) - goto out; - - /* paranoia */ - sync(); - sleep(3); - - if (loadblocknums(argv[optind + 1], inode)) - goto out; - - size = fraglist->loadsz * DEV_BSIZE; - /* size to be written to bootsect */ - } - - devfd = open(argv[optind + 1], O_RDWR, 0); - if (devfd < 0) { - warn("open raw partition RW"); - goto out; - } - if (ioctl(devfd, DIOCGDINFO, &dl) < 0) { - if ((errno == EINVAL) || (errno == ENOTTY)) { - if (forceifnolabel) - bsdoffs = 0; - else { - warnx("no disklabel, use -f to install anyway"); - goto out; - } - } else { - warn("get disklabel"); - goto out; - } - } else { - char c = argv[optind + 1][strlen(argv[optind + 1]) - 1]; -#define isvalidpart(c) ((c) >= 'a' && (c) <= 'z') - if(!isvalidpart(c) || (c - 'a') >= dl.d_npartitions) { - warnx("invalid partition"); - goto out; - } - bsdoffs = dl.d_partitions[c - 'a'].p_offset; - } - if (verbose) - fprintf(stderr, "BSD partition starts at sector %d\n", bsdoffs); - - /* - * add offset of BSD partition to fraglist entries - */ - for (i = 0; i < fraglist->numentries; i++) - fraglist->entries[i].offset += bsdoffs; - - if (!nowrite) { - /* - * write first blocks (max loadsz) to start of BSD partition, - * skip disklabel (in second disk block) - */ - lseek(devfd, 0, SEEK_SET); - res = write(devfd, bp, DEV_BSIZE); - if (res < 0) { - warn("final write1"); - goto out; - } - lseek(devfd, 2 * DEV_BSIZE, SEEK_SET); - res = write(devfd, bp + 2 * DEV_BSIZE, size - 2 * DEV_BSIZE); - if (res < 0) { - warn("final write2"); - goto out; - } - } - allok = 1; - -out: - if (devfd >= 0) - close(devfd); - if (bp) - free(bp); - if (inode != (ino_t) - 1) { - cleanupfileondev(argv[optind + 1], bootblkname, !allok || nowrite); - } - return (!allok); -} diff --git a/sys/boot/i386/installboot/installboot.h b/sys/boot/i386/installboot/installboot.h deleted file mode 100644 index 83d2275..0000000 --- a/sys/boot/i386/installboot/installboot.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $NetBSD: installboot.h,v 1.3 1998/01/05 07:02:57 perry Exp $ */ - -ino_t createfileondev __P((char *, char *, char *, int)); -void cleanupfileondev __P((char *, char *, int)); - -char *getmountpoint __P((char *)); -void cleanupmount __P((char *)); - -extern int verbose; diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile index e2cf0c4..d6525df 100644 --- a/sys/boot/i386/libi386/Makefile +++ b/sys/boot/i386/libi386/Makefile @@ -1,16 +1,13 @@ -# $Id: Makefile,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ +# $Id: Makefile,v 1.2 1998/08/31 21:10:43 msmith Exp $ # -SUBDIR= crt LIB= i386 NOPIC= NOPROFILE= -SRCS= aout_freebsd.c biosdelay.S biosdisk.c biosdisk_support.S biosgetrtc.S \ - biosmem.S biosreboot.S bootinfo.c comconsole.c comconsole_support.S \ - devicename.c gatea20.c getsecs.c i386_copy.c i386_module.c \ - startprog.S vidconsole.c vidconsole_support.S +SRCS= aout_freebsd.c biosdisk.c biosmem.c bootinfo.c comconsole.c \ + devicename.c gatea20.c i386_copy.c i386_module.c time.c vidconsole.c -CFLAGS+= -I${.CURDIR}/../../common +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib # Make the disk code more talkative #CFLAGS+= -DDISK_DEBUG diff --git a/sys/boot/i386/libi386/aout_freebsd.c b/sys/boot/i386/libi386/aout_freebsd.c index 7d570d3..674e243 100644 --- a/sys/boot/i386/libi386/aout_freebsd.c +++ b/sys/boot/i386/libi386/aout_freebsd.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: aout_freebsd.c,v 1.2 1998/08/31 21:10:43 msmith Exp $ + * $Id: aout_freebsd.c,v 1.3 1998/09/14 18:27:05 msmith Exp $ */ #include @@ -37,6 +37,7 @@ #include "bootstrap.h" #include "libi386.h" +#include "btxv86.h" static int aout_exec(struct loaded_module *amp); @@ -141,6 +142,8 @@ aout_exec(struct loaded_module *mp) printf("Start @ 0x%lx ...\n", entry); #endif - startprog(entry, 6, argv, (vm_offset_t)0x90000); + __exec(entry, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); + +/* startprog(entry, 6, argv, (vm_offset_t)0x90000); */ panic("exec returned"); } diff --git a/sys/boot/i386/libi386/biosdelay.S b/sys/boot/i386/libi386/biosdelay.S deleted file mode 100644 index c04a57b..0000000 --- a/sys/boot/i386/libi386/biosdelay.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: biosdelay.S,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ */ - -/* - * Copyright (c) 1996, 1997 - * Perry E. Metzger. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgements: - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#define data32 .byte 0x66 - - .text - -/* -# BIOS call "INT 15H Function 86H" to sleep for a set number of microseconds -# Call with %ah = 0x86 -# %cx = time interval (high) -# %dx = time interval (low) -# Return: -# If error -# CF = set -# else -# CF = clear -*/ -ENTRY(delay) - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - - movw 20(%esp), %dx - movw 22(%esp), %cx - - call CNAME(prot_to_real) - - movb $0x86, %ah - int $0x15 - setnc %ah - - movb %ah, %bl # real_to_prot uses %eax - - data32 - call CNAME(real_to_prot) - - xorl %eax, %eax - movb %bl, %al - - popl %edi - popl %esi - popl %ebx - popl %ebp - ret diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c index a6bcbbe..ffb54b0 100644 --- a/sys/boot/i386/libi386/biosdisk.c +++ b/sys/boot/i386/libi386/biosdisk.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: biosdisk.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ */ /* @@ -42,7 +42,8 @@ #include #include -#include "bootstrap.h" +#include +#include #include "libi386.h" #include "crt/biosdisk_ll.h" @@ -55,21 +56,13 @@ # define D(x) #endif -/* biosdisk_support.S */ -extern u_long bd_int13fn8(int unit); - -static int bd_edd3probe(int unit); -static int bd_edd1probe(int unit); -static int bd_int13probe(int unit); - -static int bd_init(void); -static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); -static int bd_open(struct open_file *f, void *vdev); -static int bd_close(struct open_file *f); struct open_disk { - struct biosdisk_ll od_ll; /* contains bios unit, geometry (XXX absorb) */ - int od_unit; /* our unit number */ + int od_dkunit; /* disk unit number */ + int od_unit; /* BIOS unit number */ + int od_cyl; /* BIOS geometry */ + int od_hds; + int od_sec; int od_boff; /* block offset from beginning of BIOS disk */ int od_flags; #define BD_MODEMASK 0x3 @@ -80,6 +73,18 @@ struct open_disk { u_char od_buf[BUFSIZE]; /* transfer buffer (do we want/need this?) */ }; +static int bd_getgeom(struct open_disk *od); +static int bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest); + +static int bd_edd3probe(int unit); +static int bd_edd1probe(int unit); +static int bd_int13probe(int unit); + +static int bd_init(void); +static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); +static int bd_open(struct open_file *f, void *vdev); +static int bd_close(struct open_file *f); + struct devsw biosdisk = { "disk", DEVT_DISK, @@ -162,12 +167,16 @@ bd_edd1probe(int unit) static int bd_int13probe(int unit) { - u_long geom; - - /* try int 0x13, function 8 */ - geom = bd_int13fn8(unit); - - return(geom != 0); + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + v86.eax = 0x800; + v86.edx = unit; + v86int(); + + if (!(v86.efl & 0x1) && /* carry clear */ + ((v86.edx & 0xff) > unit & 0x7f)) /* unit # OK */ + return(1); + return(0); } /* @@ -202,9 +211,9 @@ bd_open(struct open_file *f, void *vdev) } /* Look up BIOS unit number, intialise open_disk structure */ - od->od_unit = dev->d_kind.biosdisk.unit; - od->od_ll.dev = bdinfo[od->od_unit].bd_unit; - od->od_flags = bdinfo[od->od_unit].bd_flags; + od->od_dkunit = dev->d_kind.biosdisk.unit; + od->od_unit = bdinfo[od->od_dkunit].bd_unit; + od->od_flags = bdinfo[od->od_dkunit].bd_flags; od->od_boff = 0; error = 0; #if 0 @@ -214,7 +223,7 @@ bd_open(struct open_file *f, void *vdev) #endif /* Get geometry for this open (removable device may have changed) */ - if (set_geometry(&od->od_ll)) { + if (bd_getgeom(od)) { D(printf("bd_open: can't get geometry\n")); error = ENXIO; goto out; @@ -229,7 +238,7 @@ bd_open(struct open_file *f, void *vdev) /* * Find the slice in the DOS slice table. */ - if (readsects(&od->od_ll, 0, 1, od->od_buf, 0)) { + if (bd_read(od, 0, 1, od->od_buf)) { D(printf("bd_open: error reading MBR\n")); error = EIO; goto out; @@ -292,7 +301,7 @@ bd_open(struct open_file *f, void *vdev) D(printf("bd_open: opening raw slice\n")); } else { - if (readsects(&od->od_ll, sector + LABELSECTOR, 1, od->od_buf, 0)) { + if (bd_read(od, sector + LABELSECTOR, 1, od->od_buf)) { D(printf("bd_open: error reading disklabel\n")); error = EIO; goto out; @@ -348,11 +357,11 @@ bd_close(struct open_file *f) #if 0 D(printf("bd_close: open_disk %p\n", od)); #endif - +#if 0 /* XXX is this required? (especially if disk already open...) */ if (od->od_flags & BD_FLOPPY) delay(3000000); - +#endif free(od); return(0); } @@ -387,7 +396,7 @@ bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t if (rsize) *rsize = 0; - if (blks && readsects(&od->od_ll, dblk + od->od_boff, blks, buf, 0)) { + if (blks && bd_read(od, dblk + od->od_boff, blks, buf)) { D(printf("read error\n")); return (EIO); } @@ -396,7 +405,7 @@ bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t D(printf("bd_strategy: frag read %d from %d+%d+d to %p\n", #endif fragsize, od->od_boff, dblk, blks, buf + (blks * BIOSDISK_SECSIZE))); - if (fragsize && readsects(&od->od_ll, dblk + od->od_boff + blks, 1, fragsize, 0)) { + if (fragsize && bd_read(od, dblk + od->od_boff + blks, 1, fragsize)) { D(printf("frag read error\n")); return(EIO); } @@ -406,3 +415,64 @@ bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize = size; return (0); } + +static int +bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest) +{ + int x, bpc, cyl, hd, sec; + + bpc = (od->od_sec * od->od_hds); /* blocks per cylinder */ + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + + while (blks != 0) { + x = dblk; + cyl = x / bpc; /* block # / blocks per cylinder */ + x %= bpc; /* block offset into cylinder */ + hd = x / od->od_sec; /* offset / blocks per track */ + sec = x % od->od_sec; /* offset into track */ + + /* play it safe and don't cross track boundaries */ + x = min (od->od_sec - sec, blks); + + /* correct sector number for 1-based BIOS numbering */ + sec++; + + /* build request XXX support EDD requests too */ + v86.eax = 0x200 | x; + v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec; + v86.edx = (hd << 8) | od->od_unit; + v86.es = V86SEG(dest); + v86.ebx = V86OFS(dest); + v86int(); + if (v86.efl & 0x1) + return(-1); + + dest + (x * BIOSDISK_SECSIZE); + dblk += x; + blks -= x; + } + return(0); +} + +static int +bd_getgeom(struct open_disk *od) +{ + + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + v86.eax = 0x800; + v86.edx = od->od_unit; + v86int(); + + if ((v86.efl & 0x1) || /* carry set */ + ((v86.edx & 0xff) <= (od->od_unit & 0x7f))) /* unit # bad */ + return(1); + + /* convert max cyl # -> # of cylinders */ + od->od_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1; + /* convert max head # -> # of heads */ + od->od_hds = ((v86.edx & 0xff00) >> 8) + 1; + od->od_sec = v86.ecx & 0x3f; + return(0); +} diff --git a/sys/boot/i386/libi386/biosdisk_support.S b/sys/boot/i386/libi386/biosdisk_support.S deleted file mode 100644 index 52e2e0f..0000000 --- a/sys/boot/i386/libi386/biosdisk_support.S +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id: bios.S,v 1.12 1997/07/31 08:07:53 phk Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -/* - * - * get_diskinfo(): return a word that represents the - * max number of sectors and heads and drives for this device - * - */ - -ENTRY(bd_int13fn8) - push %ebp - mov %esp, %ebp - push %ebx - push %esi - push %edi - - movb 0x8(%ebp), %dl /* diskinfo(drive #) */ - call CNAME(prot_to_real) /* enter real mode */ - - movb $0x8, %ah /* ask for disk info */ - - sti - int $0x13 - cli - - jnc ok - /* call failed, return 0 */ - subb %cl, %cl - subb %ch, %ch - subb %dl, %dl - subb %dh, %dh -ok: - - data32 - call CNAME(real_to_prot) /* back to protected mode */ - - /* - * form a longword representing all this gunk: - * 6 bit zero - * 10 bit max cylinder (0 based) - * 8 bit max head (0 based) - * 2 bit zero - * 6 bit max sector (1 based) = # sectors - */ - movb %cl, %al /* Upper two bits of cylinder count */ - andl $0xc0,%eax - leal 0(,%eax,4),%eax /* << 2 */ - movb %ch, %al /* Lower 8 bits */ - sall $16,%eax /* << 16 */ - movb %dh, %ah /* max head */ - andb $0x3f, %cl /* mask of cylinder gunk */ - movb %cl, %al /* max sector (and # sectors) */ - - pop %edi - pop %esi - pop %ebx - pop %ebp - ret - diff --git a/sys/boot/i386/libi386/biosgetrtc.S b/sys/boot/i386/libi386/biosgetrtc.S deleted file mode 100644 index 5927a06..0000000 --- a/sys/boot/i386/libi386/biosgetrtc.S +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: biosgetrtc.S,v 1.2 1997/06/13 13:42:27 drochner Exp $ */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -ENTRY(biosgetrtc) - pushl %ebp - movl %esp, %ebp - pushl %ebx - pushl %ecx - pushl %edx - push %esi - push %edi - - xorl %ebx, %ebx - - call CNAME(prot_to_real) # enter real mode - - movb $2, %ah - int $0x1a - jnc ok - data32 - movl $-1, %ebx - -ok: - data32 - call CNAME(real_to_prot) # back to protected mode - - movl 8(%ebp), %eax - movl $0, (%eax) - movb %ch, (%eax) - movb %cl, 1(%eax) - movb %dh, 2(%eax) - - movl %ebx, %eax - - pop %edi - pop %esi - popl %edx - popl %ecx - popl %ebx - popl %ebp - ret diff --git a/sys/boot/i386/libi386/biosmem.S b/sys/boot/i386/libi386/biosmem.S deleted file mode 100644 index cb97672..0000000 --- a/sys/boot/i386/libi386/biosmem.S +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: biosmem.S,v 1.5 1997/08/18 22:44:01 hannken Exp $ */ - -/* - * Copyright (c) 1996 - * Perry E. Metzger. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgements: - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#include - -#define data32 .byte 0x66 - - .text - -/* get mem below 1M, in kByte */ - -ENTRY(getbasemem) - pushl %ebp - movl %esp,%ebp - pushl %ebx - push %esi - push %edi - - call CNAME(prot_to_real) - - int $0x12 - # zero-extend 16-bit result to 32 bits. - data32 - movl $0, %ebx - mov %eax,%ebx # !!! at run time, it is mov %ax,%bx - - data32 - call CNAME(real_to_prot) - - movl %ebx, %eax - - pop %edi - pop %esi - popl %ebx - popl %ebp - ret - -/* get mem above 1M, in kByte */ - -ENTRY(getextmem) - pushl %ebp - movl %esp,%ebp - pushl %ebx - push %esi - push %edi - - call CNAME(prot_to_real) - - movb $0x88,%ah - int $0x15 - - # zero-extend 16-bit result to 32 bits. - data32 - movl $0, %ebx - mov %eax,%ebx # !!! at run time, it is mov %ax,%bx - - data32 - call CNAME(real_to_prot) - - movl %ebx, %eax - - pop %edi - pop %esi - popl %ebx - popl %ebp - ret - diff --git a/sys/boot/i386/libi386/biosmem.c b/sys/boot/i386/libi386/biosmem.c new file mode 100644 index 0000000..8322654 --- /dev/null +++ b/sys/boot/i386/libi386/biosmem.c @@ -0,0 +1,52 @@ +/* + * mjs copyright + */ + +/* + * Obtain memory configuration information from the BIOS + * + * Note that we don't try too hard here; knowing the size of + * base memory and extended memory out to 16 or 64M is enough for + * the requirements of the bootstrap. + * + * We also maintain a pointer to the top of physical memory + * once called to allow rangechecking of load/copy requests. + */ +#include +#include "btxv86.h" + +vm_offset_t memtop; + +/* + * Return base memory size in kB. + */ +int +getbasemem(void) +{ + v86.ctl = 0; + v86.addr = 0x1a; /* int 0x12 */ + v86int(); + + return(v86.eax & 0xffff); +} + +/* + * Return extended memory size in kB + */ +int +getextmem(void) +{ + int extkb; + + v86.ctl = 0; + v86.addr = 0x15; /* int 0x12 function 0x88*/ + v86.eax = 0x8800; + v86int(); + extkb = v86.eax & 0xffff; + + /* Set memtop to actual top or 16M, whicheve is less */ + memtop = min((0x100000 + (extkb + 1024)), (16 * 1024 * 1024)); + + return(extkb); +} + diff --git a/sys/boot/i386/libi386/biosreboot.S b/sys/boot/i386/libi386/biosreboot.S deleted file mode 100644 index f2bfe65..0000000 --- a/sys/boot/i386/libi386/biosreboot.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: biosreboot.S,v 1.1 1997/04/13 18:45:37 perry Exp $ */ - -/* - * Copyright (c) 1997 - * Perry E. Metzger. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgements: - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#include - -#define data32 .byte 0x66 - - .text - -/* Call INT 19 to do the equivalent of CTL-ALT-DEL */ - -ENTRY(reboot) - pushl %ebp - movl %esp,%ebp - pushl %ebx - push %esi - push %edi - - call CNAME(prot_to_real) - - int $0x19 - - /* NOTE: We should never even get past this point. */ - - data32 - call CNAME(real_to_prot) - - movl %ebx, %eax - - pop %edi - pop %esi - popl %ebx - popl %ebp - ret diff --git a/sys/boot/i386/libi386/bootinfo.c b/sys/boot/i386/libi386/bootinfo.c index 02d217b..7870a5f 100644 --- a/sys/boot/i386/libi386/bootinfo.c +++ b/sys/boot/i386/libi386/bootinfo.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootinfo.c,v 1.2 1998/09/03 02:10:09 msmith Exp $ + * $Id: bootinfo.c,v 1.3 1998/09/14 18:27:05 msmith Exp $ */ #include @@ -120,18 +120,18 @@ bi_copyenv(vm_offset_t addr) /* traverse the environment */ for (ep = environ; ep != NULL; ep = ep->ev_next) { - vpbcopy(ep->ev_name, addr, strlen(ep->ev_name)); + i386_copyin(ep->ev_name, addr, strlen(ep->ev_name)); addr += strlen(ep->ev_name); - vpbcopy("=", addr, 1); + i386_copyin("=", addr, 1); addr++; if (ep->ev_value != NULL) { - vpbcopy(ep->ev_value, addr, strlen(ep->ev_value)); + i386_copyin(ep->ev_value, addr, strlen(ep->ev_value)); addr += strlen(ep->ev_value); } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } @@ -152,9 +152,9 @@ bi_copyenv(vm_offset_t addr) */ #define MOD_STR(t, a, s) { \ u_int32_t ident = (t << 16) + strlen(s) + 1; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(s, a, strlen(s) + 1); \ + i386_copyin(s, a, strlen(s) + 1); \ a += strlen(s) + 1; \ } @@ -163,9 +163,9 @@ bi_copyenv(vm_offset_t addr) #define MOD_VAR(t, a, s) { \ u_int32_t ident = (t << 16) + sizeof(s); \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(&s, a, sizeof(s)); \ + i386_copyin(&s, a, sizeof(s)); \ a += sizeof(s); \ } @@ -174,18 +174,18 @@ bi_copyenv(vm_offset_t addr) #define MOD_METADATA(a, mm) { \ u_int32_t ident = ((MODINFO_METADATA | mm->md_type) << 16) + mm->md_size; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(mm->md_data, a, mm->md_size); \ + i386_copyin(mm->md_data, a, mm->md_size); \ a += mm->md_size; \ } -#define MOD_END(a) { \ - u_int32_t ident = 0; \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ +#define MOD_END(a) { \ + u_int32_t ident = 0; \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ } vm_offset_t diff --git a/sys/boot/i386/libi386/bootinfo32.c b/sys/boot/i386/libi386/bootinfo32.c index 02d217b..7870a5f 100644 --- a/sys/boot/i386/libi386/bootinfo32.c +++ b/sys/boot/i386/libi386/bootinfo32.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootinfo.c,v 1.2 1998/09/03 02:10:09 msmith Exp $ + * $Id: bootinfo.c,v 1.3 1998/09/14 18:27:05 msmith Exp $ */ #include @@ -120,18 +120,18 @@ bi_copyenv(vm_offset_t addr) /* traverse the environment */ for (ep = environ; ep != NULL; ep = ep->ev_next) { - vpbcopy(ep->ev_name, addr, strlen(ep->ev_name)); + i386_copyin(ep->ev_name, addr, strlen(ep->ev_name)); addr += strlen(ep->ev_name); - vpbcopy("=", addr, 1); + i386_copyin("=", addr, 1); addr++; if (ep->ev_value != NULL) { - vpbcopy(ep->ev_value, addr, strlen(ep->ev_value)); + i386_copyin(ep->ev_value, addr, strlen(ep->ev_value)); addr += strlen(ep->ev_value); } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } @@ -152,9 +152,9 @@ bi_copyenv(vm_offset_t addr) */ #define MOD_STR(t, a, s) { \ u_int32_t ident = (t << 16) + strlen(s) + 1; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(s, a, strlen(s) + 1); \ + i386_copyin(s, a, strlen(s) + 1); \ a += strlen(s) + 1; \ } @@ -163,9 +163,9 @@ bi_copyenv(vm_offset_t addr) #define MOD_VAR(t, a, s) { \ u_int32_t ident = (t << 16) + sizeof(s); \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(&s, a, sizeof(s)); \ + i386_copyin(&s, a, sizeof(s)); \ a += sizeof(s); \ } @@ -174,18 +174,18 @@ bi_copyenv(vm_offset_t addr) #define MOD_METADATA(a, mm) { \ u_int32_t ident = ((MODINFO_METADATA | mm->md_type) << 16) + mm->md_size; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(mm->md_data, a, mm->md_size); \ + i386_copyin(mm->md_data, a, mm->md_size); \ a += mm->md_size; \ } -#define MOD_END(a) { \ - u_int32_t ident = 0; \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ +#define MOD_END(a) { \ + u_int32_t ident = 0; \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ } vm_offset_t diff --git a/sys/boot/i386/libi386/bootinfo64.c b/sys/boot/i386/libi386/bootinfo64.c index 02d217b..7870a5f 100644 --- a/sys/boot/i386/libi386/bootinfo64.c +++ b/sys/boot/i386/libi386/bootinfo64.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootinfo.c,v 1.2 1998/09/03 02:10:09 msmith Exp $ + * $Id: bootinfo.c,v 1.3 1998/09/14 18:27:05 msmith Exp $ */ #include @@ -120,18 +120,18 @@ bi_copyenv(vm_offset_t addr) /* traverse the environment */ for (ep = environ; ep != NULL; ep = ep->ev_next) { - vpbcopy(ep->ev_name, addr, strlen(ep->ev_name)); + i386_copyin(ep->ev_name, addr, strlen(ep->ev_name)); addr += strlen(ep->ev_name); - vpbcopy("=", addr, 1); + i386_copyin("=", addr, 1); addr++; if (ep->ev_value != NULL) { - vpbcopy(ep->ev_value, addr, strlen(ep->ev_value)); + i386_copyin(ep->ev_value, addr, strlen(ep->ev_value)); addr += strlen(ep->ev_value); } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } @@ -152,9 +152,9 @@ bi_copyenv(vm_offset_t addr) */ #define MOD_STR(t, a, s) { \ u_int32_t ident = (t << 16) + strlen(s) + 1; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(s, a, strlen(s) + 1); \ + i386_copyin(s, a, strlen(s) + 1); \ a += strlen(s) + 1; \ } @@ -163,9 +163,9 @@ bi_copyenv(vm_offset_t addr) #define MOD_VAR(t, a, s) { \ u_int32_t ident = (t << 16) + sizeof(s); \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(&s, a, sizeof(s)); \ + i386_copyin(&s, a, sizeof(s)); \ a += sizeof(s); \ } @@ -174,18 +174,18 @@ bi_copyenv(vm_offset_t addr) #define MOD_METADATA(a, mm) { \ u_int32_t ident = ((MODINFO_METADATA | mm->md_type) << 16) + mm->md_size; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(mm->md_data, a, mm->md_size); \ + i386_copyin(mm->md_data, a, mm->md_size); \ a += mm->md_size; \ } -#define MOD_END(a) { \ - u_int32_t ident = 0; \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ +#define MOD_END(a) { \ + u_int32_t ident = 0; \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ } vm_offset_t diff --git a/sys/boot/i386/libi386/comconsole.c b/sys/boot/i386/libi386/comconsole.c index a75f92d..1d98585 100644 --- a/sys/boot/i386/libi386/comconsole.c +++ b/sys/boot/i386/libi386/comconsole.c @@ -24,22 +24,19 @@ * * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp * - * $Id$ + * $Id: comconsole.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ */ #include - -#include "bootstrap.h" - -/* in comconsole.S */ -extern void cominit(int s); -extern void computc(int c); -extern int comgetc(void); -extern int comiskey(void); +#include +#include +#include "libi386.h" static void comc_probe(struct console *cp); static int comc_init(int arg); -static int comc_in(void); +static void comc_putchar(int c); +static int comc_getchar(void); +static int comc_ischar(void); struct console comconsole = { "comconsole", @@ -47,11 +44,13 @@ struct console comconsole = { 0, comc_probe, comc_init, - computc, - comc_in, - comiskey + comc_putchar, + comc_getchar, + comc_ischar }; +#define BIOS_COMPORT 0 + static void comc_probe(struct console *cp) { @@ -62,17 +61,43 @@ comc_probe(struct console *cp) static int comc_init(int arg) { - /* XXX arg is unit number, should we use variables instead? */ - cominit(arg); - return(0); + v86.ctl = V86_FLAGS; + v86.addr = 0x14; + v86.eax = 0xe3; /* 9600N81 */ + v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */ + v86int(); + return(v86.efl & 1); +} + +static void +comc_putchar(int c) +{ + v86.ctl = 0; + v86.addr = 0x14; + v86.eax = 0x100 | c; + v86int(); } static int -comc_in(void) +comc_getchar(void) { - if (comiskey()) { - return(comgetc()); + if (comc_ischar()) { + v86.ctl = 0; + v86.addr = 0x14; + v86.eax = 0x300; + v86int(); + return(v86.eax); } else { return(-1); } } + +static int +comc_ischar(void) +{ + v86.ctl = 0; + v86.addr = 0x14; + v86.eax = 0x200; + v86int(); + return(v86.eax & 0x1); +} diff --git a/sys/boot/i386/libi386/comconsole_support.S b/sys/boot/i386/libi386/comconsole_support.S deleted file mode 100644 index a6861dc..0000000 --- a/sys/boot/i386/libi386/comconsole_support.S +++ /dev/null @@ -1,147 +0,0 @@ -/* $NetBSD: comio.S,v 1.2 1997/10/27 19:51:18 drochner Exp $ */ - -/* serial console handling - modelled after code in FreeBSD:sys/i386/boot/netboot/start2.S - */ - -#include - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - - .text - -/************************************************************************** -INIT - Initialization (com number) -**************************************************************************/ -ENTRY(cominit) - push %ebp - mov %esp,%ebp - push %ebx - push %edx - push %esi - push %edi - - movl 8(%ebp), %edx - - call CNAME(prot_to_real) # enter real mode - - # Initialize the serial port (dl) to 9600 baud, 8N1. - movb $0xe3, %al - movb $0, %ah - int $0x14 - mov %ax,%bx - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - mov %bx,%ax - - pop %edi - pop %esi - pop %edx - pop %ebx - pop %ebp - ret - -/************************************************************************** -PUTC - Print a character (char, com number) -**************************************************************************/ -ENTRY(computc) - push %ebp - mov %esp,%ebp - push %ecx - push %ebx - push %edx - push %esi - push %edi - - movb 8(%ebp),%cl - movl 12(%ebp),%edx - - call CNAME(prot_to_real) # enter real mode - - movb %cl,%al - movb $0x01, %ah - int $0x14 - - movb %ah,%bl - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - movb %bl,%al - - pop %edi - pop %esi - pop %edx - pop %ebx - pop %ecx - pop %ebp - ret - -/************************************************************************** -GETC - Get a character (com number) -**************************************************************************/ -ENTRY(comgetc) - push %ebp - mov %esp,%ebp - push %ebx - push %edx - push %esi - push %edi - - movl 8(%ebp),%edx - - call CNAME(prot_to_real) # enter real mode - - movb $0x02, %ah - int $0x14 - movl %eax,%ebx # at run time, it is mov %ax,%bx - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - mov %bx,%ax - - pop %edi - pop %esi - pop %edx - pop %ebx - pop %ebp - ret - -/************************************************************************** -ISKEY - Check for keyboard interrupt (com number) -**************************************************************************/ -ENTRY(comiskey) - push %ebp - mov %esp,%ebp - push %ebx - push %edx - push %esi - push %edi - - movl 8(%ebp),%edx - - call CNAME(prot_to_real) # enter real mode - - movb $0x03, %ah - int $0x14 - mov %ax,%bx - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - mov %bx,%ax - - pop %edi - pop %esi - pop %edx - pop %ebx - pop %ebp - ret diff --git a/sys/boot/i386/libi386/crt/Makefile b/sys/boot/i386/libi386/crt/Makefile deleted file mode 100644 index 400cae8..0000000 --- a/sys/boot/i386/libi386/crt/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIR= bootsect - -.include diff --git a/sys/boot/i386/libi386/crt/bios_disk.S b/sys/boot/i386/libi386/crt/bios_disk.S deleted file mode 100644 index 3e383c5..0000000 --- a/sys/boot/i386/libi386/crt/bios_disk.S +++ /dev/null @@ -1,176 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: bios_disk.S,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ - */ - -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/* extracted from netbsd:sys/arch/i386/boot/bios.S */ - -#include - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -/* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ -ENTRY(biosread) - pushl %ebp - movl %esp, %ebp - pushl %ebx - push %ecx - push %edx - push %esi - push %edi - - movb 16(%ebp), %dh - movw 12(%ebp), %cx - xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl - rorb $2, %cl - movb 20(%ebp), %al - orb %al, %cl - incb %cl # sector; sec starts from 1, not 0 - movb 8(%ebp), %dl # device - movl 28(%ebp), %ebx # offset - # prot_to_real will set %es to BOOTSEG - - call CNAME(prot_to_real) # enter real mode - - movb $0x2, %ah # subfunction - addr32 - movb 24(%ebp), %al # number of sectors - int $0x13 - setc %bl - - data32 - call CNAME(real_to_prot) # back to protected mode - - xorl %eax, %eax - movb %bl, %al # return value in %ax - - pop %edi - pop %esi - pop %edx - pop %ecx - popl %ebx - popl %ebp - ret - -/* -# -# get_diskinfo(): return a word that represents the -# max number of sectors and heads and drives for this device -# -*/ - -ENTRY(get_diskinfo) - pushl %ebp - movl %esp, %ebp - push %es - pushl %ebx - push %ecx - push %edx - push %esi - push %edi - - movb 8(%ebp), %dl # diskinfo(drive #) - - call CNAME(prot_to_real) # enter real mode - - movb $0x08, %ah # ask for disk info - int $0x13 - jnc ok - - /* - * Urk. Call failed. It is not supported for floppies by old BIOS's. - * Guess it's a 15-sector floppy. Initialize all the registers for - * documentation, although we only need head and sector counts. - */ -# subb %ah, %ah # %ax = 0 -# movb %ah, %bh # %bh = 0 -# movb $2, %bl # %bl bits 0-3 = drive type, 2 = 1.2M -# movb $79, %ch # max track - movb $15, %cl # max sector - movb $1, %dh # max head -# movb $1, %dl # # floppy drives installed - # es:di = parameter table - # carry = 0 - -ok: - data32 - call CNAME(real_to_prot) # back to protected mode - - xorl %eax, %eax - - /*form a longword representing all this gunk*/ - movb %dh, %ah # max head - andb $0x3f, %cl # mask of cylinder gunk - movb %cl, %al # max sector (and # sectors) - - pop %edi - pop %esi - pop %edx - pop %ecx - popl %ebx - pop %es - popl %ebp - ret diff --git a/sys/boot/i386/libi386/crt/biosdisk_ll.c b/sys/boot/i386/libi386/crt/biosdisk_ll.c deleted file mode 100644 index b7c77de..0000000 --- a/sys/boot/i386/libi386/crt/biosdisk_ll.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: biosdisk_ll.c,v 1.3 1997/06/13 13:36:06 drochner Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * Copyright (c) 1996 - * Perry E. Metzger. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgements: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * shared by bootsector startup (bootsectmain) and biosdisk.c - * needs lowlevel parts from bios_disk.S - */ - -#include - -#include "biosdisk_ll.h" -#include "diskbuf.h" - -/* XXX prototypes from export header? */ -extern int get_diskinfo(int); -extern int biosread(int, int, int, int, int, char *); - -#define SPT(di) ((di)&0xff) -#define HEADS(di) ((((di)>>8)&0xff)+1) - -int -set_geometry(d) - struct biosdisk_ll *d; -{ - int diskinfo; - - diskinfo = get_diskinfo(d->dev); - - d->spc = (d->spt = SPT(diskinfo)) * HEADS(diskinfo); - - /* - * get_diskinfo assumes floppy if BIOS call fails. Check at least - * "valid" geometry. - */ - return (!d->spc || !d->spt); -} - -/* - * Global shared "diskbuf" is used as read ahead buffer. For reading from - * floppies, the bootstrap has to be loaded on a 64K boundary to ensure that - * this buffer doesn't cross a 64K DMA boundary. - */ -static int ra_dev; -static int ra_end; -static int ra_first; - -int -readsects(d, dblk, num, buf, cold) /* reads ahead if (!cold) */ - struct biosdisk_ll *d; - int dblk, num; - char *buf; - int cold; /* don't use data segment or bss, don't call - * library functions */ -{ - while (num) { - int nsec; - - /* check for usable data in read-ahead buffer */ - if (cold || diskbuf_user != &ra_dev || d->dev != ra_dev - || dblk < ra_first || dblk >= ra_end) { - - /* no, read from disk */ - int cyl, head, sec; - char *trbuf; - - cyl = dblk / d->spc; - head = (dblk % d->spc) / d->spt; - sec = dblk % d->spt; - nsec = d->spt - sec; - - if (cold) { - /* transfer directly to buffer */ - trbuf = buf; - if (nsec > num) - nsec = num; - } else { - /* fill read-ahead buffer */ - trbuf = diskbuf; - if (nsec > diskbuf_size) - nsec = diskbuf_size; - - ra_dev = d->dev; - ra_first = dblk; - ra_end = dblk + nsec; - diskbuf_user = &ra_dev; - } - - if (biosread(d->dev, cyl, head, sec, nsec, trbuf)) { - if (!cold) - diskbuf_user = 0; /* mark invalid */ - return (-1); /* XXX cannot output here if - * (cold) */ - } - } else /* can take blocks from end of read-ahead - * buffer */ - nsec = ra_end - dblk; - - if (!cold) { - /* copy data from read-ahead to user buffer */ - if (nsec > num) - nsec = num; - bcopy(diskbuf + (dblk - ra_first) * BIOSDISK_SECSIZE, - buf, nsec * BIOSDISK_SECSIZE); - } - buf += nsec * BIOSDISK_SECSIZE; - num -= nsec; - dblk += nsec; - } - - return (0); -} diff --git a/sys/boot/i386/libi386/crt/biosdisk_ll.h b/sys/boot/i386/libi386/crt/biosdisk_ll.h deleted file mode 100644 index 7e0782a..0000000 --- a/sys/boot/i386/libi386/crt/biosdisk_ll.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: biosdisk_ll.h,v 1.2 1997/03/22 01:41:36 thorpej Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * Copyright (c) 1996 - * Perry E. Metzger. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgements: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * shared by bootsector startup (bootsectmain) and biosdisk.c needs lowlevel - * parts from bios_disk.S - */ - -struct biosdisk_ll { - int dev; /* BIOS device number */ - int spt, spc; /* geometry */ -}; - -#define BIOSDISK_SECSIZE 512 - -extern int set_geometry(struct biosdisk_ll *); -extern int readsects(struct biosdisk_ll *, int, int, char *, int); diff --git a/sys/boot/i386/libi386/crt/bootsect/Makefile b/sys/boot/i386/libi386/crt/bootsect/Makefile deleted file mode 100644 index 1c04705..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# -# Build a startup module -# - -# Disk buffer size in sectors -CFLAGS+= -DDISKBUFSIZE=18 -# Stack size in bytes -CFLAGS+= -DSTACKSIZE=0x1000 - -PROG= bscrt.o -LDFLAGS= -static -nostartfiles -nostdlib -Xlinker -r -NOMAN= yes - -# Bootblock-specific sources -SRCS= start_bootsect.S fraglist.S bootsectmain.c - -# Includes for libsa support routines XXX fix path! -CFLAGS+= -I${.CURDIR}/../../../../../whole/lib/libstand - -# Common items across all startups -.PATH: ${.CURDIR}/.. -CFLAGS+= -I${.CURDIR}/.. -SRCS+= biosdisk_ll.c bios_disk.S buffers.S - -.include diff --git a/sys/boot/i386/libi386/crt/bootsect/bbinfo.h b/sys/boot/i386/libi386/crt/bootsect/bbinfo.h deleted file mode 100644 index eb313ae..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/bbinfo.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * $Id: bbinfo.h,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ - * From: $NetBSD: bbinfo.h,v 1.3 1997/11/07 16:59:41 drochner Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* data structure shared by bootsector - and installboot - */ - -#ifndef __ASSEMBLER__ - -struct fraglist { - int magic; - int loadsz; /* blocks loaded by primary boot */ - int numentries, maxentries; - struct { - int offset, num; - } entries[1]; -}; - -#endif - -#define FRAGLISTVERSION 0 -#define FRAGLISTMAGIC (0xb00deda5 + FRAGLISTVERSION) - -/* only used by bootsect code (not by installboot) */ -#ifndef MAXFLENTRIES -#define MAXFLENTRIES 20 -#endif -#ifndef PRIM_LOADSZ -#define PRIM_LOADSZ 15 -#endif diff --git a/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c b/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c deleted file mode 100644 index 7c48506..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: bootsectmain.c,v 1.1.1.1 1997/03/14 02:40:34 perry Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* load remainder of boot program - (blocks from fraglist), - start main() - needs lowlevel parts from biosdisk_ll.c - */ - -#include "biosdisk_ll.h" -#include "bbinfo.h" - -int boot_biosdev; /* exported */ - -extern struct fraglist fraglist; -extern char edata[], end[]; - -extern void main(void); - -void bootsectmain(biosdev) -int biosdev; -{ - struct biosdisk_ll d; - int i; - char *buf; - - /* - * load sectors from bootdev - */ - d.dev = biosdev; - set_geometry(&d); - - buf = (char*)(PRIM_LOADSZ * BIOSDISK_SECSIZE); - - for(i = 0; i < fraglist.numentries; i++) { - int dblk, num; - - dblk = fraglist.entries[i].offset; - num = fraglist.entries[i].num; - - if(readsects(&d, dblk, num, buf, 1)) - return; /* halts in start_bootsect.S */ - - buf += num * BIOSDISK_SECSIZE; - } - - /* clear BSS */ - buf = edata; - while(buf < end) *buf++ = 0; - - /* call main() */ - boot_biosdev = biosdev; -/* main(); */ -} diff --git a/sys/boot/i386/libi386/crt/bootsect/fraglist.S b/sys/boot/i386/libi386/crt/bootsect/fraglist.S deleted file mode 100644 index 72ddad4..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/fraglist.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: fraglist.S,v 1.1.1.1 1997/03/14 02:40:34 perry Exp $ */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* space for fragment list - goes to text section - must be loaded by primary boot - */ - -#include "bbinfo.h" - - .text - - .globl _fraglist -_fraglist: - .long FRAGLISTMAGIC - .long PRIM_LOADSZ /* blocks already in memory */ - .long 0 - .long MAXFLENTRIES - . = . + 2 * MAXFLENTRIES * 4 diff --git a/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S b/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S deleted file mode 100644 index 438ae69..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S +++ /dev/null @@ -1,540 +0,0 @@ -/* $NetBSD: start_bootsect.S,v 1.3 1998/02/19 14:15:38 drochner Exp $ */ - -/* BIOS bootsector startup - parts from netbsd:sys/arch/i386/boot/start.S - and freebsd:sys/i386/boot/biosboot/boot2.S - */ - -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include -#define addr32 .byte 0x67 -#define data32 .byte 0x66 -/* #include */ - -#include "bbinfo.h" - -BOOTSEG = 0x0100 # boot will be loaded here (below 640K) -BOOTSTACK = 0xfffc # boot stack -LOADSZ = PRIM_LOADSZ # size of first loaded chunk - -SIGNATURE = 0xaa55 -PARTSTART = 0x1be # starting address of partition table -NUMPART = 4 # number of partitions in partition table -PARTSZ = 16 # sizeof(struct dos_partition) -BSDPART = 0xA5 -BOOTABLE = 0x80 # value of dp_flag, means bootable partition - - .text -_boot1: -ENTRY(start) - # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 - # ljmp to the next instruction to adjust %cs - data32 - ljmp $0x7c0, $start1 - -start1: - # set up %ds - movl %cs, %ax - movl %ax, %ds - - # temporary stack while we locate boot2 - # set up %ss and %esp - data32 - movl $BOOTSEG, %eax - movl %ax, %ss - data32 - movl $BOOTSTACK, %esp - - /*** set up %es, (where we will load boot2 to) ***/ - movl %ax, %es - - # bootstrap passes us drive number in %dl - cmpb $0x80, %dl - data32 - jae hd - -fd: -# reset the disk system - movb $0x00, %ah - int $0x13 - data32 - movl $0x0001, %ecx # cyl 0, sector 1 - movb $0x00, %dh # head - # XXX Override the drive number. - movb $0x00, %dl - data32 - jmp load - -hd: /**** load sector 0 (DOSBBSECTOR) into the BOOTSEG ****/ - data32 - movl $0x0201, %eax - xorl %ebx, %ebx # %bx = 0 - data32 - movl $0x0001, %ecx - data32 - andl $0xff, %edx - /*mov $0x0080, %edx*/ - int $0x13 - data32 - jb read_error - - /***# find the first BSD partition *****/ - data32 - movl $PARTSTART, %ebx - data32 - movl $NUMPART, %ecx -again: - addr32 - movb %es:4(%ebx), %al /* dp_typ */ - cmpb $BSDPART, %al - data32 - je found - data32 - addl $PARTSZ, %ebx - data32 - loop again - - /* didn't find either NetBSD or 386BSD partitions */ - data32 - movl $enoboot, %esi - data32 - jmp err_stop - - -/* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -found: - addr32 - movb %es:1(%ebx), %dh /* head: dp_sdh */ - addr32 - movl %es:2(%ebx), %ecx /*sect, cyl: dp_ssect + (dp_scyl << 8)*/ - -load: - movb $0x2, %ah /* function 2 */ - movb $LOADSZ, %al /* number of blocks */ - xorl %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ - int $0x13 - data32 - jb read_error - - # ljmp to the second stage boot loader (boot2). - # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - # for stack space while we load boot3. - - data32 - ljmp $BOOTSEG, $CNAME(boot2) - -# -# read_error -# - -read_error: - data32 - movl $eread, %esi -err_stop: - data32 - call message - data32 - jmp stop - -# -# message: write the error message in %ds:%esi to console -# - -message: -/* -# BIOS call "INT 10H Function 0Eh" to write character to console -# Call with %ah = 0x0e -# %al = character -# %bh = page -# %bl = foreground color -*/ - data32 - pushl %eax - data32 - pushl %ebx - data32 - pushl %edx - -nextb: - cld - lodsb # load a byte into %al - testb %al, %al - data32 - jz done - - movb $0x0e, %ah - data32 - movl $0x0001, %ebx - int $0x10 - - data32 - jmp nextb - -done: - data32 - popl %edx - data32 - popl %ebx - data32 - popl %eax - data32 - ret - -_ourseg: - .long 0 - -/************************************************************************** -GLOBAL DESCRIPTOR TABLE -**************************************************************************/ - .align 4 -gdt: /* 0x0 */ - .word 0, 0 - .byte 0, 0x00, 0x00, 0 - -/* additional dummy for Linux support (?) */ /* 0x8 */ - .word 0, 0 - .byte 0, 0x00, 0x00, 0 - - /* kernel code segment */ - .globl flatcodeseg -flatcodeseg = . - gdt /* 0x10 */ - .word 0xffff, 0 - .byte 0, 0x9f, 0xcf, 0 - - /* kernel data segment */ - .globl flatdataseg -flatdataseg = . - gdt /* 0x18 */ - .word 0xffff, 0 - .byte 0, 0x93, 0xcf, 0 - - /* boot code segment, will be patched */ -bootcodeseg = . - gdt /* 0x20 */ - .word 0xffff, 0 - .byte 0, 0x9e, 0x40, 0 - - /* boot data segment, will be patched */ -bootdataseg = . - gdt /* 0x28 */ - .word 0xffff, 0 - .byte 0, 0x92, 0x0f, 0 - - /* 16 bit real mode, will be patched */ -bootrealseg = . - gdt /* 0x30 */ - .word 0xffff, 0 - .byte 0, 0x9e, 0x00, 0 -gdtlen = . - gdt - - .align 4 -gdtarg: - .word gdtlen-1 /* limit */ - .long 0 /* addr, will be inserted */ - -_boot2: - data32 - xorl %eax, %eax - movl %cs, %ax - movl %ax, %ds - movl %ax, %es - addr32 - data32 - movl %eax, CNAME(ourseg) - data32 - shll $4, %eax - - /* fix up GDT entries for bootstrap */ -#define FIXUP(gdt_index) \ - addr32; \ - movl %eax, gdt+gdt_index+2; /* actually movw %ax */ \ - addr32; \ - movb %bl, gdt+gdt_index+4 - - data32 - shldl $16, %eax, %ebx - - FIXUP(bootcodeseg) - FIXUP(bootrealseg) - FIXUP(bootdataseg) - - /* fix up GDT pointer */ - data32 - addl $gdt, %eax - addr32 - data32 - movl %eax, gdtarg+2 - - /* change to protected mode */ - data32 - call CNAME(real_to_prot) - - /* move the stack over the top of boot1 while we load */ - movl $_ourseg - 4, %eax - movl %eax, %esp - - movzbl %dl, %edx /* discard head (%dh) and random high bits */ - pushl %edx - call CNAME(bootsectmain) - - /* Go to internal stack */ - movl $CNAME(stacktop), %eax - movl %eax, %esp - call CNAME(main) - - -ENTRY(exit) -stop: - cli - hlt - -eread: .asciz "Read error\r\n" -enoboot: .asciz "No bootable partition\r\n" -endofcode: -/* throw in a partition in case we are block0 as well */ -/* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */ - . = CNAME(boot1) + PARTSTART - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte BOOTABLE,0,1,0,BSDPART,255,255,255 - .long 0,50000 -/* the last 2 bytes in the sector 0 contain the signature */ - . = CNAME(boot1) + 0x1fe - .short SIGNATURE - . = CNAME(boot1) + 0x200 - .globl _disklabel -_disklabel: - . = CNAME(boot1) + 0x400 - - -CR0_PE = 0x1 -/* - * real_to_prot() - * transfer from real mode to protected mode. - */ -ENTRY(real_to_prot) - # guarantee that interrupt is disabled when in prot mode - cli - - # load the gdtr - addr32 - data32 - lgdt gdtarg - - # set the PE bit of CR0 - movl %cr0, %eax - - data32 - orl $CR0_PE, %eax - movl %eax, %cr0 - - # make intrasegment jump to flush the processor pipeline and - # reload CS register - data32 - ljmp $bootcodeseg, $xprot - -xprot: - # we are in USE32 mode now - # set up the protected mode segment registers : DS, SS, ES - movl $bootdataseg, %eax - movl %ax, %ds - movl %ax, %ss - movl %ax, %es - - ret - -/* - * prot_to_real() - * transfer from protected mode to real mode - */ -ENTRY(prot_to_real) - # set up a dummy stack frame for the second seg change. - # Adjust the intersegment jump instruction following - # the clearing of protected mode bit. - # This is self-modifying code, but we need a writable - # code segment, and an intersegment return does not give us that. - - movl _ourseg, %eax - movw %ax, xreal-2 - - # Change to use16 mode. - ljmp $bootrealseg, $x16 - -x16: - # clear the PE bit of CR0 - movl %cr0, %eax - data32 - andl $~CR0_PE, %eax - movl %eax, %cr0 - # Here we have an 16 bits intersegment jump. - .byte 0xea - .word xreal - .word 0 - -xreal: - # we are in real mode now - # set up the real mode segment registers : DS, SS, ES - movl %cs, %ax - movl %ax, %ds - movl %ax, %ss - movl %ax, %es - - sti - data32 - ret - -/* - * pbzero(dst, cnt) - * where dst is a physical address and cnt is the length - */ -ENTRY(pbzero) - pushl %ebp - movl %esp, %ebp - pushl %es - pushl %edi - - cld - - # set %es to point at the flat segment - movl $flatdataseg, %eax - movl %ax, %es - - movl 8(%ebp), %edi # destination - movl 12(%ebp), %ecx # count - xorl %eax, %eax # value - - rep - stosb - - popl %edi - popl %es - popl %ebp - ret - -/* - * vpbcopy(src, dst, cnt) - * where src is a virtual address and dst is a physical address - */ -ENTRY(vpbcopy) - pushl %ebp - movl %esp, %ebp - pushl %es - pushl %esi - pushl %edi - - cld - - # set %es to point at the flat segment - movl $flatdataseg, %eax - movl %ax, %es - - movl 8(%ebp), %esi # source - movl 12(%ebp), %edi # destination - movl 16(%ebp), %ecx # count - - rep - movsb - - popl %edi - popl %esi - popl %es - popl %ebp - ret - -/* - * pvbcopy(src, dst, cnt) - * where src is a physical address and dst is a virtual address - */ -ENTRY(pvbcopy) - pushl %ebp - movl %esp, %ebp - pushl %ds - pushl %esi - pushl %edi - - cld - - # set %ds to point at the flat segment - movl $flatdataseg, %eax - movl %ax, %ds - - movl 8(%ebp), %esi # source - movl 12(%ebp), %edi # destination - movl 16(%ebp), %ecx # count - - rep - movsb - - popl %edi - popl %esi - popl %ds - popl %ebp - ret - -ENTRY(vtophys) - movl _ourseg, %eax - shll $4, %eax - addl 4(%esp), %eax - ret diff --git a/sys/boot/i386/libi386/crt/buffers.S b/sys/boot/i386/libi386/crt/buffers.S deleted file mode 100644 index 9ded63c..0000000 --- a/sys/boot/i386/libi386/crt/buffers.S +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Provide buffer space for various items. - * - * We do this in the text segment so that we can control the location - * of the buffers at the link stage, and thus ensure that they are - * within reach of the real-mode support routines. - * - * It is especially important to have the stack down low so that - * it is reachable from both 32-bit and 16-bit code. - */ - -#include - - .text - .align 4 -ENTRY(diskbuf) - . = CNAME(diskbuf) + (DISKBUFSIZE * 512) -ENTRY(diskbuf_user) - .long 0 -ENTRY(diskbuf_size) - .long DISKBUFSIZE - - .align 4 -ENTRY(stackbase) - . = CNAME(stackbase) + STACKSIZE -ENTRY(stacktop) - .long 0 diff --git a/sys/boot/i386/libi386/crt/diskbuf.h b/sys/boot/i386/libi386/crt/diskbuf.h deleted file mode 100644 index ad4949c..0000000 --- a/sys/boot/i386/libi386/crt/diskbuf.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: diskbuf.h,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* data buffer for BIOS disk / DOS I/O */ - -extern char diskbuf[]; /* client-supplied disk buffer */ -extern void *diskbuf_user; /* using function sets it to unique value to allow check if overwritten*/ -extern int diskbuf_size; /* size of client-supplied buffer in sectors */ diff --git a/sys/boot/i386/libi386/getsecs.c b/sys/boot/i386/libi386/getsecs.c deleted file mode 100644 index 3529c39..0000000 --- a/sys/boot/i386/libi386/getsecs.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: getsecs.c,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ - */ - -/* extracted from netbsd:sys/arch/i386/netboot/misc.c */ - -#include -#include - -#include "libi386.h" - -extern int biosgetrtc __P((u_long*)); - -time_t -time(time_t *tloc) { - /* - * Return the current time (of day) in seconds. - * XXX should be extended to do it "more right" perhaps? - * XXX uses undocumented BCD support from libstand. - */ - - u_long t; - time_t sec; - - if(biosgetrtc(&t)) - panic("RTC invalid"); - - sec = bcd2bin(t & 0xff); - sec *= 60; - t >>= 8; - sec += bcd2bin(t & 0xff); - sec *= 60; - t >>= 8; - sec += bcd2bin(t & 0xff); - - if (tloc != NULL) - *tloc = sec; - return(sec); -} diff --git a/sys/boot/i386/libi386/i386_copy.c b/sys/boot/i386/libi386/i386_copy.c index 53e1c79..0ff98ba 100644 --- a/sys/boot/i386/libi386/i386_copy.c +++ b/sys/boot/i386/libi386/i386_copy.c @@ -9,20 +9,27 @@ #include #include "libi386.h" +#include "btxv86.h" #define READIN_BUF 4096 int i386_copyin(void *src, vm_offset_t dest, size_t len) { - vpbcopy(src, dest, len); + if (dest + len >= memtop) + return(0); + + bcopy(src, PTOV(dest), len); return(len); } int i386_copyout(vm_offset_t src, void *dest, size_t len) { - pvbcopy(src, dest, len); + if (src + len >= memtop) + return(0); + + bcopy(PTOV(src), dest, len); return(len); } @@ -33,6 +40,9 @@ i386_readin(int fd, vm_offset_t dest, size_t len) void *buf; size_t resid, chunk, get, got; + if (dest + len >= memtop) + return(0); + chunk = min(READIN_BUF, len); buf = malloc(chunk); if (buf == NULL) @@ -43,7 +53,7 @@ i386_readin(int fd, vm_offset_t dest, size_t len) got = read(fd, buf, get); if (got <= 0) break; - vpbcopy(buf, dest, chunk); + bcopy(buf, PTOV(dest), chunk); } free(buf); return(len - resid); diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h index 02168fc..0fe5350 100644 --- a/sys/boot/i386/libi386/libi386.h +++ b/sys/boot/i386/libi386/libi386.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: libi386.h,v 1.3 1998/09/03 02:10:09 msmith Exp $ + * $Id: libi386.h,v 1.4 1998/09/14 18:27:05 msmith Exp $ */ @@ -64,24 +64,39 @@ extern struct devdesc currdev; /* our current device */ extern struct devsw biosdisk; /* from crt module */ +#if 0 /* BTX */ extern void vpbcopy(void *src, vm_offset_t dest, size_t size); extern void pvbcopy(vm_offset_t src, void *dest, size_t size); extern void pbzero(vm_offset_t dest, size_t size); extern vm_offset_t vtophys(void *addr); +#endif extern int i386_copyin(void *src, vm_offset_t dest, size_t len); extern int i386_copyout(vm_offset_t src, void *dest, size_t len); extern int i386_readin(int fd, vm_offset_t dest, size_t len); +#if 0 /* BTX */ extern void startprog(vm_offset_t entry, int argc, u_int32_t *argv, vm_offset_t stack); +#endif extern int getbasemem(void); extern int getextmem(void); +extern vm_offset_t memtop; -extern void reboot(void); extern void gateA20(void); extern int i386_autoload(void); extern int bi_getboothowto(char *kargs); extern vm_offset_t bi_copyenv(vm_offset_t addr); + +/* + * BIOS functions from bioscalls.c + */ +extern int BIOS_cominit(int port); +extern int BIOS_computc(int c, int port); +extern int BIOS_comgetc(int port); +extern int BIOS_comisc(int port); +extern int BIOS_diskinfo_old(int drive, int *param); + + diff --git a/sys/boot/i386/libi386/startprog.S b/sys/boot/i386/libi386/startprog.S deleted file mode 100644 index 348341f..0000000 --- a/sys/boot/i386/libi386/startprog.S +++ /dev/null @@ -1,120 +0,0 @@ -/* $NetBSD: startprog.S,v 1.1.1.1 1997/03/14 02:40:33 perry Exp $ */ - -/* starts program in protected mode / flat space - with given stackframe - needs global variables flatcodeseg and flatdataseg - (gdt offsets) - derivied from: NetBSD:sys/arch/i386/boot/asm.S - */ - -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include - -/* - * startprog(phyaddr,argc,argv,stack) - * start the program on protected mode where phyaddr is the entry point - */ -ENTRY(startprog) - pushl %ebp - movl %esp, %ebp - - # prepare a new stack - movl $flatdataseg, %ebx - movw %bx, %es # for arg copy - movl 20(%ebp), %eax # stack - subl $4,%eax - movl %eax, %edi - - # push some number of args onto the stack - movl 12(%ebp), %ecx # argc - - movl %ecx, %eax - decl %eax - shl $2, %eax - addl 16(%ebp), %eax # ptr to last arg - movl %eax, %esi - - std # backwards - rep - movsl - - cld # LynxOS depends on it - - movl 8(%ebp), %ecx # entry - - # set new stackptr (movsl decd sp 1 more -> dummy return address) - movw %bx, %ss - movl %edi, %esp - - # plug in a return address so that FreeBSD detects we are using - # bootinfo - movl $ourreturn, %eax - movl %eax, (%esp) - - # push on our entry address - movl $flatcodeseg, %ebx # segment - pushl %ebx - pushl %ecx #entry - - # convert over the other data segs - movl $flatdataseg, %ebx - movl %bx, %ds - movl %bx, %es - - # convert the PC (and code seg) - lret - -ourreturn: - /* For now there is not much we can do, just lock in a loop */ - jmp ourreturn - diff --git a/sys/boot/i386/libi386/time.c b/sys/boot/i386/libi386/time.c new file mode 100644 index 0000000..51150bd --- /dev/null +++ b/sys/boot/i386/libi386/time.c @@ -0,0 +1,56 @@ +/* + * mjs copyright + */ + +#include +#include + +/* + * Return the time in seconds since the beginning of the day. + * + * If we pass midnight, don't wrap back to 0. + * + * XXX uses undocumented BCD support from libstand. + */ + +time_t +time(time_t *t) +{ + static time_t lasttime, now; + int hr, min, sec; + + v86.ctl = 0; + v86.addr = 0x1a; /* int 0x1a, function 2 */ + v86.eax = 0x0200; + v86int(); + + hr = bcd2bin((v86.ecx & 0xff00) >> 8); /* hour in %ch */ + min = bcd2bin(v86.ecx & 0xff); /* minute in %cl */ + sec = bcd2bin((v86.edx & 0xff00) >> 8); /* second in %dh */ + + now = hr * 3600 + min * 60 + sec; + if (now < lasttime) + now += 24 * 3600; + lasttime = now; + + if (t != NULL) + *t = now; + return(now); +} + +/* + * Use the BIOS Wait function to pause for (period) microseconds. + * + * Resolution of this function is variable, but typically around + * 1ms. + */ +void +delay(int period) +{ + v86.ctl = 0; + v86.addr = 0x15; /* int 0x1a, function 0x86 */ + v86.eax = 0x8600; + v86.ecx = period >> 16; + v86.edx = period & 0xffff; + v86int(); +} diff --git a/sys/boot/i386/libi386/vidconsole.c b/sys/boot/i386/libi386/vidconsole.c index f8903a4..afd2a78 100644 --- a/sys/boot/i386/libi386/vidconsole.c +++ b/sys/boot/i386/libi386/vidconsole.c @@ -26,24 +26,24 @@ * * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp * - * $Id$ + * $Id: vidconsole.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ */ #include +#include +#include +#include "libi386.h" +#if KEYBOARD_PROBE #include -#include "bootstrap.h" - -/* in vidconsole.S */ -extern void vidputc(int c); -extern int kbdgetc(void); -extern int kbdiskey(void); - static int probe_keyboard(void); +#endif static void vidc_probe(struct console *cp); static int vidc_init(int arg); -static int vidc_in(void); +static void vidc_putchar(int c); +static int vidc_getchar(void); +static int vidc_ischar(void); struct console vidconsole = { "vidconsole", @@ -51,9 +51,9 @@ struct console vidconsole = { 0, vidc_probe, vidc_init, - vidputc, - vidc_in, - kbdiskey + vidc_putchar, + vidc_getchar, + vidc_ischar }; static void @@ -61,11 +61,11 @@ vidc_probe(struct console *cp) { /* look for a keyboard */ -#if 0 - if (probe_keyboard()) { -#else - if (1) { +#if KEYBOARD_PROBE + if (probe_keyboard()) #endif + { + cp->c_flags |= C_PRESENTIN; } @@ -79,16 +79,42 @@ vidc_init(int arg) return(0); /* XXX reinit? */ } +static void +vidc_putchar(int c) +{ + v86.ctl = 0; + v86.addr = 0x10; + v86.eax = 0xe00 | c; + v86.ebx = 0x7; + v86int(); +} + static int -vidc_in(void) +vidc_getchar(void) { - if (kbdiskey()) { - return(kbdgetc()); + if (vidc_ischar()) { + v86.ctl = 0; + v86.addr = 0x16; + v86.eax = 0x0; + v86int(); + return(v86.eax); } else { return(-1); } } +static int +vidc_ischar(void) +{ + v86.ctl = 0; + v86.addr = 0x16; + v86.eax = 0x100; + v86int(); + return(v86.eax); +} + +#if KEYBOARD_PROBE + #define PROBE_MAXRETRY 5 #define PROBE_MAXWAIT 400 #define IO_DUMMY 0x84 @@ -197,3 +223,4 @@ probe_keyboard(void) return (1); } +#endif /* KEYBOARD_PROBE */ diff --git a/sys/boot/i386/libi386/vidconsole_support.S b/sys/boot/i386/libi386/vidconsole_support.S deleted file mode 100644 index 2b11171..0000000 --- a/sys/boot/i386/libi386/vidconsole_support.S +++ /dev/null @@ -1,103 +0,0 @@ -/* $Id$ */ - -/* - * PC console handling - * originally from: FreeBSD:sys/i386/boot/netboot/start2.S via NetBSD - */ - -#include - -#define data32 .byte 0x66 - - .text - -/************************************************************************** -PUTC - Print a character -**************************************************************************/ -ENTRY(vidputc) - push %ebp - mov %esp,%ebp - push %ecx - push %ebx - push %esi - push %edi - - movb 8(%ebp),%cl - - call CNAME(prot_to_real) # enter real mode - - movb %cl,%al - data32 - mov $1,%ebx - movb $0x0e,%ah - int $0x10 - - data32 - call CNAME(real_to_prot) # back to protected mode - - pop %edi - pop %esi - pop %ebx - pop %ecx - pop %ebp - ret - -/************************************************************************** -GETC - Get a character -**************************************************************************/ -ENTRY(kbdgetc) - push %ebp - mov %esp,%ebp - push %ebx - push %esi - push %edi - - call CNAME(prot_to_real) # enter real mode - - movb $0x0,%ah - int $0x16 - movb %al,%bl - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - movb %bl,%al - - pop %edi - pop %esi - pop %ebx - pop %ebp - ret - -/************************************************************************** -ISKEY - Check for keyboard interrupt -**************************************************************************/ -ENTRY(kbdiskey) - push %ebp - mov %esp,%ebp - push %ebx - push %esi - push %edi - - call CNAME(prot_to_real) # enter real mode - - xor %ebx,%ebx - movb $0x1,%ah - int $0x16 - data32 - jz 1f - movb %al,%bl -1: - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - movb %bl,%al - - pop %edi - pop %esi - pop %ebx - pop %ebp - ret diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile index 56c9f53..f730e5f 100644 --- a/sys/boot/i386/loader/Makefile +++ b/sys/boot/i386/loader/Makefile @@ -1,40 +1,72 @@ -# $Id: Makefile,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ +# $Id: Makefile,v 1.2 1998/09/14 18:27:06 msmith Exp $ # from $NetBSD: Makefile,v 1.12 1998/02/19 14:18:36 drochner Exp $ -BASE= loader -PROG= ${BASE}.sym +BASE= loader +PROG= ${BASE} NOMAN= NEWVERSWHAT= "bootstrap loader" +# architecture-specific loader code +SRCS= main.c conf.c + # Enable PnP and ISA-PnP code. #HAVE_PNP= yes #HAVE_ISABUS= yes -# architecture-specific loader code -SRCS+= main.c conf.c +# Verbose ls causes extra heap usage +CFLAGS+= -DVERBOSE_LS # Always add MI sources .PATH: ${.CURDIR}/../../common .include <${.CURDIR}/../../common/Makefile.inc> CFLAGS+= -I${.CURDIR}/../../common -# Verbose ls causes extra heap usage -CFLAGS+= -DVERBOSE_LS -CLEANFILES+= vers.c vers.o ${BASE}.list +CLEANFILES+= vers.c vers.o ${BASE}.list setdef0.o setdef1.o setdefs.h \ + gensetdefs.o gensetdefs ${BASE}.bin CFLAGS+= -Wall +LDFLAGS= -nostdlib -static -Ttext 0x1000 +LDADD= -lstand ${LIBI386} # i386 standalone support library LIBI386= ${.OBJDIR}/../libi386/libi386.a CFLAGS+= -I${.CURDIR}/.. -CRT= ${.OBJDIR}/../libi386/crt/bootsect/bscrt.o + +# BTX components +BTXDIR= ${.CURDIR}/../btx +BTXLDR= ${BTXDIR}/btxldr/btxldr +BTXKERN= ${BTXDIR}/btx/btx +BTXCRT= ${BTXDIR}/lib/crt0.o +CFLAGS+= -I${BTXDIR}/lib + +# BTX is expecting ELF components +CFLAGS+= -elf vers.o: sh ${.CURDIR}/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} ${CC} -c vers.c -${BASE}.sym: ${OBJS} ${LIBI386} ${CRT} vers.o - ${LD} -o ${BASE}.sym -M -e _start -N -Ttext 0 ${CRT} ${OBJS} \ - vers.o -lstand ${LIBI386} -lstand >${.OBJDIR}/${BASE}.list +${BASE}: ${BASE}.bin ${BTXLDR} ${BTXKERN} + btxld -v -f aout -e 0x100000 -o ${.TARGET} -l ${BTXLDR} -b ${BTXKERN} ${BASE}.bin + +${BASE}.bin: ${OBJS} ${LIBI386} vers.o setdef0.o setdef1.o + ${LD} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} setdef0.o ${OBJS} vers.o setdef1.o -lstand ${LIBI386} + +setdef0.o: setdefs.h + +setdef1.o: setdefs.h .include + +# Linker set gymnastics +setdefs.h: gensetdefs ${OBJS} + @echo Generating linker sets + @./gensetdefs ${OBJS} >setdefs.h + +gensetdefs: gensetdefs.o + ${CC} -static gensetdefs.o -o $@ + +gensetdefs.o: gensetdefs.c + ${CC} -c $< + + diff --git a/sys/boot/i386/loader/conf.c b/sys/boot/i386/loader/conf.c index 9fc219f..ae969dd 100644 --- a/sys/boot/i386/loader/conf.c +++ b/sys/boot/i386/loader/conf.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: conf.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ + * $Id: conf.c,v 1.2 1998/09/14 18:27:06 msmith Exp $ */ #include @@ -43,7 +43,7 @@ /* Exported for libstand */ struct devsw *devsw[] = { - &biosdisk, +/* &biosdisk, XXX BTX */ /* XXX network devices? */ NULL }; @@ -65,7 +65,7 @@ struct fs_ops *file_system[] = { extern struct module_format i386_aout; struct module_format *module_formats[] = { - &i386_aout, +/* &i386_aout, XXX BTX */ NULL }; diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c index 53f4efe..a2673bb 100644 --- a/sys/boot/i386/loader/main.c +++ b/sys/boot/i386/loader/main.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: main.c,v 1.3 1998/09/03 02:10:09 msmith Exp $ + * $Id: main.c,v 1.4 1998/09/14 18:27:06 msmith Exp $ */ /* @@ -36,8 +36,7 @@ #include "bootstrap.h" #include "libi386/libi386.h" - -extern int boot_biosdev; /* from runtime startup */ +#include "btxv86.h" struct arch_switch archsw; /* MI/MD interface boundary */ @@ -45,8 +44,6 @@ struct arch_switch archsw; /* MI/MD interface boundary */ extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; /* XXX debugging */ -#include "libi386/crt/diskbuf.h" -extern char stackbase, stacktop; extern char end[]; void @@ -56,10 +53,11 @@ main(void) int i; /* - * Initialise the heap as early as possible. Once this is done, alloc() is usable. - * The stack is buried inside us, so this is safe + * Initialise the heap as early as possible. Once this is done, malloc() is usable. + * + * XXX better to locate end of memory and use that */ - setheap((void *)end, (void *)(end + 0x80000)); + setheap((void *)end, (void *)(end + (384 * 1024))); /* * XXX Chicken-and-egg problem; we want to have console output early, but some @@ -89,7 +87,7 @@ main(void) /* We're booting from a BIOS disk, try to spiff this */ currdev.d_dev = devsw[0]; /* XXX presumes that biosdisk is first in devsw */ currdev.d_type = currdev.d_dev->dv_type; - currdev.d_kind.biosdisk.unit = boot_biosdev; + currdev.d_kind.biosdisk.unit = 0; /* XXX wrong, need to get from bootinfo etc. */ currdev.d_kind.biosdisk.slice = -1; /* XXX should be able to detect this, default to autoprobe */ currdev.d_kind.biosdisk.partition = 0; /* default to 'a' */ @@ -121,14 +119,22 @@ command_reboot(int argc, char *argv[]) printf("Rebooting...\n"); delay(1000000); - reboot(); - /* Note: we shouldn't get to this point! */ - panic("Reboot failed!"); - exit(0); + __exit(0); } +/* provide this for panic */ +void +exit(int code) +{ + __exit(code); +} + +#if 0 /* XXX learn to ask BTX */ + COMMAND_SET(stack, "stack", "show stack usage", command_stack); +extern char stackbase, stacktop; + static int command_stack(int argc, char *argv[]) { @@ -141,6 +147,7 @@ command_stack(int argc, char *argv[]) printf("%d bytes of stack used\n", &stacktop - cp); return(CMD_OK); } +#endif COMMAND_SET(heap, "heap", "show heap usage", command_heap); diff --git a/sys/boot/i386/loader/setdef0.c b/sys/boot/i386/loader/setdef0.c new file mode 100644 index 0000000..e2af74e --- /dev/null +++ b/sys/boot/i386/loader/setdef0.c @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 1997 John D. Polstra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: setdef0.c,v 1.2 1997/05/21 23:21:30 jdp Exp $ + */ + +#ifdef __ELF__ + +#include +#include + +/* + * DEFINE_SET creates the section and label for a set, and emits the + * count word at the front of it. + */ +#define DEFINE_SET(set, count) \ + __asm__(".section .set." #set ",\"aw\""); \ + __asm__(".globl " #set); \ + __asm__(".type " #set ",@object"); \ + __asm__(".p2align 2"); \ + __asm__(#set ":"); \ + __asm__(".long " #count); \ + __asm__(".previous") + +#include "setdefs.h" /* Contains a `DEFINE_SET' for each set */ + +#endif /* __ELF__ */ diff --git a/sys/boot/i386/loader/setdef1.c b/sys/boot/i386/loader/setdef1.c new file mode 100644 index 0000000..3f20119 --- /dev/null +++ b/sys/boot/i386/loader/setdef1.c @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 1997 John D. Polstra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: setdef1.c,v 1.2 1997/05/21 23:21:30 jdp Exp $ + */ + +#ifdef __ELF__ + +/* + * DEFINE_SET emits the NULL terminator for a set. + */ +#define DEFINE_SET(set, count) \ + __asm__(".section .set." #set ",\"aw\""); \ + __asm__(".long 0"); \ + __asm__(".previous") + +#include "setdefs.h" /* Contains a `DEFINE_SET' for each set */ + +#endif /* __ELF__ */ diff --git a/sys/boot/i386/loader/version b/sys/boot/i386/loader/version index df29e4e..b923863 100644 --- a/sys/boot/i386/loader/version +++ b/sys/boot/i386/loader/version @@ -1,7 +1,8 @@ -$Id$ +$Id: version,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this file is important. Make sure the current version number is on line 6. +0.2: Initial integration with BTX 0.1: Initial i386 version, inspiration and some structure from the NetBSD version. -- cgit v1.1