diff options
Diffstat (limited to 'stand/i386/loader/main.c')
-rw-r--r-- | stand/i386/loader/main.c | 99 |
1 files changed, 45 insertions, 54 deletions
diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c index cb716d7a9f21..a70b3a253b90 100644 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * MD bootstrap main() and assorted miscellaneous * commands. @@ -53,33 +50,46 @@ __FBSDID("$FreeBSD$"); #include "libzfs.h" #endif -CTASSERT(sizeof(struct bootargs) == BOOTARGS_SIZE); -CTASSERT(offsetof(struct bootargs, bootinfo) == BA_BOOTINFO); -CTASSERT(offsetof(struct bootargs, bootflags) == BA_BOOTFLAGS); -CTASSERT(offsetof(struct bootinfo, bi_size) == BI_SIZE); +_Static_assert(sizeof(struct bootargs) == BOOTARGS_SIZE, "Bootarg size bad"); +_Static_assert(offsetof(struct bootargs, bootinfo) == BA_BOOTINFO, "BA_BOOTINFO"); +_Static_assert(offsetof(struct bootargs, bootflags) == BA_BOOTFLAGS, "BA_BOOTFLAGS"); +_Static_assert(offsetof(struct bootinfo, bi_size) == BI_SIZE, "BI_SIZE"); /* Arguments passed in from the boot1/boot2 loader */ static struct bootargs *kargs; - static uint32_t initial_howto; static uint32_t initial_bootdev; static struct bootinfo *initial_bootinfo; -struct arch_switch archsw; /* MI/MD interface boundary */ - -static void extract_currdev(void); static int isa_inb(int port); static void isa_outb(int port, int value); + +#ifdef LOADER_ZFS_SUPPORT +struct zfs_boot_args *zargs; +static void i386_zfs_probe(void); +#endif + +struct arch_switch archsw = { /* MI/MD interface boundary */ + .arch_autoload = i386_autoload, + .arch_getdev = i386_getdev, + .arch_copyin = i386_copyin, + .arch_copyout = i386_copyout, + .arch_readin = i386_readin, + .arch_isainb = isa_inb, + .arch_isaoutb = isa_outb, + .arch_hypervisor = x86_hypervisor, +#ifdef LOADER_ZFS_SUPPORT + .arch_zfs_probe = i386_zfs_probe, +#endif +}; + +static void extract_currdev(void); void exit(int code); #ifdef LOADER_GELI_SUPPORT #include "geliboot.h" struct geli_boot_args *gargs; struct geli_boot_data *gbdata; #endif -#ifdef LOADER_ZFS_SUPPORT -struct zfs_boot_args *zargs; -static void i386_zfs_probe(void); -#endif /* XXX debugging */ extern char end[]; @@ -96,8 +106,6 @@ ptov(uintptr_t x) int main(void) { - int i; - /* Pick up arguments */ kargs = (void *)__args; initial_howto = kargs->howto; @@ -115,7 +123,7 @@ main(void) */ bios_getmem(); -#if defined(LOADER_BZIP2_SUPPORT) || defined(LOADER_FIREWIRE_SUPPORT) || \ +#if defined(LOADER_BZIP2_SUPPORT) || \ defined(LOADER_GPT_SUPPORT) || defined(LOADER_ZFS_SUPPORT) if (high_heap_size > 0) { heap_top = PTOV(high_heap_base + high_heap_size); @@ -166,7 +174,7 @@ main(void) /* Set up currdev variable to have hooks in place. */ env_setenv("currdev", EV_VOLATILE | EV_NOHOOK, "", - i386_setcurrdev, env_nounset); + gen_setcurrdev, env_nounset); /* * Initialise the block cache. Set the upper limit. @@ -188,19 +196,9 @@ main(void) bc_add(initial_bootdev); } - archsw.arch_autoload = i386_autoload; - archsw.arch_getdev = i386_getdev; - archsw.arch_copyin = i386_copyin; - archsw.arch_copyout = i386_copyout; - archsw.arch_readin = i386_readin; - archsw.arch_isainb = isa_inb; - archsw.arch_isaoutb = isa_outb; - archsw.arch_hypervisor = x86_hypervisor; #ifdef LOADER_ZFS_SUPPORT - archsw.arch_zfs_probe = i386_zfs_probe; - /* - * zfsboot and gptzfsboot have always passed KARGS_FLAGS_ZFS, + * gptzfsboot has always passed KARGS_FLAGS_ZFS, * so if that is set along with KARGS_FLAGS_EXTARG we know we * can interpret the extarg data as a struct zfs_boot_args. */ @@ -244,12 +242,7 @@ main(void) import_geli_boot_data(gbdata); #endif /* LOADER_GELI_SUPPORT */ - /* - * March through the device switch probing for things. - */ - for (i = 0; devsw[i] != NULL; i++) - if (devsw[i]->dv_init != NULL) - (devsw[i]->dv_init)(); + devinit(); printf("BIOS %dkB/%dkB available memory\n", bios_basemem / 1024, bios_extmem / 1024); @@ -258,6 +251,9 @@ main(void) initial_bootinfo->bi_extmem = bios_extmem / 1024; } + /* detect MEMDISK virtual disks */ + biosmemdisk_detect(); + /* detect SMBIOS for future reference */ smbios_detect(NULL); @@ -308,8 +304,8 @@ extract_currdev(void) new_currdev.dd.d_unit = 0; } else { /* we don't know what our boot device is */ - new_currdev.d_kind.biosdisk.slice = -1; - new_currdev.d_kind.biosdisk.partition = 0; + new_currdev.disk.d_slice = -1; + new_currdev.disk.d_partition = 0; biosdev = -1; } #ifdef LOADER_ZFS_SUPPORT @@ -322,8 +318,8 @@ extract_currdev(void) zargs->size >= offsetof(struct zfs_boot_args, primary_pool)) { /* sufficient data is provided */ - new_currdev.d_kind.zfs.pool_guid = zargs->pool; - new_currdev.d_kind.zfs.root_guid = zargs->root; + new_currdev.zfs.pool_guid = zargs->pool; + new_currdev.zfs.root_guid = zargs->root; if (zargs->size >= sizeof(*zargs) && zargs->primary_vdev != 0) { sprintf(buf, "%llu", zargs->primary_pool); @@ -333,8 +329,8 @@ extract_currdev(void) } } else { /* old style zfsboot block */ - new_currdev.d_kind.zfs.pool_guid = kargs->zfspool; - new_currdev.d_kind.zfs.root_guid = 0; + new_currdev.zfs.pool_guid = kargs->zfspool; + new_currdev.zfs.root_guid = 0; } new_currdev.dd.d_dev = &zfs_dev; @@ -350,14 +346,12 @@ extract_currdev(void) #endif } else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) { /* The passed-in boot device is bad */ - new_currdev.d_kind.biosdisk.slice = -1; - new_currdev.d_kind.biosdisk.partition = 0; + new_currdev.disk.d_slice = -1; + new_currdev.disk.d_partition = 0; biosdev = -1; } else { - new_currdev.d_kind.biosdisk.slice = - B_SLICE(initial_bootdev) - 1; - new_currdev.d_kind.biosdisk.partition = - B_PARTITION(initial_bootdev); + new_currdev.disk.d_slice = B_SLICE(initial_bootdev) - 1; + new_currdev.disk.d_partition = B_PARTITION(initial_bootdev); biosdev = initial_bootinfo->bi_bios_dev; /* @@ -389,13 +383,10 @@ extract_currdev(void) #ifdef LOADER_ZFS_SUPPORT if (new_currdev.dd.d_dev->dv_type == DEVT_ZFS) - init_zfs_boot_options(zfs_fmtdev(&new_currdev)); + init_zfs_boot_options(devformat(&new_currdev.dd)); #endif - env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev), - i386_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), - env_noset, env_nounset); + set_currdev(devformat(&new_currdev.dd)); } COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); @@ -462,7 +453,7 @@ i386_zfs_probe(void) for (dev.dd.d_unit = 0; bd_unit2bios(&dev) >= 0; dev.dd.d_unit++) { snprintf(devname, sizeof(devname), "%s%d:", bioshd.dv_name, dev.dd.d_unit); - zfs_probe_dev(devname, NULL); + zfs_probe_dev(devname, NULL, true); } } #endif |