git-svn-id: http://moon:8086/svn/mips@169 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2021-04-09 12:49:19 +00:00
parent 3a58da33be
commit 8e74d1080e
2 changed files with 30 additions and 17 deletions
+5 -2
View File
@@ -12,7 +12,9 @@ ROMGEN=romgen
FLASHGEN=flashgen
ENDIAN_FLAGS := -EB
CFLAGS := $(ENDIAN_FLAGS) -march=$(TARGET) -L. -T link/link.ld -Wl,--gc-sections -G 0 -O0
INCLUDES := -I libsys/boards/sim
CFLAGS := $(ENDIAN_FLAGS) -march=$(TARGET) -L. -T link/link.ld -Wl,--gc-sections -G 0 -O0 $(INCLUDES)
CFLAGS += -fno-exceptions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostartfiles
LIBS := -lsys -lc
@@ -22,7 +24,8 @@ libsys.a:
$(CC) $(CFLAGS) -c libsys/startup.s -o startup.o
$(CC) $(CFLAGS) -c libsys/kernel.s -o kernel.o
$(CC) $(CFLAGS) -c libsys/utils.c -o utils.o
$(AR) -r libsys.a startup.o kernel.o utils.o
$(CC) $(CFLAGS) -c libsys/boards/sim/board.c -o board.o
$(AR) -r libsys.a startup.o kernel.o utils.o board.o
testbench.elf: libsys.a
+25 -15
View File
@@ -2,31 +2,41 @@
#include <sys/time.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <board.h>
char readchar(void)
{
volatile char *pUART_stat = (char*)0x80000008;
volatile char *pUART_data = (char*)0x80000004;
volatile uint32_t *pUART_stat = (uint32_t*)SYS_UART_STAT;
volatile uint32_t *pUART_data = (uint32_t*)SYS_UART_DATA;
while(!(0x10 & *pUART_stat));
while(!(SYS_UART_BIT_RX_AVAIL & *pUART_stat));
return *pUART_data;
}
void _putchar(char c)
{
if (c == 0x0A)
{
writechar(0x0D);
}
writechar(c);
}
void writechar(char c)
{
volatile char *pUART_stat = (char*)0x80000008;
volatile char *pUART_data = (char*)0x80000004;
volatile uint32_t *pUART_stat = (uint32_t*)SYS_UART_STAT;
volatile uint32_t *pUART_data = (uint32_t*)SYS_UART_DATA;
while((0x02 & *pUART_stat) != 0);
while((SYS_UART_BIT_TX_FULL & *pUART_stat) != 0);
*pUART_data = c;
}
clock_t times(struct tms *buffer)
{
volatile long *pReg_usec = (long*)0x80000010;
volatile long *pReg_sec = (long*)0x80000014;
volatile uint32_t *pReg_usec = (uint32_t*)SYS_TIMER_USEC;
volatile uint32_t *pReg_sec = (uint32_t*)SYS_TIMER_SEC;
long sec;
sec = *pReg_sec;
@@ -44,8 +54,8 @@ clock_t times(struct tms *buffer)
int gettimeofday(struct timeval *tp, void *tzp)
{
volatile long *pReg_usec = (long*)0x80000010;
volatile long *pReg_sec = (long*)0x80000014;
volatile uint32_t *pReg_usec = (uint32_t*)SYS_TIMER_USEC;
volatile uint32_t *pReg_sec = (uint32_t*)SYS_TIMER_SEC;
if (tp)
{
@@ -58,8 +68,8 @@ int gettimeofday(struct timeval *tp, void *tzp)
int settimeofday(const struct timeval *tp, const struct timezone *tzp)
{
volatile long *pReg_usec = (long*)0x80000010;
volatile long *pReg_sec = (long*)0x80000014;
volatile uint32_t *pReg_usec = (uint32_t*)SYS_TIMER_USEC;
volatile uint32_t *pReg_sec = (uint32_t*)SYS_TIMER_SEC;
div_t res;
res = div(tp->tv_usec, 1E6);
@@ -124,7 +134,7 @@ int write(int file, char *ptr, int len)
int i;
for (i=0; i < len; i++)
writechar(*ptr++);
_putchar(*ptr++);
return i;
}
@@ -140,7 +150,7 @@ int sputs(char *pStr)
start = pStr;
while(*pStr)
writechar(*(pStr++));
_putchar(*(pStr++));
return pStr - start;
}
@@ -160,7 +170,7 @@ void print_byte(char byte)
else
c = nibble + 'A' - 10;
writechar(c);
_putchar(c);
}
}