diff options
Diffstat (limited to 'src/bits64')
-rw-r--r-- | src/bits64/dtables.rs | 8 | ||||
-rw-r--r-- | src/bits64/rflags.rs | 2 | ||||
-rw-r--r-- | src/bits64/segmentation.rs | 13 |
3 files changed, 11 insertions, 12 deletions
diff --git a/src/bits64/dtables.rs b/src/bits64/dtables.rs index 2bc06c8..00fad0f 100644 --- a/src/bits64/dtables.rs +++ b/src/bits64/dtables.rs @@ -1,18 +1,18 @@ //! Functions to load descriptor tables. use dtables::DescriptorTablePointer; -use bits64::segmentation::Descriptor64; +use bits64::segmentation::Descriptor; /// Load GDT table with 64-bits descriptors. -pub unsafe fn lgdt(gdt: &DescriptorTablePointer<Descriptor64>) { +pub unsafe fn lgdt(gdt: &DescriptorTablePointer<Descriptor>) { asm!("lgdt ($0)" :: "r" (gdt) : "memory"); } /// Load LDT table with 64-bits descriptors. -pub unsafe fn lldt(ldt: &DescriptorTablePointer<Descriptor64>) { +pub unsafe fn lldt(ldt: &DescriptorTablePointer<Descriptor>) { asm!("lldt ($0)" :: "r" (ldt) : "memory"); } /// Load IDT table with 64-bits descriptors. -pub unsafe fn lidt(idt: &DescriptorTablePointer<Descriptor64>) { +pub unsafe fn lidt(idt: &DescriptorTablePointer<Descriptor>) { asm!("lidt ($0)" :: "r" (idt) : "memory"); } diff --git a/src/bits64/rflags.rs b/src/bits64/rflags.rs index 6301420..e6dae17 100644 --- a/src/bits64/rflags.rs +++ b/src/bits64/rflags.rs @@ -68,7 +68,7 @@ impl RFlags { } #[cfg(target_arch="x86-64")] -pub unsafe fn flags() -> RFlags { +pub unsafe fn read() -> RFlags { let r: u64; asm!("pushfq; popq $0" : "=r"(r) :: "memory"); RFlags::from_bits_truncate(r) diff --git a/src/bits64/segmentation.rs b/src/bits64/segmentation.rs index 8bcd8cf..058bead 100644 --- a/src/bits64/segmentation.rs +++ b/src/bits64/segmentation.rs @@ -1,7 +1,7 @@ #[allow(unused_imports)] use segmentation::{SegmentSelector}; use segmentation::{DescriptorBuilder, BuildDescriptor, DescriptorType, GateDescriptorBuilder, SegmentDescriptorBuilder, LdtDescriptorBuilder, CodeSegmentType, DataSegmentType, SystemDescriptorTypes64}; -use bits32::segmentation::{Descriptor32}; +use bits32::segmentation::Descriptor as Descriptor32; /// Entry for IDT, GDT or LDT. /// @@ -9,13 +9,13 @@ use bits32::segmentation::{Descriptor32}; /// "Segment Descriptor Tables in IA-32e Mode", especially Figure 3-8. #[derive(Copy, Clone, Debug, Default)] #[repr(C, packed)] -pub struct Descriptor64 { +pub struct Descriptor { desc32: Descriptor32, lower: u32, upper: u32 } -impl Descriptor64 { +impl Descriptor { pub(crate) fn apply_builder_settings(&mut self, builder: &DescriptorBuilder) { self.desc32.apply_builder_settings(builder); @@ -87,9 +87,9 @@ impl LdtDescriptorBuilder<u64> for DescriptorBuilder { } } -impl BuildDescriptor<Descriptor64> for DescriptorBuilder { - fn finish(&self) -> Descriptor64 { - let mut desc: Descriptor64 = Default::default(); +impl BuildDescriptor<Descriptor> for DescriptorBuilder { + fn finish(&self) -> Descriptor { + let mut desc: Descriptor = Default::default(); desc.apply_builder_settings(self); desc.desc32.set_l(); // 64-bit descriptor @@ -97,7 +97,6 @@ impl BuildDescriptor<Descriptor64> for DescriptorBuilder { Some(DescriptorType::System64(typ)) => { if typ == SystemDescriptorTypes64::LDT || typ == SystemDescriptorTypes64::TssAvailable || typ == SystemDescriptorTypes64::TssBusy { assert!(!self.db); - assert!(!self.db); } typ as u8 }, |