I wrote something similar a while ago: https://github.com/boricj/hang-os
It handles interrupts/traps and targets the aarch64 QEMU virt platform. It also features a HAL.