Compare commits

..

No commits in common. "f362e0e6f4eff4ee10b67a09bc41b72f7f237ab5" and "739fa56ece9aeb0cef17af75d00a9e7b59cc83e8" have entirely different histories.

7 changed files with 3 additions and 51 deletions

View File

@ -4,8 +4,6 @@
use core::arch::x86_64::{__cpuid as do_cpuid, CpuidResult};
use core::arch::asm;
use super::gdt;
fn safe_cpuid(leaf: u32) -> CpuidResult {
return unsafe { do_cpuid(leaf) };
}
@ -24,18 +22,10 @@ pub fn halt() -> ! {
}
}
pub fn wait_for_interrupt()
{
pub fn wait_for_interrupt() -> () {
unsafe { asm!("hlt"); }
}
pub fn breakpoint()
{
pub fn breakpoint() -> () {
unsafe { asm!("int3"); }
}
pub fn platform_init()
{
gdt::init();
gdt::load_and_reload_segment_registers();
}

View File

@ -1,35 +0,0 @@
#![cfg(target_arch = "x86_64")]
#![allow(dead_code)]
use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable};
use x86_64::registers::segmentation::{CS, SS, Segment, SegmentSelector};
use x86_64::PrivilegeLevel;
use spin::Mutex;
static mut GDT: GlobalDescriptorTable = GlobalDescriptorTable::new();
static GDT_LOCK: Mutex<u64> = Mutex::new(0); // we cannot lock the GDT directly as it must stay in the same place in memory and that behaves weirdly with mutexes
fn add_entry(descriptor: Descriptor)
{
GDT_LOCK.lock();
unsafe { GDT.add_entry(descriptor); }
}
pub fn init()
{
add_entry(Descriptor::kernel_code_segment());
add_entry(Descriptor::kernel_data_segment());
add_entry(Descriptor::user_code_segment());
add_entry(Descriptor::user_data_segment());
// TODO: add a TSS.
}
pub fn load_and_reload_segment_registers()
{
GDT_LOCK.lock();
unsafe {
GDT.load();
CS::set_reg(SegmentSelector::new(1, PrivilegeLevel::Ring0));
SS::set_reg(SegmentSelector::new(2, PrivilegeLevel::Ring0));
}
}

View File

@ -1,5 +1,4 @@
#![cfg(target_arch = "x86_64")]
pub mod cpu;
pub mod io;
pub mod interrupts;
mod gdt;
pub mod interrupts;

View File

@ -25,8 +25,6 @@ pub extern "C" fn _start() -> ! {
init::halt_other_cores();
init::check_magic();
cpu::platform_init();
interrupts::load();
video::clear(Color::White);

0
tools/build-stable.sh Executable file → Normal file
View File

0
tools/install-stable.sh Executable file → Normal file
View File

0
tools/setup-bootloader.sh Executable file → Normal file
View File