-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nick Spinale <[email protected]>
- Loading branch information
Showing
13 changed files
with
628 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// 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() -> ! { | ||
unsafe { | ||
sel4_runtime_common::set_eh_frame_finder().unwrap(); | ||
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 | ||
} | ||
} |
Oops, something went wrong.