Download pmac users

Transcript
PMAC User Manual
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 interrupt(s) 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
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 need 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).
Writing a Host Communications Program
17-11