Switch to ring 3
Posted: Mon Jun 01, 2015 5:12 pm
Hello, I've (at last) successfully created basic of os - software interrupts in ring 3. Now I am aiming to crate hardware handling for for ex. PIT interrupt. I get back to user mode switch code and pushed corrected eflags on to stack, so the iret will pop ant set the register. After doing this my code fails.
bochs log says only : and the two more faults.
Edit: I should mention that generates GPF
Code: Select all
.global usermode_switch
.type usermode_switch, @function
usermode_switch:
#Data segment setup
mov $0x13, %ax
mov %ax, %ds
mov %ax, %gs
mov %ax, %fs
mov %ax, %es
#Stack save
mov %esp, %eax
#stack setup for iret and user space return
pushl $0x13
pushl %eax
pushf
#enable ints after switch to ring 3
pop %eax
or $0x200, %eax
pushl %eax
#CS selector
pushl $0x0b
pushl $end_switch
iret
.extern upperKernelCode
end_switch:
call upperKernelCode
Code: Select all
interrupt(): gate descriptor is not valid sys seg (vector=0x08)
Edit: I should mention that
Code: Select all
call upperKernelCode