summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-10-02 20:53:17 +0000
committermsmith <msmith@FreeBSD.org>1998-10-02 20:53:17 +0000
commit6d472197ec99beea28652e8ef0c17a6f72b25fea (patch)
tree6ba1be3c862ec2003cadb4b86f4b085ea41fca5a
parentf72bb5109c77fca2e22570867dddeb5afa72852f (diff)
downloadFreeBSD-src-6d472197ec99beea28652e8ef0c17a6f72b25fea.zip
FreeBSD-src-6d472197ec99beea28652e8ef0c17a6f72b25fea.tar.gz
Consolidate the bootinfo-loading code, greatly simplifying the _exec
functions.
-rw-r--r--sys/boot/i386/libi386/aout_freebsd.c129
-rw-r--r--sys/boot/i386/libi386/bootinfo.c108
-rw-r--r--sys/boot/i386/libi386/bootinfo32.c108
-rw-r--r--sys/boot/i386/libi386/bootinfo64.c108
-rw-r--r--sys/boot/i386/libi386/elf32_freebsd.c118
-rw-r--r--sys/boot/i386/libi386/elf64_freebsd.c118
-rw-r--r--sys/boot/i386/libi386/elf_freebsd.c118
-rw-r--r--sys/boot/i386/libi386/libi386.h12
8 files changed, 378 insertions, 441 deletions
diff --git a/sys/boot/i386/libi386/aout_freebsd.c b/sys/boot/i386/libi386/aout_freebsd.c
index 2f7c088..b584e93 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.7 1998/09/30 19:42:06 peter Exp $
+ * $Id: aout_freebsd.c,v 1.8 1998/10/02 16:32:45 msmith Exp $
*/
#include <sys/param.h>
@@ -43,8 +43,6 @@ static int aout_exec(struct loaded_module *amp);
struct module_format i386_aout = { aout_loadmodule, aout_exec };
-static struct bootinfo bi;
-
/*
* There is an a.out kernel and one or more a.out modules loaded.
* We wish to start executing the kernel image, so make such
@@ -53,133 +51,32 @@ static struct bootinfo bi;
static int
aout_exec(struct loaded_module *mp)
{
- struct loaded_module *xp;
- struct i386_devdesc *rootdev;
struct module_metadata *md;
struct exec *ehdr;
- u_int32_t argv[6]; /* kernel arguments */
- int major, bootdevnr;
- vm_offset_t addr, entry;
- u_int pad;
- char *rootdevname;
+ vm_offset_t entry, bootinfop;
+ int boothowto, err, bootdev;
+ struct bootinfo *bi;
if ((md = mod_findmetadata(mp, MODINFOMD_AOUTEXEC)) == NULL)
return(EFTYPE); /* XXX actually EFUCKUP */
ehdr = (struct exec *)&(md->md_data);
- /*
- * Allow the environment variable 'rootdev' to override the supplied device
- * This should perhaps go to MI code and/or have $rootdev tested/set by
- * MI code before launching the kernel.
- */
- rootdevname = getenv("rootdev");
- i386_getdev((void **)(&rootdev), rootdevname, NULL);
- if (rootdev == NULL) { /* bad $rootdev/$currdev */
- printf("can't determine root device\n");
- return(EINVAL);
- }
-
- /* Boot from whatever the current device is */
- i386_getdev((void **)(&rootdev), NULL, NULL);
- switch(rootdev->d_type) {
- case DEVT_DISK:
- /* pass in the BIOS device number of the current disk */
- bi.bi_bios_dev = bd_unit2bios(rootdev->d_kind.biosdisk.unit);
- bootdevnr = bd_getdev(rootdev);
- break;
-
- default:
- printf("aout_exec: WARNING - don't know how to boot from device type %d\n", rootdev->d_type);
- }
- free(rootdev);
-
-
- /* legacy bootinfo structure */
- bi.bi_version = BOOTINFO_VERSION;
- bi.bi_kernelname = 0; /* XXX char * -> kernel name */
- bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
- bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
- /* bi.bi_bios_geom[] */
- bi.bi_size = sizeof(bi);
- bi.bi_memsizes_valid = 1;
- bi.bi_vesa = 0; /* XXX correct value? */
- bi.bi_basemem = getbasemem();
- bi.bi_extmem = getextmem();
- bi.bi_symtab = mp->m_addr + ehdr->a_text + ehdr->a_data + ehdr->a_bss;
- bi.bi_esymtab = bi.bi_symtab + sizeof(ehdr->a_syms) + ehdr->a_syms;
-
- /* Device data is kept in the kernel argv array */
- argv[0] = bi_getboothowto(mp->m_args); /* boothowto */
- argv[1] = bootdevnr; /* bootdev */
- argv[2] = 0; /* old cyloffset */
- argv[3] = 0; /* old esym */
- argv[4] = 0; /* "new" bootinfo magic */
- argv[5] = 0; /* physical addr of bootinfo */
-
- /* find the last module in the chain */
- for (xp = mp; xp->m_next != NULL; xp = xp->m_next)
- ;
- addr = xp->m_addr + xp->m_size;
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy our environment */
- bi.bi_envp = addr;
- addr = bi_copyenv(addr);
-
- /*
- * Note, we could move the following onto a seperate page for reclaiming,
- * but the environment is so small and so is this.
- */
-
- /* pad to a 4-byte boundary */
- addr = (addr + 0x3) & ~0x3;
-
- /* leave space for bootinfo */
- argv[5] = (u_int32_t)addr;
- addr += sizeof(struct bootinfo);
-
- /* pad to a 4-byte boundary */
- addr = (addr + 0x3) & ~0x3;
-
- /* save in kernel name */
- bi.bi_kernelname = addr;
- i386_copyin(mp->m_name, addr, strlen(mp->m_name) + 1);
- addr += strlen(mp->m_name) + 1;
-
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy module list and metadata */
- bi.bi_modulep = addr;
- addr = bi_copymodules(addr);
-
- /* all done copying stuff in, save end of loaded object space */
- bi.bi_kernend = addr;
-
- /* and insert bootinfo struct into reserved spot */
- i386_copyin(&bi, (vm_offset_t)argv[5], sizeof(bi));
- argv[0] |= RB_BOOTINFO; /* it's there now */
+ /* XXX allow override? */
+ setenv("kernelname", mp->m_name, 1);
+ if ((err = bi_load(mp->m_args, &boothowto, &bootdev, &bootinfop)) != 0)
+ return(err);
entry = ehdr->a_entry & 0xffffff;
-#ifdef DEBUG
- {
- int i;
- for (i = 0; i < 6; i++)
- printf("argv[%d]=%lx\n", i, argv[i]);
- }
+ bi = (struct bootinfo *)PTOV(bootinfop);
+ bi->bi_symtab = mp->m_addr + ehdr->a_text + ehdr->a_data + ehdr->a_bss;
+ bi->bi_esymtab = bi->bi_symtab + sizeof(ehdr->a_syms) + ehdr->a_syms;
+#ifdef DEBUG
printf("Start @ 0x%lx ...\n", entry);
#endif
- __exec((void *)entry, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
+ __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop);
panic("exec returned");
}
diff --git a/sys/boot/i386/libi386/bootinfo.c b/sys/boot/i386/libi386/bootinfo.c
index 0e0a29a..531c4937 100644
--- a/sys/boot/i386/libi386/bootinfo.c
+++ b/sys/boot/i386/libi386/bootinfo.c
@@ -23,13 +23,18 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bootinfo.c,v 1.4 1998/09/17 23:52:09 msmith Exp $
+ * $Id: bootinfo.c,v 1.5 1998/09/28 21:59:21 peter Exp $
*/
-#include <sys/reboot.h>
#include <stand.h>
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <machine/bootinfo.h>
#include "bootstrap.h"
+#include "libi386.h"
+#include "btxv86.h"
+static struct bootinfo bi;
/*
* Return a 'boothowto' value corresponding to the kernel arguments in
@@ -209,3 +214,102 @@ bi_copymodules(vm_offset_t addr)
MOD_END(addr);
return(addr);
}
+
+/*
+ * Load the information expected by an i386 kernel.
+ *
+ * - The 'boothowto' argument is constructed
+ * - The 'botdev' argument is constructed
+ * - The 'bootinfo' struct is constructed, and copied into the kernel space.
+ * - The kernel environment is copied into kernel space.
+ * - Module metadata are formatted and placed in kernel space.
+ */
+int
+bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
+{
+ struct loaded_module *xp;
+ struct i386_devdesc *rootdev;
+ vm_offset_t addr, bootinfo_addr;
+ char *rootdevname;
+ int bootdevnr;
+ u_int pad;
+ char *kernelname;
+
+ *howtop = bi_getboothowto(args);
+
+ /*
+ * Allow the environment variable 'rootdev' to override the supplied device
+ * This should perhaps go to MI code and/or have $rootdev tested/set by
+ * MI code before launching the kernel.
+ */
+ rootdevname = getenv("rootdev");
+ i386_getdev((void **)(&rootdev), rootdevname, NULL);
+ if (rootdev == NULL) { /* bad $rootdev/$currdev */
+ printf("can't determine root device\n");
+ return(EINVAL);
+ }
+
+ /* Boot from whatever the current device is */
+ i386_getdev((void **)(&rootdev), NULL, NULL);
+ switch(rootdev->d_type) {
+ case DEVT_DISK:
+ /* pass in the BIOS device number of the current disk */
+ bi.bi_bios_dev = bd_unit2bios(rootdev->d_kind.biosdisk.unit);
+ bootdevnr = bd_getdev(rootdev);
+ break;
+
+ default:
+ printf("aout_exec: WARNING - don't know how to boot from device type %d\n", rootdev->d_type);
+ }
+ free(rootdev);
+ *bootdevp = bootdevnr;
+
+ /* legacy bootinfo structure */
+ bi.bi_version = BOOTINFO_VERSION;
+ bi.bi_kernelname = 0; /* XXX char * -> kernel name */
+ bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
+ bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
+ /* bi.bi_bios_geom[] */
+ bi.bi_size = sizeof(bi);
+ bi.bi_memsizes_valid = 1;
+ bi.bi_vesa = 0; /* XXX correct value? */
+ bi.bi_basemem = getbasemem();
+ bi.bi_extmem = getextmem();
+
+ /* find the last module in the chain */
+ for (xp = mod_findmodule(NULL, NULL); xp->m_next != NULL; xp = xp->m_next)
+ ;
+ addr = xp->m_addr + xp->m_size;
+ /* pad to a page boundary */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+
+ /* copy our environment */
+ bi.bi_envp = addr;
+ addr = bi_copyenv(addr);
+
+ /* pad to a page boundary */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+ /* copy module list and metadata */
+ bi.bi_modulep = addr;
+ addr = bi_copymodules(addr);
+
+ /* all done copying stuff in, save end of loaded object space */
+ bi.bi_kernend = addr;
+
+ *howtop |= RB_BOOTINFO; /* it's there now */
+
+ kernelname = getenv("kernelname");
+ bi.bi_kernelname = VTOP(kernelname);
+ *bip = VTOP(&bi);
+
+ return(0);
+}
+
diff --git a/sys/boot/i386/libi386/bootinfo32.c b/sys/boot/i386/libi386/bootinfo32.c
index 0e0a29a..531c4937 100644
--- a/sys/boot/i386/libi386/bootinfo32.c
+++ b/sys/boot/i386/libi386/bootinfo32.c
@@ -23,13 +23,18 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bootinfo.c,v 1.4 1998/09/17 23:52:09 msmith Exp $
+ * $Id: bootinfo.c,v 1.5 1998/09/28 21:59:21 peter Exp $
*/
-#include <sys/reboot.h>
#include <stand.h>
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <machine/bootinfo.h>
#include "bootstrap.h"
+#include "libi386.h"
+#include "btxv86.h"
+static struct bootinfo bi;
/*
* Return a 'boothowto' value corresponding to the kernel arguments in
@@ -209,3 +214,102 @@ bi_copymodules(vm_offset_t addr)
MOD_END(addr);
return(addr);
}
+
+/*
+ * Load the information expected by an i386 kernel.
+ *
+ * - The 'boothowto' argument is constructed
+ * - The 'botdev' argument is constructed
+ * - The 'bootinfo' struct is constructed, and copied into the kernel space.
+ * - The kernel environment is copied into kernel space.
+ * - Module metadata are formatted and placed in kernel space.
+ */
+int
+bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
+{
+ struct loaded_module *xp;
+ struct i386_devdesc *rootdev;
+ vm_offset_t addr, bootinfo_addr;
+ char *rootdevname;
+ int bootdevnr;
+ u_int pad;
+ char *kernelname;
+
+ *howtop = bi_getboothowto(args);
+
+ /*
+ * Allow the environment variable 'rootdev' to override the supplied device
+ * This should perhaps go to MI code and/or have $rootdev tested/set by
+ * MI code before launching the kernel.
+ */
+ rootdevname = getenv("rootdev");
+ i386_getdev((void **)(&rootdev), rootdevname, NULL);
+ if (rootdev == NULL) { /* bad $rootdev/$currdev */
+ printf("can't determine root device\n");
+ return(EINVAL);
+ }
+
+ /* Boot from whatever the current device is */
+ i386_getdev((void **)(&rootdev), NULL, NULL);
+ switch(rootdev->d_type) {
+ case DEVT_DISK:
+ /* pass in the BIOS device number of the current disk */
+ bi.bi_bios_dev = bd_unit2bios(rootdev->d_kind.biosdisk.unit);
+ bootdevnr = bd_getdev(rootdev);
+ break;
+
+ default:
+ printf("aout_exec: WARNING - don't know how to boot from device type %d\n", rootdev->d_type);
+ }
+ free(rootdev);
+ *bootdevp = bootdevnr;
+
+ /* legacy bootinfo structure */
+ bi.bi_version = BOOTINFO_VERSION;
+ bi.bi_kernelname = 0; /* XXX char * -> kernel name */
+ bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
+ bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
+ /* bi.bi_bios_geom[] */
+ bi.bi_size = sizeof(bi);
+ bi.bi_memsizes_valid = 1;
+ bi.bi_vesa = 0; /* XXX correct value? */
+ bi.bi_basemem = getbasemem();
+ bi.bi_extmem = getextmem();
+
+ /* find the last module in the chain */
+ for (xp = mod_findmodule(NULL, NULL); xp->m_next != NULL; xp = xp->m_next)
+ ;
+ addr = xp->m_addr + xp->m_size;
+ /* pad to a page boundary */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+
+ /* copy our environment */
+ bi.bi_envp = addr;
+ addr = bi_copyenv(addr);
+
+ /* pad to a page boundary */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+ /* copy module list and metadata */
+ bi.bi_modulep = addr;
+ addr = bi_copymodules(addr);
+
+ /* all done copying stuff in, save end of loaded object space */
+ bi.bi_kernend = addr;
+
+ *howtop |= RB_BOOTINFO; /* it's there now */
+
+ kernelname = getenv("kernelname");
+ bi.bi_kernelname = VTOP(kernelname);
+ *bip = VTOP(&bi);
+
+ return(0);
+}
+
diff --git a/sys/boot/i386/libi386/bootinfo64.c b/sys/boot/i386/libi386/bootinfo64.c
index 0e0a29a..531c4937 100644
--- a/sys/boot/i386/libi386/bootinfo64.c
+++ b/sys/boot/i386/libi386/bootinfo64.c
@@ -23,13 +23,18 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bootinfo.c,v 1.4 1998/09/17 23:52:09 msmith Exp $
+ * $Id: bootinfo.c,v 1.5 1998/09/28 21:59:21 peter Exp $
*/
-#include <sys/reboot.h>
#include <stand.h>
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <machine/bootinfo.h>
#include "bootstrap.h"
+#include "libi386.h"
+#include "btxv86.h"
+static struct bootinfo bi;
/*
* Return a 'boothowto' value corresponding to the kernel arguments in
@@ -209,3 +214,102 @@ bi_copymodules(vm_offset_t addr)
MOD_END(addr);
return(addr);
}
+
+/*
+ * Load the information expected by an i386 kernel.
+ *
+ * - The 'boothowto' argument is constructed
+ * - The 'botdev' argument is constructed
+ * - The 'bootinfo' struct is constructed, and copied into the kernel space.
+ * - The kernel environment is copied into kernel space.
+ * - Module metadata are formatted and placed in kernel space.
+ */
+int
+bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
+{
+ struct loaded_module *xp;
+ struct i386_devdesc *rootdev;
+ vm_offset_t addr, bootinfo_addr;
+ char *rootdevname;
+ int bootdevnr;
+ u_int pad;
+ char *kernelname;
+
+ *howtop = bi_getboothowto(args);
+
+ /*
+ * Allow the environment variable 'rootdev' to override the supplied device
+ * This should perhaps go to MI code and/or have $rootdev tested/set by
+ * MI code before launching the kernel.
+ */
+ rootdevname = getenv("rootdev");
+ i386_getdev((void **)(&rootdev), rootdevname, NULL);
+ if (rootdev == NULL) { /* bad $rootdev/$currdev */
+ printf("can't determine root device\n");
+ return(EINVAL);
+ }
+
+ /* Boot from whatever the current device is */
+ i386_getdev((void **)(&rootdev), NULL, NULL);
+ switch(rootdev->d_type) {
+ case DEVT_DISK:
+ /* pass in the BIOS device number of the current disk */
+ bi.bi_bios_dev = bd_unit2bios(rootdev->d_kind.biosdisk.unit);
+ bootdevnr = bd_getdev(rootdev);
+ break;
+
+ default:
+ printf("aout_exec: WARNING - don't know how to boot from device type %d\n", rootdev->d_type);
+ }
+ free(rootdev);
+ *bootdevp = bootdevnr;
+
+ /* legacy bootinfo structure */
+ bi.bi_version = BOOTINFO_VERSION;
+ bi.bi_kernelname = 0; /* XXX char * -> kernel name */
+ bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
+ bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
+ /* bi.bi_bios_geom[] */
+ bi.bi_size = sizeof(bi);
+ bi.bi_memsizes_valid = 1;
+ bi.bi_vesa = 0; /* XXX correct value? */
+ bi.bi_basemem = getbasemem();
+ bi.bi_extmem = getextmem();
+
+ /* find the last module in the chain */
+ for (xp = mod_findmodule(NULL, NULL); xp->m_next != NULL; xp = xp->m_next)
+ ;
+ addr = xp->m_addr + xp->m_size;
+ /* pad to a page boundary */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+
+ /* copy our environment */
+ bi.bi_envp = addr;
+ addr = bi_copyenv(addr);
+
+ /* pad to a page boundary */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+ /* copy module list and metadata */
+ bi.bi_modulep = addr;
+ addr = bi_copymodules(addr);
+
+ /* all done copying stuff in, save end of loaded object space */
+ bi.bi_kernend = addr;
+
+ *howtop |= RB_BOOTINFO; /* it's there now */
+
+ kernelname = getenv("kernelname");
+ bi.bi_kernelname = VTOP(kernelname);
+ *bip = VTOP(&bi);
+
+ return(0);
+}
+
diff --git a/sys/boot/i386/libi386/elf32_freebsd.c b/sys/boot/i386/libi386/elf32_freebsd.c
index 56f5936..86a8f2b 100644
--- a/sys/boot/i386/libi386/elf32_freebsd.c
+++ b/sys/boot/i386/libi386/elf32_freebsd.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: elf_freebsd.c,v 1.1 1998/09/30 19:48:09 peter Exp $
+ * $Id: elf_freebsd.c,v 1.2 1998/10/02 08:04:56 peter Exp $
*/
#include <sys/param.h>
@@ -53,35 +53,23 @@ static struct bootinfo bi;
static int
elf_exec(struct loaded_module *mp)
{
- struct loaded_module *xp;
- struct i386_devdesc *currdev;
struct module_metadata *md;
Elf_Ehdr *ehdr;
- u_int32_t argv[6]; /* kernel arguments */
- int major, bootdevnr;
- vm_offset_t addr, entry;
- u_int pad;
- vm_offset_t ssym, esym, *symptr;
+ vm_offset_t entry, bootinfop;
+ int boothowto, err, bootdev;
+ struct bootinfo *bi;
+ vm_offset_t ssym, esym;
if ((md = mod_findmetadata(mp, MODINFOMD_ELFHDR)) == NULL)
return(EFTYPE); /* XXX actually EFUCKUP */
ehdr = (Elf_Ehdr *)&(md->md_data);
- /* Boot from whatever the current device is */
- i386_getdev((void **)(&currdev), NULL, NULL);
- switch(currdev->d_type) {
- case DEVT_DISK:
- major = 0; /* XXX work out the best possible major here */
- bootdevnr = MAKEBOOTDEV(major,
- currdev->d_kind.biosdisk.slice >> 4,
- currdev->d_kind.biosdisk.slice & 0xf,
- currdev->d_kind.biosdisk.unit,
- currdev->d_kind.biosdisk.partition);
- break;
- default:
- printf("elf_exec: WARNING - don't know how to boot from device type %d\n", currdev->d_type);
- }
- free(currdev);
+ /* XXX allow override? */
+ setenv("kernelname", mp->m_name, 1);
+
+ if ((err = bi_load(mp->m_args, &boothowto, &bootdev, &bootinfop)) != 0)
+ return(err);
+ entry = ehdr->e_entry & 0xffffff;
if ((md = mod_findmetadata(mp, MODINFOMD_ELFSSYM)) != NULL)
ssym = *((vm_offset_t *)&(md->md_data));
@@ -90,92 +78,16 @@ elf_exec(struct loaded_module *mp)
if (ssym == 0 || esym == 0)
ssym = esym = 0; /* sanity */
- /* legacy bootinfo structure */
- bi.bi_version = BOOTINFO_VERSION;
- bi.bi_kernelname = 0; /* XXX char * -> kernel name */
- bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
- bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
- /* bi.bi_bios_geom[] */
- bi.bi_size = sizeof(bi);
- bi.bi_memsizes_valid = 1;
- bi.bi_vesa = 0; /* XXX correct value? */
- bi.bi_basemem = getbasemem();
- bi.bi_extmem = getextmem();
- bi.bi_symtab = ssym;
- bi.bi_esymtab = esym;
-
- /* Device data is kept in the kernel argv array */
- argv[0] = bi_getboothowto(mp->m_args); /* boothowto */
- argv[1] = bootdevnr; /* bootdev */
- argv[2] = 0; /* old cyloffset */
- argv[3] = 0; /* old esym */
- argv[4] = 0; /* "new" bootinfo magic */
- argv[5] = 0; /* physical addr of bootinfo */
-
- /* find the last module in the chain */
- for (xp = mp; xp->m_next != NULL; xp = xp->m_next)
- ;
- addr = xp->m_addr + xp->m_size;
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy our environment */
- bi.bi_envp = addr;
- addr = bi_copyenv(addr);
-
- /*
- * Note, we could move the following onto a seperate page for reclaiming,
- * but the environment is so small and so is this.
- */
-
- /* pad to a 4-byte boundary */
- addr = (addr + 0x3) & ~0x3;
-
- /* leave space for bootinfo */
- argv[5] = (u_int32_t)addr;
- addr += sizeof(struct bootinfo);
+ bi = (struct bootinfo *)PTOV(bootinfop);
+ bi->bi_symtab = ssym;
+ bi->bi_esymtab = esym;
- /* pad to a 4-byte boundary */
- addr = (addr + 0x3) & ~0x3;
-
- /* save in kernel name */
- bi.bi_kernelname = addr;
- i386_copyin(mp->m_name, addr, strlen(mp->m_name) + 1);
- addr += strlen(mp->m_name) + 1;
-
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy module list and metadata */
- bi.bi_modulep = addr;
- addr = bi_copymodules(addr);
-
- /* all done copying stuff in, save end of loaded object space */
- bi.bi_kernend = addr;
-
- /* and insert bootinfo struct into reserved spot */
- i386_copyin(&bi, (vm_offset_t)argv[5], sizeof(bi));
- argv[0] |= RB_BOOTINFO; /* it's there now */
-
- entry = ehdr->e_entry & 0xffffff;
#ifdef DEBUG
- {
- int i;
- for (i = 0; i < 6; i++)
- printf("argv[%d]=%lx\n", i, argv[i]);
- }
-
printf("Start @ 0x%lx ...\n", entry);
#endif
- __exec((void *)entry, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
+ __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop);
panic("exec returned");
}
diff --git a/sys/boot/i386/libi386/elf64_freebsd.c b/sys/boot/i386/libi386/elf64_freebsd.c
index 56f5936..86a8f2b 100644
--- a/sys/boot/i386/libi386/elf64_freebsd.c
+++ b/sys/boot/i386/libi386/elf64_freebsd.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: elf_freebsd.c,v 1.1 1998/09/30 19:48:09 peter Exp $
+ * $Id: elf_freebsd.c,v 1.2 1998/10/02 08:04:56 peter Exp $
*/
#include <sys/param.h>
@@ -53,35 +53,23 @@ static struct bootinfo bi;
static int
elf_exec(struct loaded_module *mp)
{
- struct loaded_module *xp;
- struct i386_devdesc *currdev;
struct module_metadata *md;
Elf_Ehdr *ehdr;
- u_int32_t argv[6]; /* kernel arguments */
- int major, bootdevnr;
- vm_offset_t addr, entry;
- u_int pad;
- vm_offset_t ssym, esym, *symptr;
+ vm_offset_t entry, bootinfop;
+ int boothowto, err, bootdev;
+ struct bootinfo *bi;
+ vm_offset_t ssym, esym;
if ((md = mod_findmetadata(mp, MODINFOMD_ELFHDR)) == NULL)
return(EFTYPE); /* XXX actually EFUCKUP */
ehdr = (Elf_Ehdr *)&(md->md_data);
- /* Boot from whatever the current device is */
- i386_getdev((void **)(&currdev), NULL, NULL);
- switch(currdev->d_type) {
- case DEVT_DISK:
- major = 0; /* XXX work out the best possible major here */
- bootdevnr = MAKEBOOTDEV(major,
- currdev->d_kind.biosdisk.slice >> 4,
- currdev->d_kind.biosdisk.slice & 0xf,
- currdev->d_kind.biosdisk.unit,
- currdev->d_kind.biosdisk.partition);
- break;
- default:
- printf("elf_exec: WARNING - don't know how to boot from device type %d\n", currdev->d_type);
- }
- free(currdev);
+ /* XXX allow override? */
+ setenv("kernelname", mp->m_name, 1);
+
+ if ((err = bi_load(mp->m_args, &boothowto, &bootdev, &bootinfop)) != 0)
+ return(err);
+ entry = ehdr->e_entry & 0xffffff;
if ((md = mod_findmetadata(mp, MODINFOMD_ELFSSYM)) != NULL)
ssym = *((vm_offset_t *)&(md->md_data));
@@ -90,92 +78,16 @@ elf_exec(struct loaded_module *mp)
if (ssym == 0 || esym == 0)
ssym = esym = 0; /* sanity */
- /* legacy bootinfo structure */
- bi.bi_version = BOOTINFO_VERSION;
- bi.bi_kernelname = 0; /* XXX char * -> kernel name */
- bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
- bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
- /* bi.bi_bios_geom[] */
- bi.bi_size = sizeof(bi);
- bi.bi_memsizes_valid = 1;
- bi.bi_vesa = 0; /* XXX correct value? */
- bi.bi_basemem = getbasemem();
- bi.bi_extmem = getextmem();
- bi.bi_symtab = ssym;
- bi.bi_esymtab = esym;
-
- /* Device data is kept in the kernel argv array */
- argv[0] = bi_getboothowto(mp->m_args); /* boothowto */
- argv[1] = bootdevnr; /* bootdev */
- argv[2] = 0; /* old cyloffset */
- argv[3] = 0; /* old esym */
- argv[4] = 0; /* "new" bootinfo magic */
- argv[5] = 0; /* physical addr of bootinfo */
-
- /* find the last module in the chain */
- for (xp = mp; xp->m_next != NULL; xp = xp->m_next)
- ;
- addr = xp->m_addr + xp->m_size;
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy our environment */
- bi.bi_envp = addr;
- addr = bi_copyenv(addr);
-
- /*
- * Note, we could move the following onto a seperate page for reclaiming,
- * but the environment is so small and so is this.
- */
-
- /* pad to a 4-byte boundary */
- addr = (addr + 0x3) & ~0x3;
-
- /* leave space for bootinfo */
- argv[5] = (u_int32_t)addr;
- addr += sizeof(struct bootinfo);
+ bi = (struct bootinfo *)PTOV(bootinfop);
+ bi->bi_symtab = ssym;
+ bi->bi_esymtab = esym;
- /* pad to a 4-byte boundary */
- addr = (addr + 0x3) & ~0x3;
-
- /* save in kernel name */
- bi.bi_kernelname = addr;
- i386_copyin(mp->m_name, addr, strlen(mp->m_name) + 1);
- addr += strlen(mp->m_name) + 1;
-
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy module list and metadata */
- bi.bi_modulep = addr;
- addr = bi_copymodules(addr);
-
- /* all done copying stuff in, save end of loaded object space */
- bi.bi_kernend = addr;
-
- /* and insert bootinfo struct into reserved spot */
- i386_copyin(&bi, (vm_offset_t)argv[5], sizeof(bi));
- argv[0] |= RB_BOOTINFO; /* it's there now */
-
- entry = ehdr->e_entry & 0xffffff;
#ifdef DEBUG
- {
- int i;
- for (i = 0; i < 6; i++)
- printf("argv[%d]=%lx\n", i, argv[i]);
- }
-
printf("Start @ 0x%lx ...\n", entry);
#endif
- __exec((void *)entry, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
+ __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop);
panic("exec returned");
}
diff --git a/sys/boot/i386/libi386/elf_freebsd.c b/sys/boot/i386/libi386/elf_freebsd.c
index 56f5936..86a8f2b 100644
--- a/sys/boot/i386/libi386/elf_freebsd.c
+++ b/sys/boot/i386/libi386/elf_freebsd.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: elf_freebsd.c,v 1.1 1998/09/30 19:48:09 peter Exp $
+ * $Id: elf_freebsd.c,v 1.2 1998/10/02 08:04:56 peter Exp $
*/
#include <sys/param.h>
@@ -53,35 +53,23 @@ static struct bootinfo bi;
static int
elf_exec(struct loaded_module *mp)
{
- struct loaded_module *xp;
- struct i386_devdesc *currdev;
struct module_metadata *md;
Elf_Ehdr *ehdr;
- u_int32_t argv[6]; /* kernel arguments */
- int major, bootdevnr;
- vm_offset_t addr, entry;
- u_int pad;
- vm_offset_t ssym, esym, *symptr;
+ vm_offset_t entry, bootinfop;
+ int boothowto, err, bootdev;
+ struct bootinfo *bi;
+ vm_offset_t ssym, esym;
if ((md = mod_findmetadata(mp, MODINFOMD_ELFHDR)) == NULL)
return(EFTYPE); /* XXX actually EFUCKUP */
ehdr = (Elf_Ehdr *)&(md->md_data);
- /* Boot from whatever the current device is */
- i386_getdev((void **)(&currdev), NULL, NULL);
- switch(currdev->d_type) {
- case DEVT_DISK:
- major = 0; /* XXX work out the best possible major here */
- bootdevnr = MAKEBOOTDEV(major,
- currdev->d_kind.biosdisk.slice >> 4,
- currdev->d_kind.biosdisk.slice & 0xf,
- currdev->d_kind.biosdisk.unit,
- currdev->d_kind.biosdisk.partition);
- break;
- default:
- printf("elf_exec: WARNING - don't know how to boot from device type %d\n", currdev->d_type);
- }
- free(currdev);
+ /* XXX allow override? */
+ setenv("kernelname", mp->m_name, 1);
+
+ if ((err = bi_load(mp->m_args, &boothowto, &bootdev, &bootinfop)) != 0)
+ return(err);
+ entry = ehdr->e_entry & 0xffffff;
if ((md = mod_findmetadata(mp, MODINFOMD_ELFSSYM)) != NULL)
ssym = *((vm_offset_t *)&(md->md_data));
@@ -90,92 +78,16 @@ elf_exec(struct loaded_module *mp)
if (ssym == 0 || esym == 0)
ssym = esym = 0; /* sanity */
- /* legacy bootinfo structure */
- bi.bi_version = BOOTINFO_VERSION;
- bi.bi_kernelname = 0; /* XXX char * -> kernel name */
- bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
- bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
- /* bi.bi_bios_geom[] */
- bi.bi_size = sizeof(bi);
- bi.bi_memsizes_valid = 1;
- bi.bi_vesa = 0; /* XXX correct value? */
- bi.bi_basemem = getbasemem();
- bi.bi_extmem = getextmem();
- bi.bi_symtab = ssym;
- bi.bi_esymtab = esym;
-
- /* Device data is kept in the kernel argv array */
- argv[0] = bi_getboothowto(mp->m_args); /* boothowto */
- argv[1] = bootdevnr; /* bootdev */
- argv[2] = 0; /* old cyloffset */
- argv[3] = 0; /* old esym */
- argv[4] = 0; /* "new" bootinfo magic */
- argv[5] = 0; /* physical addr of bootinfo */
-
- /* find the last module in the chain */
- for (xp = mp; xp->m_next != NULL; xp = xp->m_next)
- ;
- addr = xp->m_addr + xp->m_size;
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy our environment */
- bi.bi_envp = addr;
- addr = bi_copyenv(addr);
-
- /*
- * Note, we could move the following onto a seperate page for reclaiming,
- * but the environment is so small and so is this.
- */
-
- /* pad to a 4-byte boundary */
- addr = (addr + 0x3) & ~0x3;
-
- /* leave space for bootinfo */
- argv[5] = (u_int32_t)addr;
- addr += sizeof(struct bootinfo);
+ bi = (struct bootinfo *)PTOV(bootinfop);
+ bi->bi_symtab = ssym;
+ bi->bi_esymtab = esym;
- /* pad to a 4-byte boundary */
- addr = (addr + 0x3) & ~0x3;
-
- /* save in kernel name */
- bi.bi_kernelname = addr;
- i386_copyin(mp->m_name, addr, strlen(mp->m_name) + 1);
- addr += strlen(mp->m_name) + 1;
-
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy module list and metadata */
- bi.bi_modulep = addr;
- addr = bi_copymodules(addr);
-
- /* all done copying stuff in, save end of loaded object space */
- bi.bi_kernend = addr;
-
- /* and insert bootinfo struct into reserved spot */
- i386_copyin(&bi, (vm_offset_t)argv[5], sizeof(bi));
- argv[0] |= RB_BOOTINFO; /* it's there now */
-
- entry = ehdr->e_entry & 0xffffff;
#ifdef DEBUG
- {
- int i;
- for (i = 0; i < 6; i++)
- printf("argv[%d]=%lx\n", i, argv[i]);
- }
-
printf("Start @ 0x%lx ...\n", entry);
#endif
- __exec((void *)entry, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
+ __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop);
panic("exec returned");
}
diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h
index 0ff88c3..3933323 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.6 1998/09/26 10:51:38 dfr Exp $
+ * $Id: libi386.h,v 1.7 1998/10/02 16:32:45 msmith Exp $
*/
@@ -81,14 +81,6 @@ 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);
+extern int bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip);
OpenPOWER on IntegriCloud