File tree Expand file tree Collapse file tree 4 files changed +36
-33
lines changed Expand file tree Collapse file tree 4 files changed +36
-33
lines changed Original file line number Diff line number Diff line change 75
75
# check that devs can also use this on Windows.
76
76
build_nostd_stable_windows :
77
77
name : build no_std (stable) [Windows]
78
+ needs : build_stable
78
79
uses : ./.github/workflows/_build-rust.yml
79
80
with :
80
81
runs-on : windows-latest
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ mod tests {
162
162
163
163
#[ test]
164
164
fn test_build_eftih64 ( ) {
165
- let tag = EFIImageHandle32 :: new ( ADDR . try_into ( ) . unwrap ( ) ) ;
165
+ let tag = EFIImageHandle64 :: new ( ADDR . try_into ( ) . unwrap ( ) ) ;
166
166
assert_eq ! ( tag. image_handle( ) , ADDR ) ;
167
167
}
168
168
}
Original file line number Diff line number Diff line change 1
- use crate :: { Reader , Tag , TagTrait , TagTypeId } ;
1
+ use crate :: { Tag , TagTrait , TagTypeId } ;
2
2
3
3
use core:: fmt:: Debug ;
4
4
use core:: mem:: size_of;
11
11
alloc:: boxed:: Box , alloc:: vec:: Vec ,
12
12
} ;
13
13
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
+
14
47
const METADATA_SIZE : usize = size_of :: < TagTypeId > ( )
15
48
+ 4 * size_of :: < u32 > ( )
16
49
+ size_of :: < u64 > ( )
Original file line number Diff line number Diff line change @@ -502,37 +502,6 @@ impl fmt::Debug for BootInformation {
502
502
}
503
503
}
504
504
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
-
536
505
/// A trait to abstract over all sized and unsized tags (DSTs). For sized tags,
537
506
/// this trait does not much. For DSTs, a `TagTrait::dst_size` implementation
538
507
/// must me provided, which returns the right size hint for the dynamically
You can’t perform that action at this time.
0 commit comments