1
0

Macro cleanup

This commit is contained in:
Mark 2025-02-17 21:33:07 -08:00
parent d6e8bb8859
commit fa2ff36610
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
5 changed files with 11 additions and 26 deletions

View File

@ -3,7 +3,6 @@
#![feature(int_roundings)]
#![feature(lang_items)]
#![allow(internal_features)]
#![feature(let_chains)]
extern crate alloc;
@ -11,6 +10,8 @@ use self::os::{OsMemoryEntry, OsMemoryKind};
#[macro_use]
mod os;
#[macro_use]
mod serial;
//TODO: allocate this in a more reasonable manner

View File

@ -1,16 +0,0 @@
/// Print to console
#[macro_export]
macro_rules! print {
($($arg:tt)*) => ({
use core::fmt::Write;
let _ = write!($crate::os::VGA.lock(), $($arg)*);
});
}
/// Print with new line to console
#[macro_export]
macro_rules! println {
() => (print!("\n"));
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}

View File

@ -5,10 +5,8 @@ use crate::serial_println;
use self::memory_map::memory_map;
use self::thunk::ThunkData;
use self::vga::Vga;
#[macro_use]
mod macros;
use crate::println;
mod memory_map;
mod panic;
@ -34,7 +32,7 @@ pub unsafe extern "C" fn start(
thunk15: extern "C" fn(),
_thunk16: extern "C" fn(),
) -> ! {
serial_println!("Entered Rust, serial ready.");
println!("Entered Rust, serial ready.");
{
// Make sure we are in mode 3 (80x25 text mode)

View File

@ -4,6 +4,8 @@ use core::alloc::Layout;
use core::arch::asm;
use core::panic::PanicInfo;
use crate::println;
#[lang = "eh_personality"]
#[no_mangle]
pub extern "C" fn rust_eh_personality() {}

View File

@ -40,7 +40,7 @@ pub fn _print(args: core::fmt::Arguments<'_>) {
/// Prints to the host through the serial interface.
#[macro_export]
macro_rules! serial_print {
macro_rules! print {
($($arg:tt)*) => {
$crate::serial::_print(format_args!($($arg)*));
};
@ -48,9 +48,9 @@ macro_rules! serial_print {
/// Prints to the host through the serial interface, appending a newline.
#[macro_export]
macro_rules! serial_println {
() => ($crate::serial_print!("\n"));
($fmt:expr) => ($crate::serial_print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => ($crate::serial_print!(
macro_rules! println {
() => ($crate::print!("\n"));
($fmt:expr) => ($crate::print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => ($crate::print!(
concat!($fmt, "\n"), $($arg)*));
}