xref: /illumos-gate/usr/src/boot/i386/loader/main.c (revision ceb3ef19)
13d4c0714SToomas Soome /*
2199767f8SToomas Soome  * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3199767f8SToomas Soome  * All rights reserved.
4199767f8SToomas Soome  *
5199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
6199767f8SToomas Soome  * modification, are permitted provided that the following conditions
7199767f8SToomas Soome  * are met:
8199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
9199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
10199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
11199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
12199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
13199767f8SToomas Soome  *
14199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24199767f8SToomas Soome  * SUCH DAMAGE.
25199767f8SToomas Soome  */
26199767f8SToomas Soome 
27199767f8SToomas Soome #include <sys/cdefs.h>
28199767f8SToomas Soome 
29199767f8SToomas Soome /*
30199767f8SToomas Soome  * MD bootstrap main() and assorted miscellaneous
31199767f8SToomas Soome  * commands.
32199767f8SToomas Soome  */
33199767f8SToomas Soome 
34199767f8SToomas Soome #include <stand.h>
35199767f8SToomas Soome #include <stddef.h>
36199767f8SToomas Soome #include <string.h>
37199767f8SToomas Soome #include <machine/bootinfo.h>
38199767f8SToomas Soome #include <machine/cpufunc.h>
39199767f8SToomas Soome #include <machine/psl.h>
40edb35047SToomas Soome #include <sys/disk.h>
4114ee0d29SToomas Soome #include <sys/param.h>
42199767f8SToomas Soome #include <sys/reboot.h>
43b713c91eSToomas Soome #include <sys/zfs_bootenv.h>
447bc07ca3SToomas Soome #include <rbx.h>
45199767f8SToomas Soome 
46199767f8SToomas Soome #include "bootstrap.h"
47199767f8SToomas Soome #include "common/bootargs.h"
48199767f8SToomas Soome #include "libi386/libi386.h"
4922028508SToomas Soome #include "smbios.h"
50199767f8SToomas Soome #include "btxv86.h"
513d4c0714SToomas Soome #include "libzfs.h"
52199767f8SToomas Soome 
530bce4af8SToomas Soome CTASSERT(sizeof (struct bootargs) == BOOTARGS_SIZE);
54199767f8SToomas Soome CTASSERT(offsetof(struct bootargs, bootinfo) == BA_BOOTINFO);
55199767f8SToomas Soome CTASSERT(offsetof(struct bootargs, bootflags) == BA_BOOTFLAGS);
56199767f8SToomas Soome CTASSERT(offsetof(struct bootinfo, bi_size) == BI_SIZE);
57199767f8SToomas Soome 
58199767f8SToomas Soome /* Arguments passed in from the boot1/boot2 loader */
597bc07ca3SToomas Soome struct bootargs *kargs;
60199767f8SToomas Soome 
617bc07ca3SToomas Soome uint32_t	opts;
620bce4af8SToomas Soome static uint32_t	initial_bootdev;
63199767f8SToomas Soome static struct bootinfo	*initial_bootinfo;
64199767f8SToomas Soome 
65199767f8SToomas Soome struct arch_switch	archsw;		/* MI/MD interface boundary */
66199767f8SToomas Soome 
67199767f8SToomas Soome static void		extract_currdev(void);
68199767f8SToomas Soome static int		isa_inb(int port);
69199767f8SToomas Soome static void		isa_outb(int port, int value);
70199767f8SToomas Soome void			exit(int code);
71199767f8SToomas Soome static void		i386_zfs_probe(void);
72199767f8SToomas Soome 
73199767f8SToomas Soome /* XXX debugging */
7418af157dSToomas Soome extern char _end[];
75199767f8SToomas Soome 
76199767f8SToomas Soome static void *heap_top;
77199767f8SToomas Soome static void *heap_bottom;
78199767f8SToomas Soome 
7922028508SToomas Soome caddr_t
ptov(uintptr_t x)8022028508SToomas Soome ptov(uintptr_t x)
8122028508SToomas Soome {
8222028508SToomas Soome 	return (PTOV(x));
8322028508SToomas Soome }
8422028508SToomas Soome 
85199767f8SToomas Soome int
main(void)86199767f8SToomas Soome main(void)
87199767f8SToomas Soome {
880bce4af8SToomas Soome 	int	i;
890bce4af8SToomas Soome 
900bce4af8SToomas Soome 	/* Pick up arguments */
910bce4af8SToomas Soome 	kargs = (void *)__args;
927bc07ca3SToomas Soome 	opts = kargs->howto;
930bce4af8SToomas Soome 	initial_bootdev = kargs->bootdev;
940bce4af8SToomas Soome 	initial_bootinfo = kargs->bootinfo ?
950bce4af8SToomas Soome 	    (struct bootinfo *)PTOV(kargs->bootinfo) : NULL;
960bce4af8SToomas Soome 
970bce4af8SToomas Soome 	/* Initialize the v86 register set to a known-good state. */
980bce4af8SToomas Soome 	bzero(&v86, sizeof (v86));
990bce4af8SToomas Soome 	v86.efl = PSL_RESERVED_DEFAULT | PSL_I;
1000bce4af8SToomas Soome 
1010bce4af8SToomas Soome 	/*
1020bce4af8SToomas Soome 	 * Initialise the heap as early as possible.
1030bce4af8SToomas Soome 	 * Once this is done, malloc() is usable.
1040bce4af8SToomas Soome 	 */
1050bce4af8SToomas Soome 	bios_getmem();
1060bce4af8SToomas Soome 
1070bce4af8SToomas Soome 	if (high_heap_size > 0) {
1080bce4af8SToomas Soome 		heap_top = PTOV(high_heap_base + high_heap_size);
1090bce4af8SToomas Soome 		heap_bottom = PTOV(high_heap_base);
1100bce4af8SToomas Soome 		if (high_heap_base < memtop_copyin)
1110bce4af8SToomas Soome 			memtop_copyin = high_heap_base;
1120bce4af8SToomas Soome 	} else {
1130bce4af8SToomas Soome 		heap_top = (void *)PTOV(bios_basemem);
1140bce4af8SToomas Soome 		heap_bottom = (void *)_end;
1150bce4af8SToomas Soome 	}
1160bce4af8SToomas Soome 	setheap(heap_bottom, heap_top);
1170bce4af8SToomas Soome 
118*ceb3ef19SToomas Soome 	/* detect ACPI for future reference */
119*ceb3ef19SToomas Soome 	biosacpi_detect();
120*ceb3ef19SToomas Soome 
1210bce4af8SToomas Soome 	/*
1220bce4af8SToomas Soome 	 * XXX Chicken-and-egg problem; we want to have console output early,
1230bce4af8SToomas Soome 	 * but some console attributes may depend on reading from eg. the boot
1240bce4af8SToomas Soome 	 * device, which we can't do yet.
1250bce4af8SToomas Soome 	 *
1260bce4af8SToomas Soome 	 * We can use printf() etc. once this is done.
1270bce4af8SToomas Soome 	 * If the previous boot stage has requested a serial console,
1280bce4af8SToomas Soome 	 * prefer that.
1290bce4af8SToomas Soome 	 */
1307bc07ca3SToomas Soome 	bi_setboothowto(opts);
1317bc07ca3SToomas Soome 	if (OPT_CHECK(RBX_DUAL)) {
1327bc07ca3SToomas Soome 		if (OPT_CHECK(RBX_SERIAL))
1330bce4af8SToomas Soome 			setenv("console", "ttya text", 1);
1340bce4af8SToomas Soome 		else
1350bce4af8SToomas Soome 			setenv("console", "text ttya", 1);
1367bc07ca3SToomas Soome 	} else if (OPT_CHECK(RBX_SERIAL)) {
1370bce4af8SToomas Soome 		setenv("console", "ttya", 1);
1387bc07ca3SToomas Soome 	} else if (OPT_CHECK(RBX_MUTE)) {
1390bce4af8SToomas Soome 		setenv("console", "null", 1);
1400bce4af8SToomas Soome 	}
1410bce4af8SToomas Soome 	cons_probe();
1420bce4af8SToomas Soome 
1430bce4af8SToomas Soome 	/*
1440bce4af8SToomas Soome 	 * Initialise the block cache. Set the upper limit.
1450bce4af8SToomas Soome 	 */
1460bce4af8SToomas Soome 	bcache_init(32768, 512);
1470bce4af8SToomas Soome 
148199767f8SToomas Soome 	/*
1490bce4af8SToomas Soome 	 * Special handling for PXE and CD booting.
150199767f8SToomas Soome 	 */
1510bce4af8SToomas Soome 	if (kargs->bootinfo == 0) {
1520bce4af8SToomas Soome 		/*
1530bce4af8SToomas Soome 		 * We only want the PXE disk to try to init itself in the below
1540bce4af8SToomas Soome 		 * walk through devsw if we actually booted off of PXE.
1550bce4af8SToomas Soome 		 */
1560bce4af8SToomas Soome 		if (kargs->bootflags & KARGS_FLAGS_PXE)
1570bce4af8SToomas Soome 			pxe_enable(kargs->pxeinfo ?
1580bce4af8SToomas Soome 			    PTOV(kargs->pxeinfo) : NULL);
1590bce4af8SToomas Soome 		else if (kargs->bootflags & KARGS_FLAGS_CD)
1600bce4af8SToomas Soome 			bc_add(initial_bootdev);
1610bce4af8SToomas Soome 	}
1620bce4af8SToomas Soome 
1630bce4af8SToomas Soome 	archsw.arch_autoload = i386_autoload;
1640bce4af8SToomas Soome 	archsw.arch_getdev = i386_getdev;
1650bce4af8SToomas Soome 	archsw.arch_copyin = i386_copyin;
1660bce4af8SToomas Soome 	archsw.arch_copyout = i386_copyout;
1670bce4af8SToomas Soome 	archsw.arch_readin = i386_readin;
1680bce4af8SToomas Soome 	archsw.arch_isainb = isa_inb;
1690bce4af8SToomas Soome 	archsw.arch_isaoutb = isa_outb;
1700bce4af8SToomas Soome 	archsw.arch_loadaddr = i386_loadaddr;
1718c653870SToomas Soome 	archsw.arch_hypervisor = x86_hypervisor;
1720bce4af8SToomas Soome 	archsw.arch_zfs_probe = i386_zfs_probe;
1730bce4af8SToomas Soome 
1740bce4af8SToomas Soome 	/*
1750bce4af8SToomas Soome 	 * March through the device switch probing for things.
1760bce4af8SToomas Soome 	 */
1770bce4af8SToomas Soome 	for (i = 0; devsw[i] != NULL; i++)
1780bce4af8SToomas Soome 		if (devsw[i]->dv_init != NULL)
1790bce4af8SToomas Soome 			(devsw[i]->dv_init)();
1800bce4af8SToomas Soome 
1810bce4af8SToomas Soome 	printf("BIOS %dkB/%dkB available memory\n", bios_basemem / 1024,
1820bce4af8SToomas Soome 	    bios_extmem / 1024);
1830bce4af8SToomas Soome 	if (initial_bootinfo != NULL) {
1840bce4af8SToomas Soome 		initial_bootinfo->bi_basemem = bios_basemem / 1024;
1850bce4af8SToomas Soome 		initial_bootinfo->bi_extmem = bios_extmem / 1024;
1860bce4af8SToomas Soome 	}
1870bce4af8SToomas Soome 
1880bce4af8SToomas Soome 	/* detect SMBIOS for future reference */
1890bce4af8SToomas Soome 	smbios_detect(NULL);
1900bce4af8SToomas Soome 
1910bce4af8SToomas Soome 	/* detect PCI BIOS for future reference */
1920bce4af8SToomas Soome 	biospci_detect();
1930bce4af8SToomas Soome 
1940bce4af8SToomas Soome 	printf("\n%s", bootprog_info);
1950bce4af8SToomas Soome 
1960bce4af8SToomas Soome 	extract_currdev();		/* set $currdev and $loaddev */
197e0721d5aSToomas Soome 	autoload_font(OPT_CHECK(RBX_TEXT_MODE) != 0);
1980bce4af8SToomas Soome 
1990bce4af8SToomas Soome 	bi_isadir();
2000bce4af8SToomas Soome 	bios_getsmap();
2010bce4af8SToomas Soome 
2020bce4af8SToomas Soome 	interact(NULL);
2030bce4af8SToomas Soome 
2040bce4af8SToomas Soome 	/* if we ever get here, it is an error */
2050bce4af8SToomas Soome 	return (1);
206199767f8SToomas Soome }
207199767f8SToomas Soome 
208199767f8SToomas Soome /*
209f6c94443SToomas Soome  * Set the 'current device' by (if possible) recovering the boot device as
210199767f8SToomas Soome  * supplied by the initial bootstrap.
211199767f8SToomas Soome  *
212199767f8SToomas Soome  * XXX should be extended for netbooting.
213199767f8SToomas Soome  */
214199767f8SToomas Soome static void
extract_currdev(void)215199767f8SToomas Soome extract_currdev(void)
216199767f8SToomas Soome {
2170bce4af8SToomas Soome 	struct i386_devdesc	new_currdev;
2180bce4af8SToomas Soome 	struct zfs_boot_args	*zargs;
219b713c91eSToomas Soome 	char			*bootonce;
2200bce4af8SToomas Soome 	int			biosdev = -1;
2210bce4af8SToomas Soome 
2220bce4af8SToomas Soome 	/* Assume we are booting from a BIOS disk by default */
2230bce4af8SToomas Soome 	new_currdev.dd.d_dev = &bioshd;
2240bce4af8SToomas Soome 
2250bce4af8SToomas Soome 	/* new-style boot loaders such as pxeldr and cdldr */
2260bce4af8SToomas Soome 	if (kargs->bootinfo == 0) {
2270bce4af8SToomas Soome 		if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) {
2280bce4af8SToomas Soome 			/* we are booting from a CD with cdboot */
2290bce4af8SToomas Soome 			new_currdev.dd.d_dev = &bioscd;
2300bce4af8SToomas Soome 			new_currdev.dd.d_unit = bd_bios2unit(initial_bootdev);
2310bce4af8SToomas Soome 		} else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) {
2320bce4af8SToomas Soome 			/* we are booting from pxeldr */
2330bce4af8SToomas Soome 			new_currdev.dd.d_dev = &pxedisk;
2340bce4af8SToomas Soome 			new_currdev.dd.d_unit = 0;
2350bce4af8SToomas Soome 		} else {
2360bce4af8SToomas Soome 			/* we don't know what our boot device is */
2370bce4af8SToomas Soome 			new_currdev.d_kind.biosdisk.slice = -1;
2380bce4af8SToomas Soome 			new_currdev.d_kind.biosdisk.partition = 0;
2390bce4af8SToomas Soome 			biosdev = -1;
2400bce4af8SToomas Soome 		}
2410bce4af8SToomas Soome 	} else if ((kargs->bootflags & KARGS_FLAGS_ZFS) != 0) {
2420bce4af8SToomas Soome 		zargs = NULL;
2430bce4af8SToomas Soome 		/* check for new style extended argument */
2440bce4af8SToomas Soome 		if ((kargs->bootflags & KARGS_FLAGS_EXTARG) != 0)
2450bce4af8SToomas Soome 			zargs = (struct zfs_boot_args *)(kargs + 1);
2460bce4af8SToomas Soome 
2470bce4af8SToomas Soome 		if (zargs != NULL &&
2480bce4af8SToomas Soome 		    zargs->size >=
2490bce4af8SToomas Soome 		    offsetof(struct zfs_boot_args, primary_pool)) {
2500bce4af8SToomas Soome 			/* sufficient data is provided */
2510bce4af8SToomas Soome 			new_currdev.d_kind.zfs.pool_guid = zargs->pool;
2520bce4af8SToomas Soome 			new_currdev.d_kind.zfs.root_guid = zargs->root;
2530bce4af8SToomas Soome 		} else {
2540bce4af8SToomas Soome 			/* old style zfsboot block */
2550bce4af8SToomas Soome 			new_currdev.d_kind.zfs.pool_guid = kargs->zfspool;
2560bce4af8SToomas Soome 			new_currdev.d_kind.zfs.root_guid = 0;
2570bce4af8SToomas Soome 		}
2580bce4af8SToomas Soome 		new_currdev.dd.d_dev = &zfs_dev;
259b713c91eSToomas Soome 		if ((bootonce = malloc(VDEV_PAD_SIZE)) != NULL) {
260b713c91eSToomas Soome 			if (zfs_get_bootonce(&new_currdev, OS_BOOTONCE_USED,
261b713c91eSToomas Soome 			    bootonce, VDEV_PAD_SIZE) == 0) {
262b713c91eSToomas Soome 				setenv("zfs-bootonce", bootonce, 1);
263b713c91eSToomas Soome 			}
264b713c91eSToomas Soome 			free(bootonce);
265b713c91eSToomas Soome 			(void) zfs_attach_nvstore(&new_currdev);
266b713c91eSToomas Soome 		} else {
267b713c91eSToomas Soome 			printf("Failed to process bootonce data: %s\n",
268b713c91eSToomas Soome 			    strerror(errno));
269b713c91eSToomas Soome 		}
2700bce4af8SToomas Soome 	} else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) {
2710bce4af8SToomas Soome 		/* The passed-in boot device is bad */
2720bce4af8SToomas Soome 		new_currdev.d_kind.biosdisk.slice = -1;
2730bce4af8SToomas Soome 		new_currdev.d_kind.biosdisk.partition = 0;
2740bce4af8SToomas Soome 		biosdev = -1;
275199767f8SToomas Soome 	} else {
2760bce4af8SToomas Soome 		new_currdev.d_kind.biosdisk.slice =
2770bce4af8SToomas Soome 		    B_SLICE(initial_bootdev) - 1;
2780bce4af8SToomas Soome 		new_currdev.d_kind.biosdisk.partition =
2790bce4af8SToomas Soome 		    B_PARTITION(initial_bootdev);
2800bce4af8SToomas Soome 		biosdev = initial_bootinfo->bi_bios_dev;
2810bce4af8SToomas Soome 
2820bce4af8SToomas Soome 		/*
2830bce4af8SToomas Soome 		 * If we are booted by an old bootstrap, we have to guess at
2840bce4af8SToomas Soome 		 * the BIOS unit number. We will lose if there is more than
2850bce4af8SToomas Soome 		 * one disk type and we are not booting from the
2860bce4af8SToomas Soome 		 * lowest-numbered disk type (ie. SCSI when IDE also exists).
2870bce4af8SToomas Soome 		 */
2880bce4af8SToomas Soome 		if ((biosdev == 0) && (B_TYPE(initial_bootdev) != 2)) {
2890bce4af8SToomas Soome 			/*
2900bce4af8SToomas Soome 			 * biosdev doesn't match major, assume harddisk
2910bce4af8SToomas Soome 			 */
2920bce4af8SToomas Soome 			biosdev = 0x80 + B_UNIT(initial_bootdev);
2930bce4af8SToomas Soome 		}
294199767f8SToomas Soome 	}
295199767f8SToomas Soome 
296199767f8SToomas Soome 	/*
2970bce4af8SToomas Soome 	 * If we are booting off of a BIOS disk and we didn't succeed
2980bce4af8SToomas Soome 	 * in determining which one we booted off of, just use disk0:
2990bce4af8SToomas Soome 	 * as a reasonable default.
300199767f8SToomas Soome 	 */
3010bce4af8SToomas Soome 	if ((new_currdev.dd.d_dev->dv_type == bioshd.dv_type) &&
3020bce4af8SToomas Soome 	    ((new_currdev.dd.d_unit = bd_bios2unit(biosdev)) == -1)) {
3030bce4af8SToomas Soome 		printf("Can't work out which disk we are booting "
3040bce4af8SToomas Soome 		    "from.\nGuessed BIOS device 0x%x not found by "
3050bce4af8SToomas Soome 		    "probes, defaulting to disk0:\n", biosdev);
3060bce4af8SToomas Soome 		new_currdev.dd.d_unit = 0;
3070bce4af8SToomas Soome 	}
3080bce4af8SToomas Soome 
3090bce4af8SToomas Soome 	env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev),
3100bce4af8SToomas Soome 	    i386_setcurrdev, env_nounset);
3110bce4af8SToomas Soome 	env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev),
3120bce4af8SToomas Soome 	    env_noset, env_nounset);
313199767f8SToomas Soome }
314199767f8SToomas Soome 
315199767f8SToomas Soome COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
316199767f8SToomas Soome 
317199767f8SToomas Soome static int
command_reboot(int argc __unused,char * argv[]__unused)3188eef2ab6SToomas Soome command_reboot(int argc __unused, char *argv[] __unused)
319199767f8SToomas Soome {
3200bce4af8SToomas Soome 	int i;
321199767f8SToomas Soome 
3220bce4af8SToomas Soome 	for (i = 0; devsw[i] != NULL; ++i)
3230bce4af8SToomas Soome 		if (devsw[i]->dv_cleanup != NULL)
3240bce4af8SToomas Soome 			(devsw[i]->dv_cleanup)();
325199767f8SToomas Soome 
3260bce4af8SToomas Soome 	printf("Rebooting...\n");
3270bce4af8SToomas Soome 	delay(1000000);
3280bce4af8SToomas Soome 	__exit(0);
329199767f8SToomas Soome }
330199767f8SToomas Soome 
331199767f8SToomas Soome /* provide this for panic, as it's not in the startup code */
332199767f8SToomas Soome void
exit(int code)333199767f8SToomas Soome exit(int code)
334199767f8SToomas Soome {
3350bce4af8SToomas Soome 	__exit(code);
336199767f8SToomas Soome }
337199767f8SToomas Soome 
338199767f8SToomas Soome COMMAND_SET(heap, "heap", "show heap usage", command_heap);
339199767f8SToomas Soome 
340199767f8SToomas Soome static int
command_heap(int argc __unused,char * argv[]__unused)3418eef2ab6SToomas Soome command_heap(int argc __unused, char *argv[] __unused)
342199767f8SToomas Soome {
3430bce4af8SToomas Soome 
3440bce4af8SToomas Soome 	mallocstats();
3450bce4af8SToomas Soome 	printf("heap base at %p, top at %p, upper limit at %p\n", heap_bottom,
3460bce4af8SToomas Soome 	    sbrk(0), heap_top);
3470bce4af8SToomas Soome 	return (CMD_OK);
348199767f8SToomas Soome }
349199767f8SToomas Soome 
350199767f8SToomas Soome /* ISA bus access functions for PnP. */
351199767f8SToomas Soome static int
isa_inb(int port)352199767f8SToomas Soome isa_inb(int port)
353199767f8SToomas Soome {
354199767f8SToomas Soome 
3550bce4af8SToomas Soome 	return (inb(port));
356199767f8SToomas Soome }
357199767f8SToomas Soome 
358199767f8SToomas Soome static void
isa_outb(int port,int value)359199767f8SToomas Soome isa_outb(int port, int value)
360199767f8SToomas Soome {
361199767f8SToomas Soome 
3620bce4af8SToomas Soome 	outb(port, value);
363199767f8SToomas Soome }
364199767f8SToomas Soome 
365199767f8SToomas Soome static void
i386_zfs_probe(void)366199767f8SToomas Soome i386_zfs_probe(void)
367199767f8SToomas Soome {
3680bce4af8SToomas Soome 	char devname[32];
3690bce4af8SToomas Soome 	struct i386_devdesc dev;
3700bce4af8SToomas Soome 
3710bce4af8SToomas Soome 	/*
3720bce4af8SToomas Soome 	 * Open all the disks we can find and see if we can reconstruct
3730bce4af8SToomas Soome 	 * ZFS pools from them.
3740bce4af8SToomas Soome 	 */
3750bce4af8SToomas Soome 	dev.dd.d_dev = &bioshd;
3760bce4af8SToomas Soome 	for (dev.dd.d_unit = 0; bd_unit2bios(&dev) >= 0; dev.dd.d_unit++) {
3770bce4af8SToomas Soome 		snprintf(devname, sizeof (devname), "%s%d:", bioshd.dv_name,
3780bce4af8SToomas Soome 		    dev.dd.d_unit);
3790bce4af8SToomas Soome 		zfs_probe_dev(devname, NULL);
3800bce4af8SToomas Soome 	}
381199767f8SToomas Soome }
382