Commit 70c0f742 by malcolm

debug serial output and fixed syscalls

parent af2a722f
......@@ -5,7 +5,7 @@
#define NUM_PROCS 16
process* procs[NUM_PROCS];
int curproc=-1;
int curproc=0;
int firstfree=0;
//process* curproc;
......@@ -18,6 +18,11 @@ void addproc(process* proc)
//curproc=proc;
}
void settf(trapframe* tf)
{
procs[curproc]->tf = tf;
}
void schedule()
{
int old = curproc;
......@@ -46,13 +51,13 @@ int yield()
int print1()
{
terminal_writestring("1");
terminal_writestring("1\n");
return 1;
}
int print2()
{
terminal_writestring("2");
terminal_writestring("2\n");
return 2;
}
......@@ -63,13 +68,18 @@ void syscall()
{
int num = procs[curproc]->tf->eax;
serial_hexword(num);
serial_writestring(" SYSCALLED\n");
if(num>0 && num<NUM_SYSCALLS && syscalls[num])
{
procs[curproc]->tf->eax = syscalls[num]();
}
else
{
serial_writestring("UNKNOWN SYSCALL CALLED\n");
serial_writestring("UNKNOWN SYSCALL CALLED ");
serial_hexword(num);
serial_writestring("\n");
procs[curproc]->tf->eax = -1;
}
}
......
......@@ -66,6 +66,7 @@ typedef struct
extern void context_switch(context** old, context* new);
void syscall();
void addproc(process* proc);
void settf(trapframe* tf);
void proc_setup();
#endif
......@@ -59,7 +59,14 @@ void int_general_protection_fault(uint32_t __attribute__((unused))error)
}
void int_page_fault(uint32_t __attribute__((unused))error)
{
serial_writestring("PAGE FAULT ERROR\n");
serial_writestring("PAGE FAULT ERROR ");
serial_hexword(error);
uint32_t cr2;
asm volatile("movl %%cr2, %0" : "=r" (cr2) : );
//register uint32_t cr2 asm("%%cr2");
serial_writestring(" ");
serial_hexword(cr2);
serial_writestring("\n");
}
void int_reserved(uint32_t __attribute__((unused))error)
{
......
......@@ -2,6 +2,7 @@
#include "string.h"
#include "serial.h"
#include "exceptions.h"
#include "PCB.h"
#pragma GCC push_options
#pragma GCC optimize ("0")
......@@ -45,6 +46,7 @@ void load_error_handlers()
void default_handler(trapframe reg)
{
settf(&reg);
if(reg.trap<32)
reg.eip+=2;
if(handlers[reg.trap]!=NULL)
......@@ -105,7 +107,7 @@ int idt_init(uint16_t code_sel)
idtsetup();
idt_install();
load_error_handlers();
handlers[0x100] = syscall;
handlers[0x80] = syscall;
return 0;
}
#pragma GCC pop_options
......@@ -6,8 +6,8 @@
void test_idt()
{
asm ("int $0x80");
asm ("int $0x90");
asm volatile("mov $4, %eax; int $0x80");
asm volatile("int $0x90");
}
void test_mem()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment