working on getting a unified stack setup for user and kernel tasks

This commit is contained in:
2026-07-01 22:09:01 -05:00
parent b6ee4fc3de
commit 48df965268
2 changed files with 11 additions and 4 deletions

View File

@@ -12,7 +12,7 @@
#include "gdt.h"
static process_t* process_table;
static int current_process = 0;
static int total_processes = 0;
@@ -138,6 +138,8 @@ int create_task(uint32_t entry_point, uint32_t cr3, int user, uint32_t u_esp) {
*(--esp) = 0x23;
} else {
// 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) = 0x08; // Kernel Code Segment (CS)
*(--esp) = entry_point; // EIP
@@ -153,6 +155,12 @@ int create_task(uint32_t entry_point, uint32_t cr3, int user, uint32_t u_esp) {
*(--esp) = 0; // ESI
*(--esp) = 0; // EDI
if (user) {
*(--esp) = 0x23; // User Data Segment
} else {
*(--esp) = 0x10; // Kernel Data Segment
}
process->esp = (uint32_t)esp;
if (!reuse) {
total_processes++;