Date: Mon, 7 Apr 1997 13:05:48 -0600 (MDT) From: Ramesh Nallur To: Eli Zaretskii cc: djgpp AT delorie DOT com Subject: Re: Interrupts (Hardware) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII First I want to thank you for replying. > It would help if you also tell why do you need to know that. This > issue is immensly complex and full of gory details; knowing what > practical use do you have in mind will help to present manageable > amount of info without losing important details. > I am doing my masters in CS and currently I am working on an OS project and I want to write a server similar to the DPMI host. For this I started looking at the cwsdpmi code, but lot of things confused me. Hence the query. I really want to know all the gory details of interrupt handling and switching between modes. I need to know the setup of the IDT etc... > The IDT is not ``replaced'', at least not necessarily. The DPMI host > usually changes some entries in the IDT to point the hardware > interrupts to its own handlers, If you look at the code in CWSDPMI, there is a whole setup for the PM. The host sets up the IDT, GDT and switches modes (RM to PM) and then runs your program. (Ofcourse the RM IDT has to be replaced to switch to PM). > but AFAIK this is so it could reissue > the interrupts to real-mode handlers if the DPMI client (the DJGPP > program you run) didn't install its own handler. There is no general Yes, thats what I thought. Let me repeat what you just said, in PM if there is any interrupt, the DPMI host checks if there is any PM interrupt handler installed. If its not then switches to RM and executes the RM handlers. So I logically assumed that in PM if I replace an IDT entry by any of my own handker then an interrupt should be caught there . For eg the clock interrupt occurs at vector number 8, so replacing the IDT at vector 8 (base+8*8,base+8*8+4) should catch the clock interrupts. Well if PIC has been programmed and its not 8 then it should have been caught some where. So if I replace all the 256 entries then somewhere the clock interrupt should have been caught. I am talking about only PM here. Am I missing something very obvious here??. Additionally I would make sure that my interrupt handler does switch modes and run the RM handler. > > Why cant I just overwrite an IDT entry in PM and expect interrupts to be > > caught? > > I think if you do that, the reflection of the interrupts from RM might > be broken. Using the appropriate DPMI function makes your program > play by the rules. > > Why would you need to do that, anyway? > Write my own server and also I am very curious to know why when I replace an IDT entry in PM is the hardware interrupt not caught (in PM). > This is the entire code of the function that sets PM interrupt > handler. Where do you see anything that's connected with RM handlers > or 0000:0000? > > #define USE_EBX > #include "dpmidefs.h" > > .text > > FUNC(___dpmi_set_protected_mode_interrupt_vector) > ENTER > > movb ARG1, %bl > movl ARG2, %eax > movl (%eax), %edx > movw 4(%eax), %cx > DPMI(0x0205) > xorl %eax,%eax > > LEAVE I should have been more specific here. Well, I was talking about the code for DPMI(0x205) and not the API. Basically the handler for int 31 and ax=0205. Your answers have cleared all of my doubts except for one. Why can't I replace an IDT (PM) entry and expect the hardware interrupts to be caught(in PM only)???. Thanks a lot.