Basic serial driver
This commit is contained in:
parent
e9fd2e98bf
commit
c33a57fa33
4 changed files with 91 additions and 12 deletions
39
kernel.c
39
kernel.c
|
|
@ -1,9 +1,15 @@
|
|||
#include "multiboot.h"
|
||||
#include "vga.h"
|
||||
#include "serial.h"
|
||||
|
||||
static inline void outb(unsigned short port, unsigned char val) {
|
||||
asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
|
||||
}
|
||||
static inline unsigned char inb(unsigned short port) {
|
||||
unsigned char ret;
|
||||
asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
char* itoa(int value, int base) {
|
||||
char* result;
|
||||
|
|
@ -41,6 +47,14 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
|
|||
vga_init(VGA_COLOR_BLACK, VGA_COLOR_GRAY);
|
||||
|
||||
vga_write_line("=== KoalemOS ===");
|
||||
|
||||
if (serial_init() > 0) {
|
||||
vga_write_line_color("Serial initialization failed", VGA_COLOR_BLACK,
|
||||
VGA_COLOR_ORANGE);
|
||||
} else {
|
||||
vga_write_line("\nInitialized serial.");
|
||||
serial_write_string("\n=== KoalemOS ===\n");
|
||||
}
|
||||
vga_write("Checking multiboot loader: ");
|
||||
|
||||
// Check multiboot header
|
||||
|
|
@ -56,23 +70,30 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
|
|||
vga_write("\nMultiboot flags: ");
|
||||
vga_write(itoa(mbootinfo->flags, 2));
|
||||
|
||||
// Check videomode
|
||||
vga_write("\nVideomode: ");
|
||||
serial_write_string("\nMultiboot flags: ");
|
||||
serial_write_string(itoa(mbootinfo->flags, 2));
|
||||
|
||||
// Check videomode
|
||||
if (mbootinfo->flags & MULTIBOOT_INFO_VBE_INFO) {
|
||||
vga_write("VBE 0x");
|
||||
vga_write("\nVBE Mode: 0x");
|
||||
vga_write(itoa(mbootinfo->vbe_mode, 16));
|
||||
} else if (mbootinfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) {
|
||||
vga_write("Framebuffer");
|
||||
vga_write("\nVideo address: 0x");
|
||||
serial_write_string("\nVBE Mode: 0x");
|
||||
serial_write_string(itoa(mbootinfo->vbe_mode, 16));
|
||||
}
|
||||
if (mbootinfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) {
|
||||
vga_write("\nFramebuffer: ");
|
||||
vga_write("address: 0x");
|
||||
vga_write(itoa(mbootinfo->framebuffer_addr, 16));
|
||||
unsigned long long *vmem = &mbootinfo->framebuffer_addr;
|
||||
serial_write_string("\nFramebuffer: ");
|
||||
serial_write_string("address: 0x");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_addr, 16));
|
||||
unsigned long *vmem = &mbootinfo->framebuffer_addr;
|
||||
*vmem = 0xff00ff;
|
||||
|
||||
} else {
|
||||
vga_write_color("Not available", VGA_COLOR_BLACK, VGA_COLOR_RED);
|
||||
vga_write_color("Info not available", VGA_COLOR_BLACK, VGA_COLOR_RED);
|
||||
serial_write_string("Info not available");
|
||||
return;
|
||||
}
|
||||
|
||||
vga_write_line("\nExecution finished, halting...");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue