Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/fdt fdt(4): Factor out bootargs support from evbarm ...
details: https://anonhg.NetBSD.org/src/rev/9f493c196ed2
branches: trunk
changeset: 377385:9f493c196ed2
user: rin <rin%NetBSD.org@localhost>
date: Mon Jul 10 07:01:48 2023 +0000
description:
fdt(4): Factor out bootargs support from evbarm and riscv.
diffstat:
sys/arch/evbarm/fdt/fdt_machdep.c | 16 ++++------------
sys/arch/riscv/riscv/riscv_machdep.c | 15 ++++-----------
sys/dev/fdt/fdt_boot.c | 19 +++++++++++++++++--
sys/dev/fdt/fdt_boot.h | 4 +++-
4 files changed, 28 insertions(+), 26 deletions(-)
diffs (170 lines):
diff -r 299f3f75cec7 -r 9f493c196ed2 sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Mon Jul 10 07:00:11 2023 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Mon Jul 10 07:01:48 2023 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
#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);
diff -r 299f3f75cec7 -r 9f493c196ed2 sys/arch/riscv/riscv/riscv_machdep.c
--- a/sys/arch/riscv/riscv/riscv_machdep.c Mon Jul 10 07:00:11 2023 +0000
+++ b/sys/arch/riscv/riscv/riscv_machdep.c Mon Jul 10 07:01:48 2023 +0000
@@ -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);
diff -r 299f3f75cec7 -r 9f493c196ed2 sys/dev/fdt/fdt_boot.c
--- a/sys/dev/fdt/fdt_boot.c Mon Jul 10 07:00:11 2023 +0000
+++ b/sys/dev/fdt/fdt_boot.c Mon Jul 10 07:01:48 2023 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
#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)
{
diff -r 299f3f75cec7 -r 9f493c196ed2 sys/dev/fdt/fdt_boot.h
--- a/sys/dev/fdt/fdt_boot.h Mon Jul 10 07:00:11 2023 +0000
+++ b/sys/dev/fdt/fdt_boot.h Mon Jul 10 07:01:48 2023 +0000
@@ -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);
Home |
Main Index |
Thread Index |
Old Index