Task contexts now load segment registers correctly
Interrupt enable bit set in saved EFLAGS register
This commit is contained in:
@@ -5,4 +5,4 @@
|
||||
|
||||
void *initialize_context(void *task_entry, struct page_stack_t *page_stack);
|
||||
|
||||
void load_context(struct process_state_t *context) __attribute__((noreturn));
|
||||
void load_context(struct process_state_t *context) __attribute__((naked));
|
||||
|
||||
@@ -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; ");
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
@@ -46,10 +58,18 @@ void isr_timer(void* frame)
|
||||
void isr_preempt(void* frame)
|
||||
{
|
||||
asm("pushal; "
|
||||
"mov %esp, %ebp");
|
||||
"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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user