forked from LowLevelDevs/FoundryOS
did interrupts stuff
This commit is contained in:
Generated
+10
@@ -11,6 +11,7 @@ dependencies = [
|
||||
"lib_framebuffer",
|
||||
"lib_serial",
|
||||
"limine",
|
||||
"pic8259",
|
||||
"spin",
|
||||
"x86_64",
|
||||
]
|
||||
@@ -104,6 +105,15 @@ dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pic8259"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62d9a86c292b165f757e47e7fd66855def189b2564609bc4203727b27c33db22"
|
||||
dependencies = [
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.19"
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ incremental = false
|
||||
codegen-units = 1
|
||||
|
||||
[profile.release]
|
||||
opt-level = "z"
|
||||
opt-level = 3
|
||||
debug = false
|
||||
debug-assertions = false
|
||||
overflow-checks = false
|
||||
|
||||
@@ -10,6 +10,7 @@ lib_serial = { path = "../lib/lib_serial" }
|
||||
lib_ascii = { path = "../lib/lib_ascii" }
|
||||
x86_64 = "0.15.2"
|
||||
spin = "0.9.8"
|
||||
pic8259 = "0.11.0"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.2.14"
|
||||
|
||||
@@ -1,18 +1,95 @@
|
||||
use lib_ascii::println_log;
|
||||
use lib_serial::serial_println;
|
||||
use x86_64::instructions::port::Port;
|
||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
|
||||
|
||||
use spin::Lazy;
|
||||
use pic8259::ChainedPics;
|
||||
use spin::{Lazy, Mutex};
|
||||
|
||||
static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
|
||||
let mut idt = InterruptDescriptorTable::new();
|
||||
idt.breakpoint.set_handler_fn(breakpoint_handler);
|
||||
idt.double_fault.set_handler_fn(double_fault_handler);
|
||||
idt.general_protection_fault
|
||||
.set_handler_fn(general_protection_fault_handler);
|
||||
|
||||
idt[InterruptIndex::Timer.as_u8()].set_handler_fn(timer_interrupt_handler);
|
||||
idt[InterruptIndex::Keyboard.as_u8()].set_handler_fn(keyboard_interrupt_handler);
|
||||
idt
|
||||
});
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
pub const PIC_1_OFFSET: u8 = 32;
|
||||
pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;
|
||||
|
||||
pub static PICS: Mutex<ChainedPics> =
|
||||
Mutex::new(unsafe { ChainedPics::new(PIC_1_OFFSET, PIC_2_OFFSET) });
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[repr(u8)]
|
||||
pub enum InterruptIndex {
|
||||
Timer = PIC_1_OFFSET,
|
||||
Keyboard,
|
||||
}
|
||||
|
||||
impl InterruptIndex {
|
||||
fn as_u8(self) -> u8 {
|
||||
self as u8
|
||||
}
|
||||
|
||||
fn _as_usize(self) -> usize {
|
||||
usize::from(self.as_u8())
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
pub fn init_idt() {
|
||||
IDT.load();
|
||||
unsafe {
|
||||
PICS.lock().initialize();
|
||||
PICS.lock().write_masks(0xfc, 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
|
||||
<<<<<<< Updated upstream
|
||||
println_log!("Exception: Breakpoint\n{:#?}", stack_frame);
|
||||
}
|
||||
=======
|
||||
serial_println!("Exception: Breakpoint\n{:#?}", stack_frame);
|
||||
println_log!("Exception: Breakpoint\n{:#?}", stack_frame);
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn general_protection_fault_handler(
|
||||
stack_frame: InterruptStackFrame,
|
||||
_error_code: u64,
|
||||
) {
|
||||
serial_println!("Exception: General Protection Fault\n{:#?}", stack_frame);
|
||||
panic!("Exception: General Protection Fault\n{:#?}", stack_frame);
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn double_fault_handler(
|
||||
stack_frame: InterruptStackFrame,
|
||||
_error_code: u64,
|
||||
) -> ! {
|
||||
serial_println!("Exception: Double Fault\n{:#?}", stack_frame);
|
||||
panic!("Exception: Double Fault\n{:#?}", stack_frame);
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
||||
let mut port = Port::new(0x60);
|
||||
let _scancode: u8 = unsafe { port.read() };
|
||||
unsafe {
|
||||
PICS.lock()
|
||||
.notify_end_of_interrupt(InterruptIndex::Keyboard.as_u8());
|
||||
}
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
||||
unsafe {
|
||||
PICS.lock()
|
||||
.notify_end_of_interrupt(InterruptIndex::Timer.as_u8());
|
||||
}
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
pub mod gdt;
|
||||
>>>>>>> Stashed changes
|
||||
pub mod interrupts;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#![no_std]
|
||||
#![feature(abi_x86_interrupt)]
|
||||
|
||||
use arch::x86_64::interrupts;
|
||||
use core::arch::asm;
|
||||
use limine::request::{RequestsEndMarker, RequestsStartMarker};
|
||||
use limine::BaseRevision;
|
||||
@@ -54,5 +55,10 @@ pub fn boot() -> Result<(), &'static str> {
|
||||
lib_serial::init()?;
|
||||
arch::x86_64::interrupts::init_idt();
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
x86_64::instructions::interrupts::enable();
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+9
-2
@@ -14,8 +14,6 @@ unsafe extern "C" fn kmain() -> ! {
|
||||
let dimensions2 = lib_framebuffer::screensize_px();
|
||||
println_log!(" [ Initialising ] ");
|
||||
|
||||
x86_64::instructions::interrupts::int3();
|
||||
|
||||
println!("Dimensions: {}x{} (px)", dimensions2.0, dimensions2.1);
|
||||
println!("Dimensions: {}x{} (chars)", dimensions.0, dimensions.1);
|
||||
|
||||
@@ -39,6 +37,15 @@ unsafe extern "C" fn kmain() -> ! {
|
||||
\\______/ \\______/ \\_/ \\______|
|
||||
"
|
||||
);
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
|
||||
// for i in 0..100000 {
|
||||
// println!("{}", i);
|
||||
// }
|
||||
|
||||
loop {}
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
FoundryOS::hcf();
|
||||
}
|
||||
|
||||
+1
-1
Submodule lib/lib_application updated: 4b1c60676a...df1cbd1170
+1
-1
Submodule lib/lib_ascii updated: d48792ecd0...fefe217980
+1
-1
Submodule lib/lib_serial updated: 6731ed5ef6...a3b0bf0bdb
Reference in New Issue
Block a user