From 5eace9997aa6e926ebd8e0f3ed268331e7aca176 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sat, 16 Sep 2023 10:48:25 +0200 Subject: [PATCH] Compile successfully on i686 as well. --- build.rs | 13 ++++++++----- src/arch/x86/mod.rs | 6 ++++++ src/context/arch/x86.rs | 1 - 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build.rs b/build.rs index 9745faa588..65c227e384 100644 --- a/build.rs +++ b/build.rs @@ -4,7 +4,7 @@ use std::env; use std::path::Path; use std::process::Command; -fn parse_kconfig(arch: &str) { +fn parse_kconfig(arch: &str) -> Option<()> { println!("cargo:rerun-if-changed=config.toml"); assert!(Path::new("config.toml.example").try_exists().unwrap()); @@ -13,9 +13,10 @@ fn parse_kconfig(arch: &str) { } let config_str = std::fs::read_to_string("config.toml").unwrap(); let root: Table = toml::from_str(&config_str).unwrap(); - let altfeatures = root.get("arch").unwrap().as_table().unwrap() - .get(arch).unwrap().as_table().unwrap() - .get("features").unwrap().as_table().unwrap(); + + let altfeatures = root.get("arch")?.as_table().unwrap() + .get(arch)?.as_table().unwrap() + .get("features")?.as_table().unwrap(); for (name, value) in altfeatures { let choice = value.as_str().unwrap(); @@ -23,6 +24,8 @@ fn parse_kconfig(arch: &str) { println!("cargo:rustc-cfg=cpu_feature_{choice}=\"{name}\""); } + + Some(()) } fn main() { @@ -72,5 +75,5 @@ fn main() { _ => (), } - parse_kconfig(arch_str); + let _ = parse_kconfig(arch_str); } diff --git a/src/arch/x86/mod.rs b/src/arch/x86/mod.rs index 471e9d7a99..c2c38730a6 100644 --- a/src/arch/x86/mod.rs +++ b/src/arch/x86/mod.rs @@ -86,3 +86,9 @@ pub unsafe extern "fastcall" fn arch_copy_to_user_inner(len: usize, dst: usize, pub unsafe fn bootstrap_mem(bootstrap: &Bootstrap) -> &'static [u8] { core::slice::from_raw_parts(CurrentRmmArch::phys_to_virt(bootstrap.base.start_address()).data() as *const u8, bootstrap.page_count * PAGE_SIZE) } +pub const KFX_SIZE: usize = 512; + +// This function exists as the KFX size is dynamic on x86_64. +pub fn kfx_size() -> usize { + KFX_SIZE +} diff --git a/src/context/arch/x86.rs b/src/context/arch/x86.rs index 7789c36100..b8593d3b6f 100644 --- a/src/context/arch/x86.rs +++ b/src/context/arch/x86.rs @@ -20,7 +20,6 @@ pub static CONTEXT_SWITCH_LOCK: AtomicBool = AtomicBool::new(false); const ST_RESERVED: u128 = 0xFFFF_FFFF_FFFF_0000_0000_0000_0000_0000; -pub const KFX_SIZE: usize = 512; pub const KFX_ALIGN: usize = 16; #[derive(Clone, Debug)]