Chapter 5 Input/Output Interfaces
5-18 Compaq iPAQ Family of Internet Devices
First Edition March 2000
5.6.3.2 8042 Control
The BIOS function INT 16 is typically used for controlling interaction with the keyboard. Sub-
functions of INT 16 conduct the basic routines of handling keyboard data (i.e., translating the
keyboards scan codes into ASCII codes). The keyboard/pointing device interface is accessed by
the CPU through I/O mapped ports 60h and 64h, which provide the following functions:
Output buffer reads
Input buffer writes
Status reads
Command writes
Ports 60h an d 64h can be accessed usin g the IN instru ction for a read an d the OUT instruct ion
for a write. Prior to reading data from port 60h, the Output Buffer Full status bit (64h, bit <0>)
should be checked to ensure data is available. Likewise, before writing a command or data, the
Input Buffer Empty status bit (64h, bit <1>) should also be ch ecked to ensure space is
available.
I/O Port 60h
I/O port 60h is used for accessing the input and output buffers. This register is used to send and
receive data from t he keyboard and the poi nting device. Th is register is als o used to send the
second byte of multi-byte commands to the 8042 and to receive responses from th e 8042 for
commands that require a response.
A read of 60h by the CPU yields the byte held in the output buffer. The output buffer holds data
that has been received from the keyboard an d is to be transferr ed to the system.
A CPU write to 60h places a data byte in the input byte buffer and sets the CMD/ DATA bit of
the Status register to DATA. The input buffer is used for transferring data from the system to the
keyboard. All data written to this port by the CPU will be transferred to the keyboard except
bytes that follow a multibyte command that was written to 64h
I/O Port 64h
I/O port 64h is used for reading the status register and for writing commands. A read of 64h by
the CPU will yield the status byte defined as follows:
Bit Function
7..4 General Purpose Flags.
3 C MD/DATA Flag (reflects the state of A2 during a CPU write).
0 = Data
1 = Command
2 G eneral Purpose Flag.
1 Input B uffer Full. Set (to 1) upon a CPU write. Cleared by
IN A, DBB instruction.
0 O utput Buffer Full (if set). Cleared by a CPU read of the buffer.
A CPU write to I/O port 64h places a command value into the input buffer and sets the
CMD/DATA bit of the status register (bit <3>) to CMD.