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