A bit of cleaning

This commit is contained in:
2026-02-06 14:39:19 +01:00
parent 38710653be
commit 8aad1235c3
8 changed files with 62 additions and 54 deletions

41
src/boot/boot.c Normal file
View File

@@ -0,0 +1,41 @@
/*
* @author xamidev <xamidev@riseup.net>
* @brief Limine requests for boot
* @license GPL-3.0-only
*/
#include <limine.h>
// Framebuffer request
__attribute__((used, section(".limine_requests")))
volatile struct limine_framebuffer_request framebuffer_request = {
.id = LIMINE_FRAMEBUFFER_REQUEST,
.revision = 0
};
// Memory map request
__attribute__((used, section(".limine_requests")))
volatile struct limine_memmap_request memmap_request = {
.id = LIMINE_MEMMAP_REQUEST,
.revision = 0
};
// Higher Half Direct Map
__attribute__((used, section(".limine_requests")))
volatile struct limine_hhdm_request hhdm_request = {
.id = LIMINE_HHDM_REQUEST,
.revision = 0
};
// Executable Address/Kernel Address (find base phys/virt address of kernel)
__attribute__((used, section(".limine_requests")))
volatile struct limine_kernel_address_request kerneladdr_request = {
.id = LIMINE_KERNEL_ADDRESS_REQUEST,
.revision = 0
};
__attribute__((used, section(".limine_requests_start")))
volatile LIMINE_REQUESTS_START_MARKER;
__attribute__((used, section(".limine_requests_end")))
volatile LIMINE_REQUESTS_END_MARKER;

View File

@@ -11,11 +11,16 @@
#define PEPPEROS_VERSION_MAJOR "0"
#define PEPPEROS_VERSION_MINOR "0"
#define PEPPEROS_VERSION_PATCH "1"
#define PEPPEROS_SPLASH "pepperOS version "PEPPEROS_VERSION_MAJOR"."PEPPEROS_VERSION_MINOR"."PEPPEROS_VERSION_PATCH"\n"
/* process */
#define PROCESS_NAME_MAX 64
#define PROCESS_STACK_SIZE 0x10000 // 64kb
/* sched */
// 1 tick = 1 ms => quantum = 10ms
#define SCHEDULER_QUANTUM 10
/* kernel */
#define KERNEL_BASE 0xFFFFFFFF80000000ULL
// 2 MB should be enough (as of now, the whole kernel ELF is around 75kb)

View File

@@ -12,6 +12,7 @@
#include <kernel.h>
#include <stdbool.h>
#include "sched/scheduler.h"
#include "config.h"
struct interrupt_descriptor idt[256];
struct idtr idt_reg;
@@ -191,8 +192,7 @@ struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context)
DEBUG("Control Protection Exception!");
break;
case 32:
//DEBUG("Timer Interrupt");
case 32: // Timer Interrupt
ticks++;
if (ticks % SCHEDULER_QUANTUM == 0)

View File

@@ -17,8 +17,6 @@ enum TermColors
WHITE = 0xffffff
};
#define MAX_LINES 256
#define PSF1_FONT_MAGIC 0x0436
typedef struct

View File

@@ -38,7 +38,4 @@ struct boot_context
struct limine_kernel_address_response* kaddr;
};
// 1 tick = 1 ms => quantum = 10ms
#define SCHEDULER_QUANTUM 10
#endif

View File

@@ -26,52 +26,17 @@
// Limine version used
__attribute__((used, section(".limine_requests")))
static volatile LIMINE_BASE_REVISION(3);
volatile LIMINE_BASE_REVISION(3);
// Framebuffer request
__attribute__((used, section(".limine_requests")))
static volatile struct limine_framebuffer_request framebuffer_request = {
.id = LIMINE_FRAMEBUFFER_REQUEST,
.revision = 0
};
// Memory map request
__attribute__((used, section(".limine_requests")))
static volatile struct limine_memmap_request memmap_request = {
.id = LIMINE_MEMMAP_REQUEST,
.revision = 0
};
// Higher Half Direct Map
__attribute__((used, section(".limine_requests")))
static volatile struct limine_hhdm_request hhdm_request = {
.id = LIMINE_HHDM_REQUEST,
.revision = 0
};
// Executable Address/Kernel Address (find base phys/virt address of kernel)
__attribute__((used, section(".limine_requests")))
static volatile struct limine_kernel_address_request kerneladdr_request = {
.id = LIMINE_KERNEL_ADDRESS_REQUEST,
.revision = 0
};
__attribute__((used, section(".limine_requests_start")))
static volatile LIMINE_REQUESTS_START_MARKER;
__attribute__((used, section(".limine_requests_end")))
static volatile LIMINE_REQUESTS_END_MARKER;
// Panic (should dump registers etc. in the future)
// Halt and catch fire (makes machine stall)
void hcf()
{
//CLEAR_INTERRUPTS;
for (;;)
{
asm("hlt");
}
CLEAR_INTERRUPTS; for (;;)asm("hlt");
}
// Doing nothing (can be interrupted)
void idle() {for(;;)asm("hlt");}
void panic(struct cpu_status_t* ctx)
{
DEBUG("\x1b[38;5;231m\x1b[48;5;196mKernel panic!!!\x1b[0m at rip=%p\nSomething went horribly wrong! vect=0x%.2x errcode=0x%x\n\rrax=%p rbx=%p rcx=%p rdx=%p\n\rrsi=%p rdi=%p r8=%p r9=%p\n\rr10=%p r11=%p r12=%p r13=%p\n\rr14=%p r15=%p\n\n\rflags=%p\n\rstack at rbp=%p\n\rHalting...",
@@ -82,10 +47,13 @@ void panic(struct cpu_status_t* ctx)
hcf();
}
const char* splash = "pepperOS version "PEPPEROS_VERSION_MAJOR"."PEPPEROS_VERSION_MINOR"."PEPPEROS_VERSION_PATCH"\n";
struct boot_context boot_ctx;
extern volatile struct limine_framebuffer_request framebuffer_request;
extern volatile struct limine_memmap_request memmap_request;
extern volatile struct limine_hhdm_request hhdm_request;
extern volatile struct limine_kernel_address_request kerneladdr_request;
extern struct process_t* processes_list;
extern struct process_t* current_process;
@@ -146,7 +114,7 @@ void kmain()
keyboard_init(FR);
term_init();
kputs(splash);
kputs(PEPPEROS_SPLASH);
hcf();
idle();
}