Message board for the users of flat assembler.
> OS Construction > PM Switch from ring0 to ring3?
dosin 06 Nov 2007, 05:31
There are the Eflags:
EFLAGS_IOPL code:3000h bits: 12,13 = io priv level
and I have read that you can access by means of a gate?
or thourgh syscall and sysenter funtions?
or through the GDT? I was looking at MenuetOS
MenuetOS code: ring3_code_l: dw 0xffff dw 0x0000 db 0x00 dw 11011111b *256 +11111010b db 0x00
Has anyone done this?
or know of any examples to get started with this?
so far I have just been working at ring 0... and I am trying to figure out how to load my driver into ring1 for example... or do I even need to switch rings in order to do this? and then go to ring3 and execute some code to test..
Thanks in advance for any help!
|06 Nov 2007, 05:31||
Japheth 06 Nov 2007, 21:55
A switch from ring 0 to ring 3 is done by a RETF or a IRET!
And IOPL is absolutely irrelevant for this mode switch.
|06 Nov 2007, 21:55||
dosin 07 Nov 2007, 00:29
?A switch from ring 0 to ring 3 is done by a RETF or a IRET!
to go into ring 3 do I use the IRET again to go back to ring 0..
also what about ring 1 and 2?
and would an int ?? cause it to switch since it ends with IRET?
should I place the iret or retf in a function:
so far its locking up the sys when I try it
|07 Nov 2007, 00:29||
Japheth 07 Nov 2007, 08:41
> to go into ring 3 do I use the IRET again to go back to ring 0..
this question tells me that you urgently should read the intel documentation first. A switch to a "inner" ring is done through a gate (call, interrupt, trap gates), returning to an "outer" ring is done via RETF/IRET.
if a RETF (IRET) causes a ring switch, the cpu expects not just EIP/CS(/EFL) onto the stack, but additionally ESP/SS. If the VM bit is set in the EFL register copy onto the stack and the cpu is in ring 0, the cpu will also expect v86-mode values for ES,DS,FS,GS onto the stack.
|07 Nov 2007, 08:41||
dosin 08 Nov 2007, 07:27
Well I have been going over the manual and some other documentation..
hence my confusion on this...
This is from chapter four protection... am I reading in the wrong section on this?
---INTEL SYS MANUAL---
This was in a 386 programming book and does not discuss the iret or retf
syscall and sysenter
and from looking at other OS and articles...
Thanks for your help and clarifying it...
you given me a good place to start working on it!
|08 Nov 2007, 07:27||
< Last Thread | Next Thread >
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.