• Keine Ergebnisse gefunden

INTERRUPT DEVICES

Im Dokument SYSTEMS GUIDE (Seite 54-59)

XIOS OVERVIEW

3.5 INTERRUPT DEVICES

As in the case of polled I/O devices, an XIOS driver handling an interrupt-driven I/O device should not execute a wait loop or halt instruction while waiting for an interrupt to occur.

The Concurrent XIOS handles interrupt-driven devices with DEV_WAITFLAG and DEV _SETFLAG system calls. A process that needs to wait for an interrupt to occur makes a DEV_WAITFLAG system call with a flag number. The system stops this process until the desired XIOS interrupt handler routine makes a DEV _SETFLAG system call with the same flag number. The waiting process then continues execution. The interrupt handler follows the steps outlined below, executing a JUMP FAR (JMPF) to the Dispatcher entry pOint. The interrupt handler can also perform an IRET instruction when it needs to return, but jumping directly to the Dispatcher provides a faster response to the process waiting on the flag and is logically equivalent to the IRET instruction.

If interrupts are enabled within an interrupt routine, a Tick interrupt can cause the interrupt handler to be dispatched. This dispatch could make interrupt response time unacceptable. To avoid this situation, do not re-enable interrupts within the interrupt handlers or only jump to the Dispatcher when not in another interrupt handler routine.

Because of machine architecture differences, Concurrent interrupt handlers differ from those in an 8080, 8085, or Z-80 environment. Study the example XI OS Tick interrupt handler carefully. During initial debugging, do not implement interrupts until after the system works in a polled environment.

An XIOS interrupt handler routine must perform the following basic steps:

1. Do a stack switch to a local stack. The interrupted process might not have enough stack space for a context save.

2. Save the register environment of the interrupted process, or at least the registers that will be used by the interrupt routine. Usually the registers are saved on the local stack established by the first step.

3. Satisfy the interrupting condition. This can include resetting the hardware and performing a DEV_SETFLAG system call to notify a process that the interrupt for which it was waiting has occurred.

4. Restore the interrupted process's register environment.

Interrupt Devices Concurent DOS B6 System Guide 5. Switch back to the original stack.

6. Return from the interrupt routine with either a JUMP FAR (JMPF) to the dispatcher or an Interrupt Return (IRET). When interrupts are not re-enabled within the interrupt handler, a JMPF to the dispatcher is executed on each system tick and after a DEV_SETFLAG call is made. If interrupts are re-enabled, an IRET instruction is executed.

Note: DEV_SETFLAG is the only Concurrent system call an interrupt routine can use. This is because DEV_SETFLAG is the only system call the operating system assumes has no process context associated with it. DEV_SETFLAG must enter the operating system through the SUP entry point at SYSDAT:OOOOH and cannot use INT 224.

3.6 Numeric Data Processor EXCEPTION HANDLER

This section explains how to provide support for the NDP chip. This is required to allow more than one process to use the NDP without conflict and to handle the NDP exception interrupt. The following discussion applies to the BOB7, B02B7 and B03B7 Numeric Data Processor (NDP) from Intel. The XIOS initialization code must initialize five fields in the SYSDAT area to support the NDP. The XI OS must also contain a default exception handler to handle any interrupts from the NDP. The system is structured so that a programmer can write an individual exception handler for the NDP.

The XIOS initialization code must first check for the presence of the NDP chip by using the FNINIT instruction. If the NDP is present, the XIOS initialization code must set up the following SYSDAT fields:

SEG_BOB7 OFF_BOB7 SYS_B7_SG SYS_B7_0F OWNER_BOB7

Must be set to the segment and offset of the NDP interrupt vector.

Must be set to the segment and

offset of the XI OS default exception handler.

Must be set to 0 to indicate that there is an NDP present in the system. The default value is FFFFH which indicates no NDP. FFFFH is put in this field by the SUP initialization code.

The NDP interrupt vector itself must also be set to the segment and offset of the XIOS default exception handler.

To guarantee program integrity in a multitasking environment, the NDP exception handler must perform its functions in a specific order. The following steps outline the primary functions of the example default NDP exception handler (see Listing 3-4):

1. Save the Processor environment.

2. 'Save the NDP environment.

3. Clear the NDP IR (status word).

Concurent DOS 86 System Guide Numeric Data Processor Exception Handler 4. Disable NDP interrupts.

5. Acknowledge the interrupt (hardware dependent).

6. Read the OWNER_808? field in SYSDAT and perform the desired action. Note that processor interrupts are currently disabled. Do not perform any action that would turn them back on yet. The default exception handler uses the OWNER_808? field to terminate the process on a severe error.

? Restore the processor environment.

8. Restore the NDP environment with clear status. This enables the NDP interrupts.

9. Execute an IRET instruction to return and enable the processor interrupts.

If the NDP environment is not restored before processor interrupts are enabled and an interrupt occurs (for example, Tick), a different NDP process can gain control of the NDP and swap in its NDP context. On a second interrupt, or on an IRET instruction, the process that happened to be executing the exception handler code will be brought back into context and will write over the new NDP context.

All NDP processes are initialized by the system with the address of the default exception handler. If a process wants to use its own exception handler, it must initially overwrite the NDP interrupt vector with the address of its own exception handler. On each context switch, the NDP interrupt vector is saved and restored as part of the NDP process's environment.

The hardware-dependent address of the NDP interrupt vector is provided in the SEG_808? and OFF _808? fields of the system data area.

An individual exception handler that does not follow the sequence of events described for the default handler will have unpredictable results on the system. If possible, make this default interrupt handler re-entrant.

Numeric Data Processor Exception Handler Concurent DOS 86 System Guide take specific actions in response to these conditions. ThiS handler ignores non-severe errors (overflow, etc.) and terminates processes with severe errors (divide by zero, stack violation).

push

Concurent DOS 86 System Guide Numeric Data Processor Exception Handler routines should either handle the function requested or print an error message and terminate the current process. Obviously on a PC or compatible many of the functions can be passed on to the ROS.

The following ROS interrupts are intercepted by Concurrent.

INT 11 h System Configuration sub-functions are passed to the original ISR. Check new PS/2 sub-functions.

PC/AT ROS Interrrupt Support Concurent DOS 86 System Guide INT 16h Keyboard Services

Sub-functions 0 to 2 and 10h to 12h are emulated by Concurrent. All other sub-functions are passed to the original ISR. INT 16h is commonly used by clone manufacturers to access extra facilities provided by their hardware, ie Processor Speed Switching.

INT 17h Parallel Printer 1/0

Sub-functions 0 (Print Character) and 2 (Status) are emulated by Concurrent.

All other sub-functions are passed to the original ISR.

Im Dokument SYSTEMS GUIDE (Seite 54-59)