Skip to content

Commit

Permalink
clean warnings and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhiyuanSue committed Aug 27, 2024
1 parent 9cc0f27 commit 5855819
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 99 deletions.
39 changes: 19 additions & 20 deletions kernel/src/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,26 +143,25 @@ pub fn bi_finalise(dtb_size: usize, dtb_phys_addr: usize, extra_bi_size: usize)

pub fn init_core_state(scheduler_action: *mut tcb_t) {
// unsafe {
// #[cfg(feature = "ENABLE_SMP")]
// if scheduler_action as usize != 0 && scheduler_action as usize != 1 {
// tcbDebugAppend(scheduler_action);
// }
// let idle_thread = {
// #[cfg(not(feature = "ENABLE_SMP"))]
// {
// ksIdleThread as *mut tcb_t
// }
// #[cfg(feature = "ENABLE_SMP")]
// {
// ksSMP[cpu_id()].ksIdleThread as *mut tcb_t
// }
// };
// tcbDebugAppend(idle_thread);
// }

set_current_scheduler_action(scheduler_action as usize);
set_current_thread(get_idle_thread());

// #[cfg(feature = "ENABLE_SMP")]
// if scheduler_action as usize != 0 && scheduler_action as usize != 1 {
// tcbDebugAppend(scheduler_action);
// }
// let idle_thread = {
// #[cfg(not(feature = "ENABLE_SMP"))]
// {
// ksIdleThread as *mut tcb_t
// }
// #[cfg(feature = "ENABLE_SMP")]
// {
// ksSMP[cpu_id()].ksIdleThread as *mut tcb_t
// }
// };
// tcbDebugAppend(idle_thread);
// }

set_current_scheduler_action(scheduler_action as usize);
set_current_thread(get_idle_thread());
}

#[cfg(feature = "ENABLE_SMP")]
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/interfaces_impl/cspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub fn finaliseCap(cap: &cap_t, _final: bool, _exposed: bool) -> finaliseCap_ret
safe_unbind_notification(tcb);
tcb.cancel_ipc();
tcb.suspend();
// #[cfg(feature="DEBUG_BUILD")]
// #[cfg(feature="DEBUG_BUILD")]
// unsafe {
// tcbDebugRemove(tcb as *mut tcb_t);
// }
Expand Down
44 changes: 22 additions & 22 deletions kernel/src/kernel/fastpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub fn fastpath_copy_mrs(length: usize, src: &mut tcb_t, dest: &mut tcb_t) {
#[no_mangle]
#[cfg(target_arch = "aarch64")]
pub fn fastpath_restore(_badge: usize, _msgInfo: usize, cur_thread: *mut tcb_t) {
use core::arch::asm;
use core::arch::asm;
unsafe {
(*cur_thread).tcbArch.load_thread_local();
asm!(
Expand Down Expand Up @@ -180,13 +180,13 @@ pub fn fastpath_restore(_badge: usize, _msgInfo: usize, cur_thread: *mut tcb_t)
pub fn fastpath_restore(_badge: usize, _msgInfo: usize, cur_thread: *mut tcb_t) {
#[cfg(feature = "ENABLE_SMP")]
{}
extern "C" {
pub fn __fastpath_restore(badge: usize, msgInfo: usize, cur_thread_reg: usize);
}
unsafe {
__fastpath_restore(_badge,_msgInfo,(*cur_thread).tcbArch.raw_ptr());
}
panic!("unreachable")
extern "C" {
pub fn __fastpath_restore(badge: usize, msgInfo: usize, cur_thread_reg: usize);
}
unsafe {
__fastpath_restore(_badge, _msgInfo, (*cur_thread).tcbArch.raw_ptr());
}
panic!("unreachable")
}

#[inline]
Expand Down Expand Up @@ -262,7 +262,7 @@ pub fn fastpath_call(cptr: usize, msgInfo: usize) {
info.set_caps_unwrapped(0);
let msgInfo1 = info.to_word();
let badge = ep_cap.get_ep_badge();
fastpath_restore(badge, msgInfo1, get_currenct_thread());
fastpath_restore(badge, msgInfo1, get_currenct_thread());
}

#[inline]
Expand Down Expand Up @@ -344,18 +344,18 @@ pub fn fastpath_reply_recv(cptr: usize, msgInfo: usize) {
);

// unsafe {
let node = convert_to_mut_type_ref::<cte_t>(caller_slot.cteMDBNode.get_prev());
mdb_node_ptr_mset_mdbNext_mdbRevocable_mdbFirstBadged(&mut node.cteMDBNode, 0, 1, 1);
caller_slot.cap = cap_t::new_null_cap();
caller_slot.cteMDBNode = mdb_node_t::new(0, 0, 0, 0);
fastpath_copy_mrs(length, current, caller);

caller.tcbState.words[0] = ThreadState::ThreadStateRunning as usize;
let cap_pd = new_vtable.get_pt_base_ptr() as *mut PTE;
let stored_hw_asid: PTE = PTE(new_vtable.get_pt_mapped_asid());
switchToThread_fp(caller, cap_pd, stored_hw_asid);
info.set_caps_unwrapped(0);
let msg_info1 = info.to_word();
fastpath_restore(0, msg_info1, get_currenct_thread() as *mut tcb_t);
let node = convert_to_mut_type_ref::<cte_t>(caller_slot.cteMDBNode.get_prev());
mdb_node_ptr_mset_mdbNext_mdbRevocable_mdbFirstBadged(&mut node.cteMDBNode, 0, 1, 1);
caller_slot.cap = cap_t::new_null_cap();
caller_slot.cteMDBNode = mdb_node_t::new(0, 0, 0, 0);
fastpath_copy_mrs(length, current, caller);

caller.tcbState.words[0] = ThreadState::ThreadStateRunning as usize;
let cap_pd = new_vtable.get_pt_base_ptr() as *mut PTE;
let stored_hw_asid: PTE = PTE(new_vtable.get_pt_mapped_asid());
switchToThread_fp(caller, cap_pd, stored_hw_asid);
info.set_caps_unwrapped(0);
let msg_info1 = info.to_word();
fastpath_restore(0, msg_info1, get_currenct_thread() as *mut tcb_t);
// }
}
4 changes: 2 additions & 2 deletions kernel/src/kernel/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod boot;
pub mod fastpath;
pub mod fault;
#[cfg(target_arch="riscv64")]
core::arch::global_asm!(include_str!("fastpath_restore.S"));
#[cfg(target_arch = "riscv64")]
core::arch::global_asm!(include_str!("fastpath_restore.S"));
4 changes: 2 additions & 2 deletions kernel/src/syscall/invocation/invoke_untyped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn create_object(
tcb.init();
tcb.tcbTimeSlice = CONFIG_TIME_SLICE;
tcb.domain = get_current_domain();
// #[cfg(feature="DEBUG_BUILD")]
// #[cfg(feature="DEBUG_BUILD")]
// unsafe {
// tcbDebugAppend(tcb as *mut tcb_t);
// }
Expand Down Expand Up @@ -90,7 +90,7 @@ fn create_object(
tcb.init();
tcb.tcbTimeSlice = CONFIG_TIME_SLICE;
tcb.domain = get_current_domain();
// #[cfg(feature="DEBUG_BUILD")]
// #[cfg(feature="DEBUG_BUILD")]
// unsafe {
// tcbDebugAppend(tcb as *mut tcb_t);
// }
Expand Down
8 changes: 4 additions & 4 deletions kernel/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[cfg(target_arch="aarch64")]
#[cfg(target_arch = "aarch64")]
use sel4_common::{
sel4_config::{ID_AA64PFR0_EL1_ASIMD, ID_AA64PFR0_EL1_FP},
MASK,
};
#[cfg(target_arch="aarch64")]
#[cfg(target_arch = "aarch64")]
use sel4_vspace::{dsb, isb};

use crate::BIT;
Expand Down Expand Up @@ -62,7 +62,7 @@ pub fn clear_memory_pt(ptr: *mut u8, bits: usize) {
}

#[inline]
#[cfg(target_arch="aarch64")]
#[cfg(target_arch = "aarch64")]
pub fn setVTable(addr: usize) {
dsb();
unsafe {
Expand All @@ -72,7 +72,7 @@ pub fn setVTable(addr: usize) {
}

#[inline]
#[cfg(target_arch="aarch64")]
#[cfg(target_arch = "aarch64")]
pub fn fpsimd_HWCapTest() -> bool {
let mut id_aa64pfr0: usize;

Expand Down
3 changes: 1 addition & 2 deletions sel4_vspace/src/arch/aarch64/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use sel4_common::{
config::{PADDR_BASE, PADDR_TOP, PPTR_BASE, PPTR_TOP},
vm_rights_t,
},
ffi_call,
sel4_config::{seL4_LargePageBits, ARM_Large_Page, ARM_Small_Page, PUD_INDEX_BITS},
utils::convert_to_mut_type_ref,
BIT,
Expand Down Expand Up @@ -124,7 +123,7 @@ pub fn rust_map_kernel_window() {
BIT!(PUD_INDEX_BITS) - 1,
PDE::new_small(kpptr_to_paddr(get_kernel_page_table_base())),
);
map_kernel_devices();
map_kernel_devices();
// ffi_call!(map_kernel_devices());
}

Expand Down
93 changes: 49 additions & 44 deletions sel4_vspace/src/arch/aarch64/device.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use crate::{paddr_t, pptr_t, vm_attributes_t};
use super::boot::map_kernel_frame;
use crate::{paddr_t, pptr_t, vm_attributes_t};
use sel4_common::arch::vm_rights_t::VMKernelOnly;
use sel4_common::{sel4_config::PAGE_BITS, BIT};

pub const KDEV_BASE: usize = 0xFFFFFFFFC0000000;
pub(crate) const NUM_KERNEL_DEVICE_FRAMES:usize=3;
pub(crate) const UART_PPTR:usize=KDEV_BASE+ 0x0;
pub(crate) const GIC_V2_DISTRIBUTOR_PPTR:usize= KDEV_BASE + 0x1000;
pub(crate) const GIC_V2_CONTROLLER_PPTR:usize=KDEV_BASE + 0x2000;
pub(crate) const NUM_KERNEL_DEVICE_FRAMES: usize = 3;
pub(crate) const UART_PPTR: usize = KDEV_BASE + 0x0;
pub(crate) const GIC_V2_DISTRIBUTOR_PPTR: usize = KDEV_BASE + 0x1000;
pub(crate) const GIC_V2_CONTROLLER_PPTR: usize = KDEV_BASE + 0x2000;
#[derive(Copy, Clone)]
struct kernel_frame_t{
paddr:paddr_t,
pptr:pptr_t,
armExecuteNever:isize,
userAvailable:isize,
struct kernel_frame_t {
paddr: paddr_t,
pptr: pptr_t,
armExecuteNever: isize,
userAvailable: isize,
}

#[derive(Copy, Clone)]
Expand All @@ -23,43 +23,48 @@ struct p_region_t {
pub end: usize,
}
extern "C" {
pub(self) fn reserve_region(reg: p_region_t) -> bool;
pub(self) fn reserve_region(reg: p_region_t) -> bool;
}

#[no_mangle]
#[link_section = ".boot.text"]
pub(self) static mut kernel_device_frames:[kernel_frame_t;NUM_KERNEL_DEVICE_FRAMES]=[
kernel_frame_t{
paddr:paddr_t(0x9000000),
pptr :UART_PPTR,
armExecuteNever : 1,
userAvailable : 1
},
kernel_frame_t{
paddr : paddr_t(0x8000000),
pptr : GIC_V2_DISTRIBUTOR_PPTR,
armExecuteNever : 1,
userAvailable : 0
},
kernel_frame_t{
paddr : paddr_t(0x8010000),
pptr : GIC_V2_CONTROLLER_PPTR,
armExecuteNever :1,
userAvailable :0
},
pub(self) static mut kernel_device_frames: [kernel_frame_t; NUM_KERNEL_DEVICE_FRAMES] = [
kernel_frame_t {
paddr: paddr_t(0x9000000),
pptr: UART_PPTR,
armExecuteNever: 1,
userAvailable: 1,
},
kernel_frame_t {
paddr: paddr_t(0x8000000),
pptr: GIC_V2_DISTRIBUTOR_PPTR,
armExecuteNever: 1,
userAvailable: 0,
},
kernel_frame_t {
paddr: paddr_t(0x8010000),
pptr: GIC_V2_CONTROLLER_PPTR,
armExecuteNever: 1,
userAvailable: 0,
},
];
#[no_mangle]
pub fn map_kernel_devices(){
unsafe {
for kernel_frame in kernel_device_frames{
let vm_attr:vm_attributes_t=vm_attributes_t(kernel_frame.armExecuteNever as usize);
map_kernel_frame(kernel_frame.paddr.0,kernel_frame.pptr,VMKernelOnly,vm_attr);
if kernel_frame.userAvailable ==0{
reserve_region(p_region_t {
start: kernel_frame.paddr.0,
end: kernel_frame.paddr.0 + BIT!(PAGE_BITS),
});
}
}
}
}
pub fn map_kernel_devices() {
unsafe {
for kernel_frame in kernel_device_frames {
let vm_attr: vm_attributes_t = vm_attributes_t(kernel_frame.armExecuteNever as usize);
map_kernel_frame(
kernel_frame.paddr.0,
kernel_frame.pptr,
VMKernelOnly,
vm_attr,
);
if kernel_frame.userAvailable == 0 {
reserve_region(p_region_t {
start: kernel_frame.paddr.0,
end: kernel_frame.paddr.0 + BIT!(PAGE_BITS),
});
}
}
}
}
4 changes: 2 additions & 2 deletions sel4_vspace/src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
mod asid;
mod boot;
mod device;
mod interface;
mod machine;
mod pagetable;
mod pte;
mod structures;
mod utils;
mod device;
pub use asid::*;
pub use boot::*;
pub use device::*;
pub use interface::*;
pub use machine::*;
pub use pagetable::create_it_pud_cap;
pub use pte::PTEFlags;
pub use structures::*;
pub use utils::*;
pub use device::*;

0 comments on commit 5855819

Please sign in to comment.