cantrip-os-rootserver: fetch file fill data per platform Select the scheme for filling file data according to the target platform. For now all platforms continue to read data from the cpio archive embeded in the capdl-loader image setup in memory. Eventually nexus platforms will read data from the Security Core (and elide the embedded cpio archive). Change-Id: Ie5f60b795a206fcccbdc311c4acd0ee3ff4a8527
diff --git a/cantrip-os-rootserver/Cargo.toml b/cantrip-os-rootserver/Cargo.toml index 0502813..e041c65 100644 --- a/cantrip-os-rootserver/Cargo.toml +++ b/cantrip-os-rootserver/Cargo.toml
@@ -23,10 +23,19 @@ sel4-config = { path = "../../cantrip/apps/system/components/cantrip-os-common/src/sel4-config" } [features] -default = ["LOG_INFO"] -CONFIG_PLAT_BCM2837 = [] -CONFIG_PLAT_SHODAN = [] -CONFIG_PLAT_NEXUS = [] +default = [ + "LOG_INFO", + "model/CONFIG_CAPDL_SHARED_FRAMES", +] +fill_from_cpio = [ + "model/CONFIG_CAPDL_LOADER_FILL_FROM_CPIO", +] +fill_from_sec = [ + "model/CONFIG_CAPDL_LOADER_FILL_FROM_SEC", +] +CONFIG_PLAT_BCM2837 = ["fill_from_cpio"] +CONFIG_PLAT_SHODAN = ["fill_from_cpio"] +CONFIG_PLAT_NEXUS = ["fill_from_cpio"] # Used by sel4-config to extract kernel config CONFIG_PRINTING = [] CONFIG_DEBUG_BUILD = [] @@ -37,18 +46,16 @@ LOG_DEBUG = ["log/release_max_level_debug"] LOG_TRACE = ["log/release_max_level_trace"] +[dependencies] +cantrip-os-common = { path = "../../cantrip/apps/system/components/cantrip-os-common", default-features = false } +capdl = { path = "../../cantrip/apps/system/components/cantrip-os-common/src/capdl" } +cfg-if = "1.0" +core2 = { version = "0.3", default-features = false } +log = "0.4" +model = { path = "../../cantrip/apps/system/components/cantrip-os-common/src/model" } +static_assertions = "1.1" + [lib] name = "cantrip_os_rootserver" path = "src/lib.rs" crate-type = ["staticlib"] - -[dependencies.cantrip-os-common] -default-features = false -features = ["capdl_support", "logger_support"] -path = "../../cantrip/apps/system/components/cantrip-os-common" - -[dependencies] -cfg-if = "1.0" -core2 = { version = "0.3", default-features = false } -log = "0.4" -static_assertions = "1.1"
diff --git a/cantrip-os-rootserver/src/lib.rs b/cantrip-os-rootserver/src/lib.rs index 92f24ee..a03db9e 100644 --- a/cantrip-os-rootserver/src/lib.rs +++ b/cantrip-os-rootserver/src/lib.rs
@@ -41,14 +41,14 @@ #![no_main] use cantrip_os_common::allocator; -use cantrip_os_common::capdl; -use cantrip_os_common::model; use cantrip_os_common::sel4_sys; +use capdl; use cfg_if::cfg_if; -use core::mem::size_of; use core2::io::{Cursor, Write}; +use core::mem::size_of; use core::ptr; use log::*; +use model; use capdl::CDL_Core; use capdl::CDL_Model; @@ -68,15 +68,25 @@ extern "C" { static capdl_spec: CDL_Model; // Generated by the CapDL tools from the .cdl spec - static _capdl_archive: [u8; 1]; // CPIO archive of component images - static _capdl_archive_end: [u8; 1]; - static __executable_start: [u8; 1]; // Start of rootserver image. static _end: [u8; 1]; fn sel4runtime_bootinfo() -> *const seL4_BootInfo; } +// Most platforms have the CAmkES components embedded in an elf segment +// exposed through these symbols. Some platforms may store the data in +// flash and retrieve it on demand using platform-specific methods. +// +// Note we depend on LTO to elide the associated elf segment when built +// without "fill_from_cpio" (e.g. "fill_from_sec"). This is subtle but +// allows us to leave the cmake BuildCapDLApplication function unchanged. +#[cfg(feature = "fill_from_cpio")] +extern "C" { + static _capdl_archive: [u8; 1]; // CPIO archive of component images + static _capdl_archive_end: [u8; 1]; +} + // Set log level for tracing rootseerver operation. cfg_if! { if #[cfg(feature = "LOG_DEBUG")] { @@ -293,6 +303,8 @@ fn calc_bytes(begin: *const u8, end: *const u8) -> usize { (end as usize) - (begin as usize) } + + #[cfg(feature = "fill_from_cpio")] let capdl_archive_ref = unsafe { core::slice::from_raw_parts( ptr::addr_of!(_capdl_archive[0]), @@ -302,6 +314,9 @@ ), ) }; + #[cfg(not(feature = "fill_from_cpio"))] + let capdl_archive_ref = &[0u8; 0]; + let executable_ref = unsafe { core::slice::from_raw_parts( ptr::addr_of!(__executable_start[0]),