Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/platform/aarch64-virt/aarch64-virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#include "drivers/pl011.h"

// Semihosting definitions
#define SEMIHOSTING_SYS_EXIT 0x18
#define ADP_STOPPED_APPLICATION_EXIT 0x20026
extern uintptr_t semihosting_call(uint32_t reason, uintptr_t arg);

long
gicr_base(void)
{
Expand All @@ -22,9 +27,20 @@ board_init_early(void)
printf("ID_AA64MMFR0_EL1 = %lx\n", wut);
}

void
semihosting_exit(uint32_t reason, uint32_t subcode)
{
uint64_t parameters[] = {reason, subcode};

(void)semihosting_call(SEMIHOSTING_SYS_EXIT, (uintptr_t)&parameters);
}

void
reboot(void)
{
semihosting_exit(ADP_STOPPED_APPLICATION_EXIT, 0);
// should not reach here

printf("Reboot not implemented, stalling forever\n");

while(1) {
Expand Down
4 changes: 2 additions & 2 deletions src/platform/aarch64-virt/aarch64-virt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ GDB_PORT ?= 1234
GDB_HOST ?= 127.0.0.1

qemu: ${O}/build.elf
qemu-system-aarch64 -M virt,gic-version=3,virtualization=on -cpu cortex-a57 -nographic -kernel $< -s -S
qemu-system-aarch64 -M virt,gic-version=3,virtualization=on -semihosting -cpu cortex-a57 -nographic -kernel $< -s -S

run: ${O}/build.elf
qemu-system-aarch64 -m 8192 -M virt,gic-version=3 -cpu cortex-a57 -nographic -kernel $<
qemu-system-aarch64 -m 8192 -M virt,gic-version=3 -semihosting -cpu cortex-a57 -nographic -kernel $<

gdb: ${O}/build.elf
${GDB} -ex "target extended-remote ${GDB_HOST}:${GDB_PORT}" -ex "layout asm" -ex "layout regs" -x ${T}/gdb/macros $<
5 changes: 5 additions & 0 deletions src/platform/aarch64-virt/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ putc:
tbnz w2, #5, 1b
str x0, [x1]
ret

.globl semihosting_call
semihosting_call:
hlt #0xf000
ret