File tree Expand file tree Collapse file tree 14 files changed +125
-87
lines changed Expand file tree Collapse file tree 14 files changed +125
-87
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,13 @@ safely cast to the target type.
25
25
![ Generic parsing flow overview] ( ./parsing-flow-generic.drawio.png " Generic parsing flow overview: From raw bytes to specific structures ")
26
26
27
27
The next figure is like the previous figure, but shows a more specific parsing
28
- flow by using types of the ` multiboot2 ` crate. Green shows the raw memory.
29
- Purple boxes refers to logic in ` multiboot2-common ` . Red components show structs
30
- from the ` multiboot2 ` crate.
28
+ flow by using example types of the ` multiboot2 ` crate. Specifically, it shows
29
+ how the header structs for each multiboot2 structure, each implementing
30
+ the ` Header ` trait, are utilized as generic types to get the right size
31
+ information of the final type tag type.
32
+
33
+ Green shows the raw memory, purple boxes refer to logic in ` multiboot2-common ` ,
34
+ and red components show structs from the ` multiboot2 ` crate.
31
35
32
36
![ Specific parsing flow overview] ( ./parsing-flow-specific.drawio.png " Specific parsing flow overview: From raw bytes to multiboot2 structures ")
33
37
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -7,11 +7,14 @@ use core::marker::PhantomData;
7
7
use core:: mem;
8
8
9
9
/// Iterates over the tags (modelled by [`DynSizedStructure`]) of the underlying
10
- /// byte slice. Each tag is expected to have the same common [`Header`].
10
+ /// byte slice. Each tag is expected to have the same common [`Header`] with
11
+ /// the corresponding ABI guarantees.
11
12
///
12
13
/// As the iterator emits elements of type [`DynSizedStructure`], users should
13
- /// casted them to specific [`Tag`]s using [`DynSizedStructure::cast`] following
14
- /// a user policy. This can for example happen on the basis of some ID.
14
+ /// cast them to specific [`Tag`]s using [`DynSizedStructure::cast`] following
15
+ /// a user-specific policy. This can for example happen on the basis of some ID.
16
+ ///
17
+ /// This iterator also emits end tags and doesn't treat them separately.
15
18
///
16
19
/// This type ensures the memory safety guarantees promised by this crates
17
20
/// documentation.
@@ -30,6 +33,8 @@ pub struct TagIter<'a, H: Header> {
30
33
impl < ' a , H : Header > TagIter < ' a , H > {
31
34
/// Creates a new iterator.
32
35
#[ must_use]
36
+ // TODO we could take a BytesRef here, but the surrounding code should be
37
+ // bullet-proof enough.
33
38
pub fn new ( mem : & ' a [ u8 ] ) -> Self {
34
39
// Assert alignment.
35
40
assert_eq ! ( mem. as_ptr( ) . align_offset( ALIGNMENT ) , 0 ) ;
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ pub trait MaybeDynSized: Pointee {
64
64
/// data, read the tag size from [`Self::header`] and create a sub slice.
65
65
fn as_bytes ( & self ) -> BytesRef < Self :: Header > {
66
66
let ptr = core:: ptr:: addr_of!( * self ) ;
67
- // Actual tag size, optionally with terminating padding.
67
+ // Actual tag size with optional terminating padding.
68
68
let size = mem:: size_of_val ( self ) ;
69
69
let slice = unsafe { slice:: from_raw_parts ( ptr. cast :: < u8 > ( ) , size) } ;
70
70
// Unwrap is fine as this type can't exist without the underlying memory
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ impl Debug for EntryAddressHeaderTag {
53
53
. field ( "type" , & self . typ ( ) )
54
54
. field ( "flags" , & self . flags ( ) )
55
55
. field ( "size" , & self . size ( ) )
56
- . field ( "entry_addr" , & ( self . entry_addr as * const u32 ) )
56
+ . field ( "entry_addr" , & self . entry_addr )
57
57
. finish ( )
58
58
}
59
59
}
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ impl Debug for EntryEfi32HeaderTag {
62
62
. field ( "type" , & self . typ ( ) )
63
63
. field ( "flags" , & self . flags ( ) )
64
64
. field ( "size" , & self . size ( ) )
65
- . field ( "entry_addr" , & ( self . entry_addr as * const u32 ) )
65
+ . field ( "entry_addr" , & self . entry_addr )
66
66
. finish ( )
67
67
}
68
68
}
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ impl Debug for EntryEfi64HeaderTag {
62
62
. field ( "type" , & self . typ ( ) )
63
63
. field ( "flags" , & self . flags ( ) )
64
64
. field ( "size" , & self . size ( ) )
65
- . field ( "entry_addr" , & ( self . entry_addr as * const u32 ) )
65
+ . field ( "entry_addr" , & self . entry_addr )
66
66
. finish ( )
67
67
}
68
68
}
Original file line number Diff line number Diff line change @@ -108,10 +108,10 @@ impl Debug for RelocatableHeaderTag {
108
108
. field ( "flags" , & self . flags ( ) )
109
109
. field ( "size" , & self . size ( ) )
110
110
// trick to print this as hexadecimal pointer
111
- . field ( "min_addr" , & ( self . min_addr as * const u32 ) )
112
- . field ( "max_addr" , & ( self . max_addr as * const u32 ) )
113
- . field ( "align" , & { self . align } )
114
- . field ( "preference" , & { self . preference } )
111
+ . field ( "min_addr" , & self . min_addr )
112
+ . field ( "max_addr" , & self . max_addr )
113
+ . field ( "align" , & self . align )
114
+ . field ( "preference" , & self . preference )
115
115
. finish ( )
116
116
}
117
117
}
Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ impl<'a> BootInformation<'a> {
132
132
133
133
/// Get the start address of the boot info.
134
134
#[ must_use]
135
+ // TODO deprecated and use pointers only (see provenance discussions)
135
136
pub fn start_address ( & self ) -> usize {
136
137
self . as_ptr ( ) as usize
137
138
}
@@ -153,6 +154,7 @@ impl<'a> BootInformation<'a> {
153
154
/// let end_addr = boot_info.start_address() + boot_info.total_size();
154
155
/// ```
155
156
#[ must_use]
157
+ // TODO deprecated and use pointers only (see provenance discussions)
156
158
pub fn end_address ( & self ) -> usize {
157
159
self . start_address ( ) + self . total_size ( )
158
160
}
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ impl<'a> Iterator for ElfSectionIter<'a> {
134
134
}
135
135
}
136
136
137
- impl < ' a > Debug for ElfSectionIter < ' a > {
137
+ impl Debug for ElfSectionIter < ' _ > {
138
138
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> core:: fmt:: Result {
139
139
let mut debug = f. debug_list ( ) ;
140
140
self . clone ( ) . for_each ( |ref e| {
@@ -183,7 +183,7 @@ struct ElfSectionInner64 {
183
183
entry_size : u64 ,
184
184
}
185
185
186
- impl < ' a > ElfSection < ' a > {
186
+ impl ElfSection < ' _ > {
187
187
/// Get the section type as a `ElfSectionType` enum variant.
188
188
#[ must_use]
189
189
pub fn section_type ( & self ) -> ElfSectionType {
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ pub enum FramebufferType<'a> {
319
319
Text ,
320
320
}
321
321
322
- impl < ' a > FramebufferType < ' a > {
322
+ impl FramebufferType < ' _ > {
323
323
#[ must_use]
324
324
#[ cfg( feature = "builder" ) ]
325
325
const fn id ( & self ) -> FramebufferTypeId {
Original file line number Diff line number Diff line change @@ -455,13 +455,13 @@ impl<'a> Iterator for EFIMemoryAreaIter<'a> {
455
455
}
456
456
}
457
457
458
- impl < ' a > ExactSizeIterator for EFIMemoryAreaIter < ' a > {
458
+ impl ExactSizeIterator for EFIMemoryAreaIter < ' _ > {
459
459
fn len ( & self ) -> usize {
460
460
self . entries
461
461
}
462
462
}
463
463
464
- impl < ' a > Debug for EFIMemoryAreaIter < ' a > {
464
+ impl Debug for EFIMemoryAreaIter < ' _ > {
465
465
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> core:: fmt:: Result {
466
466
let mut debug = f. debug_list ( ) ;
467
467
let iter = self . clone ( ) ;
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ impl<'a> Iterator for ModuleIter<'a> {
123
123
}
124
124
}
125
125
126
- impl < ' a > Debug for ModuleIter < ' a > {
126
+ impl Debug for ModuleIter < ' _ > {
127
127
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> core:: fmt:: Result {
128
128
let mut list = f. debug_list ( ) ;
129
129
self . clone ( ) . for_each ( |tag| {
You can’t perform that action at this time.
0 commit comments