10 #include "dt/dt_rstmgr.h"
11 #include "dt/dt_rv_core_ibex.h"
12 #include "external/freertos/include/FreeRTOS.h"
13 #include "external/freertos/include/queue.h"
14 #include "external/freertos/include/task.h"
20 #include "sw/device/lib/dif/dif_rv_core_ibex.h"
24 #include "sw/device/lib/testing/rand_testutils.h"
25 #include "sw/device/lib/testing/test_framework/FreeRTOSConfig.h"
26 #include "sw/device/lib/testing/test_framework/check.h"
27 #include "sw/device/lib/testing/test_framework/coverage.h"
28 #include "sw/device/lib/testing/test_framework/ottf_console.h"
29 #include "sw/device/lib/testing/test_framework/ottf_isrs.h"
30 #include "sw/device/lib/testing/test_framework/ottf_test_config.h"
31 #include "sw/device/lib/testing/test_framework/status.h"
32 #include "sw/device/silicon_creator/lib/manifest_def.h"
34 #define MODULE_ID MAKE_MODULE_ID('o', 't', 'm')
44 extern void *pxCurrentTCB;
51 void ottf_machine_ecall_handler(uint32_t *exc_info) {
52 if (pxCurrentTCB != NULL) {
60 "OTTF currently only supports use of machine-mode ecall for FreeRTOS "
61 "context switching.");
65 configSTACK_DEPTH_TYPE task_stack_depth,
66 uint32_t task_priority) {
67 return xTaskCreate(task_function, task_name,
68 task_stack_depth, NULL,
69 tskIDLE_PRIORITY + 1 + task_priority,
80 return pcTaskGetName(NULL);
90 extern const size_t kStatusReportListSize;
91 extern status_t status_report_list[];
95 static size_t status_report_list_cnt = 0;
100 status_report_list[status_report_list_cnt % kStatusReportListSize] =
status;
101 status_report_list_cnt++;
104 static void report_test_status(
bool result) {
110 if (!kOttfTestConfig.silence_console_prints) {
118 LOG_INFO(
"Status reported by the test:");
120 size_t print_cnt = status_report_list_cnt;
121 if (status_report_list_cnt > kStatusReportListSize) {
122 print_cnt = kStatusReportListSize;
125 for (
size_t i = 1; i <= print_cnt; i++) {
126 size_t idx = (status_report_list_cnt - i) % kStatusReportListSize;
127 LOG_INFO(
"- %r", status_report_list[idx]);
130 if (status_report_list_cnt > kStatusReportListSize) {
132 "Some statuses have been lost due to the limited size of the list.");
136 coverage_send_buffer();
137 test_status_set(result ? kTestStatusPassed : kTestStatusFailed);
143 static void test_wrapper(
void *task_parameters) {
148 report_test_status(result);
151 void _ottf_main(
void) {
152 test_status_set(kTestStatusInTest);
156 CHECK_DIF_OK(dif_rstmgr_init_from_dt(kDtRstmgrAon, &rstmgr));
163 CHECK_DIF_OK(dif_rv_plic_init_from_dt(kDtRvPlic, &ottf_plic));
168 if (!kOttfTestConfig.silence_console_prints) {
175 dif_rv_core_ibex_t rv_core_ibex;
176 CHECK_DIF_OK(dif_rv_core_ibex_init_from_dt(kDtRvCoreIbex, &rv_core_ibex));
177 rand_testutils_rng_ctx = rand_testutils_init(&rv_core_ibex);
185 vTaskStartScheduler();
196 #define OTTF_STATUS_REPORT_DEFAULT_LIST_SIZE 10
197 OT_WEAK const size_t kStatusReportListSize =
198 OTTF_STATUS_REPORT_DEFAULT_LIST_SIZE;
199 OT_WEAK status_t status_report_list[OTTF_STATUS_REPORT_DEFAULT_LIST_SIZE];