- refactored

git-svn-id: http://moon:8086/svn/mips@149 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2021-04-06 13:41:03 +00:00
parent dd10b4b5db
commit 7634bf8d41
17 changed files with 256 additions and 86 deletions
+39
View File
@@ -0,0 +1,39 @@
# environment vaiables read:
# BOARD = {ml402, denano, sim}
# WITH_TLB = {n, y}
# ENDIANESS = {eb, el}
# DEBUGGER = {gdb, mips, rom}
BOARD ?= ml402
WITH_TLB ?= n
ENDIANESS ?= eb
DEBUGGER ?= mips
DEFINES := -DBOARD_$(BOARD)
CCFLAGS := -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics
CFLAGS := -fno-exceptions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostartfiles -Os
CFLAGS_TLB-y := -DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
CFLAGS_TLB-n := -DSYS_IO_BASE=0xA0000000 -DSDRAM_BASE=0x40000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x00000000
CFLAGS-eb =-EB
CFLAGS-el =-EL
CFLAGS += $(CFLAGS_TLB-$(WITH_TLB))
CFLAGS += $(CFLAGS-$(ENDIANESS))
CFLAGS += -msoft-float -march=r3000
CFLAGS += $(CFLAGS-$(BOARD))
FLASHGEN_TLB-y := flashgen_tlb
FLASHGEN_TLB-n := flashgen
PACKHEX := packhex
AS=mips-elf-as
AR=mips-elf-ar
CC=mips-elf-gcc
LD=mips-elf-gcc
OBJDUMP=mips-elf-objdump
OBJCOPY=mips-elf-objcopy
FLASHGEN=$(FLASHGEN_TLB-$(WITH_TLB))
+8 -32
View File
@@ -1,8 +1,8 @@
# environment vaiables read:
# BOARD = {ml402, denano}
# TLB = {no, yes}
# ENDIANESS = {eb, el}
# DEBUGGER = {gdb, mips, rom}
include $(MIPS_HOME)/make/compile.mk
CFLAGS-sim := -Os
CFLAGS-ml402 := -g -O2
CFLAGS-denano := -g -O2
ifeq ($(TLB),yes)
SPECNAME=specs_tlb
@@ -10,35 +10,11 @@ else
SPECNAME=specs
endif
ifeq ($(ENDIANESS),eb)
ENDIAN_FLAGS=-EB
else
ENDIAN_FLAGS=-EL
endif
BUILD_DIR=build/$(BOARD)/$(ENDIANESS)
LSYS_BUILD_DIR=libsys/build/$(BOARD)/$(ENDIANESS)
CFLAGS :=$(ENDIAN_FLAGS) -ffunction-sections -fdata-sections -Wl,--gc-sections -G 0 -T $(MIPS_HOME)/link/ram.ld -g -msoft-float -O2 -march=r3000 -I. -Ilibsys -Ilibsys/boards/$(BOARD) -L$(LSYS_BUILD_DIR) -Wl,-M
ifeq ($(TLB),yes)
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
else
CFLAGS+=-DSYS_IO_BASE=0xA0000000 -DSDRAM_BASE=0x40000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x00000000
endif
CFLAGS += -Wl,--gc-sections -G 0 -T $(MIPS_HOME)/link/ram.ld
CFLAGS += -I. -Ilibsys -Ilibsys/boards/$(BOARD) -L$(LSYS_BUILD_DIR) $(DEFINES)
ifeq ($(TLB),yes)
FLASHGEN=flashgen_tlb
else
FLASHGEN=flashgen
endif
PACKHEX=packhex
LIBS=-lm -lc -lsys -lc
AS=mips-elf-as
AR=mips-elf-ar
CC=mips-elf-gcc
LD=mips-elf-ld
OBJDUMP=mips-elf-objdump
OBJCOPY=mips-elf-objcopy
LIBS=-lsys -lm -lc
+5 -30
View File
@@ -1,20 +1,8 @@
# environment vaiables read:
# BOARD = {ml402, denano}
# TLB = {no, yes}
# ENDIANESS = {eb, el}
# DEBUGGER = {gdb, mips, rom}
include $(MIPS_HOME)/make/compile.mk
BOARD ?= ml402
TLB ?= no
ENDIANESS ?= eb
DEBUGGER ?= mips
ifeq ($(ENDIANESS),el)
ENDIAN_FLAGS=-EL
else
ENDIAN_FLAGS=-EB
endif
CFLAGS-sim := -Os
CFLAGS-ml402 := -g -O2
CFLAGS-denano := -g -O2
ifeq ($(DEBUGGER),gdb)
DBG_FLAGS := -DWITH_GDB_STUB
@@ -29,21 +17,8 @@ ifeq ($(DEBUGGER),rom)
endif
CFLAGS=$(ENDIAN_FLAGS) -ffunction-sections -fdata-sections -g -msoft-float -O2 -march=r3000 -I. -Iboards/$(BOARD) -D$(BOARD) $(DBG_FLAGS)
ifeq ($(TLB),yes)
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
else
CFLAGS+=-DSYS_IO_BASE=0xA0000000 -DSDRAM_BASE=0x40000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x00000000
endif
CFLAGS += -I. -Iboards/$(BOARD) $(DBG_FLAGS) $(DEFINES)
BUILD_DIR=./build/$(BOARD)/$(ENDIANESS)
AS=mips-elf-as
AR=mips-elf-ar
CC=mips-elf-gcc
LD=mips-elf-ld
OBJDUMP=mips-elf-objdump
OBJCOPY=mips-elf-objcopy
FLASHGEN=flashgen
+1 -1
View File
@@ -5,7 +5,7 @@ include ../make/mips_app.mk
PROG-ml402 = $(addprefix $(BUILD_DIR)/, hello.elf testbench.elf test_irq.elf dhry.elf queens.elf stanford.elf paranoia.elf rmd160_test.elf Bessel.elf whet.elf phrasen.elf dttl.elf richards_benchmark.elf test_exception.elf life.elf r3.elf gunzip.elf basic_math.elf jman_patches.elf jman_patchmeshes.elf jman_polys.elf test_hpi.elf test_vga.elf test_fft.elf)
PROG-denano = $(addprefix $(BUILD_DIR)/, hello.elf dhry.elf queens.elf stanford.elf paranoia.elf rmd160_test.elf Bessel.elf whet.elf phrasen.elf dttl.elf richards_benchmark.elf test_exception.elf testbench_denano.elf)
PROG-sim = $(addprefix $(BUILD_DIR)/, hello.elf ICacheTest.elf)
PROG-sim = $(addprefix $(BUILD_DIR)/, hello.elf)
CFLAGS-sim := -O0
CFLAGS += $(CFLAGS-$(BOARD))
+1 -1
View File
@@ -2,5 +2,5 @@
int main()
{
printf("Hello, world!\n");
printf("Hello, MIPS-world!\n");
}
+4 -4
View File
@@ -1,5 +1,5 @@
# environment vaiables read:
# BOARD = {ml402, denano}
# BOARD = {ml402, denano, sim}
# TLB = {no, yes}
# ENDIANESS = {eb, el}
# DEBUGGER = {gdb, mips, rom}
@@ -13,7 +13,7 @@ include ../../make/mips_lib.mk
OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o $(DBG_OBJ) console.o uart.o board.o gpio.o mips_ps2.o mips_gfx.o screen.o)
OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o $(DBG_OBJ) console.o uart.o board.o gpio.o)
OBJS-sim=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o $(DBG_OBJ) console.o uart.o board.o gpio.o)
OBJS-sim=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o console.o uart.o board.o gpio.o)
all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a
@@ -28,8 +28,8 @@ $(BUILD_DIR)/board.o : boards/$(BOARD)/board.c
$(BUILD_DIR)/libsys.a: $(OBJS-$(BOARD))
$(AR) -r $(BUILD_DIR)/libsys.a $(OBJS-$(BOARD))
$(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/startup.o startup.S
$(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/kernel.o kernel.S
$(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/startup.o asm/startup.S
$(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/kernel.o asm/kernel.S
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
@@ -1,5 +1,5 @@
#include <regdef.h>
#include <xcpt_asm.h>
#include "regdef.h"
#include "xcpt_asm.h"
.text
.section .exc_vect, "ax"
@@ -1,4 +1,4 @@
#include <regdef.h>
#include "regdef.h"
.file "startup.S"
.section .rodata
@@ -8,23 +8,15 @@ argv: .word argv0
.text
.section .start, "ax"
.extern _init
.extern board_init
.align 2
.set noreorder
_start:
la sp, stack_ptr
la gp, _gp
la ra, _zero_bss
j _init
nop
.text
.globl _zero_bss
.extern board_init
.align 2
.set noreorder
_zero_bss:
# zero bss
la $8, __bss_start
+1 -1
View File
@@ -9,7 +9,7 @@
#include "../../irq.h"
#include "../../uart.h"
#include "../../console.h"
#include "../../regdef.h"
#include "../../asm/regdef.h"
extern uart_if_t uart_if[];
+1 -1
View File
@@ -9,7 +9,7 @@
#include "../../irq.h"
#include "../../uart.h"
#include "../../console.h"
#include "../../regdef.h"
#include "../../asm/regdef.h"
extern uart_if_t uart_if[];
#ifdef WITH_ROM_DEBUGGER
+49
View File
@@ -0,0 +1,49 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
#include <stddef.h>
#include "board.h"
#include "../../irq.h"
#include "../../uart.h"
#include "../../console.h"
#include "../../asm/regdef.h"
extern uart_if_t uart_if[];
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
const con_if_entry_t con_if_entry[] =
{
{0, "stdin", &uart_if[0], NULL, NULL, UART_readchar, NULL},
{1, "stdout", &uart_if[0], NULL, NULL, NULL, UART_writechar},
{2, "stderr", &uart_if[0], NULL, NULL, NULL, UART_writechar},
{3, "UART-0", &uart_if[0], NULL, NULL, UART_readchar, UART_writechar},
{4, "UART-1", &uart_if[1], NULL, NULL, UART_readchar, UART_writechar}
};
const con_if_t con_if =
{
con_if_entry, ARRAYSIZE(con_if_entry)
};
void board_init(void)
{
uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL;
// Disable timers
*pITIM_ctrl = 0;
// Setup syscall support
syscalls_init();
// Setup interrupt support
interrupt_init();
interrupt_global_enable();
// Do some initializations here
}
+139
View File
@@ -0,0 +1,139 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: board.h
* Author: jens
*
* Created on 8. Januar 2017, 11:33
*/
#ifndef BOARD_H
#define BOARD_H
#define CPU_FREQ_HZ 100000000
#define UART_STDIO 0
#define UART_DEBUGGER 1
// ---------------------------------------------------------
// IRQs
// ---------------------------------------------------------
#define SYS_INT_SOFT_0 0
#define SYS_INT_SOFT_1 1
#define SYS_INT_TIMER 2
#define SYS_INT_UART0 3
#define SYS_INT_UART1 4
#define SYS_INT_FLASH 5
// ---------------------------------------------------------
// Memory-mapped registers
// ---------------------------------------------------------
#ifndef SYS_IO_BASE
#define SYS_IO_BASE 0xA0000000
#endif
#ifndef SDRAM_BASE
#define SDRAM_BASE 0x40000000
#endif
#ifndef FLASH_BASE_IO
#define FLASH_BASE_IO 0xA4000000
#endif
#ifndef FLASH_BASE_MEM
#define FLASH_BASE_MEM 0x00000000
#endif
// Backwards compatibility
#define SYS_FLASH_IO FLASH_BASE_IO
#define SYS_FLASH_MEM FLASH_BASE_MEM
// GPIO
#define SYS_GPIO_0_BASE (SYS_IO_BASE + 0)
#define SYS_GPIO_0_DATA (SYS_GPIO_0_BASE + 0)
#define SYS_GPIO_0_DIR (SYS_GPIO_0_BASE + 4)
#define GPIO_0_DFLT_DIR 0x00000000 // Inputs
#define GPIO_0_DFLT_DATA 0x00000000
#define GPIO_0_MASK_LED 0x000000FF
#define GPIO_0_ALIGN_LED 0
#define GPIO_0_MASK_DIP 0x0000000F
#define GPIO_0_ALIGN_DIP 8
#define GPIO_0_MASK_BTN 0x0000001F
#define GPIO_0_ALIGN_BTN 24
// RTC
#define SYS_TIMER_USEC (SYS_IO_BASE + 0x8)
#define SYS_TIMER_SEC (SYS_IO_BASE + 0xC)
// TIMERs
#define SYS_ITIM_CTRL (SYS_IO_BASE + 0x18)
#define SYS_ITIM_STAT (SYS_IO_BASE + 0x1C)
#define SYS_ITIM0_CNT (SYS_IO_BASE + 0x20)
#define SYS_ITIM1_CNT (SYS_IO_BASE + 0x24)
#define SYS_ITIM2_CNT (SYS_IO_BASE + 0x28)
#define SYS_ITIM3_CNT (SYS_IO_BASE + 0x2C)
#define SYS_ITIM0_CMP (SYS_IO_BASE + 0x30)
#define SYS_ITIM1_CMP (SYS_IO_BASE + 0x34)
#define SYS_ITIM2_CMP (SYS_IO_BASE + 0x38)
#define SYS_ITIM3_CMP (SYS_IO_BASE + 0x3C)
// UARTs
#define SYS_UART_BIT_TX_HALFFULL 0x00000001
#define SYS_UART_BIT_TX_FULL 0x00000002
#define SYS_UART_BIT_RX_HALFFULL 0x00000004
#define SYS_UART_BIT_RX_FULL 0x00000008
#define SYS_UART_BIT_RX_AVAIL 0x00000010
#define SYS_UART_BIT_TX_INTEN 0x00000020
#define SYS_UART_BIT_RX_INTEN 0x00000040
#define SYS_UART_BIT_TX_IRQ 0x00000100
#define SYS_UART_BIT_RX_IRQ 0x00000200
#define SYS_UART_DATA SYS_UART0_DATA
#define SYS_UART_STAT SYS_UART0_STAT
#define SYS_UART_BAUD SYS_UART0_BAUD
#define SYS_UART0_DATA (SYS_IO_BASE + 0x10000)
#define SYS_UART0_STAT (SYS_IO_BASE + 0x10004)
#define SYS_UART0_BAUD (SYS_IO_BASE + 0x10008)
#define SYS_UART1_DATA (SYS_IO_BASE + 0x30000)
#define SYS_UART1_STAT (SYS_IO_BASE + 0x30004)
#define SYS_UART1_BAUD (SYS_IO_BASE + 0x30008)
// SPI
#define SYS_SPI_STAT (SYS_IO_BASE + 0x20000)
// Read
#define SPI_STAT_CMDRDY (0x01)
#define SPI_STAT_DINRDY (0x02)
#define SPI_STAT_DOUTRDY (0x04)
#define SPI_STAT_CMD_FIFO_FULL (0x0100)
#define SPI_STAT_CMD_FIFO_EMPTY (0x0200)
#define SPI_STAT_WRITE_FIFO_FULL (0x0400)
#define SPI_STAT_WRITE_FIFO_EMPTY (0x0800)
#define SPI_STAT_READ_FIFO_FULL (0x1000)
#define SPI_STAT_READ_FIFO_EMPTY (0x2000)
#define SPI_STAT_RX_VALID (0x4000)
#define SPI_STAT_SPI_HOLD (0x8000)
// Write
#define SPI_STAT_COMMIT (1)
#define SYS_SPI_XFER_SIZE (SYS_IO_BASE + 0x20004)
#define SYS_SPI_DATA_SIZE (SYS_IO_BASE + 0x20008)
#define SYS_SPI_DATA (SYS_IO_BASE + 0x2000C)
#define SYS_SPI_CTRL (SYS_IO_BASE + 0x20010)
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* BOARD_H */
+1 -1
View File
@@ -1,6 +1,6 @@
#include <stddef.h>
#include <stdint.h>
#include "regdef.h"
#include "asm/regdef.h"
#include "xcpt.h"
#include "irq.h"
+1 -1
View File
@@ -6,7 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "libsys.h"
#include "regdef.h"
#include "asm/regdef.h"
static uint32_t critical_nesting_counter = 0;
+2 -2
View File
@@ -32,7 +32,7 @@ if [ ! -e ./$SRC_BINUTILS-build ]; then
echo Building $SRC_BINUTILS
mkdir -p $SRC_BINUTILS-build
cd $SRC_BINUTILS-build
../$SRC_BINUTILS/configure --target=$TARGET --prefix=$PREFIX || exit 1
../$SRC_BINUTILS/configure --target=$TARGET --prefix=$PREFIX --disable-nls --disable-werror || exit 1
make -j4 || exit 1
make install || exit 1
cd ..
@@ -177,7 +177,7 @@ if [ ! -e ./$SRC_GCC-build ]; then
echo Building $SRC_GCC
mkdir -p $SRC_GCC-build
cd $SRC_GCC-build
../$SRC_GCC/configure --target=$TARGET --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --with-float=soft --with-newlib --verbose --enable-languages="c,c++" --with-gnu-as --with-gnu-ld || exit 1
../$SRC_GCC/configure --target=$TARGET --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --with-float=soft --with-newlib --verbose --enable-languages="c,c++" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --disable-multilib --without-headers --disable-shared --enable-lto -disable-werror || exit 1
make -j4 all || exit 1
make info || exit 1
make install || exit 1