Implement changing PIT frequency
ticks are now 1000.15 or so Hz
This commit is contained in:
@@ -38,12 +38,14 @@ pub extern fn rust_handle_timer() {
|
||||
}
|
||||
|
||||
fn timer_callback(count: u64) {
|
||||
if count % 4 == 0 {
|
||||
if count % 1000 == 0 {
|
||||
checkerboard(vga_buffer::Color::White);
|
||||
}
|
||||
if count % 4 == 2 {
|
||||
if count % 1000 == 500 {
|
||||
checkerboard(vga_buffer::Color::LightCyan);
|
||||
}
|
||||
|
||||
vga_buffer::print_u32(count as u32, 0);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
@@ -170,7 +170,7 @@ setup_IDT:
|
||||
ret
|
||||
|
||||
setup_PIC:
|
||||
mov al, 0xfc
|
||||
mov al, 0xfc ;timer and keyboard, no more
|
||||
out byte 0x21, al
|
||||
mov al, 0xff
|
||||
out byte 0xa1, al
|
||||
@@ -178,6 +178,20 @@ setup_PIC:
|
||||
ret
|
||||
|
||||
setup_PIT:
|
||||
%define PIT_CH0 0x40
|
||||
%define PIT_MODE_CMD 0x43
|
||||
%define TIMER_CONSTANT 1193 ;generates ticks at 1000.15 Hz
|
||||
cli
|
||||
|
||||
mov al, 0b00_11_010_0 ; channel 0, low-byte/hi-byte, rate generator
|
||||
out PIT_MODE_CMD, al
|
||||
|
||||
mov ax, TIMER_CONSTANT
|
||||
out PIT_CH0, al
|
||||
mov al, ah
|
||||
out PIT_CH0, al
|
||||
|
||||
sti
|
||||
ret
|
||||
|
||||
idt64:
|
||||
|
||||
Reference in New Issue
Block a user