remove magic numbers for syscon

This commit is contained in:
Liam Kerr 2026-02-08 22:15:50 +00:00
parent 8cd08165e0
commit fae2e42f8f
2 changed files with 9 additions and 6 deletions

View file

@ -4,11 +4,11 @@
#include "drivers/uart.h" #include "drivers/uart.h"
void poweroff(void) { void poweroff(void) {
kputs("Poweroff requested"); kputs("Poweroff requested");
*(uint32_t *)SYSCON_ADDR = 0x5555; *(volatile uint32_t *)SYSCON_ADDR = SYSCON_POWEROFF;
} }
void reboot(void) { void reboot(void) {
kputs("Reboot requested"); kputs("Reboot requested");
*(uint32_t *)SYSCON_ADDR = 0x7777; *(volatile uint32_t *)SYSCON_ADDR = SYSCON_REBOOT;
} }

View file

@ -1,10 +1,13 @@
#ifndef SYSCON_H #ifndef SYSCON_H
#define SYSCON_H #define SYSCON_H
// "test" syscon-compatible device is at memory-mapped address 0x100000 // QEMU Sifive Test device address
// according to our device tree
#define SYSCON_ADDR 0x100000 #define SYSCON_ADDR 0x100000
// Magic values for the Sifive Test device
#define SYSCON_POWEROFF 0x5555
#define SYSCON_REBOOT 0x7777
void poweroff(void); void poweroff(void);
void reboot(void); void reboot(void);