Compare commits
5 Commits
develop
...
private/ho
| Author | SHA1 | Date | |
|---|---|---|---|
| dd071a3d30 | |||
| 109cc2a7ad | |||
| 89e4d58c9e | |||
| 2d2a64aa7a | |||
| f8fa382b62 |
13
test_fw/CMakeLists.txt
Normal file
13
test_fw/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.21)
|
||||||
|
project(test_fw C)
|
||||||
|
set(TARGET test_fw)
|
||||||
|
add_executable(${TARGET} test_fw.c)
|
||||||
|
|
||||||
|
set(BOARD "iss" CACHE STRING "Target board")
|
||||||
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../bare-metal-bsp bsp)
|
||||||
|
target_link_libraries(${TARGET} PRIVATE bsp)
|
||||||
|
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
||||||
|
COMMENT "Creating disassembly for ${TARGET}")
|
||||||
122
test_fw/CMakePresets.json
Normal file
122
test_fw/CMakePresets.json
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"vendor": {
|
||||||
|
"conan": {}
|
||||||
|
},
|
||||||
|
"cmakeMinimumRequired": {
|
||||||
|
"major": 3,
|
||||||
|
"minor": 24,
|
||||||
|
"patch": 0
|
||||||
|
},
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "32imc",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../bare-metal-bsp/cmake/rv32imc.cmake"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "64imc",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../bare-metal-bsp/cmake/rv64gc.cmake"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "iss",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"BOARD": "iss"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "moonlight",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"BOARD": "moonlight"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "riscv_vp",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"BOARD": "riscv_vp",
|
||||||
|
"LINKER_SCRIPT": "/scratch/hongyu/workarea/Firmwares/bare-metal-bsp/env/riscv_vp/flash.lds"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rtl",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"BOARD": "rtl"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "debug",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ISS_Debug",
|
||||||
|
"inherits": ["iss", "debug", "32imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Moonlight_Debug",
|
||||||
|
"inherits": ["moonlight", "debug", "32imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "riscv_vp_Debug",
|
||||||
|
"inherits": ["riscv_vp", "debug", "32imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ISS_Debug_64",
|
||||||
|
"inherits": ["iss", "debug", "64imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Moonlight_Debug_64",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": ["moonlight", "debug", "64imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "riscv_vp_Debug_64",
|
||||||
|
"inherits": ["riscv_vp", "debug", "64imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ISS_Release",
|
||||||
|
"inherits": ["iss", "release", "32imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Moonlight_Release",
|
||||||
|
"inherits": ["moonlight", "release", "32imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "riscv_vp_Release",
|
||||||
|
"inherits": ["riscv_vp", "release", "32imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ISS_Release_64",
|
||||||
|
"inherits": ["iss", "release", "64imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Moonlight_Release_64",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": ["moonlight", "release", "64imc"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "riscv_vp_Release_64",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": ["riscv_vp", "release", "64imc"]
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
42
test_fw/test_fw.c
Normal file
42
test_fw/test_fw.c
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#include "encoding.h"
|
||||||
|
#include "platform.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void handle_m_time_interrupt() {
|
||||||
|
uint64_t time = get_aclint_mtime(aclint);
|
||||||
|
time += MTIMER_NEXT_TICK_INC;
|
||||||
|
set_aclint_mtimecmp(aclint, time);
|
||||||
|
puts("m_time_irq");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
puts("in main");
|
||||||
|
// avoid getting interrupt upon enabling MIP/MIE_MTI
|
||||||
|
set_aclint_mtimecmp(aclint, 0xffffffffffffffff);
|
||||||
|
// enable global interrupt
|
||||||
|
csr_set_bits_mstatus(MSTATUS_MIE_BIT_MASK);
|
||||||
|
|
||||||
|
puts("after enable MSTATUS_MIE/MPP");
|
||||||
|
// enable MIE
|
||||||
|
csr_set_bits_mie(MIE_MTI_BIT_MASK | MIE_MSI_BIT_MASK | MIE_MEI_BIT_MASK);
|
||||||
|
puts("after enable MIE");
|
||||||
|
|
||||||
|
uint64_t time = get_aclint_mtime(aclint);
|
||||||
|
printf("in main() get_aclint_mtime return %lu \n", (uint32_t)time);
|
||||||
|
set_aclint_mtime(aclint, 9);
|
||||||
|
time = get_aclint_mtime(aclint);
|
||||||
|
printf("in main() get_aclint_mtime after set 9, return %lu \n", (uint32_t)time);
|
||||||
|
|
||||||
|
set_aclint_mtimecmp(aclint, (time + 3));
|
||||||
|
puts("set mtimecmp");
|
||||||
|
|
||||||
|
uint64_t timecmp = get_aclint_mtimecmp(aclint);
|
||||||
|
printf("in main() get_aclint_mtimecmp return %d \n", timecmp);
|
||||||
|
|
||||||
|
puts(" finshed ");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user