File tree Expand file tree Collapse file tree 5 files changed +38
-35
lines changed Expand file tree Collapse file tree 5 files changed +38
-35
lines changed Original file line number Diff line number Diff line change 7575 # check that devs can also use this on Windows.
7676 build_nostd_stable_windows :
7777 name : build no_std (stable) [Windows]
78+ needs : build_stable
7879 uses : ./.github/workflows/_build-rust.yml
7980 with :
8081 runs-on : windows-latest
Original file line number Diff line number Diff line change @@ -98,12 +98,12 @@ pub struct InformationRequestHeaderTagIter<'a> {
9898}
9999
100100impl < ' a > InformationRequestHeaderTagIter < ' a > {
101- fn new ( count : u32 , base_ptr : * const MbiTagTypeId ) -> Self {
101+ const fn new ( count : u32 , base_ptr : * const MbiTagTypeId ) -> Self {
102102 Self {
103103 i : 0 ,
104104 count,
105105 base_ptr,
106- _marker : PhantomData :: default ( ) ,
106+ _marker : PhantomData ,
107107 }
108108 }
109109}
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ mod tests {
162162
163163 #[ test]
164164 fn test_build_eftih64 ( ) {
165- let tag = EFIImageHandle32 :: new ( ADDR . try_into ( ) . unwrap ( ) ) ;
165+ let tag = EFIImageHandle64 :: new ( ADDR . try_into ( ) . unwrap ( ) ) ;
166166 assert_eq ! ( tag. image_handle( ) , ADDR ) ;
167167 }
168168}
Original file line number Diff line number Diff line change 1- use crate :: { Reader , Tag , TagTrait , TagTypeId } ;
1+ use crate :: { Tag , TagTrait , TagTypeId } ;
22
33use core:: fmt:: Debug ;
44use core:: mem:: size_of;
1111 alloc:: boxed:: Box , alloc:: vec:: Vec ,
1212} ;
1313
14+ /// Helper struct to read bytes from a raw pointer and increase the pointer
15+ /// automatically.
16+ struct Reader {
17+ ptr : * const u8 ,
18+ off : usize ,
19+ }
20+
21+ impl Reader {
22+ fn new < T > ( ptr : * const T ) -> Reader {
23+ Reader {
24+ ptr : ptr as * const u8 ,
25+ off : 0 ,
26+ }
27+ }
28+
29+ fn read_u8 ( & mut self ) -> u8 {
30+ self . off += 1 ;
31+ unsafe { * self . ptr . add ( self . off - 1 ) }
32+ }
33+
34+ fn read_u16 ( & mut self ) -> u16 {
35+ self . read_u8 ( ) as u16 | ( self . read_u8 ( ) as u16 ) << 8
36+ }
37+
38+ fn read_u32 ( & mut self ) -> u32 {
39+ self . read_u16 ( ) as u32 | ( self . read_u16 ( ) as u32 ) << 16
40+ }
41+
42+ fn current_address ( & self ) -> usize {
43+ unsafe { self . ptr . add ( self . off ) as usize }
44+ }
45+ }
46+
1447const METADATA_SIZE : usize = size_of :: < TagTypeId > ( )
1548 + 4 * size_of :: < u32 > ( )
1649 + size_of :: < u64 > ( )
Original file line number Diff line number Diff line change @@ -502,37 +502,6 @@ impl fmt::Debug for BootInformation {
502502 }
503503}
504504
505- pub ( crate ) struct Reader {
506- pub ( crate ) ptr : * const u8 ,
507- pub ( crate ) off : usize ,
508- }
509-
510- impl Reader {
511- pub ( crate ) fn new < T > ( ptr : * const T ) -> Reader {
512- Reader {
513- ptr : ptr as * const u8 ,
514- off : 0 ,
515- }
516- }
517-
518- pub ( crate ) fn read_u8 ( & mut self ) -> u8 {
519- self . off += 1 ;
520- unsafe { * self . ptr . add ( self . off - 1 ) }
521- }
522-
523- pub ( crate ) fn read_u16 ( & mut self ) -> u16 {
524- self . read_u8 ( ) as u16 | ( self . read_u8 ( ) as u16 ) << 8
525- }
526-
527- pub ( crate ) fn read_u32 ( & mut self ) -> u32 {
528- self . read_u16 ( ) as u32 | ( self . read_u16 ( ) as u32 ) << 16
529- }
530-
531- pub ( crate ) fn current_address ( & self ) -> usize {
532- unsafe { self . ptr . add ( self . off ) as usize }
533- }
534- }
535-
536505/// A trait to abstract over all sized and unsized tags (DSTs). For sized tags,
537506/// this trait does not much. For DSTs, a `TagTrait::dst_size` implementation
538507/// must me provided, which returns the right size hint for the dynamically
You can’t perform that action at this time.
0 commit comments