77#![ no_std]
88#![ no_main]
99
10- use aarch64_paging:: paging:: Attributes ;
10+ use aarch64_paging:: {
11+ mair:: { Mair , MairAttribute , NormalMemory } ,
12+ paging:: Attributes ,
13+ } ;
1114use aarch64_rt:: { InitialPagetable , entry, initial_pagetable} ;
1215use arm_pl011_uart:: { PL011Registers , Uart , UniqueMmioPointer } ;
1316use core:: { fmt:: Write , panic:: PanicInfo , ptr:: NonNull } ;
@@ -32,16 +35,33 @@ const MEMORY_ATTRIBUTES: Attributes = Attributes::VALID
3235 . union ( Attributes :: ACCESSED )
3336 . union ( Attributes :: NON_GLOBAL ) ;
3437
35- initial_pagetable ! ( {
36- let mut idmap = [ 0 ; 512 ] ;
37- // 1 GiB of device memory.
38- idmap[ 0 ] = DEVICE_ATTRIBUTES . bits( ) ;
39- // 1 GiB of normal memory.
40- idmap[ 1 ] = MEMORY_ATTRIBUTES . bits( ) | 0x40000000 ;
41- // Another 1 GiB of device memory starting at 256 GiB.
42- idmap[ 256 ] = DEVICE_ATTRIBUTES . bits( ) | 0x4000000000 ;
43- InitialPagetable ( idmap)
44- } ) ;
38+ /// Indirect memory attributes to use.
39+ ///
40+ /// These are used for `ATTRIBUTE_INDEX_0` and `ATTRIBUTE_INDEX_1` in `DEVICE_ATTRIBUTES` and
41+ /// `MEMORY_ATTRIBUTES` respectively.
42+ const MAIR : Mair = Mair :: EMPTY
43+ . with_attribute ( 0 , MairAttribute :: DEVICE_NGNRE )
44+ . with_attribute (
45+ 1 ,
46+ MairAttribute :: normal (
47+ NormalMemory :: WriteBackNonTransientReadWriteAllocate ,
48+ NormalMemory :: WriteBackNonTransientReadWriteAllocate ,
49+ ) ,
50+ ) ;
51+
52+ initial_pagetable ! (
53+ {
54+ let mut idmap = [ 0 ; 512 ] ;
55+ // 1 GiB of device memory.
56+ idmap[ 0 ] = DEVICE_ATTRIBUTES . bits( ) ;
57+ // 1 GiB of normal memory.
58+ idmap[ 1 ] = MEMORY_ATTRIBUTES . bits( ) | 0x40000000 ;
59+ // Another 1 GiB of device memory starting at 256 GiB.
60+ idmap[ 256 ] = DEVICE_ATTRIBUTES . bits( ) | 0x4000000000 ;
61+ InitialPagetable ( idmap)
62+ } ,
63+ MAIR . 0
64+ ) ;
4565
4666entry ! ( main) ;
4767fn main ( arg0 : u64 , arg1 : u64 , arg2 : u64 , arg3 : u64 ) -> ! {
0 commit comments