Skip to content

Commit

Permalink
Fix asm and global_asm macros (#10)
Browse files Browse the repository at this point in the history
The macros are now namespaced:
rust-lang/rust#84019

In addition, llvm_asm was removed.
  • Loading branch information
simonschoening authored Feb 25, 2022
1 parent 25cb528 commit 61599d3
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/riscv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extern crate opensbi_rt;
use riscv::register::scause::{Exception as E, Scause, Trap};
use riscv::register::{scause, stval};
use trapframe::{GeneralRegs, TrapFrame, UserContext};
use core::arch::asm;

#[no_mangle]
extern "C" fn main() {
Expand Down
1 change: 1 addition & 0 deletions examples/uefi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use trapframe::{GeneralRegs, TrapFrame, UserContext};
use uefi::prelude::*;
use x86_64::registers::control::*;
use x86_64::structures::paging::{PageTable, PageTableFlags};
use core::arch::asm;

#[entry]
fn efi_main(_image: Handle, st: SystemTable<Boot>) -> uefi::Status {
Expand Down
2 changes: 2 additions & 0 deletions src/arch/aarch64/fncall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//! Because we will store values in their pthread structure.
use super::UserContext;
use core::arch::global_asm;

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

Expand Down Expand Up @@ -41,6 +42,7 @@ impl UserContext {
#[cfg(test)]
mod tests {
use crate::*;
use core::arch::global_asm;

// Mock user program to dump registers at stack.
global_asm!(
Expand Down
1 change: 1 addition & 0 deletions src/arch/aarch64/trap.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use core::arch::{asm, global_asm};

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

Expand Down
7 changes: 6 additions & 1 deletion src/arch/mipsel/trap.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::arch::{asm, global_asm};

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

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

#[no_mangle]
Expand Down
2 changes: 2 additions & 0 deletions src/arch/riscv/trap.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::arch::{asm, global_asm};

#[cfg(target_arch = "riscv32")]
global_asm!(
r"
Expand Down
2 changes: 2 additions & 0 deletions src/arch/x86_64/fncall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//! Because we will store values in their pthread structure.
use super::UserContext;
use core::arch::global_asm;

extern "sysv64" {
/// The syscall entry of function call.
Expand Down Expand Up @@ -230,6 +231,7 @@ syscall_fn_return:
#[cfg(test)]
mod tests {
use crate::*;
use core::arch::global_asm;

#[cfg(target_os = "macos")]
global_asm!(".set _dump_registers, dump_registers");
Expand Down
1 change: 1 addition & 0 deletions src/arch/x86_64/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::arch::asm;
use core::mem::size_of;

use x86_64::instructions::tables::{lgdt, load_tss};
Expand Down
1 change: 1 addition & 0 deletions src/arch/x86_64/idt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloc::boxed::Box;
use core::arch::asm;
use x86_64::structures::idt::*;
use x86_64::structures::DescriptorTablePointer;
use x86_64::{PrivilegeLevel, VirtAddr};
Expand Down
1 change: 1 addition & 0 deletions src/arch/x86_64/syscall.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::UserContext;
use core::arch::global_asm;
use x86_64::registers::model_specific::{Efer, EferFlags, LStar, SFMask};
use x86_64::registers::rflags::RFlags;
use x86_64::VirtAddr;
Expand Down
2 changes: 2 additions & 0 deletions src/arch/x86_64/trap.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::arch::global_asm;

global_asm!(include_str!("trap.S"));
global_asm!(include_str!(concat!(env!("OUT_DIR"), "/vector.S")));

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![no_std]
#![feature(llvm_asm, asm, global_asm, linkage)]
#![feature(linkage)]
#![deny(warnings)]
#![cfg_attr(target_arch = "mips", feature(asm_experimental_arch))]

extern crate alloc;

Expand Down

0 comments on commit 61599d3

Please sign in to comment.