[comp.sys.ibm.pc] COM ports - I am still confused!!!

brand@janus.uucp (Graham Brand) (06/16/89)

In article <2073@iesd.dk> kjeld@iesd.dk (Kjeld Flarup) writes:
>I have noted some questions concerning interrupts and COM ports.
>First there is a reply to Dave Vasko:
>		PORT    ADDRESS      INTERRUPT 
>		COM1	3F8-3FF      IRQ4
>		COM2	2F8-2FF      IRQ3
>		COM3    2F0-2F7      IRQ4 ( or IRQ2 )
>		COM4    3F0-3F7      IRQ3 ( or IRQ5 )
>
>I think. because noone seems to know for sure.
   ^^^^^

	Thanks for the useful information, assuming that it is correct! 
However, previous responses have left me a little confused, I must 
admit. For example, I have seen the following references to port 
addresses:

(foss@iris.ucdavis.edu)
3E8 for COM3
2E8 for COM4

(simon@ms.uky.edu)
0040:0000 for COM1
0040:0002 for COM2
0040:0004 for COM3
0040:0006 for COM4

These seem different to me! Would someone please enlighten me?

Cheers,
-Graham Brand (brand@janus.berkeley.edu or ..!ucbvax!ucbjanus!brand)

philba@microsoft.UUCP (Phil Barrett) (06/16/89)

>
>(foss@iris.ucdavis.edu)
>3E8 for COM3
>2E8 for COM4
>
>(simon@ms.uky.edu)
>0040:0000 for COM1
>0040:0002 for COM2
>0040:0004 for COM3
>0040:0006 for COM4
>
>These seem different to me! Would someone please enlighten me?
>

the reason for the confusion is that the comm I/O port addresses are
specific to the HW manufacturer.  The second answer (from simon@ms.uky.edu)
is correct.  The actual comm I/O port base address can be found at the
addresses 40:0, 40:2, 40:4 and 40:6 for com1 through com4, respectively.
This isn't a function of DOS but of the BIOS (and some drivers).  This
scheme makes it easy for an application that directly manipulates the comm
device to be configuration independent.  

The printer ports are handled via similar scheme (lpt1 @ 40:8, lpt2 @ 40:A,
lpt3 @ 40:C and lpt4 @ 40:E).

Of course, I am solely responsible for the content of this message.

phil barrett
microsoft

rkl@cbnewsh.ATT.COM (kevin.laux) (06/16/89)

In article <29697@ucbvax.BERKELEY.EDU>, brand@janus.uucp (Graham Brand) writes:
| In article <2073@iesd.dk> kjeld@iesd.dk (Kjeld Flarup) writes:
| >I have noted some questions concerning interrupts and COM ports.
| >First there is a reply to Dave Vasko:
| >		PORT    ADDRESS      INTERRUPT 
| >		COM1	3F8-3FF      IRQ4
| >		COM2	2F8-2FF      IRQ3
| >		COM3    2F0-2F7      IRQ4 ( or IRQ2 )
| >		COM4    3F0-3F7      IRQ3 ( or IRQ5 )
| >
| >I think. because noone seems to know for sure.
|    ^^^^^
| 
| 	Thanks for the useful information, assuming that it is correct! 
| However, previous responses have left me a little confused, I must 
| admit. For example, I have seen the following references to port 
| addresses:
| 
| (foss@iris.ucdavis.edu)
| 3E8 for COM3
| 2E8 for COM4

	This is manufacturer dependent.  Some serial ports cards use 2F0 and
3F0; others use 3E8 and 2E8.  3E8 and 2E8 are the more standard.

| (simon@ms.uky.edu)
| 0040:0000 for COM1
| 0040:0002 for COM2
| 0040:0004 for COM3
| 0040:0006 for COM4
| 
| These seem different to me! Would someone please enlighten me?

	0040:0000..0040:0006 are memory locations in the BIOS data area.
They contain the I/O Port base addresses for the COM ports.  If you wish
the system to be aware of COM3 and COM4, you must stuff the I/O port
addresses into the locations yourself.  Also you must set bits 9-11 in the
2-byte word at 0040:0010 (equipment-list word) to the number of COM ports.

--rkl

pete@octopus.UUCP (Pete Holzmann) (06/21/89)

In article <6049@microsoft.UUCP> philba@microsoft.UUCP (Phil Barrett) writes:
>>(simon@ms.uky.edu)
>>0040:0000 for COM1
>>...
>The actual comm I/O port base address can be found at the
>addresses 40:0, 40:2, 40:4 and 40:6 for com1 through com4, respectively.
>This isn't a function of DOS but of the BIOS (and some drivers).  This
>scheme makes it easy for an application that directly manipulates the comm
>device to be configuration independent.  
>
>The printer ports are handled via similar scheme (lpt1 @ 40:8, lpt2 @ 40:A,
>lpt3 @ 40:C and lpt4 @ 40:E).

Unfortunately, while the above answer is correct regarding LPT ports, it
is WRONG for COM ports. 

More specifically: LPT1 can be any of several I/O ports, depending on which
hardware you have. DOS checks for 3 standard LPT addresses (3BC, 278 and
378, in that order), and fills in a table starting at 40:8 with whichever
ports it finds. The port listed at 40:8 is LPT1, *always*. I.e., if you have
278 only, that will be LPT1. If you have 3BC and 278, 3BC will be LPT1. And
so on.

DOS checks for the normal COM1/COM2 addresses (2F8, 3F8) and fills in a table
at 40:0. This is fine, but by universal common convention, the table is
is not used to determine the address of COM1. COM1 is 3F8, COM2 is 2F8. There
are a few software packages out there that try to "follow the rules" and
use whatever is at 40:0 for COM1, etc. These packages are a pain in the
neck for support people. It works fine as long as you have 1 com port set up
as COM1, or two ports set up as COM1 and COM2. But if somebody has 1 com port
set up as COM2, some software will simply choke. Too bad.

-- 
Peter Holzmann, Octopus Enterprises   |(if you're a techie Christian & are
19611 La Mar Ct., Cupertino, CA 95014 |interested in helping w/ the Great
UUCP: {hpda,pyramid}!octopus!pete     |Commission, email dsa-contact@octopus)
DSA office ans mach=408/996-7746;Work (SLP) voice=408/985-7400,FAX=408/985-0859

vail@tegra.UUCP (Johnathan Vail) (06/23/89)

In article <645@octopus.UUCP> pete@octopus.UUCP (Pete Holzmann) writes:

   More specifically: LPT1 can be any of several I/O ports, depending on which
   hardware you have. DOS checks for 3 standard LPT addresses (3BC, 278 and
                      ^^^
   378, in that order), and fills in a table starting at 40:8 with whichever

   DOS checks for the normal COM1/COM2 addresses (2F8, 3F8) and fills in a table
   ^^^
   at 40:0. This is fine, but by universal common convention, the table is

Is it really DOS that does this or BIOS?  Memory at segment 40 is the
BIOS data area and I was wondering if DOS is the one that mormally
goes in and sets this up (of course I am sure that it can and does on
occasion but is this supposed to be true?).

.         /|/|
  _______/ | |
    ( )  \ | |
          \|\|
 _____
|     | Johnathan Vail | tegra!N1DXG@ulowell.edu
|Tegra| (508) 663-7435 | N1DXG@145.110-,145.270-,444.2+,448.625-
 -----

lance@helios (Lance Bresee) (07/23/89)

If you buy a serial card, sometimes called an AT IO card,
they consider com3 to be 03e8h to 03efh and com4 to be
02e8h and 02efh.  The only two interrupt lines provided on most
are irq3 and irq4. these are the lines for com1 and com2, so
interrupt driven software will conflict unless you turn off
the interrupts for one or more ports.  The numerical segment-
offset addresses you list probably refer to AT interrupt vector
addresses in the BIOS data area...i don't know why you would want those..
see the IBM XT or AT technical reference for a look at the 8250 uuart
and hoh it is programmed                  
GOOD LUCK