Time (#11)
* WIP: Time syscalls * Count time from PIT using low tickrate * Implement realtime * Implement nanosleep with a tight loop
This commit is contained in:
parent
798f7c8808
commit
64cc730eac
11 changed files with 199 additions and 7 deletions
|
@ -2,6 +2,7 @@ use spin::Mutex;
|
|||
use x86::io;
|
||||
|
||||
use device::serial::{COM1, COM2};
|
||||
use time;
|
||||
|
||||
pub static ACKS: Mutex<[usize; 16]> = Mutex::new([0; 16]);
|
||||
pub static COUNTS: Mutex<[usize; 16]> = Mutex::new([0; 16]);
|
||||
|
@ -27,6 +28,16 @@ pub unsafe fn acknowledge(irq: usize) {
|
|||
|
||||
interrupt!(pit, {
|
||||
COUNTS.lock()[0] += 1;
|
||||
|
||||
{
|
||||
const PIT_RATE: u64 = 46500044;
|
||||
|
||||
let mut offset = time::OFFSET.lock();
|
||||
let sum = offset.1 + PIT_RATE;
|
||||
offset.1 = sum % 1000000000;
|
||||
offset.0 += sum / 1000000000;
|
||||
}
|
||||
|
||||
master_ack();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue