37 lines
870 B
C
37 lines
870 B
C
// #include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <terminal.h>
|
|
#include <ports.h>
|
|
#include <memory.h>
|
|
#include <multiboot.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);
|
|
}
|