Skip to content
Snippets Groups Projects
Commit d53fd6d7 authored by Eemeli Lehtonen's avatar Eemeli Lehtonen
Browse files

Limine & BOOTBOOT

parent d6707183
No related branches found
No related tags found
No related merge requests found
use core::fmt::Arguments;
use spin::Lazy;
//
#[macro_export]
macro_rules! print {
($($t:tt)*) => { $crate::log::_print(format_args!($($t)*)) };
}
#[macro_export]
macro_rules! println {
() => { $crate::log::_print(format_args!("\n")); };
($($t:tt)*) => { $crate::log::_print(format_args_nl!($($t)*)); };
}
//
static LOGGER: Lazy<Logger> = Lazy::new(Logger::init);
struct Logger {
term: bool,
qemu: bool,
}
impl Logger {
fn init() -> Self {
Logger {
term: true,
qemu: true,
}
}
fn print(&self, args: Arguments) {
if self.term {
crate::arch::boot::_print(args);
}
if self.qemu {
crate::qemu::_print(args);
}
}
}
#[doc(hidden)]
pub fn _print(args: Arguments) {
LOGGER.print(args)
}
#![no_std] #![no_std]
#![no_main] #![no_main]
#![feature(format_args_nl)]
#![feature(abi_x86_interrupt)]
use spin::Mutex;
#[path = "arch/x86_64/mod.rs"] #[path = "arch/x86_64/mod.rs"]
pub mod arch; pub mod arch;
pub mod log;
pub mod qemu;
// pub mod vga;
pub mod vga; static BOOTLOADER: Mutex<&'static str> = Mutex::new("Hyperion");
#[panic_handler] #[panic_handler]
fn panic_handler(_: &core::panic::PanicInfo) -> ! { fn panic_handler(_: &core::panic::PanicInfo) -> ! {
...@@ -12,10 +19,8 @@ fn panic_handler(_: &core::panic::PanicInfo) -> ! { ...@@ -12,10 +19,8 @@ fn panic_handler(_: &core::panic::PanicInfo) -> ! {
} }
fn kernel_main() -> ! { fn kernel_main() -> ! {
// null byte clears the VGA buffer println!("Hello from Hyperion");
// print!("\0"); println!(" - Hyperion was booted with {}", BOOTLOADER.lock());
// println!("Hello from Hyperion, pointer = {pointer:#x}, fb = {fb:#x}");
loop { loop {
unsafe { unsafe {
......
use core::fmt::{Arguments, Write};
use spin::{Lazy, Mutex};
use uart_16550::SerialPort;
//
static COM1: Lazy<Mutex<SerialPort>> = Lazy::new(|| {
let mut port = unsafe { SerialPort::new(0x3f8) };
port.init();
Mutex::new(port)
});
//
#[doc(hidden)]
pub fn _print(args: Arguments) {
let mut writer = COM1.lock();
writer.write_fmt(args).unwrap();
}
...@@ -7,30 +7,6 @@ use volatile::Volatile; ...@@ -7,30 +7,6 @@ use volatile::Volatile;
// //
#[macro_export]
macro_rules! println {
() => {
println!("");
};
($($arg:tt)*) => {
$crate::vga::_println(format_args!($($arg)*))
}
}
#[macro_export]
macro_rules! print {
() => {
print!("");
};
($($arg:tt)*) => {
$crate::vga::_print(format_args!($($arg)*))
};
}
//
pub struct Writer { pub struct Writer {
cursor: [usize; 2], cursor: [usize; 2],
color: ColorCode, color: ColorCode,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment