Skip to content

Commit

Permalink
Mcs support (#19)
Browse files Browse the repository at this point in the history
* start add some of the mcs features

* add lot's of mcs todo codes and add the new pbf of aarch64

* add the no mcs case framework

* pass the rel4_complier

* put in all the symbols

* update the fastpath_reply_recv

* try to add the riscv pbf support

* fill in the real riscv pbf
  • Loading branch information
ZhiyuanSue authored Nov 15, 2024
1 parent c03fd28 commit 0380995
Show file tree
Hide file tree
Showing 46 changed files with 2,018 additions and 65 deletions.
41 changes: 33 additions & 8 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def parse_args():
parser.add_argument('-p', '--platform', dest='platform', default='spike', help="set-platform")
parser.add_argument('-c', '--cpu', dest="cpu_nums", type=int,
help="kernel & qemu cpu nums", default=1)
parser.add_argument('-m', '--mcs', dest='mcs', default='off', help="set-mcs")
args = parser.parse_args()
return args

Expand All @@ -48,6 +49,10 @@ def clean_config():
elif args.platform == "qemu-arm-virt":
target = "aarch64-unknown-none-softfloat"

mcs = False
if args.mcs == "on":
mcs = True

if os.path.exists(build_dir):
shutil.rmtree(build_dir)
os.makedirs(build_dir)
Expand All @@ -58,21 +63,41 @@ def clean_config():
sys.exit(-1)
else:
if args.cpu_nums > 1:
if not exec_shell(f"cargo build --release --target {target} --features ENABLE_SMP"):
clean_config()
sys.exit(-1)
if mcs == True:
print("[ Config ] multi cpu and mcs\n")
if not exec_shell(f"cargo build --release --target {target} --features \"ENABLE_SMP KERNEL_MCS\""):
clean_config()
sys.exit(-1)
else:
print("[ Config ] multi cpu no mcs\n")
if not exec_shell(f"cargo build --release --target {target} --features ENABLE_SMP"):
clean_config()
sys.exit(-1)
else:
if not exec_shell(f"cargo build --release --target {target}"):
clean_config()
sys.exit(-1)
if mcs == True:
print("[ Config ] single cpu and mcs\n")
if not exec_shell(f"cargo build --release --target {target} --features \"KERNEL_MCS\""):
clean_config()
sys.exit(-1)
else:
print("[ Config ] single cpu no mcs\n")
if not exec_shell(f"cargo build --release --target {target}"):
clean_config()
sys.exit(-1)

if args.cpu_nums > 1:
shell_command = f"cd ./build && ../../init-build.sh -DPLATFORM={args.platform} -DSIMULATION=TRUE -DSMP=TRUE && ninja"
shell_command = f"cd ./build && ../../init-build.sh -DPLATFORM={args.platform} -DSIMULATION=TRUE -DSMP=TRUE "
if mcs==True:
shell_command = shell_command + " -DMCS=TRUE "
shell_command = shell_command + " && ninja"
if not exec_shell(shell_command):
clean_config()
sys.exit(-1)
sys.exit(0)
shell_command = f"cd ./build && ../../init-build.sh -DPLATFORM={args.platform} -DSIMULATION=TRUE && ninja"
shell_command = f"cd ./build && ../../init-build.sh -DPLATFORM={args.platform} -DSIMULATION=TRUE "
if mcs==True:
shell_command = shell_command + " -DMCS=TRUE "
shell_command = shell_command + " && ninja"
if not exec_shell(shell_command):
clean_config()
sys.exit(-1)
Expand Down
1 change: 1 addition & 0 deletions kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ driver-collect = { git = "https://github.com/rel4team/driver-collect.git", branc

[features]
ENABLE_SMP = ["sel4_common/ENABLE_SMP", "sel4_task/ENABLE_SMP", "sel4_vspace/ENABLE_SMP"]
KERNEL_MCS = ["sel4_common/KERNEL_MCS", "sel4_task/KERNEL_MCS", "sel4_cspace/KERNEL_MCS"]

[profile.release]
lto = true
18 changes: 18 additions & 0 deletions kernel/src/boot/root_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub static mut rootserver: rootserver_mem_t = rootserver_mem_t {
boot_info: 0,
extra_bi: 0,
tcb: 0,
#[cfg(feature = "KERNEL_MCS")]
sc: 0,
paging: region_t {
start: (0),
end: (0),
Expand Down Expand Up @@ -95,6 +97,11 @@ pub fn root_server_init(
) {
return None;
}

// #ifdef CONFIG_KERNEL_MCS
// init_sched_control(root_cnode_cap, CONFIG_MAX_NUM_NODES);
// #endif

let ipcbuf_cap = unsafe { create_ipcbuf_frame_cap(&root_cnode_cap, &it_pd_cap, ipcbuf_vptr) };
if ipcbuf_cap.clone().unsplay().get_tag() == cap_tag::cap_null_cap {
debug!("ERROR: could not create IPC buffer for initial thread");
Expand Down Expand Up @@ -140,6 +147,7 @@ unsafe fn create_initial_thread(
ipcbuf_vptr: usize,
ipcbuf_cap: cap_frame_cap,
) -> *mut tcb_t {
// TODO: MCS
let tcb = convert_to_mut_type_ref::<tcb_t>(rootserver.tcb + TCB_OFFSET);
tcb.tcbTimeSlice = CONFIG_TIME_SLICE;
tcb.tcbArch = ArchTCB::default();
Expand Down Expand Up @@ -176,6 +184,7 @@ unsafe fn create_initial_thread(
tcb.tcbMCP = seL4_MaxPrio;
tcb.tcbPriority = seL4_MaxPrio;
set_thread_state(tcb, ThreadState::ThreadStateRunning);
#[cfg(not(feature = "KERNEL_MCS"))]
tcb.setup_reply_master();
ksCurDomain = ksDomSchedule[ksDomScheduleIdx].domain;
ksDomainTime = ksDomSchedule[ksDomScheduleIdx].length;
Expand Down Expand Up @@ -204,6 +213,7 @@ unsafe fn create_initial_thread(
ipcbuf_vptr: usize,
ipcbuf_cap: cap_frame_cap,
) -> *mut tcb_t {
// TODO: MCS
let tcb = convert_to_mut_type_ref::<tcb_t>(rootserver.tcb + TCB_OFFSET);
tcb.tcbTimeSlice = CONFIG_TIME_SLICE;
tcb.tcbArch = ArchTCB::default();
Expand Down Expand Up @@ -240,6 +250,7 @@ unsafe fn create_initial_thread(
tcb.tcbMCP = seL4_MaxPrio;
tcb.tcbPriority = seL4_MaxPrio;
set_thread_state(tcb, ThreadState::ThreadStateRunning);
#[cfg(not(feature = "KERNEL_MCS"))]
tcb.setup_reply_master();
ksCurDomain = ksDomSchedule[ksDomScheduleIdx].domain;
ksDomainTime = ksDomSchedule[ksDomScheduleIdx].length;
Expand Down Expand Up @@ -310,6 +321,13 @@ fn create_it_asid_pool(root_cnode_cap: &cap_cnode_cap) -> cap_asid_pool_cap {
);
ap_cap
}

#[cfg(feature = "KERNEL_MCS")]
//TODO: MCS
fn init_sched_control(root_cnode_cap: &cap_cnode_cap, num_nodes: usize) -> bool {
true
}

#[cfg(target_arch = "aarch64")]
fn create_frame_ui_frames(
root_cnode_cap: &cap_cnode_cap,
Expand Down
Loading

0 comments on commit 0380995

Please sign in to comment.