blob: 8b561ce8ea1c89df689ade3bac2e3717a7a088b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#![allow(dead_code)]
#![allow(unused_imports)]
#![no_std]
#![no_main]
#![feature(const_option)]
mod arch;
mod defs;
mod ds;
mod io;
mod machine;
mod mm;
use crate::machine::key::Modifiers;
use arch::x86_64::interrupt;
use arch::x86_64::interrupt::pic_8259;
use arch::x86_64::interrupt::pic_8259::PicDeviceInt;
use core::panic::PanicInfo;
use machine::cgascr::CGAScreen;
use machine::multiboot;
#[cfg(not(test))]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
println!("{}", info);
loop {}
}
#[no_mangle]
pub extern "C" fn _entry() -> ! {
// init code
io::set_attr(0x1f);
io::clear_screen();
assert!(multiboot::check(), "bad multiboot info from grub!");
let mbi = multiboot::get_mb_info().expect("bad multiboot info flags");
let mem = unsafe { mbi.get_mem() }.unwrap();
println!(
"available memory: lower {:#X} KiB, upper:{:#X} KiB",
mem.lower(),
mem.upper()
);
mm::init();
interrupt::init();
pic_8259::allow(PicDeviceInt::KEYBOARD);
interrupt::interrupt_enable();
println!(
"kernel: {:#X} - {:#X}",
defs::pmap_kernel_start(),
defs::pmap_kernel_end()
);
println!(
" BSS: {:#X} - {:#X}",
defs::pmap_bss_start(),
defs::pmap_bss_end()
);
// io::print_welcome();
// busy loop query keyboard
loop {
io::KBCTL_GLOBAL.lock().fetch_key();
if let Some(k) = io::KBCTL_GLOBAL.lock().consume_key() {
println! {"key: {:?}", k}
}
}
}
|