Task contexts now load segment registers correctly

Interrupt enable bit set in saved EFLAGS register
This commit is contained in:
2021-04-18 02:10:03 -05:00
parent 1171aa2ca3
commit c39cbb79cd
3 changed files with 32 additions and 7 deletions

View File

@@ -35,7 +35,7 @@ void *initialize_context(void *task_entry, struct page_stack_t *page_stack)
memset(stack, 0, sizeof(*stack));
stack->eip = (uint32_t)task_entry;
stack->cs = 27;
stack->flags = flags;
stack->flags = flags | 0x200;
stack->esp = 0xFF7FE000;
stack->ss = 35;
stack->esp_temp = &stack->eax;
@@ -44,8 +44,13 @@ void *initialize_context(void *task_entry, struct page_stack_t *page_stack)
void load_context(struct process_state_t *context)
{
asm("mov %0, %%esp; "
asm("mov $0x10, %%ax; "
"mov %%ax, %%ds; "
"mov %%ax, %%es; "
"mov %%ax, %%fs; "
"mov %%ax, %%gs; "
::: "ax");
asm("mov 4(%esp), %esp; "
"popal; "
"iret; "
:: "r"(context));
"iret; ");
}

View File

@@ -16,6 +16,12 @@ void isr_division_by_zero(void* frame)
void isr_gp_fault(void* frame, unsigned int error)
{
asm("cli");
asm("mov $0x10, %%ax; "
"mov %%ax, %%ds; "
"mov %%ax, %%es; "
"mov %%ax, %%fs; "
"mov %%ax, %%gs; "
::: "ax");
printf("Exception: GP fault, code %08x\n", error);
asm("hlt");
}
@@ -25,6 +31,12 @@ void isr_page_fault(void* frame, unsigned int error)
size_t addr;
asm("mov %%cr2, %0"
: "=r"(addr));
asm("mov $0x10, %%ax; "
"mov %%ax, %%ds; "
"mov %%ax, %%es; "
"mov %%ax, %%fs; "
"mov %%ax, %%gs; "
::: "ax");
printf("Exception: Page fault, code %08x, linear address %08x\n", error, addr);
asm("hlt");
}
@@ -45,11 +57,19 @@ void isr_timer(void* frame)
void isr_preempt(void* frame)
{
asm("pushal;"
"mov %esp, %ebp");
asm("pushal; "
"mov %esp, %ebp; ");
asm("mov $0x10, %%ax; "
"mov %%ax, %%ds; "
"mov %%ax, %%es; "
"mov %%ax, %%fs; "
"mov %%ax, %%gs; "
::: "ax");
struct process_state_t *process_state;
asm("mov %%ebp, %0"
: "=r"(process_state));
printf("Preempted process %08x.\n", kernel_state.active_process);
apic_eoi();
next_process(&kernel_state, process_state);
}