aboutsummaryrefslogtreecommitdiff
path: root/src/dtables.rs
diff options
context:
space:
mode:
authorGravatar Gerd Zellweger <mail@gerdzellweger.com> 2015-11-29 12:17:36 +0100
committerGravatar Gerd Zellweger <mail@gerdzellweger.com> 2015-11-29 12:17:36 +0100
commit8ea2eb2dc442e9d0e89e08d40283b1aaba1cc87a (patch)
treeeaa63e77f9386864c26fb87a9f50f4628611abc8 /src/dtables.rs
parentbec7731473a0fae1d837a8a0fdfc902504ea9fcd (diff)
downloadrust-x86-8ea2eb2dc442e9d0e89e08d40283b1aaba1cc87a.tar.gz
rust-x86-8ea2eb2dc442e9d0e89e08d40283b1aaba1cc87a.tar.zst
rust-x86-8ea2eb2dc442e9d0e89e08d40283b1aaba1cc87a.zip
Fixing volatile and memory attributes for assembly.
For volatile: You can prevent an asm instruction from being deleted by writing the keyword volatile after the asm. [...] The volatile keyword indicates that the instruction has important side-effects. GCC will not delete a volatile asm if it is reachable. and An asm instruction without any output operands will be treated identically to a volatile asm instruction. And for memory: This will cause GCC to not keep memory values cached in registers across the assembler instruction and not optimize stores or loads to that memory. See also: https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Extended-Asm.html http://stackoverflow.com/questions/14449141/the-difference-between-asm-asm-volatile-and-clobbering-memory
Diffstat (limited to 'src/dtables.rs')
-rw-r--r--src/dtables.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/dtables.rs b/src/dtables.rs
index a47d344..1aff96b 100644
--- a/src/dtables.rs
+++ b/src/dtables.rs
@@ -1,4 +1,4 @@
-/// Functions and data-structures to load descriptor tables.
+//! Functions and data-structures to load descriptor tables.
/// A struct describing a pointer to a descriptor table (GDT / IDT).
/// This is in a format suitable for giving to 'lgdt' or 'lidt'.
@@ -13,15 +13,15 @@ pub struct DescriptorTablePointer {
/// Load GDT table.
pub unsafe fn lgdt(gdt: &DescriptorTablePointer) {
- asm!("lgdt ($0)" :: "r" (gdt));
+ asm!("lgdt ($0)" :: "r" (gdt) : "memory");
}
/// Load LDT table.
pub unsafe fn lldt(ldt: &DescriptorTablePointer) {
- asm!("lldt ($0)" :: "r" (ldt));
+ asm!("lldt ($0)" :: "r" (ldt) : "memory");
}
/// Load IDT table.
pub unsafe fn lidt(idt: &DescriptorTablePointer) {
- asm!("lidt ($0)" :: "r" (idt));
+ asm!("lidt ($0)" :: "r" (idt) : "memory");
} \ No newline at end of file