<s>
In	O
computing	O
,	O
a	O
keyboard	B-Device
controller	I-Device
is	O
a	O
device	O
that	O
interfaces	O
a	O
keyboard	B-Device
to	O
a	O
computer	O
.	O
</s>
<s>
When	O
data	O
from	O
the	O
keyboard	B-Device
arrives	O
,	O
the	O
controller	O
raises	O
an	O
interrupt	B-Application
(	O
a	O
keyboard	B-Device
interrupt	B-Application
)	O
to	O
allow	O
the	O
CPU	B-General_Concept
to	O
handle	O
the	O
input	O
.	O
</s>
<s>
If	O
a	O
keyboard	B-Device
is	O
a	O
separate	O
peripheral	B-Device
system	B-General_Concept
unit	I-General_Concept
(	O
such	O
as	O
in	O
most	O
modern	O
desktop	B-Device
computers	I-Device
)	O
,	O
the	O
keyboard	B-Device
controller	I-Device
is	O
not	O
directly	O
attached	O
to	O
the	O
keys	O
but	O
receives	O
scancodes	O
from	O
a	O
microcontroller	B-Architecture
embedded	O
in	O
the	O
keyboard	B-Device
via	O
some	O
kind	O
of	O
serial	B-Protocol
interface	I-Protocol
.	O
</s>
<s>
In	O
this	O
case	O
,	O
the	O
controller	O
usually	O
also	O
controls	O
the	O
keyboard	B-Device
's	O
LEDs	O
by	O
sending	O
data	O
back	O
to	O
the	O
keyboard	B-Device
through	O
the	O
wire	O
.	O
</s>
<s>
In	O
the	O
80s	O
the	O
IBM	B-Operating_System
PC	I-Operating_System
AT	I-Operating_System
used	O
an	O
Intel	B-Device
8042	I-Device
chip	O
to	O
interface	O
to	O
the	O
keyboard	B-Device
.	O
</s>
<s>
This	O
computer	O
also	O
controlled	O
access	O
to	O
the	O
A20	B-Device
line	I-Device
in	O
order	O
to	O
implement	O
a	O
workaround	O
for	O
a	O
chip	O
bug	O
in	O
the	O
Intel	B-General_Concept
80286	I-General_Concept
.	O
</s>
<s>
The	O
keyboard	B-Device
controller	I-Device
was	O
also	O
used	O
to	O
initiate	O
a	O
software	O
CPU	B-General_Concept
reset	O
in	O
order	O
to	O
allow	O
the	O
CPU	B-General_Concept
to	O
transition	O
from	O
protected	B-Application
mode	I-Application
to	O
real	B-Application
mode	I-Application
because	O
the	O
286	B-General_Concept
did	O
not	O
allow	O
the	O
CPU	B-General_Concept
to	O
go	O
from	O
protected	B-Application
mode	I-Application
to	O
real	B-Application
mode	I-Application
unless	O
the	O
CPU	B-General_Concept
is	O
reset	O
.	O
</s>
<s>
This	O
was	O
a	O
problem	O
because	O
the	O
BIOS	B-Operating_System
and	O
the	O
operating	O
system	O
services	O
could	O
only	O
be	O
called	O
by	O
programs	O
in	O
real	B-Application
mode	I-Application
.	O
</s>
<s>
These	O
behaviors	O
have	O
been	O
used	O
by	O
plenty	O
of	O
software	O
that	O
expects	O
this	O
behavior	O
,	O
and	O
therefore	O
keyboard	B-Device
controllers	I-Device
have	O
continued	O
controlling	O
the	O
A20	B-Device
line	I-Device
and	O
performing	O
software	O
CPU	B-General_Concept
interrupts	I-General_Concept
even	O
when	O
the	O
need	O
for	O
a	O
reset	O
via	O
the	O
keyboard	B-Device
controller	I-Device
was	O
obviated	O
by	O
the	O
Intel	B-General_Concept
80386	I-General_Concept
's	O
ability	O
to	O
switch	O
to	O
real	B-Application
mode	I-Application
from	O
protected	B-Application
mode	I-Application
without	O
a	O
CPU	B-General_Concept
reset	O
.	O
</s>
<s>
The	O
keyboard	B-Device
controller	I-Device
also	O
handles	O
PS/2	B-Protocol
mouse	I-Protocol
input	O
if	O
a	O
PS/2	B-Protocol
mouse	I-Protocol
port	O
is	O
present	O
.	O
</s>
<s>
Today	O
the	O
keyboard	B-Device
controller	I-Device
is	O
either	O
a	O
unit	O
inside	O
a	O
super	B-Device
I/O	I-Device
device	O
or	O
is	O
missing	O
,	O
having	O
the	O
keyboard	B-Device
controller	I-Device
integrated	O
in	O
the	O
USB	O
keyboard	B-Device
itself	O
,	O
and	O
its	O
role	O
in	O
controlling	O
the	O
A20	B-Device
line	I-Device
handled	O
by	O
the	O
chipset	O
.	O
</s>
<s>
IBM	O
plays	O
a	O
small	O
role	O
in	O
the	O
creation	O
of	O
the	O
keyboard	B-Device
controller	I-Device
.	O
</s>
<s>
With	O
the	O
IBM	O
compatible	O
computers	O
,	O
the	O
keyboard	B-Device
controller	I-Device
or	O
Intel	B-Device
8042	I-Device
keyboard	B-Device
controller	I-Device
is	O
found	O
on	O
the	O
motherboard	B-Device
.	O
</s>
<s>
The	O
controller	O
handles	O
input	O
received	O
from	O
the	O
computer	B-Device
keyboard	I-Device
,	O
A20	B-Device
lines	I-Device
,	O
reset	O
,	O
deciphering	O
scan	O
codes	O
,	O
as	O
well	O
as	O
the	O
PS/2	B-Protocol
mouse	I-Protocol
.	O
</s>
<s>
With	O
later	O
models	O
of	O
keyboards	B-Device
,	O
the	O
8042	B-Device
was	O
replaced	O
with	O
the	O
8742	B-Device
micro-controller	B-Architecture
,	O
which	O
had	O
a	O
microprocessor	O
,	O
RAM	O
,	O
and	O
I/O	O
ports	O
.	O
</s>
<s>
Anyone	O
trying	O
to	O
use	O
the	O
classic	O
8042-style	O
keyboard	B-Device
controller	I-Device
(	O
KBC	O
)	O
found	O
in	O
the	O
IBM	B-Operating_System
PC/AT	I-Operating_System
and	O
nearly	O
all	O
later	O
PCs	O
typically	O
runs	O
into	O
a	O
problem	O
with	O
a	O
lack	O
of	O
accurate	O
documentation	O
.	O
</s>
<s>
The	O
8042	B-Device
(	O
or	O
8742	B-Device
,	O
or	O
any	O
number	O
of	O
compatible	O
parts	O
built	O
into	O
later	O
Super	B-Device
I/O	I-Device
chips	O
)	O
is	O
actually	O
quite	O
well	O
documented	O
.	O
</s>
<s>
The	O
catch	O
is	O
that	O
the	O
8042	B-Device
is	O
a	O
programmable	O
micro-controller	B-Architecture
with	O
its	O
own	O
control	O
software	O
in	O
(	O
usually	O
)	O
ROM	O
.	O
</s>
<s>
It	O
should	O
be	O
understood	O
that	O
all	O
those	O
commands	O
are	O
a	O
pure	O
software	O
construct	O
,	O
with	O
nothing	O
about	O
the	O
8042	B-Device
hardware	O
dictating	O
that	O
the	O
commands	O
need	O
to	O
follow	O
any	O
specific	O
format	O
,	O
function	O
,	O
or	O
that	O
they	O
even	O
need	O
to	O
be	O
there	O
at	B-Device
all	O
.	O
</s>
<s>
Therefore	O
,	O
understanding	O
the	O
8042	B-Device
ROM	O
code	O
is	O
the	O
only	O
way	O
towards	O
understanding	O
exactly	O
what	O
the	O
commands	O
are	O
and	O
what	O
they	O
do	O
,	O
with	O
the	O
caveat	O
that	O
different	O
controllers	O
may	O
and	O
do	O
have	O
somewhat	O
different	O
code	O
in	O
their	O
ROM	O
.	O
</s>
<s>
20h	O
–	O
3Fh	O
:	O
Read	O
KBC	O
RAM	O
at	B-Device
offset	O
20h-3Fh	O
.	O
</s>
<s>
60h	O
–	O
7Fh	O
:	O
Write	O
KBC	O
RAM	O
at	B-Device
offset	O
20h-3Fh	O
.	O
</s>
<s>
The	O
byte	O
at	B-Device
offset	O
20h	O
is	O
the	O
command	O
byte	O
and	O
is	O
treated	O
specially	O
.	O
</s>
<s>
ADh	O
:	O
Disable	O
keyboard	B-Device
.	O
</s>
<s>
AEh	O
:	O
Enable	O
keyboard	B-Device
.	O
</s>
<s>
A	O
portable	O
computing	O
device	O
comprising:a	O
keyboard	B-Device
controller	I-Device
having	O
a	O
first	O
input	O
for	O
receiving	O
keystroke	O
inputs	O
and	O
having	O
an	O
output	O
for	O
conveying	O
said	O
keystroke	O
inputs	O
to	O
a	O
main	O
processor	O
;	O
and	O
a	O
secondary	O
processor	O
having	O
an	O
interface	O
to	O
said	O
keyboard	B-Device
controller	I-Device
through	O
a	O
secondary	O
bus	O
,	O
said	O
secondary	O
bus	O
also	O
being	O
used	O
to	O
communicate	O
with	O
a	O
battery	O
module	O
,	O
wherein	O
said	O
keyboard	B-Device
controller	I-Device
also	O
conveys	O
said	O
keystroke	O
inputs	O
to	O
said	O
secondary	O
processor	O
through	O
said	O
secondary	O
bus	O
.	O
</s>
<s>
The	O
keyboard	B-Device
controller	I-Device
is	O
programmed	O
to	O
support	O
the	O
IBM®	O
compatible	O
personal	O
computer	B-Device
keyboard	I-Device
serial	B-Protocol
interface	I-Protocol
.	O
</s>
<s>
The	O
keyboard	B-Device
controller	I-Device
receives	O
serial	O
data	O
from	O
the	O
keyboard	B-Device
,	O
checks	O
the	O
parity	O
of	O
the	O
data	O
,	O
translates	O
the	O
scan	O
code	O
,	O
and	O
presents	O
the	O
data	O
to	O
the	O
system	O
as	O
a	O
byte	O
of	O
data	O
in	O
its	O
output	O
buffer	O
.	O
</s>
<s>
The	O
controller	O
will	O
interrupt	B-Application
the	O
system	O
when	O
data	O
is	O
placed	O
in	O
its	O
output	O
buffer	O
.	O
</s>
<s>
The	O
byte	O
of	O
data	O
will	O
be	O
sent	O
to	O
the	O
keyboard	B-Device
serially	O
with	O
an	O
odd	O
parity	O
bit	O
automatically	O
inserted	O
.	O
</s>
<s>
The	O
keyboard	B-Device
is	O
required	O
to	O
acknowledge	O
all	O
data	O
transmissions	O
.	O
</s>
<s>
No	O
transmission	O
should	O
be	O
sent	O
to	O
the	O
keyboard	B-Device
until	O
acknowledgment	O
is	O
received	O
for	O
the	O
previous	O
byte	O
sent	O
.	O
</s>
<s>
The	O
keyboard	B-Device
controller	I-Device
and	O
BIOS	B-Operating_System
to	O
improve	O
the	O
performance	O
of	O
IBM	O
PC	O
machines	O
and	O
their	O
compatibles	O
.	O
</s>
<s>
A	O
hardwired	O
methodology	O
is	O
used	O
in	O
this	O
keyboard	B-Device
controller	I-Device
instead	O
of	O
a	O
software	O
implementation	O
,	O
as	O
in	O
the	O
traditional	O
8042	B-Device
keyboard	B-Device
BIOS	B-Operating_System
.	O
</s>
<s>
This	O
enables	O
the	O
keyboard	B-Device
controller	I-Device
to	O
respond	O
instantly	O
to	O
all	O
commands	O
sent	O
from	O
the	O
keyboard	B-Device
to	O
the	O
CPU	B-General_Concept
BIOS	B-Operating_System
.	O
</s>
