Added support for setting up a serial port. This first serial driver appears to only work correctly in QEMU.

This commit is contained in:
2020-05-24 03:24:25 -05:00
parent cf88cb98fb
commit b409b3e9d2
11 changed files with 113 additions and 27 deletions
+11 -19
View File
@@ -1,10 +1,16 @@
#include "../includes/io.h"
#include "../includes/serial.h"
#include "../includes/screen.h"
void kmain()
{
set_serial_baud_rate(COM1_PORT, 0x03);
configure_serial_line(COM1_PORT);
write_to_com(COM1_PORT, "Info From Kernel: Set up COM1 for messaging.\n");
clear_screen();
write_to_com(COM1_PORT, "Info From Kernel: Clearing screen.\n");
print_banner();
write_to_com(COM1_PORT, "Info From Kernel: Displaying OS banner.\n");
//draw_rect(20, 5, 50, 7, 0x4, 0xF);
draw_rect(0, 5, 5, 13, 0xF, 0x4);
draw_rect(5, 8, 10, 10, 0x4, 0xF);
@@ -14,11 +20,13 @@ void kmain()
set_cursor(0, 14);
move_cursor(0, 14);
move_cursor(0, 15);
draw_s("Test print", 0x8, 0xF);
draw_string("Test print", 0x8, 0xF);
move_cursor(0, 16);
draw_s("And now the cursor has been moved to y = 16.", 0x1, 0xF);
draw_string("And now the cursor has been moved to y = 16.", 0x1, 0xF);
move_cursor(5, 20);
draw_s("Cursor moved over 5 cells and down 4 cells.", 0xF, 0x0);
draw_string("Cursor moved over 5 cells and down 4 cells.", 0xF, 0x0);
draw_string("And the cursor moves to the end of the string", 0x1, 0xF);
draw_string("Now this string should have a newline now:\nAnd now a new line is here.", 0xF, 0x0);
//draw_rect(20, 5, 50, 7, 0x4, 0xF);
//draw_rect(20, 5, 50, 7, 0x4, 0xF);
//draw_rect(20, 5, 50, 7, 0x4, 0xF);
@@ -28,19 +36,3 @@ void kmain()
//draw_s("And 2nd Row. Now the 3rd row.", 2, 9);
asm("hlt");
}
void write_screen(unsigned int i, char c, unsigned char fg, unsigned char bg)
{
char *fb = (char *) 0x000B8000;
fb[i] = c;
fb[i + 1] = ((fg & 0x0F) << 4) | (bg & 0x0F);
}
void move(unsigned short pos)
{
outb(0x3D4, 14);
outb(0x3D5, ((pos >> 8 ) & 0x00FF));
outb(0x3D4, 15);
outb(0x3D5, pos & 0x00FF);
}