Skip to content

Commit f251d5c

Browse files
committed
Updates for new version of arm-gic.
1 parent 6a493c8 commit f251d5c

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/exercises/bare-metal/rtc/src/exceptions.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use arm_gic::gicv3::{GicV3, InterruptGroup};
15+
use arm_gic::gicv3::{GicCpuInterface, InterruptGroup};
1616
use log::{error, info, trace};
1717
use smccc::Hvc;
1818
use smccc::psci::system_off;
@@ -28,8 +28,9 @@ extern "C" fn sync_exception_current(_elr: u64, _spsr: u64) {
2828
#[unsafe(no_mangle)]
2929
extern "C" fn irq_current(_elr: u64, _spsr: u64) {
3030
trace!("irq_current");
31-
let intid = GicV3::get_and_acknowledge_interrupt(InterruptGroup::Group1)
32-
.expect("No pending interrupt");
31+
let intid =
32+
GicCpuInterface::get_and_acknowledge_interrupt(InterruptGroup::Group1)
33+
.expect("No pending interrupt");
3334
info!("IRQ {intid:?}");
3435
}
3536

src/exercises/bare-metal/rtc/src/main.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use core::hint::spin_loop;
2929
// ANCHOR: imports
3030
use aarch64_paging::paging::Attributes;
3131
use aarch64_rt::{InitialPagetable, entry, initial_pagetable};
32-
use arm_gic::gicv3::GicV3;
3332
use arm_gic::gicv3::registers::{Gicd, GicrSgi};
33+
use arm_gic::gicv3::{GicCpuInterface, GicV3};
3434
use arm_pl011_uart::{PL011Registers, Uart, UniqueMmioPointer};
3535
use core::panic::PanicInfo;
3636
use core::ptr::NonNull;
@@ -39,8 +39,8 @@ use smccc::Hvc;
3939
use 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.
4646
const 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

Comments
 (0)