From 7a22ac83bbb3024ae04d89628073198701cf775c Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Sun, 6 Oct 2024 23:24:03 -0700 Subject: [PATCH 1/7] crates/meta: Add more re-exports Signed-off-by: Nick Spinale --- Cargo.lock | 19 +++++++++++++++++++ crates/private/meta/Cargo.nix | 20 ++++++++++++++++++++ crates/private/meta/Cargo.toml | 19 +++++++++++++++++++ crates/private/meta/src/lib.rs | 21 +++++++++++++++++++++ 4 files changed, 79 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 767d74461..afd17279a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1044,29 +1044,48 @@ dependencies = [ "sel4-async-block-io-fat", "sel4-async-io", "sel4-async-network", + "sel4-async-network-rustls", + "sel4-async-network-rustls-utils", "sel4-async-single-threaded-executor", "sel4-async-time", "sel4-async-unsync", "sel4-atomic-ptr", + "sel4-bcm2835-aux-uart-driver", "sel4-bounce-buffer-allocator", "sel4-config", + "sel4-dlmalloc", + "sel4-driver-interfaces", + "sel4-elf-header", "sel4-externally-shared", "sel4-immediate-sync-once-cell", "sel4-immutable-cell", + "sel4-initialize-tls", "sel4-logging", "sel4-microkit", "sel4-microkit-message", "sel4-microkit-message-types", + "sel4-newlib", "sel4-one-ref-cell", + "sel4-panicking", + "sel4-panicking-env", + "sel4-pl011-driver", + "sel4-pl031-driver", "sel4-platform-info", + "sel4-reset", "sel4-root-task", "sel4-shared-ring-buffer", "sel4-shared-ring-buffer-block-io", "sel4-shared-ring-buffer-block-io-types", "sel4-shared-ring-buffer-bookkeeping", "sel4-shared-ring-buffer-smoltcp", + "sel4-sp804-driver", + "sel4-stack", "sel4-sync", + "sel4-sync-trivial", "sel4-sys", + "sel4-virtio-blk", + "sel4-virtio-hal-impl", + "sel4-virtio-net", ] [[package]] diff --git a/crates/private/meta/Cargo.nix b/crates/private/meta/Cargo.nix index d4ff855e9..263bc194f 100644 --- a/crates/private/meta/Cargo.nix +++ b/crates/private/meta/Cargo.nix @@ -20,21 +20,41 @@ mk { sel4-async-block-io-fat sel4-async-io sel4-async-network + sel4-async-network-rustls + sel4-async-network-rustls-utils sel4-async-single-threaded-executor sel4-async-time sel4-async-unsync sel4-atomic-ptr sel4-bounce-buffer-allocator + sel4-dlmalloc + sel4-driver-interfaces + sel4-elf-header sel4-immediate-sync-once-cell sel4-immutable-cell + sel4-initialize-tls sel4-logging + sel4-newlib sel4-one-ref-cell + sel4-panicking + sel4-panicking-env + sel4-reset sel4-shared-ring-buffer sel4-shared-ring-buffer-block-io sel4-shared-ring-buffer-block-io-types sel4-shared-ring-buffer-bookkeeping sel4-shared-ring-buffer-smoltcp + sel4-stack sel4-sync + sel4-sync-trivial + + sel4-bcm2835-aux-uart-driver + sel4-pl011-driver + sel4-pl031-driver + sel4-sp804-driver + sel4-virtio-blk + sel4-virtio-hal-impl + sel4-virtio-net ; sel4-externally-shared = localCrates.sel4-externally-shared // { features = [ "unstable" ]; }; diff --git a/crates/private/meta/Cargo.toml b/crates/private/meta/Cargo.toml index e116b05c9..29521b907 100644 --- a/crates/private/meta/Cargo.toml +++ b/crates/private/meta/Cargo.toml @@ -28,28 +28,47 @@ sel4-async-block-io = { path = "../../sel4-async/block-io" } sel4-async-block-io-fat = { path = "../../sel4-async/block-io/fat" } sel4-async-io = { path = "../../sel4-async/io" } sel4-async-network = { path = "../../sel4-async/network" } +sel4-async-network-rustls = { path = "../../sel4-async/network/rustls" } +sel4-async-network-rustls-utils = { path = "../../sel4-async/network/rustls/utils" } sel4-async-single-threaded-executor = { path = "../../sel4-async/single-threaded-executor" } sel4-async-time = { path = "../../sel4-async/time" } sel4-async-unsync = { path = "../../sel4-async/unsync" } sel4-atomic-ptr = { path = "../../sel4-atomic-ptr" } +sel4-bcm2835-aux-uart-driver = { path = "../../drivers/bcm2835-aux-uart" } sel4-bounce-buffer-allocator = { path = "../../sel4-bounce-buffer-allocator" } sel4-config = { path = "../../sel4/config" } +sel4-dlmalloc = { path = "../../sel4-dlmalloc" } +sel4-driver-interfaces = { path = "../../sel4-driver-interfaces" } +sel4-elf-header = { path = "../../sel4-elf-header" } sel4-externally-shared = { path = "../../sel4-externally-shared", features = ["unstable"] } sel4-immediate-sync-once-cell = { path = "../../sel4-immediate-sync-once-cell" } sel4-immutable-cell = { path = "../../sel4-immutable-cell" } +sel4-initialize-tls = { path = "../../sel4-initialize-tls" } sel4-logging = { path = "../../sel4-logging" } sel4-microkit = { path = "../../sel4-microkit", features = ["full"], optional = true } sel4-microkit-message = { path = "../../sel4-microkit/message", optional = true } sel4-microkit-message-types = { path = "../../sel4-microkit/message/types", optional = true } +sel4-newlib = { path = "../../sel4-newlib" } sel4-one-ref-cell = { path = "../../sel4-one-ref-cell" } +sel4-panicking = { path = "../../sel4-panicking" } +sel4-panicking-env = { path = "../../sel4-panicking/env" } +sel4-pl011-driver = { path = "../../drivers/pl011" } +sel4-pl031-driver = { path = "../../drivers/pl031" } +sel4-reset = { path = "../../sel4-reset" } sel4-root-task = { path = "../../sel4-root-task", features = ["full"], optional = true } sel4-shared-ring-buffer = { path = "../../sel4-shared-ring-buffer" } sel4-shared-ring-buffer-block-io = { path = "../../sel4-shared-ring-buffer/block-io" } sel4-shared-ring-buffer-block-io-types = { path = "../../sel4-shared-ring-buffer/block-io/types" } sel4-shared-ring-buffer-bookkeeping = { path = "../../sel4-shared-ring-buffer/bookkeeping" } sel4-shared-ring-buffer-smoltcp = { path = "../../sel4-shared-ring-buffer/smoltcp" } +sel4-sp804-driver = { path = "../../drivers/sp804" } +sel4-stack = { path = "../../sel4-stack" } sel4-sync = { path = "../../sel4-sync" } +sel4-sync-trivial = { path = "../../sel4-sync/trivial" } sel4-sys = { path = "../../sel4/sys" } +sel4-virtio-blk = { path = "../../drivers/virtio/blk" } +sel4-virtio-hal-impl = { path = "../../drivers/virtio/hal-impl" } +sel4-virtio-net = { path = "../../drivers/virtio/net" } [target."cfg(not(target_arch = \"x86_64\"))".dependencies] sel4-platform-info = { path = "../../sel4-platform-info", optional = true } diff --git a/crates/private/meta/src/lib.rs b/crates/private/meta/src/lib.rs index 8014d8b24..a839becdb 100644 --- a/crates/private/meta/src/lib.rs +++ b/crates/private/meta/src/lib.rs @@ -79,28 +79,49 @@ pub mod absent {} definitely! { sel4 + // sel4_abstract_rc sel4_async_block_io sel4_async_block_io_fat sel4_async_io sel4_async_network + sel4_async_network_rustls + // sel4_async_network_rustls_utils sel4_async_single_threaded_executor sel4_async_time sel4_async_unsync sel4_atomic_ptr sel4_bounce_buffer_allocator sel4_config + sel4_dlmalloc + sel4_driver_interfaces + sel4_elf_header sel4_externally_shared sel4_immediate_sync_once_cell sel4_immutable_cell + sel4_initialize_tls sel4_logging + sel4_newlib sel4_one_ref_cell + sel4_panicking + sel4_panicking_env + sel4_reset sel4_shared_ring_buffer sel4_shared_ring_buffer_block_io sel4_shared_ring_buffer_block_io_types sel4_shared_ring_buffer_bookkeeping sel4_shared_ring_buffer_smoltcp + sel4_stack sel4_sync + sel4_sync_trivial sel4_sys + + sel4_bcm2835_aux_uart_driver + sel4_pl011_driver + sel4_pl031_driver + sel4_sp804_driver + sel4_virtio_net + sel4_virtio_blk + sel4_virtio_hal_impl } maybe! { From f2471609ebc41f5807f63f309104582167c9e1a5 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 7 Oct 2024 00:15:55 -0700 Subject: [PATCH 2/7] crates/private/meta: Expand Signed-off-by: Nick Spinale --- crates/private/meta/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/private/meta/src/lib.rs b/crates/private/meta/src/lib.rs index a839becdb..a53ed610b 100644 --- a/crates/private/meta/src/lib.rs +++ b/crates/private/meta/src/lib.rs @@ -23,9 +23,11 @@ //! notification-based mutexes. //! - [`sel4_logging`]: [`Log`](log::Log) implementation for the [`log`] crate. //! - [`sel4_externally_shared`]: Abstractions for interacting with data in shared memory. -//! - [`sel4_shared_ring_buffer`]: Implementation of shared data structures used in the [seL4 Device +//! - [`sel4_shared_ring_buffer`] and `sel4_shared_ring_buffer_*`: Implementation of shared data structures used in the [seL4 Device //! Driver Framework](https://github.com/au-ts/sddf). //! - `sel4_async_*`: Crates for leveraging async Rust in seL4 userspace. +//! - `sel4_*_driver`: Crates implementing drivers for use with `sel4_shared_ring_buffer_*` and the orthogonal [`sel4_driver_interfaces`]. +//! - ...and many more, including lower-level crates for implementing additional runtimes. //! //! ### Runtime crates //! @@ -79,6 +81,9 @@ pub mod absent {} definitely! { sel4 + sel4_sys + sel4_config + // sel4_abstract_rc sel4_async_block_io sel4_async_block_io_fat @@ -91,7 +96,6 @@ definitely! { sel4_async_unsync sel4_atomic_ptr sel4_bounce_buffer_allocator - sel4_config sel4_dlmalloc sel4_driver_interfaces sel4_elf_header @@ -113,7 +117,6 @@ definitely! { sel4_stack sel4_sync sel4_sync_trivial - sel4_sys sel4_bcm2835_aux_uart_driver sel4_pl011_driver From ef3dc5bc39501ea4b06b691c0b8135b9f5b6a68b Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 7 Oct 2024 00:17:01 -0700 Subject: [PATCH 3/7] Fix link in README.md Signed-off-by: Nick Spinale --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d257e2ae7..999b8e646 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This repository contains crates for supporting the use of Rust in The [./hacking](./hacking) directory contains scripts for developing and testing these crates using Nix and, optionally, Docker. -This work is funded by the [seL4 Foundation](https://sel4.systems/Foundation/home.pml). +This work is funded by the [seL4 Foundation](https://sel4.systems/Foundation/). ### Rendered rustdoc From 06a43457baae7be758770a8eebf2040adca17a8a Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 7 Oct 2024 00:23:11 -0700 Subject: [PATCH 4/7] Fix dependency commit hashes in README.md Signed-off-by: Nick Spinale --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 999b8e646..f1d73e2d8 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,11 @@ following versions of those related projects: [`cd6d3b8c25d49be2b100b0608cf0613483a6fffa`](https://github.com/seL4/seL4/tree/cd6d3b8c25d49be2b100b0608cf0613483a6fffa) (version 13.0.0, on [github.com/seL4/seL4:master](https://github.com/seL4/seL4/tree/master)) - seL4, when used with Microkit: - [`0cdbffec9cf6b4c7c9c57971cbee5a24a70c8fd0`](https://github.com/seL4/seL4/tree/0cdbffec9cf6b4c7c9c57971cbee5a24a70c8fd0) + [`4cae30a6ef166a378d4d23697b00106ce7e4e76f`](https://github.com/seL4/seL4/tree/4cae30a6ef166a378d4d23697b00106ce7e4e76f) (on [github.com/seL4/seL4:microkit](https://github.com/seL4/seL4/tree/microkit)) - seL4 Microkit: - [`1ccdfcb3b224533c965fd6508de3dd56657f959c`](https://github.com/seL4/microkit/tree/1ccdfcb3b224533c965fd6508de3dd56657f959c) - (version 1.3.0, on [github.com/seL4/microkit:main](https://github.com/seL4/microkit/tree/main)) + [`395cf0e5be489bbd7586b012188fc1f712cd1a57`](https://github.com/seL4/microkit/tree/395cf0e5be489bbd7586b012188fc1f712cd1a57) + (version 1.4.1, on [github.com/seL4/microkit:main](https://github.com/seL4/microkit/tree/main)) ### Demos From 870776cdfbd3b651734dd30254e72733292123d0 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Sun, 6 Oct 2024 23:38:24 -0700 Subject: [PATCH 5/7] Improve rustdoc Signed-off-by: Nick Spinale --- crates/sel4-microkit/base/src/defer.rs | 1 + crates/sel4-microkit/base/src/handler.rs | 3 ++ crates/sel4-microkit/base/src/message.rs | 15 +++++++ crates/sel4-microkit/base/src/symbols.rs | 57 +++++++++++++++++++++--- crates/sel4-microkit/macros/src/lib.rs | 40 ----------------- crates/sel4-microkit/src/lib.rs | 41 +++++++++++++++-- crates/sel4-root-task/src/lib.rs | 10 +++-- crates/sel4/src/lib.rs | 7 ++- 8 files changed, 117 insertions(+), 57 deletions(-) diff --git a/crates/sel4-microkit/base/src/defer.rs b/crates/sel4-microkit/base/src/defer.rs index facda19a3..d04ddc934 100644 --- a/crates/sel4-microkit/base/src/defer.rs +++ b/crates/sel4-microkit/base/src/defer.rs @@ -91,6 +91,7 @@ impl PreparedDeferredAction { } } +/// Utility type for implementing [`Handler::take_deferred_action`]. // TODO maybe excessive. remove? pub struct DeferredActionSlot { inner: Option, diff --git a/crates/sel4-microkit/base/src/handler.rs b/crates/sel4-microkit/base/src/handler.rs index c60f649bd..992319610 100644 --- a/crates/sel4-microkit/base/src/handler.rs +++ b/crates/sel4-microkit/base/src/handler.rs @@ -37,6 +37,9 @@ pub trait Handler { panic!("unexpected protected procedure call from channel {channel:?} with msg_info={msg_info:?}") } + /// This method has the same meaning and type as its analog in `libmicrokit`. + /// + /// The default implementation just panics. fn fault( &mut self, child: Child, diff --git a/crates/sel4-microkit/base/src/message.rs b/crates/sel4-microkit/base/src/message.rs index 182b8f525..4a606643e 100644 --- a/crates/sel4-microkit/base/src/message.rs +++ b/crates/sel4-microkit/base/src/message.rs @@ -4,9 +4,13 @@ // SPDX-License-Identifier: BSD-2-Clause // +/// Type alias for [`MessageInfo`] labels. pub type MessageLabel = sel4::Word; + +/// Type alias for message register values. pub type MessageRegisterValue = sel4::Word; +/// Corresponds to `microkit_msginfo`. #[derive(Debug, Clone)] pub struct MessageInfo { inner: sel4::MessageInfo, @@ -32,18 +36,22 @@ impl MessageInfo { Self::from_inner(sel4::MessageInfo::new(label, 0, 0, count)) } + /// The label associated with this message. pub fn label(&self) -> MessageLabel { self.inner.label() } + /// The number of meaningful bits in `MessageLabel`. pub const fn label_width() -> usize { sel4::MessageInfo::label_width() } + /// The number of filled message registers associated with this message. pub fn count(&self) -> usize { self.inner.length() } + /// Interpret this message as a [`sel4::Fault`]. pub fn fault(&self) -> sel4::Fault { sel4::with_ipc_buffer(|ipc_buffer| sel4::Fault::new(ipc_buffer, self.inner())) } @@ -55,26 +63,33 @@ impl Default for MessageInfo { } } +/// Provides access to the protection domain's message registers. pub fn with_msg_regs(f: impl FnOnce(&[MessageRegisterValue]) -> T) -> T { sel4::with_ipc_buffer(|ipc_buffer| f(ipc_buffer.msg_regs())) } +/// Provides mutable access to the protection domain's message registers. pub fn with_msg_regs_mut(f: impl FnOnce(&mut [MessageRegisterValue]) -> T) -> T { sel4::with_ipc_buffer_mut(|ipc_buffer| f(ipc_buffer.msg_regs_mut())) } +/// Provides access to the protection domain's message registers, viewed as an array of bytes. pub fn with_msg_bytes(f: impl FnOnce(&[u8]) -> T) -> T { sel4::with_ipc_buffer(|ipc_buffer| f(ipc_buffer.msg_bytes())) } +/// Provides mutable access to the protection domain's message registers, viewed as an array of +/// bytes. pub fn with_msg_bytes_mut(f: impl FnOnce(&mut [u8]) -> T) -> T { sel4::with_ipc_buffer_mut(|ipc_buffer| f(ipc_buffer.msg_bytes_mut())) } +/// Corresponds to `microkit_mr_set`. pub fn set_mr(i: usize, value: MessageRegisterValue) { with_msg_regs_mut(|regs| regs[i] = value) } +/// Corresponds to `microkit_mr_get`. pub fn get_mr(i: usize) -> MessageRegisterValue { with_msg_regs(|regs| regs[i]) } diff --git a/crates/sel4-microkit/base/src/symbols.rs b/crates/sel4-microkit/base/src/symbols.rs index 538f4bd06..554230c7d 100644 --- a/crates/sel4-microkit/base/src/symbols.rs +++ b/crates/sel4-microkit/base/src/symbols.rs @@ -7,6 +7,50 @@ use core::ptr; use core::str::{self, Utf8Error}; +/// Declares a symbol via which the `microkit` tool can inject a variable declared by e.g. +/// `setvar_vaddr`, and returns the variable's value at runtime. +/// +/// This macro is represents a lower-level interface than +/// [`memory_region_symbol`](crate::memory_region_symbol). +/// +/// The following fragment demonstrates its usage: +/// +/// ```rust +/// let my_var: &'static T = var!(my_var_symbol_name: T = MY_DEFAULT_VALUE) +/// ``` +/// +/// where `MY_DEFAULT_VALUE` is the value that the variable will be given at compile-time, before +/// the protection domain image is passed to the `microkit` tool. +/// +/// The patching mechanism used by the `microkit` tool requires that the symbol be allocated space +/// in the protection domain's ELF file, so we declare the symbol as part of the `.data` section. +/// +/// For more detail, see this macro's definition. +/// +/// # Examples +/// +/// ```rust +/// let foo = bar + *var!(baz: usize = 0); +/// ``` +/// +/// # Note +/// +/// The `microkit` tool requires memory region address symbols to be present in protection domain +/// binaries. To prevent Rust from optimizing them out in cases where it is not used, add the +/// unstable `#[used(linker)]` attribute. For example: +/// +/// ```rust +/// #![feature(used_with_arg)] +/// +/// // might be optimized away if not used +/// memory_region_symbol!(foo: usize = 0) +/// +/// // won't be optimized away +/// memory_region_symbol! { +/// #[used(linker)] +/// foo: usize = 0 +/// } +/// ``` #[macro_export] macro_rules! var { ($(#[$attrs:meta])* $symbol:ident: $ty:ty = $default:expr) => {{ @@ -25,10 +69,10 @@ macro_rules! var { /// Declares a symbol via which the `microkit` tool can inject a memory region's address, and /// returns the memory region's address at runtime. /// -/// For more detail, see its definition. -/// /// The patching mechanism used by the `microkit` tool requires that the symbol be allocated space -/// in the protection domain's ELF file, so we delare the symbol as part of the `.data` section. +/// in the protection domain's ELF file, so we declare the symbol as part of the `.data` section. +/// +/// For more detail, see this macro's definition. /// /// # Examples /// @@ -116,23 +160,24 @@ macro_rules! maybe_extern_var { }}; } -/// Returns whether this projection domain is a passive server. +/// Returns whether this protection domain is a passive server. pub fn pd_is_passive() -> bool { *maybe_extern_var!(microkit_passive: bool = false) } -/// Returns the name of this projection domain without converting to unicode. +/// Returns the name of this protection domain without converting to unicode. pub fn pd_name_bytes() -> &'static [u8] { let all_bytes = maybe_extern_var!(microkit_name: [u8; 16] = [0; 16]); let n = all_bytes.iter().take_while(|b| **b != 0).count(); &all_bytes[..n] } -/// Returns the name of this projection domain. +/// Returns the name of this protection domain. pub fn pd_name() -> Result<&'static str, Utf8Error> { str::from_utf8(pd_name_bytes()) } +/// Returns a pointer to the protection domain's [`sel4::IpcBuffer`]. pub fn ipc_buffer_ptr() -> *mut sel4::IpcBuffer { extern "C" { static mut __sel4_ipc_buffer_obj: sel4::IpcBuffer; diff --git a/crates/sel4-microkit/macros/src/lib.rs b/crates/sel4-microkit/macros/src/lib.rs index 68acae4e5..53373f886 100644 --- a/crates/sel4-microkit/macros/src/lib.rs +++ b/crates/sel4-microkit/macros/src/lib.rs @@ -9,46 +9,6 @@ use proc_macro2::TokenStream as TokenStream2; use quote::quote; use syn::parse_macro_input; -/// Declares the initialization function, stack size, and, optionally, heap and heap size. -/// -/// The syntax is: -/// -/// ```rust -/// #[protection_domain($($key:ident = $value:expr),* $(,)?)] -/// fn init() -> impl Handler { -/// // ... -/// } -/// ``` -/// -/// Where the possible keys are: -/// - `stack_size`: Sets the stack size. Defaults to `0x4000`. -/// - `heap_size`: Declares a `#[global_allocator]` implemented using Dlmalloc and a -/// statically-allocated heap. Optional. -/// -/// The function to which the attribute is applied will be used to initialize the protection domain. -/// It must satisfy `FnOnce() -> T where T: Handler`. -/// -/// This macro is a thin wrapper around `sel4_microkit::declare_protection_domain`. The following -/// are equivalent: -/// -/// ```rust -/// #[protection_domain(stack_size = 0x12000, heap_size = 0x34000)] -/// fn init() -> impl Handler { -/// // ... -/// } -/// ``` -/// -/// ```rust -/// declare_protection_domain! { -/// init = my_init, -/// stack_size = 0x12000, -/// heap_size = 0x34000, -/// } -/// -/// fn init() -> impl Handler { -/// // ... -/// } -/// ``` #[proc_macro_attribute] pub fn protection_domain(attr: TokenStream, item: TokenStream) -> TokenStream { let item = parse_macro_input!(item as syn::ItemFn); diff --git a/crates/sel4-microkit/src/lib.rs b/crates/sel4-microkit/src/lib.rs index 9e0831030..8a693a219 100644 --- a/crates/sel4-microkit/src/lib.rs +++ b/crates/sel4-microkit/src/lib.rs @@ -38,7 +38,6 @@ extern crate alloc; use sel4::sel4_cfg; pub use sel4_microkit_base::*; -pub use sel4_microkit_macros::protection_domain; mod entry; mod heap; @@ -49,9 +48,44 @@ pub mod panicking; #[sel4_cfg(PRINTING)] pub use printing::{debug_print, debug_println}; -/// Declares the initialization function, stack size, and, optionally, heap and heap size. +/// Declares a function to be the the protection domain's initialization function. +/// +/// For example: +/// +/// ```rust +/// #[protection_domain] +/// fn init() -> impl Handler { +/// todo!() +/// } +/// ``` +/// +/// The initialization function have a signature of the form: +/// +/// ```rust +/// fn() -> T +/// ``` +/// +/// (See [`Handler`]) /// -/// See the [`protection_domain`] attribute macro for more detail. +/// This macro takes two optional parameters, whose values can be any expression of type `usize`: +/// +/// ```rust +/// #[protection_domain( +/// stack_size = , +/// heap_size = , +/// )] +/// ``` +/// +/// - `stack_size`: Declares the size of the protection domain's stack, in bytes. Note that this +/// includes space for thread-local storage. If absent, [`DEFAULT_STACK_SIZE`] will be used. +/// - `heap_size`: Creates a `#[global_allocator]`, backed by a static heap of the specified size. +/// If this parameter is not specified, no `#[global_allocator]` will be automatically declared, +/// and, unless one is manually declared, heap allocations will result in a link-time error. +/// +/// Note that, if both parameters are provided, they must appear in the order above. +pub use sel4_microkit_macros::protection_domain; + +#[doc(hidden)] #[macro_export] macro_rules! declare_protection_domain { { @@ -82,6 +116,7 @@ macro_rules! declare_protection_domain { }; } +/// The default stack size used by [`#[protection_domain]`](crate::protection_domain). pub const DEFAULT_STACK_SIZE: usize = 1024 * if cfg!(panic = "unwind") && cfg!(debug_assertions) { 128 diff --git a/crates/sel4-root-task/src/lib.rs b/crates/sel4-root-task/src/lib.rs index 0d16b1e19..e57526e9c 100644 --- a/crates/sel4-root-task/src/lib.rs +++ b/crates/sel4-root-task/src/lib.rs @@ -60,19 +60,21 @@ pub use sel4_panicking_env::{debug_print, debug_println}; /// } /// ``` /// -/// /// The main function have a signature of the form: /// /// ```rust -/// fn(&sel4::BootInfoPtr) -> T +/// fn(&sel4::BootInfoPtr) -> T /// ``` /// /// (See [`Termination`]) /// -/// This macro takes two optional parameters: +/// This macro takes two optional parameters, whose values can be any expression of type `usize`: /// /// ```rust -/// #[root_task(stack_size = , heap_size = )] +/// #[root_task( +/// stack_size = , +/// heap_size = , +/// )] /// ``` /// /// - `stack_size`: Declares the size of the initial thread's stack, in bytes. Note that this diff --git a/crates/sel4/src/lib.rs b/crates/sel4/src/lib.rs index 1b2f83121..3cae0b229 100644 --- a/crates/sel4/src/lib.rs +++ b/crates/sel4/src/lib.rs @@ -7,10 +7,9 @@ //! This crate provides straightforward, pure-Rust bindings to the [seL4 //! API](https://sel4.systems/Info/Docs/seL4-manual-latest.pdf). //! -//! Most items in this crate correspond to types, constants, and functions in -//! [libsel4](https://docs.sel4.systems/projects/sel4/api-doc.html). Notably, when applicable, -//! `seL4_CPtr` is agumented in [`Cap`] with a marker specifying the type of capability it points -//! to. +//! Most items in this crate correspond to types, constants, and functions in `libsel4`. See the +//! [seL4 manual](https://sel4.systems/Info/Docs/seL4-manual-latest.pdf) for more information about +//! the seL4 concepts and `libsel4` items references in this crate's documentation. //! //! This crate's implementation is based on the lower-level [`sel4-sys`](::sel4_sys) crate, which is //! generated from the libsel4 headers and interface definition files. From 86243e69c29b99ee3cad16e26e9808277b5d892e Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 7 Oct 2024 00:55:35 -0700 Subject: [PATCH 6/7] crates/meta: Remove rustls Signed-off-by: Nick Spinale --- Cargo.lock | 2 -- crates/private/meta/Cargo.nix | 2 -- crates/private/meta/Cargo.toml | 2 -- crates/private/meta/src/lib.rs | 2 -- 4 files changed, 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index afd17279a..87d35564b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1044,8 +1044,6 @@ dependencies = [ "sel4-async-block-io-fat", "sel4-async-io", "sel4-async-network", - "sel4-async-network-rustls", - "sel4-async-network-rustls-utils", "sel4-async-single-threaded-executor", "sel4-async-time", "sel4-async-unsync", diff --git a/crates/private/meta/Cargo.nix b/crates/private/meta/Cargo.nix index 263bc194f..eb2246639 100644 --- a/crates/private/meta/Cargo.nix +++ b/crates/private/meta/Cargo.nix @@ -20,8 +20,6 @@ mk { sel4-async-block-io-fat sel4-async-io sel4-async-network - sel4-async-network-rustls - sel4-async-network-rustls-utils sel4-async-single-threaded-executor sel4-async-time sel4-async-unsync diff --git a/crates/private/meta/Cargo.toml b/crates/private/meta/Cargo.toml index 29521b907..6079d86bf 100644 --- a/crates/private/meta/Cargo.toml +++ b/crates/private/meta/Cargo.toml @@ -28,8 +28,6 @@ sel4-async-block-io = { path = "../../sel4-async/block-io" } sel4-async-block-io-fat = { path = "../../sel4-async/block-io/fat" } sel4-async-io = { path = "../../sel4-async/io" } sel4-async-network = { path = "../../sel4-async/network" } -sel4-async-network-rustls = { path = "../../sel4-async/network/rustls" } -sel4-async-network-rustls-utils = { path = "../../sel4-async/network/rustls/utils" } sel4-async-single-threaded-executor = { path = "../../sel4-async/single-threaded-executor" } sel4-async-time = { path = "../../sel4-async/time" } sel4-async-unsync = { path = "../../sel4-async/unsync" } diff --git a/crates/private/meta/src/lib.rs b/crates/private/meta/src/lib.rs index a53ed610b..ac35b0ec7 100644 --- a/crates/private/meta/src/lib.rs +++ b/crates/private/meta/src/lib.rs @@ -89,8 +89,6 @@ definitely! { sel4_async_block_io_fat sel4_async_io sel4_async_network - sel4_async_network_rustls - // sel4_async_network_rustls_utils sel4_async_single_threaded_executor sel4_async_time sel4_async_unsync From ea23f2438b3f735a5d788e146bf40138fa34351d Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 7 Oct 2024 01:01:18 -0700 Subject: [PATCH 7/7] crates/private/meta: Fix cross-platform build Signed-off-by: Nick Spinale --- crates/private/meta/Cargo.nix | 6 +++++- crates/private/meta/Cargo.toml | 4 +++- crates/private/meta/src/lib.rs | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/private/meta/Cargo.nix b/crates/private/meta/Cargo.nix index eb2246639..e8e11e4c4 100644 --- a/crates/private/meta/Cargo.nix +++ b/crates/private/meta/Cargo.nix @@ -36,7 +36,6 @@ mk { sel4-one-ref-cell sel4-panicking sel4-panicking-env - sel4-reset sel4-shared-ring-buffer sel4-shared-ring-buffer-block-io sel4-shared-ring-buffer-block-io-types @@ -64,6 +63,11 @@ mk { target."cfg(not(target_thread_local))".dependencies = { sel4 = localCrates.sel4 // { features = [ "single-threaded" ]; }; }; + target."cfg(target_arch = \"aarch64\")".dependencies = { + inherit (localCrates) + sel4-reset + ; + }; target."cfg(not(target_arch = \"x86_64\"))".dependencies = { sel4-platform-info = localCrates.sel4-platform-info // { optional = true; }; }; diff --git a/crates/private/meta/Cargo.toml b/crates/private/meta/Cargo.toml index 6079d86bf..40c8ddb4a 100644 --- a/crates/private/meta/Cargo.toml +++ b/crates/private/meta/Cargo.toml @@ -52,7 +52,6 @@ sel4-panicking = { path = "../../sel4-panicking" } sel4-panicking-env = { path = "../../sel4-panicking/env" } sel4-pl011-driver = { path = "../../drivers/pl011" } sel4-pl031-driver = { path = "../../drivers/pl031" } -sel4-reset = { path = "../../sel4-reset" } sel4-root-task = { path = "../../sel4-root-task", features = ["full"], optional = true } sel4-shared-ring-buffer = { path = "../../sel4-shared-ring-buffer" } sel4-shared-ring-buffer-block-io = { path = "../../sel4-shared-ring-buffer/block-io" } @@ -73,3 +72,6 @@ sel4-platform-info = { path = "../../sel4-platform-info", optional = true } [target."cfg(not(target_thread_local))".dependencies] sel4 = { path = "../../sel4", features = ["single-threaded"] } + +[target."cfg(target_arch = \"aarch64\")".dependencies] +sel4-reset = { path = "../../sel4-reset" } diff --git a/crates/private/meta/src/lib.rs b/crates/private/meta/src/lib.rs index ac35b0ec7..75b5d5665 100644 --- a/crates/private/meta/src/lib.rs +++ b/crates/private/meta/src/lib.rs @@ -106,7 +106,14 @@ definitely! { sel4_one_ref_cell sel4_panicking sel4_panicking_env +} + +maybe! { + #[cfg(target_arch = "aarch64")] sel4_reset +} + +definitely! { sel4_shared_ring_buffer sel4_shared_ring_buffer_block_io sel4_shared_ring_buffer_block_io_types