Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
back2root:ibm-pc-ms-dos:hardware:8042 [2022/12/29 15:17] – [Tableau] frater | back2root:ibm-pc-ms-dos:hardware:8042 [2024/08/27 15:38] (Version actuelle) – [Commands System Issues to Keyboard (write port 60h)] frater | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== 8042 - Keyboard Controller | + | ====== 8042 - Keyboard Controller (AT,PS/2) ====== |
- | ===== 8042 Status Register | + | ==== 8042 Commands & Responses - (Port 60h) ==== |
+ | === Commands System Issues to Keyboard (write port 60h) === | ||
+ | {{tablelayout? | ||
+ | ^ Command | ||
+ | | EDh | Set/Reset Mode Indicators, keyboard responds with ACK then waits for a following option byte.\\ When the option byte is received the keyboard again ACK's and then sets the LED's accordingly.\\ Scanning is resumed if scanning was enabled. If another command is received instead of the option byte (high bit set on) this command is terminated. | ||
+ | |7-3|2|1|0| Keyboard Status Indicator Option Byte | ||
+ | | | | `--- Scroll-Lock indicator | ||
+ | | | `---- Num-Lock indicator | ||
+ | | `----- Caps-Lock indicator | ||
+ | `------- reserved (must be zero) </ | ||
+ | | EEh | Diagnostic Echo, keyboard echoes the EE byte back to the system without an acknowledgement. | ||
+ | | F0h | PS/2 Select/Read Alternate Scan Code Sets, instructs keyboard to use one of the three make/break scan code sets.\\ Keyboard responds by clearing the output buffer/ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | F2h | PS/2 Read Keyboard ID, keyboard responds with an ACK and a two byte keyboard ID of 83AB. | | ||
+ | | F3h | Set Typematic Rate/Delay, keyboard responds with ACK and waits for rate/delay byte.\\ Upon receipt of the rate/delay byte the keyboard responds with an ACK, then sets the new typematic values and scanning continues if scanning was enabled.< | ||
+ | | ||
+ | | | | |-+-+-+-+---- typematic rate indicator (see INT 16,3) | ||
+ | | | | | | `------- A in period formula (see below) | ||
+ | | | | `---------- B is period formula (see below) | ||
+ | | `------------- typematic delay | ||
+ | `-------------- always zero | ||
+ | </ | ||
+ | | F4h | Enable Keyboard, cause the keyboard to clear its output buffer and last typematic key and then respond with an ACK. The keyboard then begins scanning. | ||
+ | | F5h | Default w/Disable, resets keyboard to power-on condition by clearing the output buffer, resetting typematic rate/delay, resetting last typematic key and setting default key types.\\ The keyboard responds with an ACK and waits for the next instruction. | ||
+ | | F6h | Set Default, resets to power-on condition by clearing the output buffer, resetting typematic rate/delay and last typematic key and sets default key types.\\ The keyboard responds with an ACK and continues scanning. | ||
+ | | F7h | PS/2 Set All Keys to Typematic, keyboard responds by sending an ACK, clearing its output buffer and setting the key type to Typematic.\\ Scanning continues if scanning was enabled. This command may be sent while using any Scan Code Set but only has effect when Scan Code Set 3 is in use. | | ||
+ | | F8h | PS/2 Set All Keys to Make/Break, keyboard responds by sending an ACK, clearing its output buffer and setting the key type to Make/ | ||
+ | | F9h | PS/2 Set All Keys to Make, keyboard responds by sending an ACK, clearing its output buffer and setting the key type to Make. Scanning continues if scanning was enabled.\\ This command may be sent while using any Scan Code Set but only has effect when Scan Code Set 3 is in use. | | ||
+ | | FAh | PS/2 Set All Keys to Typematic Make/Break, keyboard responds by sending an ACK, clearing its output buffer and setting the key type to Typematic Make/ | ||
+ | | FBh | PS/2 Set Key Type to Typematic, keyboard responds by sending an ACK, clearing its output buffer and then waiting for the key ID (make code from Scan Code Set 3).\\ The specified key type is then set to typematic.This command may be sent while using any Scan Code Set but only has effect when Scan Code Set 3 is in use. | | ||
+ | | FCh | PS/2 Set Key Type to Make/Break, keyboard responds by sending an ACK, clearing its output buffer and then waiting for the key ID (make code from Scan Code Set 3).\\ The specified key type is then set to Make/Break. This command may be sent while using any Scan Code Set but only has effect when Scan Code Set 3 is in use. | | ||
+ | | FDh | PS/2 Set Key Type to Make, keyboard responds by sending an ACK, clearing its output buffer and then waiting for the key ID (make code from Scan Code Set 3).\\ The specified key type is then set to Make.\\ This command may be sent while using any Scan Code Set but only has effect when Scan Code Set 3 is in use. | | ||
+ | | FEh | Resend, should be sent when a transmission error is detected from the keyboard | ||
+ | | FFh | Reset, Keyboard sends ACK and waits for system to receive it then begins a program reset and Basic Assurance Test (BAT). \\ Keyboard returns a one byte completion code then sets default Scan Code Set 2. | | ||
- | ^ bit ^ 8042 Status Register | ||
- | | 0 | output register (60h) has data for system | ||
- | | 1 | input register (60h/64h) has data for 8042 | | ||
- | | 2 | system flag (set to 0 after power on reset) | ||
- | | 3 | data in input register is command (1) or data (0) | | ||
- | | 4 | 1=keyboard enabled\\ 0=keyboard disabled (via switch) | ||
- | | 5 | 1=transmit timeout (data transmit not complete) | ||
- | | 6 | 1=receive timeout (data transmit not complete) | ||
- | | 7 | 1=even parity rec' | ||
- | ^ Port ^ Mode ^ name ^Description^ | + | === Keyboard Responses |
- | | 64h | read | + | |
- | | 64h | write |command register.| Writing this port sets Bit 3 of the status register | + | |
- | | 60h | read | + | |
- | | | + | |
+ | | 00h |Key Detection Error or Overrun Error for Scan Code Set 1, replaces last key in the keyboard buffer if the buffer is full. | | ||
+ | | AAh |BAT Completion Code, keyboard sends this to indicate the keyboard test was successful.| | ||
+ | | EEh |Echo Response, response to the Echo command.| | ||
+ | | F0h | ||
+ | | FAh | ||
+ | | FCh |BAT Failure Code, keyboard sends this to indicate the keyboard test failed and stops scanning until a response or reset is sent.| | ||
+ | | FEh | ||
+ | | FFh |Key Detection Error or Overrun Error for Scan Code Set 2 or 3, replaces last key in the keyboard buffer if the buffer is full.| | ||
+ | | idh | ||
- | ====== 8042 Commands Related to PC Systems | ||
- | ^ Command | + | <WRAP round box> |
- | | 20h | Read Command Byte: current 8042 command byte is placed in port 60h. | | + | command |
- | | 60h | Write 8042 Command Byte: next data byte written to port 60h is placed in 8042 command register. Format (see table 1) | | + | </WRAP> |
- | | A4h | Password Installed Test:\\ returned data can be read from port 60h; | + | |
- | | A5h | Load Security: bytes written to port 60h will be read until a null (0) is found. | + | |
- | | A6h | Enable Security: works only if a password is already loaded | + | |
- | | A7h | Disable Auxiliary Interface: sets Bit 5 of command | + | |
- | | A8h | Enable Auxiliary Interface: clears Bit 5 of command register | + | |
- | | A9h | Auxiliary Interface Test: clock and data lines are tested; results placed at port 60h are listed below\\ 00 no error\\ 01 keyboard clock line is stuck low\\ 02 keyboard clock line is stuck high\\ 03 keyboard data line is stuck low\\ 04 keyboard data line is stuck high | | + | |
- | | AAh | Self Test: diagnostic result placed at port 60h, 55h=OK | + | |
- | | ABh | Keyboard Interface Test:clock and data lines are tested; results placed at port 60h are listed above with command A9h | | + | |
- | | ACh | Diagnostic Dump: sends 16 bytes of 8042' | + | |
- | | ADh | Disable Keyboard Interface: sets Bit 4 of command register stopping keyboard I/O by driving the clock line low | | + | |
- | | AEh | Enable Keyboard Interface: clears Bit 4 of command register enabling keyboard interface. | + | |
- | | C0h | Read Input Port: data is read from its input port (which is inaccessible to the data bus) and written to output register at port 60h; \\ output register should be empty before call. (see Table 2) | | + | |
- | | C1h | Poll Input Port Low Bits: Bits 0-3 of port 1 placed in status Bits 4-7 | | + | |
- | | C2h | Poll Input Port High Bits: Bits 4-7 of port 1 placed in status Bits 4-7 | | + | |
- | | D0h | Read Output Port: data is read from 8042 output port (which is inaccessible to the data bus) and placed in output register; the output register should be empty. (see command D1 below) | + | |
- | | D1h | Write Output Port: next byte written to port 60h is placed in the 8042 output port (which is inaccessible to the data bus) (see Table 3) | | + | |
- | | D2h | Write Keyboard Output Register: on PS/2 systems the next data byte written to port 60h input register is written to port 60h output register as if initiated by a device; invokes interrupt if enabled | + | |
- | | D3h | Write Auxiliary Output Register: on PS/2 systems the next data byte written to port 60h input register is written to port 60h output register as if initiated by a device; invokes interrupt if enabled | + | |
- | | D4h | Write Auxiliary Device: on PS/2 systems the next data byte written to input register a port at 60h is sent to the auxiliary device | + | |
- | | E0h | Read Test Inputs: 8042 reads its T0 and T1 inputs; data is placed in output register; | + | |
- | | Fxh | Pulse Output Port: Bits 0-3 of the 8042 output port can be pulsed low for 6 æs; Bits 0-3 of command indicate which Bits should be pulsed; 0=pulse, 1=don' | + | |
+ | see [[back2root: | ||
- | === Table 1 === | + | ===== 8042 - Speaker Controller & NMI (AT,PS/2) - Port 61h ===== |
- | ^ bit | + | |
- | | 0 | 1=enable output register full interrupt | + | |
- | | 1 | should be 0 | | + | |
- | | | + | |
- | | 3 | 1=override keyboard inhibit\\ 0=allow inhibit | + | |
- | | 4 | disable keyboard I/O by driving clock line low | | + | |
- | | 5 | disable auxiliary device, drives clock line low | | + | |
- | | 6 | IBM scancode translation: | + | |
- | | 7 | reserved, should be 0 | | + | |
+ | This register can be Write and Read | ||
+ | ^ bit ^ Description | ||
+ | | 0 | PIT Channel 2 enabled (see [[back2root: | ||
+ | | 1 | Speaker Position\\ < | ||
+ | | 2 | | | ||
+ | | 3 | | | ||
+ | | 4 | | | ||
+ | | 5 | | | ||
+ | | 6 | | | ||
+ | | 7 | Reset Keyboard status (scan code readed) | ||
+ | === Speaker === | ||
+ | The speaker itself has two possible positions, " | ||
- | - PC systems previous to the AT use the 8255 PPI as a keyboard controller and use the keyboard' | + | This position can be set through bit 1 of port 0x61 on the Keyboard Controller. |
- | | + | |
- | - see | + | If this bit is set (=1), the speaker will move to the " |
+ | |||
+ | Moving in and out repeatedly produces audible tones if the speed of repetition (the frequency) is within the range the speaker can reproduce and the human ear can hear. Also, a single movement in or out makes a click sound because it's so fast. Thus, a frequency which is too low to be heard as a tone may be heard as a rattle or buzz. (In fact, any frequency produced by this system also produces higher frequencies; | ||
+ | ==== 8042 Status Register (port 64h read) ==== | ||
+ | {{tablelayout? | ||
+ | ^ Port ^ Mode | ||
+ | | 60h | ||
+ | | 60h | ||
+ | | 64h | ||
+ | | 64h | ||
+ | |||
+ | ^ bit ^ Port 60h ^ Port 64h ^ 8042 Status Register | ||
+ | | 0 | Y | ||
+ | | 1 | Y | ||
+ | | 2 | Y | ||
+ | | 3 | Y | ||
+ | | 4 | Y | ||
+ | | 5 | Y | ||
+ | | 6 | Y | ||
+ | | 7 | Y | ||
+ | ===== 8042 Commands Related to PC Systems | ||
+ | |||
+ | ^ Command | ||
+ | | 20h | Read Command Byte: current 8042 command byte is placed in port 60h.| | ||
+ | | 60h | Write 8042 Command Byte: next data byte written to port 60h is placed in 8042 command register. Format (see table 1)| | ||
+ | | A4h | Password Installed Test:\\ returned data can be read from port 60h;\\ < | ||
+ | | A5h | Load Security: bytes written to port 60h will be read until a null (0) is found.| | ||
+ | | A6h | Enable Security: works only if a password is already loaded| | ||
+ | | A7h | Disable Auxiliary Interface: sets Bit 5 of command register stopping auxiliary I/O by driving the clock line low| | ||
+ | | A8h | Enable Auxiliary Interface: clears Bit 5 of command register| | ||
+ | | A9h | Auxiliary Interface Test: clock and data lines are tested; results placed at port 60h are listed below\\ < | ||
+ | | AAh | Self Test: diagnostic result placed at port 60h, 55h=OK| | ||
+ | | ABh | Keyboard Interface Test:clock and data lines are tested; results placed at port 60h are listed above with command A9h| | ||
+ | | ACh | Diagnostic Dump: sends 16 bytes of 8042's RAM, current input port state, current output port state and 8042 program status word to port 60h in scan-code format.| | ||
+ | | ADh | Disable Keyboard Interface: sets Bit 4 of command register stopping keyboard I/O by driving the clock line low| | ||
+ | | AEh | Enable Keyboard Interface: clears Bit 4 of command register enabling keyboard interface.| | ||
+ | | C0h | Read Input Port: data is read from its input port (which is inaccessible to the data bus) and written to output register at port 60h; \\ output register should be empty before call. (see Table 2)| | ||
+ | | C1h | Poll Input Port Low Bits: Bits 0-3 of port 1 placed in status Bits 4-7| | ||
+ | | C2h | Poll Input Port High Bits: Bits 4-7 of port 1 placed in status Bits 4-7| | ||
+ | | D0h | Read Output Port: data is read from 8042 output port (which is inaccessible to the data bus) and placed in output register; the output register should be empty. (see command D1 below)| | ||
+ | | D1h | Write Output Port: next byte written to port 60h is placed in the 8042 output port (which is inaccessible to the data bus) (see Table 3)| | ||
+ | | D2h | Write Keyboard Output Register: on PS/2 systems the next data byte written to port 60h input register is written to port 60h output register as if initiated by a device; invokes interrupt if enabled| | ||
+ | | D3h | Write Auxiliary Output Register: on PS/2 systems the next data byte written to port 60h input register is written to port 60h output register as if initiated by a device; invokes interrupt if enabled| | ||
+ | | D4h | Write Auxiliary Device: on PS/2 systems the next data byte written to input register a port at 60h is sent to the auxiliary device| | ||
+ | | E0h | Read Test Inputs: 8042 reads its T0 and T1 inputs; data is placed in output register; | ||
+ | | Fxh | Pulse Output Port: Bits 0-3 of the 8042 output port can be pulsed low for 6 æs; Bits 0-3 of command indicate which Bits should be pulsed; 0=pulse, 1=don' | ||
+ | |||
+ | == Table 1 == | ||
+ | ^ bit ^ 8042 Command Byte ^ | ||
+ | | 0 | 1=enable output register full interrupt | ||
+ | | 1 | should be 0 | | ||
+ | | 2 | 1=set status register system\\ 0=clear | ||
+ | | 3 | 1=override keyboard inhibit\\ 0=allow inhibit | ||
+ | | 4 | disable keyboard I/O by driving clock line low | | ||
+ | | 5 | disable auxiliary device, drives clock line low | | ||
+ | | 6 | IBM scancode translation: | ||
+ | | 7 | reserved, should be 0 | | ||
+ | |||
+ | == Table 2 == | ||
+ | ^ bit ^ 8042 Input Port ^ | ||
+ | | 0-3 | undefined | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |||
+ | == Table 3 == | ||
+ | ^ bit ^ 8042 Output Port^ | ||
+ | | | ||
+ | | | ||
+ | | 2-3 | undefined| | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |||
+ | == Table 4 == | ||
+ | ^ bit ^ Test Input Port Bits ^ | ||
+ | | 0 | keyboard clock | | ||
+ | | 1 | keyboard data | | ||
+ | |||
+ | <WRAP round box> | ||
+ | PC systems previous to the AT use the [[back2root: | ||
+ | |||
+ | the keyboard' | ||
+ | </WRAP> | ||
+ | |||
+ | see KEYBOARD COMMANDS for information on programming the keyboards internal microprocessor | ||