[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interrupt code



Wayne, David, and community,


When the interrupt occurs, it is necessary to save any registers used by the interrupt service routine.

Regarding the saving of these registers, there  are two techniques  for this context save.

The first one is to simply push the context registers onto thew caller's stack and pop them when you are done.

Since we don't know the size and location of the callers stack, this can be problematic.

The second technique involves the use of a private stack on entry and switch back before the end of the ISR.

This generally works in a system where the interrupts are not reenabled until the end of the ISR.

Currently, it is undefined whether we will allow nested interrupts. When an ISR  is entered, the time between the
disablement of the interrupt system and it's subsequent re-enablement is a guarded region and constitutes a
latency period for all other interrupts that may be pending. In the case of some devices, it is necessary to
servicer them immediately to prevent data loss. For this reason it is desirable to allow nested interrupts.

I can see a likely scenario where we would want to use nested interrupts. The PS/2 mouse and keyboard ports
must be serviced on time, especially necessary if we are bit banging/grabbing in order to receive serial presented
information.

Nested interrupts are a little tricky, but can be used to provide dramatic results. I am hoping that the interrupt
scema will take this into account. A case in point being the implementation of MPM-80 the performance of which
depends heavily on the use of nested interrupts to support mass storage access (may include floppies and
communication channels such as UART's.

A typical technique is to keep an interrupt count in memory that is incremented on entry and decremented on exit.

The 8259A programmable interrupt controller has priority dispatching modes, although I usually use it in 
"round robin" mode. Also please note that when using the 8259A interrupt controller, failure to clear all interrupt
causes before exiting is penalized by subsequent failure of the interrupt system as the 8259A will not accept
future interrupts.

An easy example of this would be the collision of the timer interrupt with other real-time devices such as a 
floppy drive which requires the incoming data to be read immediately.

Hence there is a genuine difference between David's proof of concept interrupt example and a more realistic
fully functional system with up to eight interrupt sources (using the 8259A interrupt controller, including the
pesky IR7 default interrupt (also known as the vacuum cleaner interrupt because it just happens when the 
environment is noisy, and it must be handed immediately as indicated in the Intel documentation.

Because of all these factors, a robust interrupt system capable of handling nested interrupts requires a sophisticated
ISR whose size will easily exceed the last page of the CBIOS space. Because of this I see a requirement
for the entire ISR and supporting routines to be in the alternate bank. There is of course the issue of user callbacks
to ISR extensions existing in the base banks of the TPA space.
Nested interrupts are a challenge to test and certify as correct and safe.

I really look forward to discussing the HBIOS's support for interrupts, as this groundwork is critical for the more
challenging port to MP/M-80 using the HBIOS for all hardware related  tasks.

Respectfully,

Douglas Goodall


On Sep 18, 2012, at 6:39 AM, Wayne Warthen <wwar...@gmail.com> wrote:

Hi David,

In KBDISR, I don't see you saving the register contents.  Isn't that required?  Seems like every hardware interrupt would destroy the active registers.  I don't think the Z80 automatically saves and restores the registers when an interrupt occurs, does it?

Thanks,

Wayne



On Tue, Sep 18, 2012 at 6:34 AM, Wayne Warthen <wwar...@gmail.com> wrote:
Hi David,

Yes, I don't think I have been very clear about the HBIOS upper memory stub.

The top page of memory ($FF00-$FFFF) is a part of HBIOS.  This area hosts the RST 08 handler, the interrupt vector table, and is intended to host the ISR's.  The tricky part is that you will find this code in bnk1.asm.  At the end of bnk1.asm is found the HBIOS upper memory stub.  When the loader sets up HBIOS, it copies the code in the last 256 bytes of bnk1.asm into the top 256 of normal memory.

If you look at bnk1.asm, you can add code after the HB_ENTRY routine.  It may be a little confusing because the HBIOS stack is located in the slack space at the very top of memory.  This means that as code is added after HB_ENTRY, that the HBIOS stack space will be reduced.  Currently, there is a fair amount of space there (more than needed for the stack).  However, I fully expect that some day I will need to expand the HBIOS stub from the current 256 bytes to 512 bytes.

I hope I have explained this OK.  Let me know if it works for you.  I'm very excited about the interrupt support work you are doing.  This can substantially improve the useability of the BIOS.

Thanks!

Wayne


On Mon, Sep 17, 2012 at 11:17 PM, David Giles <vk...@internode.on.net> wrote:
Hi Wayne,

Which bit of HBIOS is in the upper 32k?  Must have missed that.  And yes KBDISR (and any others) can go there.

Regards

David



On 18/09/12 15:01, Wayne Warthen wrote:
Hi David,

I definitely like the idea of the keyboard ISR.  The polling method used now is very problematic.

What you have below is almost exactly what I was expecting.  The only thing I still don't quite understand is the idea that some code needs to go in CBIOS.  There is an area of the HBIOS that is permanently resident in the upper 32K.  Can't KBDISR go there?

Thanks!

Wayne