Changeset View
Changeset View
Standalone View
Standalone View
head/stand/i386/loader/main.c
Show First 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct i386_devdesc new_currdev; | struct i386_devdesc new_currdev; | ||||
#ifdef LOADER_ZFS_SUPPORT | #ifdef LOADER_ZFS_SUPPORT | ||||
char buf[20]; | char buf[20]; | ||||
#endif | #endif | ||||
int biosdev = -1; | int biosdev = -1; | ||||
/* Assume we are booting from a BIOS disk by default */ | /* Assume we are booting from a BIOS disk by default */ | ||||
new_currdev.dd.d_dev = &biosdisk; | new_currdev.dd.d_dev = &bioshd; | ||||
/* new-style boot loaders such as pxeldr and cdldr */ | /* new-style boot loaders such as pxeldr and cdldr */ | ||||
if (kargs->bootinfo == 0) { | if (kargs->bootinfo == 0) { | ||||
if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) { | if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) { | ||||
/* we are booting from a CD with cdboot */ | /* we are booting from a CD with cdboot */ | ||||
new_currdev.dd.d_dev = &bioscd; | new_currdev.dd.d_dev = &bioscd; | ||||
new_currdev.dd.d_unit = bc_bios2unit(initial_bootdev); | new_currdev.dd.d_unit = bd_bios2unit(initial_bootdev); | ||||
} else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) { | } else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) { | ||||
/* we are booting from pxeldr */ | /* we are booting from pxeldr */ | ||||
new_currdev.dd.d_dev = &pxedisk; | new_currdev.dd.d_dev = &pxedisk; | ||||
new_currdev.dd.d_unit = 0; | new_currdev.dd.d_unit = 0; | ||||
} else { | } else { | ||||
/* we don't know what our boot device is */ | /* we don't know what our boot device is */ | ||||
new_currdev.d_kind.biosdisk.slice = -1; | new_currdev.d_kind.biosdisk.slice = -1; | ||||
new_currdev.d_kind.biosdisk.partition = 0; | new_currdev.d_kind.biosdisk.partition = 0; | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | #endif | ||||
if ((biosdev == 0) && (B_TYPE(initial_bootdev) != 2)) /* biosdev doesn't match major */ | if ((biosdev == 0) && (B_TYPE(initial_bootdev) != 2)) /* biosdev doesn't match major */ | ||||
biosdev = 0x80 + B_UNIT(initial_bootdev); /* assume harddisk */ | biosdev = 0x80 + B_UNIT(initial_bootdev); /* assume harddisk */ | ||||
} | } | ||||
/* | /* | ||||
* If we are booting off of a BIOS disk and we didn't succeed in determining | * If we are booting off of a BIOS disk and we didn't succeed in determining | ||||
* which one we booted off of, just use disk0: as a reasonable default. | * which one we booted off of, just use disk0: as a reasonable default. | ||||
*/ | */ | ||||
if ((new_currdev.dd.d_dev->dv_type == biosdisk.dv_type) && | if ((new_currdev.dd.d_dev->dv_type == bioshd.dv_type) && | ||||
((new_currdev.dd.d_unit = bd_bios2unit(biosdev)) == -1)) { | ((new_currdev.dd.d_unit = bd_bios2unit(biosdev)) == -1)) { | ||||
printf("Can't work out which disk we are booting from.\n" | printf("Can't work out which disk we are booting from.\n" | ||||
"Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); | "Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); | ||||
new_currdev.dd.d_unit = 0; | new_currdev.dd.d_unit = 0; | ||||
} | } | ||||
#ifdef LOADER_ZFS_SUPPORT | #ifdef LOADER_ZFS_SUPPORT | ||||
if (new_currdev.dd.d_dev->dv_type == DEVT_ZFS) | if (new_currdev.dd.d_dev->dv_type == DEVT_ZFS) | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | isa_outb(int port, int value) | ||||
outb(port, value); | outb(port, value); | ||||
} | } | ||||
#ifdef LOADER_ZFS_SUPPORT | #ifdef LOADER_ZFS_SUPPORT | ||||
static void | static void | ||||
i386_zfs_probe(void) | i386_zfs_probe(void) | ||||
{ | { | ||||
char devname[32]; | char devname[32]; | ||||
int unit; | struct i386_devdesc dev; | ||||
/* | /* | ||||
* Open all the disks we can find and see if we can reconstruct | * Open all the disks we can find and see if we can reconstruct | ||||
* ZFS pools from them. | * ZFS pools from them. | ||||
*/ | */ | ||||
for (unit = 0; unit < MAXBDDEV; unit++) { | dev.dd.d_dev = &bioshd; | ||||
if (bd_unit2bios(unit) == -1) | for (dev.dd.d_unit = 0; bd_unit2bios(&dev) >= 0; dev.dd.d_unit++) { | ||||
break; | snprintf(devname, sizeof(devname), "%s%d:", bioshd.dv_name, | ||||
if (bd_unit2bios(unit) < 0x80) | dev.dd.d_unit); | ||||
continue; | |||||
sprintf(devname, "disk%d:", unit); | |||||
zfs_probe_dev(devname, NULL); | zfs_probe_dev(devname, NULL); | ||||
} | } | ||||
} | } | ||||
#endif | #endif |