Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
invoke rkargparse in rkboot
Browse files Browse the repository at this point in the history
  • Loading branch information
u8cat committed Jul 2, 2022
1 parent fbbb389 commit 3b2d7fa
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 78 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 2 additions & 76 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions default_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<<STACK_SIZE_PAGE_ORDER);
Expand Down
1 change: 1 addition & 0 deletions lib/rkboot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ edition = "2021"
rksched = {path = "../rksched", optional = true}
rkschedcoop = {path = "../rkschedcoop", optional = true}
rkschedpreem = {path = "../rkschedpreem", optional = true}
rkargparse = {path = "../rkargparse"}
17 changes: 17 additions & 0 deletions lib/rkboot/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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

config MAX_ARGS_CNT
int "maximum kernel argmuents count"
default 64
endmenu
14 changes: 12 additions & 2 deletions lib/rkboot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
use core::time::Duration;
use core::{slice,str};
use core::mem::{align_of, size_of};
use core::ptr::{addr_of, null_mut};
use core::ptr::{addr_of, null_mut, addr_of_mut};
use rkalloc::RKalloc;
use rkplat::{irq,time,bootstrap,device, lcpu};
#[cfg(feature="have_scheduler")]
use rksched::RKsched;
use runikraft::align_as;
use runikraft::config::HEAP_SIZE;
use runikraft::config::{HEAP_SIZE,rkboot::*};

#[cfg(any(feature="alloc_buddy"))]
static mut HEAP:align_as::A4096<[u8;HEAP_SIZE]> = align_as::A4096::new([0;HEAP_SIZE]);
Expand Down Expand Up @@ -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")]
Expand Down
51 changes: 51 additions & 0 deletions lib/rkplat/config
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3b2d7fa

Please sign in to comment.