Compare commits
6 Commits
bf0e4ec057
...
328a961276
| Author | SHA1 | Date | |
|---|---|---|---|
| 328a961276 | |||
| 6e2607cecc | |||
| fced281870 | |||
| 703fbf67b4 | |||
| 59d0a22738 | |||
| 3df19468e9 |
@@ -4,6 +4,7 @@ include(CheckLinkerFlag)
|
|||||||
project(mnrs-bsp LANGUAGES ASM C)
|
project(mnrs-bsp LANGUAGES ASM C)
|
||||||
set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/env/${BOARD}/link.lds"
|
set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/env/${BOARD}/link.lds"
|
||||||
CACHE FILEPATH "Linker script to use for BSP linking")
|
CACHE FILEPATH "Linker script to use for BSP linking")
|
||||||
|
get_filename_component(LINKER_SCRIPT_DIR "${LINKER_SCRIPT}" DIRECTORY)
|
||||||
set(BSP_STARTUP "${CMAKE_CURRENT_SOURCE_DIR}/env/start.S"
|
set(BSP_STARTUP "${CMAKE_CURRENT_SOURCE_DIR}/env/start.S"
|
||||||
CACHE FILEPATH "Path to the BSP startup assembly file")
|
CACHE FILEPATH "Path to the BSP startup assembly file")
|
||||||
set(BSP_TRAP_HANDLER "${CMAKE_CURRENT_SOURCE_DIR}/env/entry.S"
|
set(BSP_TRAP_HANDLER "${CMAKE_CURRENT_SOURCE_DIR}/env/entry.S"
|
||||||
@@ -38,7 +39,7 @@ check_linker_flag(C "LINKER:--no-warn-rwx-segments" HAS_NO_WARN_RWX_SEGMENTS)
|
|||||||
if(HAS_NO_WARN_RWX_SEGMENTS)
|
if(HAS_NO_WARN_RWX_SEGMENTS)
|
||||||
target_link_options(bsp INTERFACE LINKER:--no-warn-rwx-segments)
|
target_link_options(bsp INTERFACE LINKER:--no-warn-rwx-segments)
|
||||||
endif()
|
endif()
|
||||||
target_link_options(bsp INTERFACE LINKER: -nostartfiles -T ${LINKER_SCRIPT})
|
target_link_options(bsp INTERFACE LINKER: -nostartfiles -T ${LINKER_SCRIPT} -L${LINKER_SCRIPT_DIR})
|
||||||
|
|
||||||
if(SEMIHOSTING)
|
if(SEMIHOSTING)
|
||||||
target_include_directories(bsp INTERFACE include)
|
target_include_directories(bsp INTERFACE include)
|
||||||
|
|||||||
2
env/riscv_vp/memory_map.ld
vendored
2
env/riscv_vp/memory_map.ld
vendored
@@ -1,7 +1,7 @@
|
|||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
ram (wxa!ri) : ORIGIN = 0x00000000, LENGTH = 128K
|
ram (wxa!ri) : ORIGIN = 0x00000000, LENGTH = 128K
|
||||||
rom (rxai!w) : ORIGIN = 0x1000E000, LENGTH = 2k
|
rom (rxai!w) : ORIGIN = 0x10080000, LENGTH = 8k
|
||||||
flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 16M
|
flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 16M
|
||||||
dram (wxa!ri) : ORIGIN = 0x40000000, LENGTH = 2048M
|
dram (wxa!ri) : ORIGIN = 0x40000000, LENGTH = 2048M
|
||||||
}
|
}
|
||||||
|
|||||||
3
env/riscv_vp/platform.h
vendored
3
env/riscv_vp/platform.h
vendored
@@ -21,10 +21,11 @@
|
|||||||
#include "minres/devices/qspi.h"
|
#include "minres/devices/qspi.h"
|
||||||
#include "minres/devices/timer.h"
|
#include "minres/devices/timer.h"
|
||||||
#include "minres/devices/uart.h"
|
#include "minres/devices/uart.h"
|
||||||
|
#include <riscv/riscv_csr.h>
|
||||||
|
|
||||||
#define PERIPH(TYPE, ADDR) ((volatile TYPE*)(ADDR))
|
#define PERIPH(TYPE, ADDR) ((volatile TYPE*)(ADDR))
|
||||||
// values from memory_map.ld
|
// values from memory_map.ld
|
||||||
#define XIP_START_LOC 0x30000000
|
#define XIP_START_LOC 0x20000000
|
||||||
#define RAM_START_LOC 0x00000000
|
#define RAM_START_LOC 0x00000000
|
||||||
#define APB_BASE 0x10000000
|
#define APB_BASE 0x10000000
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,36 @@
|
|||||||
#ifndef _DEVICES_ACLINT_H
|
#ifndef _DEVICES_ACLINT_H
|
||||||
#define _DEVICES_ACLINT_H
|
#define _DEVICES_ACLINT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "gen/aclint.h"
|
#include "gen/aclint.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
static void set_aclint_mtime(volatile aclint_t* reg, uint64_t value) {
|
||||||
static void set_aclint_mtime(volatile aclint_t* reg, uint64_t value){
|
|
||||||
set_aclint_mtime_hi(reg, (uint32_t)(value >> 32));
|
set_aclint_mtime_hi(reg, (uint32_t)(value >> 32));
|
||||||
set_aclint_mtime_lo(reg, (uint32_t)value);
|
set_aclint_mtime_lo(reg, (uint32_t)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t get_aclint_mtime(volatile aclint_t* reg){
|
static uint64_t get_aclint_mtime(volatile aclint_t* reg) {
|
||||||
uint64_t value = ((uint64_t)get_aclint_mtime_hi(reg) << 32) | (uint64_t)get_aclint_mtime_lo(reg);
|
// #if ( __riscv_xlen == 64)
|
||||||
return value;
|
// volatile uint64_t *mtime = (volatile uint64_t *)(RISCV_MTIME_ADDR);
|
||||||
|
// return *mtime;
|
||||||
|
// #else
|
||||||
|
uint32_t mtimeh_val;
|
||||||
|
uint32_t mtimel_val;
|
||||||
|
do {
|
||||||
|
mtimeh_val = get_aclint_mtime_hi(reg);
|
||||||
|
mtimel_val = get_aclint_mtime_lo(reg);
|
||||||
|
} while(mtimeh_val != get_aclint_mtime_hi(reg));
|
||||||
|
return (uint64_t)((((uint64_t)mtimeh_val) << 32) | mtimel_val);
|
||||||
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_aclint_mtimecmp(volatile aclint_t* reg, uint64_t value){
|
static void set_aclint_mtimecmp(volatile aclint_t* reg, uint64_t value) {
|
||||||
set_aclint_mtimecmp0lo(reg, (uint32_t)0xFFFFFFFF);
|
set_aclint_mtimecmp0lo(reg, (uint32_t)0xFFFFFFFF);
|
||||||
set_aclint_mtimecmp0hi(reg, (uint32_t)(value >> 32));
|
set_aclint_mtimecmp0hi(reg, (uint32_t)(value >> 32));
|
||||||
set_aclint_mtimecmp0lo(reg, (uint32_t)value);
|
set_aclint_mtimecmp0lo(reg, (uint32_t)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t get_aclint_mtimecmp(volatile aclint_t* reg){
|
static uint64_t get_aclint_mtimecmp(volatile aclint_t* reg) {
|
||||||
uint64_t value = ((uint64_t)get_aclint_mtimecmp0hi(reg) << 32) | (uint64_t)get_aclint_mtimecmp0lo(reg);
|
uint64_t value = ((uint64_t)get_aclint_mtimecmp0hi(reg) << 32) | (uint64_t)get_aclint_mtimecmp0lo(reg);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
3790
include/riscv/riscv_csr.h
Normal file
3790
include/riscv/riscv_csr.h
Normal file
File diff suppressed because it is too large
Load Diff
13609
include/riscv/riscv_csr.hpp
Normal file
13609
include/riscv/riscv_csr.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,9 +5,11 @@
|
|||||||
extern ssize_t _bsp_write(int, const void*, size_t);
|
extern ssize_t _bsp_write(int, const void*, size_t);
|
||||||
|
|
||||||
int __wrap_puts(const char* s) {
|
int __wrap_puts(const char* s) {
|
||||||
const char* str = s;
|
if(!s) return -1;
|
||||||
while(*str)
|
const char* str = s;
|
||||||
str++;
|
while(*str)
|
||||||
return _bsp_write(STDOUT_FILENO, s, str - s);
|
++str;
|
||||||
|
*(char*)str='\n';
|
||||||
|
return _bsp_write(STDOUT_FILENO, s, (str - s)+1);
|
||||||
}
|
}
|
||||||
weak_under_alias(puts);
|
weak_under_alias(puts);
|
||||||
|
|||||||
Reference in New Issue
Block a user