summaryrefslogtreecommitdiff
path: root/kernel/syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/syscalls.c')
-rw-r--r--kernel/syscalls.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/kernel/syscalls.c b/kernel/syscalls.c
index 8007b1d..782ae86 100644
--- a/kernel/syscalls.c
+++ b/kernel/syscalls.c
@@ -26,13 +26,10 @@ static fifo fifos[MAX_FIFOS];
static uint32_t fifo_data_len[MAX_FIFOS];
static uint32_t next_fifo=0;
-extern uint32_t fb_addr;
-
// screen / terminal
term_out screen;
terminal_tty tty1;
-
int syscall_unhandled(int nr)
{
char msg[256];
@@ -67,13 +64,11 @@ int syscall_lseek(int file,int ptr,int dir)
// TODO: /dev/console or /dev/tty1 - /dev/ttyN
int syscall_write(int file, char *buf, int len)
{
-
for(int i=0;i<len;i++)
{
fd_write(&fds[file],buf[i]);
fifo_data_len[file]++;
}
-
return len;
}
@@ -240,35 +235,36 @@ int get_max_fd()
// TODO: allow opening existing files/named pipes
int syscall_open(char *name, int flags, int mode)
{
+
if( next_fifo>=MAX_FIFOS || next_fd>=MAX_FD)kpanic("we ran out of fd's or fifo's");
-
- if(0!=strcmp(name,"term"))
- {
- fifos[next_fifo]=fifo_create_buffered(1);
- fds[next_fd]=fd_from_fifo(&fifos[next_fifo]);
- }
- else
+ if(!strcmp(name,"term"))
{
-
- // HERE WE SEE THE GENIUS OF OUR ABSTRACTIONS (I HOPE...)
-
- if (fb_addr<0x100000) // text-mode
- {
screen.put_char=console_put_char;
screen.update_cursor=update_cursor;
- }
- else // framebuffer mode
- {
+
+ tty1=terminal_init(&screen,NULL);
+
+ fifos[next_fifo].data=&tty1;
+ fifos[next_fifo].put=terminal_put;
+
+ fds[next_fd]=fd_from_fifo(&fifos[next_fifo]);
+ }
+ else if(!strcmp(name,"xterm"))
+ {
screen.put_char=vesa_console_put_char;
screen.update_cursor=vesa_update_cursor;
- }
- tty1=terminal_init(&screen,NULL);
+ tty1=terminal_init(&screen,NULL);
- fifos[next_fifo].data=&tty1;
- fifos[next_fifo].put=terminal_put;
+ fifos[next_fifo].data=&tty1;
+ fifos[next_fifo].put=terminal_put;
+ fds[next_fd]=fd_from_fifo(&fifos[next_fifo]);
+ }
+ else
+ {
+ fifos[next_fifo]=fifo_create_buffered(1);
fds[next_fd]=fd_from_fifo(&fifos[next_fifo]);
}