DPMI raw mode switch
From: rjb (nonesuch_at_here.com)
Date: 06/02/04
- Next message: Robert Redelmeier: "Re: A fucking bunch of lying pussies"
- Previous message: T.M. Sommers: "Re: Linux syscalls"
- Next in thread: BSpider: "Re: DPMI raw mode switch"
- Reply: BSpider: "Re: DPMI raw mode switch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 2 Jun 2004 17:28:56 +0000 (UTC)
In the DPMI specs it says:
<< When a program uses the raw mode switch services (see
page 77) or issues DOS calls from a hardware interrupt
handler, it will need to save the state of the current
task before changing modes. This service returns the
addresses of two procedures used to save the state of
the current task's registers. For example, the real
mode address is used to save the state of the protected
mode registers. The protected mode address is used to
save the state of the real mode registers. >>
I don't follow that. I've just entered protected mode for the first time,
using the standard ax=1687/int 2F routine. Any real mode registers I was
using before are now lost, surely? How can I save real mode registers when
I'm in protected mode?
The example code they give doesn't help much either:-
Sample_Timer_Code:
pushf
call FAR PTR cs:[Next_Timer_Handler]
sti
;
; Save protected mode registers
;
push ds
push es
pusha
;
; Save real mode registers
;
mov ds, cs:[My_Local_DS]
mov ax, ss
mov es, ax
sub sp, [State_Save_Size]
mov di, sp
xor al, al
call [PM_Save_Restore_State]
;
; Raw mode switch here
;
.
.
.
;
; Restore real mode registers
;
mov ax, ss
mov es, ax
mov di, sp
mov al, 1
call [PM_Save_Restore_State]
add sp, [State_Save_Size]
; Restore protected mode registers and return
;
popa
pop es
pop ds
iret
Since the final pops restore the same registers pushed at the start, I
presume we're supposed to be back in protected mode. In that case, where it
says "Raw mode switch here", it must mean *two* raw mode switches - into vm,
and back into pm. So what about the return switch to pm that isn't shown?
Does that switch require some saving routine as well? And what are these
registers that are being saved anyway? Are they just segment registers, or
the whole collection? Also, who are they being saved for? I don't think it
can be me, since when I switch to rm from pm, using the call address
supplied, I am invited to specify all the important registers I want, as
follows:-
AX = New DS
CX = New ES
DX = New SS
(E)BX = New (E)SP
SI = New CS
(E)DI = New (E)IP
So I just cannot see what that saving service is for. It makes no sense. Can
anyone explain this?
rjb
- Next message: Robert Redelmeier: "Re: A fucking bunch of lying pussies"
- Previous message: T.M. Sommers: "Re: Linux syscalls"
- Next in thread: BSpider: "Re: DPMI raw mode switch"
- Reply: BSpider: "Re: DPMI raw mode switch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]