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

📄 理解和使用linux的硬件抽象层hal - colorant的专栏 - csdn博客.htm

📁 理解和使用Linux的硬件抽象层HAL.rar理解和使用Linux的硬件抽象层HAL.rar
💻 HTM
📖 第 1 页 / 共 5 页
字号:
face="Times New Roman">HAL</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不是</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><FONT 
face="Times New Roman">2001</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">太空漫游系列里的那台超级电脑</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><FONT face="Times New Roman">8 
</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">)</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><FONT 
face="Times New Roman">HAL</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><FONT 
face="Times New Roman">Hardware Abstraction Layer</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">即硬件抽象层的首字母缩写,以下来源于</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><FONT 
face="Times New Roman">Hal Spec</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的框图很好的说明了它的组成部分:</SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><O:P><FONT face=宋体><IMG 
alt=hal-arch src=""></FONT></O:P></SPAN></P>
<P class=a style="MARGIN: 7.8pt 0cm 0pt"><SPAN lang=EN 
style="mso-ansi-language: EN"><V:SHAPETYPE id=_x0000_t75 stroked="f" filled="f" 
path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" 
coordsize="21600,21600"><V:STROKE joinstyle="miter"></V:STROKE><V:FORMULAS><V:F 
eqn="if lineDrawn pixelLineWidth 0"></V:F><V:F eqn="sum @0 1 0"></V:F><V:F 
eqn="sum 0 0 @1"></V:F><V:F eqn="prod @2 1 2"></V:F><V:F 
eqn="prod @3 21600 pixelWidth"></V:F><V:F 
eqn="prod @3 21600 pixelHeight"></V:F><V:F eqn="sum @0 0 1"></V:F><V:F 
eqn="prod @6 1 2"></V:F><V:F eqn="prod @7 21600 pixelWidth"></V:F><V:F 
eqn="sum @8 21600 0"></V:F><V:F eqn="prod @7 21600 pixelHeight"></V:F><V:F 
eqn="sum @10 21600 0"></V:F></V:FORMULAS><V:PATH o:connecttype="rect" 
gradientshapeok="t" o:extrusionok="f"></V:PATH><O:LOCK aspectratio="t" 
v:ext="edit"></O:LOCK></V:SHAPETYPE><V:SHAPE id=_x0000_i1025 
style="WIDTH: 464.25pt; HEIGHT: 291.75pt; mso-position-vertical: absolute" 
alt="" type="#_x0000_t75"><V:IMAGEDATA 
o:href="http://people.freedesktop.org/~david/hal-spec/hal-arch.png" 
src="file:///C:\DOCUME~1\raymond\LOCALS~1\Temp\msohtml1\03\clip_image001.png"></V:IMAGEDATA></V:SHAPE><O:P></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">它是一个位于操作系统和驱动程序之上,运行在用户空间中的服务程序。</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><O:P></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">它的目的是对上层应用提供一个统一的简单的查询硬件设备的接口。它所谓的抽象,基本上也就仅限于这一功能,它通常并不提供对硬件的实际操作,对硬件的操作,还是由应用程序来完成。</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><O:P></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">细化来说,除了提供标准的硬件查询接口,它甚至并不考虑如何对硬件进行配置,这不是它要完成的工作,但它确实提供了存储硬件配置相关信息的空间。下面我们会说到,那被称为属性。</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><O:P></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所以,简单的说,你可以把</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><FONT 
face="Times New Roman">HAL</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">理解为:一堆的硬件列表以及他们的相关属性的集合。</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><O:P></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">那么,这一堆硬件列表能有什么用呢?应该说,它简化了应用的查询逻辑,把这一部分的复杂性转移到了应用程序之外,由</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><FONT 
face="Times New Roman">HAL</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">统一处理,其次,按作者的期望,当一些库函数也开始使用</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><FONT 
face="Times New Roman">HAL</FONT></SPAN><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的时候,应用程序甚至可以把对不同硬件的实际操作的复杂性也交给库函数来自动处理。</SPAN><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; COLOR: black"><O:P></O:P></SPAN></P>
<H2 style="MARGIN: 0cm 0cm 0pt 31.2pt"><FONT face="Times New Roman"><SPAN 
lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN 
style="mso-list: Ignore">2.2<SPAN style="FONT: 7pt 'Times New Roman'"><FONT 
size=5>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</FONT></SPAN></SPAN></SPAN><SPAN lang=EN-US>HAL</SPAN></FONT><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的组成框架</SPAN></H2>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT 
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">按照上面的框图,首先是</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">HAL daemon</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">HAL</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的服务进程。其次是硬件信息文件,后缀</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">fdi</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,再有是</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">Callout</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">Addons</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,这些是</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">HAL</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">针对不同硬件进行额外的处理工作所需的一些可执行文件或脚本。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">Hal</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">内部,每个硬件(具体的或抽象的)都是由一个</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">Device Object</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设备对象来表示。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT 
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT 
size=3>每个设备对象会包括以下几个概念的组成部分:</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN 
lang=EN-US><FONT face="Times New Roman">UDI: Unique Device Identifer 
</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">每个设备对象的唯一标识符,它是根据</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">BUS</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">信息得到的,它的目标是保证设备的唯一性,同时在一个可移除设备多次插入拔出过程中保持相同的值。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN 
lang=EN-US><FONT face="Times New Roman">Property </FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">:属性,是一个</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">key/value pair</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。每个属性由一个键和一个键值组成,用来存储设备对象相关的各种信息。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN 
lang=EN-US><FONT face="Times New Roman">Method </FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">:方法是用来读取设置属性,或提供某些特定操作。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN 
lang=EN-US><FONT face="Times New Roman">Interface </FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">:这个更多的是</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">DBUS</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的概念。属性和方法被分类到不同的</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">Interface</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中。</SPAN></FONT></P>
<H2 style="MARGIN: 0cm 0cm 0pt 31.2pt"><FONT face="Times New Roman"><SPAN 
lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN 
style="mso-list: Ignore">2.3<SPAN style="FONT: 7pt 'Times New Roman'"><FONT 
size=5>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</FONT></SPAN></SPAN></SPAN><SPAN lang=EN-US>HAL</SPAN></FONT><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">硬件信息的来源</SPAN></H2>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN 
lang=EN-US><FONT face="Times New Roman">HAL</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中设备对象的相关信息来源主要有以下几种:</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT 
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoListBullet2 style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US 
style="FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings"><SPAN 
style="mso-list: Ignore"><FONT size=3>Ø</FONT><SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN></SPAN><FONT size=3><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通过</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">Sysfs</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">得到,有相当一部分的属性是通过这种方式得到的,比如</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">UDI</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,设备的厂商,设备的父节点,设备的总线类型,硬盘的</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">UUID</FONT></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">啊等等。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT 
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoListBullet2 style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US 
style="FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings"><SPAN 
style="mso-list: Ignore"><FONT size=3>Ø</FONT><SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN></SPAN><FONT size=3><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通过</SPAN><SPAN 
lang=EN-US><FONT face="Times New Roman">Probe</FONT></SPAN><SPAN 

⌨️ 快捷键说明

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