- removed call to dbg_init()
- added call to libsys_init() which calls dbg_init(). - added void Screen_clr(void); void Screen_line_clr(void); void Screen_csr_set_x(UINT32 coord); void Screen_csr_set_y(UINT32 coord); - changed register defines to UPPER-CASE Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@637 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -10,6 +10,14 @@
|
|||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
void libsys_init(void)
|
||||||
|
{
|
||||||
|
// Initalize debugger
|
||||||
|
dbg_init();
|
||||||
|
|
||||||
|
// Do some initializations here
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
UINT32 GetPort(int file)
|
UINT32 GetPort(int file)
|
||||||
{
|
{
|
||||||
@@ -69,19 +77,19 @@ typedef struct _scon_if_out_t
|
|||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
static uart_if_t uart_if[2] =
|
static uart_if_t uart_if[2] =
|
||||||
{
|
{
|
||||||
{(UINT32*)sys_uart0_stat, (UINT32*)sys_uart0_data, (UINT32*)sys_uart0_baud},
|
{(UINT32*)SYS_UART0_STAT, (UINT32*)SYS_UART0_DATA, (UINT32*)SYS_UART0_BAUD},
|
||||||
{(UINT32*)sys_uart1_stat, (UINT32*)sys_uart1_data, (UINT32*)sys_uart1_baud}
|
{(UINT32*)SYS_UART1_STAT, (UINT32*)SYS_UART1_DATA, (UINT32*)SYS_UART1_BAUD}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ps2_if_t ps2_if[2] =
|
static ps2_if_t ps2_if[2] =
|
||||||
{
|
{
|
||||||
{(UINT32*)sys_ps2_0_stat, (UINT32*)sys_ps2_0_data},
|
{(UINT32*)SYS_PS2_0_STAT, (UINT32*)SYS_PS2_0_DATA},
|
||||||
{(UINT32*)sys_ps2_1_stat, (UINT32*)sys_ps2_1_data}
|
{(UINT32*)SYS_PS2_1_STAT, (UINT32*)SYS_PS2_1_DATA}
|
||||||
};
|
};
|
||||||
|
|
||||||
static vga_if_t vga_if =
|
static vga_if_t vga_if =
|
||||||
{
|
{
|
||||||
(UINT32*)sys_vga_ctrl, (UINT32*)sys_vga_ascii, (UINT32*)sys_vga_posx, (UINT32*)sys_vga_posy
|
(UINT32*)SYS_VGA_CTRL, (UINT32*)SYS_VGA_ASCII, (UINT32*)SYS_VGA_POSX, (UINT32*)SYS_VGA_POSY
|
||||||
};
|
};
|
||||||
|
|
||||||
static con_if_in_t con_if_in[4] =
|
static con_if_in_t con_if_in[4] =
|
||||||
@@ -249,67 +257,73 @@ void DCACHE_invalidate_at(UINT32* pPtr)
|
|||||||
//keymap for the AT keyboard SG layout
|
//keymap for the AT keyboard SG layout
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char scancode;
|
UINT8 scancode;
|
||||||
char unshifted;
|
UINT8 unshifted;
|
||||||
char shifted;
|
UINT8 shifted;
|
||||||
|
UINT8 altered;
|
||||||
} libsys_key_entry_t;
|
} libsys_key_entry_t;
|
||||||
|
|
||||||
#define SHIFTED (1<<0)
|
#define SHIFTED (1<<0)
|
||||||
#define ALTERED (1<<1)
|
#define ALTERED (1<<1)
|
||||||
#define CONTROLLED (1<<2)
|
#define CONTROLLED (1<<2)
|
||||||
|
|
||||||
static const libsys_key_entry_t __keymap[] =
|
static const libsys_key_entry_t __keymap_german[] =
|
||||||
{
|
{
|
||||||
{0x1c, 'a', 'A'},
|
{0x1c, 'a', 'A', 'a'},
|
||||||
{0x32, 'b', 'B'},
|
{0x32, 'b', 'B', 'b'},
|
||||||
{0x21, 'c', 'C'},
|
{0x21, 'c', 'C', 'c'},
|
||||||
{0x23, 'd', 'D'},
|
{0x23, 'd', 'D', 'd'},
|
||||||
{0x24, 'e', 'E'},
|
{0x24, 'e', 'E', '€'},
|
||||||
{0x2b, 'f', 'F'},
|
{0x2b, 'f', 'F', 'f'},
|
||||||
{0x34, 'g', 'G'},
|
{0x34, 'g', 'G', 'g'},
|
||||||
{0x33, 'h', 'H'},
|
{0x33, 'h', 'H', 'h'},
|
||||||
{0x43, 'i', 'I'},
|
{0x43, 'i', 'I', 'i'},
|
||||||
{0x3b, 'j', 'J'},
|
{0x3b, 'j', 'J', 'j'},
|
||||||
{0x42, 'k', 'K'},
|
{0x42, 'k', 'K', 'k'},
|
||||||
{0x4b, 'l', 'L'},
|
{0x4b, 'l', 'L', 'l'},
|
||||||
{0x3a, 'm', 'M'},
|
{0x3a, 'm', 'M', 'µ'},
|
||||||
{0x31, 'n', 'N'},
|
{0x31, 'n', 'N', 'n'},
|
||||||
{0x44, 'o', 'O'},
|
{0x44, 'o', 'O', 'o'},
|
||||||
{0x4d, 'p', 'P'},
|
{0x4d, 'p', 'P', 'p'},
|
||||||
{0x15, 'q', 'Q'},
|
{0x15, 'q', 'Q', '@'},
|
||||||
{0x2d, 'r', 'R'},
|
{0x2d, 'r', 'R', 'r'},
|
||||||
{0x1b, 's', 'S'},
|
{0x1b, 's', 'S', 's'},
|
||||||
{0x2c, 't', 'T'},
|
{0x2c, 't', 'T', 't'},
|
||||||
{0x3c, 'u', 'U'},
|
{0x3c, 'u', 'U', 'u'},
|
||||||
{0x2a, 'v', 'V'},
|
{0x2a, 'v', 'V', 'v'},
|
||||||
{0x1d, 'w', 'W'},
|
{0x1d, 'w', 'W', 'w'},
|
||||||
{0x22, 'x', 'X'},
|
{0x22, 'x', 'X', 'x'},
|
||||||
{0x1a, 'y', 'Y'},
|
{0x1a, 'y', 'Y', 'y'},
|
||||||
{0x35, 'z', 'Z'},
|
{0x35, 'z', 'Z', 'z'},
|
||||||
{0x16, '1', '+'},
|
{0x16, '1', '!', '1'},
|
||||||
{0x1e, '2', '"'},
|
{0x1e, '2', '"', '2'},
|
||||||
{0x26, '3', '*'},
|
{0x26, '3', '§', '3'},
|
||||||
{0x25, '4', 'ç'},
|
{0x25, '4', '$', '4'},
|
||||||
{0x2e, '5', '%'},
|
{0x2e, '5', '%', '5'},
|
||||||
{0x36, '6', '&'},
|
{0x36, '6', '&', '6'},
|
||||||
{0x3d, '7', '/'},
|
{0x3d, '7', '/', '{'},
|
||||||
{0x3e, '8', '('},
|
{0x3e, '8', '(', '['},
|
||||||
{0x46, '9', ')'},
|
{0x46, '9', ')', ']'},
|
||||||
{0x45, '0', '='},
|
{0x45, '0', '=', '}'},
|
||||||
{0x29, ' ', ' '},
|
{0x4e, 'ß', '?', '\\'},
|
||||||
{0x41, ',', ';'},
|
{0x29, ' ', ' ', ' '},
|
||||||
{0x49, '.', ':'},
|
{0x41, ',', ';', ','},
|
||||||
{0x4a, '-', '_'},
|
{0x49, '.', ':', '.'},
|
||||||
{0x76, '\x1b', '\x1b'}, //ESC
|
{0x4a, '-', '_', '-'},
|
||||||
{0x5a, '\n', '\n'}, //RETURN
|
{0x52, 'ä', 'Ä', 'ä'},
|
||||||
{0x0d, '\t', '\t'}, //TAB
|
{0x4c, 'ö', 'Ö', 'ö'},
|
||||||
{0x66, '\b', '\b'}, //BS
|
{0x54, 'ü', 'Ü', 'ü'},
|
||||||
|
{0x5a, '\n', '\n', '\n'}, //RETURN
|
||||||
|
{0x5b, '+', '*', '~'},
|
||||||
|
{0x5d, '#', '\'', '#'},
|
||||||
|
{0x0e, '^', '°', '^'},
|
||||||
|
{0x61, '<', '>', '|'},
|
||||||
{0} //sentinel
|
{0} //sentinel
|
||||||
};
|
};
|
||||||
|
|
||||||
static char __findkey(char scancode, int mode)
|
static char __findkey(char scancode, int mode)
|
||||||
{
|
{
|
||||||
const libsys_key_entry_t *p = __keymap;
|
const libsys_key_entry_t *p = __keymap_german;
|
||||||
while (p->scancode)
|
while (p->scancode)
|
||||||
{
|
{
|
||||||
if (p->scancode == scancode)
|
if (p->scancode == scancode)
|
||||||
@@ -319,6 +333,7 @@ static char __findkey(char scancode, int mode)
|
|||||||
case SHIFTED:
|
case SHIFTED:
|
||||||
return p->shifted;
|
return p->shifted;
|
||||||
case ALTERED:
|
case ALTERED:
|
||||||
|
return p->altered;
|
||||||
case ALTERED|SHIFTED:
|
case ALTERED|SHIFTED:
|
||||||
default:
|
default:
|
||||||
return p->unshifted;
|
return p->unshifted;
|
||||||
@@ -358,15 +373,15 @@ UINT32 PS2_readchar(ps2_if_t *pIF)
|
|||||||
if (!pIF)
|
if (!pIF)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (!(sys_ps2_bit_rx_avail & *pIF->pCTRL));
|
while (!(SYS_PS2_BIT_RX_AVAIL & *pIF->pCTRL));
|
||||||
|
|
||||||
return (*pIF->pDATA & 0xFF);
|
return (*pIF->pDATA & 0xFF);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int con_readchar(ps2_if_t *pIF)
|
UINT32 con_readchar(ps2_if_t *pIF)
|
||||||
{
|
{
|
||||||
int c;
|
UINT8 c;
|
||||||
static char mode = 0;
|
static char mode = 0;
|
||||||
static char nextrelease = 0;
|
static char nextrelease = 0;
|
||||||
static char extended = 0;
|
static char extended = 0;
|
||||||
@@ -428,7 +443,7 @@ int con_readchar(ps2_if_t *pIF)
|
|||||||
|
|
||||||
if (char_valid)
|
if (char_valid)
|
||||||
{
|
{
|
||||||
// printf("c = %c (%d), flags = 0x%08X, mode = 0x%08X\n", c, c, flags, mode);
|
// fprintf(stderr, "c = %c (%d), flags = 0x%08X, mode = 0x%08X\n", c, c, flags, mode);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,7 +461,7 @@ int UART_readchar(uart_if_t *pIF)
|
|||||||
if (!pIF)
|
if (!pIF)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (sys_uart_bit_rx_avail & *pIF->pCTRL)
|
if (SYS_UART_BIT_RX_AVAIL & *pIF->pCTRL)
|
||||||
return (*pIF->pDATA & 0xFF);
|
return (*pIF->pDATA & 0xFF);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@@ -457,18 +472,92 @@ void UART_writechar(uart_if_t *pIF, char c)
|
|||||||
if (!pIF)
|
if (!pIF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while((sys_uart_bit_tx_halffull & *pIF->pCTRL) != 0);
|
while((SYS_UART_BIT_TX_HALFFULL & *pIF->pCTRL) != 0);
|
||||||
|
|
||||||
*pIF->pDATA = (UINT32)c;
|
*pIF->pDATA = (UINT32)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cg_writechar(vga_if_t *pIF, char c)
|
void cg_writechar(vga_if_t *pIF, char c)
|
||||||
{
|
{
|
||||||
|
UINT32 code;
|
||||||
|
|
||||||
if (!pIF)
|
if (!pIF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (!(*pIF->pCTRL & sys_vga_bit_cgrdy));
|
// Output translation
|
||||||
*pIF->pDATA = (UINT32)c;
|
switch(c)
|
||||||
|
{
|
||||||
|
case 'Ä':
|
||||||
|
code = 196;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'ä':
|
||||||
|
code = 228;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Ö':
|
||||||
|
code = 214;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'ö':
|
||||||
|
code = 246;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Ü':
|
||||||
|
code = 220;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'ü':
|
||||||
|
code = 252;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '&':
|
||||||
|
code = 230;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '§':
|
||||||
|
code = 167;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'ß':
|
||||||
|
code = 223;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '°':
|
||||||
|
code = 176;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'µ':
|
||||||
|
code = 181;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
code = (UINT32)c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||||
|
*pIF->pDATA = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cg_set_csr_x(vga_if_t *pIF, UINT32 coord)
|
||||||
|
{
|
||||||
|
if (!pIF)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set cursor
|
||||||
|
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||||
|
*pIF->pCSRX = coord;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cg_set_csr_y(vga_if_t *pIF, UINT32 coord)
|
||||||
|
{
|
||||||
|
if (!pIF)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set cursor
|
||||||
|
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||||
|
*pIF->pCSRY = coord;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cg_clr_line(vga_if_t *pIF)
|
void cg_clr_line(vga_if_t *pIF)
|
||||||
@@ -476,8 +565,8 @@ void cg_clr_line(vga_if_t *pIF)
|
|||||||
if (!pIF)
|
if (!pIF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (!(*pIF->pCTRL & sys_vga_bit_cgrdy));
|
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||||
*pIF->pCTRL |= sys_vga_bit_clrline;
|
*pIF->pCTRL |= SYS_VGA_BIT_CLRLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cg_clr_screen(vga_if_t *pIF)
|
void cg_clr_screen(vga_if_t *pIF)
|
||||||
@@ -486,23 +575,38 @@ void cg_clr_screen(vga_if_t *pIF)
|
|||||||
if (!pIF)
|
if (!pIF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (!(*pIF->pCTRL & sys_vga_bit_cgrdy));
|
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||||
*pIF->pCTRL |= sys_vga_bit_clrscr;
|
*pIF->pCTRL |= SYS_VGA_BIT_CLRSCR;
|
||||||
|
|
||||||
// Cursor home
|
// Cursor home
|
||||||
while (!(*pIF->pCTRL & sys_vga_bit_cgrdy));
|
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||||
*pIF->pCSRX = 0;
|
*pIF->pCSRX = 0;
|
||||||
|
|
||||||
while (!(*pIF->pCTRL & sys_vga_bit_cgrdy));
|
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||||
*pIF->pCSRY = 0;
|
*pIF->pCSRY = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clr_screen(void)
|
void Screen_clr(void)
|
||||||
{
|
{
|
||||||
cg_clr_screen(&vga_if);
|
cg_clr_screen(&vga_if);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Screen_line_clr(void)
|
||||||
|
{
|
||||||
|
cg_clr_line(&vga_if);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen_csr_set_x(UINT32 coord)
|
||||||
|
{
|
||||||
|
cg_set_csr_x(&vga_if, coord);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen_csr_set_y(UINT32 coord)
|
||||||
|
{
|
||||||
|
cg_set_csr_y(&vga_if, coord);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
char readchar(UINT32 port)
|
char readchar(UINT32 port)
|
||||||
{
|
{
|
||||||
@@ -572,15 +676,9 @@ void _putchar(UINT32 port, char c)
|
|||||||
cg_writechar((vga_if_t*)pIF->pIF, c);
|
cg_writechar((vga_if_t*)pIF->pIF, c);
|
||||||
if (c == 0x0A)
|
if (c == 0x0A)
|
||||||
{
|
{
|
||||||
|
cg_clr_line((vga_if_t*)pIF->pIF);
|
||||||
cg_writechar((vga_if_t*)pIF->pIF, 0x0D);
|
cg_writechar((vga_if_t*)pIF->pIF, 0x0D);
|
||||||
cg_clr_line((vga_if_t*)pIF->pIF);
|
|
||||||
}
|
}
|
||||||
if (c == 0x0D)
|
|
||||||
{
|
|
||||||
cg_writechar((vga_if_t*)pIF->pIF, 0x0A);
|
|
||||||
cg_clr_line((vga_if_t*)pIF->pIF);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -618,8 +716,8 @@ void sleep(unsigned ms)
|
|||||||
|
|
||||||
int getrusage(int who, struct rusage *usage)
|
int getrusage(int who, struct rusage *usage)
|
||||||
{
|
{
|
||||||
volatile long *pReg_usec = (long*)sys_timer_usec;
|
volatile long *pReg_usec = (long*)SYS_TIMER_USEC;
|
||||||
volatile long *pReg_sec = (long*)sys_timer_sec;
|
volatile long *pReg_sec = (long*)SYS_TIMER_SEC;
|
||||||
|
|
||||||
// who: RUSAGE_SELF or RUSAGE_CHILDREN
|
// who: RUSAGE_SELF or RUSAGE_CHILDREN
|
||||||
usage->ru_utime.tv_usec = *pReg_usec;
|
usage->ru_utime.tv_usec = *pReg_usec;
|
||||||
@@ -630,8 +728,8 @@ int getrusage(int who, struct rusage *usage)
|
|||||||
|
|
||||||
clock_t times(struct tms *buffer)
|
clock_t times(struct tms *buffer)
|
||||||
{
|
{
|
||||||
volatile long *pReg_usec = (long*)sys_timer_usec;
|
volatile long *pReg_usec = (long*)SYS_TIMER_USEC;
|
||||||
volatile long *pReg_sec = (long*)sys_timer_sec;
|
volatile long *pReg_sec = (long*)SYS_TIMER_SEC;
|
||||||
long sec;
|
long sec;
|
||||||
long usec;
|
long usec;
|
||||||
|
|
||||||
@@ -651,8 +749,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*)sys_timer_usec;
|
volatile long *pReg_usec = (long*)SYS_TIMER_USEC;
|
||||||
volatile long *pReg_sec = (long*)sys_timer_sec;
|
volatile long *pReg_sec = (long*)SYS_TIMER_SEC;
|
||||||
|
|
||||||
if (tp)
|
if (tp)
|
||||||
{
|
{
|
||||||
@@ -665,8 +763,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*)sys_timer_usec;
|
volatile long *pReg_usec = (long*)SYS_TIMER_USEC;
|
||||||
volatile long *pReg_sec = (long*)sys_timer_sec;
|
volatile long *pReg_sec = (long*)SYS_TIMER_SEC;
|
||||||
div_t res;
|
div_t res;
|
||||||
|
|
||||||
res = div(tp->tv_usec, 1E6);
|
res = div(tp->tv_usec, 1E6);
|
||||||
@@ -746,10 +844,9 @@ int read(int file, char *ptr, int len)
|
|||||||
while (i < len)
|
while (i < len)
|
||||||
{
|
{
|
||||||
c = readchar(port);
|
c = readchar(port);
|
||||||
|
_putchar(port, c);
|
||||||
if ((c == 0x0D) || (c == 0x0A))
|
if ((c == 0x0D) || (c == 0x0A))
|
||||||
{
|
{
|
||||||
writechar(port, 0x0D);
|
|
||||||
writechar(port, 0x0A);
|
|
||||||
if (i==0)
|
if (i==0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -759,7 +856,6 @@ int read(int file, char *ptr, int len)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptr[i++] = c;
|
ptr[i++] = c;
|
||||||
writechar(port, c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
Reference in New Issue
Block a user