File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
uefi-test-runner/src/boot Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ pub fn test() {
2626 test_reinstall_protocol_interface ( ) ;
2727 test_uninstall_protocol_interface ( ) ;
2828 test_install_configuration_table ( ) ;
29+ info ! ( "Testing crc32..." ) ;
30+ test_calculate_crc32 ( ) ;
2931}
3032
3133fn test_tpl ( ) {
@@ -247,3 +249,11 @@ fn test_install_configuration_table() {
247249 boot:: free_pool ( config) . unwrap ( ) ;
248250 }
249251}
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 1313- Added ` proto::ata::pass_thru::AtaPassThru ` .
1414- Added ` boot::ScopedProtocol::open_params() ` .
1515- Added ` boot::TplGuard::old_tpl() ` .
16+ - Added ` boot::calculate_crc32() ` .
1617
1718## Changed
1819- ** 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
14611461 open_protocol_exclusive ( device_handle)
14621462}
14631463
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+
14641477/// Protocol interface [`Guids`][Guid] that are installed on a [`Handle`] as
14651478/// returned by [`protocols_per_handle`].
14661479#[ derive( Debug ) ]
You can’t perform that action at this time.
0 commit comments