Category : Files from Magazines
Archive   : PCTJ8804.ZIP
Filename : POS_READ.C1

 
Output of file : POS_READ.C1 contained in archive : PCTJ8804.ZIP
/* This code illustrates techniques for reading POS data
* It searches the slots, looking for IBM Multi-Protocol
* Communications adapters and displays a report of what it finds.
*
* Uses Turbo C inportb() and outportb() for port I/O.
* Written by Dan Rollins
*/
#define MPCA_ID 0xdeff /* card ID of Multi-Protocol adapter */
#define PORT_BITS 0x1e /* bit mask to determine port usage */
#define SDLC_1 0x10 /* values for SDLC ports */
#define SDLC_2 0x12
#define BISYNC_1 0x18 /* values for BISYNC ports */
#define BISYNC_2 0x1A
/* other values are asynch serial ports */
#define SLOT_SELECT 0x96 /* port selects a slot for setup */
#define CARD_ID 0x100 /* (also 0101h) contains the card ID */
#define POS_BASE 0x102 /* port contains first POS data byte */
#define POS_BYTES 4 /* number of POS bytes to read */

main()
{
unsigned j, t, id;
unsigned char pos[POS_BYTES];

for ( j=1; j <= 8; j++ ) {
id = ReadSlot( j, &pos );
printf( "Slot %d: ID=%4X, POS bytes= %2X, %2X, %2X, %2X\n",
j, id, pos[0], pos[1], pos[2], pos[3] );
if ( id == MPCA_ID ) {
printf(" Multi-Protocol Communications Adapter found ...\n");
t = pos[0] & PORT_BITS;
switch (t) {
case SDLC_1:
case SDLC_2:
printf(" Setup for SDLC usage.\n");
break;
case BISYNC_1:
printf(" Setup as BISYNC_1, ports 3A0h-3ABh\n");
break;
case BISYNC_2:
printf(" Setup as BISYNC_2, ports 380h-38Bh\n");
break;
default:
printf(" Setup as SERIAL_%d.\n", (t >> 1)+1 );
}
}
}
}

/* This reads POS information from the adapter in a selected slot.
* Returns the adapter ID and fills an array with 4 POS bytes.
*/
ReadSlot( slot_no, pos_array )
unsigned slot_no;
char *pos_array;
{
unsigned id, j;
outportb(SLOT_SELECT, (slot_no-1) | 8); /* put it in setup mode */
id = inportb(CARD_ID); /* read low byte of card ID */
id |= (inportb(CARD_ID+1) << 8); /* read the high byte */
for ( j=0; j pos_array[j] = inportb(POS_BASE+j); /* the caller's array */
}
outportb( SLOT_SELECT, 0 ); /* get out of setup; enable card */
return(id); /* return value is the card ID */
}

  3 Responses to “Category : Files from Magazines
Archive   : PCTJ8804.ZIP
Filename : POS_READ.C1

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/