Skip to content

Commit 6cc4182

Browse files
roblablaGabrielMajeri
authored andcommitted
Use EFIAPI ABI introduced in latest nightly (#104)
- Use `efiapi` ABI introduced in latest nightly - Document the requirement of `#![feature(abi_efiapi)]`
1 parent 37039fd commit 6cc4182

File tree

15 files changed

+70
-67
lines changed

15 files changed

+70
-67
lines changed

BUILDING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The following steps allow you to build a simple UEFI app.
1818
and make sure you have an entry point function which matches the one below:
1919

2020
```rust
21+
#![feature(abi_efiapi)]
2122
use uefi::prelude::*;
2223

2324
#[entry]

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#![cfg_attr(feature = "exts", feature(allocator_api, alloc_layout_extra))]
2727
#![feature(optin_builtin_traits)]
2828
#![feature(try_trait)]
29+
#![feature(abi_efiapi)]
2930
#![no_std]
3031
// Enable some additional warnings and lints.
3132
#![warn(missing_docs, unused)]

src/proto/console/gop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ use core::ptr;
3737
#[unsafe_guid("9042a9de-23dc-4a38-96fb-7aded080516a")]
3838
#[derive(Protocol)]
3939
pub struct GraphicsOutput<'boot> {
40-
query_mode: extern "win64" fn(
40+
query_mode: extern "efiapi" fn(
4141
&GraphicsOutput,
4242
mode: u32,
4343
info_sz: &mut usize,
4444
&mut *const ModeInfo,
4545
) -> Status,
46-
set_mode: extern "win64" fn(&mut GraphicsOutput, mode: u32) -> Status,
46+
set_mode: extern "efiapi" fn(&mut GraphicsOutput, mode: u32) -> Status,
4747
// Clippy correctly complains that this is too complicated, but we can't change the spec.
4848
#[allow(clippy::type_complexity)]
49-
blt: unsafe extern "win64" fn(
49+
blt: unsafe extern "efiapi" fn(
5050
this: &mut GraphicsOutput,
5151
buffer: *mut BltPixel,
5252
op: u32,

src/proto/console/pointer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use core::mem::MaybeUninit;
99
#[unsafe_guid("31878c87-0b75-11d5-9a4f-0090273fc14d")]
1010
#[derive(Protocol)]
1111
pub struct Pointer<'boot> {
12-
reset: extern "win64" fn(this: &mut Pointer, ext_verif: bool) -> Status,
13-
get_state: extern "win64" fn(this: &Pointer, state: *mut PointerState) -> Status,
12+
reset: extern "efiapi" fn(this: &mut Pointer, ext_verif: bool) -> Status,
13+
get_state: extern "efiapi" fn(this: &Pointer, state: *mut PointerState) -> Status,
1414
wait_for_input: Event,
1515
mode: &'boot PointerMode,
1616
}

src/proto/console/serial.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pub struct Serial<'boot> {
1818
// Revision of this protocol, only 1.0 is currently defined.
1919
// Future versions will be backwards compatible.
2020
revision: u32,
21-
reset: extern "win64" fn(&mut Serial) -> Status,
22-
set_attributes: extern "win64" fn(
21+
reset: extern "efiapi" fn(&mut Serial) -> Status,
22+
set_attributes: extern "efiapi" fn(
2323
&Serial,
2424
baud_rate: u64,
2525
receive_fifo_depth: u32,
@@ -28,10 +28,10 @@ pub struct Serial<'boot> {
2828
data_bits: u8,
2929
stop_bits_type: StopBits,
3030
) -> Status,
31-
set_control_bits: extern "win64" fn(&mut Serial, ControlBits) -> Status,
32-
get_control_bits: extern "win64" fn(&Serial, &mut ControlBits) -> Status,
33-
write: unsafe extern "win64" fn(&mut Serial, &mut usize, *const u8) -> Status,
34-
read: unsafe extern "win64" fn(&mut Serial, &mut usize, *mut u8) -> Status,
31+
set_control_bits: extern "efiapi" fn(&mut Serial, ControlBits) -> Status,
32+
get_control_bits: extern "efiapi" fn(&Serial, &mut ControlBits) -> Status,
33+
write: unsafe extern "efiapi" fn(&mut Serial, &mut usize, *const u8) -> Status,
34+
read: unsafe extern "efiapi" fn(&mut Serial, &mut usize, *mut u8) -> Status,
3535
io_mode: &'boot IoMode,
3636
}
3737

src/proto/console/text/input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use core::mem::MaybeUninit;
77
#[unsafe_guid("387477c1-69c7-11d2-8e39-00a0c969723b")]
88
#[derive(Protocol)]
99
pub struct Input {
10-
reset: extern "win64" fn(this: &mut Input, extended: bool) -> Status,
11-
read_key_stroke: extern "win64" fn(this: &mut Input, key: *mut RawKey) -> Status,
10+
reset: extern "efiapi" fn(this: &mut Input, extended: bool) -> Status,
11+
read_key_stroke: extern "efiapi" fn(this: &mut Input, key: *mut RawKey) -> Status,
1212
wait_for_key: Event,
1313
}
1414

src/proto/console/text/output.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ use core::fmt;
1111
#[unsafe_guid("387477c2-69c7-11d2-8e39-00a0c969723b")]
1212
#[derive(Protocol)]
1313
pub struct Output<'boot> {
14-
reset: extern "win64" fn(this: &Output, extended: bool) -> Status,
15-
output_string: unsafe extern "win64" fn(this: &Output, string: *const Char16) -> Status,
16-
test_string: unsafe extern "win64" fn(this: &Output, string: *const Char16) -> Status,
17-
query_mode: extern "win64" fn(
14+
reset: extern "efiapi" fn(this: &Output, extended: bool) -> Status,
15+
output_string: unsafe extern "efiapi" fn(this: &Output, string: *const Char16) -> Status,
16+
test_string: unsafe extern "efiapi" fn(this: &Output, string: *const Char16) -> Status,
17+
query_mode: extern "efiapi" fn(
1818
this: &Output,
1919
mode: usize,
2020
columns: &mut usize,
2121
rows: &mut usize,
2222
) -> Status,
23-
set_mode: extern "win64" fn(this: &mut Output, mode: usize) -> Status,
24-
set_attribute: extern "win64" fn(this: &mut Output, attribute: usize) -> Status,
25-
clear_screen: extern "win64" fn(this: &mut Output) -> Status,
26-
set_cursor_position: extern "win64" fn(this: &mut Output, column: usize, row: usize) -> Status,
27-
enable_cursor: extern "win64" fn(this: &mut Output, visible: bool) -> Status,
23+
set_mode: extern "efiapi" fn(this: &mut Output, mode: usize) -> Status,
24+
set_attribute: extern "efiapi" fn(this: &mut Output, attribute: usize) -> Status,
25+
clear_screen: extern "efiapi" fn(this: &mut Output) -> Status,
26+
set_cursor_position: extern "efiapi" fn(this: &mut Output, column: usize, row: usize) -> Status,
27+
enable_cursor: extern "efiapi" fn(this: &mut Output, visible: bool) -> Status,
2828
data: &'boot OutputData,
2929
}
3030

src/proto/media/file/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,40 +271,40 @@ impl Drop for FileHandle {
271271
#[repr(C)]
272272
pub(super) struct FileImpl {
273273
revision: u64,
274-
open: unsafe extern "win64" fn(
274+
open: unsafe extern "efiapi" fn(
275275
this: &mut FileImpl,
276276
new_handle: &mut *mut FileImpl,
277277
filename: *const Char16,
278278
open_mode: FileMode,
279279
attributes: FileAttribute,
280280
) -> Status,
281-
close: extern "win64" fn(this: &mut FileImpl) -> Status,
282-
delete: extern "win64" fn(this: &mut FileImpl) -> Status,
283-
read: unsafe extern "win64" fn(
281+
close: extern "efiapi" fn(this: &mut FileImpl) -> Status,
282+
delete: extern "efiapi" fn(this: &mut FileImpl) -> Status,
283+
read: unsafe extern "efiapi" fn(
284284
this: &mut FileImpl,
285285
buffer_size: &mut usize,
286286
buffer: *mut u8,
287287
) -> Status,
288-
write: unsafe extern "win64" fn(
288+
write: unsafe extern "efiapi" fn(
289289
this: &mut FileImpl,
290290
buffer_size: &mut usize,
291291
buffer: *const u8,
292292
) -> Status,
293-
get_position: extern "win64" fn(this: &mut FileImpl, position: &mut u64) -> Status,
294-
set_position: extern "win64" fn(this: &mut FileImpl, position: u64) -> Status,
295-
get_info: unsafe extern "win64" fn(
293+
get_position: extern "efiapi" fn(this: &mut FileImpl, position: &mut u64) -> Status,
294+
set_position: extern "efiapi" fn(this: &mut FileImpl, position: u64) -> Status,
295+
get_info: unsafe extern "efiapi" fn(
296296
this: &mut FileImpl,
297297
information_type: &Guid,
298298
buffer_size: &mut usize,
299299
buffer: *mut u8,
300300
) -> Status,
301-
set_info: unsafe extern "win64" fn(
301+
set_info: unsafe extern "efiapi" fn(
302302
this: &mut FileImpl,
303303
information_type: &Guid,
304304
buffer_size: usize,
305305
buffer: *const c_void,
306306
) -> Status,
307-
flush: extern "win64" fn(this: &mut FileImpl) -> Status,
307+
flush: extern "efiapi" fn(this: &mut FileImpl) -> Status,
308308
}
309309

310310
/// Disambiguates the file type. Returned by `File::into_type()`.

src/proto/media/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::ptr;
1414
#[derive(Protocol)]
1515
pub struct SimpleFileSystem {
1616
revision: u64,
17-
open_volume: extern "win64" fn(this: &mut SimpleFileSystem, root: &mut *mut FileImpl) -> Status,
17+
open_volume: extern "efiapi" fn(this: &mut SimpleFileSystem, root: &mut *mut FileImpl) -> Status,
1818
}
1919

2020
impl SimpleFileSystem {

src/proto/pi/mp.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use core::ptr;
2020
use core::time::Duration;
2121

2222
/// Callback to be called on the AP.
23-
pub type Procedure = extern "win64" fn(*mut c_void);
23+
pub type Procedure = extern "efiapi" fn(*mut c_void);
2424

2525
bitflags! {
2626
/// Flags indicating if the processor is BSP or AP,
@@ -94,17 +94,17 @@ pub struct CPUPhysicalLocation {
9494
#[unsafe_guid("3fdda605-a76e-4f46-ad29-12f4531b3d08")]
9595
#[derive(Protocol)]
9696
pub struct MPServices {
97-
get_number_of_processors: extern "win64" fn(
97+
get_number_of_processors: extern "efiapi" fn(
9898
this: *const MPServices,
9999
number_of_processors: *mut usize,
100100
number_of_enabled_processors: *mut usize,
101101
) -> Status,
102-
get_processor_info: extern "win64" fn(
102+
get_processor_info: extern "efiapi" fn(
103103
this: *const MPServices,
104104
processor_number: usize,
105105
processor_info_buffer: *mut ProcessorInformation,
106106
) -> Status,
107-
startup_all_aps: extern "win64" fn(
107+
startup_all_aps: extern "efiapi" fn(
108108
this: *const MPServices,
109109
procedure: Procedure,
110110
single_thread: bool,
@@ -113,7 +113,7 @@ pub struct MPServices {
113113
procedure_argument: *mut c_void,
114114
failed_cpu_list: *mut *mut usize,
115115
) -> Status,
116-
startup_this_ap: extern "win64" fn(
116+
startup_this_ap: extern "efiapi" fn(
117117
this: *const MPServices,
118118
procedure: Procedure,
119119
processor_number: usize,
@@ -122,18 +122,18 @@ pub struct MPServices {
122122
procedure_argument: *mut c_void,
123123
finished: *mut bool,
124124
) -> Status,
125-
switch_bsp: extern "win64" fn(
125+
switch_bsp: extern "efiapi" fn(
126126
this: *const MPServices,
127127
processor_number: usize,
128128
enable_old_bsp: bool,
129129
) -> Status,
130-
enable_disable_ap: extern "win64" fn(
130+
enable_disable_ap: extern "efiapi" fn(
131131
this: *const MPServices,
132132
processor_number: usize,
133133
enable_ap: bool,
134134
health_flag: *const u32,
135135
) -> Status,
136-
who_am_i: extern "win64" fn(this: *const MPServices, processor_number: *mut usize) -> Status,
136+
who_am_i: extern "efiapi" fn(this: *const MPServices, processor_number: *mut usize) -> Status,
137137
}
138138

139139
impl MPServices {

0 commit comments

Comments
 (0)