AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
vga.c
Go to the documentation of this file.
1
9
10
#include <
core/system.h
>
11
#include <
cpu/io.h
>
12
#include <
mm/mm.h
>
13
#include <
dev/vt.h
>
14
15
#define VGA_ROWS 25
16
#define VGA_COLS 80
17
18
static
uint16_t
*
vga
= (
uint16_t
*)
VMA
(0xB8000);
19
20
static
struct
ioaddr
crtc
= {
21
.addr = 0x3D4,
22
.type =
IOADDR_PORT
,
23
};
24
26
static
void
vga_draw
(
int
row,
int
col,
struct
vt_cell
cell)
27
{
28
vga
[row *
VGA_COLS
+ col] =
vt_vga_attr
(cell) << 8 | cell.
ch
;
29
}
30
32
static
void
vga_cursor
(
int
row,
int
col,
int
visible)
33
{
34
/* a hidden cursor is one past the end of the screen */
35
unsigned
pos = visible ? row *
VGA_COLS
+ col :
VGA_ROWS
*
VGA_COLS
;
36
37
io_out8
(&
crtc
, 0x00, 0x0F);
38
io_out8
(&
crtc
, 0x01, pos & 0xFF);
39
io_out8
(&
crtc
, 0x00, 0x0E);
40
io_out8
(&
crtc
, 0x01, (pos >> 8) & 0xFF);
41
}
42
48
int
vt_vga_probe
(
void
)
49
{
50
return
0;
51
}
52
53
struct
vt_display
vt_vga_display
= {
54
.name =
"VGA text mode"
,
55
.rows =
VGA_ROWS
,
56
.cols =
VGA_COLS
,
57
.draw =
vga_draw
,
58
.cursor =
vga_cursor
,
59
};
io_out8
static void io_out8(struct ioaddr *io, uintptr_t off, uint8_t val)
Writes an 8-, 16- or 32-bit register.
Definition
io.h:44
VMA
#define VMA(obj)
Definition
mm.h:36
VGA_ROWS
#define VGA_ROWS
Definition
vga.c:22
vga
static char * vga
Definition
vga.c:14
VGA_COLS
#define VGA_COLS
Definition
vga.c:21
IOADDR_PORT
#define IOADDR_PORT
Definition
io.h:89
vga_draw
static void vga_draw(int row, int col, struct vt_cell cell)
Draws one cell of the screen.
Definition
vga.c:26
crtc
static struct ioaddr crtc
Definition
vga.c:20
vga_cursor
static void vga_cursor(int row, int col, int visible)
Moves the cursor, or hides it.
Definition
vga.c:32
vt_vga_probe
int vt_vga_probe(void)
Says whether VGA text mode can be used.
Definition
vga.c:48
vt_vga_display
struct vt_display vt_vga_display
Definition
vga.c:53
system.h
io.h
mm.h
uint16_t
unsigned short int uint16_t
Definition
stddef.h:21
ioaddr
Where a device's registers are.
Definition
io.h:95
vt_cell
A character cell.
Definition
vt.h:35
vt_cell::ch
uint8_t ch
Definition
vt.h:36
vt_display
A display that virtual terminals are shown on.
Definition
vt.h:43
vt_vga_attr
uint8_t vt_vga_attr(struct vt_cell cell)
Returns the VGA text mode attribute of a cell (its colours, in VGA's order), for the VGA display and ...
Definition
vt.c:122
vt.h
kernel
dev
tty
vt
vga.c
Generated by
1.18.0