home *** CD-ROM | disk | FTP | other *** search
/ Byte OS/2 Programmer's Cookbook / OS2TOOLS.ISO / ibminfo / comhack.txt < prev    next >
Internet Message Format  |  1992-10-16  |  11KB

  1. From: tedm@agora.rain.com (Ted Mittelstaedt)
  2. Subject: How to modify cheap com port cards
  3. Date: Sat, 3 Oct 1992 21:35:49 GMT
  4.  
  5.   Modifying a simple COM port is easy, I'll tell you how I modified an internal
  6. modem card that I have to use IRQ2/9.  Keep in mind that I have not done this
  7. with the COM card I was referring to previously.  I don't think it would be
  8. difficult, however, as it appears to be the same setup as the internal modem.
  9.  
  10.  
  11.  
  12.            HARDWARE HACKING: MODIFYING A SIMPLE(CHEAP) COM PORT TO
  13.                                  USE HIGHER IRQ's
  14.  
  15.    First of all, lets discuss the idea of what an IRQ is, and how it's 
  16. implimented on an AT, just so we are all clear on the concept.
  17.  
  18.   As most people probably know, on a standard AT there are 4 I/O port memory
  19. locations commonly associated with serial communication ports, and there are
  20. only 2 commonly associated IRQ's that are used with these locations.  What 
  21. does this mean?  Well, here goes:
  22.  
  23.   A COM port on an IBM AT class computer usually consists of what are known as
  24. UARTS.  These are physical chips that translate the parallel data from the 
  25. computer's bus to serial data that the modem needs.  These are usually stand-
  26. alone chips that reside on a "serial port card", however in the case of 
  27. the cheaper internal modems they can be a small section of the modem chip,
  28. which typically would be a larger chip containing the UART, the modem, and so
  29. forth.
  30.   UARTS take up what is known as "I/O Port Memory" when they are plugged into
  31. the computer.  The memory locations referred to by COM port card makers and
  32. others are actually the starting I/O memory address of a number of I/O ports
  33. "a block" that contain various UART programming registers for the chip.
  34.   The memory locations on an AT that have come to be known as the "standard"
  35. locations are:
  36.    03F8  02F8  03E8  02E8  (these are hexadecimal numbers)
  37.   Now, There are 2 ways to program UARTS, the first is "interrupt driven" and
  38. the second is "polled"  With Polled operation, the subject of IRQ's has no
  39. relavence, because the IRQ is not even active.  Instead, the Operating System
  40. is supposed to periodically read some ports in the port block to see if a
  41. character has arrived.  Needless to say, this makes for very crude operation
  42. since many characters can come and go before the OS gets around to checking
  43. the port.  Worse yet, if no characters are coming in at all, the OS is wasting
  44. CPU cycles on useless instructions to get incoming characters when there 
  45. aren't any to get!  Polled operation is the type of operation that the BIOS
  46. sets up for the COM ports when the computer is started, it is what is going
  47. on when you TYPE a file to the COM port from the DOS prompt.
  48.   This is how the designers of the AT could get away with supplying only 2
  49. IRQ's to the 4 com ports.  Since the BIOS programs the UART to go into polled
  50. mode, there is never an IRQ conflict, at least when the machine starts, there
  51. isin't.
  52.   Of course, communication programs have loads of characters coming in that
  53. can't wait for the OS to poll.  So, the concept of the IRQ comes into play.
  54.   An IRQ is simply this: a wire that runs from a chip deep in the bowls of the
  55. AT called an "Interrupt controller" and connects to one or more of the UARTS.
  56. When a UART receives a character, it "triggers the IRQ" by dropping the 
  57. voltage on the wire, this signals the Interrupt controller to wake up and
  58. do something about the incoming character.  If the Interrupt controller is
  59. properly programmed, and the UART is programmed to be in the "interrupt
  60. driven" mode, what happens is the controller interrupts the CPU and the CPU
  61. supposedly starts executing a routine to fetch the character from the port.
  62.   This is where the fun and games start.  With the "standard" AT, if you plug
  63. 4 UARTS (com ports) into the 4 I/O memory locations, the default settings on
  64. the serial cards (or internal modems) will connect the IRQ wires from COM1 &
  65. COM3 together, and COM2 & COM4 together.  This pair of wires will then be
  66. connected to the Interrupt Controller.  This is great for Polled Operation,
  67. because the IRQ lines are not active, but less than desirable for Interrupt
  68. Driven operation.  The reason is that software is generally not written to
  69. expect this, the biggest problem is what if 2 ports connected together receive
  70. a character at the same time?  Software to support IRQ sharing must check
  71. each port connected to the same IRQ to make sure that no character came in when
  72. the Interrupt controller is triggered.
  73.   Because of this, various schemes have arisen to obtain more IRQ lines for
  74. the COM ports/and or share the IRQ lines available.  The problem with them is
  75. that there is no standardization, and worse a lot of programmers are
  76. "unclear on the concept" so even if there were a standard half the software
  77. would probably not impliment it correctly.
  78.   Another problem is the difference between the XT and the AT.  With an XT,
  79. you get only 1 Interrupt Controller chip which limits you to a grand total
  80. of 8 IRQ lines.  Some of these are used for such essentials as the keyboard
  81. and the clock, so you really only get 5 free.  Of the 5, one is IRQ2, that
  82. goes to the video card for the Horizontal Retrace (which is hardly ever
  83. used unless you like CGA cards) and 2 others go to the Printer Ports. (of
  84. which there are 2 on XT & AT's). So, you really only get 2 good ones, unless you
  85. like to lose one of your printers, or take a chance on conflicting with your
  86. SoundBlaster/Midi card (which is usually connected to IRQ2).
  87.   With an AT, you get 2 Interrupt Controllers, so you get 15 total.  Wait, I
  88. hear you saying, 8 + * = 16.  Well, that is true, but the way that the AT
  89. designers decided to implement the second Interrupt Controller is by hanging
  90. it off IRQ2 on the first one.  They then ran the wire from IRQ9 on the second
  91. to the same buss connector used for IRQ2, and did some fiddley-fancy with the
  92. BIOS so that your cards that expected to see IRQ2 thought that they were.
  93.   So, you can see that the problem of IRQ's on the AT is not just a hardware
  94. one, it is software as well.  This article will attempt to tell you how to
  95. configure separate IRQ's for the 4 com ports, but if your software is not
  96. written to use anything other than the default connections, you won't get
  97. anywhere.
  98.  
  99.   The first thing you need to know is where the physical contacts are for
  100. the various IRQ's  Here is the pinout for the standard AT:
  101.  
  102.   B4 = IRQ9      }
  103.   B21 = IRQ7     }
  104.   B22 = IRQ6     }---- These are all on the "8-bit" buss connector
  105.   B23 = IRQ5     }
  106.   B24 = IRQ4     }
  107.   B25 = IRQ3     }
  108.  
  109.   D3 = IRQ10     }
  110.   D4 = IRQ11     }
  111.   D5 = IRQ12     }---- These are all on the "16-bit" Buss connector
  112.   D4 = IRQ15     }
  113.   D5 = IRQ14     }
  114.  
  115.  
  116. Standard AT Buss layout:
  117.  
  118. A1                      A31  C1         C18
  119. ---------------------------  --------------
  120. |                         |  |            |      Front of Motherboard
  121. |                         |  |            |
  122. ---------------------------  --------------
  123. B1                      B31  D1         D18
  124.  
  125. To find out which pin is which, start counting from the back go forward
  126.  
  127.   Now, take a look at that port card that you are planning to modify.  Find
  128. IRQ3 on it and trace the circuit trace.  It will usually go to a jumper block
  129. that is configured something like this:
  130.  
  131.        IRQ3   UART#2
  132.    -------------
  133.    |       . . |
  134.    |       . . |
  135.    -------------
  136.      UART#1   IRQ4
  137.  
  138. And the instructions with the card for configuring it will go something like
  139. this:
  140.  
  141.   Uart1 (com1) to IRQ4  set jumper like this:
  142.  
  143. ----------------
  144. |          . . |
  145. |          --- |
  146. ----------------
  147.  
  148.   Uart1 (com1) to IRQ3 set like this:
  149. ----------------
  150. |          | . |
  151. |          | . |
  152. ----------------
  153.  
  154.   Uart2 (com2) to IRQ4 set like this:
  155.  
  156. ----------------
  157. |          . | |
  158. |          . | |
  159. ----------------
  160.  
  161.   Uart2 (com2) to IRQ3 set like this:
  162.  
  163. ----------------
  164. |          --- |
  165. |          . . |
  166. ----------------
  167.  
  168. These instructions will usually be combined with other jumper settings,
  169. so it may be difficult to see what the card maker is getting at.  Remember,
  170. these cards are CHEAP you aren't getting the red carpet here! :-)  You might
  171. be lucky to get docs at all