Init struct + freeing a bit of kmain()

This commit is contained in:
2026-03-08 13:21:19 +01:00
parent 5e9c582833
commit 42c7a55d3f
9 changed files with 71 additions and 33 deletions

View File

@@ -17,6 +17,8 @@ uint8_t key_status = 0b00000000;
unsigned char* keymap;
unsigned char* keymap_shifted;
extern struct init_status init;
unsigned char kbdus[128] =
{
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */
@@ -205,6 +207,10 @@ void keyboard_handler()
if (c)
{
if (c == '\n')
{
_putchar('\r');
}
// Should probably have a keyboard buffer here... instead of this
_putchar(c);
}
@@ -247,4 +253,5 @@ void keyboard_init(unsigned char layout)
outb(0x21, mask);
DEBUG("PS/2 Keyboard initialized");
init.keyboard = true;
}

View File

@@ -7,6 +7,8 @@
#include <kernel.h>
#include "serial.h"
extern struct init_status init;
void outb(int port, unsigned char data)
{
__asm__ __volatile__("outb %%al, %%dx" :: "a" (data),"d" (port));
@@ -43,6 +45,7 @@ int serial_init()
outb(PORT + 4, 0x0F);
DEBUG("*** Welcome to PepperOS! ***");
init.serial = true;
return 0;
}

View File

@@ -16,8 +16,12 @@ because this shitty implementation will be replaced one day by Flanterm
#include "term.h"
#include "config.h"
#include "flanterm.h"
#include "flanterm_backends/fb.h"
#include "mem/heap/kheap.h"
#include "limine.h"
extern struct flanterm_context* ft_ctx;
extern struct init_status init;
// Overhead that could be avoided, right? (for printf)
void _putchar(char character)
@@ -36,4 +40,35 @@ void kputs(const char* str)
i++;
}
_putchar('\r');
}
extern struct flanterm_context* ft_ctx;
extern struct boot_context boot_ctx;
void flanterm_free_wrapper(void* ptr, size_t size)
{
(void)size;
kfree(ptr);
}
void term_init()
{
uint32_t bgColor = 0x252525;
ft_ctx = flanterm_fb_init(
kmalloc,
flanterm_free_wrapper,
boot_ctx.fb->address, boot_ctx.fb->width, boot_ctx.fb->height, boot_ctx.fb->pitch,
boot_ctx.fb->red_mask_size, boot_ctx.fb->red_mask_shift,
boot_ctx.fb->green_mask_size, boot_ctx.fb->green_mask_shift,
boot_ctx.fb->blue_mask_size, boot_ctx.fb->blue_mask_shift,
NULL,
NULL, NULL,
&bgColor, NULL,
NULL, NULL,
NULL, 0, 0, 1,
0, 0,
0,
0
);
init.terminal = true;
}

View File

@@ -9,5 +9,6 @@
void kputs(const char* str);
void _putchar(char character);
void term_init();
#endif