PDA

View Full Version : IBM PC XT/AT keyboard controller ports question



vladstamate
May 21st, 2015, 10:10 PM
Hi all,

Looking at bochs port list here (http://bochs.sourceforge.net/techspec/PORTS.LST) and watching what the BIOS for the IBM PC AT is doing I cannot see them matching, so I need a bit of help.

This is a part of the BIOS where I think it is detecting the equipment list. This output is from execution of the 1982 IBM PC AT BIOS on my emulator.

fe204 e4 IN 0x62, AL
fe206 24 AND AL, 0xf
fe208 8a MOV AH, AL
fe20a b0 MOV AL, 0xad
fe20c e6 OUT 0x61, AL
fe20e 90 NOP
fe20f e4 IN 0x62, AL
fe211 b1 MOV CL, 0x4
fe213 d2 ROL AL, CL
fe215 24 AND AL, 0xf0
fe217 a OR AL, AH
fe219 2a SUB AH, AH
fe21b a3 MOV [0x410], AX ; 0x40:0x10 is the equipment byte in the bios data area.

So my question is how is the BIOS using port 61 and 62? What does outputting 0xAD to port 61 mean? It also seems reading 62 twice can give different results (which are later OR'ed) so it makes me think 0xAD is a command. But I am confused as that is not what bochs is really saying it is happening.

Thanks,
Vlad.

modem7
May 22nd, 2015, 04:17 AM
This output is from execution of the 1982 IBM PC AT BIOS ..
Why does that sentence include "AT"? The code that you have posted is from an IBM PC.


But I am confused as that is not what bochs is really saying it is happening.
In my opinion, IBM's documention will be more helpful to you. There are port maps and BIOS listings in it.

In an IBM PC, ports 60h/61h/62h correspond to ports A/B/C on the 8255 PPI chip.
That information and the bit breakdown is in the IBM technical reference; see page 2-24 of the manual [here (http://www.minuszerodegrees.net/manuals/IBM_5150_Technical_Reference_6025005_AUG81.pdf)].

In summary, the code you have posted is reading the setting of the five switches that are used in the SW2 switch block, then placing the result into the BIOS data area.

Why two reads of 62h? Due to the way the motherboard is wired, complete inspection of SW2 cannot be done as one read of port 62h:

1. Set bit 2 of port 61h high. The result is that any read of port 62h will return switches 1 to 4 of SW2 in the lower nibble.
2. Read port 62h (to get switches 1 to 4 of SW2).
3. Set bit 2 of port 61h low. The result is that any read of port 62h will return switch 5 of SW2 in bit 0.
4. Read port 62h (to get switch 5 of SW2).

vladstamate
May 22nd, 2015, 05:10 AM
Why does that sentence include "AT"? The code that you have posted is from an IBM PC.

I apologize, confusing. Yes the code is from IBM PC.


In my opinion, IBM's documention will be more helpful to you. There are port maps and BIOS listings in it.

In an IBM PC, ports 60h/61h/62h correspond to ports A/B/C on the 8255 PPI chip.
That information and the bit breakdown is in the IBM technical reference; see page 2-24 of the manual [here (http://www.minuszerodegrees.net/manuals/IBM_5150_Technical_Reference_6025005_AUG81.pdf)].

In summary, the code you have posted is reading the setting of the five switches that are used in the SW2 switch block, then placing the result into the BIOS data area.

Why two reads of 62h? Due to the way the motherboard is wired, complete inspection of SW2 cannot be done as one read of port 62h:

1. Set bit 2 of port 61h high. The result is that any read of port 62h will return switches 1 to 4 of SW2 in the lower nibble.
2. Read port 62h (to get switches 1 to 4 of SW2).
3. Set bit 2 of port 61h low. The result is that any read of port 62h will return switch 5 of SW2 in bit 0.
4. Read port 62h (to get switch 5 of SW2).

That is exactly what I was looking for, thank you!

Regards,
Vlad.