forked from rust-osdev/bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
37 lines (29 loc) · 801 Bytes
/
lib.rs
File metadata and controls
37 lines (29 loc) · 801 Bytes
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
#![no_std]
use bootloader_api::{BootloaderConfig, config::Mapping};
pub const KERNEL_ADDR: u64 = 0x1987_6543_0000;
pub const BOOTLOADER_CONFIG: BootloaderConfig = {
let mut config = BootloaderConfig::new_default();
config.mappings.kernel_base = Mapping::FixedAddress(KERNEL_ADDR);
config
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum QemuExitCode {
Success = 0x10,
Failed = 0x11,
}
pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
use x86_64::instructions::{nop, port::Port};
unsafe {
let mut port = Port::new(0xf4);
port.write(exit_code as u32);
}
loop {
nop();
}
}
pub fn serial() -> uart_16550::SerialPort {
let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) };
port.init();
port
}