Finished basic task switching mechansim
PCB is local to a process's address space. Context switches are written in assembly. Moved x86 headers to include/x86
This commit is contained in:
@@ -1,32 +1,43 @@
|
||||
#include "kernel.h"
|
||||
#include "isr.h"
|
||||
#include "x86/isr.h"
|
||||
#include "stdio.h"
|
||||
#include "apic.h"
|
||||
#include "x86/apic.h"
|
||||
#include "x86/processstate.h"
|
||||
#include "context.h"
|
||||
|
||||
void isr_generic(void* frame)
|
||||
struct interrupt_frame_t
|
||||
{
|
||||
size_t eip;
|
||||
size_t cs;
|
||||
size_t eflags;
|
||||
size_t esp;
|
||||
size_t ss;
|
||||
};
|
||||
|
||||
void isr_generic(struct interrupt_frame_t *frame)
|
||||
{
|
||||
printf("Generic interrupt.\n");
|
||||
}
|
||||
|
||||
void isr_division_by_zero(void* frame)
|
||||
void isr_division_by_zero(struct interrupt_frame_t *frame)
|
||||
{
|
||||
printf("Exception: Division by zero\n");
|
||||
}
|
||||
|
||||
void isr_gp_fault(void* frame, unsigned int error)
|
||||
void isr_gp_fault(struct interrupt_frame_t *frame, unsigned int error)
|
||||
{
|
||||
asm("cli");
|
||||
asm("mov $0x10, %%ax; "
|
||||
"mov %%ax, %%ds; "
|
||||
"mov %%ax, %%es; "
|
||||
"mov %%ax, %%fs; "
|
||||
"mov %%ax, %%gs; "
|
||||
::: "ax");
|
||||
"mov %%ax, %%gs; " ::
|
||||
: "ax");
|
||||
printf("Exception: GP fault, code %08x\n", error);
|
||||
asm("hlt");
|
||||
}
|
||||
|
||||
void isr_page_fault(void* frame, unsigned int error)
|
||||
void isr_page_fault(struct interrupt_frame_t *frame, unsigned int error)
|
||||
{
|
||||
size_t addr;
|
||||
asm("mov %%cr2, %0"
|
||||
@@ -35,53 +46,26 @@ void isr_page_fault(void* frame, unsigned int error)
|
||||
"mov %%ax, %%ds; "
|
||||
"mov %%ax, %%es; "
|
||||
"mov %%ax, %%fs; "
|
||||
"mov %%ax, %%gs; "
|
||||
::: "ax");
|
||||
"mov %%ax, %%gs; " ::
|
||||
: "ax");
|
||||
printf("Exception: Page fault, code %08x, linear address %08x\n", error, addr);
|
||||
asm("hlt");
|
||||
}
|
||||
|
||||
void isr_double_fault(void* frame, unsigned int error)
|
||||
void isr_double_fault(struct interrupt_frame_t *frame, unsigned int error)
|
||||
{
|
||||
asm("cli");
|
||||
|
||||
|
||||
printf("Exception: Double fault (!!), code %08x\n", error);
|
||||
asm("hlt");
|
||||
}
|
||||
|
||||
void isr_timer(void* frame)
|
||||
void isr_timer(struct interrupt_frame_t *frame)
|
||||
{
|
||||
printf("Timer tick.\n");
|
||||
apic_eoi();
|
||||
}
|
||||
|
||||
void isr_preempt(void* frame)
|
||||
void isr_syscall(struct interrupt_frame_t *frame)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void isr_ap_start(void* frame)
|
||||
{
|
||||
asm(".code16");
|
||||
//...
|
||||
asm(".code32");
|
||||
// do something useful
|
||||
}
|
||||
|
||||
void isr_syscall(void* frame)
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user