Module Name: src
Committed By: rin
Date: Mon Jul 10 07:01:48 UTC 2023
Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c
src/sys/arch/riscv/riscv: riscv_machdep.c
src/sys/dev/fdt: fdt_boot.c fdt_boot.h
Log Message:
fdt(4): Factor out bootargs support from evbarm and riscv.
To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/evbarm/fdt/fdt_machdep.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/riscv/riscv/riscv_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/fdt_boot.c \
src/sys/dev/fdt/fdt_boot.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.104 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.105
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.104 Mon Jul 10 07:00:12 2023
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c Mon Jul 10 07:01:48 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.104 2023/07/10 07:00:12 rin Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.105 2023/07/10 07:01:48 rin Exp $ */
/*-
* Copyright (c) 2015-2017 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.104 2023/07/10 07:00:12 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.105 2023/07/10 07:01:48 rin Exp $");
#include "opt_arm_debug.h"
#include "opt_bootconfig.h"
@@ -110,12 +110,7 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_machdep.
#include <dev/wscons/wsdisplayvar.h>
#endif
-#ifndef FDT_MAX_BOOT_STRING
-#define FDT_MAX_BOOT_STRING 1024
-#endif
-
BootConfig bootconfig;
-char bootargs[FDT_MAX_BOOT_STRING] = "";
char *boot_args = NULL;
/* filled in before cleaning bss. keep in .data */
@@ -282,10 +277,7 @@ initarm(void *arg)
/* Early console may be available, announce ourselves. */
VPRINTF("FDT<%p>\n", fdt_addr_r);
- const int chosen = OF_finddevice("/chosen");
- if (chosen >= 0)
- OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
- boot_args = bootargs;
+ boot_args = fdt_get_bootargs();
/* Heads up ... Setup the CPU / MMU / TLB functions. */
VPRINTF("cpufunc\n");
@@ -383,7 +375,7 @@ initarm(void *arg)
/* Perform PT build and VM init */
cpu_kernel_vm_init(memory_start, memory_size);
- VPRINTF("bootargs: %s\n", bootargs);
+ VPRINTF("bootargs: %s\n", boot_args);
parse_mi_bootargs(boot_args);
Index: src/sys/arch/riscv/riscv/riscv_machdep.c
diff -u src/sys/arch/riscv/riscv/riscv_machdep.c:1.29 src/sys/arch/riscv/riscv/riscv_machdep.c:1.30
--- src/sys/arch/riscv/riscv/riscv_machdep.c:1.29 Mon Jun 12 19:04:14 2023
+++ src/sys/arch/riscv/riscv/riscv_machdep.c Mon Jul 10 07:01:48 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: riscv_machdep.c,v 1.29 2023/06/12 19:04:14 skrll Exp $ */
+/* $NetBSD: riscv_machdep.c,v 1.30 2023/07/10 07:01:48 rin Exp $ */
/*-
* Copyright (c) 2014, 2019, 2022 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include "opt_riscv_debug.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: riscv_machdep.c,v 1.29 2023/06/12 19:04:14 skrll Exp $");
+__RCSID("$NetBSD: riscv_machdep.c,v 1.30 2023/07/10 07:01:48 rin Exp $");
#include <sys/param.h>
@@ -81,13 +81,9 @@ char machine_arch[] = MACHINE_ARCH;
#define VPRINTF(...) __nothing
#endif
-#ifndef FDT_MAX_BOOT_STRING
-#define FDT_MAX_BOOT_STRING 1024
-#endif
/* 64 should be enough, even for a ZFS UUID */
#define MAX_BOOT_DEV_STR 64
-char bootargs[FDT_MAX_BOOT_STRING] = "";
char bootdevstr[MAX_BOOT_DEV_STR] = "";
char *boot_args = NULL;
@@ -716,10 +712,7 @@ init_riscv(register_t hartid, paddr_t dt
/* Early console may be available, announce ourselves. */
VPRINTF("FDT<%p>\n", fdt_data);
- const int chosen = OF_finddevice("/chosen");
- if (chosen >= 0)
- OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
- boot_args = bootargs;
+ boot_args = fdt_get_bootargs();
VPRINTF("devmap %p\n", plat->fp_devmap());
pmap_devmap_bootstrap(0, plat->fp_devmap());
@@ -783,7 +776,7 @@ init_riscv(register_t hartid, paddr_t dt
/* Perform PT build and VM init */
cpu_kernel_vm_init(memory_start, memory_end);
- VPRINTF("bootargs: %s\n", bootargs);
+ VPRINTF("bootargs: %s\n", boot_args);
parse_mi_bootargs(boot_args);
Index: src/sys/dev/fdt/fdt_boot.c
diff -u src/sys/dev/fdt/fdt_boot.c:1.2 src/sys/dev/fdt/fdt_boot.c:1.3
--- src/sys/dev/fdt/fdt_boot.c:1.2 Mon Jul 10 07:00:12 2023
+++ src/sys/dev/fdt/fdt_boot.c Mon Jul 10 07:01:48 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_boot.c,v 1.2 2023/07/10 07:00:12 rin Exp $ */
+/* $NetBSD: fdt_boot.c,v 1.3 2023/07/10 07:01:48 rin Exp $ */
/*-
* Copyright (c) 2015-2017 Jared McNeill <[email protected]>
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v 1.2 2023/07/10 07:00:12 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v 1.3 2023/07/10 07:01:48 rin Exp $");
#include "opt_efi.h"
#include "opt_md.h"
@@ -87,6 +87,11 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v
#endif
#include <dev/fdt/fdt_memory.h>
+#ifndef FDT_MAX_BOOT_STRING
+#define FDT_MAX_BOOT_STRING 1024
+#endif
+static char bootargs[FDT_MAX_BOOT_STRING] = "";
+
#ifdef EFI_RUNTIME
#include <machine/efirt.h>
@@ -186,6 +191,16 @@ fdt_unmap_range(void *ptr, uint64_t size
uvm_km_free(kernel_map, startva, sz, UVM_KMF_VAONLY);
}
+char *
+fdt_get_bootargs(void)
+{
+ const int chosen = OF_finddevice("/chosen");
+
+ if (chosen >= 0)
+ OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
+ return bootargs;
+}
+
void
fdt_probe_initrd(void)
{
Index: src/sys/dev/fdt/fdt_boot.h
diff -u src/sys/dev/fdt/fdt_boot.h:1.2 src/sys/dev/fdt/fdt_boot.h:1.3
--- src/sys/dev/fdt/fdt_boot.h:1.2 Mon Jul 10 07:00:12 2023
+++ src/sys/dev/fdt/fdt_boot.h Mon Jul 10 07:01:48 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_boot.h,v 1.2 2023/07/10 07:00:12 rin Exp $ */
+/* $NetBSD: fdt_boot.h,v 1.3 2023/07/10 07:01:48 rin Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -38,6 +38,8 @@
void fdt_map_efi_runtime(const char *prop, enum cpu_efirt_mem_type type);
#endif
+char *fdt_get_bootargs(void);
+
void fdt_probe_initrd(void);
void fdt_setup_initrd(void);
void fdt_reserve_initrd(void);