added PS/2 mouse code
[bootcensus] / src / kmain.c
1 /*
2 pcboot - bootable PC demo/game kernel
3 Copyright (C) 2018  John Tsiombikas <nuclear@member.fsf.org>
4
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.
9
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.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18 #include <stdio.h>
19 #include <string.h>
20 #include <ctype.h>
21 #include "segm.h"
22 #include "intr.h"
23 #include "mem.h"
24 #include "keyb.h"
25 #include "psaux.h"
26 #include "timer.h"
27 #include "contty.h"
28 #include "video.h"
29 #include "pci.h"
30 #include "vbetest.h"
31
32
33 void logohack(void);
34
35 void pcboot_main(void)
36 {
37         init_segm();
38         init_intr();
39
40         con_init();
41         kb_init();
42         init_psaux();
43
44         init_mem();
45
46         init_pci();
47
48         /* initialize the timer */
49         init_timer();
50
51         enable_intr();
52
53         printf("PCBoot kernel initialized\n");
54
55         for(;;) {
56                 int c;
57
58                 halt_cpu();
59                 while((c = kb_getkey()) >= 0) {
60                         switch(c) {
61                         case KB_F1:
62                                 set_vga_mode(0x13);
63                                 logohack();
64                                 set_vga_mode(3);
65                                 break;
66
67                         case KB_F2:
68                                 vbetest();
69                                 break;
70                         }
71                         if(isprint(c)) {
72                                 printf("key: %d '%c'\n", c, (char)c);
73                         } else {
74                                 printf("key: %d\n", c);
75                         }
76                 }
77                 if((nticks % 250) == 0) {
78                         con_printf(71, 0, "[%ld]", nticks);
79                 }
80         }
81 }