#![no_std]

use core::ptr::{read_volatile, write_volatile};

#[macro_export]
macro_rules! print {
    () => {};
    ($($arg:tt)*) => {
        $crate::peripherals::uart::_print(format_args!($($arg)*))
    };
}

#[macro_export]
macro_rules! println {
    () => {};
    ($($arg:tt)*) => {
        print!($($arg)*);
        print!("\r\n");
    };
}

pub mod peripherals;

pub mod configuration;
pub mod framebuffer;
pub mod heap;
pub mod irq_interrupt;
pub mod mailbox;
pub mod timer;

pub fn mmio_read(address: u32) -> u32 {
    unsafe { read_volatile(address as *const u32) }
}

pub fn mmio_write(address: u32, data: u32) {
    unsafe { write_volatile(address as *mut u32, data) }
}

#[derive(Debug)]
pub enum NovaError {
    Mailbox,
    HeapFull,
    EmptyHeapSegmentNotAllowed,
}
