Page MenuHomeFreeBSD

D7846.id20240.diff
No OneTemporary

D7846.id20240.diff

Index: sys/dev/ofw/ofw_subr.h
===================================================================
--- sys/dev/ofw/ofw_subr.h
+++ sys/dev/ofw/ofw_subr.h
@@ -46,4 +46,6 @@
int ofw_reg_to_paddr(phandle_t _dev, int _regno, bus_addr_t *_paddr,
bus_size_t *_size, pcell_t *_pci_hi);
+int ofw_parse_bootargs(void);
+
#endif
Index: sys/dev/ofw/ofw_subr.c
===================================================================
--- sys/dev/ofw/ofw_subr.c
+++ sys/dev/ofw/ofw_subr.c
@@ -34,6 +34,7 @@
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/libkern.h>
+#include <sys/reboot.h>
#include <sys/rman.h>
#include <machine/bus.h>
@@ -180,3 +181,64 @@
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.
+ */
+int
+ofw_parse_bootargs(void)
+{
+ phandle_t chosen;
+ char buf[2048]; /* early stack supposedly big enough */
+ int err;
+
+ chosen = OF_finddevice("/chosen");
+ if (chosen <= 0)
+ return (chosen);
+
+ if ((err = OF_getprop(chosen, "bootargs", buf, sizeof(buf))) != -1) {
+ _parse_bootargs(buf);
+ return (0);
+ }
+
+ return (err);
+}
Index: sys/powerpc/powerpc/machdep.c
===================================================================
--- sys/powerpc/powerpc/machdep.c
+++ sys/powerpc/powerpc/machdep.c
@@ -128,6 +128,7 @@
#include <ddb/ddb.h>
#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_subr.h>
int cold = 1;
#ifdef __powerpc64__
@@ -140,6 +141,7 @@
extern void *ap_pcpu;
struct pcpu __pcpu[MAXCPU];
+static char init_kenv[2048];
static struct trapframe frame0;
@@ -292,7 +294,7 @@
bzero(__sbss_start, __sbss_end - __sbss_start);
bzero(__bss_start, _end - __bss_start);
#endif
- init_static_kenv(NULL, 0);
+ init_static_kenv(init_kenv, sizeof(init_kenv));
}
/* Store boot environment state */
OF_initial_setup((void *)fdt, NULL, (int (*)(void *))ofentry);
@@ -335,6 +337,8 @@
OF_bootstrap();
+ ofw_parse_bootargs();
+
/*
* Initialize the console before printing anything.
*/

File Metadata

Mime Type
text/plain
Expires
Mon, Aug 17, 9:06 PM (3 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36871939
Default Alt Text
D7846.id20240.diff (3 KB)

Event Timeline