Merge branch 'master' into net-dev
[akaros.git] / kern / arch / sparc / console.c
1 #include <arch/frontend.h>
2
3 void
4 cons_init(void)
5 {
6 }
7
8 // `High'-level console I/O.  Used by readline and cprintf.
9
10 void
11 cputbuf(const char*COUNT(len) buf, int len)
12 {
13         frontend_syscall(RAMP_SYSCALL_write,1,buf,len);
14 }
15
16 // Low-level console I/O
17
18 inline void
19 cons_putc(int c)
20 {
21         if(c == '\b')
22         {
23                 char buf[3] = {'\b', ' ', '\b'};
24                 cputbuf(buf,3);
25         }
26         else
27         {
28                 char ch = c;
29                 cputbuf(&ch,1);
30         }
31 }
32
33
34 void
35 cputchar(int c)
36 {
37         cons_putc(c);
38 }
39
40 int
41 cons_getc()
42 {
43         return frontend_syscall(RAMP_SYSCALL_getch,0,0,0);
44 }
45
46 int
47 getchar(void)
48 {
49         int c;
50
51         while ((c = cons_getc()) == 0)
52                 /* do nothing */;
53         return c;
54 }
55
56 int
57 iscons(int fdnum)
58 {
59         // used by readline
60         return 1;
61 }