File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ pub(crate) mod polyfill;
136
136
137
137
pub mod helpers;
138
138
139
+ mod macros;
139
140
mod util;
140
141
141
142
#[ cfg( test) ]
Original file line number Diff line number Diff line change
1
+ /// Set the entry point for a UEFI executable.
2
+ ///
3
+ /// This macro takes one argument, the function to run when the executable is
4
+ /// launched. That function must take no arguments and return a [`uefi::Result`].
5
+ ///
6
+ /// # Example
7
+ ///
8
+ /// ```
9
+ /// uefi::set_main!(main);
10
+ ///
11
+ /// fn main() -> uefi::Result {
12
+ /// Ok(())
13
+ /// }
14
+ /// ```
15
+ #[ macro_export]
16
+ macro_rules! set_main {
17
+ ( $main: ident) => {
18
+ #[ export_name = "efi_main" ]
19
+ fn efi_main(
20
+ image: :: uefi:: Handle ,
21
+ system_table: * mut :: core:: ffi:: c_void,
22
+ ) -> :: uefi:: Status {
23
+ unsafe { :: uefi:: boot:: set_image_handle( image) } ;
24
+ unsafe { :: uefi:: system:: set_system_table( system_table. cast( ) ) } ;
25
+ let result = $main( ) ;
26
+ match result {
27
+ Ok ( ( ) ) => :: uefi:: Status :: SUCCESS ,
28
+ Err ( err) => err. status( ) ,
29
+ }
30
+ }
31
+ } ;
32
+ }
You can’t perform that action at this time.
0 commit comments