Specifications
68 Chapter 5 - Software Interface
BUS.C - PC-Bus and Micro Channel Driver Code
The following machine-dependent code implements the getpacket() and
sendpacket() functions for the E271-2201 PC-Bus and E271-2202 Micro Channel
controllers.
The getpacket() function discards all packets until the requested packet is received.
The getanypacketbus() function polls the Not Ready bit and reads the eight I/O
ports. The sendpacket() function writes to the I/O ports. See Bus Controllers,
page 55, for information on communicating with bus controllers.
The E271-2202 is located by checking the POS registers for the ID of the
"adapter" in each slot. Once the E271-2202 is located, the Base I/O Port (and
optionally the Interrupt) can be read. This auto-detect procedure can only be run
after a hard system reset, a soft reset (Control-Alt-Delete), or after sending a
Quiet-all command to the E271-2202. Therefore, call disablecontroller() when you
are finished with the controller so others may locate and use it. For more
information on the interrupt 15h BIOS calls used in this code, see the IBM
Personal System/2 and Personal Computer BIOS Interface Technical Reference.
/************ E271-2201, E271-2202 controller dependent code *************/
#define DEFAULTBASEPORT 0x280 /* default base port address of E271-2201 */
#define IBM_ID 0x6253 /* IBM assigned Micro Channel adapter ID for
E271-2202 */
unsigned baseport; /* controller base I/O port */
boolean mca; /* true if Micro Channel */
int initbuscontroller(void);
int clearbuscontroller(void);
boolean getanypacketbus(packettype packet);
boolean checkmca(void);
int findmcacontroller(void);
void resetmcacontrollerpos(void);
void initcontroller(void)
{
int msg = OK;
mca = checkmca();
if (mca) /* are we on a Micro Channel system? */
msg = findmcacontroller(); /* yes set baseport value */
else
baseport = DEFAULTBASEPORT;
if (msg == OK)
msg = initbuscontroller(); /* initialize E271-2201 and E271-2202 */
if (msg == OK)
msg = clearbuscontroller();
if (msg != OK)
quit(errormsg(msg));
}
int initbuscontroller(void)
{
packettype ack,quiet = {'Q',2,0,0,0,0,0,0};
byte b;
b = (byte)inp(baseport) & (byte)0x7f; /* command byte is guaranteed A Z */
if ((b < (byte)'A') || (b > (byte)'Z'))
return(NOCONTROLLER);
sendpacket(quiet); /* enable controller */
if (!getpacket(ack,'A')) /* any ack? */
return(NOCONTROLLER);
return(OK);
}
int clearbuscontroller(void)
{
int count=250;