Skip to content

Commit 61599d3

Browse files
Fix asm and global_asm macros (#10)
The macros are now namespaced: rust-lang/rust#84019 In addition, llvm_asm was removed.
1 parent 25cb528 commit 61599d3

File tree

12 files changed

+22
-2
lines changed

12 files changed

+22
-2
lines changed

examples/riscv/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extern crate opensbi_rt;
88
use riscv::register::scause::{Exception as E, Scause, Trap};
99
use riscv::register::{scause, stval};
1010
use trapframe::{GeneralRegs, TrapFrame, UserContext};
11+
use core::arch::asm;
1112

1213
#[no_mangle]
1314
extern "C" fn main() {

examples/uefi/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use trapframe::{GeneralRegs, TrapFrame, UserContext};
1414
use uefi::prelude::*;
1515
use x86_64::registers::control::*;
1616
use x86_64::structures::paging::{PageTable, PageTableFlags};
17+
use core::arch::asm;
1718

1819
#[entry]
1920
fn efi_main(_image: Handle, st: SystemTable<Boot>) -> uefi::Status {

src/arch/aarch64/fncall.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//! Because we will store values in their pthread structure.
99
1010
use super::UserContext;
11+
use core::arch::global_asm;
1112

1213
global_asm!(include_str!("fncall.S"));
1314

@@ -41,6 +42,7 @@ impl UserContext {
4142
#[cfg(test)]
4243
mod tests {
4344
use crate::*;
45+
use core::arch::global_asm;
4446

4547
// Mock user program to dump registers at stack.
4648
global_asm!(

src/arch/aarch64/trap.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::*;
2+
use core::arch::{asm, global_asm};
23

34
global_asm!(include_str!("trap.S"));
45

src/arch/mipsel/trap.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::arch::{asm, global_asm};
2+
13
global_asm!(include_str!("trap.S"));
24

35
/// Initialize interrupt handling for the current HART.
@@ -11,7 +13,10 @@ global_asm!(include_str!("trap.S"));
1113
/// You **MUST NOT** modify these registers later.
1214
pub unsafe fn init() {
1315
// Set cp0 ebase(15, 1) register to trap entry
14-
llvm_asm!("mtc0 $0, $$15, 1":: "r"(trap_entry as usize) :: "volatile");
16+
asm!(
17+
"mtc0 {trap_entry}, $15, 1",
18+
trap_entry = in(reg) trap_entry,
19+
);
1520
}
1621

1722
#[no_mangle]

src/arch/riscv/trap.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::arch::{asm, global_asm};
2+
13
#[cfg(target_arch = "riscv32")]
24
global_asm!(
35
r"

src/arch/x86_64/fncall.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//! Because we will store values in their pthread structure.
99
1010
use super::UserContext;
11+
use core::arch::global_asm;
1112

1213
extern "sysv64" {
1314
/// The syscall entry of function call.
@@ -230,6 +231,7 @@ syscall_fn_return:
230231
#[cfg(test)]
231232
mod tests {
232233
use crate::*;
234+
use core::arch::global_asm;
233235

234236
#[cfg(target_os = "macos")]
235237
global_asm!(".set _dump_registers, dump_registers");

src/arch/x86_64/gdt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use alloc::boxed::Box;
44
use alloc::vec::Vec;
5+
use core::arch::asm;
56
use core::mem::size_of;
67

78
use x86_64::instructions::tables::{lgdt, load_tss};

src/arch/x86_64/idt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use alloc::boxed::Box;
2+
use core::arch::asm;
23
use x86_64::structures::idt::*;
34
use x86_64::structures::DescriptorTablePointer;
45
use x86_64::{PrivilegeLevel, VirtAddr};

src/arch/x86_64/syscall.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::UserContext;
2+
use core::arch::global_asm;
23
use x86_64::registers::model_specific::{Efer, EferFlags, LStar, SFMask};
34
use x86_64::registers::rflags::RFlags;
45
use x86_64::VirtAddr;

src/arch/x86_64/trap.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::arch::global_asm;
2+
13
global_asm!(include_str!("trap.S"));
24
global_asm!(include_str!(concat!(env!("OUT_DIR"), "/vector.S")));
35

src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![no_std]
2-
#![feature(llvm_asm, asm, global_asm, linkage)]
2+
#![feature(linkage)]
33
#![deny(warnings)]
4+
#![cfg_attr(target_arch = "mips", feature(asm_experimental_arch))]
45

56
extern crate alloc;
67

0 commit comments

Comments
 (0)