Browse Source

shared/runtime/semihosting_arm: Add mp_semihosting_exit.

Signed-off-by: Damien George <damien@micropython.org>
pull/15624/head
Damien George 3 months ago
parent
commit
1090f1a60c
  1. 8
      shared/runtime/semihosting_arm.c
  2. 1
      shared/runtime/semihosting_arm.h

8
shared/runtime/semihosting_arm.c

@ -36,6 +36,7 @@
#define SYS_WRITE 0x05
#define SYS_READ 0x06
#define SYS_READC 0x07
#define SYS_EXIT 0x18
// Constants:
#define OPEN_MODE_READ (0) // mode "r"
@ -88,6 +89,13 @@ void mp_semihosting_init() {
mp_semihosting_stdout = mp_semihosting_open_console(OPEN_MODE_WRITE);
}
void mp_semihosting_exit(int status) {
if (status == 0) {
status = 0x20026;
}
mp_semihosting_call(SYS_EXIT, (void *)(uintptr_t)status);
}
int mp_semihosting_rx_char() {
return mp_semihosting_call(SYS_READC, NULL);
}

1
shared/runtime/semihosting_arm.h

@ -46,6 +46,7 @@ If mp_semihosting_rx_char() doesn't work then try mp_semihosting_rx_chars(str, 1
#include <stdint.h>
void mp_semihosting_init();
void mp_semihosting_exit(int status);
int mp_semihosting_rx_char();
int mp_semihosting_rx_chars(char *str, size_t len);
uint32_t mp_semihosting_tx_strn(const char *str, size_t len);

Loading…
Cancel
Save