39 lines
868 B
C
39 lines
868 B
C
#include <terminal.h>
|
|
#include <memory.h>
|
|
#include <ports.h>
|
|
#include <multiboot.h>
|
|
#include <stddef.h>
|
|
#include <debug.h>
|
|
|
|
#define VGA_ADDRESS_PORT 0x3D4
|
|
#define VGA_DATA_PORT 0x3D5
|
|
#define VGA_REGISTER_CURSOR_POS_LOW 0xF
|
|
#define VGA_REGISTER_CURSOR_POS_HIGH 0xE
|
|
|
|
static void *vidmem;
|
|
|
|
static int setup = 0;
|
|
|
|
void vga_init(struct fbinfo *fbinfo)
|
|
{
|
|
(void) fbinfo;
|
|
vidmem = VGA_MEMORY;
|
|
memset(vidmem, 0, VGA_SIZE*sizeof(struct vga_cell));
|
|
setup = 1;
|
|
}
|
|
|
|
void vga_movecursor(unsigned int cursor)
|
|
{
|
|
if(!setup) return;
|
|
outb(VGA_ADDRESS_PORT, VGA_REGISTER_CURSOR_POS_LOW);
|
|
outb(VGA_DATA_PORT, (uint8_t)(cursor & 0xFF));
|
|
outb(VGA_ADDRESS_PORT, VGA_REGISTER_CURSOR_POS_HIGH);
|
|
outb(VGA_DATA_PORT, (uint8_t)((cursor >> 8) & 0xFF));
|
|
}
|
|
|
|
void vga_flush(struct vga_cell *buffer)
|
|
{
|
|
if(!setup) return;
|
|
memcpy(vidmem, buffer, VGA_SIZE*2);
|
|
}
|