CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
platform-simulation_exit.hh
1// Copyright Microsoft and CHERIoT Contributors.
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#ifdef SIMULATION
7# include <stdint.h>
8# include <platform-uart.hh>
9# include <string_view>
10
11static void platform_simulation_exit(uint32_t code)
12{
13 auto uart =
14# if DEVICE_EXISTS(uart0)
15 MMIO_CAPABILITY(Uart, uart0);
16# elif DEVICE_EXISTS(uart)
17 MMIO_CAPABILITY(Uart, uart);
18# else
19# error No UART found in platform_simulation_exit
20# endif
21 // Writing the following magic string to the UART will cause the sonata
22 // simulator to exit.
23 const char *magicString =
24 "Safe to exit simulator.\xd8\xaf\xfb\xa0\xc7\xe1\xa9\xd7";
25 while (char ch = *magicString++)
26 {
27 uart->blocking_write(ch);
28 }
29}
30#endif
#define MMIO_CAPABILITY(type, name)
Provide a capability of the type volatile type * referring to the MMIO region exported in the linker ...