mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-17 21:22:10 +00:00
feat(core): implement svc shutdown
This commit is contained in:
parent
cca9d4b1c4
commit
4968d7da53
@ -49,6 +49,9 @@
|
||||
#include "supervise.h"
|
||||
#include "touch.h"
|
||||
|
||||
// from util.s
|
||||
extern void shutdown_privileged(void);
|
||||
|
||||
int main(void) {
|
||||
random_delays_init();
|
||||
|
||||
@ -180,6 +183,11 @@ void SVC_C_Handler(uint32_t *stack) {
|
||||
cyccnt_cycles = *DWT_CYCCNT_ADDR;
|
||||
break;
|
||||
#endif
|
||||
case SVC_SHUTDOWN:
|
||||
shutdown_privileged();
|
||||
for (;;)
|
||||
;
|
||||
break;
|
||||
default:
|
||||
stack[0] = 0xffffffff;
|
||||
break;
|
||||
|
@ -3,6 +3,10 @@
|
||||
#define SVC_ENABLE_IRQ 0
|
||||
#define SVC_DISABLE_IRQ 1
|
||||
#define SVC_SET_PRIORITY 2
|
||||
#define SVC_SHUTDOWN 4
|
||||
|
||||
// from util.s
|
||||
extern void shutdown_privileged(void);
|
||||
|
||||
static inline uint32_t is_mode_unprivileged(void) {
|
||||
uint32_t r0;
|
||||
@ -38,3 +42,11 @@ static inline void svc_setpriority(uint32_t IRQn, uint32_t priority) {
|
||||
NVIC_SetPriority(IRQn, priority);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void svc_shutdown(void) {
|
||||
if (is_mode_unprivileged()) {
|
||||
__asm__ __volatile__("svc %0" ::"i"(SVC_SHUTDOWN) : "memory");
|
||||
} else {
|
||||
shutdown_privileged();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user