iPXE
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.

Macros

#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

Macro Definition Documentation

◆ CONSOLE_DIRECT_VGA

#define CONSOLE_DIRECT_VGA   ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )

Definition at line 20 of file video_subr.c.

◆ VIDBUFFER

#define VIDBUFFER   0xB8000

Definition at line 28 of file video_subr.c.

Referenced by video_init().

Function Documentation

◆ memsetw()

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

Definition at line 30 of file video_subr.c.

31{
32 unsigned int i;
33 u16 *ss = (u16 *) s;
34
35 for (i = 0; i < n; i++) {
36 ss[i] = ( u16 ) c;
37 }
38}
uint32_t ss
Definition librm.h:1
#define u16
Definition vga.h:20

References ss, and u16.

Referenced by video_init().

◆ video_init()

void video_init ( void )
static

Definition at line 40 of file video_subr.c.

41{
42 static int inited=0;
43
44 vidmem = (char *)phys_to_virt(VIDBUFFER);
45
46 if (!inited) {
47 video_line = 0;
48 video_col = 0;
49
50 memsetw(vidmem, VGA_ATTR_CLR_WHT, 2*1024); //
51
52 inited=1;
53 }
54}
#define VGA_ATTR_CLR_WHT
Definition vga.h:157
static int video_line
Definition video_subr.c:26
static int video_col
Definition video_subr.c:26
static char * vidmem
Definition video_subr.c:25
#define VIDBUFFER
Definition video_subr.c:28
static void memsetw(void *s, int c, unsigned int n)
Definition video_subr.c:30

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

Referenced by __init_fn().

◆ video_scroll()

void video_scroll ( void )
static

Definition at line 56 of file video_subr.c.

57{
58 int i;
59
60 memmove(vidmem, vidmem + COLS * 2, (LINES - 1) * COLS * 2);
61 for (i = (LINES - 1) * COLS * 2; i < LINES * COLS * 2; i += 2)
62 vidmem[i] = ' ';
63}
void * memmove(void *dest, const void *src, size_t len) __nonnull
#define LINES(...)
Define inline lines.
#define COLS
Definition vga.h:27

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

Referenced by vga_putc().

◆ vga_putc()

void vga_putc ( int byte)
static

Definition at line 65 of file video_subr.c.

66{
67 if (byte == '\n') {
68 video_line++;
69 video_col = 0;
70
71 } else if (byte == '\r') {
72 video_col = 0;
73
74 } else if (byte == '\b') {
75 video_col--;
76
77 } else if (byte == '\t') {
78 video_col += 4;
79
80 } else if (byte == '\a') {
81 //beep
82 //beep(500);
83
84 } else {
85 vidmem[((video_col + (video_line *COLS)) * 2)] = byte;
87 video_col++;
88 }
89 if (video_col < 0) {
90 video_col = 0;
91 }
92 if (video_col >= COLS) {
93 video_line++;
94 video_col = 0;
95 }
96 if (video_line >= LINES) {
98 video_line--;
99 }
100 // move the cursor
103}
#define CRTC_CURSOR_HI
Definition vga.h:116
#define CRTC_CURSOR_LO
Definition vga.h:117
#define write_crtc(data, addr)
Definition vga.h:30
static void video_scroll(void)
Definition video_subr.c:56

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

◆ __init_fn()

struct init_fn video_init_fn __init_fn ( INIT_EARLY )

References __init_fn, INIT_EARLY, and video_init().

Variable Documentation

◆ __console_driver

struct console_driver vga_console __console_driver
Initial value:
= {
.putchar = vga_putc,
.disabled = CONSOLE_DISABLED,
}
#define CONSOLE_DISABLED
Console is disabled for all uses.
Definition console.h:112
#define CONSOLE_DIRECT_VGA
Definition video_subr.c:20
static void vga_putc(int byte)
Definition video_subr.c:65

Definition at line 23 of file video_subr.c.

◆ vidmem

char* vidmem
static

Definition at line 25 of file video_subr.c.

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

◆ video_line

int video_line
static

Definition at line 26 of file video_subr.c.

Referenced by vga_putc(), and video_init().

◆ video_col

int video_col
static

Definition at line 26 of file video_subr.c.

Referenced by vga_putc(), and video_init().