* Add methods to mask and clear interrupts. * Start on GICv3 driver. * Enable and use RTC interrupt. * WFI * Add newtype for interrupt ID. * Add extension to use interrupt. * Add method to send an SGI. * Silence warnings about unused methods in provided drivers. * Implement Debug manually for IntId. It's useful to say what kind of interrupt it is. * Acknowledge and log interrupt. We should end it as well, but doing so results in a loop unless we first clear the match. * cargo fmt with imports_granularity = "module" * Use arm-gic crate rather than including driver in the example.
2.6 KiB
RTC driver
The QEMU aarch64 virt machine has a PL031 real-time clock at 0x9010000. For this exercise, you should write a driver for it.
- Use it to print the current time to the serial console. You can use the
chrono
crate for date/time formatting. - Use the match register and raw interrupt status to busy-wait until a given time, e.g. 3 seconds
in the future. (Call
core::hint::spin_loop
inside the loop.) - Extension if you have time: Enable and handle the interrupt generated by the RTC match. You can
use the driver provided in the
arm-gic
crate to configure the Arm Generic Interrupt Controller.
Download the exercise template and look in the rtc
directory for the following files.
src/main.rs
:
{{#include rtc/src/main.rs:top}}
{{#include rtc/src/main.rs:imports}}
{{#include rtc/src/main.rs:main}}
// TODO: Initialise RTC and print value.
// TODO: Wait for 3 seconds.
{{#include rtc/src/main.rs:main_end}}
src/exceptions.rs
(you should only need to change this for the 3rd part of the exercise):
{{#include rtc/src/exceptions.rs}}
src/logger.rs
(you shouldn't need to change this):
{{#include rtc/src/logger.rs}}
src/pl011.rs
(you shouldn't need to change this):
{{#include rtc/src/pl011.rs}}
Cargo.toml
(you shouldn't need to change this):
{{#include rtc/Cargo.toml}}
build.rs
(you shouldn't need to change this):
{{#include rtc/build.rs}}
entry.S
(you shouldn't need to change this):
{{#include rtc/entry.S}}
exceptions.S
(you shouldn't need to change this):
{{#include rtc/exceptions.S}}
idmap.S
(you shouldn't need to change this):
{{#include rtc/idmap.S}}
image.ld
(you shouldn't need to change this):
{{#include rtc/image.ld}}
Makefile
(you shouldn't need to change this):
{{#include rtc/Makefile}}
.cargo/config.toml
(you shouldn't need to change this):
{{#include rtc/.cargo/config.toml}}
Run the code in QEMU with make qemu
.