Add a Gdt::load method

master
Philipp Oppermann 8 years ago
parent 238cc575c3
commit 58e90d497e

@ -27,6 +27,18 @@ impl Gdt {
SegmentSelector::new(index as u16, PrivilegeLevel::Ring0)
}
pub fn load(&'static self) {
use x86_64::instructions::tables::{DescriptorTablePointer, lgdt};
use core::mem::size_of;
let ptr = DescriptorTablePointer {
base: self.table.as_ptr() as u64,
limit: (self.table.len() * size_of::<u64>() - 1) as u16,
};
unsafe { lgdt(&ptr) };
}
fn push(&mut self, value: u64) -> usize {
if self.next_free < self.table.len() {
let index = self.next_free;

Loading…
Cancel
Save