@@ -211,14 +211,14 @@ impl BootInformation {
211
211
212
212
/// Search for the ELF Sections tag.
213
213
pub fn elf_sections_tag ( & self ) -> Option < ElfSectionsTag > {
214
- self . get_tag ( TagType :: ElfSections )
214
+ self . get_tag ( TagType :: ElfSections . into ( ) )
215
215
. map ( |tag| unsafe { elf_sections:: elf_sections_tag ( tag, self . offset ) } )
216
216
}
217
217
218
218
/// Search for the Memory map tag.
219
219
pub fn memory_map_tag ( & self ) -> Option < & MemoryMapTag > {
220
- self . get_tag ( TagType :: Mmap )
221
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const MemoryMapTag ) } )
220
+ self . get_tag ( TagType :: Mmap . into ( ) )
221
+ . map ( |tag| tag. cast_tag :: < MemoryMapTag > ( ) )
222
222
}
223
223
224
224
/// Get an iterator of all module tags.
@@ -228,80 +228,80 @@ impl BootInformation {
228
228
229
229
/// Search for the BootLoader name tag.
230
230
pub fn boot_loader_name_tag ( & self ) -> Option < & BootLoaderNameTag > {
231
- self . get_tag ( TagType :: BootLoaderName )
232
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const BootLoaderNameTag ) } )
231
+ self . get_tag ( TagType :: BootLoaderName . into ( ) )
232
+ . map ( |tag| tag. cast_tag :: < BootLoaderNameTag > ( ) )
233
233
}
234
234
235
235
/// Search for the Command line tag.
236
236
pub fn command_line_tag ( & self ) -> Option < & CommandLineTag > {
237
- self . get_tag ( TagType :: Cmdline )
238
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const CommandLineTag ) } )
237
+ self . get_tag ( TagType :: Cmdline . into ( ) )
238
+ . map ( |tag| tag. cast_tag :: < CommandLineTag > ( ) )
239
239
}
240
240
241
241
/// Search for the VBE framebuffer tag.
242
242
pub fn framebuffer_tag ( & self ) -> Option < FramebufferTag > {
243
- self . get_tag ( TagType :: Framebuffer )
243
+ self . get_tag ( TagType :: Framebuffer . into ( ) )
244
244
. map ( framebuffer:: framebuffer_tag)
245
245
}
246
246
247
247
/// Search for the EFI 32-bit SDT tag.
248
248
pub fn efi_sdt_32_tag ( & self ) -> Option < & EFISdt32 > {
249
- self . get_tag ( TagType :: Efi32 )
250
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFISdt32 ) } )
249
+ self . get_tag ( TagType :: Efi32 . into ( ) )
250
+ . map ( |tag| tag. cast_tag :: < EFISdt32 > ( ) )
251
251
}
252
252
253
253
/// Search for the EFI 64-bit SDT tag.
254
254
pub fn efi_sdt_64_tag ( & self ) -> Option < & EFISdt64 > {
255
- self . get_tag ( TagType :: Efi64 )
256
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFISdt64 ) } )
255
+ self . get_tag ( TagType :: Efi64 . into ( ) )
256
+ . map ( |tag| tag. cast_tag :: < EFISdt64 > ( ) )
257
257
}
258
258
259
259
/// Search for the (ACPI 1.0) RSDP tag.
260
260
pub fn rsdp_v1_tag ( & self ) -> Option < & RsdpV1Tag > {
261
- self . get_tag ( TagType :: AcpiV1 )
262
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const RsdpV1Tag ) } )
261
+ self . get_tag ( TagType :: AcpiV1 . into ( ) )
262
+ . map ( |tag| tag. cast_tag :: < RsdpV1Tag > ( ) )
263
263
}
264
264
265
265
/// Search for the (ACPI 2.0 or later) RSDP tag.
266
266
pub fn rsdp_v2_tag ( & self ) -> Option < & RsdpV2Tag > {
267
- self . get_tag ( TagType :: AcpiV2 )
268
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const RsdpV2Tag ) } )
267
+ self . get_tag ( TagType :: AcpiV2 . into ( ) )
268
+ . map ( |tag| tag. cast_tag :: < RsdpV2Tag > ( ) )
269
269
}
270
270
271
271
/// Search for the EFI Memory map tag.
272
272
pub fn efi_memory_map_tag ( & self ) -> Option < & EFIMemoryMapTag > {
273
273
// If the EFIBootServicesNotExited is present, then we should not use
274
274
// the memory map, as it could still be in use.
275
- match self . get_tag ( TagType :: EfiBs ) {
275
+ match self . get_tag ( TagType :: EfiBs . into ( ) ) {
276
276
Some ( _tag) => None ,
277
277
None => self
278
- . get_tag ( TagType :: EfiMmap )
279
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFIMemoryMapTag ) } ) ,
278
+ . get_tag ( TagType :: EfiMmap . into ( ) )
279
+ . map ( |tag| tag. cast_tag :: < EFIMemoryMapTag > ( ) ) ,
280
280
}
281
281
}
282
282
283
283
/// Search for the EFI 32-bit image handle pointer.
284
284
pub fn efi_32_ih ( & self ) -> Option < & EFIImageHandle32 > {
285
- self . get_tag ( TagType :: Efi32Ih )
286
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFIImageHandle32 ) } )
285
+ self . get_tag ( TagType :: Efi32Ih . into ( ) )
286
+ . map ( |tag| tag. cast_tag :: < EFIImageHandle32 > ( ) )
287
287
}
288
288
289
289
/// Search for the EFI 64-bit image handle pointer.
290
290
pub fn efi_64_ih ( & self ) -> Option < & EFIImageHandle64 > {
291
- self . get_tag ( TagType :: Efi64Ih )
292
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const EFIImageHandle64 ) } )
291
+ self . get_tag ( TagType :: Efi64Ih . into ( ) )
292
+ . map ( |tag| tag. cast_tag :: < EFIImageHandle64 > ( ) )
293
293
}
294
294
295
295
/// Search for the Image Load Base Physical Address.
296
296
pub fn load_base_addr ( & self ) -> Option < & ImageLoadPhysAddr > {
297
- self . get_tag ( TagType :: LoadBaseAddr )
298
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const ImageLoadPhysAddr ) } )
297
+ self . get_tag ( TagType :: LoadBaseAddr . into ( ) )
298
+ . map ( |tag| tag. cast_tag :: < ImageLoadPhysAddr > ( ) )
299
299
}
300
300
301
301
/// Search for the VBE information tag.
302
302
pub fn vbe_info_tag ( & self ) -> Option < & ' static VBEInfoTag > {
303
- self . get_tag ( TagType :: Vbe )
304
- . map ( |tag| unsafe { & * ( tag as * const Tag as * const VBEInfoTag ) } )
303
+ self . get_tag ( TagType :: Vbe . into ( ) )
304
+ . map ( |tag| tag. cast_tag :: < VBEInfoTag > ( ) )
305
305
}
306
306
307
307
fn get ( & self ) -> & BootInformationInner {
0 commit comments