Subversion Repositories HelenOS-historic

Rev

Rev 1490 | Rev 1498 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1490 Rev 1492
Line 29... Line 29...
29
#include <async.h>
29
#include <async.h>
30
#include <ipc/fb.h>
30
#include <ipc/fb.h>
31
#include <ipc/ipc.h>
31
#include <ipc/ipc.h>
32
#include <libc.h>
32
#include <libc.h>
33
#include <errno.h>
33
#include <errno.h>
-
 
34
#include <string.h>
-
 
35
#include <libc.h>
-
 
36
#include <stdio.h>
34
 
37
 
35
#include "sysio.h"
38
#include "sysio.h"
36
 
39
 
37
/* Allow only 1 connection */
40
/* Allow only 1 connection */
38
static int client_connected = 0;
41
static int client_connected = 0;
39
 
42
 
-
 
43
#define CLRSCR   "\033[2J"
-
 
44
 
40
static void sysput(char c)
45
static void sysput(char c)
41
{
46
{
42
    __SYSCALL3(SYS_IO, 1, (sysarg_t)&c, (sysarg_t) 1);
47
    __SYSCALL3(SYS_IO, 1, (sysarg_t)&c, (sysarg_t) 1);
43
}
48
}
44
 
49
 
-
 
50
static void sysputs(char *s)
-
 
51
{
-
 
52
    __SYSCALL3(SYS_IO, 1, (sysarg_t)s, strlen(s));
-
 
53
}
-
 
54
 
-
 
55
static void curs_goto(unsigned int row, unsigned int col)
-
 
56
{
-
 
57
    char control[20];
-
 
58
 
-
 
59
    if (row > 100 || col > 100)
-
 
60
        return;
-
 
61
 
-
 
62
    snprintf(control, 20, "\033[%d;%df",row, col);
-
 
63
    sysputs(control);
-
 
64
}
-
 
65
 
45
static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall)
66
static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall)
46
{
67
{
47
    int retval;
68
    int retval;
48
    ipc_callid_t callid;
69
    ipc_callid_t callid;
49
    ipc_call_t call;
70
    ipc_call_t call;
50
    char c;
71
    char c;
-
 
72
    int lastcol=0;
-
 
73
    int lastrow=0;
-
 
74
    int newcol,newrow;
51
 
75
 
52
    if (client_connected) {
76
    if (client_connected) {
53
        ipc_answer_fast(iid, ELIMIT, 0,0);
77
        ipc_answer_fast(iid, ELIMIT, 0,0);
54
        return;
78
        return;
55
    }
79
    }
Line 62... Line 86...
62
            client_connected = 0;
86
            client_connected = 0;
63
            ipc_answer_fast(callid,0,0,0);
87
            ipc_answer_fast(callid,0,0,0);
64
            return; /* Exit thread */
88
            return; /* Exit thread */
65
        case FB_PUTCHAR:
89
        case FB_PUTCHAR:
66
            c = IPC_GET_ARG1(call);
90
            c = IPC_GET_ARG1(call);
-
 
91
            newrow = IPC_GET_ARG2(call);
-
 
92
            newcol = IPC_GET_ARG3(call);
-
 
93
            if (lastcol != newcol || lastrow!=newrow)
-
 
94
                curs_goto(newrow, newcol);
-
 
95
            lastcol = newcol + 1;
-
 
96
            lastrow = newrow;
67
            sysput(c);
97
            sysput(c);
68
            retval = 0;
98
            retval = 0;
69
            break;
99
            break;
-
 
100
        case FB_CURSOR_GOTO:
-
 
101
            newrow = IPC_GET_ARG1(call);
-
 
102
            newcol = IPC_GET_ARG2(call);
-
 
103
            curs_goto(newrow, newcol);
-
 
104
            break;
70
        case FB_GET_CSIZE:
105
        case FB_GET_CSIZE:
71
            ipc_answer_fast(callid, 0, 25, 80);
106
            ipc_answer_fast(callid, 0, 25, 80);
72
            continue;
107
            continue;
-
 
108
        case FB_CLEAR:
-
 
109
            sysputs(CLRSCR);
-
 
110
            retval = 0;
-
 
111
            break;
73
        default:
112
        default:
74
            retval = ENOENT;
113
            retval = ENOENT;
75
        }
114
        }
76
        ipc_answer_fast(callid,retval,0,0);
115
        ipc_answer_fast(callid,retval,0,0);
77
    }
116
    }
78
}
117
}
79
 
118
 
80
void sysio_init(void)
119
void sysio_init(void)
81
{
120
{
82
    async_set_client_connection(sysio_client_connection);
121
    async_set_client_connection(sysio_client_connection);
-
 
122
    sysputs(CLRSCR);
-
 
123
    curs_goto(0,0);
83
}
124
}