Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce spawn-task example #111

Merged
merged 33 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
74b310d
nix: Reduce CapDL loader optimization
nspin Mar 7, 2024
c965bda
nix: Actually strip for minimal ELF attrs
nspin Mar 7, 2024
bf98265
crates/sel4: Introduce UserContext::c_param{,_mut}
nspin Mar 7, 2024
709d6a2
crates/sel4: Rename SizedFrameType -> CapTypeForFrameObjectOfFixedSize
nspin Mar 7, 2024
34df46c
crates/sel4: Add CapTypeForObject* traits
nspin Mar 7, 2024
c9a6f54
crates/sel4: Introduce TranslationStructureType
nspin Mar 7, 2024
865f5ae
crates/sel4: Rename FrameSize -> FrameObjectType
nspin Mar 11, 2024
3b544e0
crates/sel4: Rename TranslationStructureType -> TranslationStructureO…
nspin Mar 11, 2024
95a7e91
crates/sel4: Use full names for FrameObjectType variants
nspin Mar 11, 2024
d2bd338
crates/sel4: Rename ObjectBlueprintRISCV -> ObjectBlueprintRiscV
nspin Mar 11, 2024
9c833d9
Make types of automatic linker symbols more consistent
nspin Mar 11, 2024
2d8eb61
crates/sel4-root-task: Improve style
nspin Mar 11, 2024
c4f0fb6
Improve consistency in identifier capitalization
nspin Mar 11, 2024
c8fd0dd
crates/sel4: Organize x86 modules
nspin Mar 11, 2024
a1c9f09
crates/sel4: Use more structure param types
nspin Mar 11, 2024
5c4e09c
Use proper repr in CapDL initializer
nspin Mar 11, 2024
8951ae2
crates/sel4: Add TranslationStructureObjectType::FIRST_LEVEL_WITH_FRA…
nspin Mar 12, 2024
6de6508
crates/sel4: Add TranslationStructureObjectType::step_bits
nspin Mar 12, 2024
934089e
crates/sel4: Add vspace_levels module
nspin Mar 12, 2024
5da9445
crates/sel4: Rename translation structure -> table
nspin Mar 12, 2024
b8c5054
crates/sel4: Improve method names
nspin Mar 12, 2024
c91e172
crates/sel4: Derive more traits for CapType
nspin Mar 12, 2024
f1a3a98
crates/sel4: Improve step_bits implementation
nspin Mar 12, 2024
07f1b83
crates/sel4: Derive Copy for CapRightsBuilder
nspin Mar 13, 2024
0db0800
Clean up aarch32 TLS code
nspin Mar 13, 2024
10ad7b8
crates/sel4: Derive Copy for MessageInfoBuilder
nspin Mar 13, 2024
9b844c9
Improve spawn-thread example
nspin Mar 13, 2024
5d9339d
Add spawn-task example
nspin Mar 13, 2024
a00ee5e
Fix spawn-task example for aarch32
nspin Mar 14, 2024
20a3f07
nix: Run spawn-task during tests
nspin Mar 14, 2024
c73593c
nix: Adjust CapDL initializer opt level
nspin Mar 14, 2024
781fb0b
crates/sel4-kernel-loader: Remove debug print statement
nspin Mar 14, 2024
3991a41
crates/sel4-capdl-initializer: Simplify
nspin Mar 14, 2024
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
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ members = [
"crates/examples/root-task/example-root-task",
"crates/examples/root-task/example-root-task-without-runtime",
"crates/examples/root-task/hello",
"crates/examples/root-task/spawn-task",
"crates/examples/root-task/spawn-task/child",
"crates/examples/root-task/spawn-thread",
"crates/private/meta",
"crates/private/support/sel4-simple-task/config-types",
Expand Down
18 changes: 18 additions & 0 deletions crates/examples/root-task/spawn-task/Cargo.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2024, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#

{ mk, versions, localCrates }:

mk {
package.name = "spawn-task";
dependencies = {
object = { version = versions.object; default-features = false; features = [ "read" ]; };
inherit (localCrates)
sel4
sel4-root-task
;
};
}
22 changes: 22 additions & 0 deletions crates/examples/root-task/spawn-task/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright 2023, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#
#
# This file is generated from './Cargo.nix'. You can edit this file directly
# if you are not using this project's Cargo manifest management tools.
# See 'hacking/cargo-manifest-management/README.md' for more information.
#

[package]
name = "spawn-task"
version = "0.1.0"
authors = ["Nick Spinale <[email protected]>"]
edition = "2021"
license = "BSD-2-Clause"

[dependencies]
object = { version = "0.32.1", default-features = false, features = ["read"] }
sel4 = { path = "../../../sel4" }
sel4-root-task = { path = "../../../sel4-root-task" }
26 changes: 26 additions & 0 deletions crates/examples/root-task/spawn-task/child/Cargo.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright 2024, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#

{ mk, versions, localCrates }:

mk {
package.name = "spawn-task-child";
dependencies = {
inherit (versions) cfg-if;
inherit (localCrates)
sel4
sel4-panicking-env
sel4-dlmalloc
sel4-sync
;
sel4-panicking = localCrates.sel4-panicking // {
features = [ "unwinding" "alloc" ];
};
sel4-runtime-common = localCrates.sel4-runtime-common // {
features = [ "start" "tls" "unwinding" ];
};
};
}
29 changes: 29 additions & 0 deletions crates/examples/root-task/spawn-task/child/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Copyright 2023, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#
#
# This file is generated from './Cargo.nix'. You can edit this file directly
# if you are not using this project's Cargo manifest management tools.
# See 'hacking/cargo-manifest-management/README.md' for more information.
#

[package]
name = "spawn-task-child"
version = "0.1.0"
authors = ["Nick Spinale <[email protected]>"]
edition = "2021"
license = "BSD-2-Clause"

[dependencies]
cfg-if = "1.0.0"
sel4 = { path = "../../../../sel4" }
sel4-dlmalloc = { path = "../../../../sel4-dlmalloc" }
sel4-panicking = { path = "../../../../sel4-panicking", features = ["unwinding", "alloc"] }
sel4-panicking-env = { path = "../../../../sel4-panicking/env" }
sel4-sync = { path = "../../../../sel4-sync" }

[dependencies.sel4-runtime-common]
path = "../../../../sel4-runtime-common"
features = ["start", "tls", "unwinding"]
20 changes: 20 additions & 0 deletions crates/examples/root-task/spawn-task/child/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Copyright 2024, Colias Group, LLC
//
// SPDX-License-Identifier: BSD-2-Clause
//

#![no_std]
#![no_main]

mod runtime;

fn main() -> ! {
sel4::debug_println!("In child task");

sel4::Notification::from_bits(1).signal();

sel4::Tcb::from_bits(2).tcb_suspend().unwrap();

unreachable!()
}
71 changes: 71 additions & 0 deletions crates/examples/root-task/spawn-task/child/src/runtime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// Copyright 2024, Colias Group, LLC
//
// SPDX-License-Identifier: BSD-2-Clause
//

use core::ptr;

use sel4::CapTypeForFrameObjectOfFixedSize;
use sel4_dlmalloc::{StaticDlmallocGlobalAlloc, StaticHeap};
use sel4_panicking::catch_unwind;
use sel4_panicking_env::abort;
use sel4_sync::{GenericRawMutex, PanickingMutexSyncOps};

use crate::main;

const STACK_SIZE: usize = 1024 * 64;

sel4_runtime_common::declare_stack!(STACK_SIZE);

const HEAP_SIZE: usize = 1024 * 64;

static STATIC_HEAP: StaticHeap<HEAP_SIZE> = StaticHeap::new();

#[global_allocator]
static GLOBAL_ALLOCATOR: StaticDlmallocGlobalAlloc<
GenericRawMutex<PanickingMutexSyncOps>,
&'static StaticHeap<HEAP_SIZE>,
> = StaticDlmallocGlobalAlloc::new(
GenericRawMutex::new(PanickingMutexSyncOps::new()),
&STATIC_HEAP,
);

sel4_panicking_env::register_debug_put_char!(sel4::debug_put_char);

#[no_mangle]
unsafe extern "C" fn sel4_runtime_rust_entry() -> ! {
unsafe extern "C" fn cont_fn(_cont_arg: *mut sel4_runtime_common::ContArg) -> ! {
inner_entry()
}

sel4_runtime_common::initialize_tls_on_stack_and_continue(cont_fn, ptr::null_mut())
}

fn inner_entry() -> ! {
#[cfg(panic = "unwind")]
{
sel4_runtime_common::set_eh_frame_finder().unwrap();
}

unsafe {
sel4::set_ipc_buffer(get_ipc_buffer().as_mut().unwrap());
sel4_runtime_common::run_ctors();
}

match catch_unwind(main) {
Ok(never) => never,
Err(_) => abort!("main() panicked"),
}
}

fn get_ipc_buffer() -> *mut sel4::IpcBuffer {
extern "C" {
static _end: usize;
}
unsafe {
(ptr::addr_of!(_end) as usize)
.next_multiple_of(sel4::cap_type::Granule::FRAME_OBJECT_TYPE.bytes())
as *mut sel4::IpcBuffer
}
}
Loading
Loading