@@ -18,7 +18,7 @@ pub struct MemoryMapTag {
18
18
size : u32 ,
19
19
entry_size : u32 ,
20
20
entry_version : u32 ,
21
- first_area : MemoryArea ,
21
+ first_area : [ MemoryArea ; 0 ] ,
22
22
}
23
23
24
24
impl MemoryMapTag {
@@ -31,10 +31,13 @@ impl MemoryMapTag {
31
31
/// Return an iterator over all marked memory areas.
32
32
pub fn all_memory_areas ( & self ) -> impl Iterator < Item = & MemoryArea > {
33
33
let self_ptr = self as * const MemoryMapTag ;
34
- let start_area = ( & self . first_area ) as * const MemoryArea ;
34
+ let start_area = self . first_area . as_ptr ( ) ;
35
+
35
36
MemoryAreaIter {
36
37
current_area : start_area as u64 ,
37
- last_area : ( self_ptr as u64 + ( self . size - self . entry_size ) as u64 ) ,
38
+ // NOTE: `last_area` is only a bound, it doesn't necessarily point exactly to the last element
39
+ last_area : ( self_ptr as u64
40
+ + ( self . size as u64 - core:: mem:: size_of :: < MemoryMapTag > ( ) as u64 ) ) ,
38
41
entry_size : self . entry_size ,
39
42
phantom : PhantomData ,
40
43
}
@@ -127,7 +130,7 @@ pub struct EFIMemoryMapTag {
127
130
size : u32 ,
128
131
desc_size : u32 ,
129
132
desc_version : u32 ,
130
- first_desc : EFIMemoryDesc ,
133
+ first_desc : [ EFIMemoryDesc ; 0 ] ,
131
134
}
132
135
133
136
impl EFIMemoryMapTag {
@@ -137,10 +140,12 @@ impl EFIMemoryMapTag {
137
140
/// available memory areas for tables and such.
138
141
pub fn memory_areas ( & self ) -> EFIMemoryAreaIter {
139
142
let self_ptr = self as * const EFIMemoryMapTag ;
140
- let start_area = ( & self . first_desc ) as * const EFIMemoryDesc ;
143
+ let start_area = self . first_desc . as_ptr ( ) ;
141
144
EFIMemoryAreaIter {
142
145
current_area : start_area as u64 ,
143
- last_area : ( self_ptr as u64 + self . size as u64 ) ,
146
+ // NOTE: `last_area` is only a bound, it doesn't necessarily point exactly to the last element
147
+ last_area : ( self_ptr as u64
148
+ + ( self . size as u64 - core:: mem:: size_of :: < EFIMemoryMapTag > ( ) as u64 ) ) ,
144
149
entry_size : self . desc_size ,
145
150
phantom : PhantomData ,
146
151
}
0 commit comments