2 * Copyright (c) 1998 Robert Nordier
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
16 #include <sys/cdefs.h>
17 __FBSDID("$FreeBSD$");
19 #include <sys/param.h>
20 #include <sys/errno.h>
21 #include <sys/diskmbr.h>
25 #include <sys/reboot.h>
26 #include <sys/queue.h>
28 #include <machine/bootinfo.h>
29 #include <machine/elf.h>
30 #include <machine/pc/bios.h>
53 #define BIOS_NUMDRIVES 0x475
59 #define TYPE_MAXHARD TYPE_DA
62 #define DEV_GELIBOOT_BSIZE 4096
67 static const uuid_t freebsd_zfs_uuid = GPT_ENT_TYPE_FREEBSD_ZFS;
69 static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */
70 static const unsigned char flags[NOPT] = {
88 static const unsigned char dev_maj[NDEV] = {30, 4, 2};
91 static char cmddup[512];
92 static char kname[1024];
93 static char rootname[256];
94 static int comspeed = SIOSPD;
95 static struct bootinfo bootinfo;
96 static uint32_t bootdev;
97 static struct zfs_boot_args zfsargs;
98 static struct zfsmount zfsmount;
100 vm_offset_t high_heap_base;
101 uint32_t bios_basemem, bios_extmem, high_heap_size;
103 static struct bios_smap smap;
106 * The minimum amount of memory to reserve in bios_extmem for the heap.
108 #define HEAP_MIN (64 * 1024 * 1024)
110 static char *heap_next;
111 static char *heap_end;
113 /* Buffers that must not span a 64k boundary. */
114 #define READ_BUF_SIZE 8192
116 char rdbuf[READ_BUF_SIZE]; /* for reading large things */
117 char secbuf[READ_BUF_SIZE]; /* for MBR/disklabel */
119 static struct dmadat *dmadat;
123 static void load(void);
124 static int parse_cmd(void);
125 static void bios_getmem(void);
126 void *malloc(size_t n);
127 void free(void *ptr);
133 if (p + n > heap_end) {
134 printf("malloc failure\n");
152 strdup(const char *s)
154 char *p = malloc(strlen(s) + 1);
159 #ifdef LOADER_GELI_SUPPORT
160 #include "geliboot.c"
161 static char gelipw[GELI_PW_MAXLEN];
162 static struct keybuf *gelibuf;
168 * Read from a dnode (which must be from a ZPL filesystem).
171 zfs_read(spa_t *spa, const dnode_phys_t *dnode, off_t *offp, void *start, size_t size)
173 const znode_phys_t *zp = (const znode_phys_t *) dnode->dn_bonus;
178 if (*offp + n > zp->zp_size)
179 n = zp->zp_size - *offp;
181 rc = dnode_read(spa, dnode, *offp, start, n);
193 static spa_t *primary_spa;
194 static vdev_t *primary_vdev;
197 * A wrapper for dskread that doesn't have to worry about whether the
198 * buffer pointer crosses a 64k boundary.
201 vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
204 daddr_t lba, alignlba;
206 unsigned int nb, alignnb;
207 struct dsk *dsk = (struct dsk *) priv;
209 if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1)))
213 lba = off / DEV_BSIZE;
216 * Align reads to 4k else 4k sector GELIs will not decrypt.
217 * Round LBA down to nearest multiple of DEV_GELIBOOT_BSIZE bytes.
219 alignlba = rounddown2(off, DEV_GELIBOOT_BSIZE) / DEV_BSIZE;
221 * The read must be aligned to DEV_GELIBOOT_BSIZE bytes relative to the
222 * start of the GELI partition, not the start of the actual disk.
224 alignlba += dsk->start;
225 diff = (lba - alignlba) * DEV_BSIZE;
228 nb = bytes / DEV_BSIZE;
230 * Ensure that the read size plus the leading offset does not
231 * exceed the size of the read buffer.
233 if (nb > (READ_BUF_SIZE - diff) / DEV_BSIZE)
234 nb = (READ_BUF_SIZE - diff) / DEV_BSIZE;
236 * Round the number of blocks to read up to the nearest multiple
237 * of DEV_GELIBOOT_BSIZE.
239 alignnb = roundup2(nb * DEV_BSIZE + diff, DEV_GELIBOOT_BSIZE)
242 if (drvread(dsk, dmadat->rdbuf, alignlba, alignnb))
244 #ifdef LOADER_GELI_SUPPORT
246 if (is_geli(dsk) == 0) {
247 if (geli_read(dsk, ((alignlba - dsk->start) *
248 DEV_BSIZE), dmadat->rdbuf, alignnb * DEV_BSIZE))
252 memcpy(p, dmadat->rdbuf + diff, nb * DEV_BSIZE);
256 bytes -= nb * DEV_BSIZE;
257 /* Don't need the leading offset after the first block. */
265 vdev_write(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
270 struct dsk *dsk = (struct dsk *) priv;
272 if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1)))
276 lba = off / DEV_BSIZE;
279 nb = bytes / DEV_BSIZE;
280 if (nb > READ_BUF_SIZE / DEV_BSIZE)
281 nb = READ_BUF_SIZE / DEV_BSIZE;
282 memcpy(dmadat->rdbuf, p, nb * DEV_BSIZE);
283 if (drvwrite(dsk, dmadat->rdbuf, lba, nb))
287 bytes -= nb * DEV_BSIZE;
294 xfsread(const dnode_phys_t *dnode, off_t *offp, void *buf, size_t nbyte)
296 if ((size_t)zfs_read(spa, dnode, offp, buf, nbyte) != nbyte) {
297 printf("Invalid format\n");
304 * Read Pad2 (formerly "Boot Block Header") area of the first
305 * vdev label of the given vdev.
308 vdev_read_pad2(vdev_t *vdev, char *buf, size_t size)
311 char *tmp = zap_scratch;
312 off_t off = offsetof(vdev_label_t, vl_pad2);
314 if (size > VDEV_PAD_SIZE)
315 size = VDEV_PAD_SIZE;
318 BP_SET_LSIZE(&bp, VDEV_PAD_SIZE);
319 BP_SET_PSIZE(&bp, VDEV_PAD_SIZE);
320 BP_SET_CHECKSUM(&bp, ZIO_CHECKSUM_LABEL);
321 BP_SET_COMPRESS(&bp, ZIO_COMPRESS_OFF);
322 DVA_SET_OFFSET(BP_IDENTITY(&bp), off);
323 if (vdev_read_phys(vdev, &bp, tmp, off, 0))
325 memcpy(buf, tmp, size);
330 vdev_clear_pad2(vdev_t *vdev)
332 char *zeroes = zap_scratch;
334 off_t off = offsetof(vdev_label_t, vl_pad2);
336 memset(zeroes, 0, VDEV_PAD_SIZE);
337 end = (uint64_t *)(zeroes + VDEV_PAD_SIZE);
338 /* ZIO_CHECKSUM_LABEL magic and pre-calcualted checksum for all zeros */
339 end[-5] = 0x0210da7ab10c7a11;
340 end[-4] = 0x97f48f807f6e2a3f;
341 end[-3] = 0xaf909f1658aacefc;
342 end[-2] = 0xcbd1ea57ff6db48b;
343 end[-1] = 0x6ec692db0d465fab;
344 if (vdev_write(vdev, vdev->v_read_priv, off, zeroes, VDEV_PAD_SIZE))
354 /* Parse system memory map */
358 v86.addr = 0x15; /* int 0x15 function 0xe820*/
360 v86.ecx = sizeof(struct bios_smap);
362 v86.es = VTOPSEG(&smap);
363 v86.edi = VTOPOFF(&smap);
365 if (V86_CY(v86.efl) || (v86.eax != SMAP_SIG))
367 /* look for a low-memory segment that's large enough */
368 if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) &&
369 (smap.length >= (512 * 1024)))
370 bios_basemem = smap.length;
371 /* look for the first segment in 'extended' memory */
372 if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0x100000)) {
373 bios_extmem = smap.length;
377 * Look for the largest segment in 'extended' memory beyond
380 if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base > 0x100000) &&
381 (smap.base < 0x100000000ull)) {
385 * If this segment crosses the 4GB boundary, truncate it.
387 if (smap.base + size > 0x100000000ull)
388 size = 0x100000000ull - smap.base;
390 if (size > high_heap_size) {
391 high_heap_size = size;
392 high_heap_base = smap.base;
395 } while (v86.ebx != 0);
397 /* Fall back to the old compatibility function for base memory */
398 if (bios_basemem == 0) {
400 v86.addr = 0x12; /* int 0x12 */
403 bios_basemem = (v86.eax & 0xffff) * 1024;
406 /* Fall back through several compatibility functions for extended memory */
407 if (bios_extmem == 0) {
409 v86.addr = 0x15; /* int 0x15 function 0xe801*/
412 if (!V86_CY(v86.efl)) {
413 bios_extmem = ((v86.ecx & 0xffff) + ((v86.edx & 0xffff) * 64)) * 1024;
416 if (bios_extmem == 0) {
418 v86.addr = 0x15; /* int 0x15 function 0x88*/
421 bios_extmem = (v86.eax & 0xffff) * 1024;
425 * If we have extended memory and did not find a suitable heap
426 * region in the SMAP, use the last 3MB of 'extended' memory as a
427 * high heap candidate.
429 if (bios_extmem >= HEAP_MIN && high_heap_size < HEAP_MIN) {
430 high_heap_size = HEAP_MIN;
431 high_heap_base = bios_extmem + 0x100000 - HEAP_MIN;
436 * Try to detect a device supported by the legacy int13 BIOS
439 int13probe(int drive)
447 if (!V86_CY(v86.efl) && /* carry clear */
448 ((v86.edx & 0xff) != (drive & DRV_MASK))) { /* unit # OK */
449 if ((v86.ecx & 0x3f) == 0) { /* absurd sector size */
450 return(0); /* skip device */
458 * We call this when we find a ZFS vdev - ZFS consumes the dsk
459 * structure so we must make a new one.
462 copy_dsk(struct dsk *dsk)
466 newdsk = malloc(sizeof(struct dsk));
472 probe_drive(struct dsk *dsk)
477 unsigned part, entries_per_sec;
480 #if defined(GPT) || defined(LOADER_GELI_SUPPORT)
484 struct dos_partition *dp;
489 * If we find a vdev on the whole disk, stop here.
491 if (vdev_probe(vdev_read, dsk, NULL) == 0)
494 #ifdef LOADER_GELI_SUPPORT
496 * Taste the disk, if it is GELI encrypted, decrypt it and check to see if
497 * it is a usable vdev then. Otherwise dig
498 * out the partition table and probe each slice/partition
499 * in turn for a vdev or GELI encrypted vdev.
505 if (geli_taste(vdev_read, dsk, elba) == 0) {
506 if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, dsk->unit,
508 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
513 #endif /* LOADER_GELI_SUPPORT */
515 sec = dmadat->secbuf;
520 * First check for GPT.
522 if (drvread(dsk, sec, 1, 1)) {
525 memcpy(&hdr, sec, sizeof(hdr));
526 if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) != 0 ||
527 hdr.hdr_lba_self != 1 || hdr.hdr_revision < 0x00010000 ||
528 hdr.hdr_entsz < sizeof(*ent) || DEV_BSIZE % hdr.hdr_entsz != 0) {
533 * Probe all GPT partitions for the presence of ZFS pools. We
534 * return the spa_t for the first we find (if requested). This
535 * will have the effect of booting from the first pool on the
538 * If no vdev is found, GELI decrypting the device and try again
540 entries_per_sec = DEV_BSIZE / hdr.hdr_entsz;
541 slba = hdr.hdr_lba_table;
542 elba = slba + hdr.hdr_entries / entries_per_sec;
543 while (slba < elba) {
545 if (drvread(dsk, sec, slba, 1))
547 for (part = 0; part < entries_per_sec; part++) {
548 ent = (struct gpt_ent *)(sec + part * hdr.hdr_entsz);
549 if (memcmp(&ent->ent_type, &freebsd_zfs_uuid,
550 sizeof(uuid_t)) == 0) {
551 dsk->start = ent->ent_lba_start;
552 dsk->slice = part + 1;
554 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
556 * This slice had a vdev. We need a new dsk
557 * structure now since the vdev now owns this one.
561 #ifdef LOADER_GELI_SUPPORT
562 else if (geli_taste(vdev_read, dsk, ent->ent_lba_end -
563 ent->ent_lba_start) == 0) {
564 if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw,
565 dsk->unit, 'p', dsk->slice, dsk) == 0) {
567 * This slice has GELI, check it for ZFS.
569 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
571 * This slice had a vdev. We need a new dsk
572 * structure now since the vdev now owns this one.
579 #endif /* LOADER_GELI_SUPPORT */
588 if (drvread(dsk, sec, DOSBBSECTOR, 1))
590 dp = (void *)(sec + DOSPARTOFF);
592 for (i = 0; i < NDOSPART; i++) {
595 dsk->start = dp[i].dp_start;
597 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
600 #ifdef LOADER_GELI_SUPPORT
601 else if (geli_taste(vdev_read, dsk, dp[i].dp_size -
602 dp[i].dp_start) == 0) {
603 if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, dsk->unit,
606 * This slice has GELI, check it for ZFS.
608 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
610 * This slice had a vdev. We need a new dsk
611 * structure now since the vdev now owns this one.
618 #endif /* LOADER_GELI_SUPPORT */
632 dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
636 if (high_heap_size > 0) {
637 heap_end = PTOV(high_heap_base + high_heap_size);
638 heap_next = PTOV(high_heap_base);
640 heap_next = (char *)dmadat + sizeof(*dmadat);
641 heap_end = (char *)PTOV(bios_basemem);
644 dsk = malloc(sizeof(struct dsk));
645 dsk->drive = *(uint8_t *)PTOV(ARGS);
646 dsk->type = dsk->drive & DRV_HARD ? TYPE_AD : TYPE_FD;
647 dsk->unit = dsk->drive & DRV_MASK;
648 dsk->slice = *(uint8_t *)PTOV(ARGS + 1) + 1;
653 bootinfo.bi_version = BOOTINFO_VERSION;
654 bootinfo.bi_size = sizeof(bootinfo);
655 bootinfo.bi_basemem = bios_basemem / 1024;
656 bootinfo.bi_extmem = bios_extmem / 1024;
657 bootinfo.bi_memsizes_valid++;
658 bootinfo.bi_bios_dev = dsk->drive;
660 bootdev = MAKEBOOTDEV(dev_maj[dsk->type],
661 dsk->slice, dsk->unit, dsk->part);
663 /* Process configuration file */
667 #ifdef LOADER_GELI_SUPPORT
673 * Probe the boot drive first - we will try to boot from whatever
674 * pool we find on that drive.
679 * Probe the rest of the drives that the bios knows about. This
680 * will find any other available pools and it may fill in missing
681 * vdevs for the boot pool.
684 for (i = 0; i < *(unsigned char *)PTOV(BIOS_NUMDRIVES); i++)
686 for (i = 0; i < MAXBDDEV; i++)
689 if ((i | DRV_HARD) == *(uint8_t *)PTOV(ARGS))
692 if (!int13probe(i | DRV_HARD))
695 dsk = malloc(sizeof(struct dsk));
696 dsk->drive = i | DRV_HARD;
697 dsk->type = dsk->drive & TYPE_AD;
707 * The first discovered pool, if any, is the pool.
709 spa = spa_get_primary();
711 printf("%s: No ZFS pools located, can't boot\n", BOOTPROG);
717 primary_vdev = spa_get_primary_vdev(spa);
720 rc = vdev_read_pad2(primary_vdev, cmd, sizeof(cmd));
721 if (vdev_clear_pad2(primary_vdev))
722 printf("failed to clear pad2 area of primary vdev\n");
726 * We could find an old-style ZFS Boot Block header here.
729 if (*(uint64_t *)cmd != 0x2f5b007b10c) {
731 * Note that parse() is destructive to cmd[] and we also want
732 * to honor RBX_QUIET option that could be present in cmd[].
735 memcpy(cmddup, cmd, sizeof(cmd));
737 printf("failed to parse pad2 area of primary vdev\n");
740 if (!OPT_CHECK(RBX_QUIET))
741 printf("zfs nextboot: %s\n", cmddup);
743 /* Do not process this command twice */
747 printf("failed to read pad2 area of primary vdev\n");
749 /* Mount ZFS only if it's not already mounted via nextboot parsing. */
750 if (zfsmount.spa == NULL &&
751 (zfs_spa_init(spa) != 0 || zfs_mount(spa, 0, &zfsmount) != 0)) {
752 printf("%s: failed to mount default pool %s\n",
753 BOOTPROG, spa->spa_name);
755 } else if (zfs_lookup(&zfsmount, PATH_CONFIG, &dn) == 0 ||
756 zfs_lookup(&zfsmount, PATH_DOTCONFIG, &dn) == 0) {
758 zfs_read(spa, &dn, &off, cmd, sizeof(cmd));
763 * Note that parse_cmd() is destructive to cmd[] and we also want
764 * to honor RBX_QUIET option that could be present in cmd[].
766 memcpy(cmddup, cmd, sizeof(cmd));
769 if (!OPT_CHECK(RBX_QUIET))
770 printf("%s: %s\n", PATH_CONFIG, cmddup);
771 /* Do not process this command twice */
775 /* Do not risk waiting at the prompt forever. */
776 if (nextboot && !autoboot)
780 * Try to exec /boot/loader. If interrupted by a keypress,
781 * or in case of failure, try to load a kernel directly instead.
784 if (autoboot && !*kname) {
785 memcpy(kname, PATH_LOADER_ZFS, sizeof(PATH_LOADER_ZFS));
788 memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
792 /* Present the user with the boot2 prompt. */
795 if (!autoboot || !OPT_CHECK(RBX_QUIET)) {
796 printf("\nFreeBSD/x86 boot\n");
797 if (zfs_rlookup(spa, zfsmount.rootobj, rootname) != 0)
798 printf("Default: %s/<0x%llx>:%s\n"
800 spa->spa_name, zfsmount.rootobj, kname);
801 else if (rootname[0] != '\0')
802 printf("Default: %s/%s:%s\n"
804 spa->spa_name, rootname, kname);
806 printf("Default: %s:%s\n"
808 spa->spa_name, kname);
810 if (ioctrl & IO_SERIAL)
812 if (!autoboot || keyhit(5))
813 getstr(cmd, sizeof(cmd));
814 else if (!autoboot || !OPT_CHECK(RBX_QUIET))
824 /* XXX - Needed for btxld to link the boot2 binary; do not remove. */
844 static Elf32_Phdr ep[2];
845 static Elf32_Shdr es[2];
852 if (zfs_lookup(&zfsmount, kname, &dn)) {
853 printf("\nCan't find %s\n", kname);
857 if (xfsread(&dn, &off, &hdr, sizeof(hdr)))
859 if (N_GETMAGIC(hdr.ex) == ZMAGIC)
861 else if (IS_ELF(hdr.eh))
864 printf("Invalid %s\n", "format");
868 addr = hdr.ex.a_entry & 0xffffff;
871 if (xfsread(&dn, &off, p, hdr.ex.a_text))
873 p += roundup2(hdr.ex.a_text, PAGE_SIZE);
874 if (xfsread(&dn, &off, p, hdr.ex.a_data))
876 p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
877 bootinfo.bi_symtab = VTOP(p);
878 memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms));
879 p += sizeof(hdr.ex.a_syms);
881 if (xfsread(&dn, &off, p, hdr.ex.a_syms))
884 if (xfsread(&dn, &off, p, sizeof(int)))
889 if (xfsread(&dn, &off, p, x))
894 off = hdr.eh.e_phoff;
895 for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) {
896 if (xfsread(&dn, &off, ep + j, sizeof(ep[0])))
898 if (ep[j].p_type == PT_LOAD)
901 for (i = 0; i < 2; i++) {
902 p = PTOV(ep[i].p_paddr & 0xffffff);
903 off = ep[i].p_offset;
904 if (xfsread(&dn, &off, p, ep[i].p_filesz))
907 p += roundup2(ep[1].p_memsz, PAGE_SIZE);
908 bootinfo.bi_symtab = VTOP(p);
909 if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) {
910 off = hdr.eh.e_shoff + sizeof(es[0]) *
911 (hdr.eh.e_shstrndx + 1);
912 if (xfsread(&dn, &off, &es, sizeof(es)))
914 for (i = 0; i < 2; i++) {
915 memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
916 p += sizeof(es[i].sh_size);
917 off = es[i].sh_offset;
918 if (xfsread(&dn, &off, p, es[i].sh_size))
923 addr = hdr.eh.e_entry & 0xffffff;
925 bootinfo.bi_esymtab = VTOP(p);
926 bootinfo.bi_kernelname = VTOP(kname);
927 zfsargs.size = sizeof(zfsargs);
928 zfsargs.pool = zfsmount.spa->spa_guid;
929 zfsargs.root = zfsmount.rootobj;
930 zfsargs.primary_pool = primary_spa->spa_guid;
931 #ifdef LOADER_GELI_SUPPORT
932 explicit_bzero(gelipw, sizeof(gelipw));
933 gelibuf = malloc(sizeof(struct keybuf) + (GELI_MAX_KEYS * sizeof(struct keybuf_ent)));
934 geli_fill_keybuf(gelibuf);
935 zfsargs.notapw = '\0';
936 zfsargs.keybuf_sentinel = KEYBUF_SENTINEL;
937 zfsargs.keybuf = gelibuf;
939 zfsargs.gelipw[0] = '\0';
941 if (primary_vdev != NULL)
942 zfsargs.primary_vdev = primary_vdev->v_guid;
944 printf("failed to detect primary vdev\n");
945 __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
947 KARGS_FLAGS_ZFS | KARGS_FLAGS_EXTARG,
948 (uint32_t) spa->spa_guid,
949 (uint32_t) (spa->spa_guid >> 32),
955 zfs_mount_ds(char *dsname)
961 q = strchr(dsname, '/');
964 newspa = spa_find_by_name(dsname);
965 if (newspa == NULL) {
966 printf("\nCan't find ZFS pool %s\n", dsname);
970 if (zfs_spa_init(newspa))
975 if (zfs_lookup_dataset(newspa, q, &newroot)) {
976 printf("\nCan't find dataset %s in ZFS pool %s\n",
977 q, newspa->spa_name);
981 if (zfs_mount(newspa, newroot, &zfsmount)) {
982 printf("\nCan't mount ZFS dataset\n");
997 while ((c = *arg++)) {
998 if (c == ' ' || c == '\t' || c == '\n')
1000 for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
1005 while ((c = *arg++)) {
1007 if (*(uint8_t *)PTOV(0x496) & 0x10) {
1010 opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL);
1013 printf("Keyboard: %s\n", cp);
1015 } else if (c == 'S') {
1017 while ((unsigned int)(i = *arg++ - '0') <= 9)
1019 if (j > 0 && i == -'0') {
1023 /* Fall through to error below ('S' not in optstr[]). */
1025 for (i = 0; c != optstr[i]; i++)
1028 opts ^= OPT_SET(flags[i]);
1030 ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
1031 OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
1032 if (ioctrl & IO_SERIAL) {
1033 if (sio_init(115200 / comspeed) != 0)
1034 ioctrl &= ~IO_SERIAL;
1039 if (zfs_lookup(&zfsmount, arg, &dn) == 0) {
1047 * Report pool status if the comment is 'status'. Lets
1048 * hope no-one wants to load /status as a kernel.
1050 if (!strcmp(arg, "status")) {
1056 * If there is "zfs:" prefix simply ignore it.
1058 if (strncmp(arg, "zfs:", 4) == 0)
1062 * If there is a colon, switch pools.
1064 q = strchr(arg, ':');
1067 if (zfs_mount_ds(arg) != 0)
1071 if ((i = ep - arg)) {
1072 if ((size_t)i >= sizeof(kname))
1074 memcpy(kname, arg, i + 1);