35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
// Entry point of the TSOS kernel
|
|
#include "kernel/ktypes.h"
|
|
#include "kernel/drivers/vga/screen.h"
|
|
|
|
|
|
void kmain(void) {
|
|
byte* vga = (byte*)VMEM_ADDRESS;
|
|
vga_writeb(0x3d4, 14); // We request the high byte of cursor position on port 0x3D4
|
|
int cursor = vga_readb(0x3d5); // And now we read it
|
|
// Since this is the high byte, we shift the
|
|
// cursor by 8 bits to make room for the low
|
|
// byte
|
|
cursor <<= 8;
|
|
// Now we request the low byte
|
|
vga_writeb(0x3d4, 15);
|
|
// And we add it to the cursor
|
|
cursor += vga_readb(0x3d5);
|
|
// VGA 'cells' are 2 bytes long, but
|
|
// the cursor counts cells as a unit,
|
|
// so we multiply it by 2
|
|
cursor *= 2;
|
|
// We add 160 because when we print a
|
|
// message via VGA in the bootloader,
|
|
// and that leaves the cursor in the
|
|
// wrong position
|
|
cursor += 160;
|
|
// Now we write some message onto the screen
|
|
byte *s = "TSOS Kernel started";
|
|
for (int i = 0; s[i] != '\0'; i++) {
|
|
vga[cursor] = s[i]; // We set the character code we want
|
|
cursor++;
|
|
vga[cursor] = 0x07; // Light grey on black
|
|
cursor++;
|
|
}
|
|
} |