Xref: news2.mv.net comp.os.msdos.djgpp:6809 From: C M Marka Newsgroups: comp.os.msdos.djgpp Subject: Re: writing hw interrupt handlers. Date: Sun, 4 Aug 1996 17:46:12 +0000 Organization: LITNET Lines: 57 Message-ID: References: <4tuak7$h7m AT news DOT goodnet DOT com> NNTP-Posting-Host: santaka.sc-uni.ktu.lt Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <4tuak7$h7m@news.goodnet.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On 3 Aug 1996 snarfy AT goodnet DOT com wrote: > > _protected_mode_IRQ0_handler: > cli > ...do some stuff > movb $0x20,%al > outb %al, $0x20 > sti > iret > > Now, what else would have to be added to that code to make it work > without calling _go32_dpmi_allocate_iret_wrapper() on it? Maybe a > pusha, popa, stack switch, ... ? > ok, here's an example: # no cli! pusha pushl %ds mov %cs:___djgpp_ds_alias, %ds # # do your stuff here # popl %ds movb $0x20, %al outb %al, $0x20 popa sti iret cli/sti take up A LOT of CPU cycles under DPMI, and and the handler gets called with interrupts disabled anyway. so there.. Stack switch is not important in most cases IMHO. You get 4 Kb of stack, why shouldn't this be enough? And, of course, you want ds to point to your data segment, don't you? And don't forger to lock the handler and averything it touches! (___djgpp_ds_alias is locked by DJGPP startup code, so no problems here). And you can use ___djgpp_dos_sel if you need, it's locked as well. Anyway, check v2tk/mkkbd3.zip for an example with more explanations. BTW, I use pushl/popl on ds because that way the stack gets aligned better, and I use mov instead movw with ds because as generates extra bytes in the latter case. Phew... I hope I'll be able to explain all the pitfalls in the HW interrupts chapter of the DJGPP book, which I am working on (the chapter, not the book :) Cheers! Martynas