Skip to content

Commit

Permalink
Simulator exit test added
Browse files Browse the repository at this point in the history
  • Loading branch information
marnovandermaas committed Jan 17, 2025
1 parent 5217912 commit a9d126f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions sw/cheri/checks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions sw/cheri/checks/uart_simexit_check.cc
Original file line number Diff line number Diff line change
@@ -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 <stdint.h>

// clang-format off
#include "../../common/defs.h"
#include <cheri.hh>
// clang-format on
#include <platform-uart.hh>
#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<void> root{rwRoot};

// Create a bounded capability to the UART
Capability<volatile OpenTitanUart> uart = root.cast<volatile OpenTitanUart>();
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);
}

0 comments on commit a9d126f

Please sign in to comment.