Mail Archives: djgpp/1999/04/08/21:41:46
ams AT ludd DOT luth DOT se (Martin Str|mberg) writes:
> Yes. But you missed the point where I said upon entry of my
> handler. Hence x = 8!
But knowing how to do things yourself is usually better than getting
answer without knowledge, so I described how to calculate offsets.
>
> Anyway I _really_ appreciate your helping comments.
You are welcome.
>
> Another question: teh selector is 16 bits, right? But when pushed or
> popped stack changes by 32 bits?
My book says:
"`push' instruction decrements stack pointer on 2, if command's operand
size attribute is equal 16 bits; otherwise it is decremented by 4.
Then operand is placed on top of stack, addressed by stack pointer."
It is better to keep stack aligned, that's why nobody is using pushw
for pushing selectors and all commands that place selector on stack,
increment stack pointer by 4 bytes (lcall and int, maybe others too).
>
> : BTW, you can use selector from stack to determine DPL or anything
> : else necessary for allocated selector (though all allocated selectors
> : will usually have the same DPL as your interrupt handler DPL).
>
> Hmm. What is DPL? Something Priviledge Level?
Descriptor Priviledge Level. Sorry, I'm not able to explain what it
means, you'd better read a book about that.
>
> So how can I determine DPL from selector? And what should I have it
> for?
You can use `lar' instruction. See src/libc/dpmi/api/dpmi_lar.S in
djlsr202.zip, for example. You may need it if you want to match DPMI
specs. Quoting the description of Int 0x31/AX=0x0000
o The privilege level of descriptors will match the
application's code segment privilege level. When
modifying descriptors, always set the DPL to the
same privilege ring as your program's code
segment. Use the lar instruction to determine the
privilege of a descriptor.
You can use %cs of your program code which was pushed on stack upon
entry to interrupt, and get access rights for it. Then set access
rights for selector which you are returning from cache. Perhaps you
should not bother about it right now, because usually all selectors
allocated with Int 0x31/AX=0x0000 and AX=0x000A will have one DPL. If
they are guaranteed to have one DPL and it is not possible for program
to change DPL of allocated descriptor to something else, then you
don't need it at all.
--
Michael Bukin
- Raw text -