3 * modified from linuxbios code
4 * by Cai Qiang <rimy2000@hotmail.com>
12 #include <gpxe/init.h>
15 struct console_driver vga_console
;
17 static char *vidmem
; /* The video buffer */
18 static int video_line
, video_col
;
20 #define VIDBUFFER 0xB8000
22 static void memsetw(void *s
, int c
, unsigned int n
)
27 for (i
= 0; i
< n
; i
++) {
32 static void video_init(void)
36 vidmem
= (char *)phys_to_virt(VIDBUFFER
);
42 memsetw(vidmem
, VGA_ATTR_CLR_WHT
, 2*1024); //
48 static void video_scroll(void)
52 memcpy(vidmem
, vidmem
+ COLS
* 2, (LINES
- 1) * COLS
* 2);
53 for (i
= (LINES
- 1) * COLS
* 2; i
< LINES
* COLS
* 2; i
+= 2)
57 static void vga_putc(int byte
)
63 } else if (byte
== '\r') {
66 } else if (byte
== '\b') {
69 } else if (byte
== '\t') {
72 } else if (byte
== '\a') {
77 vidmem
[((video_col
+ (video_line
*COLS
)) * 2)] = byte
;
78 vidmem
[((video_col
+ (video_line
*COLS
)) * 2) +1] = VGA_ATTR_CLR_WHT
;
84 if (video_col
>= COLS
) {
88 if (video_line
>= LINES
) {
93 write_crtc((video_col
+ (video_line
*COLS
)) >> 8, CRTC_CURSOR_HI
);
94 write_crtc((video_col
+ (video_line
*COLS
)) & 0x0ff, CRTC_CURSOR_LO
);
97 struct console_driver vga_console __console_driver
= {
102 struct init_fn video_init_fn
__init_fn ( INIT_EARLY
) = {
103 .initialise
= video_init
,