Skip to content

Commit 79ad922

Browse files
committed
Update kernel 11 (#18)
* clean seL4_CapRights_t * clean the sel4 fault part * clean some plus define bitfield * clean the mdb * clean the mdb_node_t * clean the thread_state * clean the notification * clean endpoint
1 parent 586dd19 commit 79ad922

21 files changed

+179
-181
lines changed

src/arch/aarch64/exception.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ use aarch64_cpu::registers::Readable;
1515
use aarch64_cpu::registers::TTBR0_EL1;
1616
use log::debug;
1717
use sel4_common::arch::ArchReg::*;
18-
use sel4_common::fault::seL4_Fault_t;
1918
use sel4_common::print;
2019
use sel4_common::sel4_config::seL4_MsgMaxLength;
2120
use sel4_common::structures::exception_t;
2221
use sel4_common::structures_gen::cap_tag;
22+
use sel4_common::structures_gen::seL4_Fault_UnknownSyscall;
23+
use sel4_common::structures_gen::seL4_Fault_UserException;
24+
use sel4_common::structures_gen::seL4_Fault_VMFault;
2325
use sel4_common::utils::global_read;
2426
use sel4_task::{activateThread, get_currenct_thread, get_current_domain, schedule};
2527

@@ -85,7 +87,7 @@ pub fn handleUnknownSyscall(w: isize) -> exception_t {
8587
return exception_t::EXCEPTION_NONE;
8688
}
8789
unsafe {
88-
current_fault = seL4_Fault_t::new_unknown_syscall_fault(w as usize);
90+
current_fault = seL4_Fault_UnknownSyscall::new(w as u64).unsplay();
8991
handle_fault(get_currenct_thread());
9092
}
9193
schedule();
@@ -96,7 +98,7 @@ pub fn handleUnknownSyscall(w: isize) -> exception_t {
9698
#[no_mangle]
9799
pub fn handleUserLevelFault(w_a: usize, w_b: usize) -> exception_t {
98100
unsafe {
99-
current_fault = seL4_Fault_t::new_user_exeception(w_a, w_b);
101+
current_fault = seL4_Fault_UserException::new(w_a as u64, w_b as u64).unsplay();
100102
handle_fault(get_currenct_thread());
101103
}
102104
schedule();
@@ -159,16 +161,19 @@ pub fn handle_vm_fault(type_: usize) -> exception_t {
159161
let fault = get_esr();
160162
log::debug!("fault addr: {:#x} esr: {:#x}", addr, fault);
161163
unsafe {
162-
current_fault = seL4_Fault_t::new_vm_fault(addr, fault, 0);
164+
current_fault = seL4_Fault_VMFault::new(addr as u64, fault as u64, 0)
165+
.unsplay()
166+
.clone();
163167
}
164-
log::debug!("current_fault: {:#x?}", global_read!(current_fault));
168+
let current_fault_cpy = unsafe { current_fault.clone() };
169+
log::debug!("current_fault: {:#x?}", global_read!(current_fault_cpy));
165170
exception_t::EXCEPTION_FAULT
166171
}
167172
ARMPrefetchAbort => {
168173
let pc = get_currenct_thread().tcbArch.get_register(FaultIP);
169174
let fault = get_esr();
170175
unsafe {
171-
current_fault = seL4_Fault_t::new_vm_fault(pc, fault, 1);
176+
current_fault = seL4_Fault_VMFault::new(pc as u64, fault as u64, 1).unsplay();
172177
}
173178

174179
log::debug!("ttbr0_el1: {:#x?}", TTBR0_EL1.get());

src/arch/aarch64/pg.rs

-40
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,6 @@ use sel4_task::get_currenct_thread;
1010
use sel4_vspace::asid_t;
1111
use sel4_vspace::setCurrentUserVSpaceRoot;
1212
use sel4_vspace::ttbr_new;
13-
use sel4_vspace::{vptr_t, PTE};
14-
15-
#[repr(C)]
16-
struct lookupPGDSlot_ret_t {
17-
status: exception_t,
18-
pgdSlot: usize, // *mut pgde_t
19-
}
20-
21-
#[repr(C)]
22-
struct lookupPDSlot_ret_t {
23-
status: exception_t,
24-
pdSlot: usize, // *mut pde_t
25-
}
26-
27-
#[repr(C)]
28-
struct lookupPUDSlot_ret_t {
29-
status: exception_t,
30-
pudSlot: usize, // *mut pude_t
31-
}
32-
33-
#[no_mangle]
34-
extern "C" fn lookupPGDSlot(_vspace: *mut PTE, _vptr: vptr_t) -> lookupPGDSlot_ret_t {
35-
// which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of PTE in this commit
36-
// ZhiyuanSue
37-
unimplemented!("lookupPGDSlot")
38-
}
39-
40-
#[no_mangle]
41-
extern "C" fn lookupPDSlot(_vspace: *mut PTE, _vptr: vptr_t) -> lookupPDSlot_ret_t {
42-
// which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of PTE in this commit
43-
// ZhiyuanSue
44-
unimplemented!("lookupPDSlot")
45-
}
46-
47-
#[no_mangle]
48-
extern "C" fn lookupPUDSlot(_vspace: *mut PTE, _vptr: vptr_t) -> lookupPUDSlot_ret_t {
49-
// which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of PTE in this commit
50-
// ZhiyuanSue
51-
unimplemented!("lookupPUDSlot")
52-
}
5313

5414
#[no_mangle]
5515
// typedef word_t cptr_t;

src/arch/riscv/exception.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ use crate::syscall::{
1212
};
1313
use log::debug;
1414
use sel4_common::arch::ArchReg::*;
15-
use sel4_common::fault::seL4_Fault_t;
1615
use sel4_common::print;
1716
use sel4_common::sel4_config::seL4_MsgMaxLength;
1817
use sel4_common::structures::exception_t;
1918
use sel4_common::structures_gen::cap_tag;
19+
use sel4_common::structures_gen::seL4_Fault_UnknownSyscall;
20+
use sel4_common::structures_gen::seL4_Fault_UserException;
21+
use sel4_common::structures_gen::seL4_Fault_VMFault;
2022
use sel4_task::{activateThread, get_currenct_thread, schedule};
2123

2224
#[no_mangle]
@@ -78,7 +80,7 @@ pub fn handleUnknownSyscall(w: isize) -> exception_t {
7880
return exception_t::EXCEPTION_NONE;
7981
}
8082
unsafe {
81-
current_fault = seL4_Fault_t::new_unknown_syscall_fault(w as usize);
83+
current_fault = seL4_Fault_UnknownSyscall::new(w as u64).unsplay();
8284
handle_fault(get_currenct_thread());
8385
}
8486
schedule();
@@ -89,7 +91,7 @@ pub fn handleUnknownSyscall(w: isize) -> exception_t {
8991
#[no_mangle]
9092
pub fn handleUserLevelFault(w_a: usize, w_b: usize) -> exception_t {
9193
unsafe {
92-
current_fault = seL4_Fault_t::new_user_exeception(w_a, w_b);
94+
current_fault = seL4_Fault_UserException::new(w_a as u64, w_b as u64).unsplay();
9395
handle_fault(get_currenct_thread());
9496
}
9597
schedule();
@@ -113,19 +115,23 @@ pub fn handle_vm_fault(type_: usize) -> exception_t {
113115
match type_ {
114116
RISCVLoadPageFault | RISCVLoadAccessFault => {
115117
unsafe {
116-
current_fault = seL4_Fault_t::new_vm_fault(addr, RISCVLoadAccessFault, 0);
118+
current_fault =
119+
seL4_Fault_VMFault::new(addr as u64, RISCVLoadAccessFault as u64, 0).unsplay();
117120
}
118121
exception_t::EXCEPTION_FAULT
119122
}
120123
RISCVStorePageFault | RISCVStoreAccessFault => {
121124
unsafe {
122-
current_fault = seL4_Fault_t::new_vm_fault(addr, RISCVStoreAccessFault, 0);
125+
current_fault =
126+
seL4_Fault_VMFault::new(addr as u64, RISCVStoreAccessFault as u64, 0).unsplay();
123127
}
124128
exception_t::EXCEPTION_FAULT
125129
}
126130
RISCVInstructionAccessFault | RISCVInstructionPageFault => {
127131
unsafe {
128-
current_fault = seL4_Fault_t::new_vm_fault(addr, RISCVInstructionAccessFault, 1);
132+
current_fault =
133+
seL4_Fault_VMFault::new(addr as u64, RISCVInstructionAccessFault as u64, 1)
134+
.unsplay();
129135
}
130136
exception_t::EXCEPTION_FAULT
131137
}

src/boot/utils.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use crate::structures::{p_region_t, region_t, v_region_t};
66
use crate::{BIT, ROUND_DOWN, ROUND_UP};
77
use log::debug;
88
use sel4_common::arch::config::{PADDR_TOP, PPTR_BASE, PPTR_TOP};
9+
use sel4_common::sel4_bitfield_types::Bitfield;
910
use sel4_common::sel4_config::*;
10-
use sel4_common::structures_gen::{cap, cap_cnode_cap};
11+
use sel4_common::structures_gen::{cap, cap_cnode_cap, mdb_node};
1112
use sel4_cspace::interface::*;
1213
use sel4_vspace::*;
1314
// #[cfg(target_arch="riscv64")]
@@ -72,10 +73,12 @@ pub fn arch_get_n_paging(it_v_reg: v_region_t) -> usize {
7273
pub fn write_slot(ptr: *mut cte_t, capability: cap) {
7374
unsafe {
7475
(*ptr).capability = capability;
75-
(*ptr).cteMDBNode = mdb_node_t::default();
76+
(*ptr).cteMDBNode = mdb_node {
77+
0: Bitfield { arr: [0; 2usize] },
78+
};
7679
let mdb = &mut (*ptr).cteMDBNode;
77-
mdb.set_revocable(1);
78-
mdb.set_first_badged(1);
80+
mdb.set_mdbRevocable(1);
81+
mdb.set_mdbFirstBadged(1);
7982
}
8083
}
8184

src/interfaces_impl/cspace.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use crate::kernel::boot::current_lookup_fault;
55
use crate::syscall::safe_unbind_notification;
66
use sel4_common::sel4_config::{tcbCNodeEntries, tcbCTable, tcbVTable};
77
use sel4_common::structures::exception_t;
8-
use sel4_common::structures_gen::{cap, cap_null_cap, cap_tag};
8+
use sel4_common::structures_gen::{cap, cap_null_cap, cap_tag, endpoint, notification};
99
use sel4_common::utils::convert_to_mut_type_ref;
1010
use sel4_cspace::capability::cap_func;
1111
use sel4_cspace::compatibility::{ZombieType_ZombieTCB, Zombie_new};
1212
use sel4_cspace::interface::finaliseCap_ret;
13-
use sel4_ipc::{endpoint_t, notification_t, Transfer};
13+
use sel4_ipc::{endpoint_func, notification_func, Transfer};
1414
use sel4_task::{get_currenct_thread, ksWorkUnitsCompleted, tcb_t};
1515
#[cfg(target_arch = "riscv64")]
1616
use sel4_vspace::find_vspace_for_asid;
@@ -176,7 +176,7 @@ pub fn finaliseCap(capability: &cap, _final: bool, _exposed: bool) -> finaliseCa
176176
cap_tag::cap_endpoint_cap => {
177177
if _final {
178178
// cancelAllIPC(cap.get_ep_ptr() as *mut endpoint_t);
179-
convert_to_mut_type_ref::<endpoint_t>(
179+
convert_to_mut_type_ref::<endpoint>(
180180
cap::cap_endpoint_cap(capability).get_capEPPtr() as usize,
181181
)
182182
.cancel_all_ipc()
@@ -187,7 +187,7 @@ pub fn finaliseCap(capability: &cap, _final: bool, _exposed: bool) -> finaliseCa
187187
}
188188
cap_tag::cap_notification_cap => {
189189
if _final {
190-
let ntfn = convert_to_mut_type_ref::<notification_t>(
190+
let ntfn = convert_to_mut_type_ref::<notification>(
191191
cap::cap_notification_cap(capability).get_capNtfnPtr() as usize,
192192
);
193193
ntfn.safe_unbind_tcb();

src/interrupt/handler.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use crate::interrupt::*;
44
use core::intrinsics::unlikely;
55
use log::debug;
66
use sel4_common::structures::exception_t;
7-
use sel4_common::structures_gen::{cap, cap_tag};
8-
use sel4_ipc::notification_t;
7+
use sel4_common::structures_gen::{cap, cap_tag, notification};
8+
use sel4_ipc::notification_func;
99
use sel4_task::{activateThread, schedule, timerTick};
1010

1111
#[no_mangle]
@@ -45,7 +45,7 @@ pub fn handleInterrupt(irq: usize) {
4545
if handler_cap.get_tag() == cap_tag::cap_notification_cap
4646
&& cap::cap_notification_cap(handler_cap).get_capNtfnCanSend() != 0
4747
{
48-
let nf = convert_to_mut_type_ref::<notification_t>(
48+
let nf = convert_to_mut_type_ref::<notification>(
4949
cap::cap_notification_cap(handler_cap).get_capNtfnPtr() as usize,
5050
);
5151
nf.send_signal(cap::cap_notification_cap(handler_cap).get_capNtfnPtr() as usize);

src/kernel/boot.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
extern crate core;
22

33
use sel4_common::sel4_bitfield_types::Bitfield;
4+
use sel4_common::structures_gen::seL4_Fault;
45
use sel4_common::{
5-
fault::seL4_Fault_t, sel4_config::seL4_MsgMaxExtraCaps, structures_gen::lookup_fault,
6+
sel4_config::seL4_MsgMaxExtraCaps, structures_gen::lookup_fault,
67
utils::convert_to_option_mut_type_ref,
78
};
89
use sel4_cspace::interface::cte_t;
@@ -15,8 +16,8 @@ pub static mut current_lookup_fault: lookup_fault = lookup_fault(Bitfield { arr:
1516

1617
#[no_mangle]
1718
// #[link_section = ".boot.bss"]
18-
pub static mut current_fault: seL4_Fault_t = seL4_Fault_t {
19-
words: [0; seL4_Fault_t::WIDTH],
19+
pub static mut current_fault: seL4_Fault = seL4_Fault {
20+
0: Bitfield { arr: [0; 2usize] },
2021
};
2122

2223
#[no_mangle]

0 commit comments

Comments
 (0)