summaryrefslogtreecommitdiffstats
path: root/sys/boot/i386
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2016-02-09 22:32:24 +0000
committeremaste <emaste@FreeBSD.org>2016-02-09 22:32:24 +0000
commitf1429e95c359a7e76f8385cdd47f887b7d1bbd0e (patch)
tree7afcfe90b96978757e63fae08a8ce479d0affe67 /sys/boot/i386
parent87ab639764a7d4ff24c9e2ecd1f21536e3b9ceb5 (diff)
downloadFreeBSD-src-f1429e95c359a7e76f8385cdd47f887b7d1bbd0e.zip
FreeBSD-src-f1429e95c359a7e76f8385cdd47f887b7d1bbd0e.tar.gz
MFC boot loader path and RBX constant deduplication
r294765 (imp) Move all the separate copies of the same strings into paths.h. There's nothing machine specific about these. r294765 (imp) RBX_ defines are in rbx.h, move it there. r294847 (imp) Remove static from these two. They slipped through the cracks. r294925 (imp) Fix mistake when transitioning to the new defines with ZFS loader. I hate adding yet another define, but it is the lessor of the evil choices available. Kill another evil by removing PATH_BOOT3 and replacing it with PATH_LOADER or PATH_LOADER_ZFS as appropriate. Approved by: re (gjb)
Diffstat (limited to 'sys/boot/i386')
-rw-r--r--sys/boot/i386/boot2/boot2.c49
-rw-r--r--sys/boot/i386/common/rbx.h61
-rw-r--r--sys/boot/i386/gptboot/gptboot.c10
-rw-r--r--sys/boot/i386/zfsboot/zfsboot.c10
4 files changed, 10 insertions, 120 deletions
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c
index cd384e5..401a933 100644
--- a/sys/boot/i386/boot2/boot2.c
+++ b/sys/boot/i386/boot2/boot2.c
@@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$");
#include "boot2.h"
#include "lib.h"
+#include "paths.h"
+#include "rbx.h"
/* Define to 0 to omit serial support */
#ifndef SERIAL
@@ -52,46 +54,6 @@ __FBSDID("$FreeBSD$");
#define SECOND 18 /* Circa that many ticks in a second. */
-#define RBX_ASKNAME 0x0 /* -a */
-#define RBX_SINGLE 0x1 /* -s */
-/* 0x2 is reserved for log2(RB_NOSYNC). */
-/* 0x3 is reserved for log2(RB_HALT). */
-/* 0x4 is reserved for log2(RB_INITNAME). */
-#define RBX_DFLTROOT 0x5 /* -r */
-#define RBX_KDB 0x6 /* -d */
-/* 0x7 is reserved for log2(RB_RDONLY). */
-/* 0x8 is reserved for log2(RB_DUMP). */
-/* 0x9 is reserved for log2(RB_MINIROOT). */
-#define RBX_CONFIG 0xa /* -c */
-#define RBX_VERBOSE 0xb /* -v */
-#define RBX_SERIAL 0xc /* -h */
-#define RBX_CDROM 0xd /* -C */
-/* 0xe is reserved for log2(RB_POWEROFF). */
-#define RBX_GDB 0xf /* -g */
-#define RBX_MUTE 0x10 /* -m */
-/* 0x11 is reserved for log2(RB_SELFTEST). */
-/* 0x12 is reserved for boot programs. */
-/* 0x13 is reserved for boot programs. */
-#define RBX_PAUSE 0x14 /* -p */
-#define RBX_QUIET 0x15 /* -q */
-#define RBX_NOINTR 0x1c /* -n */
-/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
-#define RBX_DUAL 0x1d /* -D */
-/* 0x1f is reserved for log2(RB_BOOTINFO). */
-
-/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
-#define RBX_MASK (OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \
- OPT_SET(RBX_DFLTROOT) | OPT_SET(RBX_KDB ) | \
- OPT_SET(RBX_CONFIG) | OPT_SET(RBX_VERBOSE) | \
- OPT_SET(RBX_SERIAL) | OPT_SET(RBX_CDROM) | \
- OPT_SET(RBX_GDB ) | OPT_SET(RBX_MUTE) | \
- OPT_SET(RBX_PAUSE) | OPT_SET(RBX_DUAL))
-
-#define PATH_DOTCONFIG "/boot.config"
-#define PATH_CONFIG "/boot/config"
-#define PATH_BOOT3 "/boot/loader"
-#define PATH_KERNEL "/boot/kernel/kernel"
-
#define ARGS 0x900
#define NOPT 14
#define NDEV 3
@@ -106,9 +68,6 @@ __FBSDID("$FreeBSD$");
#define TYPE_MAXHARD TYPE_DA
#define TYPE_FD 2
-#define OPT_SET(opt) (1 << (opt))
-#define OPT_CHECK(opt) ((opts) & OPT_SET(opt))
-
extern uint32_t _end;
static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */
@@ -143,7 +102,7 @@ static struct dsk {
} dsk;
static char cmd[512], cmddup[512], knamebuf[1024];
static const char *kname;
-static uint32_t opts;
+uint32_t opts;
static struct bootinfo bootinfo;
#if SERIAL
static int comspeed = SIOSPD;
@@ -275,7 +234,7 @@ main(void)
*/
if (!kname) {
- kname = PATH_BOOT3;
+ kname = PATH_LOADER;
if (autoboot && !keyhit(3*SECOND)) {
load();
kname = PATH_KERNEL;
diff --git a/sys/boot/i386/common/rbx.h b/sys/boot/i386/common/rbx.h
deleted file mode 100644
index 21371a5..0000000
--- a/sys/boot/i386/common/rbx.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * Copyright (c) 1998 Robert Nordier
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are freely
- * permitted provided that the above copyright notice and this
- * paragraph and the following disclaimer are duplicated in all
- * such forms.
- *
- * This software is provided "AS IS" and without any express or
- * implied warranties, including, without limitation, the implied
- * warranties of merchantability and fitness for a particular
- * purpose.
- *
- * $FreeBSD$
- */
-
-#ifndef _RBX_H_
-#define _RBX_H_
-
-#define RBX_ASKNAME 0x0 /* -a */
-#define RBX_SINGLE 0x1 /* -s */
-/* 0x2 is reserved for log2(RB_NOSYNC). */
-/* 0x3 is reserved for log2(RB_HALT). */
-/* 0x4 is reserved for log2(RB_INITNAME). */
-#define RBX_DFLTROOT 0x5 /* -r */
-#define RBX_KDB 0x6 /* -d */
-/* 0x7 is reserved for log2(RB_RDONLY). */
-/* 0x8 is reserved for log2(RB_DUMP). */
-/* 0x9 is reserved for log2(RB_MINIROOT). */
-#define RBX_CONFIG 0xa /* -c */
-#define RBX_VERBOSE 0xb /* -v */
-#define RBX_SERIAL 0xc /* -h */
-#define RBX_CDROM 0xd /* -C */
-/* 0xe is reserved for log2(RB_POWEROFF). */
-#define RBX_GDB 0xf /* -g */
-#define RBX_MUTE 0x10 /* -m */
-/* 0x11 is reserved for log2(RB_SELFTEST). */
-/* 0x12 is reserved for boot programs. */
-/* 0x13 is reserved for boot programs. */
-#define RBX_PAUSE 0x14 /* -p */
-#define RBX_QUIET 0x15 /* -q */
-#define RBX_NOINTR 0x1c /* -n */
-/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
-#define RBX_DUAL 0x1d /* -D */
-/* 0x1f is reserved for log2(RB_BOOTINFO). */
-
-/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
-#define RBX_MASK (OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \
- OPT_SET(RBX_DFLTROOT) | OPT_SET(RBX_KDB ) | \
- OPT_SET(RBX_CONFIG) | OPT_SET(RBX_VERBOSE) | \
- OPT_SET(RBX_SERIAL) | OPT_SET(RBX_CDROM) | \
- OPT_SET(RBX_GDB ) | OPT_SET(RBX_MUTE) | \
- OPT_SET(RBX_PAUSE) | OPT_SET(RBX_DUAL))
-
-#define OPT_SET(opt) (1 << (opt))
-#define OPT_CHECK(opt) ((opts) & OPT_SET(opt))
-
-extern uint32_t opts;
-
-#endif /* !_RBX_H_ */
diff --git a/sys/boot/i386/gptboot/gptboot.c b/sys/boot/i386/gptboot/gptboot.c
index 0596499..5316706 100644
--- a/sys/boot/i386/gptboot/gptboot.c
+++ b/sys/boot/i386/gptboot/gptboot.c
@@ -37,11 +37,7 @@ __FBSDID("$FreeBSD$");
#include "util.h"
#include "cons.h"
#include "gpt.h"
-
-#define PATH_DOTCONFIG "/boot.config"
-#define PATH_CONFIG "/boot/config"
-#define PATH_BOOT3 "/boot/loader"
-#define PATH_KERNEL "/boot/kernel/kernel"
+#include "paths.h"
#define ARGS 0x900
#define NOPT 14
@@ -180,7 +176,7 @@ main(void)
if (autoboot && keyhit(3)) {
if (*kname == '\0')
- memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
+ memcpy(kname, PATH_LOADER, sizeof(PATH_LOADER));
break;
}
autoboot = 0;
@@ -192,7 +188,7 @@ main(void)
*/
if (*kname != '\0')
load();
- memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
+ memcpy(kname, PATH_LOADER, sizeof(PATH_LOADER));
load();
memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
load();
diff --git a/sys/boot/i386/zfsboot/zfsboot.c b/sys/boot/i386/zfsboot/zfsboot.c
index ca82c63..6fbbc6f 100644
--- a/sys/boot/i386/zfsboot/zfsboot.c
+++ b/sys/boot/i386/zfsboot/zfsboot.c
@@ -42,14 +42,10 @@ __FBSDID("$FreeBSD$");
#include "util.h"
#include "cons.h"
#include "bootargs.h"
+#include "paths.h"
#include "libzfs.h"
-#define PATH_DOTCONFIG "/boot.config"
-#define PATH_CONFIG "/boot/config"
-#define PATH_BOOT3 "/boot/zfsloader"
-#define PATH_KERNEL "/boot/kernel/kernel"
-
#define ARGS 0x900
#define NOPT 14
#define NDEV 3
@@ -550,12 +546,12 @@ main(void)
}
/*
- * Try to exec stage 3 boot loader. If interrupted by a keypress,
+ * Try to exec /boot/loader. If interrupted by a keypress,
* or in case of failure, try to load a kernel directly instead.
*/
if (autoboot && !*kname) {
- memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
+ memcpy(kname, PATH_LOADER_ZFS, sizeof(PATH_LOADER_ZFS));
if (!keyhit(3)) {
load();
memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
OpenPOWER on IntegriCloud