still fighting an issue
This commit is contained in:
@@ -16,10 +16,7 @@ static process_t* process_table;
|
||||
static int current_process = 0;
|
||||
static int total_processes = 0;
|
||||
|
||||
#define IDLE_TASK_PID 1
|
||||
static void idle_task() {
|
||||
while (1) asm volatile("hlt");
|
||||
}
|
||||
#define IDLE_TASK_PID 0
|
||||
|
||||
static void lock_scheduler() {
|
||||
disable_interrupts();
|
||||
@@ -94,8 +91,6 @@ void init_scheduler() {
|
||||
process->flags = PROCESS_FLAG_KERNEL;
|
||||
total_processes++;
|
||||
|
||||
create_task((uint32_t)idle_task, fetch_cr3(), 0, 0);
|
||||
|
||||
current_process = 0;
|
||||
}
|
||||
|
||||
@@ -131,15 +126,13 @@ int create_task(uint32_t entry_point, uint32_t cr3, int user, uint32_t u_esp) {
|
||||
uint32_t* esp = (uint32_t*)kstack_top;
|
||||
if (user) {
|
||||
*(--esp) = 0x23; // User Data Segment (SS) with RPL 3 (0x20 | 3)
|
||||
*(--esp) = u_esp; // User Stack Pointer (ESP) - location mapped in user space
|
||||
*(--esp) = u_esp; // User Stack Pointer (ESP) - location mapped in user space
|
||||
*(--esp) = 0x0202; // EFLAGS (Interrupts enabled)
|
||||
*(--esp) = 0x1B; // User Code Segment (CS) with RPL 3 (0x18 | 3)
|
||||
*(--esp) = entry_point; // EIP
|
||||
*(--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
|
||||
@@ -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; // EDI
|
||||
|
||||
if (user) {
|
||||
*(--esp) = 0x23; // User Data Segment
|
||||
} else {
|
||||
*(--esp) = 0x10; // Kernel Data Segment
|
||||
}
|
||||
|
||||
process->esp = (uint32_t)esp;
|
||||
if (!reuse) {
|
||||
total_processes++;
|
||||
|
||||
Reference in New Issue
Block a user