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

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.

Function Documentation

◆ memsetw()

static 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 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
uint32_t c
Definition: md4.c:30
uint32_t ss
Definition: librm.h:250
unsigned int n
Definition: entropy.h:159

References c, n, ss, and u16.

Referenced by video_init().

◆ video_init()

static 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 }
static int video_col
Definition: video_subr.c:26
static int video_line
Definition: video_subr.c:26
static void memsetw(void *s, int c, unsigned int n)
Definition: video_subr.c:30
static __always_inline void * phys_to_virt(unsigned long phys_addr)
Convert physical address to a virtual address.
Definition: uaccess.h:299
#define VGA_ATTR_CLR_WHT
Definition: vga.h:157
static char * vidmem
Definition: video_subr.c:25
#define VIDBUFFER
Definition: video_subr.c:28

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

◆ video_scroll()

static 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 }
#define LINES(...)
Define inline lines.
Definition: linebuf_test.c:44
static char * vidmem
Definition: video_subr.c:25
#define COLS
Definition: curses.h:111
void * memmove(void *dest, const void *src, size_t len) __nonnull

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

Referenced by vga_putc().

◆ vga_putc()

static 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;
86  vidmem[((video_col + (video_line *COLS)) * 2) +1] = VGA_ATTR_CLR_WHT;
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) {
97  video_scroll();
98  video_line--;
99  }
100  // move the cursor
103 }
static int video_col
Definition: video_subr.c:26
#define write_crtc(data, addr)
Definition: vga.h:30
static int video_line
Definition: video_subr.c:26
#define LINES(...)
Define inline lines.
Definition: linebuf_test.c:44
#define VGA_ATTR_CLR_WHT
Definition: vga.h:157
#define CRTC_CURSOR_HI
Definition: vga.h:116
static char * vidmem
Definition: video_subr.c:25
#define COLS
Definition: curses.h:111
static void video_scroll(void)
Definition: video_subr.c:56
#define CRTC_CURSOR_LO
Definition: vga.h:117

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  )

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:111
static void vga_putc(int byte)
Definition: video_subr.c:65
#define CONSOLE_DIRECT_VGA
Definition: video_subr.c:20

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().