]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/x86/lib/video.c
3 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <stdio_dev.h>
12 #include <asm/ptrace.h>
16 /* basic textmode I/O from linux kernel */
17 static char *vidmem
= (char *)0xb8000;
19 static int lines
, cols
;
20 static int orig_x
, orig_y
;
22 static void beep(int dur
)
27 for (i
= 0; i
< 10*dur
; i
++)
33 static void scroll(void)
37 memcpy(vidmem
, vidmem
+ cols
* 2, (lines
- 1) * cols
* 2);
38 for (i
= (lines
- 1) * cols
* 2; i
< lines
* cols
* 2; i
+= 2)
42 static void __video_putc(const char c
, int *x
, int *y
)
46 if (++(*y
) >= lines
) {
50 } else if (c
== '\b') {
53 vidmem
[((*x
) + cols
* (*y
)) * 2] = ' ';
55 } else if (c
== '\r') {
58 } else if (c
== '\a') {
61 } else if (c
== '\t') {
62 __video_putc(' ', x
, y
);
63 __video_putc(' ', x
, y
);
64 __video_putc(' ', x
, y
);
65 __video_putc(' ', x
, y
);
66 __video_putc(' ', x
, y
);
67 __video_putc(' ', x
, y
);
68 __video_putc(' ', x
, y
);
69 __video_putc(' ', x
, y
);
70 } else if (c
== '\v') {
73 __video_putc(' ', x
, y
);
75 __video_putc(' ', x
, y
);
77 __video_putc(' ', x
, y
);
79 __video_putc(' ', x
, y
);
81 __video_putc(' ', x
, y
);
83 __video_putc(' ', x
, y
);
85 __video_putc(' ', x
, y
);
87 __video_putc(' ', x
, y
);
89 } else if (c
== '\f') {
91 for (i
= 0; i
< lines
* cols
* 2; i
+= 2)
96 vidmem
[((*x
) + cols
* (*y
)) * 2] = c
;
99 if (++(*y
) >= lines
) {
107 static void video_putc(const char c
)
114 __video_putc(c
, &x
, &y
);
119 pos
= (x
+ cols
* y
) * 2; /* Update cursor position */
121 outb_p(0xff & (pos
>> 9), vidport
+1);
123 outb_p(0xff & (pos
>> 1), vidport
+1);
126 static void video_puts(const char *s
)
134 while ((c
= *s
++) != '\0')
135 __video_putc(c
, &x
, &y
);
140 pos
= (x
+ cols
* y
) * 2; /* Update cursor position */
142 outb_p(0xff & (pos
>> 9), vidport
+1);
144 outb_p(0xff & (pos
>> 1), vidport
+1);
151 static struct stdio_dev vga_dev
;
152 static struct stdio_dev kbd_dev
;
154 vidmem
= (char *) 0xb8000;
161 pos
= inb_p(vidport
+1);
164 pos
|= inb_p(vidport
+1);
170 printf("pos %x %d %d\n", pos
, orig_x
, orig_y
);
175 memset(&vga_dev
, 0, sizeof(vga_dev
));
176 strcpy(vga_dev
.name
, "vga");
178 vga_dev
.flags
= DEV_FLAGS_OUTPUT
| DEV_FLAGS_SYSTEM
;
179 vga_dev
.putc
= video_putc
; /* 'putc' function */
180 vga_dev
.puts
= video_puts
; /* 'puts' function */
181 vga_dev
.tstc
= NULL
; /* 'tstc' function */
182 vga_dev
.getc
= NULL
; /* 'getc' function */
184 if (stdio_register(&vga_dev
) == 0)
187 if (i8042_kbd_init())
190 memset(&kbd_dev
, 0, sizeof(kbd_dev
));
191 strcpy(kbd_dev
.name
, "kbd");
193 kbd_dev
.flags
= DEV_FLAGS_INPUT
| DEV_FLAGS_SYSTEM
;
194 kbd_dev
.putc
= NULL
; /* 'putc' function */
195 kbd_dev
.puts
= NULL
; /* 'puts' function */
196 kbd_dev
.tstc
= i8042_tstc
; /* 'tstc' function */
197 kbd_dev
.getc
= i8042_getc
; /* 'getc' function */
199 if (stdio_register(&kbd_dev
) == 0)
206 int drv_video_init(void)