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) {
|
fn timer_callback(count: u64) {
|
||||||
if count % 4 == 0 {
|
if count % 1000 == 0 {
|
||||||
checkerboard(vga_buffer::Color::White);
|
checkerboard(vga_buffer::Color::White);
|
||||||
}
|
}
|
||||||
if count % 4 == 2 {
|
if count % 1000 == 500 {
|
||||||
checkerboard(vga_buffer::Color::LightCyan);
|
checkerboard(vga_buffer::Color::LightCyan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vga_buffer::print_u32(count as u32, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ setup_IDT:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
setup_PIC:
|
setup_PIC:
|
||||||
mov al, 0xfc
|
mov al, 0xfc ;timer and keyboard, no more
|
||||||
out byte 0x21, al
|
out byte 0x21, al
|
||||||
mov al, 0xff
|
mov al, 0xff
|
||||||
out byte 0xa1, al
|
out byte 0xa1, al
|
||||||
@@ -178,6 +178,20 @@ setup_PIC:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
setup_PIT:
|
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
|
ret
|
||||||
|
|
||||||
idt64:
|
idt64:
|
||||||
|
|||||||
Reference in New Issue
Block a user