Move PIC logic to rust
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#![feature(no_std, lang_items, const_fn)]
|
#![feature(no_std, lang_items, const_fn, asm)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -14,6 +14,23 @@ extern {
|
|||||||
fn call_interrupt();
|
fn call_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern fn rust_setup_PIC() {
|
||||||
|
|
||||||
|
let interrupt_mask1: u8 = 0xfc;
|
||||||
|
let interrupt_mask2: u8 = 0xff;
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
out(0x21, interrupt_mask1);
|
||||||
|
out(0xa1, interrupt_mask2);
|
||||||
|
asm!("sti");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn out(port: u16, value: u8) {
|
||||||
|
asm!("outb %%dx, %%al" : : "dx" (port), "al"(value));
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn rust_interrupt_handler() {
|
pub extern fn rust_interrupt_handler() {
|
||||||
checkerboard(vga_buffer::Color::White);
|
checkerboard(vga_buffer::Color::White);
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ long_mode_start:
|
|||||||
call setup_SSE
|
call setup_SSE
|
||||||
call setup_IDT
|
call setup_IDT
|
||||||
call setup_PIT
|
call setup_PIT
|
||||||
call setup_PIC
|
extern rust_setup_PIC
|
||||||
|
call rust_setup_PIC
|
||||||
extern rust_main
|
extern rust_main
|
||||||
call rust_main
|
call rust_main
|
||||||
; rust main returned, print `OS returned!`
|
; rust main returned, print `OS returned!`
|
||||||
@@ -169,13 +170,14 @@ setup_IDT:
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
setup_PIC:
|
|
||||||
mov al, 0xfc ;timer and keyboard, no more
|
;setup_PIC:
|
||||||
out byte 0x21, al
|
; mov al, 0xfc ;timer and keyboard, no more
|
||||||
mov al, 0xff
|
; out byte 0x21, al
|
||||||
out byte 0xa1, al
|
; mov al, 0xff
|
||||||
sti
|
; out byte 0xa1, al
|
||||||
ret
|
; sti
|
||||||
|
; ret
|
||||||
|
|
||||||
setup_PIT:
|
setup_PIT:
|
||||||
%define PIT_CH0 0x40
|
%define PIT_CH0 0x40
|
||||||
|
|||||||
Reference in New Issue
Block a user