kbd_fix #12

Merged
xamidev merged 3 commits from kbd_fix into main 2026-03-09 09:30:42 +01:00
6 changed files with 20 additions and 17 deletions
Showing only changes of commit 3f9b78b05e - Show all commits

View File

@@ -47,3 +47,4 @@ PepperOS wouldn't be possible without the following freely-licensed software:
- the [OSDev](https://osdev.org) wiki & forums
- Intel 64 and IA-32 Architectures Software Developer's Manual
- Documentation for the [GNU Compiler Collection](https://gcc.gnu.org/onlinedocs/gcc/)

View File

@@ -52,8 +52,7 @@ void idt_load(void* idt_addr)
void idt_init()
{
// We set 256 entries, but we have only the first few stubs.
// Undefined behavior?
// Hardcoded...
for (size_t i=0; i<=33; i++)
{
// Each vector handler is 16-byte aligned, so <vector_no>*16 = address of that handler

View File

@@ -23,8 +23,7 @@ enum ErrorCodes
extern volatile uint64_t ticks;
#define DEBUG(log, ...) fctprintf((void*)&skputc, 0, "[%8u] debug: [%s]: " log "\r\n", ticks, __FILE__, ##__VA_ARGS__)
#define DEBUG(log, ...) fctprintf((void*)&skputc, 0, "[%8u] debug: <%s>: " log "\r\n", ticks, __func__, ##__VA_ARGS__)
/* #define DEBUG(log, ...) \
printf("debug: [%s]: " log "\r\n", __FILE__, ##__VA_ARGS__); \

View File

@@ -50,16 +50,24 @@ 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)
{
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");
for (;;)
{
asm("hlt");
}
}
extern uintptr_t kheap_start;
@@ -94,17 +102,13 @@ void kmain()
idt_init();
process_init();
struct process_t* idle_proc = process_create("idle", (void*)idle_main, 0);
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();
current_process = idle_proc;
current_process->status = RUNNING;
kputs(PEPPEROS_SPLASH);
//panic(NULL, "Test panic");
idle();
}

View File

@@ -45,7 +45,7 @@ void process_display_list(struct process_t* processes_list)
struct process_t* process_create(char* name, void(*function)(void*), void* arg)
{
/* CLEAR_INTERRUPTS; */
CLEAR_INTERRUPTS;
struct process_t* proc = (struct process_t*)kmalloc(sizeof(struct process_t));
struct cpu_status_t* ctx = (struct cpu_status_t*)kmalloc(sizeof(struct cpu_status_t));
@@ -79,7 +79,7 @@ struct process_t* process_create(char* name, void(*function)(void*), void* arg)
process_add(&processes_list, proc);
/* SET_INTERRUPTS; */
SET_INTERRUPTS;
return proc;
}

View File

@@ -12,6 +12,7 @@
extern struct process_t* processes_list;
extern struct process_t* current_process;
extern struct process_t* idle_proc;
void scheduler_init()
{
@@ -28,9 +29,8 @@ struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
if (current_process == NULL)
{
// Wtf happened
current_process = processes_list;
//panic(NULL, "Scheduler called without current process");
// If no more processes, then set IDLE as the current process, that's it.
current_process = idle_proc;
}
current_process->context = context;
@@ -49,15 +49,15 @@ struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
if (current_process != NULL && current_process->status == DEAD)
{
process_delete(&prev_process, current_process);
current_process = NULL;
return idle_proc->context;
} else
{
current_process->status = RUNNING;
break;
}
}
// Current_process gets wrong context?? (iret_rip points to other stuff than process function; like putpixel() for example)
DEBUG("current_process={pid=%u, name='%s', root_page_table[virt]=%p}", current_process->pid, current_process->name, current_process->root_page_table);
load_cr3(VIRT_TO_PHYS((uint64_t)current_process->root_page_table));