@@ -135,6 +135,42 @@ pub enum MbiLoadError {
135
135
#[ cfg( feature = "unstable" ) ]
136
136
impl core:: error:: Error for MbiLoadError { }
137
137
138
+ #[ repr( C , align( 8 ) ) ]
139
+ struct BootInformationInner {
140
+ total_size : u32 ,
141
+ _reserved : u32 ,
142
+ // followed by various, dynamically sized multiboot2 tags
143
+ tags : [ Tag ; 0 ] ,
144
+ }
145
+
146
+ impl BootInformationInner {
147
+ #[ cfg( feature = "builder" ) ]
148
+ fn new ( total_size : u32 ) -> Self {
149
+ Self {
150
+ total_size,
151
+ _reserved : 0 ,
152
+ tags : [ ] ,
153
+ }
154
+ }
155
+
156
+ fn has_valid_end_tag ( & self ) -> bool {
157
+ let end_tag_prototype = EndTag :: default ( ) ;
158
+
159
+ let self_ptr = self as * const _ ;
160
+ let end_tag_addr = self_ptr as usize + ( self . total_size - end_tag_prototype. size ) as usize ;
161
+ let end_tag = unsafe { & * ( end_tag_addr as * const Tag ) } ;
162
+
163
+ end_tag. typ == end_tag_prototype. typ && end_tag. size == end_tag_prototype. size
164
+ }
165
+ }
166
+
167
+ #[ cfg( feature = "builder" ) ]
168
+ impl StructAsBytes for BootInformationInner {
169
+ fn byte_size ( & self ) -> usize {
170
+ core:: mem:: size_of :: < Self > ( )
171
+ }
172
+ }
173
+
138
174
/// A Multiboot 2 Boot Information (MBI) accessor.
139
175
#[ repr( transparent) ]
140
176
pub struct BootInformation < ' a > ( & ' a BootInformationInner ) ;
@@ -185,35 +221,7 @@ impl BootInformation<'_> {
185
221
186
222
Ok ( Self ( mbi) )
187
223
}
188
- }
189
-
190
- #[ repr( C , align( 8 ) ) ]
191
- struct BootInformationInner {
192
- total_size : u32 ,
193
- _reserved : u32 ,
194
- // followed by various, dynamically sized multiboot2 tags
195
- tags : [ Tag ; 0 ] ,
196
- }
197
-
198
- impl BootInformationInner {
199
- #[ cfg( feature = "builder" ) ]
200
- fn new ( total_size : u32 ) -> Self {
201
- Self {
202
- total_size,
203
- _reserved : 0 ,
204
- tags : [ ] ,
205
- }
206
- }
207
- }
208
224
209
- #[ cfg( feature = "builder" ) ]
210
- impl StructAsBytes for BootInformationInner {
211
- fn byte_size ( & self ) -> usize {
212
- core:: mem:: size_of :: < Self > ( )
213
- }
214
- }
215
-
216
- impl BootInformation < ' _ > {
217
225
/// Get the start address of the boot info.
218
226
pub fn start_address ( & self ) -> usize {
219
227
core:: ptr:: addr_of!( * self . 0 ) as usize
@@ -427,18 +435,6 @@ impl BootInformation<'_> {
427
435
}
428
436
}
429
437
430
- impl BootInformationInner {
431
- fn has_valid_end_tag ( & self ) -> bool {
432
- let end_tag_prototype = EndTag :: default ( ) ;
433
-
434
- let self_ptr = self as * const _ ;
435
- let end_tag_addr = self_ptr as usize + ( self . total_size - end_tag_prototype. size ) as usize ;
436
- let end_tag = unsafe { & * ( end_tag_addr as * const Tag ) } ;
437
-
438
- end_tag. typ == end_tag_prototype. typ && end_tag. size == end_tag_prototype. size
439
- }
440
- }
441
-
442
438
// SAFETY: BootInformation contains a const ptr to memory that is never mutated.
443
439
// Sending this pointer to other threads is sound.
444
440
unsafe impl Send for BootInformation < ' _ > { }
@@ -496,37 +492,6 @@ impl fmt::Debug for BootInformation<'_> {
496
492
}
497
493
}
498
494
499
- pub ( crate ) struct Reader {
500
- pub ( crate ) ptr : * const u8 ,
501
- pub ( crate ) off : usize ,
502
- }
503
-
504
- impl Reader {
505
- pub ( crate ) fn new < T > ( ptr : * const T ) -> Reader {
506
- Reader {
507
- ptr : ptr as * const u8 ,
508
- off : 0 ,
509
- }
510
- }
511
-
512
- pub ( crate ) fn read_u8 ( & mut self ) -> u8 {
513
- self . off += 1 ;
514
- unsafe { * self . ptr . add ( self . off - 1 ) }
515
- }
516
-
517
- pub ( crate ) fn read_u16 ( & mut self ) -> u16 {
518
- self . read_u8 ( ) as u16 | ( self . read_u8 ( ) as u16 ) << 8
519
- }
520
-
521
- pub ( crate ) fn read_u32 ( & mut self ) -> u32 {
522
- self . read_u16 ( ) as u32 | ( self . read_u16 ( ) as u32 ) << 16
523
- }
524
-
525
- pub ( crate ) fn current_address ( & self ) -> usize {
526
- unsafe { self . ptr . add ( self . off ) as usize }
527
- }
528
- }
529
-
530
495
/// A trait to abstract over all sized and unsized tags (DSTs). For sized tags,
531
496
/// this trait does not much. For DSTs, a `TagTrait::dst_size` implementation
532
497
/// must me provided, which returns the right size hint for the dynamically
0 commit comments