1
1
//! Shim lock protocol.
2
2
3
+ #![ cfg( any(
4
+ target_arch = "i386" ,
5
+ target_arch = "x86_64" ,
6
+ target_arch = "arm" ,
7
+ target_arch = "aarch64"
8
+ ) ) ]
9
+
3
10
use crate :: proto:: Protocol ;
4
11
use crate :: result:: Error ;
5
12
use crate :: { unsafe_guid, Result , Status } ;
@@ -36,6 +43,18 @@ pub struct Hashes {
36
43
pub sha1 : [ u8 ; SHA1_DIGEST_SIZE ] ,
37
44
}
38
45
46
+ // These macros set the correct calling convention for the Shim protocol methods.
47
+
48
+ #[ cfg( any( target_arch = "i386" , target_arch = "x86_64" ) ) ]
49
+ macro_rules! shim_function {
50
+ ( fn $args: tt -> $return_type: ty) => ( extern "sysv64" fn $args -> $return_type)
51
+ }
52
+
53
+ #[ cfg( any( target_arch = "arm" , target_arch = "aarch64" ) ) ]
54
+ macro_rules! shim_function {
55
+ ( fn $args: tt -> $return_type: ty) => ( extern "C" fn $args -> $return_type)
56
+ }
57
+
39
58
/// The Shim lock protocol.
40
59
///
41
60
/// This protocol is not part of the UEFI specification, but is
@@ -50,15 +69,17 @@ pub struct Hashes {
50
69
#[ unsafe_guid( "605dab50-e046-4300-abb6-3dd810dd8b23" ) ]
51
70
#[ derive( Protocol ) ]
52
71
pub struct ShimLock {
53
- verify : extern "sysv64" fn ( buffer : * const u8 , size : u32 ) -> Status ,
54
- hash : extern "sysv64" fn (
55
- buffer : * const u8 ,
56
- size : u32 ,
57
- context : * mut Context ,
58
- sha256 : * mut [ u8 ; SHA256_DIGEST_SIZE ] ,
59
- sha1 : * mut [ u8 ; SHA1_DIGEST_SIZE ] ,
60
- ) -> Status ,
61
- context : extern "sysv64" fn ( buffer : * const u8 , size : u32 , context : * mut Context ) -> Status ,
72
+ verify : shim_function ! { fn ( buffer: * const u8 , size: u32 ) -> Status } ,
73
+ hash : shim_function ! {
74
+ fn (
75
+ buffer: * const u8 ,
76
+ size: u32 ,
77
+ context: * mut Context ,
78
+ sha256: * mut [ u8 ; SHA256_DIGEST_SIZE ] ,
79
+ sha1: * mut [ u8 ; SHA1_DIGEST_SIZE ]
80
+ ) -> Status
81
+ } ,
82
+ context : shim_function ! { fn ( buffer: * const u8 , size: u32 , context: * mut Context ) -> Status } ,
62
83
}
63
84
64
85
impl ShimLock {
0 commit comments