iPXE
Defines | Functions | Variables
video_subr.c File Reference
#include "stddef.h"
#include "string.h"
#include <ipxe/io.h>
#include <ipxe/console.h>
#include <ipxe/init.h>
#include "vga.h"
#include <config/console.h>

Go to the source code of this file.

Defines

#define CONSOLE_DIRECT_VGA   ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
#define VIDBUFFER   0xB8000

Functions

static void memsetw (void *s, int c, unsigned int n)
static void video_init (void)
static void video_scroll (void)
static void vga_putc (int byte)
struct init_fn video_init_fn __init_fn (INIT_EARLY)

Variables

struct console_driver vga_console __console_driver
static char * vidmem
static int video_line
static int video_col

Define Documentation

Definition at line 20 of file video_subr.c.

#define VIDBUFFER   0xB8000

Definition at line 28 of file video_subr.c.

Referenced by video_init().


Function Documentation

static void memsetw ( void *  s,
int  c,
unsigned int  n 
) [static]

Definition at line 30 of file video_subr.c.

References ss, and u16.

Referenced by video_init().

{
        unsigned int i;
        u16 *ss = (u16 *) s;

        for (i = 0; i < n; i++) {
                ss[i] = ( u16 ) c;
        }
}
static void video_init ( void  ) [static]

Definition at line 40 of file video_subr.c.

References memsetw(), phys_to_virt(), VGA_ATTR_CLR_WHT, VIDBUFFER, video_col, video_line, and vidmem.

{
        static int inited=0;

        vidmem = (char *)phys_to_virt(VIDBUFFER);

        if (!inited) {
                video_line = 0;
                video_col = 0;
        
                memsetw(vidmem, VGA_ATTR_CLR_WHT, 2*1024); //

                inited=1;
        }
}
static void video_scroll ( void  ) [static]

Definition at line 56 of file video_subr.c.

References COLS, LINES, memmove(), and vidmem.

Referenced by vga_putc().

{
        int i;

        memmove(vidmem, vidmem + COLS * 2, (LINES - 1) * COLS * 2);
        for (i = (LINES - 1) * COLS * 2; i < LINES * COLS * 2; i += 2)
                vidmem[i] = ' ';
}
static void vga_putc ( int  byte) [static]

Definition at line 65 of file video_subr.c.

References COLS, CRTC_CURSOR_HI, CRTC_CURSOR_LO, LINES, VGA_ATTR_CLR_WHT, video_col, video_line, video_scroll(), vidmem, and write_crtc.

{
        if (byte == '\n') {
                video_line++;
                video_col = 0;

        } else if (byte == '\r') {
                video_col = 0;

        } else if (byte == '\b') {
                video_col--;

        } else if (byte == '\t') {
                video_col += 4;

        } else if (byte == '\a') {
                //beep
                //beep(500);

        } else {
                vidmem[((video_col + (video_line *COLS)) * 2)] = byte;
                vidmem[((video_col + (video_line *COLS)) * 2) +1] = VGA_ATTR_CLR_WHT;
                video_col++;
        }
        if (video_col < 0) {
                video_col = 0;
        }
        if (video_col >= COLS) {
                video_line++;
                video_col = 0;
        }
        if (video_line >= LINES) {
                video_scroll();
                video_line--;
        }
        // move the cursor
        write_crtc((video_col + (video_line *COLS)) >> 8, CRTC_CURSOR_HI);
        write_crtc((video_col + (video_line *COLS)) & 0x0ff, CRTC_CURSOR_LO);
}
struct init_fn video_init_fn __init_fn ( INIT_EARLY  ) [read]

Variable Documentation

struct console_driver vga_console __console_driver
Initial value:
 {
        .putchar = vga_putc,
        .disabled = CONSOLE_DISABLED,
        .usage = CONSOLE_DIRECT_VGA,
}

Definition at line 23 of file video_subr.c.

char* vidmem [static]

Definition at line 25 of file video_subr.c.

Referenced by vga_putc(), video_init(), and video_scroll().

int video_line [static]

Definition at line 26 of file video_subr.c.

Referenced by vga_putc(), and video_init().

int video_col [static]

Definition at line 26 of file video_subr.c.

Referenced by vga_putc(), and video_init().