aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dtables.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/dtables.rs b/src/dtables.rs
index bdc3d9c..2798fa4 100644
--- a/src/dtables.rs
+++ b/src/dtables.rs
@@ -12,6 +12,15 @@ pub struct DescriptorTablePointer<Entry> {
pub base: *const Entry,
}
+impl<T> Default for DescriptorTablePointer<T> {
+ fn default() -> DescriptorTablePointer<T> {
+ DescriptorTablePointer {
+ limit: 0,
+ base: core::ptr::null(),
+ }
+ }
+}
+
impl<T> DescriptorTablePointer<T> {
pub fn new(tbl: &T) -> Self {
// GDT, LDT, and IDT all expect the limit to be set to "one less".
@@ -58,3 +67,8 @@ pub unsafe fn lldt<T>(ldt: &DescriptorTablePointer<T>) {
pub unsafe fn lidt<T>(idt: &DescriptorTablePointer<T>) {
asm!("lidt ($0)" :: "r" (idt) : "memory");
}
+
+/// Retrive IDT table with 32bit descriptors.
+pub unsafe fn sidt<T>(mut idt: &mut DescriptorTablePointer<T>) {
+ asm!("sidt ($0)" : "=r" (idt) :: "memory");
+}