User's Manual

PMAC User Manual
Writing a Host Communications Program 257
The resulting new mask word is written back to I/O port address 21(hex) with:
outportb (0x21, ch)
Finally, re-enable the PC interrupts (TurboC command: enable();). This completes the setup procedure.
Using the Interrupts
To react to an interrupt in actual use, write an interrupt service routine. TurboC has a special type of
routine that makes this relatively easy. In naming the routine, specify that it is an interrupt routine. The
routine header line is something like:
static void interrupt far pmac_comm (void)
Not all of these words are needed in the declaration. The first void says that the routine will not return a
value; interrupt specifies this as an interrupt service routine; far declares the address (referred to in
setvect) to be a far pointer; pmac_comm is the name of the routine (called in setvect); the second "void"
declares that this has no arguments (since it cannot).
The interrupt routine should first disable PC interrupts (for just long enough to make sure the necessary
tasks can be done). Then it should write an End-of-Interrupt byte to the PC PIC (I/O port address
20(hex)). This byte has a high nibble of six, and a low nibble with the IRQ line number. For instance, if
IRQ4 is used, the TurboC statment to do this is:
outportb (0x20, 0x64) ;
As soon as possible, the PC interrupts should be re-enabled. When this can occur depends on how the
program is structured.
Now write an End-of-Interrupt byte to the PMAC PIC. The byte is the same (six in the high nibble;
hardware input (IR) line number in the low nibble). For the PMAC PIC, this byte is written to the card’s
base address plus eight in the PC’s I/O port space. This could be done with an outportb command.
Of course, somewhere in here, take the action that needs to be taken on receiving the interrupt, whether it
is simply reading a character, sending a command line, or finding an error condition.
Restoring Previous Vectors
Before exiting the application program, remask the PC interrupt and restore the old vector and mask the
interrupts on the PMAC PIC. The following TurboC code does this:
setvect (0x0c, oldvect) ; /* Restore old IRQ4 vector */
disable () ; /* Disable PC interrupts */
ch = inportb (0x21) ; /* Get PC mask word */
ch = ch | 0x10 ; /* Make bit 4 equal 1 */
outportb (0x21, ch) ; /* Send new PC mask word */
enable () ; /* Re-enable PC interrupts */
outportb (base+9, 0xff) ; /* Mask all PMAC interrupts */
VMEbus Communications
Setting up The Base Address for PMAC VME
PMAC VME communicates with the VME bus as a slave device through a set of 16 8-bit mailbox
registers., which are essentially 16 bytes of dual ported registers (not to be confused with Option 2V:
8Kx16 dual ported RAM). The mailbox registers occupy an address space on the VME bus, starting with
the base address plus 1.
Before communicating with PMAC VME over the VME bus, the base address of the mailbox registers
must be set up. Determine what memory space is available in the VME system, such that PMAC VME
will not conflict with other existing devices in the VME system. After selecting an address location, the
next thing to do is to tell PMAC what VME bus address it will reside at.