src/exercises/bare-metal/rtc.md
The QEMU aarch64 virt machine has a PL031 real-time clock at 0x9010000. For this exercise, you should write a driver for it.
chrono crate for date/time formatting.core::hint::spin_loop inside
the loop.)arm-gic crate to
configure the Arm Generic Interrupt Controller.
IntId::spi(2).arm_gic::wfi(), which will cause the core to sleep until it receives an
interrupt.Download the exercise template and
look in the rtc directory for the following files.
src/main.rs:
<!-- File src/main.rs --> <!-- mdbook-xgettext: skip --># // Copyright 2023 Google LLC
# // SPDX-License-Identifier: Apache-2.0
#
{{#include rtc/src/main.rs:top}}
{{#include rtc/src/main.rs:imports}}
{{#include rtc/src/main.rs:main}}
// TODO: Create instance of RTC driver and print current time.
// 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):
<!-- File src/exceptions.rs --> <!-- mdbook-xgettext: skip --># // Copyright 2023 Google LLC
# // SPDX-License-Identifier: Apache-2.0
#
{{#include rtc/src/exceptions.rs}}
src/logger.rs (you shouldn't need to change this):
<!-- File src/logger.rs --> <!-- mdbook-xgettext: skip --># // Copyright 2023 Google LLC
# // SPDX-License-Identifier: Apache-2.0
#
{{#include rtc/src/logger.rs}}
Cargo.toml (you shouldn't need to change this):
<!-- File Cargo.toml --> <!-- mdbook-xgettext: skip -->{{#include rtc/Cargo.toml}}
build.rs (you shouldn't need to change this):
<!-- File build.rs --> <!-- mdbook-xgettext: skip -->{{#include rtc/build.rs}}
memory.ld (you shouldn't need to change this):
<!-- File memory.ld --> <!-- mdbook-xgettext: skip -->{{#include rtc/memory.ld}}
Makefile (you shouldn't need to change this):
<!-- File Makefile --> <!-- mdbook-xgettext: skip -->{{#include rtc/Makefile}}
.cargo/config.toml (you shouldn't need to change this):
<!-- File .cargo/config.toml --> <!-- mdbook-xgettext: skip -->{{#include rtc/.cargo/config.toml}}
Run the code in QEMU with make qemu.