- fixed
git-svn-id: http://moon:8086/svn/mips@169 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
+5
-2
@@ -12,7 +12,9 @@ ROMGEN=romgen
|
|||||||
FLASHGEN=flashgen
|
FLASHGEN=flashgen
|
||||||
|
|
||||||
ENDIAN_FLAGS := -EB
|
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
|
CFLAGS += -fno-exceptions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostartfiles
|
||||||
LIBS := -lsys -lc
|
LIBS := -lsys -lc
|
||||||
|
|
||||||
@@ -22,7 +24,8 @@ libsys.a:
|
|||||||
$(CC) $(CFLAGS) -c libsys/startup.s -o startup.o
|
$(CC) $(CFLAGS) -c libsys/startup.s -o startup.o
|
||||||
$(CC) $(CFLAGS) -c libsys/kernel.s -o kernel.o
|
$(CC) $(CFLAGS) -c libsys/kernel.s -o kernel.o
|
||||||
$(CC) $(CFLAGS) -c libsys/utils.c -o utils.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
|
testbench.elf: libsys.a
|
||||||
|
|||||||
+25
-15
@@ -2,31 +2,41 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
char readchar(void)
|
char readchar(void)
|
||||||
{
|
{
|
||||||
volatile char *pUART_stat = (char*)0x80000008;
|
volatile uint32_t *pUART_stat = (uint32_t*)SYS_UART_STAT;
|
||||||
volatile char *pUART_data = (char*)0x80000004;
|
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;
|
return *pUART_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _putchar(char c)
|
||||||
|
{
|
||||||
|
if (c == 0x0A)
|
||||||
|
{
|
||||||
|
writechar(0x0D);
|
||||||
|
}
|
||||||
|
writechar(c);
|
||||||
|
}
|
||||||
|
|
||||||
void writechar(char c)
|
void writechar(char c)
|
||||||
{
|
{
|
||||||
volatile char *pUART_stat = (char*)0x80000008;
|
volatile uint32_t *pUART_stat = (uint32_t*)SYS_UART_STAT;
|
||||||
volatile char *pUART_data = (char*)0x80000004;
|
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;
|
*pUART_data = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_t times(struct tms *buffer)
|
clock_t times(struct tms *buffer)
|
||||||
{
|
{
|
||||||
volatile long *pReg_usec = (long*)0x80000010;
|
volatile uint32_t *pReg_usec = (uint32_t*)SYS_TIMER_USEC;
|
||||||
volatile long *pReg_sec = (long*)0x80000014;
|
volatile uint32_t *pReg_sec = (uint32_t*)SYS_TIMER_SEC;
|
||||||
long sec;
|
long sec;
|
||||||
|
|
||||||
sec = *pReg_sec;
|
sec = *pReg_sec;
|
||||||
@@ -44,8 +54,8 @@ clock_t times(struct tms *buffer)
|
|||||||
|
|
||||||
int gettimeofday(struct timeval *tp, void *tzp)
|
int gettimeofday(struct timeval *tp, void *tzp)
|
||||||
{
|
{
|
||||||
volatile long *pReg_usec = (long*)0x80000010;
|
volatile uint32_t *pReg_usec = (uint32_t*)SYS_TIMER_USEC;
|
||||||
volatile long *pReg_sec = (long*)0x80000014;
|
volatile uint32_t *pReg_sec = (uint32_t*)SYS_TIMER_SEC;
|
||||||
|
|
||||||
if (tp)
|
if (tp)
|
||||||
{
|
{
|
||||||
@@ -58,8 +68,8 @@ int gettimeofday(struct timeval *tp, void *tzp)
|
|||||||
|
|
||||||
int settimeofday(const struct timeval *tp, const struct timezone *tzp)
|
int settimeofday(const struct timeval *tp, const struct timezone *tzp)
|
||||||
{
|
{
|
||||||
volatile long *pReg_usec = (long*)0x80000010;
|
volatile uint32_t *pReg_usec = (uint32_t*)SYS_TIMER_USEC;
|
||||||
volatile long *pReg_sec = (long*)0x80000014;
|
volatile uint32_t *pReg_sec = (uint32_t*)SYS_TIMER_SEC;
|
||||||
div_t res;
|
div_t res;
|
||||||
|
|
||||||
res = div(tp->tv_usec, 1E6);
|
res = div(tp->tv_usec, 1E6);
|
||||||
@@ -124,7 +134,7 @@ int write(int file, char *ptr, int len)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0; i < len; i++)
|
for (i=0; i < len; i++)
|
||||||
writechar(*ptr++);
|
_putchar(*ptr++);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -140,7 +150,7 @@ int sputs(char *pStr)
|
|||||||
start = pStr;
|
start = pStr;
|
||||||
|
|
||||||
while(*pStr)
|
while(*pStr)
|
||||||
writechar(*(pStr++));
|
_putchar(*(pStr++));
|
||||||
|
|
||||||
return pStr - start;
|
return pStr - start;
|
||||||
}
|
}
|
||||||
@@ -160,7 +170,7 @@ void print_byte(char byte)
|
|||||||
else
|
else
|
||||||
c = nibble + 'A' - 10;
|
c = nibble + 'A' - 10;
|
||||||
|
|
||||||
writechar(c);
|
_putchar(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user