Skip to content

Commit

Permalink
fix previous bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhiyuanSue committed Dec 22, 2024
1 parent a50d86b commit 3afd7a0
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 44 deletions.
23 changes: 16 additions & 7 deletions sel4_common/src/arch/aarch64/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,29 @@ pub const n_syscallMessage: usize = 12;
pub const n_timeoutMessage: usize = 34;
pub const msgRegisterNum: usize = 4;
pub const msgRegister: [usize; msgRegisterNum] = [2, 3, 4, 5];
#[cfg(not(feature="KERNEL_MCS"))]
#[cfg(not(feature = "KERNEL_MCS"))]
pub const MAX_MSG_SIZE: usize = n_syscallMessage;
#[cfg(feature="KERNEL_MCS")]
#[cfg(feature = "KERNEL_MCS")]
pub const MAX_MSG_SIZE: usize = n_timeoutMessage;
#[cfg(not(feature="KERNEL_MCS"))]
#[cfg(not(feature = "KERNEL_MCS"))]
pub const fault_messages: [[usize; MAX_MSG_SIZE]; 2] = [
[0, 1, 2, 3, 4, 5, 6, 7, 34, 31, 32, 33],
[34, 31, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0],
];
#[cfg(feature="KERNEL_MCS")]
#[cfg(feature = "KERNEL_MCS")]
pub const fault_messages: [[usize; MAX_MSG_SIZE]; 3] = [
[0, 1, 2, 3, 4, 5, 6, 7, 34, 31, 32, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[34, 31, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[34, 31, 33, 0, 1, 2, 3, 4, 5, 6, 7, 8, 16, 17, 18, 29, 30, 9, 10, 11, 12, 13, 14, 15, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]
[
0, 1, 2, 3, 4, 5, 6, 7, 34, 31, 32, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
],
[
34, 31, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
],
[
34, 31, 33, 0, 1, 2, 3, 4, 5, 6, 7, 8, 16, 17, 18, 29, 30, 9, 10, 11, 12, 13, 14, 15, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28,
],
];
pub const frameRegNum: usize = 17;
pub const gpRegNum: usize = 19;
Expand Down
23 changes: 16 additions & 7 deletions sel4_common/src/arch/riscv64/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,29 @@ pub const n_syscallMessage: usize = 10;
pub const n_exceptionMessage: usize = 2;
#[cfg(feature = "KERNEL_MCS")]
pub const n_timeoutMessage: usize = 32;
#[cfg(not(feature="KERNEL_MCS"))]
#[cfg(not(feature = "KERNEL_MCS"))]
pub const MAX_MSG_SIZE: usize = n_syscallMessage;
#[cfg(feature="KERNEL_MCS")]
#[cfg(feature = "KERNEL_MCS")]
pub const MAX_MSG_SIZE: usize = n_timeoutMessage;
#[cfg(not(feature="KERNEL_MCS"))]
#[cfg(not(feature = "KERNEL_MCS"))]
pub const fault_messages: [[usize; MAX_MSG_SIZE]; 2] = [
[33, 1, 0, 9, 10, 11, 12, 13, 14, 15],
[33, 1, 0, 0, 0, 0, 0, 0, 0, 0],
];
#[cfg(feature="KERNEL_MCS")]
#[cfg(feature = "KERNEL_MCS")]
pub const fault_messages: [[usize; MAX_MSG_SIZE]; 3] = [
[33, 1, 0, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[33, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[33, 0, 1, 2, 7, 8, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 9, 10, 11, 12, 13, 14, 15, 16, 4, 5, 6, 27, 28, 29, 30, 3],
[
33, 1, 0, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
],
[
33, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
],
[
33, 0, 1, 2, 7, 8, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 9, 10, 11, 12, 13, 14, 15, 16,
4, 5, 6, 27, 28, 29, 30, 3,
],
];

pub const frameRegNum: usize = 16;
Expand Down
2 changes: 1 addition & 1 deletion sel4_common/src/fault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub const seL4_VMFault_Addr: usize = 1;
pub const seL4_VMFault_PrefetchFault: usize = 2;
pub const seL4_VMFault_FSR: usize = 3;
pub const seL4_VMFault_Length: usize = 4;
pub const seL4_Timeout_Data:usize = 0;
pub const seL4_Timeout_Data: usize = 0;

pub const seL4_CapFault_IP: usize = 0;
pub const seL4_CapFault_Addr: usize = 1;
Expand Down
2 changes: 1 addition & 1 deletion sel4_ipc/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl endpoint_func for endpoint {
canDonate: bool,
) {
use sel4_task::{ksCurSC, reply::reply_t, sched_context::sched_context_t};
// sel4_common::println!("send ipc {}",self.get_ep_state() as usize);
// sel4_common::println!("send ipc {}",self.get_ep_state() as usize);
match self.get_ep_state() {
EPState::Idle | EPState::Send => {
if blocking {
Expand Down
53 changes: 26 additions & 27 deletions sel4_ipc/src/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ use sel4_common::structures_gen::seL4_Fault_NullFault;
use sel4_common::structures_gen::seL4_Fault_tag;
use sel4_common::utils::*;
use sel4_cspace::interface::*;
#[cfg(feature = "KERNEL_MCS")]
use sel4_task::reply::reply_t;
#[cfg(feature = "KERNEL_MCS")]
use sel4_task::reply_remove_tcb;
use sel4_task::sched_context::sched_context_t;
use sel4_task::{possible_switch_to, set_thread_state, tcb_t, ThreadState};
#[cfg(feature = "KERNEL_MCS")]
use sel4_task::{reply::reply_t, reply_remove_tcb, sched_context::sched_context_t};
use sel4_vspace::pptr_t;

/// The trait for IPC transfer, please see doc.md for more details
Expand Down Expand Up @@ -252,19 +249,21 @@ impl Transfer for tcb_t {
seL4_Fault::seL4_Fault_VMFault(&self.tcbFault).get_FSR() as usize,
)
}
seL4_Fault_tag::seL4_Fault_Timeout => {
let len = receiver.set_mr(
seL4_Timeout_Data,
seL4_Fault::seL4_Fault_Timeout(&self.tcbFault).get_badge() as usize
);
if let Some(sc) = convert_to_option_mut_type_ref::<sched_context_t>(self.tcbSchedContext){
let consumed = sc.schedContext_updateConsumed();
receiver.set_mr(len, consumed)
}
else {
len
}
}
#[cfg(feature = "KERNEL_MCS")]
seL4_Fault_tag::seL4_Fault_Timeout => {
let len = receiver.set_mr(
seL4_Timeout_Data,
seL4_Fault::seL4_Fault_Timeout(&self.tcbFault).get_badge() as usize,
);
if let Some(sc) =
convert_to_option_mut_type_ref::<sched_context_t>(self.tcbSchedContext)
{
let consumed = sc.schedContext_updateConsumed();
receiver.set_mr(len, consumed)
} else {
len
}
}
_ => {
panic!("invalid fault")
}
Expand Down Expand Up @@ -319,15 +318,15 @@ impl Transfer for tcb_t {
);
return label as usize == 0;
}
#[cfg(feature="KERNEL_MCS")]
seL4_Fault_tag::seL4_Fault_Timeout => {
self.copy_fault_mrs_for_reply(
receiver,
MessageID_TimeoutReply,
core::cmp::min(length, n_exceptionMessage),
);
return label as usize == 0;
}
#[cfg(feature = "KERNEL_MCS")]
seL4_Fault_tag::seL4_Fault_Timeout => {
self.copy_fault_mrs_for_reply(
receiver,
MessageID_TimeoutReply,
core::cmp::min(length, n_exceptionMessage),
);
return label as usize == 0;
}
_ => true,
}
}
Expand Down
2 changes: 1 addition & 1 deletion sel4_task/src/sched_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl sched_context {
assert!(to.tcbSchedContext == 0);
if let Some(from) = convert_to_option_mut_type_ref::<tcb_t>(self.scTcb) {
from.sched_dequeue();
from.Release_Remove();
from.Release_Remove();
from.tcbSchedContext = 0;
if from.is_current() || from.get_ptr() == unsafe { ksSchedulerAction } {
rescheduleRequired();
Expand Down

0 comments on commit 3afd7a0

Please sign in to comment.