From 7fa6a4524790f26c14018420f2e1505b861379a8 Mon Sep 17 00:00:00 2001 From: Erin Date: Wed, 2 Feb 2022 00:06:00 +0100 Subject: [PATCH 1/2] cpuid fixed --- ableos/src/experiments/info.rs | 32 ++++++++++++++++---------------- ableos/src/lib.rs | 9 +++------ 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/ableos/src/experiments/info.rs b/ableos/src/experiments/info.rs index fc6aec08..901a3d4f 100644 --- a/ableos/src/experiments/info.rs +++ b/ableos/src/experiments/info.rs @@ -18,6 +18,7 @@ //! } //! ``` +use core::arch::asm; use core::ops::Deref; use core::{fmt, slice, str}; @@ -39,28 +40,27 @@ pub enum RequestType { } pub fn cpuid(code: RequestType) -> (u32, u32, u32, u32) { - let res1; - let res2; - let res3; - let res4; + let eax; + let ebx; + let ecx; + let edx; unsafe { - llvm_asm!("cpuid" - : // output operands - "={eax}"(res1), - "={ebx}"(res2), - "={ecx}"(res3), - "={edx}"(res4) - : // input operands - "{eax}"(code as u32), - "{ecx}"(0 as u32) - : // clobbers - : // options + asm!( + "movq %rbx, {0:r}", + "cpuid", + "xchgq %rbx, {0:r}", + lateout(reg) ebx, + inlateout("eax") code as u32 => eax, + inlateout("ecx") 0 => ecx, + lateout("edx") edx, + options(nostack, preserves_flags, att_syntax), ); } - (res1, res2, res3, res4) + (eax, ebx, ecx, edx) } + /// The main entrypoint to the CPU information #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] pub fn master() -> Option { diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index b3d9c2ca..d241fa5f 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -6,17 +6,14 @@ #![no_std] #![feature( abi_x86_interrupt, - // asm, asm_sym, alloc_error_handler, core_intrinsics, - // global_asm, + exclusive_range_pattern, lang_items, - llvm_asm, - naked_functions + naked_functions, + slice_pattern, )] -#![feature(exclusive_range_pattern)] -#![feature(slice_pattern)] /// Contains architecture specific code for aarch64. #[cfg(target_arch = "aarch64")] From a60349c2f9a167978dc3362eade6253340030d16 Mon Sep 17 00:00:00 2001 From: Erin Date: Wed, 2 Feb 2022 00:12:29 +0100 Subject: [PATCH 2/2] updated cpuio dependency --- ableos/Cargo.lock | 4 ++-- ableos/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ableos/Cargo.lock b/ableos/Cargo.lock index 8f29203c..cb5e881e 100644 --- a/ableos/Cargo.lock +++ b/ableos/Cargo.lock @@ -150,8 +150,8 @@ dependencies = [ [[package]] name = "cpuio" -version = "0.3.0" -source = "git+https://github.com/anyusernameworks/cpuio.git#3908ecab79df80670ee1c5121870fc131f07627b" +version = "0.3.2" +source = "git+https://git.ablecorp.us/ondra05/cpuio.git#093cc103101b4ba4abd02d77c884113a376cdc64" [[package]] name = "crunchy" diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index e12a9ab1..c8258a93 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -100,7 +100,7 @@ git = "https://git.ablecorp.us:443/able/externc-libm.git" [target.'cfg(target_arch = "x86_64")'.dependencies] bootloader = { version = "0.9.8", features = ["map_physical_memory"] } -cpuio = { git = "https://github.com/anyusernameworks/cpuio.git" } +cpuio = { git = "https://git.ablecorp.us/ondra05/cpuio.git" } pic8259 = "0.10.1" uart_16550 = "0.2.0" volatile = "0.2.6"