@@ -111,12 +111,12 @@ impl RuntimeServices {
111111
112112 /// Get the size (in bytes) of a variable. This can be used to find out how
113113 /// 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 > {
115115 let mut data_size = 0 ;
116116 let status = unsafe {
117117 ( self . get_variable ) (
118118 name. as_ptr ( ) ,
119- vendor,
119+ & vendor. 0 ,
120120 ptr:: null_mut ( ) ,
121121 & mut data_size,
122122 ptr:: null_mut ( ) ,
@@ -139,15 +139,15 @@ impl RuntimeServices {
139139 pub fn get_variable < ' a > (
140140 & self ,
141141 name : & CStr16 ,
142- vendor : & Guid ,
142+ vendor : & VariableVendor ,
143143 buf : & ' a mut [ u8 ] ,
144144 ) -> Result < ( & ' a [ u8 ] , VariableAttributes ) > {
145145 let mut attributes = VariableAttributes :: empty ( ) ;
146146 let mut data_size = buf. len ( ) ;
147147 unsafe {
148148 ( self . get_variable ) (
149149 name. as_ptr ( ) ,
150- vendor,
150+ & vendor. 0 ,
151151 & mut attributes,
152152 & mut data_size,
153153 buf. as_mut_ptr ( ) ,
@@ -189,7 +189,10 @@ impl RuntimeServices {
189189 break ;
190190 } ;
191191
192- all_variables. push ( VariableKey { name, vendor } ) ;
192+ all_variables. push ( VariableKey {
193+ name,
194+ vendor : VariableVendor ( vendor) ,
195+ } ) ;
193196 }
194197 Status :: BUFFER_TOO_SMALL => {
195198 // The name buffer passed in was too small, resize it to be
@@ -220,12 +223,19 @@ impl RuntimeServices {
220223 pub fn set_variable (
221224 & self ,
222225 name : & CStr16 ,
223- vendor : & Guid ,
226+ vendor : & VariableVendor ,
224227 attributes : VariableAttributes ,
225228 data : & [ u8 ] ,
226229 ) -> Result {
227230 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 ( )
229239 }
230240 }
231241
@@ -482,22 +492,38 @@ bitflags! {
482492 }
483493}
484494
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+ }
493519
494520/// Unique key for a variable.
495521#[ cfg( feature = "exts" ) ]
496522#[ derive( Debug ) ]
497523pub struct VariableKey {
498524 name : Vec < u16 > ,
499525 /// Unique identifier for the vendor.
500- pub vendor : Guid ,
526+ pub vendor : VariableVendor ,
501527}
502528
503529#[ cfg( feature = "exts" ) ]
@@ -520,10 +546,10 @@ impl fmt::Display for VariableKey {
520546
521547 write ! ( f, ", vendor: " ) ?;
522548
523- if self . vendor == GLOBAL_VARIABLE {
549+ if self . vendor == VariableVendor :: GLOBAL_VARIABLE {
524550 write ! ( f, "GLOBAL_VARIABLE" ) ?;
525551 } else {
526- write ! ( f, "{}" , self . vendor) ?;
552+ write ! ( f, "{}" , self . vendor. 0 ) ?;
527553 }
528554
529555 write ! ( f, " }}" )
0 commit comments