Skip to content

Commit

Permalink
sel4-simple-task: Add 32-bit support
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Mar 5, 2024
1 parent 4177b84 commit 8b8465a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ cfg_if::cfg_if! {
}
}

pub type RawConfigWord = u64;

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct ConfigBadge(RawConfigWord);
Expand All @@ -34,7 +32,7 @@ impl ConfigBadge {

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct ConfigCPtrBits(u64);
pub struct ConfigCPtrBits(RawConfigWord);

impl ConfigCPtrBits {
pub fn new(word: RawConfigWord) -> Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// SPDX-License-Identifier: BSD-2-Clause
//

pub type RawConfigWord = u64;

macro_rules! dummies {
{
$($i:ident)*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use sel4::{Badge, CPtrBits, Cap, CapType};

use crate::{ConfigBadge, ConfigCPtr, ConfigCPtrBits};

pub type RawConfigWord = sel4::Word;

pub trait WrappedCPtr {
fn wrap(bits: CPtrBits) -> Self;
}
Expand Down
7 changes: 4 additions & 3 deletions crates/private/support/sel4-simple-task/runtime/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ mk {

inherit (localCrates)
sel4
sel4-backtrace-simple
sel4-dlmalloc
sel4-immediate-sync-once-cell
sel4-panicking
Expand All @@ -25,10 +24,12 @@ mk {
sel4-simple-task-threading
sel4-sync
;

sel4-backtrace = localCrates.sel4-backtrace // { features = [ "unwinding" "postcard" ]; };
sel4-runtime-common = localCrates.sel4-runtime-common // { features = [ "tls" "unwinding" ]; };
};
target."cfg(not(target_arch = \"arm\"))".dependencies = {
sel4-backtrace = localCrates.sel4-backtrace // { features = [ "unwinding" "postcard" ]; };
inherit (localCrates) sel4-backtrace-simple;
};
features = {
serde_json = [
"dep:serde_json"
Expand Down
6 changes: 4 additions & 2 deletions crates/private/support/sel4-simple-task/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ serde_json = ["dep:serde_json"]
[dependencies]
postcard = { version = "1.0.2", default-features = false }
sel4 = { path = "../../../../sel4" }
sel4-backtrace = { path = "../../../../sel4-backtrace", features = ["unwinding", "postcard"] }
sel4-backtrace-simple = { path = "../../../../sel4-backtrace/simple" }
sel4-dlmalloc = { path = "../../../../sel4-dlmalloc" }
sel4-immediate-sync-once-cell = { path = "../../../../sel4-immediate-sync-once-cell" }
sel4-panicking = { path = "../../../../sel4-panicking" }
Expand All @@ -42,3 +40,7 @@ sel4-simple-task-threading = { path = "../threading" }
sel4-sync = { path = "../../../../sel4-sync" }
serde = { version = "1.0.147", default-features = false }
serde_json = { version = "1.0.87", default-features = false, optional = true }

[target."cfg(not(target_arch = \"arm\"))".dependencies]
sel4-backtrace = { path = "../../../../sel4-backtrace", features = ["unwinding", "postcard"] }
sel4-backtrace-simple = { path = "../../../../sel4-backtrace/simple" }
25 changes: 21 additions & 4 deletions crates/private/support/sel4-simple-task/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ use core::ptr;
use core::slice;

use sel4::Endpoint;
use sel4_backtrace_simple::SimpleBacktracing;
use sel4_dlmalloc::StaticHeapBounds;
use sel4_immediate_sync_once_cell::ImmediateSyncOnceCell;
use sel4_panicking::ExternalPanicInfo;
use sel4_panicking_env::{abort, AbortInfo};
use sel4_simple_task_runtime_config_types::RuntimeConfig;
use sel4_simple_task_threading::StaticThread;

#[cfg(not(target_arch = "arm"))]
use sel4_backtrace_simple::SimpleBacktracing;

mod declare_main;
mod termination;

Expand Down Expand Up @@ -79,12 +81,17 @@ pub unsafe extern "C" fn cont_fn(cont_arg: *mut sel4_runtime_common::ContArg) ->

if thread_index == 0 {
CONFIG.set(config.clone()).unwrap();
sel4_runtime_common::set_eh_frame_finder().unwrap();

#[cfg(not(target_arch = "arm"))]
{
sel4_runtime_common::set_eh_frame_finder().unwrap();
}

sel4_panicking::set_hook(&panic_hook);
sel4_runtime_common::run_ctors();
__sel4_simple_task_main(config.arg());
} else {
let endpoint = Endpoint::from_bits(thread_config.endpoint().unwrap());
let endpoint = Endpoint::from_bits(thread_config.endpoint().unwrap().try_into().unwrap());
let reply_authority = {
sel4::sel4_cfg_if! {
if #[sel4_cfg(KERNEL_MCS)] {
Expand All @@ -105,6 +112,8 @@ pub fn try_idle() {
CONFIG
.get()
.and_then(RuntimeConfig::idle_notification)
.map(sel4::CPtrBits::try_from)
.map(Result::unwrap)
.map(sel4::Notification::from_bits)
.map(sel4::Notification::wait);
}
Expand All @@ -128,7 +137,11 @@ sel4_panicking_env::register_debug_put_char!(sel4::debug_put_char);

fn panic_hook(info: &ExternalPanicInfo<'_>) {
debug_println!("{}", info);
get_backtracing().collect_and_send();

#[cfg(not(target_arch = "arm"))]
{
get_backtracing().collect_and_send();
}
}

fn get_static_heap_bounds() -> StaticHeapBounds {
Expand All @@ -144,14 +157,18 @@ fn get_static_heap_mutex_notification() -> sel4::Notification {
.get()
.unwrap()
.static_heap_mutex_notification()
.map(sel4::CPtrBits::try_from)
.map(Result::unwrap)
.map(sel4::Notification::from_bits)
.unwrap()
}

#[cfg(not(target_arch = "arm"))]
pub fn get_backtracing() -> SimpleBacktracing {
SimpleBacktracing::new(get_backtrace_image_identifier())
}

#[allow(dead_code)]
fn get_backtrace_image_identifier() -> Option<&'static str> {
CONFIG.get().unwrap().image_identifier()
}
Expand Down
11 changes: 8 additions & 3 deletions hacking/src/python/capdl_simple_composition/kernel_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ def is_mcs(self):

# TODO
def page_sizes_in_bits(self):
if self.arch() == 'arm':
sel4_arch = self.sel4_arch()
if sel4_arch == 'aarch64':
return [12, 21]
elif self.sel4_arch() == 'riscv64':
elif sel4_arch == 'aarch32':
return [12, 20]
elif sel4_arch == 'riscv64':
return [12, 21]
elif self.arch() == 'x86':
elif sel4_arch == 'riscv32':
return [12, 22]
elif sel4_arch == 'x86_64':
return [12, 21]
else:
raise NotImplementedError
Expand Down

0 comments on commit 8b8465a

Please sign in to comment.