1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
const COMMON_MAGIC: [u64; 2] = [0xc7b1dd30df4c8b88, 0x0a82e883a194f07b];
/// This creates a limine request with const defaults by black magic.
/// It also automatically creates the `id` and `revision` fields.
/// # Example
/// ```rust
/// limine_request! {
/// /// A test limine request, being public isn't required
/// pub struct TestRequest: [0xdead, 0xbeef] {
/// /// The response
/// pub response: Option<NonNull<TestResponse>>,
/// }
/// }
/// ```
/// Will be expanded to
/// ```rust
/// pub struct TestRequest {
/// /// The request id array
/// pub id: [u64; 4],
/// /// The request revision
/// pub revision: u64,
/// /// The response
/// pub response: Option<NonNull<TestResponse>>,
/// }
///
/// impl TestRequest {
/// /// Create a new instance of this request
/// pub const fn new() -> Self {
/// use crate::ConstDefault;
/// Self {
/// id: [
/// crate::requests::COMMON_MAGIC[0],
/// crate::requests::COMMON_MAGIC[1],
/// 0xdead,
/// 0xbeef,
/// ],
/// revision: 0,
/// response: None,
/// }
/// }
/// }
/// ```
macro_rules! limine_request {
(
$(#[$outer_meta:meta])*
$vis:vis struct $req:ident: [$val1:expr, $val2:expr] {
$(
$(#[$inner_meta:meta])*
$vis_f:vis $ident_f:ident: $ty:ty,
)*
}
) => {
$(#[$outer_meta])*
$vis struct $req {
/// The request id array
pub id: [u64; 4],
/// The request revision
pub revision: u64,
$(
$(#[$inner_meta])*
$vis_f $ident_f: $ty,
)*
}
impl $req {
/// Create a new instance of this request
pub const fn new() -> Self {
use $crate::ConstDefault;
Self {
id: [
$crate::requests::COMMON_MAGIC[0],
$crate::requests::COMMON_MAGIC[1],
$val1,
$val2
],
revision: 0,
$(
$ident_f: <$ty>::DEFAULT,
)*
}
}
/// Alias to `Self::new`
pub const fn default() -> Self {
Self::new()
}
/// Wrap the item in [Request]
pub const fn into(self) -> $crate::Request<Self> {
$crate::Request(::core::cell::UnsafeCell::new(self))
}
}
};
}
mod boot_time;
pub use boot_time::*;
mod efi_sys_table;
pub use efi_sys_table::*;
mod entry_point;
pub use entry_point::*;
mod framebuffer;
pub use framebuffer::*;
mod hhdm;
pub use hhdm::*;
mod bootloader_info;
pub use bootloader_info::*;
mod kernel_address;
pub use kernel_address::*;
mod kernel_file;
pub use kernel_file::*;
mod level_5_paging;
pub use level_5_paging::*;
mod memory_map;
pub use memory_map::*;
mod module;
pub use module::*;
mod rsdp;
pub use rsdp::*;
mod smbios;
pub use smbios::*;
mod smp;
pub use smp::*;
mod stack_size;
pub use stack_size::*;
mod terminal;
pub use terminal::*;