Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/sel4-capdl-initializer/src/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ impl<'a> Initializer<'a> {
}
}

let fpu_disabled = obj.extra.fpu_disabled;

#[allow(unused_variables)]
let affinity = obj.extra.affinity.to_sel4();

Expand Down Expand Up @@ -822,6 +824,14 @@ impl<'a> Initializer<'a> {
fault_ep,
)?;

let tcb_flags = sel4::TcbFlagsBuilder::new()
.fpu_disabled(fpu_disabled)
.build();
tcb.tcb_set_flags(
Comment thread
JDuchniewicz marked this conversation as resolved.
0,
tcb_flags,
)?;

tcb.tcb_set_timeout_endpoint(temp_fault_ep)?;
} else {
let fault_ep = sel4::CPtr::from_bits(obj.extra.master_fault_ep.as_ref().unwrap().to_sel4());
Expand All @@ -841,6 +851,14 @@ impl<'a> Initializer<'a> {
prio,
)?;

let tcb_flags = sel4::TcbFlagsBuilder::new()
.fpu_disabled(fpu_disabled)
.build();
tcb.tcb_set_flags(
0,
tcb_flags,
)?;

sel4::sel4_cfg_if! {
if #[sel4_cfg(not(MAX_NUM_NODES = "1"))] {
tcb.tcb_set_affinity(affinity)?;
Expand Down
1 change: 1 addition & 0 deletions crates/sel4-capdl-initializer/types/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ pub mod object {
pub affinity: Word,
pub prio: u8,
pub max_prio: u8,
pub fpu_disabled: bool,
pub resume: bool,

pub domain: Option<u8>,
Expand Down
42 changes: 42 additions & 0 deletions crates/sel4/src/invocations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,38 @@ impl<C: InvocationContext> Untyped<C> {
const USER_CONTEXT_MAX_REG_COUNT: usize =
mem::size_of::<sys::seL4_UserContext>() / mem::size_of::<Word>();

#[derive(Debug, Clone, PartialEq)]
pub struct TcbFlagsBuilder(Word);

impl TcbFlagsBuilder {
pub fn new() -> Self {
Self(sel4_sys::seL4_TCBFlag::seL4_TCBFlag_NoFlag)
}

pub fn build(self) -> Word {
self.0
}

pub fn fpu_disabled(self, val: bool) -> Self {
self.apply_flag_val(sel4_sys::seL4_TCBFlag::seL4_TCBFlag_fpuDisabled, val)
}

fn apply_flag_val(mut self, flag: Word, val: bool) -> Self {
if val {
self.0 |= flag
} else {
self.0 &= !flag
}
self
}
}

impl Default for TcbFlagsBuilder {
fn default() -> Self {
Self::new()
}
}

impl<C: InvocationContext> Tcb<C> {
/// Corresponds to `seL4_TCB_ReadRegisters`.
pub fn tcb_read_registers(self, suspend: bool, count: Word) -> Result<UserContext> {
Expand Down Expand Up @@ -124,6 +156,16 @@ impl<C: InvocationContext> Tcb<C> {
}))
}

// Corresponds to `seL4_TCB_SetFlags`.
pub fn tcb_set_flags(self, clear: Word, set: Word) -> Result<Word> {
let ret = self.invoke(|cptr, ipc_buffer| {
ipc_buffer
.inner_mut()
.seL4_TCB_SetFlags(cptr.bits(), clear, set)
});
Error::or(ret.error, ret.flags)
}

sel4_cfg_if! {
if #[sel4_cfg(KERNEL_MCS)] {
/// Corresponds to `seL4_TCB_Configure`.
Expand Down
1 change: 1 addition & 0 deletions crates/sel4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub use cptr::{
pub use error::{Error, Result};
pub use fault::*;
pub use invocation_context::{InvocationContext, NoExplicitInvocationContext, NoInvocationContext};
pub use invocations::TcbFlagsBuilder;
pub use ipc_buffer::IpcBuffer;
pub use message_info::{MessageInfo, MessageInfoBuilder};
pub use object::{
Expand Down
2 changes: 1 addition & 1 deletion hacking/nix/scope/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let

capdlCommon = {
url = "https://github.com/coliasgroup/capdl.git";
rev = "6282fc3d4cf4a2d17c52dcdea11b08997458f9a3"; # branch rust-testing
rev = "e0dfb895ec7dda40a6e59eec11fe2c20dd5c831d"; # branch rust-testing
local = localRoot + "/capdl";
extraFilter = path: type:
lib.hasSuffix "/.stack-work" path || lib.hasSuffix "/stack.yaml.lock" path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def __init__(self, component, name,
tcb.prio = prio
tcb.max_prio = max_prio
tcb.affinity = affinity
tcb.fpu_disabled = False
tcb.resume = True
tcb['cspace'] = self.component.cnode_cap(update_guard_size=self.component.update_guard_size)
tcb['vspace'] = Cap(self.component.pd())
Expand Down
Loading