@@ -29,8 +29,8 @@ use core::hint::spin_loop;
2929// ANCHOR: imports
3030use aarch64_paging:: paging:: Attributes ;
3131use aarch64_rt:: { InitialPagetable , entry, initial_pagetable} ;
32- use arm_gic:: gicv3:: GicV3 ;
3332use arm_gic:: gicv3:: registers:: { Gicd , GicrSgi } ;
33+ use arm_gic:: gicv3:: { GicCpuInterface , GicV3 } ;
3434use arm_pl011_uart:: { PL011Registers , Uart , UniqueMmioPointer } ;
3535use core:: panic:: PanicInfo ;
3636use core:: ptr:: NonNull ;
@@ -39,8 +39,8 @@ use smccc::Hvc;
3939use smccc:: psci:: system_off;
4040
4141/// Base addresses of the GICv3.
42- const GICD_BASE_ADDRESS : * mut Gicd = 0x800_0000 as _ ;
43- const GICR_BASE_ADDRESS : * mut GicrSgi = 0x80A_0000 as _ ;
42+ const GICD_BASE_ADDRESS : NonNull < Gicd > = NonNull :: new ( 0x800_0000 as _ ) . unwrap ( ) ;
43+ const GICR_BASE_ADDRESS : NonNull < GicrSgi > = NonNull :: new ( 0x80A_0000 as _ ) . unwrap ( ) ;
4444
4545/// Base address of the primary PL011 UART.
4646const PL011_BASE_ADDRESS : NonNull < PL011Registers > =
@@ -90,8 +90,14 @@ fn main(x0: u64, x1: u64, x2: u64, x3: u64) -> ! {
9090 // SAFETY: `GICD_BASE_ADDRESS` and `GICR_BASE_ADDRESS` are the base
9191 // addresses of a GICv3 distributor and redistributor respectively, and
9292 // nothing else accesses those address ranges.
93- let mut gic =
94- unsafe { GicV3 :: new ( GICD_BASE_ADDRESS , GICR_BASE_ADDRESS , 1 , false ) } ;
93+ let mut gic = unsafe {
94+ GicV3 :: new (
95+ UniqueMmioPointer :: new ( GICD_BASE_ADDRESS ) ,
96+ GICR_BASE_ADDRESS ,
97+ 1 ,
98+ false ,
99+ )
100+ } ;
95101 gic. setup ( 0 ) ;
96102 // ANCHOR_END: main
97103
@@ -102,11 +108,11 @@ fn main(x0: u64, x1: u64, x2: u64, x3: u64) -> ! {
102108 let time = Utc . timestamp_opt ( timestamp. into ( ) , 0 ) . unwrap ( ) ;
103109 info ! ( "RTC: {time}" ) ;
104110
105- GicV3 :: set_priority_mask ( 0xff ) ;
106- gic. set_interrupt_priority ( PL031_IRQ , None , 0x80 ) ;
107- gic. set_trigger ( PL031_IRQ , None , Trigger :: Level ) ;
111+ GicCpuInterface :: set_priority_mask ( 0xff ) ;
112+ gic. set_interrupt_priority ( PL031_IRQ , None , 0x80 ) . unwrap ( ) ;
113+ gic. set_trigger ( PL031_IRQ , None , Trigger :: Level ) . unwrap ( ) ;
108114 irq_enable ( ) ;
109- gic. enable_interrupt ( PL031_IRQ , None , true ) ;
115+ gic. enable_interrupt ( PL031_IRQ , None , true ) . unwrap ( ) ;
110116
111117 // Wait for 3 seconds, without interrupts.
112118 let target = timestamp + 3 ;
0 commit comments