blob: dc75cf9cc81f9e26f8e3b16f69b09e41c35b8114 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
*
* 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/examples/hello_world_multicore/hello_world_multicore_sc_loaders.h"
#include "sw/device/lib/arch/device.h"
#include "sw/device/lib/dif/dif_smc_ctrl.h"
#include "sw/device/lib/dif/dif_uart.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"
/*
* Sample program to run some code on all cores in the system.
* SC - Orchestrate the other cores, print status to UART.
* SMC - Print to UART.
* Kelvin - Add 1 to all words in a fixed block of memory.
*/
OTTF_DEFINE_TEST_CONFIG();
static dif_smc_ctrl_t smc_ctrl;
static dif_uart_t uart;
void _ottf_main(void) {
test_status_set(kTestStatusInTest);
init_uart(TOP_MATCHA_UART0_BASE_ADDR, &uart);
LOG_INFO("hello_world_multicore_sc");
// Do any initialization needed before loading SMC and Kelvin.
load_init();
// Copy binary to SMC RAM.
load_smc();
mmio_region_t ml_dmem =
mmio_region_from_addr(TOP_MATCHA_ML_TOP_DMEM_BASE_ADDR);
// Fill the memory with zeroes.
for (int i = 0; i < TOP_MATCHA_ML_TOP_DMEM_SIZE_BYTES / sizeof(uint32_t);
++i) {
mmio_region_write32(ml_dmem, i * sizeof(uint32_t), 0);
}
// Copy binary to ML_DMEM.
load_kelvin();
// Enable SMC.
CHECK_DIF_OK(dif_smc_ctrl_init(
mmio_region_from_addr(TOP_MATCHA_SMC_CTRL_BASE_ADDR), &smc_ctrl));
CHECK_DIF_OK(dif_smc_ctrl_set_en(&smc_ctrl));
asm volatile("wfi");
}