foo
[eightysix] / kern / src / disp.c
diff --git a/kern/src/disp.c b/kern/src/disp.c
new file mode 100644 (file)
index 0000000..f6e9014
--- /dev/null
@@ -0,0 +1,104 @@
+#include "disp.h"
+
+static void detect_video(void);
+
+struct console con_disp = { clear_disp, disp_putc, 0 };
+
+static uint16_t __far *vmem;
+static uint16_t cur_attr;
+static int cur_x, cur_y;
+static int cur_scroll;
+static int mono;
+
+void init_disp(void)
+{
+       detect_video();
+}
+
+static void detect_video(void)
+{
+       mono = 0;
+       disp_type = DISP_UNK;
+
+       if(detect_vgainfo() == 0) {
+               goto done;
+       }
+       if(detect_egainfo() == 0) {
+               goto done;
+       }
+       if(detect_eqlist() == 0) {
+               goto done;
+       }
+
+done:
+       vmem = mono ? MK_FP(0xb000, 0) : MK_FP(0xb800, 0);
+}
+
+static int detect_vgainfo(void)
+{
+       union regs regs;
+
+       regs.w.ax = 0x1a00;
+       int86(0x10, &regs, &regs);
+       if(regs.h.al != 0x1a) {
+               return -1;
+       }
+
+       switch(regs.h.bl) {
+       case 1:
+               disp_type = DISP_MDA;
+               mono = 1;
+               break;
+       case 2:
+               disp_type = DISP_CGA;
+               break;
+       case 4:
+               disp_type = DISP_EGA;
+               break;
+       case 5:
+               disp_type = DISP_EGA;
+               mono = 1;
+               break;
+       case 6:
+               disp_type = DISP_PGA;
+               break;
+       case 7:
+               disp_type = DISP_VGA;
+               mono = 1;
+               break;
+       case 8:
+               disp_type = DISP_VGA;
+               break;
+       case 0xa:
+       case 0xc:
+               disp_type = DISP_MCGA;
+               break;
+       case 0xb:
+               disp_type = DISP_MCGA;
+               mono = 1;
+               break;
+       default:
+               return -1;
+       }
+       return 0;
+}
+
+static int detect_egainfo(void)
+{
+       union regs regs;
+
+       regs.w.ax = 0x1200;
+       regs.w.bx = 0xff10;
+       int86(0x10, &regs, &regs);
+       if(regs.h.bh == 0xff) {
+               return -1;
+       }
+
+       disp_type = DISP_EGA;
+       mono = regs.h.bh;
+       return 0;
+}
+
+static int detect_eqlist(void)
+{
+}