diff --git a/kernel/src/arch/mod.rs b/kernel/src/arch/mod.rs index c1a5e1b..30621ca 100644 --- a/kernel/src/arch/mod.rs +++ b/kernel/src/arch/mod.rs @@ -14,3 +14,25 @@ arch_cond!( riscv64: "riscv64", x86_64: "x86_64", ); +use {crate::arch::interrupts::Interrupt, alloc::string::String}; +pub struct InterruptList { + list: HashMap, +} +use hashbrown::HashMap; +impl InterruptList { + pub fn new() -> Self { + Self { + list: HashMap::new(), + } + } +} +use { + alloc::vec::Vec, + spin::{Lazy, Mutex}, +}; +pub static INTERRUPT_LIST: Lazy> = Lazy::new(|| { + let mut il = InterruptList::new(); + use crate::alloc::string::ToString; + il.list.insert(Interrupt::Timer, "PS/2 Mouse".to_string()); + Mutex::new(il) +}); diff --git a/kernel/src/arch/x86_64/interrupts.rs b/kernel/src/arch/x86_64/interrupts.rs index 25c2931..0d3215d 100644 --- a/kernel/src/arch/x86_64/interrupts.rs +++ b/kernel/src/arch/x86_64/interrupts.rs @@ -11,7 +11,10 @@ static mut LAPIC: LocalApic = unsafe { MaybeUninit::zeroed().assume_init() }; static mut IDT: InterruptDescriptorTable = unsafe { MaybeUninit::zeroed().assume_init() }; #[repr(u8)] -#[derive(Debug)] +#[derive(Debug)]#[derive(Eq, Hash, PartialEq)] + + +pub enum Interrupt { Timer = 32, ApicErr = u8::MAX - 1, @@ -61,6 +64,8 @@ extern "x86-interrupt" fn page_fault( } extern "x86-interrupt" fn timer(_isf: InterruptStackFrame) { + interrupt(Interrupt::Timer); + unsafe { LAPIC.end_of_interrupt(); } @@ -81,6 +86,31 @@ extern "x86-interrupt" fn spurious(_: InterruptStackFrame) { } fn interrupt(interrupt_type: Interrupt){ - log::info!("Interrupt type {:?}", interrupt_type); - panic!() + + use crate::arch::INTERRUPT_LIST; + let il = INTERRUPT_LIST.lock(); + let val = il.list.get(&interrupt_type).unwrap(); + + use crate::holeybytes::kernel_services::service_definition_service::sds_search_service; + let buffer = sds_search_service(val); + if buffer != 0 { + use alloc::vec::Vec;use crate::kmain::IPC_BUFFERS; + let mut buffs = IPC_BUFFERS.lock(); + match buffs.get_mut(&buffer) { + Some(buff) => { + let mut msg_vec = Vec::new(); + msg_vec.push(0xff); + buff.push(msg_vec.to_vec()); + log::debug!("Sent Message {:?} to Buffer({})", msg_vec, buffer); + } + None => { + log::error!("Access of non-existent buffer {}", buffer) + } + } + + + + // log::info!("{}", buffer); + +} } \ No newline at end of file diff --git a/kernel/src/holeybytes/kernel_services/service_definition_service.rs b/kernel/src/holeybytes/kernel_services/service_definition_service.rs index 7cf03ec..10db094 100644 --- a/kernel/src/holeybytes/kernel_services/service_definition_service.rs +++ b/kernel/src/holeybytes/kernel_services/service_definition_service.rs @@ -92,8 +92,7 @@ fn sds_create_service(protocol: &'static str) -> u64 { // let a: protocol::Protocol = protocol.into(); buff_id } - -fn sds_search_service(protocol: &str) -> u64 { +pub fn sds_search_service(protocol: &str) -> u64 { let services = SERVICES.lock(); let compare = Protocol::from(protocol); for (bid, protocol_canidate) in &services.0 { diff --git a/kernel/src/holeybytes/mod.rs b/kernel/src/holeybytes/mod.rs index 42e4812..2c4dbab 100644 --- a/kernel/src/holeybytes/mod.rs +++ b/kernel/src/holeybytes/mod.rs @@ -1,5 +1,5 @@ mod ecah; -mod kernel_services; +pub mod kernel_services; mod mem; use {