Cleanup and documentation
This commit is contained in:
parent
3392bda28d
commit
5224d33fb4
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
|
Loading…
Reference in New Issue