30 lines
767 B
C
30 lines
767 B
C
// Implementation of a simple video driver using VGA text mode
|
|
#include "video.h"
|
|
|
|
|
|
uchar_t vga_readb(u16_t port) {
|
|
// Reads a byte from the specified I/O port
|
|
uchar_t result;
|
|
__asm__("in %%dx, %%al" : "=a" (result) : "d" (port));
|
|
return result;
|
|
}
|
|
|
|
|
|
void vga_writeb(u16_t port, uchar_t data) {
|
|
// Writes a byte from the specified I/O port
|
|
__asm__("out %%al, %%dx" : : "a" (data), "d" (port));
|
|
}
|
|
|
|
|
|
u16_t vga_writew(u16_t port) {
|
|
// Reads a word (16 bits) from the specified I/O port
|
|
u16_t result;
|
|
__asm__("in %%dx, %%ax" : "=a" (result) : "d" (port));
|
|
return result;
|
|
}
|
|
|
|
|
|
void vga_readw(u16_t port, u16_t data) {
|
|
// Writes a word (16 bits) to the specified I/O port
|
|
__asm__("out %%ax, %%dx" : : "a" (data), "d" (port));
|
|
} |