Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F158647521
D16205.id45114.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
12 KB
Referenced Files
None
Subscribers
None
D16205.id45114.diff
View Options
Index: sys/dev/ofw/ofw_subr.c
===================================================================
--- sys/dev/ofw/ofw_subr.c
+++ sys/dev/ofw/ofw_subr.c
@@ -184,44 +184,6 @@
return (0);
}
-/* Parse cmd line args as env - copied from xlp_machdep. */
-/* XXX-BZ this should really be centrally provided for all (boot) code. */
-static void
-_parse_bootargs(char *cmdline)
-{
- char *n, *v;
-
- while ((v = strsep(&cmdline, " \n")) != NULL) {
- if (*v == '\0')
- continue;
- if (*v == '-') {
- while (*v != '\0') {
- v++;
- switch (*v) {
- case 'a': boothowto |= RB_ASKNAME; break;
- /* Someone should simulate that ;-) */
- case 'C': boothowto |= RB_CDROM; break;
- case 'd': boothowto |= RB_KDB; break;
- case 'D': boothowto |= RB_MULTIPLE; break;
- case 'm': boothowto |= RB_MUTE; break;
- case 'g': boothowto |= RB_GDB; break;
- case 'h': boothowto |= RB_SERIAL; break;
- case 'p': boothowto |= RB_PAUSE; break;
- case 'r': boothowto |= RB_DFLTROOT; break;
- case 's': boothowto |= RB_SINGLE; break;
- case 'v': boothowto |= RB_VERBOSE; break;
- }
- }
- } else {
- n = strsep(&v, "=");
- if (v == NULL)
- kern_setenv(n, "1");
- else
- kern_setenv(n, v);
- }
- }
-}
-
/*
* This is intended to be called early on, right after the OF system is
* initialized, so pmap may not be up yet.
@@ -238,7 +200,7 @@
return (chosen);
if ((err = OF_getprop(chosen, "bootargs", buf, sizeof(buf))) != -1) {
- _parse_bootargs(buf);
+ boothowto |= boot_parse_cmdline(buf);
return (0);
}
Index: sys/mips/atheros/ar531x/ar5315_machdep.c
===================================================================
--- sys/mips/atheros/ar531x/ar5315_machdep.c
+++ sys/mips/atheros/ar531x/ar5315_machdep.c
@@ -39,6 +39,7 @@
#include <sys/cons.h>
#include <sys/kdb.h>
#include <sys/reboot.h>
+#include <sys/boot.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
@@ -65,39 +66,6 @@
the dynamic kenv is setup */
char boot1_env[4096];
-/*
- * We get a string in from Redboot with the all the arguments together,
- * "foo=bar bar=baz". Split them up and save in kenv.
- */
-static void
-parse_argv(char *str)
-{
- char *n, *v;
-
- while ((v = strsep(&str, " ")) != NULL) {
- if (*v == '\0')
- continue;
- if (*v == '-') {
- while (*v != '\0') {
- v++;
- switch (*v) {
- case 'a': boothowto |= RB_ASKNAME; break;
- case 'd': boothowto |= RB_KDB; break;
- case 'g': boothowto |= RB_GDB; break;
- case 's': boothowto |= RB_SINGLE; break;
- case 'v': boothowto |= RB_VERBOSE; break;
- }
- }
- } else {
- n = strsep(&v, "=");
- if (v == NULL)
- kern_setenv(n, "1");
- else
- kern_setenv(n, v);
- }
- }
-}
-
void
platform_cpu_init()
{
@@ -299,7 +267,7 @@
if (MIPS_IS_VALID_PTR(argv)) {
for (i = 0; i < argc; i++) {
printf(" %s", argv[i]);
- parse_argv(argv[i]);
+ boothowto |= boot_parse_arg(argv[i]);
}
}
else
Index: sys/mips/atheros/ar71xx_machdep.c
===================================================================
--- sys/mips/atheros/ar71xx_machdep.c
+++ sys/mips/atheros/ar71xx_machdep.c
@@ -39,6 +39,7 @@
#include <sys/bus.h>
#include <sys/cons.h>
#include <sys/kdb.h>
+#include <sys/boot.h>
#include <sys/reboot.h>
#include <vm/vm.h>
@@ -66,39 +67,6 @@
the dynamic kenv is setup */
char boot1_env[4096];
-/*
- * We get a string in from Redboot with the all the arguments together,
- * "foo=bar bar=baz". Split them up and save in kenv.
- */
-static void
-parse_argv(char *str)
-{
- char *n, *v;
-
- while ((v = strsep(&str, " ")) != NULL) {
- if (*v == '\0')
- continue;
- if (*v == '-') {
- while (*v != '\0') {
- v++;
- switch (*v) {
- case 'a': boothowto |= RB_ASKNAME; break;
- case 'd': boothowto |= RB_KDB; break;
- case 'g': boothowto |= RB_GDB; break;
- case 's': boothowto |= RB_SINGLE; break;
- case 'v': boothowto |= RB_VERBOSE; break;
- }
- }
- } else {
- n = strsep(&v, "=");
- if (v == NULL)
- kern_setenv(n, "1");
- else
- kern_setenv(n, v);
- }
- }
-}
-
void
platform_cpu_init()
{
@@ -428,7 +396,7 @@
if (MIPS_IS_VALID_PTR(argv)) {
for (i = 0; i < argc; i++) {
printf(" %s", argv[i]);
- parse_argv(argv[i]);
+ boothowto |= boot_parse_arg(argv[i]);
}
}
else
Index: sys/mips/cavium/octeon_machdep.c
===================================================================
--- sys/mips/cavium/octeon_machdep.c
+++ sys/mips/cavium/octeon_machdep.c
@@ -664,30 +664,6 @@
}
/* impEND: This stuff should move back into the Cavium SDK */
-static void
-boothowto_parse(const char *v)
-{
- if ((v == NULL) || (*v != '-'))
- return;
-
- while (*v != '\0') {
- v++;
- switch (*v) {
- case 'a': boothowto |= RB_ASKNAME; break;
- case 'C': boothowto |= RB_CDROM; break;
- case 'd': boothowto |= RB_KDB; break;
- case 'D': boothowto |= RB_MULTIPLE; break;
- case 'm': boothowto |= RB_MUTE; break;
- case 'g': boothowto |= RB_GDB; break;
- case 'h': boothowto |= RB_SERIAL; break;
- case 'p': boothowto |= RB_PAUSE; break;
- case 'r': boothowto |= RB_DFLTROOT; break;
- case 's': boothowto |= RB_SINGLE; break;
- case 'v': boothowto |= RB_VERBOSE; break;
- }
- }
-}
-
/*
* The boot loader command line may specify kernel environment variables or
* applicable boot flags of boot(8).
@@ -709,7 +685,7 @@
if (v == NULL)
continue;
if (*v == '-') {
- boothowto_parse(v);
+ boothowto |= boot_parse_arg(v);
continue;
}
n = strsep(&v, "=");
Index: sys/mips/ingenic/jz4780_machdep.c
===================================================================
--- sys/mips/ingenic/jz4780_machdep.c
+++ sys/mips/ingenic/jz4780_machdep.c
@@ -173,50 +173,7 @@
#endif
}
-static void
-_parse_bootarg(char *v)
-{
- char *n;
-
- if (*v == '-') {
- while (*v != '\0') {
- v++;
- switch (*v) {
- case 'a': boothowto |= RB_ASKNAME; break;
- /* Someone should simulate that ;-) */
- case 'C': boothowto |= RB_CDROM; break;
- case 'd': boothowto |= RB_KDB; break;
- case 'D': boothowto |= RB_MULTIPLE; break;
- case 'm': boothowto |= RB_MUTE; break;
- case 'g': boothowto |= RB_GDB; break;
- case 'h': boothowto |= RB_SERIAL; break;
- case 'p': boothowto |= RB_PAUSE; break;
- case 'r': boothowto |= RB_DFLTROOT; break;
- case 's': boothowto |= RB_SINGLE; break;
- case 'v': boothowto |= RB_VERBOSE; break;
- }
- }
- } else {
- n = strsep(&v, "=");
- if (v == NULL)
- kern_setenv(n, "1");
- else
- kern_setenv(n, v);
- }
-}
-
-static void
-_parse_cmdline(int argc, char *argv[])
-{
- int i;
-
- for (i = 1; i < argc; i++)
- _parse_bootarg(argv[i]);
-}
-
#ifdef FDT
-/* Parse cmd line args as env - copied from xlp_machdep. */
-/* XXX-BZ this should really be centrally provided for all (boot) code. */
static void
_parse_bootargs(char *cmdline)
{
@@ -225,7 +182,7 @@
while ((v = strsep(&cmdline, " \n")) != NULL) {
if (*v == '\0')
continue;
- _parse_bootarg(v);
+ boothowto |= boot_parse_arg(v);
}
}
#endif
@@ -285,12 +242,12 @@
*/
chosen = OF_finddevice("/chosen");
if (OF_getprop(chosen, "bootargs", buf, sizeof(buf)) != -1)
- _parse_bootargs(buf);
+ boothowto |= boot_parse_cmdline(buf);
#endif
/* Parse cmdline from U-Boot */
argc = a0;
argv = (char **)a1;
- _parse_cmdline(argc, argv);
+ boothowto |= boot_parse_cmdline(argc, argv);
mips_init();
}
Index: sys/mips/mediatek/mtk_machdep.c
===================================================================
--- sys/mips/mediatek/mtk_machdep.c
+++ sys/mips/mediatek/mtk_machdep.c
@@ -46,6 +46,7 @@
#include <sys/proc.h>
#include <sys/kdb.h>
#include <sys/ptrace.h>
+#include <sys/boot.h>
#include <sys/reboot.h>
#include <sys/signalvar.h>
#include <sys/sysent.h>
@@ -196,52 +197,6 @@
#endif
}
-static void
-_parse_bootarg(char *v)
-{
- char *n;
-
- if (*v == '-') {
- while (*v != '\0') {
- v++;
- switch (*v) {
- case 'a': boothowto |= RB_ASKNAME; break;
- /* Someone should simulate that ;-) */
- case 'C': boothowto |= RB_CDROM; break;
- case 'd': boothowto |= RB_KDB; break;
- case 'D': boothowto |= RB_MULTIPLE; break;
- case 'm': boothowto |= RB_MUTE; break;
- case 'g': boothowto |= RB_GDB; break;
- case 'h': boothowto |= RB_SERIAL; break;
- case 'p': boothowto |= RB_PAUSE; break;
- case 'r': boothowto |= RB_DFLTROOT; break;
- case 's': boothowto |= RB_SINGLE; break;
- case 'v': boothowto |= RB_VERBOSE; break;
- }
- }
- } else {
- n = strsep(&v, "=");
- if (v == NULL)
- kern_setenv(n, "1");
- else
- kern_setenv(n, v);
- }
-}
-
-/* Parse cmd line args as env - copied from xlp_machdep. */
-/* XXX-BZ this should really be centrally provided for all (boot) code. */
-static void
-_parse_bootargs(char *cmdline)
-{
- char *v;
-
- while ((v = strsep(&cmdline, " \n")) != NULL) {
- if (*v == '\0')
- continue;
- _parse_bootarg(v);
- }
-}
-
void
platform_reset(void)
{
@@ -295,7 +250,7 @@
*/
chosen = OF_finddevice("/chosen");
if (OF_getprop(chosen, "bsdbootargs", buf, sizeof(buf)) != -1)
- _parse_bootargs(buf);
+ boothowto |= boot_parse_cmdline(buf);
printf("FDT DTB at: 0x%08x\n", (uint32_t)dtbp);
Index: sys/mips/nlm/xlp_machdep.c
===================================================================
--- sys/mips/nlm/xlp_machdep.c
+++ sys/mips/nlm/xlp_machdep.c
@@ -49,6 +49,7 @@
#include <sys/cons.h> /* cinit() */
#include <sys/kdb.h>
+#include <sys/boot.h>
#include <sys/reboot.h>
#include <sys/queue.h>
#include <sys/smp.h>
@@ -261,36 +262,6 @@
return;
}
-/* Parse cmd line args as env - copied from ar71xx */
-static void
-xlp_parse_bootargs(char *cmdline)
-{
- char *n, *v;
-
- while ((v = strsep(&cmdline, " \n")) != NULL) {
- if (*v == '\0')
- continue;
- if (*v == '-') {
- while (*v != '\0') {
- v++;
- switch (*v) {
- case 'a': boothowto |= RB_ASKNAME; break;
- case 'd': boothowto |= RB_KDB; break;
- case 'g': boothowto |= RB_GDB; break;
- case 's': boothowto |= RB_SINGLE; break;
- case 'v': boothowto |= RB_VERBOSE; break;
- }
- }
- } else {
- n = strsep(&v, "=");
- if (v == NULL)
- kern_setenv(n, "1");
- else
- kern_setenv(n, v);
- }
- }
-}
-
#ifdef FDT
static void
xlp_bootargs_init(__register_t arg)
@@ -321,7 +292,7 @@
}
if (OF_getprop(chosen, "bootargs", buf, sizeof(buf)) != -1)
- xlp_parse_bootargs(buf);
+ boothowto |= boot_parse_cmdline(buf);
}
#else
/*
@@ -363,7 +334,7 @@
v = kern_getenv("bootargs");
if (v != NULL) {
strlcpy(buf, v, sizeof(buf));
- xlp_parse_bootargs(buf);
+ boothowto |= boot_parse_cmdline(buf);
freeenv(v);
}
}
Index: sys/sys/boot.h
===================================================================
--- sys/sys/boot.h
+++ sys/sys/boot.h
@@ -54,4 +54,73 @@
{ NULL, 0}
};
+#ifdef _KERNEL
+#define SETENV(k, v) kern_setenv(k, v)
+#else
+#define SETENV(k, v) setenv(k, v, 1)
+#endif
+
+static inline int
+boot_parse_arg(char *v)
+{
+ char *n;
+ int howto;
+
+ howto = 0;
+ if (*v == '-') {
+ while (*v != '\0') {
+ v++;
+ switch (*v) {
+ case 'a': howto |= RB_ASKNAME; break;
+ case 'C': howto |= RB_CDROM; break;
+ case 'd': howto |= RB_KDB; break;
+ case 'D': howto |= RB_MULTIPLE; break;
+ case 'm': howto |= RB_MUTE; break;
+ case 'g': howto |= RB_GDB; break;
+ case 'h': howto |= RB_SERIAL; break;
+ case 'p': howto |= RB_PAUSE; break;
+ case 'P': howto |= RB_PROBE; break;
+ case 'r': howto |= RB_DFLTROOT; break;
+ case 's': howto |= RB_SINGLE; break;
+ case 'S': SETENV("comconsole_speed", v + 1); v += strlen(v); break;
+ case 'v': howto |= RB_VERBOSE; break;
+ }
+ }
+ } else {
+ n = strsep(&v, "=");
+ if (v == NULL)
+ SETENV(n, "1");
+ else
+ SETENV(n, v);
+ }
+ return (howto);
+}
+#undef SETENV
+
+static inline int
+boot_parse_cmdline(char *cmdline)
+{
+ char *v;
+ int howto;
+
+ howto = 0;
+ while ((v = strsep(&cmdline, " \n")) != NULL) {
+ if (*v == '\0')
+ continue;
+ howto |= boot_parse_arg(v);
+ }
+ return (howto);
+}
+
+static inline int
+boot_parse_args(int argc, char *argv[])
+{
+ int i, howto;
+
+ howto = 0;
+ for (i = 1; i < argc; i++)
+ howto |= boot_parse_arg(argv[i]);
+ return (howto);
+}
+
#endif /* !_SYS_BOOT_H_ */
Index: sys/sys/reboot.h
===================================================================
--- sys/sys/reboot.h
+++ sys/sys/reboot.h
@@ -63,6 +63,7 @@
#define RB_PAUSE 0x100000 /* pause after each output line during probe */
#define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */
#define RB_POWERCYCLE 0x400000 /* Power cycle if possible */
+#define RB_PROBE 0x10000000 /* Probe multiple consoles */
#define RB_MULTIPLE 0x20000000 /* use multiple consoles */
#define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jun 5, 7:56 AM (9 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33746566
Default Alt Text
D16205.id45114.diff (12 KB)
Attached To
Mode
D16205: Create three helper functions for parsing boot args.
Attached
Detach File
Event Timeline
Log In to Comment