modifies initcode and libwrap for new mnrs/ehrenberg vp

This commit is contained in:
Eyck-Alexander Jentzsch 2024-02-22 17:10:49 +01:00
parent 98760929c6
commit 96fa7db587
5 changed files with 16 additions and 23 deletions

View File

@ -90,10 +90,9 @@ void __attribute__((weak)) handle_m_ext_interrupt(){
} }
void __attribute__((weak)) handle_m_time_interrupt(){ void __attribute__((weak)) handle_m_time_interrupt(){
uint64_t time = ((uint64_t)mtimer->mtimeh)<<32 || mtimer->mtime; uint64_t time = get_aclint_mtime(aclint);
time+=MTIMER_NEXT_TICK_INC; time+=MTIMER_NEXT_TICK_INC;
mtimer->mtimecmph = time>>32; set_aclint_mtime(aclint, time);
mtimer->mtimecmp = time;
} }
void __attribute__((weak)) default_handler(void) { void __attribute__((weak)) default_handler(void) {

View File

@ -10,26 +10,22 @@
#define APB_BUS #define APB_BUS
#include "ehrenberg/devices/gpio.h" #include "ehrenberg/devices/gpio.h"
#include "ehrenberg/devices/interrupt.h"
#include "ehrenberg/devices/timer.h"
#include "ehrenberg/devices/uart.h" #include "ehrenberg/devices/uart.h"
#include "ehrenberg/devices/timer.h"
#include "ehrenberg/devices/aclint.h"
#include "ehrenberg/devices/interrupt.h"
#include "ehrenberg/devices/qspi.h" #include "ehrenberg/devices/qspi.h"
#define PERIPH(TYPE, ADDR) ((volatile TYPE*) (ADDR)) #define PERIPH(TYPE, ADDR) ((volatile TYPE*) (ADDR))
#define APB_BASE 0xF0000000 #define APB_BASE 0xF0000000
#define TIMER_BASE (APB_BASE+0x20000)
#define gpio_a PERIPH(gpio_t, APB_BASE+0x0000) #define gpio PERIPH(gpio_t, APB_BASE+0x0000)
//#define gpio_b PERIPH(gpio_t, APB_BASE+0x10000)
#define uart PERIPH(uart_t, APB_BASE+0x1000) #define uart PERIPH(uart_t, APB_BASE+0x1000)
#define prescaler PERIPH(uart_t, TIMER_BASE+0x0) #define timer PERIPH(timer_t, APB_BASE+0x20000)
#define timer_a PERIPH(uart_t, TIMER_BASE+0x4) #define aclint PERIPH(aclint_t, APB_BASE+0x30000)
#define timer_b PERIPH(uart_t, TIMER_BASE+0x10)
#define mtimer PERIPH(mtimer_t, APB_BASE+0x30000)
#define irq PERIPH(irq_t, APB_BASE+0x40000) #define irq PERIPH(irq_t, APB_BASE+0x40000)
#define qspi PERIPH(qspi_t, APB_BASE+0x50000) #define qspi PERIPH(qspi_t, APB_BASE+0x50000)
//volatile qspi_t* const qspi = (qspi_t*)(APB_BASE+0x50000);
#define XIP_START_LOC 0xE0040000 #define XIP_START_LOC 0xE0040000
@ -40,6 +36,5 @@
void init_pll(void); void init_pll(void);
unsigned long get_cpu_freq(void); unsigned long get_cpu_freq(void);
unsigned long get_timer_freq(void); unsigned long get_timer_freq(void);
uint64_t get_timer_value(void);
#endif /* _ISS_PLATFORM_H */ #endif /* _ISS_PLATFORM_H */

View File

@ -13,7 +13,7 @@ int __wrap_puts(const char *s)
{ {
while (*s != '\0') { while (*s != '\0') {
#if defined(BOARD_ehrenberg) #if defined(BOARD_ehrenberg)
while (uart_get_tx_free(uart)==0) ; while (get_uart_rx_tx_reg_tx_free(uart)==0) ;
uart_write(uart, *s); uart_write(uart, *s);
#elif defined(BOARD_iss) #elif defined(BOARD_iss)
*((uint32_t*) 0xFFFF0000) = *s; *((uint32_t*) 0xFFFF0000) = *s;

View File

@ -29,7 +29,7 @@ ssize_t __wrap_read(int fd, void* ptr, size_t len)
if (isatty(fd)) { if (isatty(fd)) {
#if defined(BOARD_ehrenberg) #if defined(BOARD_ehrenberg)
for (current = (uint8_t *)ptr; for (current = (uint8_t *)ptr;
(current < ((uint8_t *)ptr) + len) && (uart_get_rx_avail(uart) > 0); (current < ((uint8_t *)ptr) + len) && (get_uart_rx_tx_reg_rx_avail(uart) > 0);
current ++) { current ++) {
*current = uart_read(uart); *current = uart_read(uart);
result++; result++;

View File

@ -8,17 +8,16 @@
#include "platform.h" #include "platform.h"
#include "stub.h" #include "stub.h"
#include "weak_under_alias.h" #include "weak_under_alias.h"
ssize_t __wrap_write(int fd, const void* ptr, size_t len) ssize_t __wrap_write(int fd, const void* ptr, size_t len)
{ {
const uint8_t * current = (const uint8_t *)ptr; const uint8_t * current = (const uint8_t *)ptr;
if (isatty(fd)) { if (isatty(fd)) {
for (size_t jj = 0; jj < len; jj++) { for (size_t jj = 0; jj < len; jj++) {
#if defined(BOARD_ehrenberg) #if defined(BOARD_ehrenberg)
while (uart_get_tx_free(uart)==0) ; while (get_uart_rx_tx_reg_tx_free(uart)==0) ;
uart_write(uart, current[jj]); uart_write(uart, current[jj]);
if (current[jj] == '\n') { if (current[jj] == '\n') {
while (uart_get_tx_free(uart)==0) ; while (get_uart_rx_tx_reg_tx_free(uart)==0) ;
uart_write(uart, '\r'); uart_write(uart, '\r');
} }
#elif defined(BOARD_iss) #elif defined(BOARD_iss)