]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/x86/lib/video.c
b29075c490a48ce14e3c3c485fdb21bbcc198172
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,
26 #include <stdio_dev.h>
28 #include <asm/ptrace.h>
29 #include <asm/realmode.h>
33 /* basic textmode I/O from linux kernel */
34 static char *vidmem
= (char *)0xb8000;
36 static int lines
, cols
;
37 static int orig_x
, orig_y
;
39 static void beep(int dur
)
44 for (i
= 0; i
< 10*dur
; i
++)
50 static void scroll(void)
54 memcpy(vidmem
, vidmem
+ cols
* 2, (lines
- 1) * cols
* 2);
55 for (i
= (lines
- 1) * cols
* 2; i
< lines
* cols
* 2; i
+= 2)
59 static void __video_putc(const char c
, int *x
, int *y
)
63 if (++(*y
) >= lines
) {
67 } else if (c
== '\b') {
70 vidmem
[((*x
) + cols
* (*y
)) * 2] = ' ';
72 } else if (c
== '\r') {
75 } else if (c
== '\a') {
78 } else if (c
== '\t') {
79 __video_putc(' ', x
, y
);
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 } else if (c
== '\v') {
90 __video_putc(' ', x
, y
);
92 __video_putc(' ', x
, y
);
94 __video_putc(' ', x
, y
);
96 __video_putc(' ', x
, y
);
98 __video_putc(' ', x
, y
);
100 __video_putc(' ', x
, y
);
102 __video_putc(' ', x
, y
);
104 __video_putc(' ', x
, y
);
106 } else if (c
== '\f') {
108 for (i
= 0; i
< lines
* cols
* 2; i
+= 2)
113 vidmem
[((*x
) + cols
* (*y
)) * 2] = c
;
114 if (++(*x
) >= cols
) {
116 if (++(*y
) >= lines
) {
124 static void video_putc(const char c
)
131 __video_putc(c
, &x
, &y
);
136 pos
= (x
+ cols
* y
) * 2; /* Update cursor position */
138 outb_p(0xff & (pos
>> 9), vidport
+1);
140 outb_p(0xff & (pos
>> 1), vidport
+1);
143 static void video_puts(const char *s
)
151 while ((c
= *s
++) != '\0')
152 __video_putc(c
, &x
, &y
);
157 pos
= (x
+ cols
* y
) * 2; /* Update cursor position */
159 outb_p(0xff & (pos
>> 9), vidport
+1);
161 outb_p(0xff & (pos
>> 1), vidport
+1);
168 static struct stdio_dev vga_dev
;
169 static struct stdio_dev kbd_dev
;
171 vidmem
= (char *) 0xb8000;
178 pos
= inb_p(vidport
+1);
181 pos
|= inb_p(vidport
+1);
187 printf("pos %x %d %d\n", pos
, orig_x
, orig_y
);
192 memset(&vga_dev
, 0, sizeof(vga_dev
));
193 strcpy(vga_dev
.name
, "vga");
195 vga_dev
.flags
= DEV_FLAGS_OUTPUT
| DEV_FLAGS_SYSTEM
;
196 vga_dev
.putc
= video_putc
; /* 'putc' function */
197 vga_dev
.puts
= video_puts
; /* 'puts' function */
198 vga_dev
.tstc
= NULL
; /* 'tstc' function */
199 vga_dev
.getc
= NULL
; /* 'getc' function */
201 if (stdio_register(&vga_dev
) == 0)
204 if (i8042_kbd_init())
207 memset(&kbd_dev
, 0, sizeof(kbd_dev
));
208 strcpy(kbd_dev
.name
, "kbd");
210 kbd_dev
.flags
= DEV_FLAGS_INPUT
| DEV_FLAGS_SYSTEM
;
211 kbd_dev
.putc
= NULL
; /* 'putc' function */
212 kbd_dev
.puts
= NULL
; /* 'puts' function */
213 kbd_dev
.tstc
= i8042_tstc
; /* 'tstc' function */
214 kbd_dev
.getc
= i8042_getc
; /* 'getc' function */
216 if (stdio_register(&kbd_dev
) == 0)
223 int drv_video_init(void)
225 if (video_bios_init())