Commit 1090f1a6 authored by Damien George's avatar Damien George

shared/runtime/semihosting_arm: Add mp_semihosting_exit.

Signed-off-by: default avatarDamien George <damien@micropython.org>
parent 70a6791b
......@@ -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);
}
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment