-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
map asm! ops to unimplemented! on non ARM targets
- Loading branch information
Showing
12 changed files
with
183 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
//! Base Priority Mask Register | ||
/// Reads the CPU register | ||
#[inline(always)] | ||
#[inline] | ||
pub fn read() -> u8 { | ||
let r: u32; | ||
unsafe { | ||
asm!("mrs $0, BASEPRI" | ||
: "=r"(r) | ||
: | ||
: | ||
: "volatile"); | ||
match () { | ||
#[cfg(target_arch = "arm")] | ||
() => { | ||
let r: u32; | ||
unsafe { | ||
asm!("mrs $0, BASEPRI" : "=r"(r) ::: "volatile"); | ||
} | ||
r as u8 | ||
} | ||
#[cfg(not(target_arch = "arm"))] | ||
() => unimplemented!(), | ||
} | ||
r as u8 | ||
} | ||
|
||
/// Writes to the CPU register | ||
#[inline(always)] | ||
pub unsafe fn write(basepri: u8) { | ||
asm!("msr BASEPRI, $0" | ||
: | ||
: "r"(basepri) | ||
: "memory" | ||
: "volatile"); | ||
#[inline] | ||
pub unsafe fn write(_basepri: u8) { | ||
match () { | ||
#[cfg(target_arch = "arm")] | ||
() => asm!("msr BASEPRI, $0" :: "r"(_basepri) : "memory" : "volatile"), | ||
#[cfg(not(target_arch = "arm"))] | ||
() => unimplemented!(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
//! Link register | ||
/// Reads the CPU register | ||
#[inline(always)] | ||
#[inline] | ||
pub fn read() -> u32 { | ||
let r: u32; | ||
unsafe { | ||
asm!("mov $0,R14" | ||
: "=r"(r) | ||
: | ||
: | ||
: "volatile"); | ||
match () { | ||
#[cfg(target_arch = "arm")] | ||
() => { | ||
let r: u32; | ||
unsafe { asm!("mov $0,R14" : "=r"(r) ::: "volatile") } | ||
r | ||
} | ||
#[cfg(not(target_arch = "arm"))] | ||
() => unimplemented!(), | ||
} | ||
r | ||
} | ||
|
||
/// Writes `bits` to the CPU register | ||
#[inline(always)] | ||
#[cfg_attr(not(target_arch = "arm"), allow(unused_variables))] | ||
#[inline] | ||
pub unsafe fn write(bits: u32) { | ||
asm!("mov R14,$0" | ||
: | ||
: "r"(bits) | ||
: | ||
: "volatile"); | ||
match () { | ||
#[cfg(target_arch = "arm")] | ||
() => asm!("mov R14,$0" :: "r"(bits) :: "volatile"), | ||
#[cfg(not(target_arch = "arm"))] | ||
() => unimplemented!(), | ||
} | ||
} |
Oops, something went wrong.