@@ -225,7 +225,7 @@ impl BootInformation {
225
225
/// Search for the Memory map tag.
226
226
pub fn memory_map_tag ( & self ) -> Option < & MemoryMapTag > {
227
227
self . get_tag ( TagType :: Mmap )
228
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const MemoryMapTag ) } )
228
+ . map ( |tag| tag. cast_tag :: < MemoryMapTag > ( ) )
229
229
}
230
230
231
231
/// Get an iterator of all module tags.
@@ -236,13 +236,13 @@ impl BootInformation {
236
236
/// Search for the BootLoader name tag.
237
237
pub fn boot_loader_name_tag ( & self ) -> Option < & BootLoaderNameTag > {
238
238
self . get_tag ( TagType :: BootLoaderName )
239
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const BootLoaderNameTag ) } )
239
+ . map ( |tag| tag. cast_tag :: < BootLoaderNameTag > ( ) )
240
240
}
241
241
242
242
/// Search for the Command line tag.
243
243
pub fn command_line_tag ( & self ) -> Option < & CommandLineTag > {
244
244
self . get_tag ( TagType :: Cmdline )
245
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const CommandLineTag ) } )
245
+ . map ( |tag| tag. cast_tag :: < CommandLineTag > ( ) )
246
246
}
247
247
248
248
/// Search for the VBE framebuffer tag. The result is `Some(Err(e))`, if the
@@ -255,25 +255,25 @@ impl BootInformation {
255
255
/// Search for the EFI 32-bit SDT tag.
256
256
pub fn efi_sdt_32_tag ( & self ) -> Option < & EFISdt32 > {
257
257
self . get_tag ( TagType :: Efi32 )
258
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFISdt32 ) } )
258
+ . map ( |tag| tag. cast_tag :: < EFISdt32 > ( ) )
259
259
}
260
260
261
261
/// Search for the EFI 64-bit SDT tag.
262
262
pub fn efi_sdt_64_tag ( & self ) -> Option < & EFISdt64 > {
263
263
self . get_tag ( TagType :: Efi64 )
264
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFISdt64 ) } )
264
+ . map ( |tag| tag. cast_tag :: < EFISdt64 > ( ) )
265
265
}
266
266
267
267
/// Search for the (ACPI 1.0) RSDP tag.
268
268
pub fn rsdp_v1_tag ( & self ) -> Option < & RsdpV1Tag > {
269
269
self . get_tag ( TagType :: AcpiV1 )
270
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const RsdpV1Tag ) } )
270
+ . map ( |tag| tag. cast_tag :: < RsdpV1Tag > ( ) )
271
271
}
272
272
273
273
/// Search for the (ACPI 2.0 or later) RSDP tag.
274
274
pub fn rsdp_v2_tag ( & self ) -> Option < & RsdpV2Tag > {
275
275
self . get_tag ( TagType :: AcpiV2 )
276
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const RsdpV2Tag ) } )
276
+ . map ( |tag| tag. cast_tag :: < RsdpV2Tag > ( ) )
277
277
}
278
278
279
279
/// Search for the EFI Memory map tag, if the boot services were exited.
@@ -287,32 +287,32 @@ impl BootInformation {
287
287
Some ( _tag) => None ,
288
288
None => self
289
289
. get_tag ( TagType :: EfiMmap )
290
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFIMemoryMapTag ) } ) ,
290
+ . map ( |tag| tag. cast_tag :: < EFIMemoryMapTag > ( ) ) ,
291
291
}
292
292
}
293
293
294
294
/// Search for the EFI 32-bit image handle pointer.
295
295
pub fn efi_32_ih ( & self ) -> Option < & EFIImageHandle32 > {
296
296
self . get_tag ( TagType :: Efi32Ih )
297
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFIImageHandle32 ) } )
297
+ . map ( |tag| tag. cast_tag :: < EFIImageHandle32 > ( ) )
298
298
}
299
299
300
300
/// Search for the EFI 64-bit image handle pointer.
301
301
pub fn efi_64_ih ( & self ) -> Option < & EFIImageHandle64 > {
302
302
self . get_tag ( TagType :: Efi64Ih )
303
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFIImageHandle64 ) } )
303
+ . map ( |tag| tag. cast_tag :: < EFIImageHandle64 > ( ) )
304
304
}
305
305
306
306
/// Search for the Image Load Base Physical Address.
307
307
pub fn load_base_addr ( & self ) -> Option < & ImageLoadPhysAddr > {
308
308
self . get_tag ( TagType :: LoadBaseAddr )
309
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const ImageLoadPhysAddr ) } )
309
+ . map ( |tag| tag. cast_tag :: < ImageLoadPhysAddr > ( ) )
310
310
}
311
311
312
312
/// Search for the VBE information tag.
313
313
pub fn vbe_info_tag ( & self ) -> Option < & VBEInfoTag > {
314
314
self . get_tag ( TagType :: Vbe )
315
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const VBEInfoTag ) } )
315
+ . map ( |tag| tag. cast_tag :: < VBEInfoTag > ( ) )
316
316
}
317
317
318
318
fn get ( & self ) -> & BootInformationInner {
0 commit comments