User's Manual

PMAC User Manual
256 Writing a Host Communications Program
Vectoring
In vectoring, usually the first step is to save the old vector so it can be restored on exiting the program. This
is essential if borrowing an interrupt line. In TurboC, this can be done using the getvect function, as in:
oldvect = getvect(0x0d)
This statement stores the existing interrupt vector for interrupt number 0d(hex) — IRQ5 — in the (long)
variable oldvect.
The next step is to enter an interrupt vector. Do this in TurboC with the setvect function, as in:
setvect (0x0d, pmac_comm);
The address of the interrupt service routine does not need to be specified, only the name of the routine —
in this case pmac_comm.
The unmasking step should wait until the PMAC has been set up properly.
Setting up the Host Request Function
To set up PMAC, first write a value to the DSP’s interrupt control register, which is at the PMAC base
address in the PC’s port space (this address is set by jumpers E66-E71 and E91-E92). This value will
determine what, if any, character-by-character handshake interrupts will be used. Refer to the HREQ
description, above, for the proper value. The TurboC command would be:
outportb (base, value);
(The equivalent Microsoft C command is outp [base, value].) This command, or its equivalent in other
languages, can also be used to perform the steps below.
Initializing the PMAC PIC
Next, write to the PMAC PIC’s Initialization Command Words (ICWs) to set up the PIC properly.
Although this IC is on PMAC, it is mapped into the PC’s port space as two registers at the PMAC base
address plus 8 and 9.
To do this, perform the following steps:
Write a byte of 17(hex) to [PMAC base address + 8]. This sets up ICW1 for edge-triggered
interrupts.
Write a byte of 08(hex) to [PMAC base address + 9]. This sets up ICW2.
Write a byte of 03(hex) to [PMAC base address + 9]. This sets up ICW4 for 8086-mode operation.
Write a byte of FF(hex) to [PMAC base address + 9]. This writes to Operation Control Word 1 to
mask all eight interrupts into the PMAC PIC.
Unmasking Interrupts
When ready to accept interrupts from PMAC, unmask the interrupts into the PMAC PIC that will be
active. Write a one-byte argument in which every masked interrupt to the PMAC PIC is represented by a
1; and every unmasked interrupt is represented by a zero. For instance, to unmask IR4 alone, the argument
would be ef(hex); to unmask IR5 alone, the argument would be df(hex). The routines write this argument
to the PMAC PIC's Operation Control Word 1 (OCW1). Without the driver, use a command like:
outportb (base+9, 0xef); /* unmask IR4 only */
At this point, unmask the interrupt being used on the PC’s PIC. First, disable the PC interrupts (TurboC
command: disable(); ). Next, read the current mask word at I/O port address 21(hex) with a command
like:
ch = inportb(0x21)
Then unmask the new interrupt to be use by performing a bit-by-bit AND between the current mask word
and a mask word that would enable only the new interrupt line – ef(hex) for IRQ4, fe(hex) for IRQ3. The
C command for this is:
ch = ch & 0xef