Implement changing PIT frequency

ticks are now 1000.15 or so Hz
This commit is contained in:
greg
2015-11-17 03:30:43 -08:00
parent a209559319
commit d133c198a4
2 changed files with 19 additions and 3 deletions

View File

@@ -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]

View File

@@ -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: