- refactored libsys

- added critical section
- added interrupt global enable/disable
- added console::getInstanveByName



git-svn-id: http://moon:8086/svn/mips@76 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2017-01-12 16:25:20 +00:00
parent 0f4b7e015f
commit 5c9c50ebeb
21 changed files with 129 additions and 307 deletions
+15 -20
View File
@@ -5,12 +5,7 @@
#include <sys/times.h>
#include <sys/time.h>
#include <console.h>
#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");