diff --git a/sw/cheri/checks/CMakeLists.txt b/sw/cheri/checks/CMakeLists.txt index 52bede39..d80dd557 100644 --- a/sw/cheri/checks/CMakeLists.txt +++ b/sw/cheri/checks/CMakeLists.txt @@ -6,6 +6,7 @@ set(CHECKS gpio_check.cc lcd_check.cc uart_check.cc + uart_simexit_check.cc sdraw_check.cc spi_test.cc system_info_check.cc diff --git a/sw/cheri/checks/uart_simexit_check.cc b/sw/cheri/checks/uart_simexit_check.cc new file mode 100644 index 00000000..44d00e40 --- /dev/null +++ b/sw/cheri/checks/uart_simexit_check.cc @@ -0,0 +1,40 @@ +/** + * Copyright lowRISC contributors. + * Licensed under the Apache License, Version 2.0, see LICENSE for details. + * SPDX-License-Identifier: Apache-2.0 + */ + +#define CHERIOT_NO_AMBIENT_MALLOC +#define CHERIOT_NO_NEW_DELETE +#define CHERIOT_PLATFORM_CUSTOM_UART + +#include + +// clang-format off +#include "../../common/defs.h" +#include +// clang-format on +#include +#include "../common/uart-utils.hh" + +using namespace CHERI; + +/** + * C++ entry point for the loader. This is called from assembly, with the + * read-write root in the first argument. + */ +[[noreturn]] extern "C" void entry_point(void* rwRoot) { + Capability root{rwRoot}; + + // Create a bounded capability to the UART + Capability uart = root.cast(); + uart.address() = UART_ADDRESS; + uart.bounds() = UART_BOUNDS; + + uart->init(BAUD_RATE); + write_str(uart, "Trying out simulation exit!\r\n"); + write_str(uart, "Safe to exit simulator.\xd8\xaf\xfb\xa0\xc7\xe1\xa9\xd7"); + write_str(uart, "This should not be printed.\r\n"); + write_str(uart, "FAIL\r\n"); + while (true); +}