⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driver-keyboard_2.htm

📁 编写自己的操作系统
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0060)http://www.huihoo.com/gnu_linux/own_os/driver-keyboard_2.htm -->
<HTML xmlns:o = "urn:schemas-microsoft-com:office:office"><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT 
face="Times New Roman" size=6><SPAN style="mso-tab-count: 1"><STRONG>4.2 
Keyboard</STRONG></SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT 
face="Times New Roman" size=6><SPAN style="mso-tab-count: 1"><FONT 
size=3></FONT></SPAN></FONT></SPAN>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT 
face="Times New Roman" size=6><SPAN style="mso-tab-count: 1"><FONT 
size=3>[</FONT><A href="index.htm" 
tppabs="http://pagoda-ooos.51.net/os_book/index.htm"><FONT 
size=3>Home</FONT></A><FONT size=3>]&nbsp; [</FONT><A 
href="driver.htm" 
tppabs="http://pagoda-ooos.51.net/os_book/driver.htm"><FONT 
size=3>Top</FONT></A><FONT size=3>]&nbsp; [</FONT><FONT 
size=3>Previous</FONT><FONT size=3>]&nbsp; [</FONT><FONT size=3>Next</FONT><FONT 
size=3>]</FONT></SPAN></FONT></SPAN><SPAN lang=EN-US><FONT 
face="Times New Roman" size=5><SPAN 
style="mso-tab-count: 1"><STRONG></STRONG></SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT 
face="Times New Roman" size=5><SPAN style="mso-tab-count: 1"><STRONG>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">
<HR width="100%" SIZE=2>

<P></P>
<P></P></STRONG></SPAN></FONT></SPAN><SPAN lang=EN-US><FONT 
face="Times New Roman TUR"><SPAN style="mso-tab-count: 1">
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
lang=EN-US><FONT face="Times New Roman" size=5><STRONG>4.2.1 
Overview</STRONG></FONT></SPAN></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
lang=EN-US><FONT face="Times New Roman" size=4><FONT face="Times New Roman CE" 
size=3><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></FONT>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT 
face="Times New Roman TUR" size=3>键盘是计算机系统的重要输入设备,所有的IBM 
PC及其兼容机都有一个键盘。所以键盘驱动是一个面向IBM PC机OS的必不可少的部分。</FONT></SPAN></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman TUR" 
size=3><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></SPAN></SPAN></FONT>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT 
face="Times New Roman TUR" 
size=3>当IBM从1981年开始,每次推出其新的PC机架构,同时也推出其新的键盘设计——最早的“IBM PC”,到稍后的“IBM 
XT”,所使用的键盘被称作"XT Keyboard",现在这种键盘已经完全过时,我们现在写键盘驱动程序时可以完全不用考虑它。随后1984年IBM推出了“IBM 
AT”,它所使用的键盘被称作“AT Keyboard”;1987年IBM推出的“IBM PS/2”使用的键盘被称作“PS/2 Keyboard”。“AT 
Keyboard”和“PS/2 Keyboard”大同小异,被称作IBM兼容键盘,所有的现代IBM 
PC/兼容机都支持他,它的接口相对简单,是本部分内容的重点。而当今最新的PC上都支持USB接口的键盘,但他的接口相对复杂的多,并且也不向后兼容,所以本部分内容不涉及它。</FONT></SPAN></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=""><FONT size=2><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></SPAN></SPAN></FONT></FONT>&nbsp;</P><FONT 
face=""><FONT size=2><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
<HR width="100%" SIZE=2>

<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><STRONG><FONT 
face="Times New Roman" size=5></FONT></STRONG>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT 
face="Times New Roman TUR"><SPAN style="mso-tab-count: 1"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
lang=EN-US><FONT face="Times New Roman" size=5><STRONG>4.2.2 
History</STRONG></FONT></SPAN></SPAN></SPAN></FONT></SPAN></P><SPAN 
lang=EN-US><FONT face="Times New Roman TUR"><SPAN style="mso-tab-count: 1"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
lang=EN-US><FONT face="Times New Roman" size=5>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=""><FONT size=2><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></SPAN></SPAN></FONT></FONT>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman TUR" 
size=3><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">IBM从1981年发布它的第一款个人计算机“IBM 
PC”以来,它所使用的键盘也在不断的更新。如下表所示:</SPAN></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman TUR" 
size=3><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></SPAN></SPAN></FONT>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=1>
  <TBODY>
  <TR>
    <TD><STRONG><FONT face="Times New Roman TUR">机型</FONT></STRONG></TD>
    <TD><STRONG><FONT face="Times New Roman TUR">IBM PC/XT</FONT></STRONG></TD>
    <TD><STRONG><FONT face="Times New Roman TUR">IBM AT</FONT></STRONG></TD>
    <TD><STRONG><FONT face="Times New Roman TUR">IBM 
PS/2</FONT></STRONG></TD></TR>
  <TR>
    <TD><STRONG><FONT face="Times New Roman TUR">发布年份</FONT></STRONG></TD>
    <TD><FONT face="Times New Roman TUR">1981</FONT></TD>
    <TD><FONT face="Times New Roman TUR">1984</FONT></TD>
    <TD><FONT face="Times New Roman TUR">1987</FONT></TD></TR>
  <TR>
    <TD><STRONG><FONT face="Times New Roman TUR">按键数</FONT></STRONG></TD>
    <TD><FONT face="Times New Roman TUR">81</FONT></TD>
    <TD><FONT face="Times New Roman TUR">83-101</FONT></TD>
    <TD><FONT face="Times New Roman TUR">83-101</FONT></TD></TR>
  <TR>
    <TD><STRONG><FONT face="Times New Roman TUR">串行协议</FONT></STRONG></TD>
    <TD><FONT face="Times New Roman TUR">单向</FONT></TD>
    <TD><FONT face="Times New Roman TUR">双向</FONT></TD>
    <TD><FONT face="Times New Roman TUR">双向</FONT></TD></TR>
  <TR>
    <TD><STRONG><FONT face="Times New Roman TUR">Scan code 
    set</FONT></STRONG></TD>
    <TD><FONT face="Times New Roman TUR">1</FONT></TD>
    <TD><FONT face="Times New Roman TUR">2</FONT></TD>
    <TD><FONT face="Times New Roman TUR">2(增加了可选的Scan code set 3)</FONT></TD></TR>
  <TR>
    <TD><STRONG><FONT face="Times New Roman TUR">接口芯片</FONT></STRONG></TD>
    <TD><FONT face="Times New Roman TUR">8255</FONT></TD>
    <TD><FONT face="Times New Roman TUR">8042</FONT></TD>
    <TD><FONT face="Times New Roman TUR">8042</FONT></TD></TR>
  <TR>
    <TD><STRONG><FONT face="Times New Roman TUR">主机到键盘的命令数</FONT></STRONG></TD>
    <TD><FONT face="Times New Roman TUR">无</FONT></TD>
    <TD><FONT face="Times New Roman TUR">8</FONT></TD>
    <TD><FONT 
face="Times New Roman TUR">17</FONT></TD></TR></TBODY></TABLE></SPAN></SPAN></SPAN></P>
<P><FONT face="Times New Roman TUR" size=3>"PS/2 Keyboard"最初只是对“AT 
Keyboard”作了一些扩展,它完全兼容“AT Keyboard”。但对于数量众多的键盘生产商来说,他们所生产的键盘并非完全遵照"PS/2 
Keyboard"或“AT 
Keyboard”的标准,而是只需要做到对它们兼容即可。比如,某些使用PS/2接口的键盘却只实现了7个主要的“主机到键盘的命令”,对于剩下了10个只是简单的回馈ACK。而某些使用AT接口的键盘却完全实现了“PS/2 
Keyboard”的17个命令。所以,你所拥有的键盘即使是IBM兼容键盘,而未必会完全实现了标准所规定的所有功能。</FONT></P>
<P><FONT face="Times New Roman TUR" size=3>所以,现在的IBM兼容键盘有如下特征:</FONT></P>
<UL>
  <LI><FONT face="Times New Roman TUR" size=3>任意数量的按键(通常是101到104); </FONT>
  <LI><FONT face="Times New Roman TUR" size=3>双向串行协议; </FONT>
  <LI><FONT face="Times New Roman TUR" size=3>仅仅保证支持Scan code set 2; </FONT>
  <LI><FONT face="Times New Roman TUR" size=3>接口芯片可能不是8042,但保证都和8042兼容。 </FONT>
  <LI><FONT face="Times New Roman TUR" 
  size=3>对所有的17个命令都会回复“ACK”,但未必会完全实现它们。</FONT></LI></UL>
<P><FONT face="Times New Roman TUR" size=3>“XT 
Keyboard”使用的协议和“AT-PS/2 Keyboard”完全不同,所以它们之间完全不兼容。但在过渡时期,有一些键盘生产厂商生产的"AT-PS/2 
Keyboard",可以通过设置跳线,使其兼容"XT Keyboard"。这只不过在一个键盘里实现了两种方式,并不意味着“XT 
Keyboard”和"AT-PS/2 Keyboard"是兼容的。</FONT></P>
<P><FONT face="Times New Roman TUR" size=3>由于“XT Keyboard”已经完全过时,我们下面不会再介绍“XT 
Keyboard”相关的细节,我们的内容定位于“AT-PS/2 Keyboard”。</FONT></P><FONT size=2>
<HR width="100%" SIZE=2>

<P><SPAN lang=EN-US><FONT face="Times New Roman TUR"><SPAN 
style="mso-tab-count: 1"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
lang=EN-US><FONT face="Times New Roman" size=5><STRONG>4.2.3 
Architechure</STRONG></FONT></SPAN></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
lang=EN-US><FONT face="Times New Roman TUR"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT 
size=3><FONT face="Times New Roman TUR">在IBM AT和IBM 
PS/2键盘系统中,CPU并不直接和Keyboard进行通信,而是通过一个8042芯片或者其它与之兼容的芯片。增加这么一个中间层,就可以屏蔽掉不同键盘之间实现的差别,并可以增加新的特性。如下图所示</FONT>:</FONT></SPAN></SPAN></SPAN></FONT></SPAN></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN 
lang=EN-US><FONT face="Times New Roman" size=4><FONT face=""><FONT size=2><SPAN 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -