3 * Daniel Engström, Omicron Ceti AB, daniel@omicron.se
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/ptrace.h>
29 #include <asm/realmode.h>
34 /* basic textmode I/O from linux kernel */
35 static char *vidmem = (char *)0xb8000;
37 static int lines, cols;
38 static int orig_x, orig_y;
40 static void beep(int dur)
45 for (i=0;i<10*dur;i++) {
51 static void scroll(void)
55 memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 );
56 for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 )
60 static void __video_putc(const char c, int *x, int *y)
64 if ( ++(*y) >= lines ) {
68 } else if (c == '\b') {
71 vidmem [ ( (*x) + cols * (*y) ) * 2 ] = ' ';
73 } else if (c == '\r') {
76 } else if (c == '\a') {
79 } else if (c == '\t') {
80 __video_putc(' ', x, y);
81 __video_putc(' ', x, y);
82 __video_putc(' ', x, y);
83 __video_putc(' ', x, y);
84 __video_putc(' ', x, y);
85 __video_putc(' ', x, y);
86 __video_putc(' ', x, y);
87 __video_putc(' ', x, y);
88 } else if (c == '\v') {
91 __video_putc(' ', x, y);
93 __video_putc(' ', x, y);
95 __video_putc(' ', x, y);
97 __video_putc(' ', x, y);
99 __video_putc(' ', x, y);
101 __video_putc(' ', x, y);
103 __video_putc(' ', x, y);
105 __video_putc(' ', x, y);
107 } else if (c == '\f') {
109 for (i=0;i<lines*cols*2;i+=2) {
115 vidmem [ ( (*x) + cols * (*y) ) * 2 ] = c;
116 if ( ++(*x) >= cols ) {
118 if ( ++(*y) >= lines ) {
126 static void video_putc(const char c)
133 __video_putc(c, &x, &y);
138 pos = (x + cols * y) * 2; /* Update cursor position */
140 outb_p(0xff & (pos >> 9), vidport+1);
142 outb_p(0xff & (pos >> 1), vidport+1);
145 static void video_puts(const char *s)
153 while ( ( c = *s++ ) != '\0' ) {
154 __video_putc(c, &x, &y);
160 pos = (x + cols * y) * 2; /* Update cursor position */
162 outb_p(0xff & (pos >> 9), vidport+1);
164 outb_p(0xff & (pos >> 1), vidport+1);
171 static device_t vga_dev;
172 static device_t kbd_dev;
174 vidmem = (char *) 0xb8000;
181 pos = inb_p(vidport+1);
184 pos |= inb_p(vidport+1);
190 printf("pos %x %d %d\n", pos, orig_x, orig_y);
192 if (orig_y > lines) {
197 memset(&vga_dev, 0, sizeof(vga_dev));
198 strcpy(vga_dev.name, "vga");
200 vga_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
201 vga_dev.putc = video_putc; /* 'putc' function */
202 vga_dev.puts = video_puts; /* 'puts' function */
203 vga_dev.tstc = NULL; /* 'tstc' function */
204 vga_dev.getc = NULL; /* 'getc' function */
206 if (device_register(&vga_dev) == 0) {
210 if (i8042_kbd_init()) {
214 memset(&kbd_dev, 0, sizeof(kbd_dev));
215 strcpy(kbd_dev.name, "kbd");
217 kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
218 kbd_dev.putc = NULL; /* 'putc' function */
219 kbd_dev.puts = NULL; /* 'puts' function */
220 kbd_dev.tstc = i8042_tstc; /* 'tstc' function */
221 kbd_dev.getc = i8042_getc; /* 'getc' function */
223 if (device_register(&kbd_dev) == 0) {
230 int drv_video_init(void)
232 if (video_bios_init()) {