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# ifdef RISCV_HTIF
9/**
10 * This is a special MMIO register. Writing an LSB of 1 terminates
11 * simulation. The upper 31 bits can pass extra metadata. We use all 0s
12 * to indicates success.
13 *
14 * This symbol doesn't need to be exported. The simulator is clever
15 * enough to find it even if it's local.
16 *
17 * HTIF is more general than our use here, so it's possible that someone else
18 * wants to use it as well, so we mark our symbol as weak.
19 */
20volatile uint32_t tohost[2] __attribute__((weak));
21# endif
22
23static void platform_simulation_exit(uint32_t code)
24{
25# ifdef RISCV_HTIF
26 // If this is using the standard RISC-V to-host mechanism, this will exit.
27 tohost[0] = 0x1 | (code << 1);
28 tohost[1] = 0;
29# endif
30}
31#endif