Keep track of # of clock ticks and bump PIT freq to 1kHz
This commit is contained in:
parent
7284cef45a
commit
a4a8bf0152
@ -1,16 +1,12 @@
|
||||
use crate::{
|
||||
bootinfo::BOOTINFO,
|
||||
print, println,
|
||||
tasking::{InvalidPid, IpcMessage, SleepReason},
|
||||
virtual_memory::{ASpaceMutex, AddressSpace, PagingError, ACTIVE_SPACE, KERNEL_SPACE},
|
||||
TASKING,
|
||||
bootinfo::BOOTINFO, pit::NUM_INTERRUPTS, print, println, tasking::{InvalidPid, IpcMessage, SleepReason}, virtual_memory::{ASpaceMutex, AddressSpace, PagingError, ACTIVE_SPACE, KERNEL_SPACE}, TASKING
|
||||
};
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use az::WrappingCast;
|
||||
use cast::{u64, usize};
|
||||
use core::{
|
||||
arch::{asm, naked_asm},
|
||||
ptr, slice,
|
||||
ptr, slice, sync::atomic::Ordering,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use pic8259::ChainedPics;
|
||||
@ -809,6 +805,13 @@ extern "C" fn syscall_handler() {
|
||||
}
|
||||
35 => TASKING.unlock_mutex(usize(regs.rcx)),
|
||||
36 => TASKING.drop_mutex(usize(regs.rcx)),
|
||||
37 => {
|
||||
// Frequency of clock ticks
|
||||
retval = 1000;
|
||||
}
|
||||
38 => {
|
||||
retval = NUM_INTERRUPTS.load(Ordering::Relaxed);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
unsafe { SYSCALL_REGS = regs };
|
||||
|
@ -129,7 +129,7 @@ pub fn main() {
|
||||
Lazy::force(&KERNEL_SPACE);
|
||||
Lazy::force(&ACTIVE_SPACE);
|
||||
interrupts::init();
|
||||
pit::init(100);
|
||||
pit::init(1000);
|
||||
let initrd = unsafe {
|
||||
let ramdisk_start = BOOTINFO.ramdisk_addr.into_option().expect("initrd no present");
|
||||
let ramdisk_len = BOOTINFO.ramdisk_len;
|
||||
|
@ -1,3 +1,5 @@
|
||||
use core::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
use crate::{
|
||||
interrupts::{self, EoiGuard},
|
||||
println, TASKING,
|
||||
@ -10,6 +12,8 @@ static CMD: Mutex<PortWriteOnly<u8>> = Mutex::new(PortWriteOnly::new(0x43));
|
||||
|
||||
const MAX_FREQ: u32 = 1_193_180;
|
||||
|
||||
pub static NUM_INTERRUPTS: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
pub fn init(mut freq: u32) {
|
||||
assert_ne!(freq, 0);
|
||||
#[expect(
|
||||
@ -47,6 +51,7 @@ pub fn init(mut freq: u32) {
|
||||
}
|
||||
|
||||
fn handler(_irq: u8, eoi_guard: EoiGuard) {
|
||||
NUM_INTERRUPTS.fetch_add(1, Ordering::Relaxed);
|
||||
drop(eoi_guard);
|
||||
if TASKING.ok_to_yield() {
|
||||
TASKING.task_yield();
|
||||
|
Loading…
Reference in New Issue
Block a user