File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed 
library/std/src/sys/pal/uefi Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -393,7 +393,9 @@ mod uefi_command_internal {
393393            } 
394394        } 
395395
396-         pub  fn  start_image ( & self )  -> io:: Result < r_efi:: efi:: Status >  { 
396+         pub  fn  start_image ( & mut  self )  -> io:: Result < r_efi:: efi:: Status >  { 
397+             self . update_st_crc32 ( ) ?; 
398+ 
397399            let  boot_services:  NonNull < r_efi:: efi:: BootServices >  = boot_services ( ) 
398400                . ok_or_else ( || const_io_error ! ( io:: ErrorKind :: NotFound ,  "Boot Services not found" ) ) ?
399401                . cast ( ) ; 
@@ -476,6 +478,27 @@ mod uefi_command_internal {
476478
477479            self . args  = Some ( args) ; 
478480        } 
481+ 
482+         fn  update_st_crc32 ( & mut  self )  -> io:: Result < ( ) >  { 
483+             let  bt:  NonNull < r_efi:: efi:: BootServices >  = boot_services ( ) . unwrap ( ) . cast ( ) ; 
484+             let  st_size = self . st . hdr . header_size  as  usize ; 
485+             let  mut  crc32:  u32  = 0 ; 
486+ 
487+             let  r = unsafe  { 
488+                 ( ( * bt. as_ptr ( ) ) . calculate_crc32 ) ( 
489+                     self . st . as_mut ( )  as  * mut  r_efi:: efi:: SystemTable  as  * mut  crate :: ffi:: c_void , 
490+                     st_size, 
491+                     & mut  crc32, 
492+                 ) 
493+             } ; 
494+ 
495+             if  r. is_error ( )  { 
496+                 Err ( io:: Error :: from_raw_os_error ( r. as_usize ( ) ) ) 
497+             }  else  { 
498+                 self . st . hdr . crc32  = crc32; 
499+                 Ok ( ( ) ) 
500+             } 
501+         } 
479502    } 
480503
481504    impl  Drop  for  Command  { 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments