Issues with system call
Posted: Fri Nov 29, 2013 6:03 pm
I've recently been trying to follow JamesM's tutorial to implement system calls in my operating system, with minimal luck. Using the following code to perform the jump to usemode, I get a general protection fault.
I'm assuming it works, as when I don't try to call the system, everything works as normal. However, when I attempt to call my test system call on interrupt 0x7F, it GPFs.
I've double checked my GDT, IDT, and IRQ code, and can't seem to find a problem with them. The GPF gives 0 as the error code, and reports the instruction pointer to be 0 as well. Any ideas as to what might be the problem?
Code: Select all
asm volatile(" \
cli; \
mov $0x23, %ax; \
mov %ax, %ds; \
mov %ax, %es; \
mov %ax, %fs; \
mov %ax, %gs; \
\
mov %esp, %eax; \
pushl $0x23; \
pushl %eax; \
pushf; \
pop %eax; \
orl $0x0202, %eax; \
push %eax; \
pushl $0x1B; \
push $1f; \
iret; \
1: \
");
Code: Select all
global test_func
test_func:
mov eax, 0x0
int 0x7F