Skip to content

Commit

Permalink
Update kernel (#16)
Browse files Browse the repository at this point in the history
* almost done all the data structure changes and sync (#11)

* update the sel4_cspace/src/arch/aarch64/mod.rs with some definations

* add some funcitons

* update the objecttype definations

* clean the pgde/pude/pde structures definetions

* change the definetions of lookup and update 4 todos

* Update kernel 3 (#12)

* update the sel4_cspace/src/arch/aarch64/mod.rs with some definations

* add some funcitons

* update the objecttype definations

* clean the pgde/pude/pde structures definetions

* change the definetions of lookup and update 4 todos

* try to fix some functions

* fix some errors with more errors generated

* clean some unused functions

* update and pass the complier, but still have unimplement

* Update kernel 4 (#13)

* fill in the unimplement code

* clean the warnings

* add the 4k page

* FIX:the page entry problem of map kernel window

* Update kernel 5 (#14)

* fix the word the vs used

* fix the page bug, and let the root task work

* Update kernel 6 (#15)

* fix make user pte todo

* fix the unmap assert

* fix the bug of the unmap page

* fix another bug

* seems fix bug
  • Loading branch information
ZhiyuanSue committed Sep 26, 2024
1 parent bd46717 commit 044e7b1
Show file tree
Hide file tree
Showing 14 changed files with 544 additions and 543 deletions.
12 changes: 6 additions & 6 deletions src/arch/aarch64/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use aarch64_cpu::registers::Readable;
use aarch64_cpu::registers::TTBR0_EL1;
use log::debug;
use sel4_common::arch::ArchReg::*;
use sel4_common::print;
use sel4_common::fault::seL4_Fault_t;
use sel4_common::print;
use sel4_common::sel4_config::seL4_MsgMaxLength;
use sel4_common::structures::exception_t;
use sel4_common::utils::global_read;
Expand All @@ -27,23 +27,23 @@ use super::instruction::*;

#[no_mangle]
pub fn handleUnknownSyscall(w: isize) -> exception_t {
let thread = get_currenct_thread();
let thread = get_currenct_thread();
if w == SysDebugPutChar {
print!("{}",thread.tcbArch.get_register(Cap) as u8 as char);
print!("{}", thread.tcbArch.get_register(Cap) as u8 as char);
return exception_t::EXCEPTION_NONE;
}
if w == SysDebugDumpScheduler {
// unimplement debug
// unimplement debug
// println!("debug dump scheduler");
return exception_t::EXCEPTION_NONE;
}
if w == SysDebugHalt {
// unimplement debug
// unimplement debug
// println!("debug halt");
return exception_t::EXCEPTION_NONE;
}
if w == SysDebugSnapshot {
// unimplement debug
// unimplement debug
// println!("debug snapshot");
return exception_t::EXCEPTION_NONE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/arch/aarch64/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extern "C" fn decodeARMMMUInvocation(
pub fn set_vm_root_for_flush(vspace: usize, asid: asid_t) -> bool {
let thread_root = get_currenct_thread().get_cspace(tcbVTable).cap;

if thread_root.is_valid_native_root() && thread_root.get_pgd_base_ptr() == vspace as usize {
if thread_root.is_valid_native_root() && thread_root.get_vs_base_ptr() == vspace as usize {
return false;
}

Expand Down
14 changes: 7 additions & 7 deletions src/arch/riscv/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ use crate::syscall::{
use log::debug;
use sel4_common::arch::ArchReg::*;
use sel4_common::fault::seL4_Fault_t;
use sel4_common::print;
use sel4_common::sel4_config::seL4_MsgMaxLength;
use sel4_common::structures::exception_t;
use sel4_cspace::arch::CapTag;
use sel4_common::print;
use sel4_task::{activateThread, get_currenct_thread, schedule};

#[no_mangle]
pub fn handleUnknownSyscall(w: isize) -> exception_t {
let thread = get_currenct_thread();
let thread = get_currenct_thread();
if w == SysDebugPutChar {
print!("{}",thread.tcbArch.get_register(Cap) as u8 as char);
print!("{}", thread.tcbArch.get_register(Cap) as u8 as char);
return exception_t::EXCEPTION_NONE;
}
if w == SysDebugDumpScheduler {
// unimplement debug
// unimplement debug
// println!("debug dump scheduler");
return exception_t::EXCEPTION_NONE;
}
if w == SysDebugHalt {
// unimplement debug
// unimplement debug
// println!("debug halt");
return exception_t::EXCEPTION_NONE;
}
if w == SysDebugSnapshot {
// unimplement debug
// unimplement debug
// println!("debug snap shot");
return exception_t::EXCEPTION_NONE;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn handleUnknownSyscall(w: isize) -> exception_t {
debug!("SysDebugNameThread: Name too long, halting");
halt();
}

// setThreadName(TCB_PTR(cap_thread_cap_get_capTCBPtr(lu_ret.cap)), name);
return exception_t::EXCEPTION_NONE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/boot/root_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ unsafe fn rust_create_it_address_space(root_cnode_cap: &cap_t, it_v_reg: v_regio
#[cfg(target_arch = "aarch64")]
unsafe fn rust_create_it_address_space(root_cnode_cap: &cap_t, it_v_reg: v_region_t) -> cap_t {
// create the PGD
let vspace_cap = cap_t::new_page_global_directory_cap(IT_ASID, rootserver.vspace, 1);
let vspace_cap = cap_t::new_vspace_cap(IT_ASID, rootserver.vspace, 1);
let ptr = root_cnode_cap.get_cap_ptr() as *mut cte_t;
let slot_pos_before = ndks_boot.slot_pos_cur;
write_slot(ptr.add(seL4_CapInitThreadVspace), vspace_cap.clone());
Expand Down
53 changes: 27 additions & 26 deletions src/interfaces_impl/cspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ use sel4_ipc::{endpoint_t, notification_t, Transfer};
use sel4_task::{get_currenct_thread, ksWorkUnitsCompleted, tcb_t};
#[cfg(target_arch = "riscv64")]
use sel4_vspace::find_vspace_for_asid;
use sel4_vspace::{asid_pool_t, asid_t, delete_asid, delete_asid_pool, unmapPage, PTE};
#[cfg(target_arch = "aarch64")]
use sel4_vspace::{
unmap_page_directory, unmap_page_table, unmap_page_upper_directory, PDE, PGDE, PUDE,
};
use sel4_vspace::unmap_page_table;
use sel4_vspace::{asid_pool_t, asid_t, delete_asid, delete_asid_pool, unmapPage, PTE};

#[cfg(target_arch = "riscv64")]
#[no_mangle]
Expand Down Expand Up @@ -89,27 +87,32 @@ pub fn Arch_finaliseCap(cap: &cap_t, final_: bool) -> finaliseCap_ret {
}
}
}
CapTag::CapPageGlobalDirectoryCap => {
if final_ && cap.get_pgd_is_mapped() == 1 {
deleteASID(cap.get_pgd_is_mapped(), cap.get_pgd_base_ptr() as _);
}
}
CapTag::CapPageUpperDirectoryCap => {
if final_ && cap.get_pud_is_mapped() == 1 {
let pud = ptr_to_mut(cap.get_pt_base_ptr() as *mut PUDE);
unmap_page_upper_directory(
cap.get_pud_mapped_asid(),
cap.get_pud_mapped_address(),
pud,
);
}
}
CapTag::CapPageDirectoryCap => {
if final_ && cap.get_pd_is_mapped() == 1 {
let pd = ptr_to_mut(cap.get_pt_base_ptr() as *mut PDE);
unmap_page_directory(cap.get_pd_mapped_asid(), cap.get_pd_mapped_address(), pd);
CapTag::CapVspaceCap => {
if final_ && cap.get_vs_is_mapped() == 1 {
deleteASID(cap.get_vs_is_mapped(), cap.get_vs_base_ptr() as _);
}
}
// CapTag::CapPageGlobalDirectoryCap => {
// if final_ && cap.get_pgd_is_mapped() == 1 {
// deleteASID(cap.get_pgd_is_mapped(), cap.get_pgd_base_ptr() as _);
// }
// }
// CapTag::CapPageUpperDirectoryCap => {
// if final_ && cap.get_pud_is_mapped() == 1 {
// let pud = ptr_to_mut(cap.get_pt_base_ptr() as *mut PUDE);
// unmap_page_upper_directory(
// cap.get_pud_mapped_asid(),
// cap.get_pud_mapped_address(),
// pud,
// );
// }
// }
// CapTag::CapPageDirectoryCap => {
// if final_ && cap.get_pd_is_mapped() == 1 {
// let pd = ptr_to_mut(cap.get_pt_base_ptr() as *mut PDE);
// unmap_page_directory(cap.get_pd_mapped_asid(), cap.get_pd_mapped_address(), pd);
// }
// }
CapTag::CapPageTableCap => {
if final_ && cap.get_pt_is_mapped() == 1 {
let pte = ptr_to_mut(cap.get_pt_base_ptr() as *mut PTE);
Expand Down Expand Up @@ -259,7 +262,6 @@ pub fn preemptionPoint() -> exception_t {
}
}


#[no_mangle]
#[cfg(target_arch = "riscv64")]
pub fn deleteASID(asid: asid_t, vspace: *mut PTE) {
Expand All @@ -276,7 +278,7 @@ pub fn deleteASID(asid: asid_t, vspace: *mut PTE) {

#[no_mangle]
#[cfg(target_arch = "aarch64")]
pub fn deleteASID(asid: asid_t, vspace: *mut PGDE) {
pub fn deleteASID(asid: asid_t, vspace: *mut PTE) {
unsafe {
if let Err(lookup_fault) = delete_asid(
asid,
Expand All @@ -288,7 +290,6 @@ pub fn deleteASID(asid: asid_t, vspace: *mut PGDE) {
}
}


#[no_mangle]
pub fn deleteASIDPool(asid_base: asid_t, pool: *mut asid_pool_t) {
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions src/interrupt/handler.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::arch::resetTimer;
use crate::config::{irqInvalid,maxIRQ};
use crate::config::{irqInvalid, maxIRQ};
use crate::interrupt::*;
use core::intrinsics::unlikely;
use log::debug;
use sel4_common::structures::exception_t;
use sel4_cspace::interface::CapTag;
use sel4_ipc::notification_t;
use sel4_task::{activateThread, schedule,timerTick};
use sel4_task::{activateThread, schedule, timerTick};

#[no_mangle]
pub fn handleInterruptEntry() -> exception_t {
Expand Down
29 changes: 16 additions & 13 deletions src/syscall/invocation/arch/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use sel4_common::{arch::{vm_rights_t, ObjectType}, sel4_config::{asidInvalid, ARM_Large_Page, ARM_Small_Page}};
use sel4_common::{
arch::{vm_rights_t, ObjectType},
sel4_config::{asidInvalid, ARM_Huge_Page, ARM_Large_Page, ARM_Small_Page},
};
use sel4_cspace::arch::cap_t;
use sel4_vspace::pptr_t;

Expand All @@ -17,18 +20,6 @@ pub fn arch_create_object(
asidInvalid,
region_base,
),
ObjectType::seL4_ARM_PageUpperDirectoryObject => {
cap_t::new_page_upper_directory_cap(asidInvalid, region_base, 0, 0)
}
ObjectType::seL4_ARM_PageDirectoryObject => {
cap_t::new_page_directory_cap(asidInvalid, region_base, 0, 0)
}
ObjectType::seL4_ARM_PageTableObject => {
cap_t::new_page_table_cap(asidInvalid, region_base, 0, 0)
}
ObjectType::seL4_ARM_PageGlobalDirectoryObject => {
cap_t::new_page_global_directory_cap(asidInvalid, region_base, 0)
}
ObjectType::seL4_ARM_LargePageObject => cap_t::new_frame_cap(
device_mem,
vm_rights_t::VMReadWrite as _,
Expand All @@ -37,6 +28,18 @@ pub fn arch_create_object(
asidInvalid,
region_base,
),
ObjectType::seL4_ARM_HugePageObject => cap_t::new_frame_cap(
device_mem,
vm_rights_t::VMReadWrite as _,
0,
ARM_Huge_Page,
asidInvalid,
region_base,
),
ObjectType::seL4_ARM_VSpaceObject => cap_t::new_vspace_cap(asidInvalid, region_base, 0),
ObjectType::seL4_ARM_PageTableObject => {
cap_t::new_page_table_cap(asidInvalid, region_base, 0, 0)
}
_ => {
unimplemented!(
"create object: {:?} region: {:#x} - {:#x}",
Expand Down
6 changes: 4 additions & 2 deletions src/syscall/invocation/arch/riscv64.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use sel4_common::{arch::{vm_rights_t, ObjectType}, sel4_config::asidInvalid};
use sel4_common::{
arch::{vm_rights_t, ObjectType},
sel4_config::asidInvalid,
};
use sel4_cspace::arch::cap_t;
use sel4_vspace::pptr_t;


pub fn arch_create_object(
obj_type: ObjectType,
region_base: pptr_t,
Expand Down
Loading

0 comments on commit 044e7b1

Please sign in to comment.