Interrupt Forwarding #22
|
@ -1,5 +1,7 @@
|
||||||
//! Environment call handling routines
|
//! Environment call handling routines
|
||||||
|
|
||||||
|
use log::log;
|
||||||
|
|
||||||
use {alloc::boxed::Box, core::cell::LazyCell, hbvm::mem::Address};
|
use {alloc::boxed::Box, core::cell::LazyCell, hbvm::mem::Address};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -245,6 +247,7 @@ pub fn handler(vm: &mut Vm, pid: &usize) {
|
||||||
6 => { // Wait till interrupt
|
6 => { // Wait till interrupt
|
||||||
use crate::kmain::EXECUTOR;
|
use crate::kmain::EXECUTOR;
|
||||||
let interrupt_type = vm.registers[3].cast::<u8>();
|
let interrupt_type = vm.registers[3].cast::<u8>();
|
||||||
|
info!("Interrupt subscribled: {}", interrupt_type);
|
||||||
unsafe{
|
unsafe{
|
||||||
EXECUTOR.pause(pid.clone());
|
EXECUTOR.pause(pid.clone());
|
||||||
LazyCell::<Executor>::get_mut(&mut EXECUTOR).unwrap().interrupt_subscribe(pid.clone(), interrupt_type);
|
LazyCell::<Executor>::get_mut(&mut EXECUTOR).unwrap().interrupt_subscribe(pid.clone(), interrupt_type);
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl<T: Future<Output = ()> + Send> Process for T {}
|
||||||
pub struct Executor {
|
pub struct Executor {
|
||||||
tasks: Slab<Task>,
|
tasks: Slab<Task>,
|
||||||
task_queue: Arc<SegQueue<usize>>,
|
task_queue: Arc<SegQueue<usize>>,
|
||||||
interrupt_lookup: Box<[Option<usize>; u8::MAX as usize]>,
|
interrupt_lookup: [Option<usize>; u8::MAX as usize],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Executor {
|
impl Executor {
|
||||||
|
@ -60,7 +60,7 @@ impl Executor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unpause(self, id: usize) {
|
pub fn unpause(&self, id: usize) {
|
||||||
if let Some(task) = self.tasks.get(id) {
|
if let Some(task) = self.tasks.get(id) {
|
||||||
task.set_paused(false);
|
task.set_paused(false);
|
||||||
self.task_queue.push(id);
|
self.task_queue.push(id);
|
||||||
|
@ -85,7 +85,8 @@ impl Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if batch_len == 0 {
|
if batch_len == 0 {
|
||||||
break;
|
//break;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for &(mut id) in &task_batch[..batch_len] {
|
for &(mut id) in &task_batch[..batch_len] {
|
||||||
|
@ -108,8 +109,7 @@ impl Executor {
|
||||||
pub fn send_interrupt(&self, interrupt : u8){
|
pub fn send_interrupt(&self, interrupt : u8){
|
||||||
let id = self.interrupt_lookup[interrupt as usize];
|
let id = self.interrupt_lookup[interrupt as usize];
|
||||||
if let Some(id) = id{
|
if let Some(id) = id{
|
||||||
let task = &self.tasks[id];
|
self.unpause(id);
|
||||||
task.set_paused(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,5 @@ subscribe_to_interrupt := fn(interrupt_number: u8): bool {
|
||||||
}
|
}
|
||||||
// Pauses execution until the interrupt occures
|
// Pauses execution until the interrupt occures
|
||||||
sleep_until_interrupt := fn(interrupt_number: u8): void {
|
sleep_until_interrupt := fn(interrupt_number: u8): void {
|
||||||
@eca(6, 32);
|
@eca(6, interrupt_number)
|
||||||
}
|
}
|
11
sysdata/programs/timer_test/meta.toml
Normal file
11
sysdata/programs/timer_test/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "timer_test"
|
||||||
|
authors = ["Talha Qamar"]
|
||||||
|
|
||||||
|
[dependants.libraries]
|
||||||
|
|
||||||
|
[dependants.binaries]
|
||||||
|
hblang.version = "1.0.0"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
command = "hblang src/main.hb"
|
10
sysdata/programs/timer_test/src/main.hb
Normal file
10
sysdata/programs/timer_test/src/main.hb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
sleep := @use("../../../libraries/stn/src/sleep.hb")
|
||||||
|
log := @use("../../../libraries/stn/src/log.hb")
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
loop {
|
||||||
|
log.info("BEFORE\0")
|
||||||
|
sleep.sleep_until_interrupt(32)
|
||||||
|
log.info("AFTER\0")
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,6 +34,9 @@ resolution = "1024x768x24"
|
||||||
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||||
|
|
||||||
|
[boot.limine.ableos.modules.timer_test]
|
||||||
|
path = "boot:///timer_test.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.sunset_client]
|
# [boot.limine.ableos.modules.sunset_client]
|
||||||
# path = "boot:///sunset_client.hbf"
|
# path = "boot:///sunset_client.hbf"
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue