diff --git a/kernel.c b/kernel.c index 72d588c..2f0881a 100644 --- a/kernel.c +++ b/kernel.c @@ -6,26 +6,38 @@ // 0xB0000 for monochrome text mode (32 KB) // 0xB8000 for color text mode and CGA-compatible graphics modes (32 KB) +#include "kernel.h" + #include "stdio.h" -typedef struct user { - int id; - const char *name; +typedef struct { + char user_name[32]; + char user_hostname[32]; + + unsigned int user_id; } user; void kmain(void) { + user current_user = { + .user_name = "admin", + .user_hostname = "soraos", + .user_id = 0 + }; + __clear_screen(); - user current_user; - current_user.id = 1; - current_user.name = "admin"; - printf("SoraOS Kernel Initialized!\n"); + printf("\tWelcome to SoraOS!\n"); + printf("\tKernel Version: %s\n", __KERNEL_VERSION); + printf("\tCompiled on: %s at %s\n\n", __DATE__, __TIME__); - printf("\tUser name:\t%s\n", current_user.name); - printf("\tUser id:\t%d\n", current_user.id); - vga_set_cursor(0, 0); + // TODO: CLI IDEA + int _count = printf("%s@%s:>", current_user.user_name, current_user.user_hostname); + scursor(_count, text_pos.line); + + // TODO: Enable user input handling + // Infinite loop while (1) { diff --git a/kernel.h b/kernel.h new file mode 100644 index 0000000..8bdf25f --- /dev/null +++ b/kernel.h @@ -0,0 +1,7 @@ +#ifndef KERNEL_H +#define KERNEL_H + +#define __KERNEL_VERSION "0.1.0-alpha" +#define __KERNEL_NAME "SoraOS" + +#endif diff --git a/stdio.h b/stdio.h index 2f5c371..b7dec05 100644 --- a/stdio.h +++ b/stdio.h @@ -309,7 +309,7 @@ static inline void outb(unsigned short port, unsigned char val) { __asm__ volatile ("outb %0, %1" : : "a"(val), "Nd"(port)); } -static inline void __VGA_set_cursor(unsigned int column, unsigned int line) { +static inline void __VGA_set_cursor_internal(unsigned int column, unsigned int line) { if (column >= VGA_WIDTH) column = VGA_WIDTH - 1; if (line >= VGA_HEIGHT) line = VGA_HEIGHT - 1; @@ -330,13 +330,21 @@ static inline void __VGA_set_cursor(unsigned int column, unsigned int line) { text_pos.line = line; } -static inline void __VGA_set_cursor_VGA_pos(_VGA_screen_space pos) { - __VGA_set_cursor(pos.column, pos.line); +static void __VGA_set_cursor_VGA_pos(_VGA_screen_space pos) { + __VGA_set_cursor_internal(pos.column, pos.line); } -static inline _VGA_screen_space get_cursor_pos() { +static _VGA_screen_space get_cursor_pos() { _VGA_screen_space __temp = {cursor_pos.column, cursor_pos.line}; return __temp; } +void scursor(unsigned int column, unsigned int line) { + __VGA_set_cursor_internal(column, line); +} + + + + + #endif