Skip to content

Commit d7b514d

Browse files
committed
capdl: add FPU support flag
Signed-off-by: Jakub Duchniewicz <j.duchniewicz@unsw.edu.au>
1 parent b9ab5cd commit d7b514d

4 files changed

Lines changed: 56 additions & 0 deletions

File tree

crates/sel4-capdl-initializer/src/initialize.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ impl<'a> Initializer<'a> {
766766
}
767767
}
768768

769+
let fpu_disabled = obj.extra.fpu_disabled;
770+
769771
#[allow(unused_variables)]
770772
let affinity = obj.extra.affinity.to_sel4();
771773

@@ -822,6 +824,14 @@ impl<'a> Initializer<'a> {
822824
fault_ep,
823825
)?;
824826

827+
let tcb_flags = sel4::TcbFlagsBuilder::new()
828+
.fpu_disabled(fpu_disabled)
829+
.build();
830+
tcb.tcb_set_flags(
831+
0,
832+
tcb_flags,
833+
)?;
834+
825835
tcb.tcb_set_timeout_endpoint(temp_fault_ep)?;
826836
} else {
827837
let fault_ep = sel4::CPtr::from_bits(obj.extra.master_fault_ep.as_ref().unwrap().to_sel4());
@@ -841,6 +851,14 @@ impl<'a> Initializer<'a> {
841851
prio,
842852
)?;
843853

854+
let tcb_flags = sel4::TcbFlagsBuilder::new()
855+
.fpu_disabled(fpu_disabled)
856+
.build();
857+
tcb.tcb_set_flags(
858+
0,
859+
tcb_flags,
860+
)?;
861+
844862
sel4::sel4_cfg_if! {
845863
if #[sel4_cfg(not(MAX_NUM_NODES = "1"))] {
846864
tcb.tcb_set_affinity(affinity)?;

crates/sel4-capdl-initializer/types/src/spec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ pub mod object {
419419
pub affinity: Word,
420420
pub prio: u8,
421421
pub max_prio: u8,
422+
pub fpu_disabled: bool,
422423
pub resume: bool,
423424

424425
pub domain: Option<u8>,

crates/sel4/src/invocations.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,32 @@ impl<C: InvocationContext> Untyped<C> {
4949
const USER_CONTEXT_MAX_REG_COUNT: usize =
5050
mem::size_of::<sys::seL4_UserContext>() / mem::size_of::<Word>();
5151

52+
#[derive(Debug, Clone, PartialEq)]
53+
pub struct TcbFlagsBuilder(Word);
54+
55+
impl TcbFlagsBuilder {
56+
pub fn new() -> Self {
57+
Self(sel4_sys::seL4_TCBFlag::seL4_TCBFlag_NoFlag)
58+
}
59+
60+
pub fn build(self) -> Self {
61+
self.0
62+
}
63+
64+
pub fn fpu_disabled(mut self, val: bool) -> Self {
65+
self.apply_flag_val(sel4_sys::seL4_TCBFlag::seL4_TCBFlag_fpuDisabled, val)
66+
}
67+
68+
pub fn apply_flag_val(mut self, flag: Word, val: bool) -> Self {
69+
if val {
70+
self.0 |= flag
71+
} else {
72+
self.0 &= !flag
73+
}
74+
self
75+
}
76+
}
77+
5278
impl<C: InvocationContext> Tcb<C> {
5379
/// Corresponds to `seL4_TCB_ReadRegisters`.
5480
pub fn tcb_read_registers(self, suspend: bool, count: Word) -> Result<UserContext> {
@@ -124,6 +150,16 @@ impl<C: InvocationContext> Tcb<C> {
124150
}))
125151
}
126152

153+
// Corresponds to `seL4_TCB_SetFlags`.
154+
pub fn tcb_set_flags(self, clear: Word, set: Word) -> Result<Word> {
155+
let ret = self.invoke(|cptr, ipc_buffer| {
156+
ipc_buffer
157+
.inner_mut()
158+
.seL4_TCB_SetFlags(cptr.bits(), clear, set)
159+
});
160+
Error::or(ret.error, ret.flags)
161+
}
162+
127163
sel4_cfg_if! {
128164
if #[sel4_cfg(KERNEL_MCS)] {
129165
/// Corresponds to `seL4_TCB_Configure`.

crates/sel4/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub use cptr::{
125125
pub use error::{Error, Result};
126126
pub use fault::*;
127127
pub use invocation_context::{InvocationContext, NoExplicitInvocationContext, NoInvocationContext};
128+
pub use invocations::TcbFlagsBuilder;
128129
pub use ipc_buffer::IpcBuffer;
129130
pub use message_info::{MessageInfo, MessageInfoBuilder};
130131
pub use object::{

0 commit comments

Comments
 (0)