Log to serial

This commit is contained in:
Mathieu Strypsteen 2024-06-29 21:07:04 +02:00
parent b6b4854f71
commit 856ea613eb
3 changed files with 65 additions and 9 deletions

57
loader/Cargo.lock generated
View file

@ -8,6 +8,12 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.6.0"
@ -20,6 +26,15 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "com_logger"
version = "0.1.1"
source = "git+https://git.strypsteen.com/mathieu/com_logger#2dc5c9d0fd04e3e9102f0dbed25187761cf07525"
dependencies = [
"log",
"uart_16550",
]
[[package]]
name = "elf"
version = "0.7.4"
@ -30,6 +45,7 @@ checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b"
name = "loader"
version = "0.0.1"
dependencies = [
"com_logger",
"elf",
"log",
"uefi",
@ -38,9 +54,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.21"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "proc-macro2"
@ -80,6 +96,15 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "raw-cpuid"
version = "10.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "rustversion"
version = "1.0.17"
@ -108,6 +133,17 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "uart_16550"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dc00444796f6c71f47c85397a35e9c4dbf9901902ac02386940d178e2b78687"
dependencies = [
"bitflags 1.3.2",
"rustversion",
"x86",
]
[[package]]
name = "ucs2"
version = "0.3.3"
@ -123,7 +159,7 @@ version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9c0a56dc9fed2589aad6ddca11c2584968fc21f227b5d7083bb8961d26a69fa"
dependencies = [
"bitflags",
"bitflags 2.6.0",
"cfg-if",
"log",
"ptr_meta",
@ -150,7 +186,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efa8716f52e8cab8bcedfd5052388a0f263b69fe5cc2561548dc6a530678333c"
dependencies = [
"bitflags",
"bitflags 2.6.0",
"ptr_meta",
"uguid",
]
@ -173,6 +209,17 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"
[[package]]
name = "x86"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385"
dependencies = [
"bit_field",
"bitflags 1.3.2",
"raw-cpuid",
]
[[package]]
name = "x86_64"
version = "0.15.1"
@ -180,7 +227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bc79523af8abf92fb1a970c3e086c5a343f6bcc1a0eb890f575cbb3b45743df"
dependencies = [
"bit_field",
"bitflags",
"bitflags 2.6.0",
"rustversion",
"volatile",
]

View file

@ -4,7 +4,8 @@ version = "0.0.1"
edition = "2021"
[dependencies]
com_logger = { git = "https://git.strypsteen.com/mathieu/com_logger", version = "0.1.1" }
elf = {version = "0.7.4", default-features = false}
log = "0.4.21"
uefi = {version = "0.28.0", features = ["logger", "panic_handler"]}
log = "0.4.22"
uefi = {version = "0.28.0"}
x86_64 = {version = "0.15.1", default-features = false}

View file

@ -1,8 +1,10 @@
#![no_main]
#![no_std]
use core::panic::PanicInfo;
use elf::load_kernel;
use log::debug;
use log::{error, info};
use uefi::{
entry,
table::{boot::MemoryType, Boot, SystemTable},
@ -15,9 +17,15 @@ const KERNEL: &[u8] = include_bytes!("../../kernel/target/x86_64-unknown-none/re
#[entry]
fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
com_logger::init();
uefi::helpers::init(&mut system_table).unwrap();
debug!("Starting bootloader...");
info!("Starting bootloader...");
load_kernel(KERNEL, &system_table);
let _memory_map = system_table.exit_boot_services(MemoryType::LOADER_DATA).1;
loop {}
}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
error!("{}", info);
loop {}
}