115 lines
2.7 KiB
C
115 lines
2.7 KiB
C
/*
|
|
* @author xamidev <xamidev@riseup.net>
|
|
* @brief PepperOS kernel entry point
|
|
* @license GPL-3.0-only
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <limine.h>
|
|
#include "io/term/term.h"
|
|
#include "io/term/printf.h"
|
|
#include "io/serial/serial.h"
|
|
#include "mem/gdt/gdt.h"
|
|
#include "mem/misc/utils.h"
|
|
#include "idt/idt.h"
|
|
#include "kernel.h"
|
|
#include "time/timer.h"
|
|
#include "io/kbd/ps2.h"
|
|
#include "mem/paging/pmm.h"
|
|
#include "mem/paging/paging.h"
|
|
#include "mem/paging/vmm.h"
|
|
#include "mem/heap/kheap.h"
|
|
#include "sched/process.h"
|
|
#include "sched/scheduler.h"
|
|
#include "config.h"
|
|
#include "io/term/flanterm.h"
|
|
#include "io/term/flanterm_backends/fb.h"
|
|
|
|
// Limine version used
|
|
__attribute__((used, section(".limine_requests")))
|
|
volatile LIMINE_BASE_REVISION(3);
|
|
|
|
// Halt and catch fire (makes machine stall)
|
|
void hcf()
|
|
{
|
|
CLEAR_INTERRUPTS; for (;;)asm("hlt");
|
|
}
|
|
|
|
// Doing nothing (can be interrupted)
|
|
void idle() {SET_INTERRUPTS; for(;;)asm("hlt");}
|
|
|
|
struct flanterm_context *ft_ctx;
|
|
struct boot_context boot_ctx;
|
|
struct init_status init = {0};
|
|
|
|
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;
|
|
struct process_t* idle_proc;
|
|
|
|
bool iran = false;
|
|
|
|
// Never gets executed although pedicel is scheduled?
|
|
void pedicel_main(void* arg)
|
|
{
|
|
//panic(NULL, "test");
|
|
bool iran = true;
|
|
// FROM THE NEXT LINE ONWARDS, CANNOT WRITE TO FRAMEBUFFER WITHOUT PAGE FAULT!
|
|
//printf("\n\nWelcome to PepperOS! Pedicel speaking.\nNothing left to do, halting the system!");
|
|
}
|
|
|
|
void idle_main(void* arg)
|
|
{
|
|
for (;;) {
|
|
asm("hlt");
|
|
}
|
|
}
|
|
|
|
extern uintptr_t kheap_start;
|
|
|
|
// This is our entry point
|
|
void kmain()
|
|
{
|
|
CLEAR_INTERRUPTS;
|
|
if (!LIMINE_BASE_REVISION_SUPPORTED) hcf();
|
|
|
|
serial_init();
|
|
timer_init();
|
|
|
|
// Populate boot context
|
|
boot_ctx.fb = framebuffer_request.response ? framebuffer_request.response->framebuffers[0] : NULL;
|
|
boot_ctx.mmap = memmap_request.response ? memmap_request.response : NULL;
|
|
boot_ctx.hhdm = hhdm_request.response ? hhdm_request.response : NULL;
|
|
boot_ctx.kaddr = kerneladdr_request.response ? kerneladdr_request.response : NULL;
|
|
|
|
boot_mem_display();
|
|
pmm_init(boot_ctx);
|
|
|
|
// Remap kernel , HHDM and framebuffer
|
|
paging_init(boot_ctx);
|
|
kheap_init();
|
|
|
|
keyboard_init(FR);
|
|
|
|
term_init();
|
|
|
|
gdt_init();
|
|
idt_init();
|
|
|
|
process_init();
|
|
idle_proc = process_create("idle", (void*)idle_main, 0);
|
|
struct process_t* pedicel = process_create("pedicel", (void*)pedicel_main, 0);
|
|
|
|
process_display_list(processes_list);
|
|
|
|
scheduler_init();
|
|
|
|
kputs(PEPPEROS_SPLASH);
|
|
idle();
|
|
}
|