@@ -46,7 +46,7 @@ pub struct BootInformationHeader {
46
46
47
47
#[ cfg( feature = "builder" ) ]
48
48
impl BootInformationHeader {
49
- pub ( crate ) fn new ( total_size : u32 ) -> Self {
49
+ pub ( crate ) const fn new ( total_size : u32 ) -> Self {
50
50
Self {
51
51
total_size,
52
52
_reserved : 0 ,
@@ -140,12 +140,14 @@ impl<'a> BootInformation<'a> {
140
140
}
141
141
142
142
/// Get the start address of the boot info.
143
+ #[ must_use]
143
144
pub fn start_address ( & self ) -> usize {
144
145
self . as_ptr ( ) as usize
145
146
}
146
147
147
148
/// Get the start address of the boot info as pointer.
148
- pub fn as_ptr ( & self ) -> * const ( ) {
149
+ #[ must_use]
150
+ pub const fn as_ptr ( & self ) -> * const ( ) {
149
151
core:: ptr:: addr_of!( * self . 0 ) . cast ( )
150
152
}
151
153
@@ -159,12 +161,14 @@ impl<'a> BootInformation<'a> {
159
161
/// # let boot_info = unsafe { BootInformation::load(ptr).unwrap() };
160
162
/// let end_addr = boot_info.start_address() + boot_info.total_size();
161
163
/// ```
164
+ #[ must_use]
162
165
pub fn end_address ( & self ) -> usize {
163
166
self . start_address ( ) + self . total_size ( )
164
167
}
165
168
166
169
/// Get the total size of the boot info struct.
167
- pub fn total_size ( & self ) -> usize {
170
+ #[ must_use]
171
+ pub const fn total_size ( & self ) -> usize {
168
172
self . 0 . header . total_size as usize
169
173
}
170
174
@@ -177,11 +181,13 @@ impl<'a> BootInformation<'a> {
177
181
}*/
178
182
179
183
/// Search for the basic memory info tag.
184
+ #[ must_use]
180
185
pub fn basic_memory_info_tag ( & self ) -> Option < & BasicMemoryInfoTag > {
181
186
self . get_tag :: < BasicMemoryInfoTag > ( )
182
187
}
183
188
184
189
/// Search for the BootLoader name tag.
190
+ #[ must_use]
185
191
pub fn boot_loader_name_tag ( & self ) -> Option < & BootLoaderNameTag > {
186
192
self . get_tag :: < BootLoaderNameTag > ( )
187
193
}
@@ -192,11 +198,13 @@ impl<'a> BootInformation<'a> {
192
198
}*/
193
199
194
200
/// Search for the Command line tag.
201
+ #[ must_use]
195
202
pub fn command_line_tag ( & self ) -> Option < & CommandLineTag > {
196
203
self . get_tag :: < CommandLineTag > ( )
197
204
}
198
205
199
206
/// Search for the EFI boot services not exited tag.
207
+ #[ must_use]
200
208
pub fn efi_bs_not_exited_tag ( & self ) -> Option < & EFIBootServicesNotExitedTag > {
201
209
self . get_tag :: < EFIBootServicesNotExitedTag > ( )
202
210
}
@@ -205,34 +213,37 @@ impl<'a> BootInformation<'a> {
205
213
/// Otherwise, if the [`TagType::EfiBs`] tag is present, this returns `None`
206
214
/// as it is strictly recommended to get the memory map from the `uefi`
207
215
/// services.
216
+ #[ must_use]
208
217
pub fn efi_memory_map_tag ( & self ) -> Option < & EFIMemoryMapTag > {
209
218
// If the EFIBootServicesNotExited is present, then we should not use
210
219
// the memory map, as it could still be in use.
211
- match self . get_tag :: < EFIBootServicesNotExitedTag > ( ) {
212
- Some ( _tag) => {
213
- log:: debug!( "The EFI memory map is present but the UEFI Boot Services Not Existed Tag is present. Returning None." ) ;
214
- None
215
- }
216
- None => self . get_tag :: < EFIMemoryMapTag > ( ) ,
217
- }
220
+ self . get_tag :: < EFIBootServicesNotExitedTag > ( ) . map_or_else (
221
+ || self . get_tag :: < EFIMemoryMapTag > ( ) , |_tag| {
222
+ log:: debug!( "The EFI memory map is present but the UEFI Boot Services Not Existed Tag is present. Returning None." ) ;
223
+ None
224
+ } )
218
225
}
219
226
220
227
/// Search for the EFI 32-bit SDT tag.
228
+ #[ must_use]
221
229
pub fn efi_sdt32_tag ( & self ) -> Option < & EFISdt32Tag > {
222
230
self . get_tag :: < EFISdt32Tag > ( )
223
231
}
224
232
225
233
/// Search for the EFI 64-bit SDT tag.
234
+ #[ must_use]
226
235
pub fn efi_sdt64_tag ( & self ) -> Option < & EFISdt64Tag > {
227
236
self . get_tag :: < EFISdt64Tag > ( )
228
237
}
229
238
230
239
/// Search for the EFI 32-bit image handle pointer tag.
240
+ #[ must_use]
231
241
pub fn efi_ih32_tag ( & self ) -> Option < & EFIImageHandle32Tag > {
232
242
self . get_tag :: < EFIImageHandle32Tag > ( )
233
243
}
234
244
235
245
/// Search for the EFI 64-bit image handle pointer tag.
246
+ #[ must_use]
236
247
pub fn efi_ih64_tag ( & self ) -> Option < & EFIImageHandle64Tag > {
237
248
self . get_tag :: < EFIImageHandle64Tag > ( )
238
249
}
@@ -254,6 +265,7 @@ impl<'a> BootInformation<'a> {
254
265
/// }
255
266
/// }
256
267
/// ```
268
+ #[ must_use]
257
269
pub fn elf_sections ( & self ) -> Option < ElfSectionIter > {
258
270
let tag = self . get_tag :: < ElfSectionsTag > ( ) ;
259
271
tag. map ( |t| {
@@ -264,6 +276,7 @@ impl<'a> BootInformation<'a> {
264
276
265
277
/// Search for the VBE framebuffer tag. The result is `Some(Err(e))`, if the
266
278
/// framebuffer type is unknown, while the framebuffer tag is present.
279
+ #[ must_use]
267
280
pub fn framebuffer_tag ( & self ) -> Option < Result < & FramebufferTag , UnknownFramebufferType > > {
268
281
self . get_tag :: < FramebufferTag > ( )
269
282
. map ( |tag| match tag. buffer_type ( ) {
@@ -273,16 +286,19 @@ impl<'a> BootInformation<'a> {
273
286
}
274
287
275
288
/// Search for the Image Load Base Physical Address tag.
289
+ #[ must_use]
276
290
pub fn load_base_addr_tag ( & self ) -> Option < & ImageLoadPhysAddrTag > {
277
291
self . get_tag :: < ImageLoadPhysAddrTag > ( )
278
292
}
279
293
280
294
/// Search for the Memory map tag.
295
+ #[ must_use]
281
296
pub fn memory_map_tag ( & self ) -> Option < & MemoryMapTag > {
282
297
self . get_tag :: < MemoryMapTag > ( )
283
298
}
284
299
285
300
/// Get an iterator of all module tags.
301
+ #[ must_use]
286
302
pub fn module_tags ( & self ) -> ModuleIter {
287
303
module:: module_iter ( self . tags ( ) )
288
304
}
@@ -293,21 +309,25 @@ impl<'a> BootInformation<'a> {
293
309
}*/
294
310
295
311
/// Search for the (ACPI 1.0) RSDP tag.
312
+ #[ must_use]
296
313
pub fn rsdp_v1_tag ( & self ) -> Option < & RsdpV1Tag > {
297
314
self . get_tag :: < RsdpV1Tag > ( )
298
315
}
299
316
300
317
/// Search for the (ACPI 2.0 or later) RSDP tag.
318
+ #[ must_use]
301
319
pub fn rsdp_v2_tag ( & self ) -> Option < & RsdpV2Tag > {
302
320
self . get_tag :: < RsdpV2Tag > ( )
303
321
}
304
322
305
323
/// Search for the SMBIOS tag.
324
+ #[ must_use]
306
325
pub fn smbios_tag ( & self ) -> Option < & SmbiosTag > {
307
326
self . get_tag :: < SmbiosTag > ( )
308
327
}
309
328
310
329
/// Search for the VBE information tag.
330
+ #[ must_use]
311
331
pub fn vbe_info_tag ( & self ) -> Option < & VBEInfoTag > {
312
332
self . get_tag :: < VBEInfoTag > ( )
313
333
}
@@ -367,6 +387,7 @@ impl<'a> BootInformation<'a> {
367
387
/// .unwrap();
368
388
/// assert_eq!(tag.name(), Ok("name"));
369
389
/// ```
390
+ #[ must_use]
370
391
pub fn get_tag < TagT : TagTrait + ?Sized + ' a > ( & ' a self ) -> Option < & ' a TagT > {
371
392
self . tags ( )
372
393
. find ( |tag| tag. typ == TagT :: ID )
0 commit comments