diff options
author | 2019-05-08 23:19:14 -0700 | |
---|---|---|
committer | 2019-05-08 23:19:14 -0700 | |
commit | 4ecf24d2f349b8c0a969f1d313cc5645ba00be7d (patch) | |
tree | 650de673125ac591a9fe7c4feaa9d2ab54eb6265 /src | |
parent | d33a20587a1406ece7f71c2cd6e767c4ad2ae39b (diff) | |
download | rust-x86-4ecf24d2f349b8c0a969f1d313cc5645ba00be7d.tar.gz rust-x86-4ecf24d2f349b8c0a969f1d313cc5645ba00be7d.tar.zst rust-x86-4ecf24d2f349b8c0a969f1d313cc5645ba00be7d.zip |
Add support for sidt instruction.
Retrieves pointer to currently stored IDT.
Diffstat (limited to 'src')
-rw-r--r-- | src/dtables.rs | 14 |
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"); +} |