From: Michael Bukin Newsgroups: comp.os.msdos.djgpp Subject: Re: LONG: My INT31 handler isn't feeling too swell Date: 09 Apr 1999 08:10:24 +0700 Organization: Budker Institute of Nuclear Physics Lines: 63 Message-ID: <20zp4ik39b.fsf@Sky.inp.nsk.su> References: <7e7j4e$cr4$4 AT news DOT luth DOT se> <20vhfc47t7 DOT fsf AT Sky DOT inp DOT nsk DOT su> <7edsj2$agf$1 AT news DOT luth DOT se> <20aewlb2p0 DOT fsf AT Sky DOT inp DOT nsk DOT su> <7eim6i$nrb$1 AT news DOT luth DOT se> NNTP-Posting-Host: sky.inp.nsk.su X-Newsreader: Gnus v5.5/Emacs 19.34 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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