@@ -170,7 +170,7 @@ impl SectionAttributes {
170
170
/// Retrieves the corresponding L1 section part without the section base address being set.
171
171
const fn l1_section_part ( & self ) -> L1Section {
172
172
L1Section :: builder ( )
173
- . with_base_addr ( u12:: new ( 0 ) )
173
+ . with_base_addr_upper_bits ( u12:: new ( 0 ) )
174
174
. with_ng ( self . non_global )
175
175
. with_s ( self . shareable )
176
176
. with_apx ( self . access . apx ( ) )
@@ -208,9 +208,9 @@ impl SectionAttributes {
208
208
#[ bitbybit:: bitfield( u32 , default = 0x00 ) ]
209
209
#[ derive( PartialEq , Eq ) ]
210
210
pub struct L1Section {
211
- /// Section base address.
211
+ /// Section base address upper bits .
212
212
#[ bits( 20 ..=31 , rw) ]
213
- base_addr : u12 ,
213
+ base_addr_upper_bits : u12 ,
214
214
/// Non-global bit.
215
215
#[ bit( 17 , rw) ]
216
216
ng : bool ,
@@ -243,7 +243,7 @@ impl core::fmt::Debug for L1Section {
243
243
write ! (
244
244
f,
245
245
"L1Section {{ base_addr={:#x} ng={} s={} apx={} tex={:#b} ap={:#b} domain={:#b} xn={} c={} b={} }}" ,
246
- self . base_addr ( ) ,
246
+ self . base_addr_upper_bits ( ) ,
247
247
self . ng( ) as u8 ,
248
248
self . s( ) as u8 ,
249
249
self . apx( ) as u8 ,
@@ -272,8 +272,21 @@ impl L1Section {
272
272
if phys_addr & 0x000F_FFFF != 0 {
273
273
panic ! ( "physical base address for L1 section must be aligned to 1 MB" ) ;
274
274
}
275
- let higher_bits = phys_addr >> 20 ;
276
- Self :: new_with_raw_value ( ( higher_bits << 20 ) | section_attrs. l1_section_part ( ) . raw_value ( ) )
275
+ let attrs = section_attrs. l1_section_part ( ) ;
276
+ L1Section :: builder ( )
277
+ . with_base_addr_upper_bits ( u12:: new ( ( phys_addr >> 20 ) as u16 ) )
278
+ . with_ng ( attrs. ng ( ) )
279
+ . with_s ( attrs. s ( ) )
280
+ . with_apx ( attrs. apx ( ) )
281
+ . with_tex ( attrs. tex ( ) )
282
+ . with_ap ( attrs. ap ( ) )
283
+ . with_p_bit ( attrs. p_bit ( ) )
284
+ . with_domain ( attrs. domain ( ) )
285
+ . with_xn ( attrs. xn ( ) )
286
+ . with_c ( attrs. c ( ) )
287
+ . with_b ( attrs. b ( ) )
288
+ . with_entry_type ( attrs. entry_type ( ) )
289
+ . build ( )
277
290
}
278
291
279
292
/// Retrieve the section attributes.
@@ -285,7 +298,20 @@ impl L1Section {
285
298
/// Set the section attributes without changing the address.
286
299
#[ inline]
287
300
pub fn set_section_attrs ( & mut self , section_attrs : SectionAttributes ) {
288
- self . raw_value =
289
- ( ( self . base_addr ( ) . value ( ) as u32 ) << 20 ) | section_attrs. l1_section_part ( ) . raw_value ( ) ;
301
+ let attrs = section_attrs. l1_section_part ( ) ;
302
+ * self = L1Section :: builder ( )
303
+ . with_base_addr_upper_bits ( self . base_addr_upper_bits ( ) )
304
+ . with_ng ( attrs. ng ( ) )
305
+ . with_s ( attrs. s ( ) )
306
+ . with_apx ( attrs. apx ( ) )
307
+ . with_tex ( attrs. tex ( ) )
308
+ . with_ap ( attrs. ap ( ) )
309
+ . with_p_bit ( attrs. p_bit ( ) )
310
+ . with_domain ( attrs. domain ( ) )
311
+ . with_xn ( attrs. xn ( ) )
312
+ . with_c ( attrs. c ( ) )
313
+ . with_b ( attrs. b ( ) )
314
+ . with_entry_type ( attrs. entry_type ( ) )
315
+ . build ( )
290
316
}
291
317
}
0 commit comments