From 9342ce3c324d58ec2fec8637fb836b86dfadbc7e Mon Sep 17 00:00:00 2001 From: GZTimeWalker Date: Tue, 29 Mar 2022 19:44:45 +0800 Subject: [PATCH] v0.3.0: basic display & console & interrupt --- pkg/kernel/.cargo/config | 3 +++ pkg/kernel/src/main.rs | 5 +++++ pkg/kernel/src/utils/math.rs | 9 ++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/kernel/.cargo/config b/pkg/kernel/.cargo/config index f6f0df3..9b51a69 100644 --- a/pkg/kernel/.cargo/config +++ b/pkg/kernel/.cargo/config @@ -4,3 +4,6 @@ target = "config/x86_64-unknown-none.json" [unstable] build-std-features = ["compiler-builtins-mem"] build-std = ["core", "compiler_builtins"] + +[env] +LOG = "trace" diff --git a/pkg/kernel/src/main.rs b/pkg/kernel/src/main.rs index 2f7503f..01f7c28 100644 --- a/pkg/kernel/src/main.rs +++ b/pkg/kernel/src/main.rs @@ -48,5 +48,10 @@ pub fn kernal_main(boot_info: &'static BootInfo) -> ! { x86_64::instructions::interrupts::enable(); info!("Interrupts Enabled."); + trace!("Trace?"); + debug!("Debug Test."); + warn!("Warning Test."); + error!("ERROR!!!"); + loop {} } diff --git a/pkg/kernel/src/utils/math.rs b/pkg/kernel/src/utils/math.rs index e6d0a1d..b34a94c 100644 --- a/pkg/kernel/src/utils/math.rs +++ b/pkg/kernel/src/utils/math.rs @@ -1,17 +1,20 @@ extern crate libm; -macro_rules! no_mangle { +/// export functions in libm for float calculate +/// +/// ref: https://github.com/rust-lang/compiler-builtins/blob/master/src/math.rs +macro_rules! libm_export { ($(fn $fun:ident($($iid:ident : $ity:ty),+) -> $oty:ty;)+) => { $( #[no_mangle] pub extern "C" fn $fun($($iid: $ity),+) -> $oty { - self::libm::$fun($($iid),+) + libm::$fun($($iid),+) } )+ } } -no_mangle! { +libm_export! { fn acos(x: f64) -> f64; fn asin(x: f64) -> f64; fn cbrt(x: f64) -> f64;