LegacyBios.h 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553
  1. /** @file
  2. The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage
  3. under EFI and Legacy OS boot. This file also includes all the related
  4. COMPATIBILIY16 structures and defintions.
  5. Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow
  6. well known naming conventions.
  7. Thunk is the code that switches from 32-bit protected environment into the 16-bit real-mode
  8. environment. Reverse thunk is the code that does the opposite.
  9. Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
  10. SPDX-License-Identifier: BSD-2-Clause-Patent
  11. @par Revision Reference:
  12. This protocol is defined in Framework for EFI Compatibility Support Module spec
  13. Version 0.98.
  14. **/
  15. #ifndef _EFI_LEGACY_BIOS_H_
  16. #define _EFI_LEGACY_BIOS_H_
  17. ///
  18. ///
  19. ///
  20. #pragma pack(1)
  21. typedef UINT8 SERIAL_MODE;
  22. typedef UINT8 PARALLEL_MODE;
  23. #define EFI_COMPATIBILITY16_TABLE_SIGNATURE SIGNATURE_32 ('I', 'F', 'E', '$')
  24. ///
  25. /// There is a table located within the traditional BIOS in either the 0xF000:xxxx or 0xE000:xxxx
  26. /// physical address range. It is located on a 16-byte boundary and provides the physical address of the
  27. /// entry point for the Compatibility16 functions. These functions provide the platform-specific
  28. /// information that is required by the generic EfiCompatibility code. The functions are invoked via
  29. /// thunking by using EFI_LEGACY_BIOS_PROTOCOL.FarCall86() with the 32-bit physical
  30. /// entry point.
  31. ///
  32. typedef struct {
  33. ///
  34. /// The string "$EFI" denotes the start of the EfiCompatibility table. Byte 0 is "I," byte
  35. /// 1 is "F," byte 2 is "E," and byte 3 is "$" and is normally accessed as a DWORD or UINT32.
  36. ///
  37. UINT32 Signature;
  38. ///
  39. /// The value required such that byte checksum of TableLength equals zero.
  40. ///
  41. UINT8 TableChecksum;
  42. ///
  43. /// The length of this table.
  44. ///
  45. UINT8 TableLength;
  46. ///
  47. /// The major EFI revision for which this table was generated.
  48. ///
  49. UINT8 EfiMajorRevision;
  50. ///
  51. /// The minor EFI revision for which this table was generated.
  52. ///
  53. UINT8 EfiMinorRevision;
  54. ///
  55. /// The major revision of this table.
  56. ///
  57. UINT8 TableMajorRevision;
  58. ///
  59. /// The minor revision of this table.
  60. ///
  61. UINT8 TableMinorRevision;
  62. ///
  63. /// Reserved for future usage.
  64. ///
  65. UINT16 Reserved;
  66. ///
  67. /// The segment of the entry point within the traditional BIOS for Compatibility16 functions.
  68. ///
  69. UINT16 Compatibility16CallSegment;
  70. ///
  71. /// The offset of the entry point within the traditional BIOS for Compatibility16 functions.
  72. ///
  73. UINT16 Compatibility16CallOffset;
  74. ///
  75. /// The segment of the entry point within the traditional BIOS for EfiCompatibility
  76. /// to invoke the PnP installation check.
  77. ///
  78. UINT16 PnPInstallationCheckSegment;
  79. ///
  80. /// The Offset of the entry point within the traditional BIOS for EfiCompatibility
  81. /// to invoke the PnP installation check.
  82. ///
  83. UINT16 PnPInstallationCheckOffset;
  84. ///
  85. /// EFI system resources table. Type EFI_SYSTEM_TABLE is defined in the IntelPlatform
  86. ///Innovation Framework for EFI Driver Execution Environment Core Interface Specification (DXE CIS).
  87. ///
  88. UINT32 EfiSystemTable;
  89. ///
  90. /// The address of an OEM-provided identifier string. The string is null terminated.
  91. ///
  92. UINT32 OemIdStringPointer;
  93. ///
  94. /// The 32-bit physical address where ACPI RSD PTR is stored within the traditional
  95. /// BIOS. The remained of the ACPI tables are located at their EFI addresses. The size
  96. /// reserved is the maximum for ACPI 2.0. The EfiCompatibility will fill in the ACPI
  97. /// RSD PTR with either the ACPI 1.0b or 2.0 values.
  98. ///
  99. UINT32 AcpiRsdPtrPointer;
  100. ///
  101. /// The OEM revision number. Usage is undefined but provided for OEM module usage.
  102. ///
  103. UINT16 OemRevision;
  104. ///
  105. /// The 32-bit physical address where INT15 E820 data is stored within the traditional
  106. /// BIOS. The EfiCompatibility code will fill in the E820Pointer value and copy the
  107. /// data to the indicated area.
  108. ///
  109. UINT32 E820Pointer;
  110. ///
  111. /// The length of the E820 data and is filled in by the EfiCompatibility code.
  112. ///
  113. UINT32 E820Length;
  114. ///
  115. /// The 32-bit physical address where the $PIR table is stored in the traditional BIOS.
  116. /// The EfiCompatibility code will fill in the IrqRoutingTablePointer value and
  117. /// copy the data to the indicated area.
  118. ///
  119. UINT32 IrqRoutingTablePointer;
  120. ///
  121. /// The length of the $PIR table and is filled in by the EfiCompatibility code.
  122. ///
  123. UINT32 IrqRoutingTableLength;
  124. ///
  125. /// The 32-bit physical address where the MP table is stored in the traditional BIOS.
  126. /// The EfiCompatibility code will fill in the MpTablePtr value and copy the data
  127. /// to the indicated area.
  128. ///
  129. UINT32 MpTablePtr;
  130. ///
  131. /// The length of the MP table and is filled in by the EfiCompatibility code.
  132. ///
  133. UINT32 MpTableLength;
  134. ///
  135. /// The segment of the OEM-specific INT table/code.
  136. ///
  137. UINT16 OemIntSegment;
  138. ///
  139. /// The offset of the OEM-specific INT table/code.
  140. ///
  141. UINT16 OemIntOffset;
  142. ///
  143. /// The segment of the OEM-specific 32-bit table/code.
  144. ///
  145. UINT16 Oem32Segment;
  146. ///
  147. /// The offset of the OEM-specific 32-bit table/code.
  148. ///
  149. UINT16 Oem32Offset;
  150. ///
  151. /// The segment of the OEM-specific 16-bit table/code.
  152. ///
  153. UINT16 Oem16Segment;
  154. ///
  155. /// The offset of the OEM-specific 16-bit table/code.
  156. ///
  157. UINT16 Oem16Offset;
  158. ///
  159. /// The segment of the TPM binary passed to 16-bit CSM.
  160. ///
  161. UINT16 TpmSegment;
  162. ///
  163. /// The offset of the TPM binary passed to 16-bit CSM.
  164. ///
  165. UINT16 TpmOffset;
  166. ///
  167. /// A pointer to a string identifying the independent BIOS vendor.
  168. ///
  169. UINT32 IbvPointer;
  170. ///
  171. /// This field is NULL for all systems not supporting PCI Express. This field is the base
  172. /// value of the start of the PCI Express memory-mapped configuration registers and
  173. /// must be filled in prior to EfiCompatibility code issuing the Compatibility16 function
  174. /// Compatibility16InitializeYourself().
  175. /// Compatibility16InitializeYourself() is defined in Compatability16
  176. /// Functions.
  177. ///
  178. UINT32 PciExpressBase;
  179. ///
  180. /// Maximum PCI bus number assigned.
  181. ///
  182. UINT8 LastPciBus;
  183. ///
  184. /// Start Address of Upper Memory Area (UMA) to be set as Read/Write. If
  185. /// UmaAddress is a valid address in the shadow RAM, it also indicates that the region
  186. /// from 0xC0000 to (UmaAddress - 1) can be used for Option ROM.
  187. ///
  188. UINT32 UmaAddress;
  189. ///
  190. /// Upper Memory Area size in bytes to be set as Read/Write. If zero, no UMA region
  191. /// will be set as Read/Write (i.e. all Shadow RAM is set as Read-Only).
  192. ///
  193. UINT32 UmaSize;
  194. ///
  195. /// Start Address of high memory that can be used for permanent allocation. If zero,
  196. /// high memory is not available for permanent allocation.
  197. ///
  198. UINT32 HiPermanentMemoryAddress;
  199. ///
  200. /// Size of high memory that can be used for permanent allocation in bytes. If zero,
  201. /// high memory is not available for permanent allocation.
  202. ///
  203. UINT32 HiPermanentMemorySize;
  204. } EFI_COMPATIBILITY16_TABLE;
  205. ///
  206. /// Functions provided by the CSM binary which communicate between the EfiCompatibility
  207. /// and Compatability16 code.
  208. ///
  209. /// Inconsistent with the specification here:
  210. /// The member's name started with "Compatibility16" [defined in Intel Framework
  211. /// Compatibility Support Module Specification / 0.97 version]
  212. /// has been changed to "Legacy16" since keeping backward compatible.
  213. ///
  214. typedef enum {
  215. ///
  216. /// Causes the Compatibility16 code to do any internal initialization required.
  217. /// Input:
  218. /// AX = Compatibility16InitializeYourself
  219. /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_INIT_TABLE
  220. /// Return:
  221. /// AX = Return Status codes
  222. ///
  223. Legacy16InitializeYourself = 0x0000,
  224. ///
  225. /// Causes the Compatibility16 BIOS to perform any drive number translations to match the boot sequence.
  226. /// Input:
  227. /// AX = Compatibility16UpdateBbs
  228. /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE
  229. /// Return:
  230. /// AX = Returned status codes
  231. ///
  232. Legacy16UpdateBbs = 0x0001,
  233. ///
  234. /// Allows the Compatibility16 code to perform any final actions before booting. The Compatibility16
  235. /// code is read/write.
  236. /// Input:
  237. /// AX = Compatibility16PrepareToBoot
  238. /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE structure
  239. /// Return:
  240. /// AX = Returned status codes
  241. ///
  242. Legacy16PrepareToBoot = 0x0002,
  243. ///
  244. /// Causes the Compatibility16 BIOS to boot. The Compatibility16 code is Read/Only.
  245. /// Input:
  246. /// AX = Compatibility16Boot
  247. /// Output:
  248. /// AX = Returned status codes
  249. ///
  250. Legacy16Boot = 0x0003,
  251. ///
  252. /// Allows the Compatibility16 code to get the last device from which a boot was attempted. This is
  253. /// stored in CMOS and is the priority number of the last attempted boot device.
  254. /// Input:
  255. /// AX = Compatibility16RetrieveLastBootDevice
  256. /// Output:
  257. /// AX = Returned status codes
  258. /// BX = Priority number of the boot device.
  259. ///
  260. Legacy16RetrieveLastBootDevice = 0x0004,
  261. ///
  262. /// Allows the Compatibility16 code rehook INT13, INT18, and/or INT19 after dispatching a legacy OpROM.
  263. /// Input:
  264. /// AX = Compatibility16DispatchOprom
  265. /// ES:BX = Pointer to EFI_DISPATCH_OPROM_TABLE
  266. /// Output:
  267. /// AX = Returned status codes
  268. /// BX = Number of non-BBS-compliant devices found. Equals 0 if BBS compliant.
  269. ///
  270. Legacy16DispatchOprom = 0x0005,
  271. ///
  272. /// Finds a free area in the 0xFxxxx or 0xExxxx region of the specified length and returns the address
  273. /// of that region.
  274. /// Input:
  275. /// AX = Compatibility16GetTableAddress
  276. /// BX = Allocation region
  277. /// 00 = Allocate from either 0xE0000 or 0xF0000 64 KB blocks.
  278. /// Bit 0 = 1 Allocate from 0xF0000 64 KB block
  279. /// Bit 1 = 1 Allocate from 0xE0000 64 KB block
  280. /// CX = Requested length in bytes.
  281. /// DX = Required address alignment. Bit mapped. First non-zero bit from the right is the alignment.
  282. /// Output:
  283. /// AX = Returned status codes
  284. /// DS:BX = Address of the region
  285. ///
  286. Legacy16GetTableAddress = 0x0006,
  287. ///
  288. /// Enables the EfiCompatibility module to do any nonstandard processing of keyboard LEDs or state.
  289. /// Input:
  290. /// AX = Compatibility16SetKeyboardLeds
  291. /// CL = LED status.
  292. /// Bit 0 Scroll Lock 0 = Off
  293. /// Bit 1 NumLock
  294. /// Bit 2 Caps Lock
  295. /// Output:
  296. /// AX = Returned status codes
  297. ///
  298. Legacy16SetKeyboardLeds = 0x0007,
  299. ///
  300. /// Enables the EfiCompatibility module to install an interrupt handler for PCI mass media devices that
  301. /// do not have an OpROM associated with them. An example is SATA.
  302. /// Input:
  303. /// AX = Compatibility16InstallPciHandler
  304. /// ES:BX = Pointer to EFI_LEGACY_INSTALL_PCI_HANDLER structure
  305. /// Output:
  306. /// AX = Returned status codes
  307. ///
  308. Legacy16InstallPciHandler = 0x0008
  309. } EFI_COMPATIBILITY_FUNCTIONS;
  310. ///
  311. /// EFI_DISPATCH_OPROM_TABLE
  312. ///
  313. typedef struct {
  314. UINT16 PnPInstallationCheckSegment; ///< A pointer to the PnpInstallationCheck data structure.
  315. UINT16 PnPInstallationCheckOffset; ///< A pointer to the PnpInstallationCheck data structure.
  316. UINT16 OpromSegment; ///< The segment where the OpROM was placed. Offset is assumed to be 3.
  317. UINT8 PciBus; ///< The PCI bus.
  318. UINT8 PciDeviceFunction; ///< The PCI device * 0x08 | PCI function.
  319. UINT8 NumberBbsEntries; ///< The number of valid BBS table entries upon entry and exit. The IBV code may
  320. ///< increase this number, if BBS-compliant devices also hook INTs in order to force the
  321. ///< OpROM BIOS Setup to be executed.
  322. UINT32 BbsTablePointer; ///< A pointer to the BBS table.
  323. UINT16 RuntimeSegment; ///< The segment where the OpROM can be relocated to. If this value is 0x0000, this
  324. ///< means that the relocation of this run time code is not supported.
  325. ///< Inconsistent with specification here:
  326. ///< The member's name "OpromDestinationSegment" [defined in Intel Framework Compatibility Support Module Specification / 0.97 version]
  327. ///< has been changed to "RuntimeSegment" since keeping backward compatible.
  328. } EFI_DISPATCH_OPROM_TABLE;
  329. ///
  330. /// EFI_TO_COMPATIBILITY16_INIT_TABLE
  331. ///
  332. typedef struct {
  333. ///
  334. /// Starting address of memory under 1 MB. The ending address is assumed to be 640 KB or 0x9FFFF.
  335. ///
  336. UINT32 BiosLessThan1MB;
  337. ///
  338. /// The starting address of the high memory block.
  339. ///
  340. UINT32 HiPmmMemory;
  341. ///
  342. /// The length of high memory block.
  343. ///
  344. UINT32 HiPmmMemorySizeInBytes;
  345. ///
  346. /// The segment of the reverse thunk call code.
  347. ///
  348. UINT16 ReverseThunkCallSegment;
  349. ///
  350. /// The offset of the reverse thunk call code.
  351. ///
  352. UINT16 ReverseThunkCallOffset;
  353. ///
  354. /// The number of E820 entries copied to the Compatibility16 BIOS.
  355. ///
  356. UINT32 NumberE820Entries;
  357. ///
  358. /// The amount of usable memory above 1 MB, e.g., E820 type 1 memory.
  359. ///
  360. UINT32 OsMemoryAbove1Mb;
  361. ///
  362. /// The start of thunk code in main memory. Memory cannot be used by BIOS or PMM.
  363. ///
  364. UINT32 ThunkStart;
  365. ///
  366. /// The size of the thunk code.
  367. ///
  368. UINT32 ThunkSizeInBytes;
  369. ///
  370. /// Starting address of memory under 1 MB.
  371. ///
  372. UINT32 LowPmmMemory;
  373. ///
  374. /// The length of low Memory block.
  375. ///
  376. UINT32 LowPmmMemorySizeInBytes;
  377. } EFI_TO_COMPATIBILITY16_INIT_TABLE;
  378. ///
  379. /// DEVICE_PRODUCER_SERIAL.
  380. ///
  381. typedef struct {
  382. UINT16 Address; ///< I/O address assigned to the serial port.
  383. UINT8 Irq; ///< IRQ assigned to the serial port.
  384. SERIAL_MODE Mode; ///< Mode of serial port. Values are defined below.
  385. } DEVICE_PRODUCER_SERIAL;
  386. ///
  387. /// DEVICE_PRODUCER_SERIAL's modes.
  388. ///@{
  389. #define DEVICE_SERIAL_MODE_NORMAL 0x00
  390. #define DEVICE_SERIAL_MODE_IRDA 0x01
  391. #define DEVICE_SERIAL_MODE_ASK_IR 0x02
  392. #define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00
  393. #define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10
  394. ///@)
  395. ///
  396. /// DEVICE_PRODUCER_PARALLEL.
  397. ///
  398. typedef struct {
  399. UINT16 Address; ///< I/O address assigned to the parallel port.
  400. UINT8 Irq; ///< IRQ assigned to the parallel port.
  401. UINT8 Dma; ///< DMA assigned to the parallel port.
  402. PARALLEL_MODE Mode; ///< Mode of the parallel port. Values are defined below.
  403. } DEVICE_PRODUCER_PARALLEL;
  404. ///
  405. /// DEVICE_PRODUCER_PARALLEL's modes.
  406. ///@{
  407. #define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00
  408. #define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01
  409. #define DEVICE_PARALLEL_MODE_MODE_EPP 0x02
  410. #define DEVICE_PARALLEL_MODE_MODE_ECP 0x03
  411. ///@}
  412. ///
  413. /// DEVICE_PRODUCER_FLOPPY
  414. ///
  415. typedef struct {
  416. UINT16 Address; ///< I/O address assigned to the floppy.
  417. UINT8 Irq; ///< IRQ assigned to the floppy.
  418. UINT8 Dma; ///< DMA assigned to the floppy.
  419. UINT8 NumberOfFloppy; ///< Number of floppies in the system.
  420. } DEVICE_PRODUCER_FLOPPY;
  421. ///
  422. /// LEGACY_DEVICE_FLAGS
  423. ///
  424. typedef struct {
  425. UINT32 A20Kybd : 1; ///< A20 controller by keyboard controller.
  426. UINT32 A20Port90 : 1; ///< A20 controlled by port 0x92.
  427. UINT32 Reserved : 30; ///< Reserved for future usage.
  428. } LEGACY_DEVICE_FLAGS;
  429. ///
  430. /// DEVICE_PRODUCER_DATA_HEADER
  431. ///
  432. typedef struct {
  433. DEVICE_PRODUCER_SERIAL Serial[4]; ///< Data for serial port x. Type DEVICE_PRODUCER_SERIAL is defined below.
  434. DEVICE_PRODUCER_PARALLEL Parallel[3]; ///< Data for parallel port x. Type DEVICE_PRODUCER_PARALLEL is defined below.
  435. DEVICE_PRODUCER_FLOPPY Floppy; ///< Data for floppy. Type DEVICE_PRODUCER_FLOPPY is defined below.
  436. UINT8 MousePresent; ///< Flag to indicate if mouse is present.
  437. LEGACY_DEVICE_FLAGS Flags; ///< Miscellaneous Boolean state information passed to CSM.
  438. } DEVICE_PRODUCER_DATA_HEADER;
  439. ///
  440. /// ATAPI_IDENTIFY
  441. ///
  442. typedef struct {
  443. UINT16 Raw[256]; ///< Raw data from the IDE IdentifyDrive command.
  444. } ATAPI_IDENTIFY;
  445. ///
  446. /// HDD_INFO
  447. ///
  448. typedef struct {
  449. ///
  450. /// Status of IDE device. Values are defined below. There is one HDD_INFO structure
  451. /// per IDE controller. The IdentifyDrive is per drive. Index 0 is master and index
  452. /// 1 is slave.
  453. ///
  454. UINT16 Status;
  455. ///
  456. /// PCI bus of IDE controller.
  457. ///
  458. UINT32 Bus;
  459. ///
  460. /// PCI device of IDE controller.
  461. ///
  462. UINT32 Device;
  463. ///
  464. /// PCI function of IDE controller.
  465. ///
  466. UINT32 Function;
  467. ///
  468. /// Command ports base address.
  469. ///
  470. UINT16 CommandBaseAddress;
  471. ///
  472. /// Control ports base address.
  473. ///
  474. UINT16 ControlBaseAddress;
  475. ///
  476. /// Bus master address.
  477. ///
  478. UINT16 BusMasterAddress;
  479. UINT8 HddIrq;
  480. ///
  481. /// Data that identifies the drive data; one per possible attached drive.
  482. ///
  483. ATAPI_IDENTIFY IdentifyDrive[2];
  484. } HDD_INFO;
  485. ///
  486. /// HDD_INFO status bits
  487. ///
  488. #define HDD_PRIMARY 0x01
  489. #define HDD_SECONDARY 0x02
  490. #define HDD_MASTER_ATAPI_CDROM 0x04
  491. #define HDD_SLAVE_ATAPI_CDROM 0x08
  492. #define HDD_MASTER_IDE 0x20
  493. #define HDD_SLAVE_IDE 0x40
  494. #define HDD_MASTER_ATAPI_ZIPDISK 0x10
  495. #define HDD_SLAVE_ATAPI_ZIPDISK 0x80
  496. ///
  497. /// BBS_STATUS_FLAGS;\.
  498. ///
  499. typedef struct {
  500. UINT16 OldPosition : 4; ///< Prior priority.
  501. UINT16 Reserved1 : 4; ///< Reserved for future use.
  502. UINT16 Enabled : 1; ///< If 0, ignore this entry.
  503. UINT16 Failed : 1; ///< 0 = Not known if boot failure occurred.
  504. ///< 1 = Boot attempted failed.
  505. ///
  506. /// State of media present.
  507. /// 00 = No bootable media is present in the device.
  508. /// 01 = Unknown if a bootable media present.
  509. /// 10 = Media is present and appears bootable.
  510. /// 11 = Reserved.
  511. ///
  512. UINT16 MediaPresent : 2;
  513. UINT16 Reserved2 : 4; ///< Reserved for future use.
  514. } BBS_STATUS_FLAGS;
  515. ///
  516. /// BBS_TABLE, device type values & boot priority values.
  517. ///
  518. typedef struct {
  519. ///
  520. /// The boot priority for this boot device. Values are defined below.
  521. ///
  522. UINT16 BootPriority;
  523. ///
  524. /// The PCI bus for this boot device.
  525. ///
  526. UINT32 Bus;
  527. ///
  528. /// The PCI device for this boot device.
  529. ///
  530. UINT32 Device;
  531. ///
  532. /// The PCI function for the boot device.
  533. ///
  534. UINT32 Function;
  535. ///
  536. /// The PCI class for this boot device.
  537. ///
  538. UINT8 Class;
  539. ///
  540. /// The PCI Subclass for this boot device.
  541. ///
  542. UINT8 SubClass;
  543. ///
  544. /// Segment:offset address of an ASCIIZ description string describing the manufacturer.
  545. ///
  546. UINT16 MfgStringOffset;
  547. ///
  548. /// Segment:offset address of an ASCIIZ description string describing the manufacturer.
  549. ///
  550. UINT16 MfgStringSegment;
  551. ///
  552. /// BBS device type. BBS device types are defined below.
  553. ///
  554. UINT16 DeviceType;
  555. ///
  556. /// Status of this boot device. Type BBS_STATUS_FLAGS is defined below.
  557. ///
  558. BBS_STATUS_FLAGS StatusFlags;
  559. ///
  560. /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for
  561. /// BCV devices.
  562. ///
  563. UINT16 BootHandlerOffset;
  564. ///
  565. /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for
  566. /// BCV devices.
  567. ///
  568. UINT16 BootHandlerSegment;
  569. ///
  570. /// Segment:offset address of an ASCIIZ description string describing this device.
  571. ///
  572. UINT16 DescStringOffset;
  573. ///
  574. /// Segment:offset address of an ASCIIZ description string describing this device.
  575. ///
  576. UINT16 DescStringSegment;
  577. ///
  578. /// Reserved.
  579. ///
  580. UINT32 InitPerReserved;
  581. ///
  582. /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
  583. /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
  584. /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
  585. ///
  586. UINT32 AdditionalIrq13Handler;
  587. ///
  588. /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
  589. /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
  590. /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
  591. ///
  592. UINT32 AdditionalIrq18Handler;
  593. ///
  594. /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
  595. /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
  596. /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
  597. ///
  598. UINT32 AdditionalIrq19Handler;
  599. ///
  600. /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
  601. /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
  602. /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
  603. ///
  604. UINT32 AdditionalIrq40Handler;
  605. UINT8 AssignedDriveNumber;
  606. UINT32 AdditionalIrq41Handler;
  607. UINT32 AdditionalIrq46Handler;
  608. UINT32 IBV1;
  609. UINT32 IBV2;
  610. } BBS_TABLE;
  611. ///
  612. /// BBS device type values
  613. ///@{
  614. #define BBS_FLOPPY 0x01
  615. #define BBS_HARDDISK 0x02
  616. #define BBS_CDROM 0x03
  617. #define BBS_PCMCIA 0x04
  618. #define BBS_USB 0x05
  619. #define BBS_EMBED_NETWORK 0x06
  620. #define BBS_BEV_DEVICE 0x80
  621. #define BBS_UNKNOWN 0xff
  622. ///@}
  623. ///
  624. /// BBS boot priority values
  625. ///@{
  626. #define BBS_DO_NOT_BOOT_FROM 0xFFFC
  627. #define BBS_LOWEST_PRIORITY 0xFFFD
  628. #define BBS_UNPRIORITIZED_ENTRY 0xFFFE
  629. #define BBS_IGNORE_ENTRY 0xFFFF
  630. ///@}
  631. ///
  632. /// SMM_ATTRIBUTES
  633. ///
  634. typedef struct {
  635. ///
  636. /// Access mechanism used to generate the soft SMI. Defined types are below. The other
  637. /// values are reserved for future usage.
  638. ///
  639. UINT16 Type : 3;
  640. ///
  641. /// The size of "port" in bits. Defined values are below.
  642. ///
  643. UINT16 PortGranularity : 3;
  644. ///
  645. /// The size of data in bits. Defined values are below.
  646. ///
  647. UINT16 DataGranularity : 3;
  648. ///
  649. /// Reserved for future use.
  650. ///
  651. UINT16 Reserved : 7;
  652. } SMM_ATTRIBUTES;
  653. ///
  654. /// SMM_ATTRIBUTES type values.
  655. ///@{
  656. #define STANDARD_IO 0x00
  657. #define STANDARD_MEMORY 0x01
  658. ///@}
  659. ///
  660. /// SMM_ATTRIBUTES port size constants.
  661. ///@{
  662. #define PORT_SIZE_8 0x00
  663. #define PORT_SIZE_16 0x01
  664. #define PORT_SIZE_32 0x02
  665. #define PORT_SIZE_64 0x03
  666. ///@}
  667. ///
  668. /// SMM_ATTRIBUTES data size constants.
  669. ///@{
  670. #define DATA_SIZE_8 0x00
  671. #define DATA_SIZE_16 0x01
  672. #define DATA_SIZE_32 0x02
  673. #define DATA_SIZE_64 0x03
  674. ///@}
  675. ///
  676. /// SMM_FUNCTION & relating constants.
  677. ///
  678. typedef struct {
  679. UINT16 Function : 15;
  680. UINT16 Owner : 1;
  681. } SMM_FUNCTION;
  682. ///
  683. /// SMM_FUNCTION Function constants.
  684. ///@{
  685. #define INT15_D042 0x0000
  686. #define GET_USB_BOOT_INFO 0x0001
  687. #define DMI_PNP_50_57 0x0002
  688. ///@}
  689. ///
  690. /// SMM_FUNCTION Owner constants.
  691. ///@{
  692. #define STANDARD_OWNER 0x0
  693. #define OEM_OWNER 0x1
  694. ///@}
  695. ///
  696. /// This structure assumes both port and data sizes are 1. SmmAttribute must be
  697. /// properly to reflect that assumption.
  698. ///
  699. typedef struct {
  700. ///
  701. /// Describes the access mechanism, SmmPort, and SmmData sizes. Type
  702. /// SMM_ATTRIBUTES is defined below.
  703. ///
  704. SMM_ATTRIBUTES SmmAttributes;
  705. ///
  706. /// Function Soft SMI is to perform. Type SMM_FUNCTION is defined below.
  707. ///
  708. SMM_FUNCTION SmmFunction;
  709. ///
  710. /// SmmPort size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.
  711. ///
  712. UINT8 SmmPort;
  713. ///
  714. /// SmmData size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.
  715. ///
  716. UINT8 SmmData;
  717. } SMM_ENTRY;
  718. ///
  719. /// SMM_TABLE
  720. ///
  721. typedef struct {
  722. UINT16 NumSmmEntries; ///< Number of entries represented by SmmEntry.
  723. SMM_ENTRY SmmEntry; ///< One entry per function. Type SMM_ENTRY is defined below.
  724. } SMM_TABLE;
  725. ///
  726. /// UDC_ATTRIBUTES
  727. ///
  728. typedef struct {
  729. ///
  730. /// This bit set indicates that the ServiceAreaData is valid.
  731. ///
  732. UINT8 DirectoryServiceValidity : 1;
  733. ///
  734. /// This bit set indicates to use the Reserve Area Boot Code Address (RACBA) only if
  735. /// DirectoryServiceValidity is 0.
  736. ///
  737. UINT8 RabcaUsedFlag : 1;
  738. ///
  739. /// This bit set indicates to execute hard disk diagnostics.
  740. ///
  741. UINT8 ExecuteHddDiagnosticsFlag : 1;
  742. ///
  743. /// Reserved for future use. Set to 0.
  744. ///
  745. UINT8 Reserved : 5;
  746. } UDC_ATTRIBUTES;
  747. ///
  748. /// UD_TABLE
  749. ///
  750. typedef struct {
  751. ///
  752. /// This field contains the bit-mapped attributes of the PARTIES information. Type
  753. /// UDC_ATTRIBUTES is defined below.
  754. ///
  755. UDC_ATTRIBUTES Attributes;
  756. ///
  757. /// This field contains the zero-based device on which the selected
  758. /// ServiceDataArea is present. It is 0 for master and 1 for the slave device.
  759. ///
  760. UINT8 DeviceNumber;
  761. ///
  762. /// This field contains the zero-based index into the BbsTable for the parent device.
  763. /// This index allows the user to reference the parent device information such as PCI
  764. /// bus, device function.
  765. ///
  766. UINT8 BbsTableEntryNumberForParentDevice;
  767. ///
  768. /// This field contains the zero-based index into the BbsTable for the boot entry.
  769. ///
  770. UINT8 BbsTableEntryNumberForBoot;
  771. ///
  772. /// This field contains the zero-based index into the BbsTable for the HDD diagnostics entry.
  773. ///
  774. UINT8 BbsTableEntryNumberForHddDiag;
  775. ///
  776. /// The raw Beer data.
  777. ///
  778. UINT8 BeerData[128];
  779. ///
  780. /// The raw data of selected service area.
  781. ///
  782. UINT8 ServiceAreaData[64];
  783. } UD_TABLE;
  784. #define EFI_TO_LEGACY_MAJOR_VERSION 0x02
  785. #define EFI_TO_LEGACY_MINOR_VERSION 0x00
  786. #define MAX_IDE_CONTROLLER 8
  787. ///
  788. /// EFI_TO_COMPATIBILITY16_BOOT_TABLE
  789. ///
  790. typedef struct {
  791. UINT16 MajorVersion; ///< The EfiCompatibility major version number.
  792. UINT16 MinorVersion; ///< The EfiCompatibility minor version number.
  793. UINT32 AcpiTable; ///< The location of the RSDT ACPI table. < 4G range.
  794. UINT32 SmbiosTable; ///< The location of the SMBIOS table in EFI memory. < 4G range.
  795. UINT32 SmbiosTableLength;
  796. //
  797. // Legacy SIO state
  798. //
  799. DEVICE_PRODUCER_DATA_HEADER SioData; ///< Standard traditional device information.
  800. UINT16 DevicePathType; ///< The default boot type.
  801. UINT16 PciIrqMask; ///< Mask of which IRQs have been assigned to PCI.
  802. UINT32 NumberE820Entries; ///< Number of E820 entries. The number can change from the
  803. ///< Compatibility16InitializeYourself() function.
  804. //
  805. // Controller & Drive Identify[2] per controller information
  806. //
  807. HDD_INFO HddInfo[MAX_IDE_CONTROLLER]; ///< Hard disk drive information, including raw Identify Drive data.
  808. UINT32 NumberBbsEntries; ///< Number of entries in the BBS table
  809. UINT32 BbsTable; ///< A pointer to the BBS table. Type BBS_TABLE is defined below.
  810. UINT32 SmmTable; ///< A pointer to the SMM table. Type SMM_TABLE is defined below.
  811. UINT32 OsMemoryAbove1Mb; ///< The amount of usable memory above 1 MB, i.e. E820 type 1 memory. This value can
  812. ///< differ from the value in EFI_TO_COMPATIBILITY16_INIT_TABLE as more
  813. ///< memory may have been discovered.
  814. UINT32 UnconventionalDeviceTable; ///< Information to boot off an unconventional device like a PARTIES partition. Type
  815. ///< UD_TABLE is defined below.
  816. } EFI_TO_COMPATIBILITY16_BOOT_TABLE;
  817. ///
  818. /// EFI_LEGACY_INSTALL_PCI_HANDLER
  819. ///
  820. typedef struct {
  821. UINT8 PciBus; ///< The PCI bus of the device.
  822. UINT8 PciDeviceFun; ///< The PCI device in bits 7:3 and function in bits 2:0.
  823. UINT8 PciSegment; ///< The PCI segment of the device.
  824. UINT8 PciClass; ///< The PCI class code of the device.
  825. UINT8 PciSubclass; ///< The PCI subclass code of the device.
  826. UINT8 PciInterface; ///< The PCI interface code of the device.
  827. //
  828. // Primary section
  829. //
  830. UINT8 PrimaryIrq; ///< The primary device IRQ.
  831. UINT8 PrimaryReserved; ///< Reserved.
  832. UINT16 PrimaryControl; ///< The primary device control I/O base.
  833. UINT16 PrimaryBase; ///< The primary device I/O base.
  834. UINT16 PrimaryBusMaster; ///< The primary device bus master I/O base.
  835. //
  836. // Secondary Section
  837. //
  838. UINT8 SecondaryIrq; ///< The secondary device IRQ.
  839. UINT8 SecondaryReserved; ///< Reserved.
  840. UINT16 SecondaryControl; ///< The secondary device control I/O base.
  841. UINT16 SecondaryBase; ///< The secondary device I/O base.
  842. UINT16 SecondaryBusMaster; ///< The secondary device bus master I/O base.
  843. } EFI_LEGACY_INSTALL_PCI_HANDLER;
  844. //
  845. // Restore default pack value
  846. //
  847. #pragma pack()
  848. #define EFI_LEGACY_BIOS_PROTOCOL_GUID \
  849. { \
  850. 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d } \
  851. }
  852. typedef struct _EFI_LEGACY_BIOS_PROTOCOL EFI_LEGACY_BIOS_PROTOCOL;
  853. ///
  854. /// Flags returned by CheckPciRom().
  855. ///
  856. #define NO_ROM 0x00
  857. #define ROM_FOUND 0x01
  858. #define VALID_LEGACY_ROM 0x02
  859. #define ROM_WITH_CONFIG 0x04 ///< Not defined in the Framework CSM Specification.
  860. ///
  861. /// The following macros do not appear in the Framework CSM Specification and
  862. /// are kept for backward compatibility only. They convert 32-bit address (_Adr)
  863. /// to Segment:Offset 16-bit form.
  864. ///
  865. ///@{
  866. #define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)
  867. #define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)
  868. ///@}
  869. #define CARRY_FLAG 0x01
  870. ///
  871. /// EFI_EFLAGS_REG
  872. ///
  873. typedef struct {
  874. UINT32 CF:1;
  875. UINT32 Reserved1:1;
  876. UINT32 PF:1;
  877. UINT32 Reserved2:1;
  878. UINT32 AF:1;
  879. UINT32 Reserved3:1;
  880. UINT32 ZF:1;
  881. UINT32 SF:1;
  882. UINT32 TF:1;
  883. UINT32 IF:1;
  884. UINT32 DF:1;
  885. UINT32 OF:1;
  886. UINT32 IOPL:2;
  887. UINT32 NT:1;
  888. UINT32 Reserved4:2;
  889. UINT32 VM:1;
  890. UINT32 Reserved5:14;
  891. } EFI_EFLAGS_REG;
  892. ///
  893. /// EFI_DWORD_REGS
  894. ///
  895. typedef struct {
  896. UINT32 EAX;
  897. UINT32 EBX;
  898. UINT32 ECX;
  899. UINT32 EDX;
  900. UINT32 ESI;
  901. UINT32 EDI;
  902. EFI_EFLAGS_REG EFlags;
  903. UINT16 ES;
  904. UINT16 CS;
  905. UINT16 SS;
  906. UINT16 DS;
  907. UINT16 FS;
  908. UINT16 GS;
  909. UINT32 EBP;
  910. UINT32 ESP;
  911. } EFI_DWORD_REGS;
  912. ///
  913. /// EFI_FLAGS_REG
  914. ///
  915. typedef struct {
  916. UINT16 CF:1;
  917. UINT16 Reserved1:1;
  918. UINT16 PF:1;
  919. UINT16 Reserved2:1;
  920. UINT16 AF:1;
  921. UINT16 Reserved3:1;
  922. UINT16 ZF:1;
  923. UINT16 SF:1;
  924. UINT16 TF:1;
  925. UINT16 IF:1;
  926. UINT16 DF:1;
  927. UINT16 OF:1;
  928. UINT16 IOPL:2;
  929. UINT16 NT:1;
  930. UINT16 Reserved4:1;
  931. } EFI_FLAGS_REG;
  932. ///
  933. /// EFI_WORD_REGS
  934. ///
  935. typedef struct {
  936. UINT16 AX;
  937. UINT16 ReservedAX;
  938. UINT16 BX;
  939. UINT16 ReservedBX;
  940. UINT16 CX;
  941. UINT16 ReservedCX;
  942. UINT16 DX;
  943. UINT16 ReservedDX;
  944. UINT16 SI;
  945. UINT16 ReservedSI;
  946. UINT16 DI;
  947. UINT16 ReservedDI;
  948. EFI_FLAGS_REG Flags;
  949. UINT16 ReservedFlags;
  950. UINT16 ES;
  951. UINT16 CS;
  952. UINT16 SS;
  953. UINT16 DS;
  954. UINT16 FS;
  955. UINT16 GS;
  956. UINT16 BP;
  957. UINT16 ReservedBP;
  958. UINT16 SP;
  959. UINT16 ReservedSP;
  960. } EFI_WORD_REGS;
  961. ///
  962. /// EFI_BYTE_REGS
  963. ///
  964. typedef struct {
  965. UINT8 AL, AH;
  966. UINT16 ReservedAX;
  967. UINT8 BL, BH;
  968. UINT16 ReservedBX;
  969. UINT8 CL, CH;
  970. UINT16 ReservedCX;
  971. UINT8 DL, DH;
  972. UINT16 ReservedDX;
  973. } EFI_BYTE_REGS;
  974. ///
  975. /// EFI_IA32_REGISTER_SET
  976. ///
  977. typedef union {
  978. EFI_DWORD_REGS E;
  979. EFI_WORD_REGS X;
  980. EFI_BYTE_REGS H;
  981. } EFI_IA32_REGISTER_SET;
  982. /**
  983. Thunk to 16-bit real mode and execute a software interrupt with a vector
  984. of BiosInt. Regs will contain the 16-bit register context on entry and
  985. exit.
  986. @param[in] This The protocol instance pointer.
  987. @param[in] BiosInt The processor interrupt vector to invoke.
  988. @param[in,out] Reg Register contexted passed into (and returned) from thunk to
  989. 16-bit mode.
  990. @retval TRUE Thunk completed with no BIOS errors in the target code. See Regs for status.
  991. @retval FALSE There was a BIOS error in the target code.
  992. **/
  993. typedef
  994. BOOLEAN
  995. (EFIAPI *EFI_LEGACY_BIOS_INT86)(
  996. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  997. IN UINT8 BiosInt,
  998. IN OUT EFI_IA32_REGISTER_SET *Regs
  999. );
  1000. /**
  1001. Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
  1002. 16-bit register context on entry and exit. Arguments can be passed on
  1003. the Stack argument
  1004. @param[in] This The protocol instance pointer.
  1005. @param[in] Segment The segemnt of 16-bit mode call.
  1006. @param[in] Offset The offset of 16-bit mdoe call.
  1007. @param[in] Reg Register contexted passed into (and returned) from thunk to
  1008. 16-bit mode.
  1009. @param[in] Stack The caller allocated stack used to pass arguments.
  1010. @param[in] StackSize The size of Stack in bytes.
  1011. @retval FALSE Thunk completed with no BIOS errors in the target code. See Regs for status. @retval TRUE There was a BIOS error in the target code.
  1012. **/
  1013. typedef
  1014. BOOLEAN
  1015. (EFIAPI *EFI_LEGACY_BIOS_FARCALL86)(
  1016. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1017. IN UINT16 Segment,
  1018. IN UINT16 Offset,
  1019. IN EFI_IA32_REGISTER_SET *Regs,
  1020. IN VOID *Stack,
  1021. IN UINTN StackSize
  1022. );
  1023. /**
  1024. Test to see if a legacy PCI ROM exists for this device. Optionally return
  1025. the Legacy ROM instance for this PCI device.
  1026. @param[in] This The protocol instance pointer.
  1027. @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded
  1028. @param[out] RomImage Return the legacy PCI ROM for this device.
  1029. @param[out] RomSize The size of ROM Image.
  1030. @param[out] Flags Indicates if ROM found and if PC-AT. Multiple bits can be set as follows:
  1031. - 00 = No ROM.
  1032. - 01 = ROM Found.
  1033. - 02 = ROM is a valid legacy ROM.
  1034. @retval EFI_SUCCESS The Legacy Option ROM available for this device
  1035. @retval EFI_UNSUPPORTED The Legacy Option ROM is not supported.
  1036. **/
  1037. typedef
  1038. EFI_STATUS
  1039. (EFIAPI *EFI_LEGACY_BIOS_CHECK_ROM)(
  1040. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1041. IN EFI_HANDLE PciHandle,
  1042. OUT VOID **RomImage, OPTIONAL
  1043. OUT UINTN *RomSize, OPTIONAL
  1044. OUT UINTN *Flags
  1045. );
  1046. /**
  1047. Load a legacy PC-AT OPROM on the PciHandle device. Return information
  1048. about how many disks were added by the OPROM and the shadow address and
  1049. size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
  1050. @param[in] This The protocol instance pointer.
  1051. @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded.
  1052. This value is NULL if RomImage is non-NULL. This is the normal
  1053. case.
  1054. @param[in] RomImage A PCI PC-AT ROM image. This argument is non-NULL if there is
  1055. no hardware associated with the ROM and thus no PciHandle,
  1056. otherwise is must be NULL.
  1057. Example is PXE base code.
  1058. @param[out] Flags The type of ROM discovered. Multiple bits can be set, as follows:
  1059. - 00 = No ROM.
  1060. - 01 = ROM found.
  1061. - 02 = ROM is a valid legacy ROM.
  1062. @param[out] DiskStart The disk number of first device hooked by the ROM. If DiskStart
  1063. is the same as DiskEnd no disked were hooked.
  1064. @param[out] DiskEnd disk number of the last device hooked by the ROM.
  1065. @param[out] RomShadowAddress Shadow address of PC-AT ROM.
  1066. @param[out] RomShadowSize Size of RomShadowAddress in bytes.
  1067. @retval EFI_SUCCESS Thunk completed, see Regs for status.
  1068. @retval EFI_INVALID_PARAMETER PciHandle not found
  1069. **/
  1070. typedef
  1071. EFI_STATUS
  1072. (EFIAPI *EFI_LEGACY_BIOS_INSTALL_ROM)(
  1073. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1074. IN EFI_HANDLE PciHandle,
  1075. IN VOID **RomImage,
  1076. OUT UINTN *Flags,
  1077. OUT UINT8 *DiskStart, OPTIONAL
  1078. OUT UINT8 *DiskEnd, OPTIONAL
  1079. OUT VOID **RomShadowAddress, OPTIONAL
  1080. OUT UINT32 *ShadowedRomSize OPTIONAL
  1081. );
  1082. /**
  1083. This function attempts to traditionally boot the specified BootOption. If the EFI context has
  1084. been compromised, this function will not return. This procedure is not used for loading an EFI-aware
  1085. OS off a traditional device. The following actions occur:
  1086. - Get EFI SMBIOS data structures, convert them to a traditional format, and copy to
  1087. Compatibility16.
  1088. - Get a pointer to ACPI data structures and copy the Compatibility16 RSD PTR to F0000 block.
  1089. - Find the traditional SMI handler from a firmware volume and register the traditional SMI
  1090. handler with the EFI SMI handler.
  1091. - Build onboard IDE information and pass this information to the Compatibility16 code.
  1092. - Make sure all PCI Interrupt Line registers are programmed to match 8259.
  1093. - Reconfigure SIO devices from EFI mode (polled) into traditional mode (interrupt driven).
  1094. - Shadow all PCI ROMs.
  1095. - Set up BDA and EBDA standard areas before the legacy boot.
  1096. - Construct the Compatibility16 boot memory map and pass it to the Compatibility16 code.
  1097. - Invoke the Compatibility16 table function Compatibility16PrepareToBoot(). This
  1098. invocation causes a thunk into the Compatibility16 code, which sets all appropriate internal
  1099. data structures. The boot device list is a parameter.
  1100. - Invoke the Compatibility16 Table function Compatibility16Boot(). This invocation
  1101. causes a thunk into the Compatibility16 code, which does an INT19.
  1102. - If the Compatibility16Boot() function returns, then the boot failed in a graceful
  1103. manner--meaning that the EFI code is still valid. An ungraceful boot failure causes a reset because the state
  1104. of EFI code is unknown.
  1105. @param[in] This The protocol instance pointer.
  1106. @param[in] BootOption The EFI Device Path from BootXXXX variable.
  1107. @param[in] LoadOptionSize The size of LoadOption in size.
  1108. @param[in] LoadOption LThe oadOption from BootXXXX variable.
  1109. @retval EFI_DEVICE_ERROR Failed to boot from any boot device and memory is uncorrupted. Note: This function normally does not returns. It will either boot the OS or reset the system if memory has been "corrupted" by loading a boot sector and passing control to it.
  1110. **/
  1111. typedef
  1112. EFI_STATUS
  1113. (EFIAPI *EFI_LEGACY_BIOS_BOOT)(
  1114. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1115. IN BBS_BBS_DEVICE_PATH *BootOption,
  1116. IN UINT32 LoadOptionsSize,
  1117. IN VOID *LoadOptions
  1118. );
  1119. /**
  1120. This function takes the Leds input parameter and sets/resets the BDA accordingly.
  1121. Leds is also passed to Compatibility16 code, in case any special processing is required.
  1122. This function is normally called from EFI Setup drivers that handle user-selectable
  1123. keyboard options such as boot with NUM LOCK on/off. This function does not
  1124. touch the keyboard or keyboard LEDs but only the BDA.
  1125. @param[in] This The protocol instance pointer.
  1126. @param[in] Leds The status of current Scroll, Num & Cap lock LEDS:
  1127. - Bit 0 is Scroll Lock 0 = Not locked.
  1128. - Bit 1 is Num Lock.
  1129. - Bit 2 is Caps Lock.
  1130. @retval EFI_SUCCESS The BDA was updated successfully.
  1131. **/
  1132. typedef
  1133. EFI_STATUS
  1134. (EFIAPI *EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS)(
  1135. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1136. IN UINT8 Leds
  1137. );
  1138. /**
  1139. Retrieve legacy BBS info and assign boot priority.
  1140. @param[in] This The protocol instance pointer.
  1141. @param[out] HddCount The number of HDD_INFO structures.
  1142. @param[out] HddInfo Onboard IDE controller information.
  1143. @param[out] BbsCount The number of BBS_TABLE structures.
  1144. @param[in,out] BbsTable Points to List of BBS_TABLE.
  1145. @retval EFI_SUCCESS Tables were returned.
  1146. **/
  1147. typedef
  1148. EFI_STATUS
  1149. (EFIAPI *EFI_LEGACY_BIOS_GET_BBS_INFO)(
  1150. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1151. OUT UINT16 *HddCount,
  1152. OUT HDD_INFO **HddInfo,
  1153. OUT UINT16 *BbsCount,
  1154. IN OUT BBS_TABLE **BbsTable
  1155. );
  1156. /**
  1157. Assign drive number to legacy HDD drives prior to booting an EFI
  1158. aware OS so the OS can access drives without an EFI driver.
  1159. @param[in] This The protocol instance pointer.
  1160. @param[out] BbsCount The number of BBS_TABLE structures
  1161. @param[out] BbsTable List of BBS entries
  1162. @retval EFI_SUCCESS Drive numbers assigned.
  1163. **/
  1164. typedef
  1165. EFI_STATUS
  1166. (EFIAPI *EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI)(
  1167. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1168. OUT UINT16 *BbsCount,
  1169. OUT BBS_TABLE **BbsTable
  1170. );
  1171. /**
  1172. To boot from an unconventional device like parties and/or execute
  1173. HDD diagnostics.
  1174. @param[in] This The protocol instance pointer.
  1175. @param[in] Attributes How to interpret the other input parameters.
  1176. @param[in] BbsEntry The 0-based index into the BbsTable for the parent
  1177. device.
  1178. @param[in] BeerData A pointer to the 128 bytes of ram BEER data.
  1179. @param[in] ServiceAreaData A pointer to the 64 bytes of raw Service Area data. The
  1180. caller must provide a pointer to the specific Service
  1181. Area and not the start all Service Areas.
  1182. @retval EFI_INVALID_PARAMETER If error. Does NOT return if no error.
  1183. **/
  1184. typedef
  1185. EFI_STATUS
  1186. (EFIAPI *EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE)(
  1187. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1188. IN UDC_ATTRIBUTES Attributes,
  1189. IN UINTN BbsEntry,
  1190. IN VOID *BeerData,
  1191. IN VOID *ServiceAreaData
  1192. );
  1193. /**
  1194. Shadow all legacy16 OPROMs that haven't been shadowed.
  1195. Warning: Use this with caution. This routine disconnects all EFI
  1196. drivers. If used externally, then the caller must re-connect EFI
  1197. drivers.
  1198. @param[in] This The protocol instance pointer.
  1199. @retval EFI_SUCCESS OPROMs were shadowed.
  1200. **/
  1201. typedef
  1202. EFI_STATUS
  1203. (EFIAPI *EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS)(
  1204. IN EFI_LEGACY_BIOS_PROTOCOL *This
  1205. );
  1206. /**
  1207. Get a region from the LegacyBios for S3 usage.
  1208. @param[in] This The protocol instance pointer.
  1209. @param[in] LegacyMemorySize The size of required region.
  1210. @param[in] Region The region to use.
  1211. 00 = Either 0xE0000 or 0xF0000 block.
  1212. - Bit0 = 1 0xF0000 block.
  1213. - Bit1 = 1 0xE0000 block.
  1214. @param[in] Alignment Address alignment. Bit mapped. The first non-zero
  1215. bit from right is alignment.
  1216. @param[out] LegacyMemoryAddress The Region Assigned
  1217. @retval EFI_SUCCESS The Region was assigned.
  1218. @retval EFI_ACCESS_DENIED The function was previously invoked.
  1219. @retval Other The Region was not assigned.
  1220. **/
  1221. typedef
  1222. EFI_STATUS
  1223. (EFIAPI *EFI_LEGACY_BIOS_GET_LEGACY_REGION)(
  1224. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1225. IN UINTN LegacyMemorySize,
  1226. IN UINTN Region,
  1227. IN UINTN Alignment,
  1228. OUT VOID **LegacyMemoryAddress
  1229. );
  1230. /**
  1231. Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
  1232. @param[in] This The protocol instance pointer.
  1233. @param[in] LegacyMemorySize The size of data to copy.
  1234. @param[in] LegacyMemoryAddress The Legacy Region destination address.
  1235. Note: must be in region assigned by
  1236. LegacyBiosGetLegacyRegion.
  1237. @param[in] LegacyMemorySourceAddress The source of the data to copy.
  1238. @retval EFI_SUCCESS The Region assigned.
  1239. @retval EFI_ACCESS_DENIED Destination was outside an assigned region.
  1240. **/
  1241. typedef
  1242. EFI_STATUS
  1243. (EFIAPI *EFI_LEGACY_BIOS_COPY_LEGACY_REGION)(
  1244. IN EFI_LEGACY_BIOS_PROTOCOL *This,
  1245. IN UINTN LegacyMemorySize,
  1246. IN VOID *LegacyMemoryAddress,
  1247. IN VOID *LegacyMemorySourceAddress
  1248. );
  1249. ///
  1250. /// Abstracts the traditional BIOS from the rest of EFI. The LegacyBoot()
  1251. /// member function allows the BDS to support booting a traditional OS.
  1252. /// EFI thunks drivers that make EFI bindings for BIOS INT services use
  1253. /// all the other member functions.
  1254. ///
  1255. struct _EFI_LEGACY_BIOS_PROTOCOL {
  1256. ///
  1257. /// Performs traditional software INT. See the Int86() function description.
  1258. ///
  1259. EFI_LEGACY_BIOS_INT86 Int86;
  1260. ///
  1261. /// Performs a far call into Compatibility16 or traditional OpROM code.
  1262. ///
  1263. EFI_LEGACY_BIOS_FARCALL86 FarCall86;
  1264. ///
  1265. /// Checks if a traditional OpROM exists for this device.
  1266. ///
  1267. EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom;
  1268. ///
  1269. /// Loads a traditional OpROM in traditional OpROM address space.
  1270. ///
  1271. EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom;
  1272. ///
  1273. /// Boots a traditional OS.
  1274. ///
  1275. EFI_LEGACY_BIOS_BOOT LegacyBoot;
  1276. ///
  1277. /// Updates BDA to reflect the current EFI keyboard LED status.
  1278. ///
  1279. EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus;
  1280. ///
  1281. /// Allows an external agent, such as BIOS Setup, to get the BBS data.
  1282. ///
  1283. EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo;
  1284. ///
  1285. /// Causes all legacy OpROMs to be shadowed.
  1286. ///
  1287. EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms;
  1288. ///
  1289. /// Performs all actions prior to boot. Used when booting an EFI-aware OS
  1290. /// rather than a legacy OS.
  1291. ///
  1292. EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi;
  1293. ///
  1294. /// Allows EFI to reserve an area in the 0xE0000 or 0xF0000 block.
  1295. ///
  1296. EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion;
  1297. ///
  1298. /// Allows EFI to copy data to the area specified by GetLegacyRegion.
  1299. ///
  1300. EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion;
  1301. ///
  1302. /// Allows the user to boot off an unconventional device such as a PARTIES partition.
  1303. ///
  1304. EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice;
  1305. };
  1306. //
  1307. // Legacy BIOS needs to access memory in page 0 (0-4095), which is disabled if
  1308. // NULL pointer detection feature is enabled. Following macro can be used to
  1309. // enable/disable page 0 before/after accessing it.
  1310. //
  1311. #define ACCESS_PAGE0_CODE(statements) \
  1312. do { \
  1313. EFI_STATUS Status_; \
  1314. EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc_; \
  1315. \
  1316. Desc_.Attributes = 0; \
  1317. Status_ = gDS->GetMemorySpaceDescriptor (0, &Desc_); \
  1318. ASSERT_EFI_ERROR (Status_); \
  1319. if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) { \
  1320. Status_ = gDS->SetMemorySpaceAttributes ( \
  1321. 0, \
  1322. EFI_PAGES_TO_SIZE(1), \
  1323. Desc_.Attributes & ~(UINT64)EFI_MEMORY_RP \
  1324. ); \
  1325. ASSERT_EFI_ERROR (Status_); \
  1326. } \
  1327. \
  1328. { \
  1329. statements; \
  1330. } \
  1331. \
  1332. if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) { \
  1333. Status_ = gDS->SetMemorySpaceAttributes ( \
  1334. 0, \
  1335. EFI_PAGES_TO_SIZE(1), \
  1336. Desc_.Attributes \
  1337. ); \
  1338. ASSERT_EFI_ERROR (Status_); \
  1339. } \
  1340. } while (FALSE)
  1341. extern EFI_GUID gEfiLegacyBiosProtocolGuid;
  1342. #endif