- fixed bootloader
- bootloader added board file - refactored header files - constify constants git-svn-id: http://moon:8086/svn/mips@99 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include "board.h"
|
||||
#include "../../irq.h"
|
||||
#include "../../uart.h"
|
||||
#include "../../console.h"
|
||||
#include "../../regdef.h"
|
||||
|
||||
#define DEBUGGER gdb_stub
|
||||
@@ -23,7 +26,7 @@ const con_if_entry_t con_if_entry[] =
|
||||
{4, "UART-1", &uart_if[1], NULL, NULL, UART_readchar, UART_writechar}
|
||||
};
|
||||
|
||||
con_if_t con_if =
|
||||
const con_if_t con_if =
|
||||
{
|
||||
con_if_entry, ARRAYSIZE(con_if_entry)
|
||||
};
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
|
||||
#include "../../irq.h"
|
||||
#include "../../uart.h"
|
||||
#include "../../console.h"
|
||||
|
||||
#define CPU_FREQ_HZ 50000000
|
||||
|
||||
// ---------------------------------------------------------
|
||||
@@ -61,6 +57,12 @@
|
||||
#define GPIO_0_MASK_LED 0x000000FF
|
||||
#define GPIO_0_ALIGN_LED 0
|
||||
|
||||
#define GPIO_0_MASK_DIP 0x000000FF
|
||||
#define GPIO_0_ALIGN_DIP 16
|
||||
|
||||
#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)
|
||||
|
||||
@@ -6,10 +6,16 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../../irq.h"
|
||||
#include "../../mips_ps2.h"
|
||||
#include "../../mips_gfx.h"
|
||||
#include "../../screen.h"
|
||||
#include "../../uart.h"
|
||||
#include "../../console.h"
|
||||
#include "board.h"
|
||||
|
||||
extern void dbg_init();
|
||||
extern void dbg_handler(struct xcptcontext * xcp);
|
||||
extern int dbg_handler(struct xcptcontext * xcp);
|
||||
#define DEBUGGER dbg_handler
|
||||
|
||||
extern uart_if_t uart_if[];
|
||||
extern ps2_if_t ps2_if[];
|
||||
@@ -17,7 +23,7 @@ extern vga_if_t vga_if;
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
static const con_if_entry_t con_if_entry[] =
|
||||
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},
|
||||
@@ -29,11 +35,28 @@ static const con_if_entry_t con_if_entry[] =
|
||||
{30, "VGA-0", &vga_if, cg_open, cg_close, NULL, cg_writechar}
|
||||
};
|
||||
|
||||
con_if_t con_if =
|
||||
const con_if_t con_if =
|
||||
{
|
||||
con_if_entry, ARRAYSIZE(con_if_entry)
|
||||
};
|
||||
|
||||
void handle_debugger_int(struct xcptcontext * xcp)
|
||||
{
|
||||
dbg_handler(xcp);
|
||||
}
|
||||
|
||||
void dbg_init()
|
||||
{
|
||||
xcpt_register(EXC_ADEL, DEBUGGER);
|
||||
xcpt_register(EXC_ADES, DEBUGGER);
|
||||
xcpt_register(EXC_IBE, DEBUGGER);
|
||||
xcpt_register(EXC_DBE, DEBUGGER);
|
||||
xcpt_register(EXC_BP, DEBUGGER);
|
||||
xcpt_register(EXC_RI, DEBUGGER);
|
||||
xcpt_register(EXC_CPU, DEBUGGER);
|
||||
xcpt_register(EXC_OV, DEBUGGER);
|
||||
}
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL;
|
||||
@@ -54,7 +77,7 @@ void board_init(void)
|
||||
|
||||
// Initalize debugger
|
||||
dbg_init();
|
||||
interrupt_register(2, dbg_handler);
|
||||
interrupt_register(2, handle_debugger_int);
|
||||
interrupt_enable(2);
|
||||
|
||||
// flush stdin
|
||||
|
||||
@@ -14,13 +14,6 @@
|
||||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
|
||||
#include "../../irq.h"
|
||||
#include "../../mips_ps2.h"
|
||||
#include "../../mips_gfx.h"
|
||||
#include "../../screen.h"
|
||||
#include "../../uart.h"
|
||||
#include "../../console.h"
|
||||
|
||||
#define CPU_FREQ_HZ 100000000
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include "libsys.h"
|
||||
#include "mips_ps2.h"
|
||||
|
||||
uint32_t con_readchar(ps2_if_t *pIF);
|
||||
uint32_t ps2_readchar(ps2_if_t *pIF);
|
||||
|
||||
ps2_if_t ps2_if[2] =
|
||||
const ps2_if_t ps2_if[2] =
|
||||
{
|
||||
{ps2_type_unknown, (uint32_t*)SYS_PS2_0_STAT, (uint32_t*)SYS_PS2_0_DATA},
|
||||
{ps2_type_unknown, (uint32_t*)SYS_PS2_1_STAT, (uint32_t*)SYS_PS2_1_DATA}
|
||||
@@ -23,7 +23,7 @@ int PS2_readchar(void const *pInst)
|
||||
assert(pInst);
|
||||
ps2_if_t *pIF = (ps2_if_t*)pInst;
|
||||
|
||||
return (int)con_readchar(pIF);
|
||||
return (int)ps2_readchar(pIF);
|
||||
}
|
||||
|
||||
void PS2_open(void const *pInst)
|
||||
@@ -396,7 +396,7 @@ static char __findkey(char scancode, int mode)
|
||||
#define ARROW_LEFT (SPECIALKEY|EXTENDED|0x6b)
|
||||
#define ARROW_RIGHT (SPECIALKEY|EXTENDED|0x74)
|
||||
|
||||
uint32_t con_readchar(ps2_if_t *pIF)
|
||||
uint32_t ps2_readchar(ps2_if_t *pIF)
|
||||
{
|
||||
uint8_t c;
|
||||
static char mode = 0;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
#include <board.h>
|
||||
#include "screen.h"
|
||||
|
||||
vga_if_t vga_if =
|
||||
const vga_if_t vga_if =
|
||||
{
|
||||
(uint32_t*)SYS_VGA_CTRL, (uint32_t*)SYS_VGA_ASCII, (uint32_t*)SYS_VGA_POSX, (uint32_t*)SYS_VGA_POSY
|
||||
};
|
||||
|
||||
+4
-9
@@ -4,14 +4,13 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <board.h>
|
||||
#include "uart.h"
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Globals
|
||||
// ---------------------------------------------------------------------------------
|
||||
uart_if_t uart_if[2] =
|
||||
const uart_if_t uart_if[2] =
|
||||
{
|
||||
{(uint32_t*)SYS_UART0_STAT, (uint32_t*)SYS_UART0_DATA, (uint32_t*)SYS_UART0_BAUD},
|
||||
{(uint32_t*)SYS_UART1_STAT, (uint32_t*)SYS_UART1_DATA, (uint32_t*)SYS_UART1_BAUD}
|
||||
@@ -21,12 +20,10 @@ uart_if_t uart_if[2] =
|
||||
// Low-level I/O
|
||||
// ------------------------------------
|
||||
#define CALC_BAUD(b) \
|
||||
((uint32_t)((float)CPU_FREQ_HZ/(16*b) + 0.5f) - 1);
|
||||
(((10*CPU_FREQ_HZ)/((16*b) + 5))/10 - 1)
|
||||
|
||||
void UART_setbaud(void const *pInst, uint32_t baudrate)
|
||||
{
|
||||
assert(pInst);
|
||||
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
*pReg->pBAUD = CALC_BAUD(baudrate);
|
||||
@@ -34,20 +31,18 @@ void UART_setbaud(void const *pInst, uint32_t baudrate)
|
||||
|
||||
int UART_readchar(void const *pInst)
|
||||
{
|
||||
assert(pInst);
|
||||
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
if (SYS_UART_BIT_RX_AVAIL & *pReg->pCTRL)
|
||||
{
|
||||
return (*pReg->pDATA & 0xFF);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UART_writechar(void const *pInst, char c)
|
||||
{
|
||||
assert(pInst);
|
||||
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
while((SYS_UART_BIT_TX_HALFFULL & *pReg->pCTRL) != 0);
|
||||
|
||||
Reference in New Issue
Block a user