"8042" PS/2 Controller: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Brendan (talk | contribs)
m Extra note for status register bit 1
multiple small typo fixes
Line 208: Line 208:
|-
|-
|0xC2
|0xC2
|Copy bits 4 to 6 of input port to status bits 4 to 7
|Copy bits 4 to 7 of input port to status bits 4 to 7
|None
|None
|-
|-
Line 335: Line 335:


==== Step 2: Determine if the PS/2 Controller Exists ====
==== Step 2: Determine if the PS/2 Controller Exists ====
Before you touch the PS/2 controller at all, you should determine if it actually exists. On some systems (e.g. 80x86 Apple machines) it doesn't exist and any attempt to touch it can result in a system crash. The correct way to do this is is with [[ACPI]]. More specifically, check bit 1 (the "8042" flag) in the "IA PC Boot Architecture Flags" field at offset 109 in the Fixed ACPI Description Table (FADT). If this bit is clear then there is no PS/2 Controller to configure. Otherwise, if the bit is set or the system doesn't support ACPI (no ACPI tables and no FADT) then there is a PS/2 Controller.
Before you touch the PS/2 controller at all, you should determine if it actually exists. On some systems (e.g. 80x86 Apple machines) it doesn't exist and any attempt to touch it can result in a system crash. The correct way to do this is is with [[ACPI]]. More specifically, check bit 1 (value = 2, the "8042" flag) in the "IA PC Boot Architecture Flags" field at offset 109 in the Fixed ACPI Description Table (FADT). If this bit is clear then there is no PS/2 Controller to configure. Otherwise, if the bit is set or the system doesn't support ACPI (no ACPI tables and no FADT) then there is a PS/2 Controller.


==== Step 3: Disable Devices ====
==== Step 3: Disable Devices ====
So that any PS/2 devices can't send data at the wrong time and mess up your initialisation; start by sending a command 0xAD and command 0xA7 to the PS/2 controller. If the controller is a "single channel" device will ignore the "command 0xA7".
So that any PS/2 devices can't send data at the wrong time and mess up your initialisation; start by sending a command 0xAD and command 0xA7 to the PS/2 controller. If the controller is a "single channel" device, it will ignore the "command 0xA7".


==== Step 4: Flush The Output Buffer ====
==== Step 4: Flush The Output Buffer ====
Line 353: Line 353:
To test the PS/2 controller, send command 0xAA to it. Then wait for its response and check that it replied with 0x55.
To test the PS/2 controller, send command 0xAA to it. Then wait for its response and check that it replied with 0x55.


==== Step 7: Determine If There's 2 Channels ====
==== Step 7: Determine If There Are 2 Channels ====


If you know it's a single channel controller (from Step 5) then skip this step. Otherwise, send a command 0xA8 to enable the second PS/2 port and read the Controller Configuration Byte again. Now bit 5 of the Controller Configuration Byte should be clear - if it's set then you know it can't be a "dual channel" PS/2 controller (because the second PS/2 port should be enabled). If it is a dual channel device, send a command 0xA9 to disable the second PS/2 port again.
If you know it's a single channel controller (from Step 5) then skip this step. Otherwise, send a command 0xA8 to enable the second PS/2 port and read the Controller Configuration Byte again. Now bit 5 of the Controller Configuration Byte should be clear - if it's set then you know it can't be a "dual channel" PS/2 controller (because the second PS/2 port should be enabled). If it is a dual channel device, send a command 0xA7 to disable the second PS/2 port again.


==== Step 8: Perform Interface Tests ====
==== Step 8: Perform Interface Tests ====