add test_fw
This commit is contained in:
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"]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
45
test_fw/test_fw.c
Normal file
45
test_fw/test_fw.c
Normal file
@@ -0,0 +1,45 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "encoding.h"
|
||||
#include <string.h>
|
||||
|
||||
extern void _init();
|
||||
int main() {
|
||||
//board_init();
|
||||
_init();
|
||||
puts("after _init");
|
||||
|
||||
// set only MPP
|
||||
__asm__ volatile (
|
||||
"csrs mstatus, %0"
|
||||
:
|
||||
: "r"(MSTATUS_MPP | MSTATUS_MIE)
|
||||
: "memory"
|
||||
);
|
||||
|
||||
puts("after enable MSTATUS_MIE/MPP");
|
||||
/*
|
||||
// enable MIE
|
||||
write_csr(mie,MIE_MTIE | MIE_MSIE | MIE_MEIE);
|
||||
puts("after enable MIE");
|
||||
*/
|
||||
|
||||
uint64_t time = get_aclint_mtime(aclint);
|
||||
printf("in main() get_aclint_mtime return %d \n ",time);
|
||||
set_aclint_mtime(aclint, 9);
|
||||
time = get_aclint_mtime(aclint);
|
||||
printf("in main() get_aclint_mtime after set 9, return %d \n ",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