参考和说明

相关参考:

老狼系列参考

参考文章下载地址:
链接: https://pan.baidu.com/s/1LjrydEzCACG3ohpx7mMKKg 提取码: 4i3j

说明

因为 BIOS也不是我学习得重点,但X86架构及服务器 在使用过程中 有很多部分初始化放在了UEFI中 ,
通过ACPI 给系统提供服务,所以我也不得不看一些基础知识。
本文也是 摘选 《UEFI原理与编程_戴正华》 第一章节 好的内容简单记录下,可以快速复习。

传统BIOS(了解)

初始BIOS

BIOS(Basic Input Output System,基本输入输出系统)诞生于1975年的CP/M计算机。BIOS是一组固化在计算机主板ROM里的程序代码,其主要功能是在计算机上电时对硬件进行初始化配置,并将硬件操作封装为BIOS中断服务。这样,各种硬件间的差异便由BIOS负责维护,程序直接调用BIOS中断服务即可实现对硬件的控制。

BIOS的主要组成部分:

  • 加电自检程序(Power On Self Test, POST),在开机时负责检测硬件设备是否正常工作
  • 系统初始化程序,其中包括硬件设备的初始化以及创建BIOS中断向量等。
  • 适配外围即插即用设备。
  • CMOS设置程序,负责读写保存在CMOS中的系统设置信息。

BIOS以16位实模式运行,20位地址线,最大寻址空间1MB。BIOS使用汇编代码编写。

BIOS缺点:

开发效率低,性能差,扩展性差,安全性差

UEFI

初始UEFI

UEFI**Unified Extensible Firmware Interface,统一可扩展固件接口)定义了操作系统和平台固件之间的接口**,它是UEFI Forum发布的一种标准。UEFI是传统BIOS的替代者。UEFI发端于20世纪90年代中期的英特尔64位Itanium系统。到2005年,英特尔联合微软、AMD等公司成立Unified EFI Forum,负责指定统一的标准。第一个UEFI标准——UEFI 2.0在2006年1月发布。

UEFI不再为开发者提供中断支持,UEFI内部使用了时钟中断。**所有的异步操作都要通过事件(Event)来完成**。

UEFI优点:

UEFI使用C语言开发,开发效率高
UEFI采用模块化设计;每个驱动都是一个独立的模块。
UEFI性能有较大提升,使用“事件+异步操作”取代中断来操作外部设备

UEFI的系统构成

UEFI工程模块组成

UEFI工程模块包括应用程序模块、驱动程序模块、库模块、Shell应用程序模块。
UEFI可执行文件使用Windows平台的PE/COFF格式, 而不是Linux的ELF格式。

UEFI的启动过程(PI)

参考: TianoCore 官方文档 PI-Boot-Flow

UEFI从加点到关机的7个阶段,其中 前三个是UEFI的初始化阶段
image.png

UEFI系统的启动遵循 **UEFI平台初始化(Platform Initialization - PI**)标准。UEFI从上电到关机,分为如下七个阶段。
前三个阶段(**SECPEIDXE)是UEFI初始化阶段,DXE阶段结束后UEFI**环境已经准备完毕。
BDS和TSL是操作系统加载器(OS Loader)作为UEFI应用程序运行的阶段。
OS Loader调用ExitBootServices()服务后加入RT阶段,RT阶段包括操作系统加载器后期和操作系统运行期。
当系统硬件或操作系统出现严重错误不能继续运行时,固件会尝试修复错误,这时是AL(After Life)阶段。

image.png

UEFI的缩略语

Acronyms-and-Glossary 描述了UEFI中所有相关的缩略语

  1. ACPI
  2. Advanced Configuration and Power Interface. See www.acpi.info
  3. AL
  4. Afterlife phase. Also known as the "power down phase."
  5. AML
  6. ACPI Machine Language
  7. API
  8. Application Program Interface. Programmatic interfaces for the firmware (not Win32-type OS-level APIs).
  9. a priori file
  10. A file with a known GUID that contains the list of DXE drivers that are loaded and executed in the listed order before any other DXE drivers are discovered.
  11. Artifact
  12. Something tracked in Project Tracker
  13. ASL
  14. ACPI Source Language
  15. Attribute
  16. A field of something tracked in CEE Project Tracker
  17. BA
  18. Boot Authorization
  19. BBS
  20. BIOS Boot Specification
  21. BDS
  22. Boot Device Selection phase
  23. BFV
  24. Boot Firmware Volume. Code (i.e., PEI and PEIM code) that appears in the memory address space of the system without prior firmware intervention. See also FV.
  25. BIS
  26. Boot Integrity Services
  27. BIST
  28. Built-in self test
  29. BLT
  30. Block Transfer (pronounced "blit" as in "slit" or "flit"). A series of functions that form the basis of manipulation graphical data. The operation used to draw a rectangle of pixels on the screen.
  31. BNF
  32. Backus-Naur Form. A metasyntactic notation used to specify the syntax of programming languages, command sets, and the like
  33. BootDevice
  34. The device handle that corresponds to the device from which the currently executing image was loaded
  35. BootManager
  36. The part of the firmware implementation that is responsible for implementing system boot policy. Although a particular boot manager implementation is not specified in this document, such code is generally expected to be able to enumerate and handle transfers of control to the available OS loaders as well as EFI applications and drivers on a given system. The boot manager would typically be responsible for interacting with the system user, where applicable, to determine what to load during system startup. In cases where user interaction is not indicated, the boot manager would determine what to load and, if multiple items are to be loaded, what the sequencing of such loads would be.
  37. Boot Services
  38. The collection of interfaces and protocols that are present in the boot environment. The services minimally provide an OS loader with access to platform capabilities required to complete OS boot. Services are also available to drivers and applications that need access to platform capability. Boot services are terminated once the OS takes control of the platform.
  39. BSD
  40. Berkeley Software Distribution
  41. BSP
  42. Boot Strap Processor - typically the processor that will execute SEC and PEI
  43. COFF
  44. Common Object File Format. An (originally) Unix *-based file format that is now recognized under several OSs. The format uses one or more header fields followed by the section data for the file
  45. Compatibility16
  46. A traditional legacy BIOS with the POST and BIOS Setup code removed. Compatibility16 BIOS code executes in real mode
  47. CompatibilityBIOS
  48. The combination of both EfiCompatibility and Compatibility16
  49. CompatibilitySmm
  50. Any IBV-provided SMM code to perform traditional functions that are not provided by EFI
  51. CRC
  52. Cyclic Redundancy Check. A fixed-size error checking code appended to the end of a block of data (file) that is based on the content of the file
  53. CRTM
  54. Core Root-of-Trust Module
  55. CSM
  56. Compatibility Support Module. The combination of EfiCompatibility, CompatibilitySmm , and Compatibility16. Portion of the Framework that allows compatibility with non-EFI compliant operating systems to run on Framework firmware
  57. CVDR
  58. Configuration Values Driven through Reset
  59. Depex
  60. Dependency expression. Code associated with each Framework driver that describes the dependencies that must be satisfied in order for that driver to run. Controls order of execution in a Framework dispatch of PEIM and DXE drivers
  61. DispatchEntry Point
  62. The entry point that the dispatcher invokes
  63. Driver
  64. Modular chunk of firmware code that supports chipset or platform features. bReusable in multiple system contexts
  65. DXE
  66. Driver Execution Environment phase
  67. DXE Foundation
  68. A set of intrinsic services and an execution mechanism for sequenced control of driver modules
  69. DXE Services
  70. Services, such as security services and driver services, that are usable by DXE drivers
  71. EfiCompatibility
  72. EFI code that corresponds to EFI compatibility drivers, code that generates data for compatibility interfaces, or code that invokes compatibility services.
  73. EDK
  74. EFI Developer Kit
  75. EPL
  76. Eclipse Public License
  77. Extensible Firmware Interface (EFI)
  78. EFI is a specification that defines the interface between an operating system, option ROMs, and platform firmware. EFI was originally invented by Intel as the Intel(R) Itainum BIOS replacement. EFI is now owned by a industry non-profit collaborative trade organization called The UEFI Forum.
  79. FAT
  80. File Allocation Table
  81. FAT32
  82. FAT32 File System Driver
  83. FD
  84. Firmware Device. A persistent physical repository that contains firmware code and/or data and that may provide NVS. For the purposes of this architecture specification, the topology of bFDs should be abstracted via bFVs.
  85. FFS
  86. Firmware File System. A binary storage format that is well suited to firmware volumes. The abstracted model of the FFS is a flat file system
  87. Firmware Device
  88. See FD.
  89. Firmware Volume
  90. See FV.
  91. FIT
  92. Firmware Interface Tableb.( Itanium systems only)
  93. Font
  94. A translation between Unicode weights and glyphs. This "M" and this "M" and this "M" represent the same weight but in different fonts
  95. FoundationCode
  96. The core interoperability interfaces between modules and in the Framework
  97. FPSWA
  98. Floating Point Software Assist. (Itanium systems only)
  99. Framework
  100. short for Intel® Platform Innovation Framework for EFI
  101. FS
  102. Firmware Store. The abstracted model of the FS is a flat "file system" where individual files are SUMs
  103. FV
  104. There are one or more FVs in the FS. The FV containing the "reset vector" is known as the Boot Firmware Volume (BFV). A FV is a simple Flash File System that starts with a header and contains files that are named by a GUID. The file system is flat and does not support directories. Each file is made up of a series of sections that support encapsulation.
  105. GCD
  106. Global coherency domain. The address resources of a system as seen by a processor. It consists of both system memory and I/O space
  107. glyph
  108. The graphical representation of a single Unicode weight
  109. Globally Unique IDentifier (GUID)
  110. Globally Unique Identifier. A 128-bit value used to differentiate and name services and structures.
  111. HII
  112. Human Interface Infrastructure. Repository of configuration and translation information for localization. Typically used with boot manager and shell to provide a localized user interface.
  113. HOB
  114. Hand-Off Block. A structure used to pass information from one boot phase to another (i.e., from the PEI phase to the DXE phase)
  115. IBV
  116. Independent BIOS Vendor
  117. IFR
  118. Internal Forms Representation. A binary encoding of forms-based display content and configuration information
  119. IHV
  120. Independent Hardware Vendor
  121. IME
  122. Input Method Editor
  123. Intrinsic Services
  124. Services, such as security services and driver services, that remain available after the phase during which they are instantiated
  125. IPL
  126. Initial Program Load. An architectural PEIM to PEIM interface that starts the DXE phase
  127. IPMI
  128. Intelligent Platform Management Interface
  129. ISO 3166
  130. An association between a country or region and a two or three character ASCII string
  131. ISO 639-2
  132. An association between a language or dialect and a three character ASCII string
  133. Localization
  134. Concepts by which an interface is made useful to users speaking different languages and from various cultures by adapting the interfaces to the user. "STOP" in English would be "ALTO" in Spanish and "СТОП" in Russian. Alphabetic on keyboards are local to the language and may be local to the country the keyboard is localized for. For example, a French keyboard in France is different from a French keyboard in Canada.
  135. MCA
  136. Machine Check Architecture
  137. MDE
  138. Module Development Environment
  139. NMI
  140. Non-maskable Iinterrupt
  141. NRAM
  142. Nonvolatile Random Access Memory
  143. NVS
  144. Nonvolatile storage. Flash, EPROM, ROM, or other persistent store that will not go away once system power is removed
  145. ODM
  146. Original Device Manufacturer
  147. OEM
  148. Original Equipment Manufacturer
  149. OpROM
  150. Option ROM
  151. PAL
  152. Processor Abstraction Layer. A binary distributed by Intel that is used by the 64 bit Itanium processor family
  153. PCI
  154. Peripheral Component Interconnect. See www.pcisig.com for more information.
  155. PCR
  156. Platform Configuration Register
  157. PE/COFF
  158. PE32, PE32+, or Common Object File Format. A defined standard file format for binary images
  159. PEI
  160. Pre-EFI Initialization phase. Set of drivers usually designed to initialize memory and the cpu so that DXE phase can run. sually the first bset of code run starting from reset.
  161. PEI Foundation
  162. A set of intrinsic services and an execution mechanism for sequenced control of PEIMs
  163. Pre EFI Initialization Module (PEIM)
  164. Pre-EFI Initialization Module. Modular chunk of firmware code running in PEI that supports chipset or platform features. Reusable in multiple system contexts.
  165. PEI Services
  166. Common services that are usable by PEIMs
  167. PEIM to PEIM Interface (PPI)
  168. A C structure named by a GUID that is published by one PEIM and consumed by another. The C structure can contain data and member functions. It differs from a Protocol in that it may have to function prior to memory being available and parts of the PPI could be in read only memory.
  169. PHIT
  170. Phase Handoff Information Table. A HOB that describes the physical memory used by the PEI phase and the boot mode discovered during the PEI phase.
  171. PIC
  172. Position-independent code. Code that can be executed at any address without relocation
  173. POST
  174. Power On Self Test
  175. Protocol
  176. A C structure named by a GUID that is published by one EFI or DXE driver and consumed by another. The C structure can contain data and member functions.
  177. Reverse Thunk
  178. The code to transition from 16-bit real mode to native execution mode
  179. RSD_PTR
  180. ACPI definition: Root System Description Pointer
  181. RT or Runtime phase
  182. For EFI and the Framework this is after exit boot services has executed and the OS is in control of the system.
  183. Runtime Services
  184. Interfaces that provide access to underlying platform-specific hardware that may be useful during OS runtime, such as time and date services. These services become active during the boot process but also persist after the OS loader terminates boot services.
  185. SAL
  186. System Abstraction Layer. (Itanium systems only)
  187. SALE_ENTRY
  188. System Abstraction Layer entry point. (Itanium systems only)
  189. Sandbox
  190. The common properties of a driver or preboot environment that allow applications to run. These properties include a defined load image format and services that can run in the sandbox.
  191. SEC
  192. SECurity Phase. Initial starting point for boot process, first code executed after hardware reset. Responsible for 1) Establishing root trust in the software space; 2) Initializing architecture specific configuration to establish memory space for the C code stack.
  193. SMI
  194. System Management Interrupt
  195. SMM
  196. System Management Mode
  197. SOR
  198. Schedule on Request
  199. SSE
  200. Streaming SIMD Extensions
  201. SUM
  202. Separately Updateable Module. A portion of the BFV that is treated as a separate module that can be updated without affecting the other SUMs in the BFV.
  203. Tiano
  204. Codename for the Intel Project to develop the Framework
  205. TCB
  206. Trusted Computing Base
  207. TCG
  208. Trusted Computing Group
  209. TE Image
  210. Terse Executable image. An executable image format that is specific to the Framework. This format is used only in PEI and is used for storing executable images in a smaller amount of space than would be required by a full PE32+ image. Is a smaller more compact version of bPE32.
  211. Thunk
  212. The code to transition from native execution mode to 16-bit real mode
  213. UNDI
  214. Universal Network Driver Interface. Silicon specific driver in the preboot LAN stack that interfaces to SNP and PXEBC
  215. Unicode
  216. A standard defining an association between numeric values known as "weights" and characters from the majority of the worlds currently used languages. See the Unicode specification for more information.
  217. USB
  218. Universal Serial Bus. See http://www.usb.org for more information
  219. VFR
  220. Visual Forms Representation. A high-level language representation of IFR
  221. VM
  222. Virtual Machine
  223. VTF
  224. Volume Top File. A file in a firmware volume that must be located such that the last byte of the file is also the last byte of the firmware volume
  225. VT-UTF8
  226. A serial protocol definition that extends VT-100 to support Unicode
  227. Watchdog Timer
  228. An alarm timer that may be set to go off. This can be used to regain control in cases where a code path in the boot services environment fails to or is unable to return control by the expected path.
  229. XIP
  230. Execute In Place. PEI code that is executed from its storage location in a firmware volume