From d9b7d070c9fc6c562dd7cd3064fc19681c9f29cf Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Sun, 11 Feb 2024 00:35:11 -0800 Subject: [PATCH] [top] add header declaration for lk_boot_args Update users of the boot args array to use the header. --- lib/bootargs/bootargs.c | 10 ++++------ platform/jh7110/platform.c | 3 +-- platform/qemu-virt-riscv/platform.c | 3 +-- platform/rosco-m68k/platform.c | 9 +++++---- top/include/lk/main.h | 3 +++ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/bootargs/bootargs.c b/lib/bootargs/bootargs.c index 915226265e..ffffcad483 100644 --- a/lib/bootargs/bootargs.c +++ b/lib/bootargs/bootargs.c @@ -7,12 +7,13 @@ */ #include +#include +#include +#include #include -#include #include -#include +#include #include -#include #if WITH_KERNEL_VM #include @@ -20,9 +21,6 @@ #define LOCAL_TRACE 0 -/* saved by the main entry point in lk */ -extern ulong lk_boot_args[4]; - static bool boot_args_valid = false; static struct lk_boot_arg *boot_args; diff --git a/platform/jh7110/platform.c b/platform/jh7110/platform.c index db2d579bda..77bfe2a46e 100644 --- a/platform/jh7110/platform.c +++ b/platform/jh7110/platform.c @@ -7,6 +7,7 @@ */ #include #include +#include #include #include #include @@ -30,8 +31,6 @@ #define LOCAL_TRACE 1 -extern ulong lk_boot_args[4]; - #if WITH_KERNEL_VM #define DEFAULT_MEMORY_SIZE (MEMSIZE) /* try to fetch from the emulator via the fdt */ diff --git a/platform/qemu-virt-riscv/platform.c b/platform/qemu-virt-riscv/platform.c index 532550276e..9fbfc3710d 100644 --- a/platform/qemu-virt-riscv/platform.c +++ b/platform/qemu-virt-riscv/platform.c @@ -7,6 +7,7 @@ */ #include #include +#include #include #include #include @@ -37,8 +38,6 @@ #define LOCAL_TRACE 0 -extern ulong lk_boot_args[4]; - #if WITH_KERNEL_VM #define DEFAULT_MEMORY_SIZE (MEMSIZE) /* try to fetch from the emulator via the fdt */ diff --git a/platform/rosco-m68k/platform.c b/platform/rosco-m68k/platform.c index c5e16fb25c..c3f5d5688e 100644 --- a/platform/rosco-m68k/platform.c +++ b/platform/rosco-m68k/platform.c @@ -6,6 +6,7 @@ * https://opensource.org/licenses/MIT */ #include +#include #include #include #include @@ -44,19 +45,19 @@ struct rosco_system_data_block { }; STATIC_ASSERT(sizeof(struct rosco_system_data_block) == 0x20); -const volatile struct rosco_system_data_block *sdb = (void *)0x400; - void platform_early_init(void) { duart_early_init(); + volatile struct rosco_system_data_block *sdb = (void *)lk_boot_args[0]; + // default to 1MB memory at 0 uint32_t membase = 0x0; uint32_t memsize = 0x100000; // 1MB if (sdb->magic != ROSCO_SDB_MAGIC) { - dprintf(INFO, "ROSCO-M68K: firmware failed magic check\n"); + dprintf(INFO, "ROSCO-M68K: firmware failed magic check at %p\n", sdb); } else { - dprintf(INFO, "ROSCO-M68K: firmware structure at 0x400 - 0x41f:\n"); + dprintf(INFO, "ROSCO-M68K: firmware structure at %p - %p:\n", sdb, sdb + 0x1f); hexdump((void *)sdb, sizeof(*sdb)); printf("cpu family %u speed %u\n", sdb->cpu_info >> 29, sdb->cpu_info & 0x1fffffff); diff --git a/top/include/lk/main.h b/top/include/lk/main.h index d473f61fb0..6bfc230b7b 100644 --- a/top/include/lk/main.h +++ b/top/include/lk/main.h @@ -12,6 +12,9 @@ __BEGIN_CDECLS +// Possible boot args passed from various arch's start.S +extern ulong lk_boot_args[4]; + void lk_main(ulong arg0, ulong arg1, ulong arg2, ulong arg3) __NO_RETURN __EXTERNALLY_VISIBLE; void lk_secondary_cpu_entry(void); void lk_init_secondary_cpus(uint secondary_cpu_count);