File tree 3 files changed +24
-0
lines changed
uefi-test-runner/src/boot
3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ pub fn test() {
26
26
test_reinstall_protocol_interface ( ) ;
27
27
test_uninstall_protocol_interface ( ) ;
28
28
test_install_configuration_table ( ) ;
29
+ info ! ( "Testing crc32..." ) ;
30
+ test_calculate_crc32 ( ) ;
29
31
}
30
32
31
33
fn test_tpl ( ) {
@@ -247,3 +249,11 @@ fn test_install_configuration_table() {
247
249
boot:: free_pool ( config) . unwrap ( ) ;
248
250
}
249
251
}
252
+
253
+ fn test_calculate_crc32 ( ) {
254
+ let data = "uefi-rs" ;
255
+
256
+ let crc = boot:: calculate_crc32 ( data. as_bytes ( ) ) . unwrap ( ) ;
257
+
258
+ assert_eq ! ( crc, 0xcfc96a3e ) ;
259
+ }
Original file line number Diff line number Diff line change 13
13
- Added ` proto::ata::pass_thru::AtaPassThru ` .
14
14
- Added ` boot::ScopedProtocol::open_params() ` .
15
15
- Added ` boot::TplGuard::old_tpl() ` .
16
+ - Added ` boot::calculate_crc32() ` .
16
17
17
18
## Changed
18
19
- ** Breaking:** Removed ` BootPolicyError ` as ` BootPolicy ` construction is no
Original file line number Diff line number Diff line change @@ -1461,6 +1461,19 @@ pub fn get_image_file_system(image_handle: Handle) -> Result<ScopedProtocol<Simp
1461
1461
open_protocol_exclusive ( device_handle)
1462
1462
}
1463
1463
1464
+ /// Calculates the 32-bit CRC32 for the provided slice.
1465
+ ///
1466
+ /// # Errors
1467
+ /// * [`Status::INVALID_PARAMETER`]
1468
+ pub fn calculate_crc32 ( data : & [ u8 ] ) -> Result < u32 > {
1469
+ let bt = boot_services_raw_panicking ( ) ;
1470
+ let bt = unsafe { bt. as_ref ( ) } ;
1471
+ let mut crc = 0u32 ;
1472
+
1473
+ unsafe { ( bt. calculate_crc32 ) ( data. as_ptr ( ) . cast ( ) , data. len ( ) , & mut crc) }
1474
+ . to_result_with_val ( || crc)
1475
+ }
1476
+
1464
1477
/// Protocol interface [`Guids`][Guid] that are installed on a [`Handle`] as
1465
1478
/// returned by [`protocols_per_handle`].
1466
1479
#[ derive( Debug ) ]
You can’t perform that action at this time.
0 commit comments