diff --git a/.gitignore b/.gitignore index 8050cef..e2113f6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ bin/ limine/ ovmf/ release/ -*.log -.config* \ No newline at end of file +*.log \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index da7b995..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "external/flanterm"] - path = external/flanterm - url = https://codeberg.org/mintsuki/flanterm diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index aae99e6..df35a0b 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -10,9 +10,7 @@ "cppStandard": "${default}", "intelliSenseMode": "linux-gcc-x64", "defines": [ - "LIMINE_API_REVISION=3", - "FLANTERM_SUPPORT=1", - "BUILD_MODE=\"\"" + "LIMINE_API_REVISION=3" ] } ], diff --git a/.vscode/settings.json b/.vscode/settings.json index 3d27437..ef55fb4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,10 +13,6 @@ "emk.h": "c", "heap.h": "c", "vmm.h": "c", - "align.h": "c", - "cpu.h": "c", - "nanoprintf.h": "c", - "flanterm.h": "c", - "serial.h": "c" + "align.h": "c" } } \ No newline at end of file diff --git a/GNUmakefile b/GNUmakefile index 8154114..aa9b207 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,7 +2,7 @@ MAKEFLAGS += -rR .SUFFIXES: -QEMUFLAGS := -m 2G -serial stdio +QEMUFLAGS := -m 2G -serial stdio -display none USER_QEMUFLAGS ?= IMAGE_NAME := release/emk diff --git a/external/flanterm b/external/flanterm deleted file mode 160000 index bdecdcb..0000000 --- a/external/flanterm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bdecdcb1b7dad05ab5249e2c3e4d2c27a661e864 diff --git a/kernel/GNUmakefile b/kernel/GNUmakefile index 04a90ba..587e15c 100644 --- a/kernel/GNUmakefile +++ b/kernel/GNUmakefile @@ -8,34 +8,19 @@ BINDIR := bin TARGET := $(BINDIR)/emk.elf -KCONFIG ?= kconfig-mconf -CONFIG := .config - -ifneq ("$(wildcard $(CONFIG))","") - include $(CONFIG) -endif - CC := gcc AS := gcc NASM := nasm -ifeq ($(BUILD_MODE),) - ifeq ($(CONFIG_BUILD_MODE_DEBUG),y) - BUILD_MODE := debug - else ifeq ($(CONFIG_BUILD_MODE_RELEASE),y) - BUILD_MODE := release - else - BUILD_MODE := debug - endif -endif - +# Build mode configuration +BUILD_MODE ?= dev ifeq ($(BUILD_MODE),release) CFLAGS := -Os -pipe -Wall -Wextra -Werror -std=gnu11 -ffreestanding \ -fno-stack-protector -fno-stack-check -fno-PIC \ -ffunction-sections -fdata-sections -m64 -march=x86-64 \ -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone \ -mcmodel=kernel -fno-unwind-tables -fno-asynchronous-unwind-tables \ - -s -Wno-unused-variable -DBUILD_MODE=\"release\" + -s -Wno-unused-variable NASMFLAGS := LDFLAGS := -nostdlib -static -z max-page-size=0x1000 -Wl,--gc-sections \ -T linker.ld -Wl,-m,elf_x86_64 -Wl,--strip-all @@ -44,7 +29,7 @@ else -fno-stack-protector -fno-stack-check -fno-PIC \ -ffunction-sections -fdata-sections -m64 -march=x86-64 \ -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone \ - -mcmodel=kernel -Wno-unused-variable -DBUILD_MODE=\"dev\" + -mcmodel=kernel -Wno-unused-variable NASMFLAGS := -F dwarf -g LDFLAGS := -nostdlib -static -z max-page-size=0x1000 -Wl,--gc-sections \ -T linker.ld -Wl,-m,elf_x86_64 @@ -52,48 +37,14 @@ endif CPPFLAGS := -I../external -I$(SRCDIR) -MMD -MP -DLIMINE_API_REVISION=3 -IMPLICIT_SRCS := -ifeq ($(CONFIG_KERNEL_HEAP_FF),y) - IMPLICIT_SRCS += src/mm/heap/ff.c -else - $(error Error: No heap algorithm was defined. Please run "make menuconfig" and select one.) -endif - -ifeq ($(CONFIG_ENABLE_FLANTERM),y) - IMPLICIT_SRCS += ../external/flanterm/flanterm.c - IMPLICIT_SRCS += ../external/flanterm/backends/fb.c - CFLAGS += -I../external/flanterm/ -DFLANTERM_SUPPORT=1 -endif - -EXCLUDE_SRCS := \ - src/mm/heap/ff.c \ - ../external/flanterm/flanterm.c \ - ../external/flanterm/backends/fb.c -EXCLUDE_PATTERNS := $(foreach file,$(EXCLUDE_SRCS),! -path "$(file)") - -SRCS := $(IMPLICIT_SRCS) \ - $(shell find $(SRCDIR) -type f \( -name '*.c' -o -name '*.S' -o -name '*.asm' \) $(EXCLUDE_PATTERNS)) - -define src_to_obj -$(OBJDIR)/$(patsubst ../%,%,$(1:.c=.o)) -endef - -define src_to_obj_s -$(OBJDIR)/$(patsubst ../%,%,$(1:.S=.o)) -endef - -define src_to_obj_asm -$(OBJDIR)/$(patsubst ../%,%,$(1:.asm=.o)) -endef - -OBJS := -OBJS += $(foreach f,$(filter %.c,$(SRCS)),$(call src_to_obj,$(f))) -OBJS += $(foreach f,$(filter %.S,$(SRCS)),$(call src_to_obj_s,$(f))) -OBJS += $(foreach f,$(filter %.asm,$(SRCS)),$(call src_to_obj_asm,$(f))) +SRCS := $(shell find $(SRCDIR) -type f \( -name '*.c' -o -name '*.S' -o -name '*.asm' \)) +OBJS := $(patsubst %.c,$(OBJDIR)/%.o,$(filter %.c,$(SRCS))) \ + $(patsubst %.S,$(OBJDIR)/%.o,$(filter %.S,$(SRCS))) \ + $(patsubst %.asm,$(OBJDIR)/%.o,$(filter %.asm,$(SRCS))) DEPS := $(OBJS:.o=.d) -.PHONY: all clean distclean menuconfig +.PHONY: all clean distclean all: $(TARGET) $(OBJDIR) $(BINDIR): @@ -103,31 +54,16 @@ $(TARGET): $(OBJS) | $(BINDIR) @echo " LD $@" @$(CC) $(LDFLAGS) -o $@ $(OBJS) -$(OBJDIR)/%.o: ../%.c | $(OBJDIR) - @mkdir -p $(dir $@) - @echo " CC ../$*" - @$(CC) $(CPPFLAGS) $(CFLAGS) -c ../$*.c -o $@ - $(OBJDIR)/%.o: %.c | $(OBJDIR) @mkdir -p $(dir $@) @echo " CC $<" @$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ -$(OBJDIR)/%.o: ../%.S | $(OBJDIR) - @mkdir -p $(dir $@) - @echo " AS ../$*" - @$(AS) $(CPPFLAGS) $(CFLAGS) -c ../$*.S -o $@ - $(OBJDIR)/%.o: %.S | $(OBJDIR) @mkdir -p $(dir $@) @echo " AS $<" @$(AS) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ -$(OBJDIR)/%.o: ../%.asm | $(OBJDIR) - @mkdir -p $(dir $@) - @echo " NASM ../$*" - @$(NASM) $(NASMFLAGS) ../$*.asm -o $@ - $(OBJDIR)/%.o: %.asm | $(OBJDIR) @mkdir -p $(dir $@) @echo " NASM $<" @@ -141,7 +77,4 @@ distclean: clean @echo " DISTCLEAN" @rm -rf $(BINDIR) -menuconfig: clean - @$(KCONFIG) Kconfig - --include $(DEPS) +-include $(DEPS) \ No newline at end of file diff --git a/kernel/Kconfig b/kernel/Kconfig deleted file mode 100644 index af19094..0000000 --- a/kernel/Kconfig +++ /dev/null @@ -1,33 +0,0 @@ -mainmenu "EMK Build Configuration" - -choice - prompt "Build Mode" - default BUILD_MODE_DEBUG - -config BUILD_MODE_DEBUG - bool "Debug" - help - Build with debug symbols and no optimizations. - -config BUILD_MODE_RELEASE - bool "Release" - help - Build with optimizations and no debug symbols. - -endchoice - -choice - prompt "Kernel Heap Algorithm" - default KERNEL_HEAP_FF - -config KERNEL_HEAP_FF - bool "First-Fit" - help - Use the First-Fit memory allocation algorithm (ff.c). - -endchoice - -config ENABLE_FLANTERM - bool "Enable Flanterm Support" - help - Includes support for the Flanterm terminal emulator. Useful for debugging real hardware. diff --git a/kernel/src/boot/emk.h b/kernel/src/boot/emk.h index f78d7d5..a083268 100644 --- a/kernel/src/boot/emk.h +++ b/kernel/src/boot/emk.h @@ -5,9 +5,6 @@ #include #include #include -#if FLANTERM_SUPPORT -#include -#endif // FLANTERM_SUPPORT extern uint64_t hhdm_offset; extern struct limine_memmap_response *memmap; @@ -21,16 +18,4 @@ 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 \ No newline at end of file diff --git a/kernel/src/emk.c b/kernel/src/emk.c index 77c81b1..7eab3cf 100644 --- a/kernel/src/emk.c +++ b/kernel/src/emk.c @@ -13,10 +13,6 @@ #include #include #include -#if FLANTERM_SUPPORT -#include -#include -#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 = { @@ -28,11 +24,6 @@ __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; @@ -43,10 +34,6 @@ 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)); @@ -55,28 +42,8 @@ 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, emk1.0-%s, flanterm support: %s", __TIME__, __DATE__, BUILD_MODE, FLANTERM_SUPPORT ? "yes" : "no"); + log_early("Compiled at %s %s", __TIME__, __DATE__); if (!LIMINE_BASE_REVISION_SUPPORTED) { diff --git a/kernel/src/util/kprintf.c b/kernel/src/util/kprintf.c index be9a8b3..d15c989 100644 --- a/kernel/src/util/kprintf.c +++ b/kernel/src/util/kprintf.c @@ -1,10 +1,6 @@ /* EMK 1.0 Copyright (c) 2025 Piraterna */ -#include #include -#include -#if FLANTERM_SUPPORT -#include -#endif // FLANTERM_SUPPORT +#include #define NANOPRINTF_USE_FIELD_WIDTH_FORMAT_SPECIFIERS 1 #define NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS 1 @@ -26,10 +22,6 @@ 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);