8af7cc37fa4a090d90b9a4d74f0db3d98a78eea3
[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 "audio.h"
30 #include "pci.h"
31 #include "vbetest.h"
32
33
34 void logohack(void);
35
36 void pcboot_main(void)
37 {
38         init_segm();
39         init_intr();
40
41         con_init();
42         kb_init();
43         init_psaux();
44
45         init_mem();
46
47         init_pci();
48
49         /* initialize the timer */
50         init_timer();
51
52         audio_init();
53
54         enable_intr();
55
56         printf("PCBoot kernel initialized\n");
57
58         for(;;) {
59                 int c;
60
61                 halt_cpu();
62                 while((c = kb_getkey()) >= 0) {
63                         switch(c) {
64                         case KB_F1:
65                                 set_vga_mode(0x13);
66                                 logohack();
67                                 set_vga_mode(3);
68                                 break;
69
70                         case KB_F2:
71                                 vbetest();
72                                 break;
73                         }
74                         if(isprint(c)) {
75                                 printf("key: %d '%c'\n", c, (char)c);
76                         } else {
77                                 printf("key: %d\n", c);
78                         }
79                 }
80                 if((nticks % 250) == 0) {
81                         con_printf(71, 0, "[%ld]", nticks);
82                 }
83         }
84 }