mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Add a Gdt::load method
This commit is contained in:
@@ -27,6 +27,18 @@ impl Gdt {
|
|||||||
SegmentSelector::new(index as u16, PrivilegeLevel::Ring0)
|
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 {
|
fn push(&mut self, value: u64) -> usize {
|
||||||
if self.next_free < self.table.len() {
|
if self.next_free < self.table.len() {
|
||||||
let index = self.next_free;
|
let index = self.next_free;
|
||||||
|
|||||||
Reference in New Issue
Block a user