Flash things onto screen

also make the keyboard interrupt try to work?
This commit is contained in:
greg
2015-11-16 21:27:19 -08:00
parent 636e540355
commit a209559319
2 changed files with 20 additions and 21 deletions

View File

@@ -20,25 +20,30 @@ pub extern fn rust_interrupt_handler() {
}
#[no_mangle]
pub extern fn rust_handle_keyboard() {
pub extern fn rust_handle_keyboard(x: u8) {
checkerboard(vga_buffer::Color::Green);
vga_buffer::print_u32(x as u32, 0);
}
static mut timer_count: u64 = 0;
static mut global_timer_count: u64 = 0;
#[no_mangle]
pub extern fn rust_handle_timer() {
let gtc = unsafe { global_timer_count };
unsafe {
timer_count += 1;
}
let tc = unsafe { timer_count };
vga_buffer::print_u32(tc as u32, 23);
if (tc % 10) == 0 {
vga_buffer::print_u32(tc as u32, 24);
global_timer_count += 1;
}
timer_callback(gtc);
}
fn timer_callback(count: u64) {
if count % 4 == 0 {
checkerboard(vga_buffer::Color::White);
}
if count % 4 == 2 {
checkerboard(vga_buffer::Color::LightCyan);
}
}
#[no_mangle]
@@ -46,15 +51,6 @@ pub extern fn rust_main() {
clear();
checkerboard(vga_buffer::Color::Red);
let mut cur_checkerboard = vga_buffer::Color::Red;
let mut update_checkerboard = move || {
cur_checkerboard = match cur_checkerboard {
vga_buffer::Color::Red => vga_buffer::Color::Blue,
_ => vga_buffer::Color::Red,
};
checkerboard(cur_checkerboard);
};
loop {
}

View File

@@ -95,10 +95,13 @@ handle_keyboard:
push r11
pushfq
in al, 0x60 ;;throw this away
in al, 0x60
shl al, 8
in al, 0x61
push ax
cld
call rust_handle_keyboard
pop ax
mov al, END_OF_INTERRUPT
out PIC1_COMMAND, al