still fighting an issue

This commit is contained in:
2026-07-03 22:25:24 -05:00
parent 48df965268
commit ab5a1ecb6b
5 changed files with 18 additions and 22 deletions

View File

@@ -33,7 +33,7 @@ init_pic:
outb %al, $PIC2_DATA outb %al, $PIC2_DATA
# mask # mask
mov $0xFF, %al mov $0xFE, %al
outb %al, $PIC1_DATA outb %al, $PIC1_DATA
mov $0xFF, %al mov $0xFF, %al
outb %al, $PIC2_DATA outb %al, $PIC2_DATA

View File

@@ -41,11 +41,12 @@ ISR_ERRCODE 14 # Page Fault (Has Error Code!)
// This is a special case so we need to handle it for task switching // This is a special case so we need to handle it for task switching
.global isr32 .global isr32
.extern switch_context # scheduler.c .extern switch_context # scheduler.c
.extern send_eoi_master # drivers/pic/pic.c .extern send_eoi_master # drivers/pic/pic.S
isr32: isr32:
cli cli
pushal pushal
xorl %eax, %eax
movw %ds, %ax movw %ds, %ax
pushl %eax pushl %eax
@@ -55,12 +56,12 @@ isr32:
movw %ax, %fs movw %ax, %fs
movw %ax, %gs movw %ax, %gs
call send_eoi_master
pushl %esp pushl %esp
call switch_context call switch_context
movl %eax, %esp movl %eax, %esp
call send_eoi_master
popl %eax popl %eax
movw %ax, %ds movw %ax, %ds
movw %ax, %es movw %ax, %es

View File

@@ -3,6 +3,7 @@
#include <lib/print.h> #include <lib/print.h>
#include "syscall.h" #include "syscall.h"
#include "common.h"
#include <drivers/pic/pic.h> #include <drivers/pic/pic.h>
#include <drivers/ps2/ps2.h> #include <drivers/ps2/ps2.h>
@@ -110,7 +111,14 @@ void common_interrupt_handler(registers *args) {
case 13: case 13:
case 15: case 15:
case 16: case 16:
kprintf("CPU Error: %s, %d\n", err_messages[args->int_no], args->error_code); kprintf("CPU Error: [%d]%s\n", args->int_no, err_messages[args->int_no]);
kprintf("Error Code: 0x%x\n", args->error_code);
kprintf("Instruction Pointer: 0x%x\n", args->eip);
kprintf("Stack Pointer: 0x%x\n", args->useresp);
kprintf("EAX: 0x%x\n", args->eax);
kprintf("EFLAGS: 0x%x\n", args->eflags);
kprintf("cr3: 0x%x\n", fetch_cr3());
while(1);
break; break;
case 14:{ case 14:{
uint32_t faulting_address; uint32_t faulting_address;

View File

@@ -59,6 +59,7 @@ vfs_node_t* load_initrd() {
void load_root_program(const char* path) { void load_root_program(const char* path) {
uint32_t kernel_cr3 = fetch_cr3(); uint32_t kernel_cr3 = fetch_cr3();
void* cr3 = create_task_pd(); void* cr3 = create_task_pd();
kprintf("new task cr3 0x%x\n", cr3);
load_pd(cr3); load_pd(cr3);
flush_tlb(); flush_tlb();
@@ -171,6 +172,5 @@ void kmain(uint32_t magic, multiboot_info* mbi) {
init_scheduler(); init_scheduler();
enable_interrupts(); enable_interrupts();
kprintf("loading origin program\n");
load_root_program("/origin.elf"); load_root_program("/origin.elf");
} }

View File

@@ -16,10 +16,7 @@ static process_t* process_table;
static int current_process = 0; static int current_process = 0;
static int total_processes = 0; static int total_processes = 0;
#define IDLE_TASK_PID 1 #define IDLE_TASK_PID 0
static void idle_task() {
while (1) asm volatile("hlt");
}
static void lock_scheduler() { static void lock_scheduler() {
disable_interrupts(); disable_interrupts();
@@ -94,8 +91,6 @@ void init_scheduler() {
process->flags = PROCESS_FLAG_KERNEL; process->flags = PROCESS_FLAG_KERNEL;
total_processes++; total_processes++;
create_task((uint32_t)idle_task, fetch_cr3(), 0, 0);
current_process = 0; current_process = 0;
} }
@@ -138,8 +133,6 @@ int create_task(uint32_t entry_point, uint32_t cr3, int user, uint32_t u_esp) {
*(--esp) = 0x23; *(--esp) = 0x23;
} else { } else {
// IRET values for Ring 0 // IRET values for Ring 0
*(--esp) = 0x23; // User Data Segment (SS) with RPL 3 (0x20 | 3)
*(--esp) = kstack_top; // User Stack Pointer (ESP) - location mapped in user space
*(--esp) = 0x0202; // EFLAGS *(--esp) = 0x0202; // EFLAGS
*(--esp) = 0x08; // Kernel Code Segment (CS) *(--esp) = 0x08; // Kernel Code Segment (CS)
*(--esp) = entry_point; // EIP *(--esp) = entry_point; // EIP
@@ -155,12 +148,6 @@ int create_task(uint32_t entry_point, uint32_t cr3, int user, uint32_t u_esp) {
*(--esp) = 0; // ESI *(--esp) = 0; // ESI
*(--esp) = 0; // EDI *(--esp) = 0; // EDI
if (user) {
*(--esp) = 0x23; // User Data Segment
} else {
*(--esp) = 0x10; // Kernel Data Segment
}
process->esp = (uint32_t)esp; process->esp = (uint32_t)esp;
if (!reuse) { if (!reuse) {
total_processes++; total_processes++;