3 #include <minix/minlib.h>
4 #include <minix/const.h>
5 #include <minix/cpufeature.h>
6 #include <minix/types.h>
7 #include <minix/type.h>
10 #include <machine/partition.h>
13 #include "arch_proto.h"
15 #include "direct_utils.h"
18 #include <machine/multiboot.h>
20 /* Give non-zero values to avoid them in BSS */
21 static int print_line
= 1, print_col
= 1;
23 #include <sys/video.h>
25 extern char *video_mem
;
26 #define VIDOFFSET(line, col) ((line) * MULTIBOOT_CONSOLE_COLS * 2 + (col) * 2)
27 #define VIDSIZE VIDOFFSET(MULTIBOOT_CONSOLE_LINES-1,MULTIBOOT_CONSOLE_COLS-1)
29 void direct_put_char(char c
, int line
, int col
)
31 int offset
= VIDOFFSET(line
, col
);
32 video_mem
[offset
] = c
;
33 video_mem
[offset
+1] = 0x07; /* grey-on-black */
36 static char direct_get_char(int line
, int col
)
38 return video_mem
[VIDOFFSET(line
, col
)];
46 for(i
= 0; i
< MULTIBOOT_CONSOLE_COLS
; i
++)
47 for(j
= 0; j
< MULTIBOOT_CONSOLE_LINES
; j
++)
48 direct_put_char(' ', j
, i
);
50 print_line
= print_col
= 0;
52 /* Tell video hardware origin is 0. */
53 outb(C_6845
+INDEX
, VID_ORG
);
55 outb(C_6845
+INDEX
, VID_ORG
+1);
59 static void direct_scroll_up(int lines
)
62 for (i
= 0; i
< MULTIBOOT_CONSOLE_LINES
; i
++ ) {
63 for (j
= 0; j
< MULTIBOOT_CONSOLE_COLS
; j
++ ) {
65 if(i
< MULTIBOOT_CONSOLE_LINES
-lines
)
66 c
= direct_get_char(i
+ lines
, j
);
67 direct_put_char(c
, i
, j
);
73 void direct_print_char(char c
)
75 while (print_line
>= MULTIBOOT_CONSOLE_LINES
)
80 if(print_col
>= MULTIBOOT_CONSOLE_COLS
- TABWIDTH
) {
84 direct_put_char(' ', print_line
, print_col
++);
85 } while(print_col
% TABWIDTH
);
91 while (print_col
< MULTIBOOT_CONSOLE_COLS
)
92 direct_put_char(' ', print_line
, print_col
++);
98 direct_put_char(c
, print_line
, print_col
++);
100 if (print_col
>= MULTIBOOT_CONSOLE_COLS
) {
105 while (print_line
>= MULTIBOOT_CONSOLE_LINES
)
109 void direct_print(const char *str
)
112 direct_print_char(*str
);
117 /* Standard and AT keyboard. (PS/2 MCA implies AT throughout.) */
118 #define KEYBD 0x60 /* I/O port for keyboard data */
119 #define KB_STATUS 0x64 /* I/O port for status on AT */
120 #define KB_OUT_FULL 0x01 /* status bit set when keypress char pending */
121 #define KB_AUX_BYTE 0x20 /* Auxiliary Device Output Buffer Full */
123 int direct_read_char(unsigned char *ch
)
129 if (!(sb
& KB_OUT_FULL
)) {
135 if (!(sb
& KB_AUX_BYTE
))