A bit of cleaning
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
||||
SOURCES = src/sched/scheduler.c src/sched/process.c src/mem/heap/kheap.c src/mem/paging/vmm.c src/mem/paging/paging.c src/mem/paging/pmm.c src/string/string.c src/io/kbd/ps2.c src/io/serial/serial.c src/io/term/printf.c src/io/term/term.c src/idt/idt.c src/mem/gdt/gdt.c src/mem/misc/utils.c src/time/timer.c src/kmain.c
|
||||
SOURCES = src/boot/boot.c src/sched/scheduler.c src/sched/process.c src/mem/heap/kheap.c src/mem/paging/vmm.c src/mem/paging/paging.c src/mem/paging/pmm.c src/string/string.c src/io/kbd/ps2.c src/io/serial/serial.c src/io/term/printf.c src/io/term/term.c src/idt/idt.c src/mem/gdt/gdt.c src/mem/misc/utils.c src/time/timer.c src/kmain.c
|
||||
|
||||
PROBLEMATIC_FLAGS=-Wno-unused-parameter -Wno-unused-variable
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ The basics that I'm targeting are:
|
||||
|
||||
### Scalability/maintenance/expansion features
|
||||
|
||||
- Global config header file
|
||||
- Documentation
|
||||
- SOME error handling in functions
|
||||
- Unit tests
|
||||
|
||||
41
src/boot/boot.c
Normal file
41
src/boot/boot.c
Normal 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;
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -17,8 +17,6 @@ enum TermColors
|
||||
WHITE = 0xffffff
|
||||
};
|
||||
|
||||
#define MAX_LINES 256
|
||||
|
||||
#define PSF1_FONT_MAGIC 0x0436
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -38,7 +38,4 @@ struct boot_context
|
||||
struct limine_kernel_address_response* kaddr;
|
||||
};
|
||||
|
||||
// 1 tick = 1 ms => quantum = 10ms
|
||||
#define SCHEDULER_QUANTUM 10
|
||||
|
||||
#endif
|
||||
|
||||
58
src/kmain.c
58
src/kmain.c
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user