From 8a6ac20ca76b22693622a4f34cf7b2e3dc5b5fb2 Mon Sep 17 00:00:00 2001 From: Stefan Lankes <slankes@eonerc.rwth-aachen.de> Date: Thu, 16 Jul 2020 13:25:56 +0200 Subject: [PATCH] use llvm_asm instead of asm to support the latest nightly compiler --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- src/arch/x86_64/irq.rs | 6 +++--- src/arch/x86_64/processor.rs | 8 ++++---- src/arch/x86_64/start.rs | 2 +- src/arch/x86_64/switch.rs | 2 +- src/lib.rs | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65050c3..609c0ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,12 +20,12 @@ name = "eduos-rs" version = "0.1.0" dependencies = [ "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "x86 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x86 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "raw-cpuid" -version = "7.0.3" +version = "8.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -61,21 +61,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "x86" -version = "0.28.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 8.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] "checksum bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" -"checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" +"checksum raw-cpuid 8.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cee2c7710d96f9f90f56824fca5438b301dc0fb49ece4cf9dfa044e54067e10" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -"checksum x86 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f705f7554f555fa2d0fea9e3b53f5fd8b4b67270f48aac96a4146a19b5bf7db1" +"checksum x86 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c146cbc47471e076987378c159a7aa8fa434680c6fbddca59fe6f40f1591c819" diff --git a/Cargo.toml b/Cargo.toml index 84206fd..faf3163 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Stefan Lankes <slankes@eonerc.rwth-aachen.de>"] spin = "0.5.2" # Spinlocks. [target.'cfg(target_arch = "x86_64")'.dependencies.x86] -version = "0.28.*" +version = "0.34.*" default-features = false # The development profile, used for `cargo build`. diff --git a/src/arch/x86_64/irq.rs b/src/arch/x86_64/irq.rs index 27726b0..1a02800 100644 --- a/src/arch/x86_64/irq.rs +++ b/src/arch/x86_64/irq.rs @@ -7,19 +7,19 @@ /// Enable Interrupts pub fn irq_enable() { - unsafe { asm!("sti" ::: "memory" : "volatile") }; + unsafe { llvm_asm!("sti" ::: "memory" : "volatile") }; } /// Disable Interrupts pub fn irq_disable() { - unsafe { asm!("cli" ::: "memory" : "volatile") }; + unsafe { llvm_asm!("cli" ::: "memory" : "volatile") }; } /// Determines, if the interrupt flags (IF) is set pub fn is_irq_enabled() -> bool { let rflags: u64; - unsafe { asm!("pushf; pop $0": "=r"(rflags) :: "memory" : "volatile") }; + unsafe { llvm_asm!("pushf; pop $0": "=r"(rflags) :: "memory" : "volatile") }; if (rflags & (1u64 << 9)) != 0 { return true; } diff --git a/src/arch/x86_64/processor.rs b/src/arch/x86_64/processor.rs index f43797d..deb5a4e 100644 --- a/src/arch/x86_64/processor.rs +++ b/src/arch/x86_64/processor.rs @@ -9,7 +9,7 @@ pub fn msb(value: u64) -> Option<u64> { if value > 0 { let ret: u64; unsafe { - asm!("bsr $1, $0" : "=r"(ret) : "r"(value) : "cc" : "volatile"); + llvm_asm!("bsr $1, $0" : "=r"(ret) : "r"(value) : "cc" : "volatile"); } Some(ret) } else { @@ -23,7 +23,7 @@ pub fn lsb(value: u64) -> Option<u64> { if value > 0 { let ret: u64; unsafe { - asm!("bsf $1, $0" : "=r"(ret) : "r"(value) : "cc" : "volatile"); + llvm_asm!("bsf $1, $0" : "=r"(ret) : "r"(value) : "cc" : "volatile"); } Some(ret) } else { @@ -33,13 +33,13 @@ pub fn lsb(value: u64) -> Option<u64> { pub fn halt() { unsafe { - asm!("hlt" :::: "volatile"); + llvm_asm!("hlt" :::: "volatile"); } } pub fn pause() { unsafe { - asm!("pause" :::: "volatile"); + llvm_asm!("pause" :::: "volatile"); } } diff --git a/src/arch/x86_64/start.rs b/src/arch/x86_64/start.rs index 44512a3..c4a517c 100755 --- a/src/arch/x86_64/start.rs +++ b/src/arch/x86_64/start.rs @@ -18,7 +18,7 @@ extern "C" { #[naked] pub unsafe extern "C" fn _start() { // be sure that rsp is a valid stack pointer - asm!("mov $0, %rsp" :: "r"(BOOT_STACK.top()) :: "volatile"); + llvm_asm!("mov $0, %rsp" :: "r"(BOOT_STACK.top()) :: "volatile"); main(); diff --git a/src/arch/x86_64/switch.rs b/src/arch/x86_64/switch.rs index 6308128..56fd513 100755 --- a/src/arch/x86_64/switch.rs +++ b/src/arch/x86_64/switch.rs @@ -12,7 +12,7 @@ pub extern "C" fn switch(_old_stack: *mut usize, _new_stack: usize) { // rsi = new_stack => stack pointer of the new task unsafe { - asm!( + llvm_asm!( // store context "pushfq\n\t\ push %rax\n\t\ diff --git a/src/lib.rs b/src/lib.rs index 0086a52..f8dbd71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(asm, const_fn, lang_items)] +#![feature(llvm_asm, const_fn, lang_items)] #![feature(allocator_api)] #![feature(naked_functions)] #![no_std] -- GitLab