interrupt work

This commit is contained in:
Able 2024-11-16 02:51:58 -06:00
parent cea7f1fa5c
commit 3d53b641bf
4 changed files with 57 additions and 6 deletions

View file

@ -14,3 +14,25 @@ arch_cond!(
riscv64: "riscv64", riscv64: "riscv64",
x86_64: "x86_64", x86_64: "x86_64",
); );
use {crate::arch::interrupts::Interrupt, alloc::string::String};
pub struct InterruptList {
list: HashMap<Interrupt, String>,
}
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<Mutex<InterruptList>> = 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)
});

View file

@ -11,7 +11,10 @@ static mut LAPIC: LocalApic = unsafe { MaybeUninit::zeroed().assume_init() };
static mut IDT: InterruptDescriptorTable = unsafe { MaybeUninit::zeroed().assume_init() }; static mut IDT: InterruptDescriptorTable = unsafe { MaybeUninit::zeroed().assume_init() };
#[repr(u8)] #[repr(u8)]
#[derive(Debug)] #[derive(Debug)]#[derive(Eq, Hash, PartialEq)]
pub
enum Interrupt { enum Interrupt {
Timer = 32, Timer = 32,
ApicErr = u8::MAX - 1, ApicErr = u8::MAX - 1,
@ -61,6 +64,8 @@ extern "x86-interrupt" fn page_fault(
} }
extern "x86-interrupt" fn timer(_isf: InterruptStackFrame) { extern "x86-interrupt" fn timer(_isf: InterruptStackFrame) {
interrupt(Interrupt::Timer);
unsafe { unsafe {
LAPIC.end_of_interrupt(); LAPIC.end_of_interrupt();
} }
@ -81,6 +86,31 @@ extern "x86-interrupt" fn spurious(_: InterruptStackFrame) {
} }
fn interrupt(interrupt_type: Interrupt){ 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);
}
} }

View file

@ -92,8 +92,7 @@ fn sds_create_service(protocol: &'static str) -> u64 {
// let a: protocol::Protocol = protocol.into(); // let a: protocol::Protocol = protocol.into();
buff_id buff_id
} }
pub fn sds_search_service(protocol: &str) -> u64 {
fn sds_search_service(protocol: &str) -> u64 {
let services = SERVICES.lock(); let services = SERVICES.lock();
let compare = Protocol::from(protocol); let compare = Protocol::from(protocol);
for (bid, protocol_canidate) in &services.0 { for (bid, protocol_canidate) in &services.0 {

View file

@ -1,5 +1,5 @@
mod ecah; mod ecah;
mod kernel_services; pub mod kernel_services;
mod mem; mod mem;
use { use {