diff --git a/src/gunzip.c b/src/gunzip.c index f8e4daf..5e20deb 100644 --- a/src/gunzip.c +++ b/src/gunzip.c @@ -16,7 +16,7 @@ char * volatile pPtr_w; volatile int timeout_cnt; volatile int file_len; -void handler3(void) +void handler3(struct xcptcontext *xcp) { volatile uint32_t *pUART_stat = (uint32_t*)SYS_UART0_STAT; volatile uint32_t *pUART_data = (uint32_t*)SYS_UART0_DATA; @@ -54,7 +54,7 @@ int main(int argc, char **argv) z_stream zs; time_t start_time, work_time; - UART0_setbaud(460800); + UART_setbaud(con_getInstanceByName("UART-0"), 460800); fprintf(stdout, "Reading gzipped stream..\n"); diff --git a/src/hpi.c b/src/hpi.c index 7a1cad4..a1fd5d7 100644 --- a/src/hpi.c +++ b/src/hpi.c @@ -46,7 +46,7 @@ static usb_t _g_usb[USB_MAX_NUM_PORTS]; // --------------------------------------------------------- // HPI ISR // --------------------------------------------------------- -void cy67k3_isr(void) +void cy67k3_isr(struct xcptcontext *xcp) { int32_t i; uint16_t sie_msg, hpi_status; diff --git a/src/hpi.h b/src/hpi.h index 619bc0d..fc4704b 100644 --- a/src/hpi.h +++ b/src/hpi.h @@ -337,7 +337,7 @@ typedef struct _susb_irp_t // --------------------------------------------------------- // HPI low-level routines -void cy67k3_isr(void); +void cy67k3_isr(struct xcptcontext *xcp); void cy67k3_reset(void); uint16_t cy67k3_read_HPI_DATA(void); uint16_t cy67k3_read_HPI_MAILBOX(void); diff --git a/src/libsys/Makefile b/src/libsys/Makefile index 4763827..64dcfab 100644 --- a/src/libsys/Makefile +++ b/src/libsys/Makefile @@ -31,8 +31,8 @@ OBJDUMP=mipsel-elf-objdump OBJCOPY=mipsel-elf-objcopy FLASHGEN=flashgen -OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o irq.o mips_dbg.o mips_dis.o mips_ps2.o mips_gfx.o console.o screen.o uart.o board.o gpio.o) -OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o irq.o mips_dbg.o mips_dis.o console.o uart.o board.o) +OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o mips_ps2.o mips_gfx.o console.o screen.o uart.o board.o gpio.o) +OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o console.o uart.o board.o) all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a diff --git a/src/libsys/boards/denano/board.c b/src/libsys/boards/denano/board.c index dc9f579..861e72e 100644 --- a/src/libsys/boards/denano/board.c +++ b/src/libsys/boards/denano/board.c @@ -8,10 +8,6 @@ #include "board.h" -#include "../../irq.h" -#include "../../uart.h" -#include "../../console.h" - extern uart_if_t uart_if[]; #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) @@ -21,7 +17,8 @@ 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, "UART1", &uart_if[1], NULL, NULL, UART_readchar, 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} }; con_if_t con_if = @@ -50,10 +47,10 @@ void board_init(void) void dbg_putchar(char c) { - writechar(3, c); + writechar(4, c); } char dbg_getchar() { - return (char)readchar(3); + return (char)readchar(4); } diff --git a/src/libsys/boards/denano/board.h b/src/libsys/boards/denano/board.h index bf42abd..61fef7f 100644 --- a/src/libsys/boards/denano/board.h +++ b/src/libsys/boards/denano/board.h @@ -14,6 +14,10 @@ #ifndef BOARD_H #define BOARD_H +#include "../../irq.h" +#include "../../uart.h" +#include "../../console.h" + #define CPU_FREQ_HZ 50000000 // --------------------------------------------------------- diff --git a/src/libsys/boards/ml402/board.c b/src/libsys/boards/ml402/board.c index f0ec605..051e598 100644 --- a/src/libsys/boards/ml402/board.c +++ b/src/libsys/boards/ml402/board.c @@ -7,11 +7,6 @@ #include #include "board.h" -#include "../../irq.h" -#include "../../mips_ps2.h" -#include "../../screen.h" -#include "../../uart.h" -#include "../../console.h" extern void dbg_init(); extern void dbg_handler(struct xcptcontext * xcp); @@ -27,10 +22,11 @@ static 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-1", &uart_if[1], NULL, NULL, UART_readchar, UART_writechar}, - {4, "PS2-0", &ps2_if[0], PS2_open, PS2_close, PS2_readchar, NULL}, - {5, "PS2-1", &ps2_if[1], PS2_open, PS2_close, PS2_readchar, NULL}, - {6, "VGA-0", &vga_if, cg_open, cg_close, NULL, cg_writechar} + {10, "UART-0", &uart_if[0], NULL, NULL, UART_readchar, UART_writechar}, + {11, "UART-1", &uart_if[1], NULL, NULL, UART_readchar, UART_writechar}, + {20, "PS2-0", &ps2_if[0], PS2_open, PS2_close, PS2_readchar, NULL}, + {21, "PS2-1", &ps2_if[1], PS2_open, PS2_close, PS2_readchar, NULL}, + {30, "VGA-0", &vga_if, cg_open, cg_close, NULL, cg_writechar} }; con_if_t con_if = diff --git a/src/libsys/boards/ml402/board.h b/src/libsys/boards/ml402/board.h index 8cabe3a..c86b06f 100644 --- a/src/libsys/boards/ml402/board.h +++ b/src/libsys/boards/ml402/board.h @@ -14,6 +14,13 @@ #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 // --------------------------------------------------------- diff --git a/src/libsys/console.c b/src/libsys/console.c index a44b9ad..8265082 100644 --- a/src/libsys/console.c +++ b/src/libsys/console.c @@ -11,7 +11,7 @@ extern con_if_t con_if; // Funcs -con_if_entry_t const* con_getPort(int file) +con_if_entry_t const* con_getInterface(int file) { con_if_entry_t const *result = NULL; int i; @@ -26,6 +26,21 @@ con_if_entry_t const* con_getPort(int file) return result; } +void const* con_getInstanceByName(char const *pName) +{ + void const *result = NULL; + int i; + for (i=0; i < con_if.length; i++) + { + if (!strcmp(pName, con_if.con_if_entry[i].pName)) + { + result = con_if.con_if_entry[i].pInst; + break; + } + } + return result; +} + int con_open(char const *pName) { int i; @@ -53,7 +68,7 @@ int con_close(int fd) void con_flush(int fd) { int c; - con_if_entry_t const *pIF = con_getPort(fd); + con_if_entry_t const *pIF = con_getInterface(fd); do { @@ -66,7 +81,7 @@ void con_flush(int fd) int readchar(int fd) { int c; - con_if_entry_t const *pIF = con_getPort(fd); + con_if_entry_t const *pIF = con_getInterface(fd); assert(pIF); @@ -82,7 +97,7 @@ int readchar(int fd) void writechar(int fd, char c) { - con_if_entry_t const *pIF = con_getPort(fd); + con_if_entry_t const *pIF = con_getInterface(fd); assert(pIF); @@ -92,7 +107,7 @@ void writechar(int fd, char c) void _putchar(int fd, char c) { - con_if_entry_t const *pIF = con_getPort(fd); + con_if_entry_t const *pIF = con_getInterface(fd); assert(pIF); if (c == 0x0A) diff --git a/src/libsys/console.h b/src/libsys/console.h index 0cb8553..80fd72b 100644 --- a/src/libsys/console.h +++ b/src/libsys/console.h @@ -14,6 +14,7 @@ #ifndef CONSOLE_H #define CONSOLE_H +#include #include typedef int (*read_func_t)(void const *pInst); @@ -48,7 +49,8 @@ extern "C" { int con_open(char const *pName); int con_close(int fd); void con_flush(int file); -con_if_entry_t const* con_getPort(int file); +con_if_entry_t const* con_getInterface(int file); +void const* con_getInstanceByName(char const *pName); int readchar(int file); void writechar(int file, char c); diff --git a/src/libsys/irq.c b/src/libsys/irq.c index 4365953..8b575e8 100644 --- a/src/libsys/irq.c +++ b/src/libsys/irq.c @@ -1,9 +1,5 @@ -#include -#include -#include -#include -#include -#include "libsys.h" +#include +#include #include "regdef.h" #include "xcpt.h" #include "irq.h" @@ -63,6 +59,18 @@ void interrupt_disable(int irq_num) } } +void interrupt_enable_all() +{ + uint32_t reg = CP0_SR_read() | SR_MASK_IEC; + CP0_SR_write(reg); +} + +void interrupt_disable_all() +{ + uint32_t reg = CP0_SR_read() & ~SR_MASK_IEC; + CP0_SR_write(reg); +} + void interrupt_set(int irq_num) { reg_t reg, ip; diff --git a/src/libsys/irq.h b/src/libsys/irq.h index 941bbc6..3c83808 100644 --- a/src/libsys/irq.h +++ b/src/libsys/irq.h @@ -12,5 +12,7 @@ int _irq_dispatch(struct xcptcontext * xcp); void interrupt_register(int irq_num, fp_irq_t fp); void interrupt_enable(int irq_num); void interrupt_disable(int irq_num); +void interrupt_enable_all(); +void interrupt_disable_all(); #endif // IRQ_H diff --git a/src/libsys/libsys.c b/src/libsys/libsys.c index e45d91b..05217c9 100644 --- a/src/libsys/libsys.c +++ b/src/libsys/libsys.c @@ -5,164 +5,30 @@ #include #include #include -#include "console.h" #include "libsys.h" +#include "regdef.h" +static uint32_t critical_nesting_counter = 0; -#define CALC_BAUD(b) \ - ((uint32_t)((float)CPU_FREQ_HZ/(16*b) + 0.5f) - 1); - -void UART0_setbaud(uint32_t baudrate) +void enter_critical() { - *((uint32_t*)SYS_UART0_BAUD) = CALC_BAUD(baudrate); + if (critical_nesting_counter == 0) + { + interrupt_disable_all(); + } + critical_nesting_counter++; } -void UART1_setbaud(uint32_t baudrate) +void exit_critical() { - *((uint32_t*)SYS_UART1_BAUD) = CALC_BAUD(baudrate); -} - -// --------------------------------------------------------------------------------- -// MIPS specific -// --------------------------------------------------------------------------------- -uint32_t CP0_SR_read(void) -{ - uint32_t result; - - __asm__ - ( - "mfc0 %[val], $12\n" - : [val] "=r" (result) - ); - - return result; -} - -void CP0_SR_write(uint32_t val) -{ - __asm__ - ( - "mtc0 %[val], $12\n" - : /* no output */ - : [val] "r" (val) - ); -} - -uint32_t CP0_CR_read(void) -{ - uint32_t result; - - __asm__ - ( - "mfc0 %[val], $13\n" - : [val] "=r" (result) - ); - - return result; -} - -void CP0_CR_write(uint32_t val) -{ - __asm__ - ( - "mtc0 %[val], $13\n" - : - : [val] "r" (val) - ); -} - -uint32_t CP0_TR_read(void) -{ - uint32_t result; - - __asm__ - ( - "mfc0 %[val], $31\n" - : [val] "=r" (result) - ); - - return result; -} - -void CP0_TR_write(uint32_t val) -{ - __asm__ - ( - "mtc0 %[val], $31\n" - : - : [val] "r" (val) - ); -} - -uint32_t CP0_PRID_read(void) -{ - uint32_t result; - - __asm__ - ( - "mfc0 %[val], $15\n" - : [val] "=r" (result) - ); - - return result; -} - -void CP0_TR_write_ptr(uint32_t* pPtr) -{ - __asm__ - ( - "swc0 $31, 0(%[pPtr])\n" - : - : [pPtr] "r" (pPtr) - ); -} - -void CP0_TR_read_ptr(uint32_t* pPtr) -{ - __asm__ - ( - "lwc0 $31, 0(%[pPtr])\n" - : - : [pPtr] "r" (pPtr) - ); -} - -void ICACHE_invalidate_all(void) -{ - __asm__ - ( - "cop0 32\n" - ); -} - -void ICACHE_invalidate_at(uint32_t* pPtr) -{ - __asm__ - ( - "mtc0 %[pPtr], $31\n" - "cop0 33\n" - : - : [pPtr] "r" (pPtr) - ); -} - -void DCACHE_invalidate_all(void) -{ - __asm__ - ( - "cop0 34\n" - ); -} - -void DCACHE_invalidate_at(uint32_t* pPtr) -{ - __asm__ - ( - "mtc0 %[pPtr], $31\n" - "cop0 35\n" - : - : [pPtr] "r" (pPtr) - ); + if (critical_nesting_counter > 0) + { + critical_nesting_counter--; + if (critical_nesting_counter == 0) + { + interrupt_enable_all(); + } + } } void _exit (int exitcode) diff --git a/src/libsys/libsys.h b/src/libsys/libsys.h index bb0ef09..98195ef 100644 --- a/src/libsys/libsys.h +++ b/src/libsys/libsys.h @@ -15,76 +15,8 @@ #define IS_ERROR(e) ((e & LSYS_ERR_BASE) == LSYS_ERR_BASE) -// --------------------------------------------------------- -// Chip registers -// --------------------------------------------------------- -// COP0 registers -#define COP0_REG_INVAT_POINTER 31 - -// COP0 instructions -#define COP0_INSTR_INVALL_ICACHE 32 -#define COP0_INSTR_INVAT_ICACHE 33 -#define COP0_INSTR_INVALL_DCACHE 34 -#define COP0_INSTR_INVAT_DCACHE 35 - -#define CP0_read(idx) \ -({ \ - uint32_t result; \ - __asm__ __volatile__ \ - ( \ - "mfc0\t%0,$"#idx"\n" \ - : "=r" (result) \ - ); \ - result; \ -}) - -#define CP0_write(idx, val) \ -({ \ - __asm__ __volatile__ \ - ( \ - "mtc0\t%0,$"#idx"\n" \ - "nop\n" \ - : /* no output */ \ - : "r" (val) \ - ); \ -}) - -#define CP0_TLBR \ -({ \ - __asm__ __volatile__ \ - ( \ - "tlbr\n" \ - : /* no output */ \ - : /* no input */ \ - ); \ -}) - -#define CP0_TLBWI \ -({ \ - __asm__ __volatile__ \ - ( \ - "tlbwi\n" \ - : /* no output */ \ - : /* no input */ \ - ); \ -}) - -uint32_t CP0_SR_read(void); -void CP0_SR_write(uint32_t val); -uint32_t CP0_CR_read(void); -void CP0_CR_write(uint32_t val); -uint32_t CP0_PRID_read(void); -uint32_t CP0_TR_read(void); -void CP0_TR_write(uint32_t val); -void CP0_TR_write_ptr(uint32_t* pPtr); -void CP0_TR_read_ptr(uint32_t* pPtr); -void ICACHE_invalidate_all(void); -void ICACHE_invalidate_at(uint32_t* pPtr); -void DCACHE_invalidate_all(void); -void DCACHE_invalidate_at(uint32_t* pPtr); - -void UART0_setbaud(uint32_t baudrate); -void UART1_setbaud(uint32_t baudrate); +void enter_critical(); +void exit_critical(); int write(int file, char *ptr, int len); int sputs(char const *pStr); diff --git a/src/libsys/mips_ps2.c b/src/libsys/mips_ps2.c index 608addf..71b27d6 100644 --- a/src/libsys/mips_ps2.c +++ b/src/libsys/mips_ps2.c @@ -396,17 +396,6 @@ static char __findkey(char scancode, int mode) #define ARROW_LEFT (SPECIALKEY|EXTENDED|0x6b) #define ARROW_RIGHT (SPECIALKEY|EXTENDED|0x74) -static uint32_t readchar(ps2_if_t *pIF) -{ - if (!pIF) - return -1; - - while (!(SYS_PS2_BIT_RX_AVAIL & *pIF->pCTRL)); - - return (*pIF->pDATA & 0xFF); - -} - uint32_t con_readchar(ps2_if_t *pIF) { uint8_t c; @@ -417,7 +406,8 @@ uint32_t con_readchar(ps2_if_t *pIF) int char_valid = 0; uint8_t key; - key = readchar(pIF); + while (!(SYS_PS2_BIT_RX_AVAIL & *pIF->pCTRL)); + key = *pIF->pDATA & 0xFF; switch (key) { diff --git a/src/libsys/uart.c b/src/libsys/uart.c index 68c1715..656dd45 100644 --- a/src/libsys/uart.c +++ b/src/libsys/uart.c @@ -20,6 +20,18 @@ 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); + +void UART_setbaud(void const *pInst, uint32_t baudrate) +{ + assert(pInst); + + uart_if_t *pReg = (uart_if_t*)pInst; + + *pReg->pBAUD = CALC_BAUD(baudrate); +} + int UART_readchar(void const *pInst) { assert(pInst); diff --git a/src/test_exception.c b/src/test_exception.c index 5634efd..0a34f73 100644 --- a/src/test_exception.c +++ b/src/test_exception.c @@ -171,13 +171,13 @@ void _exc_dbe(void) } -void handler0(void) +void handler0(struct xcptcontext *xcp) { printf("Interrupt 0\n"); interrupt_clr(0); } -void handler1(void) +void handler1(struct xcptcontext *xcp) { printf("Interrupt 1\n"); interrupt_clr(1); diff --git a/src/test_hpi.c b/src/test_hpi.c index ff350b6..6eb40fb 100644 --- a/src/test_hpi.c +++ b/src/test_hpi.c @@ -50,7 +50,7 @@ uint16_t makeBuffer16(uint16_t *pDst, uint8_t *pSrc, uint32_t size) } -void uart_handler(void) +void uart_handler(struct xcptcontext *xcp) { volatile uint32_t *pUART_stat = (uint32_t*)SYS_UART_STAT; volatile uint32_t *pUART_data = (uint32_t*)SYS_UART_DATA; diff --git a/src/test_irq.c b/src/test_irq.c index 25883d9..618b7ce 100644 --- a/src/test_irq.c +++ b/src/test_irq.c @@ -5,12 +5,7 @@ #include #include -#include #include "libsys.h" -#include "irq.h" -#include "mips_gfx.h" -#include "mips_ps2.h" -#include "libsys/console.h" #define PS2_NUM_IF 2 char buffer[16384]; @@ -23,27 +18,27 @@ static gfx_t gfx; static volatile int _g_posx, _g_posy; static volatile g_btn_l, g_btn_r; static volatile uint32_t g_color; -static int ps2_fd[PS2_NUM_IF]; +static char *ps2_name[PS2_NUM_IF] = {"PS2-0", "PS2-1"}; // ------------------------------------------------------------- -void handler0(void) +void handler0(struct xcptcontext *xcp) { printf("Interrupt 0\n"); interrupt_clr(0); } -void handler1(void) +void handler1(struct xcptcontext *xcp) { printf("Interrupt 1\n"); interrupt_clr(1); } -void handler2(void) +void handler2(struct xcptcontext *xcp) { printf("Interrupt 2\n"); } -void handler3(void) +void handler3(struct xcptcontext *xcp) { volatile uint32_t *pUART0_stat = (uint32_t*)SYS_UART0_STAT; volatile uint32_t *pUART0_data = (uint32_t*)SYS_UART0_DATA; @@ -68,12 +63,12 @@ void handler3(void) } -void handler4(void) +void handler4(struct xcptcontext *xcp) { printf("Interrupt 4\n"); } -void handler5(void) +void handler5(struct xcptcontext *xcp) { uint32_t volatile *pVGA_ctrl = (uint32_t*)SYS_VGA_CTRL; @@ -82,10 +77,10 @@ void handler5(void) } -void handler6(void) +void handler6(struct xcptcontext *xcp) { int p, i; - ps2_if_t const *pIF; + ps2_if_t *pIF; uint8_t mouse_rsp[3]; uint32_t timeout_count, key; @@ -93,7 +88,7 @@ void handler6(void) for (p=0; p < PS2_NUM_IF; p++) { - pIF = (ps2_if_t const *)con_getPort(ps2_fd[p])->pInst; + pIF = (ps2_if_t*)con_getInstanceByName(ps2_name[p]); if (SYS_PS2_BIT_RX_ERR_FLAG & *pIF->pCTRL) fprintf(stderr, "PS2[%d]: Status = 0x%08X\n", p, *pIF->pCTRL); @@ -209,7 +204,7 @@ int main(void) interrupt_register(7, (void*)handler7); srand(clock()); - UART1_setbaud(460800); + UART_setbaud(con_getInstanceByName("UART-1"), 460800); printf("Hello\n"); memset(buffer, 0, sizeof(buffer)); @@ -238,8 +233,8 @@ int main(void) printf("UART0 Status = 0x%8.8X\n", *pUART0_stat); printf("UART1 Status = 0x%8.8X\n", *pUART1_stat); - ps2_fd[0] = open("PS2-0", 0, 0); - ps2_fd[1] = open("PS2-1", 0, 0); + PS2_init((ps2_if_t*)con_getInstanceByName(ps2_name[0])); + PS2_init((ps2_if_t*)con_getInstanceByName(ps2_name[1])); sputs("r: "); print_word((int)pPtr_r); sputs("\n"); sputs("w: "); print_word((int)pPtr_w); sputs("\n"); @@ -256,8 +251,8 @@ int main(void) printf("Du schriebst: %s\n", string); // Flush buffer - PS2_flush((ps2_if_t*)(con_getPort(ps2_fd[0])->pInst)); - PS2_flush((ps2_if_t*)(con_getPort(ps2_fd[1])->pInst)); + PS2_flush((ps2_if_t*)con_getInstanceByName(ps2_name[0])); + PS2_flush((ps2_if_t*)con_getInstanceByName(ps2_name[1])); printf("Start:\n"); diff --git a/src/test_vga.c b/src/test_vga.c index d677c76..a6f7c96 100644 --- a/src/test_vga.c +++ b/src/test_vga.c @@ -5,11 +5,7 @@ #include #include -#include #include "libsys.h" -#include "irq.h" -#include "mips_gfx.h" -#include "mips_ps2.h" #define PS2_NUM_IF 2 static volatile int32_t mouse_x; @@ -19,10 +15,10 @@ static gfx_t gfx; static volatile int _g_posx, _g_posy; static volatile g_btn_l, g_btn_r; static volatile uint32_t g_color; -static int ps2_fd[PS2_NUM_IF]; +static char *ps2_name[PS2_NUM_IF] = {"PS2-0", "PS2-1"}; // ------------------------------------------------------------- -void handler5(void) +void handler5(struct xcptcontext *xcp) { uint32_t volatile *pVGA_ctrl = (uint32_t*)SYS_VGA_CTRL; @@ -31,10 +27,10 @@ void handler5(void) } -void handler6(void) +void handler6(struct xcptcontext *xcp) { int p, i; - ps2_if_t const *pIF; + ps2_if_t *pIF; uint8_t mouse_rsp[3]; uint32_t timeout_count, key; @@ -42,7 +38,7 @@ void handler6(void) for (p=0; p < PS2_NUM_IF; p++) { - pIF = (ps2_if_t const *)con_getPort(ps2_fd[p])->pInst; + pIF = (ps2_if_t*)con_getInstanceByName(ps2_name[p]); if (SYS_PS2_BIT_RX_ERR_FLAG & *pIF->pCTRL) fprintf(stderr, "PS2[%d]: Status = 0x%08X\n", p, *pIF->pCTRL); @@ -140,8 +136,8 @@ int main(void) interrupt_register(6, (void*)handler6); srand(clock()); - UART1_setbaud(460800); - + UART_setbaud(con_getInstanceByName("UART-1"), 460800); + *pVGA_cgcol = 0x00FFFFFF; _g_posx = _g_posy = 0; rmb_posx = rmb_posy = 0; @@ -157,12 +153,12 @@ int main(void) GFX_show(&gfx); printf("VGA status = %08X\n", *pVGA_ctrl); - ps2_fd[0] = open("PS2-0", 0, 0); - ps2_fd[1] = open("PS2-1", 0, 0); + PS2_init((ps2_if_t*)con_getInstanceByName(ps2_name[0])); + PS2_init((ps2_if_t*)con_getInstanceByName(ps2_name[1])); // Flush buffer - PS2_flush((ps2_if_t*)(con_getPort(ps2_fd[0])->pInst)); - PS2_flush((ps2_if_t*)(con_getPort(ps2_fd[1])->pInst)); + PS2_flush((ps2_if_t*)con_getInstanceByName(ps2_name[0])); + PS2_flush((ps2_if_t*)con_getInstanceByName(ps2_name[1])); // interrupt_enable(5); interrupt_enable(6); diff --git a/src/testbench.c b/src/testbench.c index 03be8a9..97c4c12 100644 --- a/src/testbench.c +++ b/src/testbench.c @@ -100,7 +100,7 @@ int IsEndianBig(void) return -1; } -void handler3(void) +void handler3(struct xcptcontext *xcp) { volatile uint32_t *pUART_stat = (uint32_t*)SYS_UART_STAT; volatile uint32_t *pUART_data = (uint32_t*)SYS_UART_DATA; @@ -117,7 +117,7 @@ box_t box; gfx_t gfx; int posx, posy; -void handler7(void) +void handler7(struct xcptcontext *xcp) { uint32_t volatile *pTim_stat = (uint32_t*)SYS_ITIM_STAT; uint32_t volatile *pTim_ctrl = (uint32_t*)SYS_ITIM_CTRL;