- added getpid(), kill(), link(), unlink()
- modifed read() - added flush() for UART - added screen_get_resx(), screen_get_resy(), screen_get_fps() - added some more initializations in libsys_init() 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@696 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -7,14 +7,38 @@
|
||||
#include <stdlib.h>
|
||||
#include "libsys.h"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
// ---------------------------------------------------------------------------------
|
||||
void flush(UINT32 port);
|
||||
UINT32 GetPort(int file);
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Types
|
||||
// ---------------------------------------------------------------------------------
|
||||
void libsys_init(void)
|
||||
{
|
||||
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
|
||||
UINT32 volatile *pITIM_ctrl = (UINT32*)SYS_ITIM_CTRL;
|
||||
|
||||
Screen_clr();
|
||||
|
||||
// Disable timers
|
||||
*pITIM_ctrl = 0;
|
||||
|
||||
// Disable all VGA stuff
|
||||
*pVGA_ctrl = 0;
|
||||
|
||||
// Initialzie syscall support
|
||||
syscalls_init();
|
||||
|
||||
// Initalize debugger
|
||||
dbg_init();
|
||||
|
||||
// flush stdin
|
||||
flush(GetPort(0));
|
||||
|
||||
// Do some initializations here
|
||||
|
||||
}
|
||||
@@ -22,13 +46,13 @@ void libsys_init(void)
|
||||
UINT32 GetPort(int file)
|
||||
{
|
||||
if (file == 0)
|
||||
return 2;
|
||||
return 0;
|
||||
|
||||
if (file == 1)
|
||||
return 2;
|
||||
return 0;
|
||||
|
||||
if (file == 2)
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
enum
|
||||
@@ -81,11 +105,7 @@ static uart_if_t uart_if[2] =
|
||||
{(UINT32*)SYS_UART1_STAT, (UINT32*)SYS_UART1_DATA, (UINT32*)SYS_UART1_BAUD}
|
||||
};
|
||||
|
||||
static ps2_if_t ps2_if[2] =
|
||||
{
|
||||
{(UINT32*)SYS_PS2_0_STAT, (UINT32*)SYS_PS2_0_DATA},
|
||||
{(UINT32*)SYS_PS2_1_STAT, (UINT32*)SYS_PS2_1_DATA}
|
||||
};
|
||||
extern ps2_if_t ps2_if[];
|
||||
|
||||
static vga_if_t vga_if =
|
||||
{
|
||||
@@ -318,6 +338,7 @@ static const libsys_key_entry_t __keymap_german[] =
|
||||
{0x5d, '#', '\'', '#'},
|
||||
{0x0e, '^', '°', '^'},
|
||||
{0x61, '<', '>', '|'},
|
||||
{0x66, '\b', '\b', '\b'},
|
||||
{0} //sentinel
|
||||
};
|
||||
|
||||
@@ -607,7 +628,54 @@ void Screen_csr_set_y(UINT32 coord)
|
||||
cg_set_csr_y(&vga_if, coord);
|
||||
}
|
||||
|
||||
UINT32 Screen_get_resx(void)
|
||||
{
|
||||
UINT32 volatile *pVGA_res = (UINT32*)SYS_VGA_RES;
|
||||
|
||||
return (0xFFF & (*pVGA_res >> 0));
|
||||
}
|
||||
|
||||
UINT32 Screen_get_resy(void)
|
||||
{
|
||||
UINT32 volatile *pVGA_res = (UINT32*)SYS_VGA_RES;
|
||||
|
||||
return (0xFFF & (*pVGA_res >> 12));
|
||||
}
|
||||
|
||||
UINT32 Screen_get_fps(void)
|
||||
{
|
||||
UINT32 volatile *pVGA_res = (UINT32*)SYS_VGA_RES;
|
||||
|
||||
return (0xFF & (*pVGA_res >> 24));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
void flush(UINT32 port)
|
||||
{
|
||||
int c;
|
||||
con_if_in_t *pIF;
|
||||
|
||||
pIF = &con_if_in[port];
|
||||
|
||||
do
|
||||
{
|
||||
switch(pIF->type)
|
||||
{
|
||||
case IF_TYPE_UART:
|
||||
c = UART_readchar((uart_if_t*)pIF->pIF);
|
||||
break;
|
||||
|
||||
case IF_TYPE_PS2:
|
||||
c = con_readchar((ps2_if_t*)pIF->pIF);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} while(c > 0);
|
||||
}
|
||||
|
||||
char readchar(UINT32 port)
|
||||
{
|
||||
int c;
|
||||
@@ -837,26 +905,29 @@ int read(int file, char *ptr, int len)
|
||||
int i;
|
||||
char c;
|
||||
|
||||
// sputs("read ("); print_word(file); sputs(")\n");
|
||||
// sputs("read (file="); print_word(file); sputs(", len ="); print_word(len); sputs(")\n");
|
||||
i = 0;
|
||||
port = GetPort(file);
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
c = readchar(port);
|
||||
_putchar(port, c);
|
||||
|
||||
if (c == 0x04)
|
||||
break;
|
||||
|
||||
if ((c == 0x0D) || (c == 0x0A))
|
||||
{
|
||||
if (i==0)
|
||||
continue;
|
||||
|
||||
ptr[i++] = c;
|
||||
writechar(port, 0x0D);
|
||||
ptr[i++] = 0x0D;
|
||||
writechar(port, 0x0A);
|
||||
ptr[i++] = 0x0A;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr[i++] = c;
|
||||
}
|
||||
|
||||
writechar(port, c);
|
||||
ptr[i++] = c;
|
||||
|
||||
}
|
||||
return i;
|
||||
}
|
||||
@@ -881,6 +952,38 @@ int isatty(int file)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int getpid(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#include <errno.h>
|
||||
#undef errno
|
||||
extern int errno;
|
||||
int kill(int pid, int sig)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#include <errno.h>
|
||||
#undef errno
|
||||
extern int errno;
|
||||
int link(char *old, char *new)
|
||||
{
|
||||
errno = EMLINK;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#include <errno.h>
|
||||
#undef errno
|
||||
extern int errno;
|
||||
int unlink(char *name)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int sputs(char *pStr)
|
||||
{
|
||||
char *start;
|
||||
|
||||
Reference in New Issue
Block a user