@@ -111,12 +111,12 @@ impl RuntimeServices {
111
111
112
112
/// Get the size (in bytes) of a variable. This can be used to find out how
113
113
/// big of a buffer should be passed in to `get_variable`.
114
- pub fn get_variable_size ( & self , name : & CStr16 , vendor : & Guid ) -> Result < usize > {
114
+ pub fn get_variable_size ( & self , name : & CStr16 , vendor : & VariableVendor ) -> Result < usize > {
115
115
let mut data_size = 0 ;
116
116
let status = unsafe {
117
117
( self . get_variable ) (
118
118
name. as_ptr ( ) ,
119
- vendor,
119
+ & vendor. 0 ,
120
120
ptr:: null_mut ( ) ,
121
121
& mut data_size,
122
122
ptr:: null_mut ( ) ,
@@ -139,15 +139,15 @@ impl RuntimeServices {
139
139
pub fn get_variable < ' a > (
140
140
& self ,
141
141
name : & CStr16 ,
142
- vendor : & Guid ,
142
+ vendor : & VariableVendor ,
143
143
buf : & ' a mut [ u8 ] ,
144
144
) -> Result < ( & ' a [ u8 ] , VariableAttributes ) > {
145
145
let mut attributes = VariableAttributes :: empty ( ) ;
146
146
let mut data_size = buf. len ( ) ;
147
147
unsafe {
148
148
( self . get_variable ) (
149
149
name. as_ptr ( ) ,
150
- vendor,
150
+ & vendor. 0 ,
151
151
& mut attributes,
152
152
& mut data_size,
153
153
buf. as_mut_ptr ( ) ,
@@ -189,7 +189,10 @@ impl RuntimeServices {
189
189
break ;
190
190
} ;
191
191
192
- all_variables. push ( VariableKey { name, vendor } ) ;
192
+ all_variables. push ( VariableKey {
193
+ name,
194
+ vendor : VariableVendor ( vendor) ,
195
+ } ) ;
193
196
}
194
197
Status :: BUFFER_TOO_SMALL => {
195
198
// The name buffer passed in was too small, resize it to be
@@ -220,12 +223,19 @@ impl RuntimeServices {
220
223
pub fn set_variable (
221
224
& self ,
222
225
name : & CStr16 ,
223
- vendor : & Guid ,
226
+ vendor : & VariableVendor ,
224
227
attributes : VariableAttributes ,
225
228
data : & [ u8 ] ,
226
229
) -> Result {
227
230
unsafe {
228
- ( self . set_variable ) ( name. as_ptr ( ) , vendor, attributes, data. len ( ) , data. as_ptr ( ) ) . into ( )
231
+ ( self . set_variable ) (
232
+ name. as_ptr ( ) ,
233
+ & vendor. 0 ,
234
+ attributes,
235
+ data. len ( ) ,
236
+ data. as_ptr ( ) ,
237
+ )
238
+ . into ( )
229
239
}
230
240
}
231
241
@@ -482,22 +492,38 @@ bitflags! {
482
492
}
483
493
}
484
494
485
- /// Vendor GUID used to access global variables.
486
- pub const GLOBAL_VARIABLE : Guid = Guid :: from_values (
487
- 0x8be4df61 ,
488
- 0x93ca ,
489
- 0x11d2 ,
490
- 0xaa0d ,
491
- [ 0x00 , 0xe0 , 0x98 , 0x03 , 0x2b , 0x8c ] ,
492
- ) ;
495
+ newtype_enum ! {
496
+ /// Variable vendor GUID. This serves as a namespace for variables to
497
+ /// avoid naming conflicts between vendors. The UEFI specification
498
+ /// defines some special values, and vendors will define their own.
499
+ pub enum VariableVendor : Guid => {
500
+ /// Used to access global variables.
501
+ GLOBAL_VARIABLE = Guid :: from_values(
502
+ 0x8be4df61 ,
503
+ 0x93ca ,
504
+ 0x11d2 ,
505
+ 0xaa0d ,
506
+ [ 0x00 , 0xe0 , 0x98 , 0x03 , 0x2b , 0x8c ] ,
507
+ ) ,
508
+
509
+ /// Used to access EFI signature database variables.
510
+ IMAGE_SECURITY_DATABASE = Guid :: from_values(
511
+ 0xd719b2cb ,
512
+ 0x3d3a ,
513
+ 0x4596 ,
514
+ 0xa3bc ,
515
+ [ 0xda , 0xd0 , 0x0e , 0x67 , 0x65 , 0x6f ] ,
516
+ ) ,
517
+ }
518
+ }
493
519
494
520
/// Unique key for a variable.
495
521
#[ cfg( feature = "exts" ) ]
496
522
#[ derive( Debug ) ]
497
523
pub struct VariableKey {
498
524
name : Vec < u16 > ,
499
525
/// Unique identifier for the vendor.
500
- pub vendor : Guid ,
526
+ pub vendor : VariableVendor ,
501
527
}
502
528
503
529
#[ cfg( feature = "exts" ) ]
@@ -520,10 +546,10 @@ impl fmt::Display for VariableKey {
520
546
521
547
write ! ( f, ", vendor: " ) ?;
522
548
523
- if self . vendor == GLOBAL_VARIABLE {
549
+ if self . vendor == VariableVendor :: GLOBAL_VARIABLE {
524
550
write ! ( f, "GLOBAL_VARIABLE" ) ?;
525
551
} else {
526
- write ! ( f, "{}" , self . vendor) ?;
552
+ write ! ( f, "{}" , self . vendor. 0 ) ?;
527
553
}
528
554
529
555
write ! ( f, " }}" )
0 commit comments