AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
fb.c File Reference

x86: the early console on the boot loader's framebuffer. More...

#include <core/system.h>
#include <core/string.h>
#include <console/earlycon.h>
#include <cpu/io.h>
#include <mm/vm.h>
#include "font.h"

Go to the source code of this file.

Functions

void earlycon_fb_register (uintptr_t paddr, uint32_t scanline, uint32_t yres, uint32_t xres, uint32_t depth)
 Registers the boot loader's framebuffer, for the early console.
int earlycon_fb_available (void)
 Says whether the boot loader's framebuffer can be the early console.
static void earlycon_fb_scroll (int n)
 Scrolls the screen up by n lines of text, clearing the bottom.
static void fb_putc (int row, int col, char c)
 Draws a character at a row and a column of text.
static int earlycon_fb_putc (char c)
 Writes a character at the cursor, scrolling when it goes past the last line.
static int earlycon_fb_puts (char *s)
 Writes a string.
static void earlycon_fb_init ()
 Maps the framebuffer in the kernel's address space, and sizes the text screen from its resolution.

Variables

static uintptr_t fb_paddr
static uintptr_t fb_init = 0
static uint32_t fb_xres
static uint32_t fb_yres
static uint32_t fb_depth
static uint32_t fb_scanline
static uint32_t fb_row = 0
static uint32_t fb_col = 0
static uint32_t fb_rows = 25
static uint32_t fb_cols = 80
static uint32_t fb_size
static struct vm_entry fb_vmr
static char * vmem = (char *) ARCH_EARLYFB_BASE
static char * cursor = (char *) ARCH_EARLYFB_BASE
struct earlycon earlycon_fb

Detailed Description

x86: the early console on the boot loader's framebuffer.

The boot loader may set up a linear framebuffer (Multiboot's VBE or framebuffer information), which the boot code registers here. Text is drawn with the 8x16 font, in 32-bit pixels only, and the screen scrolls by copying it up a line.

Definition in file fb.c.

Function Documentation

◆ earlycon_fb_available()

int earlycon_fb_available ( void )

Says whether the boot loader's framebuffer can be the early console.

Returns
1 if one was registered and has 32 bits per pixel, 0 if not

Definition at line 55 of file fb.c.

References earlycon_fb_available(), fb_depth, fb_paddr, and fb_size.

Referenced by earlycon_fb_available(), and earlycon_reinit().

◆ earlycon_fb_init()

void earlycon_fb_init ( )
static

Maps the framebuffer in the kernel's address space, and sizes the text screen from its resolution.

Definition at line 145 of file fb.c.

References earlycon_fb_init(), fb_cols, fb_init, fb_paddr, fb_rows, fb_size, fb_vmr, fb_xres, fb_yres, vm_entry::flags, kvm_space, vm_entry::paddr, vm_entry::size, VM_KRW, and vm_map().

Referenced by earlycon_fb_init().

◆ earlycon_fb_putc()

int earlycon_fb_putc ( char c)
static

Writes a character at the cursor, scrolling when it goes past the last line.

Returns 1, 0 for a character it can't draw, or -1 before the framebuffer is mapped.

Definition at line 98 of file fb.c.

References earlycon_fb_putc(), earlycon_fb_scroll(), fb_col, fb_cols, fb_init, fb_putc(), fb_row, and fb_rows.

Referenced by earlycon_fb_putc(), and earlycon_fb_puts().

◆ earlycon_fb_puts()

int earlycon_fb_puts ( char * s)
static

Writes a string.

Returns 0.

Definition at line 135 of file fb.c.

References earlycon_fb_putc(), and earlycon_fb_puts().

Referenced by earlycon_fb_puts().

◆ earlycon_fb_register()

void earlycon_fb_register ( uintptr_t paddr,
uint32_t scanline,
uint32_t yres,
uint32_t xres,
uint32_t depth )

Registers the boot loader's framebuffer, for the early console.

The boot code calls it, before it is mapped.

Parameters
paddrits physical address
scanlinethe size of a line, in bytes
yresits height, in pixels
xresits width, in pixels
depththe bits per pixel

Definition at line 40 of file fb.c.

References earlycon_fb_register(), fb_depth, fb_paddr, fb_scanline, fb_size, fb_xres, fb_yres, and vm_entry::paddr.

Referenced by earlycon_fb_register(), and process_multiboot_info().

◆ earlycon_fb_scroll()

void earlycon_fb_scroll ( int n)
static

Scrolls the screen up by n lines of text, clearing the bottom.

Definition at line 62 of file fb.c.

References earlycon_fb_scroll(), fb_scanline, fb_size, memmove(), memset(), and vm_entry::size.

Referenced by earlycon_fb_putc(), and earlycon_fb_scroll().

◆ fb_putc()

void fb_putc ( int row,
int col,
char c )
static

Draws a character at a row and a column of text.

Definition at line 70 of file fb.c.

References vm_entry::base, cursor, fb_depth, fb_putc(), fb_scanline, and font_8x16.

Referenced by earlycon_fb_putc(), and fb_putc().

Variable Documentation

◆ cursor

char* cursor = (char *) ARCH_EARLYFB_BASE
static

Definition at line 28 of file fb.c.

Referenced by fb_putc(), and refresh().

◆ earlycon_fb

struct earlycon earlycon_fb
Initial value:
= {
}
static int earlycon_fb_putc(char c)
Writes a character at the cursor, scrolling when it goes past the last line.
Definition fb.c:98
static void earlycon_fb_init()
Maps the framebuffer in the kernel's address space, and sizes the text screen from its resolution.
Definition fb.c:145
static int earlycon_fb_puts(char *s)
Writes a string.
Definition fb.c:135

Definition at line 161 of file fb.c.

Referenced by earlycon_reinit().

◆ fb_col

uint32_t fb_col = 0
static

Definition at line 20 of file fb.c.

Referenced by earlycon_fb_putc().

◆ fb_cols

uint32_t fb_cols = 80
static

Definition at line 21 of file fb.c.

Referenced by earlycon_fb_init(), and earlycon_fb_putc().

◆ fb_depth

uint32_t fb_depth
static

Definition at line 19 of file fb.c.

Referenced by earlycon_fb_available(), earlycon_fb_register(), and fb_putc().

◆ fb_init

uintptr_t fb_init = 0
static

Definition at line 18 of file fb.c.

Referenced by earlycon_fb_init(), and earlycon_fb_putc().

◆ fb_paddr

uintptr_t fb_paddr
static

Definition at line 18 of file fb.c.

Referenced by earlycon_fb_available(), earlycon_fb_init(), and earlycon_fb_register().

◆ fb_row

uint32_t fb_row = 0
static

Definition at line 20 of file fb.c.

Referenced by earlycon_fb_putc().

◆ fb_rows

uint32_t fb_rows = 25
static

Definition at line 21 of file fb.c.

Referenced by earlycon_fb_init(), and earlycon_fb_putc().

◆ fb_scanline

uint32_t fb_scanline
static

Definition at line 20 of file fb.c.

Referenced by earlycon_fb_register(), earlycon_fb_scroll(), and fb_putc().

◆ fb_size

◆ fb_vmr

struct vm_entry fb_vmr
static
Initial value:
= {
}
#define ARCH_EARLYFB_BASE
Definition mm.h:45

Definition at line 23 of file fb.c.

Referenced by earlycon_fb_init().

◆ fb_xres

uint32_t fb_xres
static

Definition at line 19 of file fb.c.

Referenced by earlycon_fb_init(), and earlycon_fb_register().

◆ fb_yres

uint32_t fb_yres
static

Definition at line 19 of file fb.c.

Referenced by earlycon_fb_init(), and earlycon_fb_register().

◆ vmem

char* vmem = (char *) ARCH_EARLYFB_BASE
static

Definition at line 27 of file fb.c.