1
0
Fork 0

feat/kernel: Added support for Kconfig and flanterm if needed

This commit is contained in:
Kevin Alavik 2025-05-15 20:47:52 +02:00
parent 65ba98a089
commit 89795c4ad8
Signed by: cmpsb
GPG key ID: 10D1CC0526FDC6D7
9 changed files with 179 additions and 16 deletions

View file

@ -5,6 +5,9 @@
#include <boot/limine.h>
#include <stdint.h>
#include <mm/vmm.h>
#if FLANTERM_SUPPORT
#include <flanterm/flanterm.h>
#endif // FLANTERM_SUPPORT
extern uint64_t hhdm_offset;
extern struct limine_memmap_response *memmap;
@ -18,4 +21,16 @@ extern vctx_t *kvm_ctx;
#define BIT(x) (1ULL << (x))
#ifndef FLANTERM_SUPPORT
#define FLANTERM_SUPPORT 0
#endif // FLANTERM_SUPPORT
#ifndef BUILD_MODE
#define BUILD_MODE "unknown"
#endif // BUILD_MODE
#if FLANTERM_SUPPORT
extern struct flanterm_context *ft_ctx;
#endif // FLANTERM_SUPPORT
#endif // EMK_H

View file

@ -13,6 +13,10 @@
#include <arch/paging.h>
#include <mm/vmm.h>
#include <mm/heap.h>
#if FLANTERM_SUPPORT
#include <flanterm/flanterm.h>
#include <flanterm/backends/fb.h>
#endif // FLANTERM_SUPPORT
__attribute__((used, section(".limine_requests"))) static volatile LIMINE_BASE_REVISION(3);
__attribute__((used, section(".limine_requests"))) static volatile struct limine_memmap_request memmap_request = {
@ -24,6 +28,11 @@ __attribute__((used, section(".limine_requests"))) static volatile struct limine
__attribute__((used, section(".limine_requests"))) volatile struct limine_executable_address_request kernel_address_request = {
.id = LIMINE_EXECUTABLE_ADDRESS_REQUEST,
.response = 0};
#if FLANTERM_SUPPORT
__attribute__((used, section(".limine_requests"))) volatile struct limine_framebuffer_request framebuffer_request = {
.id = LIMINE_FRAMEBUFFER_REQUEST,
.response = 0};
#endif // FLANTERM_SUPPORT
__attribute__((used, section(".limine_requests_start"))) static volatile LIMINE_REQUESTS_START_MARKER;
__attribute__((used, section(".limine_requests_end"))) static volatile LIMINE_REQUESTS_END_MARKER;
@ -34,6 +43,10 @@ uint64_t kphys = 0;
uint64_t kstack_top = 0;
vctx_t *kvm_ctx = NULL;
#if FLANTERM_SUPPORT
struct flanterm_context *ft_ctx = NULL;
#endif // FLANTERM_SUPPORT
void emk_entry(void)
{
__asm__ volatile("movq %%rsp, %0" : "=r"(kstack_top));
@ -42,8 +55,28 @@ void emk_entry(void)
/* Just halt and say nothing */
hcf();
}
/* Init flanterm if we compiled with support */
#if FLANTERM_SUPPORT
struct limine_framebuffer *framebuffer = framebuffer_request.response->framebuffers[0];
ft_ctx = flanterm_fb_init(
NULL,
NULL,
framebuffer->address, framebuffer->width, framebuffer->height, framebuffer->pitch,
framebuffer->red_mask_size, framebuffer->red_mask_shift,
framebuffer->green_mask_size, framebuffer->green_mask_shift,
framebuffer->blue_mask_size, framebuffer->blue_mask_shift,
NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, 0, 0, 1,
0, 0,
0);
#endif // FLANTERM_SUPPORT
log_early("Experimental Micro Kernel (EMK) 1.0 Copytright (c) 2025 Piraterna");
log_early("Compiled at %s %s", __TIME__, __DATE__);
log_early("Compiled at %s %s, emk1.0-%s, flanterm support: %s", __TIME__, __DATE__, BUILD_MODE, FLANTERM_SUPPORT ? "yes" : "no");
if (!LIMINE_BASE_REVISION_SUPPORTED)
{

View file

@ -1,6 +1,10 @@
/* EMK 1.0 Copyright (c) 2025 Piraterna */
#include <dev/serial.h>
#include <util/kprintf.h>
#include <dev/serial.h>
#include <boot/emk.h>
#if FLANTERM_SUPPORT
#include <flanterm/flanterm.h>
#endif // FLANTERM_SUPPORT
#define NANOPRINTF_USE_FIELD_WIDTH_FORMAT_SPECIFIERS 1
#define NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS 1
@ -22,6 +26,10 @@ int kprintf(const char *fmt, ...)
if (length >= 0 && length < (int)sizeof(buffer))
{
serial_write(COM1, (uint8_t *)buffer, length);
#if FLANTERM_SUPPORT
if (ft_ctx)
flanterm_write(ft_ctx, (char *)buffer, length);
#endif // FLANTERM_SUPPORT
}
va_end(args);