2 #include "kernel/kernel.h"
3 #include <minix/minlib.h>
4 #include <minix/const.h>
5 #include <minix/cpufeature.h>
6 #include <minix/type.h>
10 #include <machine/partition.h>
12 #include "arch_proto.h"
13 #include "direct_utils.h"
16 #include <machine/multiboot.h>
18 /* Give non-zero values to avoid them in BSS */
19 static int print_line
= 1, print_col
= 1;
21 #include <sys/video.h>
23 extern char *video_mem
;
24 #define VIDOFFSET(line, col) ((line) * MULTIBOOT_CONSOLE_COLS * 2 + (col) * 2)
25 #define VIDSIZE VIDOFFSET(MULTIBOOT_CONSOLE_LINES-1,MULTIBOOT_CONSOLE_COLS-1)
27 void direct_put_char(char c
, int line
, int col
)
29 int offset
= VIDOFFSET(line
, col
);
30 video_mem
[offset
] = c
;
31 video_mem
[offset
+1] = 0x07; /* grey-on-black */
34 static char direct_get_char(int line
, int col
)
36 return video_mem
[VIDOFFSET(line
, col
)];
44 for(i
= 0; i
< MULTIBOOT_CONSOLE_COLS
; i
++)
45 for(j
= 0; j
< MULTIBOOT_CONSOLE_LINES
; j
++)
46 direct_put_char(' ', j
, i
);
48 print_line
= print_col
= 0;
50 /* Tell video hardware origin is 0. */
51 outb(C_6845
+INDEX
, VID_ORG
);
53 outb(C_6845
+INDEX
, VID_ORG
+1);
57 static void direct_scroll_up(int lines
)
60 for (i
= 0; i
< MULTIBOOT_CONSOLE_LINES
; i
++ ) {
61 for (j
= 0; j
< MULTIBOOT_CONSOLE_COLS
; j
++ ) {
63 if(i
< MULTIBOOT_CONSOLE_LINES
-lines
)
64 c
= direct_get_char(i
+ lines
, j
);
65 direct_put_char(c
, i
, j
);
71 void direct_print_char(char c
)
73 while (print_line
>= MULTIBOOT_CONSOLE_LINES
)
78 if(print_col
>= MULTIBOOT_CONSOLE_COLS
- TABWIDTH
) {
82 direct_put_char(' ', print_line
, print_col
++);
83 } while(print_col
% TABWIDTH
);
89 while (print_col
< MULTIBOOT_CONSOLE_COLS
)
90 direct_put_char(' ', print_line
, print_col
++);
96 direct_put_char(c
, print_line
, print_col
++);
98 if (print_col
>= MULTIBOOT_CONSOLE_COLS
) {
103 while (print_line
>= MULTIBOOT_CONSOLE_LINES
)
107 void direct_print(const char *str
)
110 direct_print_char(*str
);
115 /* Standard and AT keyboard. (PS/2 MCA implies AT throughout.) */
116 #define KEYBD 0x60 /* I/O port for keyboard data */
117 #define KB_STATUS 0x64 /* I/O port for status on AT */
118 #define KB_OUT_FULL 0x01 /* status bit set when keypress char pending */
119 #define KB_AUX_BYTE 0x20 /* Auxiliary Device Output Buffer Full */
121 int direct_read_char(unsigned char *ch
)
127 if (!(sb
& KB_OUT_FULL
)) {
133 if (!(sb
& KB_AUX_BYTE
))