Initial git release
[ZeXOS.git] / kernel / system_call.c
bloba56fb95c442e3a72e5a88d88ee5912d2e093d3b0
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <system.h>
21 #include <x86.h>
22 #include <string.h>
23 #include <tty.h>
24 int sattrib = 0x0F;
26 void sys_exit (struct regs *r)
28 printf ("exit (%u)\n", r->ebx);
31 extern int csr_x, csr_y;
32 extern void scroll (void);
33 extern void move_csr (void);
34 void sys_gotoxy (struct regs *r)
36 csr_x = r->ebx;
37 csr_y = r->ecx;
39 scroll ();
40 move_csr ();
43 extern unsigned char scancode;
44 void sys_getkey (struct regs *r)
46 unsigned att = sattrib << 8;
47 unsigned short *where;
48 unsigned char c = (unsigned char) scancode;
50 unsigned short *memptr = (unsigned short *) 0x9000;
51 where = memptr;
52 *where = c | att;
55 void sys_getch (struct regs *r)
57 // asm volatile ("movl %0, %%eax" :: "g" (key));
58 // asm volatile ("movl 'H', $0x");
59 unsigned att = sattrib << 8;
60 unsigned short *where;
61 unsigned char c;
63 if (key != 0) {
64 c = (unsigned char) key;
66 key = 0;
69 unsigned short *memptr = (unsigned short *) 0x9000;
70 where = memptr;
71 *where = c | att;
75 void sys_sleep (struct regs *r)
77 timer_wait (r->ebx*18);
81 void sys_putch (struct regs *r)
83 tty_putch (r->ebx);
86 void sys_color (struct regs *r)
88 settextcolor (r->ebx, r->ecx);
91 void sys_cls (struct regs *r)
93 tty_cls (currtty);
96 void syscall_handler (struct regs *r)
98 switch (r->eax) {
99 case 1:
100 sys_exit (r);
101 break;
102 case 2:
103 sys_getch (r);
104 break;
105 case 3:
106 sys_sleep (r);
107 break;
108 case 4:
109 sys_putch (r);
110 break;
111 case 5:
112 sys_color (r);
113 break;
114 case 6:
115 sys_cls (r);
116 break;
117 case 7:
118 sys_getkey (r);
119 break;
120 case 8:
121 sys_gotoxy (r);
122 break;
125 /* In either case, we need to send an EOI to the master
126 * interrupt controller too */
127 outportb(0x20, 0x20);