blob: 51fabfac416fefd3d8ea7e3cfa542658f8889cb5 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
* Copyright lowRISC contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "hw/top_matcha/sw/autogen/top_matcha.h"
#include "sw/device/lib/runtime/log.h"
#include "sw/device/lib/runtime/print.h"
#include "sw/device/lib/testing/test_framework/check.h"
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
#include "sw/device/lib/testing/test_framework/status.h"
#include "sw/device/lib/testing/test_framework/test_util.h"
OTTF_DEFINE_TEST_CONFIG();
static dif_uart_t smc_uart;
static void smode_fn(void) { asm volatile("ecall"); }
// Overrides the default supervisor ecall handler.
// From here, we will set the test pass.
void ottf_supervisor_ecall_handler(void) { test_status_set(kTestStatusPassed); }
static __attribute__((naked)) void trampoline(uint32_t smode) {
asm volatile(
".option push\n"
".option norelax\n"
"li x1, 0x00000800\n"
"csrw mstatus, x1\n"
"csrw mepc, a0\n"
"mret\n"
".option pop\n"
:
:
: "memory");
}
void _ottf_main(void) {
test_status_set(kTestStatusInTest);
// Initialize the SMC UART to enable logging for non-DV simulation platforms.
if (kDeviceType != kDeviceSimDV) {
init_uart(TOP_MATCHA_SMC_UART_BASE_ADDR, &smc_uart);
}
LOG_INFO("Hello from the SMC!");
trampoline((uint32_t)smode_fn);
__builtin_unreachable();
}