diff --git a/kernel/boot.s b/kernel/boot.s index f14477d..615e6b8 100644 --- a/kernel/boot.s +++ b/kernel/boot.s @@ -92,8 +92,6 @@ page_table_l3: .skip 4096 page_table_l2: .skip 4096 -page_table_l3_framebuffer: -.skip 4096 page_table_l2_framebuffer: .skip 4096 stack_bottom: @@ -106,11 +104,6 @@ gdt64: .quad GDT_ZERO_ENTRY .set gdt64_code_segment, . - gdt64 .quad GDT_FLAGS -/* -gdt64_data_entry: -.set gdt64_data_segment, gdt64_data_entry - gdt64 -.quad (1<<44) | (1<<46) | (1<<41) -*/ gdt64_pointer: .word . - gdt64 - 1 .quad gdt64 diff --git a/kernel/boot64.s b/kernel/boot64.s index 7ffca95..23b00af 100644 --- a/kernel/boot64.s +++ b/kernel/boot64.s @@ -12,7 +12,6 @@ long_mode_start: movw %ax, %gs /* We should keep the pointer to mb, debug needed */ - push %rbx /* Multiboot struct pointer */ mov %rbx, %rdi call kernel_main hlt diff --git a/kernel/console.c b/kernel/console.c index 48e4862..86236e8 100644 --- a/kernel/console.c +++ b/kernel/console.c @@ -17,6 +17,12 @@ multiboot_info_t *mbi; psf_font_t *font; +/* + * We write a character on the screen using the psf font. + * This function is not meant for external usage as it does not + * handle line breaking, scrolling, and special characters such + * as linefeed. + */ void putchar (uint16_t c, int32_t cx, int32_t cy, uint32_t fg, uint32_t bg) { uint32_t bytesperline = (font->width + 7) / 8; @@ -53,6 +59,9 @@ PIXEL get_pixel(uint64_t x, uint64_t y) return *((PIXEL *)(fb+pos)); } +/* + * Move all characters one row above. + */ void console_scroll() { const uint32_t width = mbi->framebuffer_width; @@ -76,6 +85,11 @@ void console_scroll() } } +/* + * Write a single character the console. + * The console is a share resource, a syncing mechanism must be used. + * The console scrolling and line wrapping is handled. + */ void console_puts(uint16_t ch) { if (ch == '\n') { @@ -96,6 +110,10 @@ void console_puts(uint16_t ch) console_x++; } +/* + * Write a character array to the console. + * The console is a share resource, a syncing mechanism must be used. + */ void console_write(char *str) { for (int idx = 0; str[idx] != '\0'; idx++ ) { @@ -103,6 +121,9 @@ void console_write(char *str) } } +/* + * Initialize the console. + */ void console_init(multiboot_info_t *multiboot_struct) { mbi = multiboot_struct; diff --git a/kernel/kprintf.c b/kernel/kprintf.c index 704324e..78b84c9 100644 --- a/kernel/kprintf.c +++ b/kernel/kprintf.c @@ -3,6 +3,9 @@ #include #include +/* + * Converts a decimal number to a different base. + */ void convert(uint64_t num, int base, char *buf, int bufsize) { int idx = 0; @@ -33,6 +36,9 @@ void convert(uint64_t num, int base, char *buf, int bufsize) } } +/* + * Print formatted string. + */ void kprintf(char *format, ...) { va_list arg;