#![feature(trait_alias)]
#![no_std]
#![allow(clippy::new_without_default)]

extern crate alloc;

pub mod bus;
pub mod clock;
pub mod device;
pub mod gpio;
pub mod interrupt;
pub mod serial;
pub mod timer;

pub mod dma;

use device::Device;
use yggdrasil_abi::error::Error;

pub trait CpuBringupDevice: Device {
    /// Starts a CPU with given index, providing it with some argument value and instruction
    /// pointer from which its execution should begin.
    ///
    /// # Safety
    ///
    /// This function is unsafe because it can have unexpected effects on the system state if
    /// misused.
    unsafe fn start_cpu(&self, id: usize, ip: usize, arg0: usize) -> Result<(), Error>;
}

pub trait ResetDevice: Device {
    /// Performs a system reset.
    ///
    /// # Safety
    ///
    /// The kernel must ensure it is actually safe to perform a reset, no critical operations
    /// are aborted and no data is lost.
    unsafe fn reset(&self) -> !;
}
