2 #include <minix/minlib.h>
3 #include <minix/cpufeature.h>
4 #include <machine/partition.h>
6 #include "direct_utils.h"
10 /* Give non-zero values to avoid them in BSS */
11 static int print_line
= 1, print_col
= 1;
13 #include <sys/video.h>
15 extern char *video_mem
;
16 #define VIDOFFSET(line, col) ((line) * MULTIBOOT_CONSOLE_COLS * 2 + (col) * 2)
17 #define VIDSIZE VIDOFFSET(MULTIBOOT_CONSOLE_LINES-1,MULTIBOOT_CONSOLE_COLS-1)
19 void direct_put_char(char c
, int line
, int col
)
21 int offset
= VIDOFFSET(line
, col
);
22 video_mem
[offset
] = c
;
23 video_mem
[offset
+1] = 0x07; /* grey-on-black */
26 static char direct_get_char(int line
, int col
)
28 return video_mem
[VIDOFFSET(line
, col
)];
36 for(i
= 0; i
< MULTIBOOT_CONSOLE_COLS
; i
++)
37 for(j
= 0; j
< MULTIBOOT_CONSOLE_LINES
; j
++)
38 direct_put_char(' ', j
, i
);
40 print_line
= print_col
= 0;
42 /* Tell video hardware origin is 0. */
43 outb(C_6845
+INDEX
, VID_ORG
);
45 outb(C_6845
+INDEX
, VID_ORG
+1);
49 static void direct_scroll_up(int lines
)
52 for (i
= 0; i
< MULTIBOOT_CONSOLE_LINES
; i
++ ) {
53 for (j
= 0; j
< MULTIBOOT_CONSOLE_COLS
; j
++ ) {
55 if(i
< MULTIBOOT_CONSOLE_LINES
-lines
)
56 c
= direct_get_char(i
+ lines
, j
);
57 direct_put_char(c
, i
, j
);
63 void direct_print_char(char c
)
65 while (print_line
>= MULTIBOOT_CONSOLE_LINES
)
70 if(print_col
>= MULTIBOOT_CONSOLE_COLS
- TABWIDTH
) {
74 direct_put_char(' ', print_line
, print_col
++);
75 } while(print_col
% TABWIDTH
);
81 while (print_col
< MULTIBOOT_CONSOLE_COLS
)
82 direct_put_char(' ', print_line
, print_col
++);
88 direct_put_char(c
, print_line
, print_col
++);
90 if (print_col
>= MULTIBOOT_CONSOLE_COLS
) {
95 while (print_line
>= MULTIBOOT_CONSOLE_LINES
)
99 void direct_print(const char *str
)
102 direct_print_char(*str
);
107 /* Standard and AT keyboard. (PS/2 MCA implies AT throughout.) */
108 #define KEYBD 0x60 /* I/O port for keyboard data */
109 #define KB_STATUS 0x64 /* I/O port for status on AT */
110 #define KB_OUT_FULL 0x01 /* status bit set when keypress char pending */
111 #define KB_AUX_BYTE 0x20 /* Auxiliary Device Output Buffer Full */
113 int direct_read_char(unsigned char *ch
)
119 if (!(sb
& KB_OUT_FULL
)) {
125 if (!(sb
& KB_AUX_BYTE
))