From 3b2d7fa9e90ae58339a2241a098a80788acb21cb Mon Sep 17 00:00:00 2001 From: WCIofQMandRA Date: Sat, 2 Jul 2022 15:38:54 +0800 Subject: [PATCH] invoke rkargparse in rkboot --- Cargo.lock | 1 + Kconfig | 78 ++----------------------------------------- default_config.rs | 4 +++ lib/rkboot/Cargo.toml | 1 + lib/rkboot/config | 17 ++++++++++ lib/rkboot/src/lib.rs | 14 ++++++-- lib/rkplat/config | 51 ++++++++++++++++++++++++++++ 7 files changed, 88 insertions(+), 78 deletions(-) create mode 100644 lib/rkboot/config create mode 100644 lib/rkplat/config diff --git a/Cargo.lock b/Cargo.lock index a32dc0a..739eb9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,6 +104,7 @@ version = "0.1.0" dependencies = [ "rkalloc", "rkallocbuddy", + "rkargparse", "rkplat", "rksched", "rkschedcoop", diff --git a/Kconfig b/Kconfig index becac31..6ffe468 100644 --- a/Kconfig +++ b/Kconfig @@ -45,82 +45,8 @@ menu "Memory and CPU Configuration" endmenu menu "Library Configuration" - menu "rkplat features" - config has_smp - bool "Symmetric multiprocessor support" - default y - - config save_fp - bool "Save floating point registers when thread switches" - default n - - config driver_uart - bool "Uart device driver" - default n - - config driver_ns16550 - bool "ns16550 driver" - default y - select driver_uart - - config driver_virtio - bool "Virtio driver" - default n - help - Depend on volatile-v0.3 and bitflags-v1.3 - - config driver_virtio_blk - bool "Virtio block driver" - default y - select driver_virtio - - config driver_virtio_console - bool "Virtio console driver" - default y - select driver_virtio - - config driver_virtio_gpu - bool "Virtio GPU driver" - default y - select driver_virtio - - config driver_virtio_input - bool "Virtio input driver" - default y - select driver_virtio - - config driver_virtio_net - bool "Virtio net driver" - default y - select driver_virtio - - config driver_rtc - bool "Real time clock driver" - default n - - config driver_goldfish_rtc - bool "Goldfish real time clock driver" - default y - select driver_rtc - - config bios_io - bool "Use BIOS to output" - default n - endmenu - - menu "rkboot features" - config have_scheduler - bool "Have scheduler" - help - Depend on rksched - - config sched_coop - bool "Cooperative scheduler" - default y - select have_scheduler - help - Depend on rksched and rkschedcoop - endmenu + source "lib/rkplat/config" + source "lib/rkboot/config" endmenu menu "Make Build Configuration" diff --git a/default_config.rs b/default_config.rs index 35f1ea4..31a7938 100644 --- a/default_config.rs +++ b/default_config.rs @@ -7,6 +7,10 @@ pub const HEAP_SIZE: usize = 16<<20; +pub mod rkboot { + pub const MAX_ARGS_CNT: usize = 64; +} + pub mod rksched { pub const STACK_SIZE_PAGE_ORDER: usize = 4; pub const STACK_SIZE: usize = super::rkplat::PAGE_SIZE*(1< = align_as::A4096::new([0;HEAP_SIZE]); @@ -99,6 +99,16 @@ impl rkalloc::RKallocState for NullAllocator { } } +static mut ARGV: [*mut u8;MAX_ARGS_CNT] = [null_mut();MAX_ARGS_CNT]; + +#[no_mangle] +pub unsafe extern "C" fn rkplat_entry_argp(arg0: *mut u8, argb: *mut u8, argb_len: usize) -> ! { + let argc = rkargparse::argnparse(argb, if argb_len==0 {usize::MAX/1024} else {argb_len}, + addr_of_mut!(ARGV[1]), MAX_ARGS_CNT-1); + ARGV[0] = arg0; + rkplat_entry(argc, ARGV.as_mut_ptr()) +} + #[no_mangle] pub unsafe extern "C" fn rkplat_entry(argc: i32, argv: *mut *mut u8) -> ! { #[cfg(feature="alloc_buddy")] diff --git a/lib/rkplat/config b/lib/rkplat/config new file mode 100644 index 0000000..1baa225 --- /dev/null +++ b/lib/rkplat/config @@ -0,0 +1,51 @@ +menu "rkplat features" + config has_smp + bool "Symmetric multiprocessor support" + default y + + config save_fp + bool "Save floating point registers when thread switches" + default n + config driver_uart + bool "Uart device driver" + default n + config driver_ns16550 + bool "ns16550 driver" + default y + select driver_uart + config driver_virtio + bool "Virtio driver" + default n + help + Depend on volatile-v0.3 and bitflags-v1.3 + config driver_virtio_blk + bool "Virtio block driver" + default y + select driver_virtio + config driver_virtio_console + bool "Virtio console driver" + default y + select driver_virtio + config driver_virtio_gpu + bool "Virtio GPU driver" + default y + select driver_virtio + config driver_virtio_input + bool "Virtio input driver" + default y + select driver_virtio + config driver_virtio_net + bool "Virtio net driver" + default y + select driver_virtio + config driver_rtc + bool "Real time clock driver" + default n + config driver_goldfish_rtc + bool "Goldfish real time clock driver" + default y + select driver_rtc + config bios_io + bool "Use BIOS to output" + default n +endmenu