f6e9014f367121d6ba23ab05529c9b5194747580
[eightysix] / kern / src / disp.c
1 #include "disp.h"
2
3 static void detect_video(void);
4
5 struct console con_disp = { clear_disp, disp_putc, 0 };
6
7 static uint16_t __far *vmem;
8 static uint16_t cur_attr;
9 static int cur_x, cur_y;
10 static int cur_scroll;
11 static int mono;
12
13 void init_disp(void)
14 {
15         detect_video();
16 }
17
18 static void detect_video(void)
19 {
20         mono = 0;
21         disp_type = DISP_UNK;
22
23         if(detect_vgainfo() == 0) {
24                 goto done;
25         }
26         if(detect_egainfo() == 0) {
27                 goto done;
28         }
29         if(detect_eqlist() == 0) {
30                 goto done;
31         }
32
33 done:
34         vmem = mono ? MK_FP(0xb000, 0) : MK_FP(0xb800, 0);
35 }
36
37 static int detect_vgainfo(void)
38 {
39         union regs regs;
40
41         regs.w.ax = 0x1a00;
42         int86(0x10, &regs, &regs);
43         if(regs.h.al != 0x1a) {
44                 return -1;
45         }
46
47         switch(regs.h.bl) {
48         case 1:
49                 disp_type = DISP_MDA;
50                 mono = 1;
51                 break;
52         case 2:
53                 disp_type = DISP_CGA;
54                 break;
55         case 4:
56                 disp_type = DISP_EGA;
57                 break;
58         case 5:
59                 disp_type = DISP_EGA;
60                 mono = 1;
61                 break;
62         case 6:
63                 disp_type = DISP_PGA;
64                 break;
65         case 7:
66                 disp_type = DISP_VGA;
67                 mono = 1;
68                 break;
69         case 8:
70                 disp_type = DISP_VGA;
71                 break;
72         case 0xa:
73         case 0xc:
74                 disp_type = DISP_MCGA;
75                 break;
76         case 0xb:
77                 disp_type = DISP_MCGA;
78                 mono = 1;
79                 break;
80         default:
81                 return -1;
82         }
83         return 0;
84 }
85
86 static int detect_egainfo(void)
87 {
88         union regs regs;
89
90         regs.w.ax = 0x1200;
91         regs.w.bx = 0xff10;
92         int86(0x10, &regs, &regs);
93         if(regs.h.bh == 0xff) {
94                 return -1;
95         }
96
97         disp_type = DISP_EGA;
98         mono = regs.h.bh;
99         return 0;
100 }
101
102 static int detect_eqlist(void)
103 {
104 }