diff --git a/Cargo.lock b/Cargo.lock index b839e392d..ec1a7e132 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2562,13 +2562,13 @@ dependencies = [ name = "sel4-config" version = "0.1.0" dependencies = [ - "prettyplease", "proc-macro2", "quote", "sel4-config-data", "sel4-config-macros", "sel4-config-types", "syn", + "tinyjson", ] [[package]] @@ -2577,7 +2577,6 @@ version = "0.1.0" dependencies = [ "sel4-build-env", "sel4-config-types", - "serde_json", ] [[package]] @@ -2660,7 +2659,6 @@ dependencies = [ "log", "object", "postcard", - "prettyplease", "proc-macro2", "quote", "riscv", @@ -3181,7 +3179,6 @@ dependencies = [ "log", "pest", "pest_derive", - "prettyplease", "proc-macro2", "quote", "regex", @@ -3800,6 +3797,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" +[[package]] +name = "tinyjson" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ab95735ea2c8fd51154d01e39cf13912a78071c2d89abc49a7ef102a7dd725a" + [[package]] name = "tinyvec" version = "1.11.0" diff --git a/crates/experimental/sddf/sys/Cargo.toml b/crates/experimental/sddf/sys/Cargo.toml index 4a5d15142..7679bdeba 100644 --- a/crates/experimental/sddf/sys/Cargo.toml +++ b/crates/experimental/sddf/sys/Cargo.toml @@ -18,5 +18,5 @@ license = "BSD-2-Clause" links = "sddf" [build-dependencies] -bindgen = "0.72.1" +bindgen = { version = "0.72.1", features = ["runtime"], default-features = false } cc = "1.2.43" diff --git a/crates/private/support/sel4-minimal-linux-runtime/macros/Cargo.toml b/crates/private/support/sel4-minimal-linux-runtime/macros/Cargo.toml index 511fe23f2..33aba18d3 100644 --- a/crates/private/support/sel4-minimal-linux-runtime/macros/Cargo.toml +++ b/crates/private/support/sel4-minimal-linux-runtime/macros/Cargo.toml @@ -22,4 +22,4 @@ proc-macro = true [dependencies] proc-macro2 = "1.0.103" quote = "1.0.41" -syn = { version = "2.0.108", features = ["full"] } +syn = { version = "2.0.108", features = ["full"], default-features = false } diff --git a/crates/private/support/sel4-simple-task/runtime/macros/Cargo.toml b/crates/private/support/sel4-simple-task/runtime/macros/Cargo.toml index bdcd17df7..e1c562698 100644 --- a/crates/private/support/sel4-simple-task/runtime/macros/Cargo.toml +++ b/crates/private/support/sel4-simple-task/runtime/macros/Cargo.toml @@ -22,4 +22,4 @@ proc-macro = true [dependencies] proc-macro2 = "1.0.103" quote = "1.0.41" -syn = { version = "2.0.108", features = ["full"] } +syn = { version = "2.0.108", features = ["full"], default-features = false } diff --git a/crates/sel4-capdl-initializer/types/Cargo.toml b/crates/sel4-capdl-initializer/types/Cargo.toml index 00db5dc22..8e97cdace 100644 --- a/crates/sel4-capdl-initializer/types/Cargo.toml +++ b/crates/sel4-capdl-initializer/types/Cargo.toml @@ -33,7 +33,7 @@ optional = true [dependencies.rkyv] version = "0.8.12" default-features = false -features = ["alloc", "bytecheck", "pointer_width_32"] +features = ["alloc", "pointer_width_32"] [dependencies.serde] version = "1.0.228" diff --git a/crates/sel4-capdl-initializer/types/derive/Cargo.toml b/crates/sel4-capdl-initializer/types/derive/Cargo.toml index cc587174e..acaf6c6d9 100644 --- a/crates/sel4-capdl-initializer/types/derive/Cargo.toml +++ b/crates/sel4-capdl-initializer/types/derive/Cargo.toml @@ -21,5 +21,5 @@ proc-macro = true [dependencies] proc-macro2 = "1.0.103" -quote = "1.0.41" -syn = "2.0.108" +quote = { version = "1.0.41", default-features = false } +syn = { version = "2.0.108", default-features = false } diff --git a/crates/sel4-capdl-initializer/types/src/lib.rs b/crates/sel4-capdl-initializer/types/src/lib.rs index 07d466023..15f72c18d 100644 --- a/crates/sel4-capdl-initializer/types/src/lib.rs +++ b/crates/sel4-capdl-initializer/types/src/lib.rs @@ -39,7 +39,7 @@ impl SpecForInitializer { } pub fn access(buf: &[u8]) -> Result<&::Archived, rancor::Error> { - rkyv::access(buf) + Ok(unsafe { rkyv::access_unchecked(buf) }) } #[allow(clippy::missing_safety_doc)] diff --git a/crates/sel4-kernel-loader/Cargo.nix b/crates/sel4-kernel-loader/Cargo.nix index 24180532c..8fe4e1a29 100644 --- a/crates/sel4-kernel-loader/Cargo.nix +++ b/crates/sel4-kernel-loader/Cargo.nix @@ -40,7 +40,6 @@ mk { quote object serde - prettyplease cc glob ; diff --git a/crates/sel4-kernel-loader/Cargo.toml b/crates/sel4-kernel-loader/Cargo.toml index e18d1e275..811a1d890 100644 --- a/crates/sel4-kernel-loader/Cargo.toml +++ b/crates/sel4-kernel-loader/Cargo.toml @@ -37,7 +37,6 @@ cc = "1.2.43" glob = "0.3.3" object = "0.38.1" postcard = { version = "1.1.3", default-features = false, features = ["alloc"] } -prettyplease = "0.2.37" proc-macro2 = "1.0.103" quote = "1.0.41" sel4-build-env = { path = "../sel4/build-env" } @@ -45,7 +44,7 @@ sel4-config = { path = "../sel4/config" } sel4-kernel-loader-payload-types = { path = "payload-types" } sel4-platform-info = { path = "../sel4-platform-info" } serde = "1.0.228" -syn = { version = "2.0.108", features = ["parsing"] } +syn = { version = "2.0.108", features = ["parsing"], default-features = false } [target."cfg(any(target_arch = \"arm\", target_arch = \"aarch64\"))".dependencies] sel4-bcm2835-aux-uart-driver = { path = "../drivers/bcm2835-aux-uart" } diff --git a/crates/sel4-root-task/macros/Cargo.toml b/crates/sel4-root-task/macros/Cargo.toml index 00b9524b7..21bb8e3b0 100644 --- a/crates/sel4-root-task/macros/Cargo.toml +++ b/crates/sel4-root-task/macros/Cargo.toml @@ -22,4 +22,4 @@ proc-macro = true [dependencies] proc-macro2 = "1.0.103" quote = "1.0.41" -syn = { version = "2.0.108", features = ["full"] } +syn = { version = "2.0.108", features = ["full"], default-features = false } diff --git a/crates/sel4/build-env/src/lib.rs b/crates/sel4/build-env/src/lib.rs index db16377cf..fa0989240 100644 --- a/crates/sel4/build-env/src/lib.rs +++ b/crates/sel4/build-env/src/lib.rs @@ -12,6 +12,13 @@ pub const SEL4_PREFIX_ENV: &str = "SEL4_PREFIX"; pub const SEL4_INCLUDE_DIRS_ENV: &str = "SEL4_INCLUDE_DIRS"; fn get_asserting_valid_unicode(var: &str) -> Option { + get_asserting_valid_unicode_runtime(var) + .inspect(|_| { + println!("cargo::rerun-if-env-changed={var}"); + }) +} + +fn get_asserting_valid_unicode_runtime(var: &str) -> Option { env::var(var) .map_err(|err| { if let VarError::NotUnicode(val) = err { @@ -19,11 +26,9 @@ fn get_asserting_valid_unicode(var: &str) -> Option { } }) .ok() - .inspect(|_| { - println!("cargo::rerun-if-env-changed={var}"); - }) } + pub fn get_with_sel4_prefix_relative_fallback( var: &str, relative_path_from_fallback: impl AsRef, @@ -48,6 +53,10 @@ pub fn get_sel4_prefix() -> Option { get_asserting_valid_unicode(SEL4_PREFIX_ENV).map(PathBuf::from) } +pub fn get_sel4_prefix_runtime() -> Option { + get_asserting_valid_unicode_runtime(SEL4_PREFIX_ENV).map(PathBuf::from) +} + pub fn get_libsel4_include_dirs() -> impl Iterator { get_asserting_valid_unicode(SEL4_INCLUDE_DIRS_ENV) .map(|val| val.split(':').map(PathBuf::from).collect()) @@ -59,6 +68,14 @@ pub fn get_libsel4_include_dirs() -> impl Iterator { }) } +pub fn get_libsel4_include_dirs_runtime() -> impl Iterator { + get_asserting_valid_unicode_runtime(SEL4_INCLUDE_DIRS_ENV) + .map(|val| val.split(':').map(PathBuf::from).collect()) + .or_else(|| get_sel4_prefix_runtime().map(|sel4_prefix| vec![sel4_prefix.join("libsel4/include")])) + .unwrap_or_else(|| panic!("{SEL4_INCLUDE_DIRS_ENV} or {SEL4_PREFIX_ENV} must be set")) + .into_iter() +} + pub fn try_find_in_libsel4_include_dirs(relative_path: impl AsRef) -> Option { for d in get_libsel4_include_dirs() { let path = Path::new(&d).join(relative_path.as_ref()); @@ -78,3 +95,23 @@ pub fn find_in_libsel4_include_dirs(relative_path: impl AsRef) -> PathBuf ) }) } + +pub fn try_find_in_libsel4_include_dirs_runtime(relative_path: impl AsRef) -> Option { + for d in get_libsel4_include_dirs_runtime() { + let path = Path::new(&d).join(relative_path.as_ref()); + if path.exists() { + return Some(path); + } + } + None +} + +pub fn find_in_libsel4_include_dirs_runtime(relative_path: impl AsRef) -> PathBuf { + let relative_path = relative_path.as_ref(); + try_find_in_libsel4_include_dirs_runtime(relative_path).unwrap_or_else(|| { + panic!( + "{} not found in libsel4 include path", + relative_path.display() + ) + }) +} diff --git a/crates/sel4/config/Cargo.nix b/crates/sel4/config/Cargo.nix index 6a220d49f..34fd5579f 100644 --- a/crates/sel4/config/Cargo.nix +++ b/crates/sel4/config/Cargo.nix @@ -15,7 +15,6 @@ mk { }; build-dependencies = { inherit (versions) - prettyplease proc-macro2 quote ; diff --git a/crates/sel4/config/Cargo.toml b/crates/sel4/config/Cargo.toml index cf8c87427..b25dcc020 100644 --- a/crates/sel4/config/Cargo.toml +++ b/crates/sel4/config/Cargo.toml @@ -20,9 +20,8 @@ license = "BSD-2-Clause" sel4-config-macros = { path = "macros" } [build-dependencies] -prettyplease = "0.2.37" proc-macro2 = "1.0.103" quote = "1.0.41" sel4-config-data = { path = "data" } sel4-config-types = { path = "types" } -syn = { version = "2.0.108", features = ["parsing"] } +syn = { version = "2.0.108", features = ["parsing"], default-features = false } diff --git a/crates/sel4/config/build.rs b/crates/sel4/config/build.rs index 04ca8dcfd..2a72edaec 100644 --- a/crates/sel4/config/build.rs +++ b/crates/sel4/config/build.rs @@ -16,7 +16,8 @@ use sel4_config_types::{Configuration, Value}; fn main() { let toks = generate_consts(get_kernel_config()); - let formatted = prettyplease::unparse(&syn::parse2(toks).unwrap()); + let syntax_tree: syn::File = syn::parse2(toks).unwrap(); + let formatted = quote!(#syntax_tree).to_string(); let out_dir = env::var("OUT_DIR").unwrap(); let out_path = PathBuf::from(&out_dir).join("consts_gen.rs"); fs::write(out_path, formatted).unwrap(); diff --git a/crates/sel4/config/data/Cargo.toml b/crates/sel4/config/data/Cargo.toml index 9345cc943..434926021 100644 --- a/crates/sel4/config/data/Cargo.toml +++ b/crates/sel4/config/data/Cargo.toml @@ -16,11 +16,15 @@ authors = ["Nick Spinale "] edition = "2024" license = "BSD-2-Clause" +[features] +embedded-config = [] + [dependencies] -sel4-config-types = { path = "../types", features = ["serde"] } -serde_json = "1.0.145" +sel4-build-env = { path = "../../build-env" } +sel4-config-types = { path = "../types", features = [] } +tinyjson = { version = "2.5.1", default-features = false } [build-dependencies] sel4-build-env = { path = "../../build-env" } -sel4-config-types = { path = "../types", features = ["serde"] } -serde_json = "1.0.145" +sel4-config-types = { path = "../types", features = [] } +tinyjson = { version = "2.5.1", default-features = false } diff --git a/crates/sel4/config/data/build.rs b/crates/sel4/config/data/build.rs index 70e974610..5e5d1e29a 100644 --- a/crates/sel4/config/data/build.rs +++ b/crates/sel4/config/data/build.rs @@ -5,12 +5,15 @@ // use std::env; +use std::io::Write; use std::fs::File; use std::path::{Path, PathBuf}; use sel4_build_env::find_in_libsel4_include_dirs; -use sel4_config_types::Configuration; +use sel4_config_types::{Configuration, Value}; +use tinyjson::JsonValue; +#[cfg(feature = "embedded-config")] fn main() { let config = { let kernel_config = from_path(find_in_libsel4_include_dirs("kernel/gen_config.json")); @@ -23,9 +26,31 @@ fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let out_path = PathBuf::from(&out_dir).join("kernel_config.json"); - serde_json::to_writer_pretty(File::create(out_path).unwrap(), &config).unwrap() + let mut out_file = File::create(out_path).unwrap(); + let out_json = JsonValue::Object(config.iter().map(|(k, v)| { + (k.clone(), match v { + Value::String(v) => JsonValue::String(v.to_string()), + Value::Bool(v) => JsonValue::Boolean(*v), + }) + }).collect()); + let out_json_str: String = out_json.format().unwrap(); + write!(out_file, "{}", out_json_str).unwrap(); } +#[cfg(not(feature = "embedded-config"))] +fn main() {} + fn from_path(path: impl AsRef) -> Configuration { - serde_json::from_reader(File::open(path).unwrap()).unwrap() + let json = std::fs::read_to_string(path).unwrap(); + let json: JsonValue = json.parse().unwrap(); + let JsonValue::Object(ref map) = json else { + panic!("invalid json: {json:#?}"); + }; + Configuration::new(map.into_iter().map(|(k, v)| { + (k.clone(), match v { + JsonValue::String(v) => Value::String(v.to_string()), + JsonValue::Boolean(v) => Value::Bool(*v), + _ => panic!("unsupported jsonvalue: key '{k}', value '{v:#?}'"), + }) + }).collect()) } diff --git a/crates/sel4/config/data/src/lib.rs b/crates/sel4/config/data/src/lib.rs index 64ce5d4e8..cf1010e81 100644 --- a/crates/sel4/config/data/src/lib.rs +++ b/crates/sel4/config/data/src/lib.rs @@ -7,14 +7,59 @@ #![allow(unused_imports)] use std::sync::LazyLock; +use std::path::Path; -pub use sel4_config_types::Configuration; +use sel4_build_env::find_in_libsel4_include_dirs_runtime; +pub use sel4_config_types::{Configuration, Value}; +use tinyjson::JsonValue; pub fn get_kernel_config() -> &'static Configuration { &KERNEL_CONFIG } +pub fn config_as_bool(string: &str) -> bool { + get_kernel_config().get(string).map(|v| v.as_bool().expect("expected bool")).expect("missing config key") +} + +pub fn config_as_string(string: &str) -> &str { + get_kernel_config().get(string).map(|v| v.as_str()).expect("expected string").expect("missing config key") +} + +#[cfg(feature = "embedded-config")] +static KERNEL_CONFIG: LazyLock = + LazyLock::new(|| from_string(KERNEL_CONFIG_JSON)); + +#[cfg(not(feature = "embedded-config"))] static KERNEL_CONFIG: LazyLock = - LazyLock::new(|| serde_json::from_str(KERNEL_CONFIG_JSON).unwrap()); + LazyLock::new(|| { + let kernel_config = from_path(find_in_libsel4_include_dirs_runtime("kernel/gen_config.json")); + let libsel4_config = from_path(find_in_libsel4_include_dirs_runtime("sel4/gen_config.json")); + let mut this = Configuration::empty(); + this.append(kernel_config); + this.append(libsel4_config); + this + }); +#[cfg(feature = "embedded-config")] const KERNEL_CONFIG_JSON: &str = include_str!(concat!(env!("OUT_DIR"), "/kernel_config.json")); + +fn from_path(path: impl AsRef) -> Configuration { + let json = std::fs::read_to_string(path).unwrap(); + from_string(&json) +} + + +fn from_string(string: &str) -> Configuration { + let json: JsonValue = string.parse().unwrap(); + let JsonValue::Object(ref map) = json else { + panic!("invalid json: {json:#?}"); + }; + Configuration::new(map.into_iter().map(|(k, v)| { + (k.clone(), match v { + JsonValue::String(v) => Value::String(v.to_string()), + JsonValue::Boolean(v) => Value::Bool(*v), + _ => panic!("unsupported jsonvalue: key '{k}', value '{v:#?}'"), + }) + }).collect()) +} + diff --git a/crates/sel4/sys/Cargo.nix b/crates/sel4/sys/Cargo.nix index d5fc98c8c..f3ae8d80c 100644 --- a/crates/sel4/sys/Cargo.nix +++ b/crates/sel4/sys/Cargo.nix @@ -19,7 +19,7 @@ mk { }; build-dependencies = { inherit (versions) - proc-macro2 quote prettyplease + proc-macro2 quote bindgen xmltree glob regex pest pest_derive ; diff --git a/crates/sel4/sys/Cargo.toml b/crates/sel4/sys/Cargo.toml index 8574f7e6e..f14f40d90 100644 --- a/crates/sel4/sys/Cargo.toml +++ b/crates/sel4/sys/Cargo.toml @@ -24,16 +24,22 @@ sel4-bitfield-ops = { path = "../bitfield-ops" } sel4-config = { path = "../config" } [build-dependencies] -bindgen = "0.72.1" +bindgen = { version = "0.72.1", default-features = false } glob = "0.3.3" pest = "2.8.3" pest_derive = "2.8.3" -prettyplease = "0.2.37" proc-macro2 = "1.0.103" quote = "1.0.41" -regex = "1.12.2" +regex = { version = "1.12.2", default-features = false } sel4-build-env = { path = "../build-env" } -sel4-config = { path = "../config" } sel4-config-data = { path = "../config/data" } -syn = { version = "2.0.108", features = ["parsing"] } +syn = { version = "2.0.108", features = ["parsing"], default-features = false } xmltree = "0.12.0" + +[bindgen.dependencies] +default-features = false +regex = { default-features = false } + +[regex.dependencies] +default-features = false +regex-automata = { default-features = false } diff --git a/crates/sel4/sys/build/c.rs b/crates/sel4/sys/build/c.rs index a6dec8d86..60fe4999c 100644 --- a/crates/sel4/sys/build/c.rs +++ b/crates/sel4/sys/build/c.rs @@ -45,6 +45,7 @@ pub fn generate_rust( arch => arch, }; + eprintln!("starting bidngen"); let mut builder = bindgen::Builder::default() .header_contents("wrapper.h", HEADER_CONTENTS) .detect_include_paths(false) @@ -60,12 +61,14 @@ pub fn generate_rust( builder = builder.blocklist_item(item); } - builder + let x = builder .constified_enum_module(".*") .derive_eq(true) .derive_default(true) .generate_comments(false) .use_core() .generate() - .unwrap() + .unwrap(); + eprintln!("builder go"); + x } diff --git a/crates/sel4/sys/build/main.rs b/crates/sel4/sys/build/main.rs index 96b3437d3..6f3afe975 100644 --- a/crates/sel4/sys/build/main.rs +++ b/crates/sel4/sys/build/main.rs @@ -5,11 +5,13 @@ // use std::env; +use std::io::{BufWriter, Write}; use std::fs; use std::path::{Path, PathBuf}; use glob::glob; use proc_macro2::TokenStream; +use quote::quote; use sel4_build_env::{find_in_libsel4_include_dirs, get_libsel4_include_dirs}; @@ -76,7 +78,7 @@ fn main() { #[allow(clippy::assertions_on_constants)] fn check_configuration() { - assert!(!sel4_config::sel4_cfg_bool!(ARCH_IA32)); + assert!(!sel4_config_data::config_as_bool("ARCH_IA32")); } struct OutDir { @@ -91,8 +93,10 @@ impl OutDir { } fn write_file(&self, toks: TokenStream, filename: impl AsRef) { - let formatted = prettyplease::unparse(&syn::parse2(toks).unwrap()); + let syntax_tree: syn::File = syn::parse2(toks).unwrap(); + let formatted = quote!(#syntax_tree).to_string(); let out_path = self.path.join(filename); - fs::write(out_path, formatted).unwrap(); + let mut out_file = BufWriter::new(fs::File::create(out_path).unwrap()); + write!(out_file, "{}", formatted).unwrap(); } } diff --git a/crates/sel4/sys/build/xml/invocations/mod.rs b/crates/sel4/sys/build/xml/invocations/mod.rs index 13d4640b3..7864b26e8 100644 --- a/crates/sel4/sys/build/xml/invocations/mod.rs +++ b/crates/sel4/sys/build/xml/invocations/mod.rs @@ -14,21 +14,17 @@ use std::path::Path; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; - -use sel4_config::sel4_cfg_bool; +use sel4_config_data::{config_as_bool, config_as_string}; use super::{Condition, parse_xml}; mod parse; use parse::*; -const WORD_SIZE: usize = sel4_config::sel4_cfg_usize!(WORD_SIZE); - -#[sel4_config::sel4_cfg(WORD_SIZE = "32")] -type Word = u32; - -#[sel4_config::sel4_cfg(WORD_SIZE = "64")] -type Word = u64; +fn get_word_size() -> usize { + let word_size_str = config_as_string("WORD_SIZE"); + if word_size_str == "64" { 64 } else if word_size_str == "32" { 32 } else { panic!("unsupported word size") } +} pub fn generate_rust( blocklist_for_bindgen: &mut Vec, @@ -158,8 +154,10 @@ impl<'a> InvocationGenerator<'a> { } let (marshalling_toks, num_msg_regs, num_caps) = self.generate_marshalling(in_params); - let num_msg_regs = Word::try_from(num_msg_regs).unwrap(); - let num_caps = Word::try_from(num_caps).unwrap(); + let num_msg_regs = u64::try_from(num_msg_regs).unwrap(); + assert!(u128::from(num_msg_regs) < (1u128 << get_word_size())); + let num_caps = u64::try_from(num_caps).unwrap(); + assert!(u128::from(num_caps) < (1u128 << get_word_size())); let invocation_label_path = { let ident = format_ident!("{}", invocation_id); @@ -269,8 +267,8 @@ impl<'a> InvocationGenerator<'a> { let name = format_ident!("{}", param.name); for (i, member) in members.iter().enumerate() { let member = format_ident!("{}", member); - let member_start = start + i * WORD_SIZE; - let member_end = member_start + WORD_SIZE; + let member_start = start + i * get_word_size(); + let member_end = member_start + get_word_size(); toks.extend(quote! { self.set_mr_bits(#member_start..#member_end, #name.#member); }) @@ -314,8 +312,8 @@ impl<'a> InvocationGenerator<'a> { let name = raw_ident(¶m.name); for (i, member) in members.iter().enumerate() { let member = raw_ident(member); - let member_start = start + i * WORD_SIZE; - let member_end = member_start + WORD_SIZE; + let member_start = start + i * get_word_size(); + let member_end = member_start + get_word_size(); toks.extend(quote! { #name.#member = self.get_mr_bits(#member_start..#member_end); }) @@ -400,7 +398,7 @@ impl<'a> LayoutHelper<'a> { fn lay_down_data(&mut self, parameter_type_name: &str) -> Range { let width = self.parameter_types.get(parameter_type_name).width(); - let start = self.data_cursor.next_multiple_of(width.min(WORD_SIZE)); + let start = self.data_cursor.next_multiple_of(width.min(get_word_size())); let end = start + width; self.data_cursor = end; start..end @@ -413,7 +411,7 @@ impl<'a> LayoutHelper<'a> { } fn num_msg_regs(&self) -> usize { - self.data_cursor.div_ceil(WORD_SIZE) + self.data_cursor.div_ceil(get_word_size()) } fn num_caps(&self) -> usize { @@ -438,9 +436,9 @@ impl ParameterType { fn width(&self) -> usize { match self { Self::Primitive { width, .. } => *width, - Self::Capability => WORD_SIZE, - Self::Bitfield => WORD_SIZE, - Self::Struct { members } => WORD_SIZE * members.len(), + Self::Capability => get_word_size(), + Self::Bitfield => get_word_size(), + Self::Struct { members } => get_word_size() * members.len(), } } @@ -504,7 +502,7 @@ impl ParameterTypes { this.insert_primitive("seL4_Uint32", 32); this.insert_primitive("seL4_Uint64", 64); this.insert_primitive("seL4_Time", 64); - this.insert_primitive("seL4_Word", WORD_SIZE); + this.insert_primitive("seL4_Word", get_word_size()); this.insert_primitive("seL4_Bool", 1); this.insert_bitfield("seL4_CapRights_t"); @@ -519,13 +517,13 @@ impl ParameterTypes { this.insert_capability("seL4_SchedContext"); this.insert_capability("seL4_SchedControl"); - if sel4_cfg_bool!(ARCH_ARM) { - this.insert_enum("seL4_ARM_VMAttributes", WORD_SIZE); - this.insert_enum("seL4_VCPUReg", WORD_SIZE); + if config_as_bool("ARCH_ARM") { + this.insert_enum("seL4_ARM_VMAttributes", get_word_size()); + this.insert_enum("seL4_VCPUReg", get_word_size()); this.insert_capability("seL4_ARM_Page"); this.insert_capability("seL4_ARM_PageTable"); this.insert_capability("seL4_ARM_PageDirectory"); - if sel4_cfg_bool!(ARCH_AARCH64) { + if config_as_bool("ARCH_AARCH64") { this.insert_capability("seL4_ARM_PageUpperDirectory"); this.insert_capability("seL4_ARM_PageGlobalDirectory"); this.insert_capability("seL4_ARM_VSpace"); @@ -537,17 +535,17 @@ impl ParameterTypes { this.insert_capability("seL4_ARM_IOPageTable"); } - if sel4_cfg_bool!(ARCH_RISCV) { - this.insert_enum("seL4_RISCV_VMAttributes", WORD_SIZE); + if config_as_bool("ARCH_RISCV") { + this.insert_enum("seL4_RISCV_VMAttributes", get_word_size()); this.insert_capability("seL4_RISCV_Page"); this.insert_capability("seL4_RISCV_PageTable"); this.insert_capability("seL4_RISCV_ASIDControl"); this.insert_capability("seL4_RISCV_ASIDPool"); } - if sel4_cfg_bool!(ARCH_X86_64) { - this.insert_enum("seL4_X86_VMAttributes", WORD_SIZE); - this.insert_enum("seL4_X86_EPT_VMAttributes", WORD_SIZE); + if config_as_bool("ARCH_X86_64") { + this.insert_enum("seL4_X86_VMAttributes", get_word_size()); + this.insert_enum("seL4_X86_EPT_VMAttributes", get_word_size()); this.insert_capability("seL4_X86_IOPort"); this.insert_capability("seL4_X86_IOPortControl"); this.insert_capability("seL4_X86_ASIDControl"); diff --git a/crates/sel4/sys/build/xml/syscalls/mod.rs b/crates/sel4/sys/build/xml/syscalls/mod.rs index 816de904f..f546a5356 100644 --- a/crates/sel4/sys/build/xml/syscalls/mod.rs +++ b/crates/sel4/sys/build/xml/syscalls/mod.rs @@ -20,7 +20,7 @@ pub fn generate_rust(syscalls_xml_path: impl AsRef) -> TokenStream { let ty = quote!(i32); let mut i = -1i32; let mut toks = quote!(); - let syscalls_for_api = if sel4_config::sel4_cfg_bool!(KERNEL_MCS) { + let syscalls_for_api = if sel4_config_data::config_as_bool("KERNEL_MCS") { &syscalls.api_mcs } else { &syscalls.api_master