Utility function for low, high bits
This commit is contained in:
@@ -58,10 +58,11 @@ mod PIT {
|
||||
pub const MILLISECOND_CONSTANT: u16 = 1193;
|
||||
|
||||
pub fn configure_PIT(timer_divider: u16) {
|
||||
|
||||
let (low_bits, high_bits) = ::util::lo_hi_bits(timer_divider);
|
||||
|
||||
unsafe {
|
||||
outb(PIT_MODE_CMD, TIMER_CONFIG_SPECIFIER);
|
||||
let low_bits = (timer_divider & 0xff) as u8;
|
||||
let high_bits = (timer_divider >> 8) as u8;
|
||||
outb(PIT_CH0, low_bits);
|
||||
outb(PIT_CH0, high_bits);
|
||||
}
|
||||
@@ -173,6 +174,11 @@ pub extern fn rust_main() {
|
||||
|
||||
// 123 |3,2,1
|
||||
mod util {
|
||||
|
||||
pub fn lo_hi_bits(n: u16) -> (u8, u8) {
|
||||
( (n & 0xff) as u8, (n >> 8) as u8)
|
||||
}
|
||||
|
||||
pub fn u32_to_chars(n: u32) -> [u8; 10] {
|
||||
let mut accum = [0; 10];
|
||||
let mut i = 0;
|
||||
@@ -325,8 +331,7 @@ mod vga_buffer {
|
||||
const CURSOR_DATA_PORT: u16 = 0x3d5;
|
||||
|
||||
let position: u16 = (y as u16)*80 + (x as u16);
|
||||
let low_bits = (position & 0xff) as u8;
|
||||
let high_bits = (position >> 8) as u8;
|
||||
let (low_bits, high_bits) = ::util::lo_hi_bits(position);
|
||||
|
||||
unsafe {
|
||||
outb(CURSOR_COMMAND_PORT, 14);
|
||||
|
||||
Reference in New Issue
Block a user