]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkPkg/Include/Protocol/LegacyBios.h
Use .radix directive that GCC assembly supports.
[mirror_edk2.git] / IntelFrameworkPkg / Include / Protocol / LegacyBios.h
CommitLineData
79964ac8 1/** @file\r
2 The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage\r
3 under EFI and Legacy OS boot.\r
4\r
5 Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow\r
6 well known naming conventions.\r
7\r
8 Thunk - A thunk is a transition from one processor mode to another. A Thunk\r
9 is a transition from native EFI mode to 16-bit mode. A reverse thunk\r
10 would be a transition from 16-bit mode to native EFI mode.\r
11\r
12 You most likely should not use this protocol! Find the EFI way to solve the\r
13 problem to make your code portable\r
14\r
15 Copyright (c) 2007, Intel Corporation\r
16 All rights reserved. This program and the accompanying materials\r
17 are licensed and made available under the terms and conditions of the BSD License\r
18 which accompanies this distribution. The full text of the license may be found at\r
19 http://opensource.org/licenses/bsd-license.php\r
20\r
21 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
22 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
23\r
24 Module Name: LegacyBios.h\r
25\r
26 @par Revision Reference:\r
27 This protocol is defined in Framework for EFI Compatibility Support Module spec\r
28 Version 0.96\r
29\r
30**/\r
31\r
32#ifndef _EFI_LEGACY_BIOS_H_\r
33#define _EFI_LEGACY_BIOS_H_\r
34\r
b80fbe85 35#include <FrameworkDxe.h>\r
36\r
79964ac8 37#define EFI_LEGACY_BIOS_PROTOCOL_GUID \\r
38 { \\r
39 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d } \\r
40 }\r
41\r
42typedef struct _EFI_LEGACY_BIOS_PROTOCOL EFI_LEGACY_BIOS_PROTOCOL;\r
43\r
44//\r
45/// @bug: These macros appear in no specifications and are kept for backward\r
46// compatibility only.\r
47// Convert from 32-bit address (_Adr) to Segment:Offset 16-bit form\r
48//\r
49#define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)\r
50#define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)\r
51#define BYTE_GRANULARITY 0x01\r
52#define WORD_GRANULARITY 0x02\r
53#define DWORD_GRANULARITY 0x04\r
54#define QWORD_GRANULARITY 0x08\r
55#define PARAGRAPH_GRANULARITY 0x10\r
56\r
57#define CARRY_FLAG 0x01\r
58\r
59//*********************************************************\r
60// EFI_EFLAGS_REG\r
61//*********************************************************\r
62typedef struct {\r
63 UINT32 CF:1;\r
64 UINT32 Reserved1:1;\r
65 UINT32 PF:1;\r
66 UINT32 Reserved2:1;\r
67 UINT32 AF:1;\r
68 UINT32 Reserved3:1;\r
69 UINT32 ZF:1;\r
70 UINT32 SF:1;\r
71 UINT32 TF:1;\r
72 UINT32 IF:1;\r
73 UINT32 DF:1;\r
74 UINT32 OF:1;\r
75 UINT32 IOPL:2;\r
76 UINT32 NT:1;\r
77 UINT32 Reserved4:2;\r
78 UINT32 VM:1;\r
79 UINT32 Reserved5:14;\r
80} EFI_EFLAGS_REG;\r
81\r
82//*********************************************************\r
83// EFI_DWORD_REGS\r
84//*********************************************************\r
85\r
86typedef struct {\r
87 UINT32 EAX;\r
88 UINT32 EBX;\r
89 UINT32 ECX;\r
90 UINT32 EDX;\r
91 UINT32 ESI;\r
92 UINT32 EDI;\r
93 EFI_EFLAGS_REG EFlags;\r
94 UINT16 ES;\r
95 UINT16 CS;\r
96 UINT16 SS;\r
97 UINT16 DS;\r
98 UINT16 FS;\r
99 UINT16 GS;\r
100 UINT32 EBP;\r
101 UINT32 ESP;\r
102} EFI_DWORD_REGS;\r
103\r
104//*******************************************\r
105// EFI_FLAGS_REG\r
106//*******************************************\r
107typedef struct {\r
108 UINT16 CF:1;\r
109 UINT16 Reserved1:1;\r
110 UINT16 PF:1;\r
111 UINT16 Reserved2:1;\r
112 UINT16 AF:1;\r
113 UINT16 Reserved3:1;\r
114 UINT16 ZF:1;\r
115 UINT16 SF:1;\r
116 UINT16 TF:1;\r
117 UINT16 IF:1;\r
118 UINT16 DF:1;\r
119 UINT16 OF:1;\r
120 UINT16 IOPL:2;\r
121 UINT16 NT:1;\r
122 UINT16 Reserved4:1;\r
123} EFI_FLAGS_REG;\r
124\r
125\r
126//*********************************************************\r
127// EFI_WORD_REGS\r
128//*********************************************************\r
129\r
130typedef struct {\r
131 UINT16 AX;\r
132 UINT16 ReservedAX;\r
133 UINT16 BX;\r
134 UINT16 ReservedBX;\r
135 UINT16 CX;\r
136 UINT16 ReservedCX;\r
137 UINT16 DX;\r
138 UINT16 ReservedDX;\r
139 UINT16 SI;\r
140 UINT16 ReservedSI;\r
141 UINT16 DI;\r
142 UINT16 ReservedDI;\r
143 EFI_FLAGS_REG Flags;\r
144 UINT16 ReservedFlags;\r
145 UINT16 ES;\r
146 UINT16 CS;\r
147 UINT16 SS;\r
148 UINT16 DS;\r
149 UINT16 FS;\r
150 UINT16 GS;\r
151 UINT16 BP;\r
152 UINT16 ReservedBP;\r
153 UINT16 SP;\r
154 UINT16 ReservedSP;\r
155} EFI_WORD_REGS;\r
156\r
157//*********************************************************\r
158// EFI_BYTE_REGS\r
159//*********************************************************\r
160\r
161typedef struct {\r
162 UINT8 AL, AH;\r
163 UINT16 ReservedAX;\r
164 UINT8 BL, BH;\r
165 UINT16 ReservedBX;\r
166 UINT8 CL, CH;\r
167 UINT16 ReservedCX;\r
168 UINT8 DL, DH;\r
169 UINT16 ReservedDX;\r
170} EFI_BYTE_REGS;\r
171\r
172typedef union {\r
173 EFI_DWORD_REGS E;\r
174 EFI_WORD_REGS X;\r
175 EFI_BYTE_REGS H;\r
176} EFI_IA32_REGISTER_SET;\r
177\r
178/**\r
179 Thunk to 16-bit real mode and execute a software interrupt with a vector\r
180 of BiosInt. Regs will contain the 16-bit register context on entry and\r
181 exit.\r
182\r
183 @param This Protocol instance pointer.\r
184 @param BiosInt Processor interrupt vector to invoke\r
185 @param Reg Register contexted passed into (and returned) from thunk to\r
186 16-bit mode\r
187\r
188 @retval FALSE Thunk completed, and there were no BIOS errors in the target code.\r
189 See Regs for status.\r
190 @retval TRUE There was a BIOS erro in the target code.\r
191\r
192**/\r
193typedef\r
194BOOLEAN\r
69686d56 195(EFIAPI *EFI_LEGACY_BIOS_INT86)(\r
79964ac8 196 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
197 IN UINT8 BiosInt,\r
198 IN OUT EFI_IA32_REGISTER_SET *Regs\r
199 );\r
200\r
201/**\r
202 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the\r
203 16-bit register context on entry and exit. Arguments can be passed on\r
204 the Stack argument\r
205\r
206 @param This Protocol instance pointer.\r
207 @param Segment Segemnt of 16-bit mode call\r
208 @param Offset Offset of 16-bit mdoe call\r
209 @param Reg Register contexted passed into (and returned) from thunk to\r
210 16-bit mode\r
211 @param Stack Caller allocated stack used to pass arguments\r
212 @param StackSize Size of Stack in bytes\r
213\r
214 @retval FALSE Thunk completed, and there were no BIOS errors in the target code.\r
215 See Regs for status.\r
216 @retval TRUE There was a BIOS erro in the target code.\r
217\r
218**/\r
219typedef\r
220BOOLEAN\r
69686d56 221(EFIAPI *EFI_LEGACY_BIOS_FARCALL86)(\r
79964ac8 222 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
223 IN UINT16 Segment,\r
224 IN UINT16 Offset,\r
225 IN EFI_IA32_REGISTER_SET *Regs,\r
226 IN VOID *Stack,\r
227 IN UINTN StackSize\r
228 );\r
229\r
230/**\r
231 Test to see if a legacy PCI ROM exists for this device. Optionally return\r
232 the Legacy ROM instance for this PCI device.\r
233\r
234 @param This Protocol instance pointer.\r
235 @param PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded\r
236 @param RomImage Return the legacy PCI ROM for this device\r
237 @param RomSize Size of ROM Image\r
238 @param Flags Indicates if ROM found and if PC-AT.\r
239\r
240 @retval EFI_SUCCESS Legacy Option ROM availible for this device\r
241 @retval EFI_UNSUPPORTED Legacy Option ROM not supported.\r
242\r
243**/\r
244typedef\r
245EFI_STATUS\r
69686d56 246(EFIAPI *EFI_LEGACY_BIOS_CHECK_ROM)(\r
79964ac8 247 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
248 IN EFI_HANDLE PciHandle,\r
249 OUT VOID **RomImage, OPTIONAL\r
250 OUT UINTN *RomSize, OPTIONAL\r
251 OUT UINTN *Flags\r
252 );\r
253\r
254/**\r
255 Load a legacy PC-AT OPROM on the PciHandle device. Return information\r
256 about how many disks were added by the OPROM and the shadow address and\r
257 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:\r
258\r
259 @param This Protocol instance pointer.\r
260 @param PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded.\r
261 This value is NULL if RomImage is non-NULL. This is the normal\r
262 case.\r
263 @param RomImage A PCI PC-AT ROM image. This argument is non-NULL if there is\r
264 no hardware associated with the ROM and thus no PciHandle,\r
265 otherwise is must be NULL.\r
266 Example is PXE base code.\r
267 @param Flags Return Status if ROM was found and if was Legacy OPROM.\r
268 @param DiskStart Disk number of first device hooked by the ROM. If DiskStart\r
269 is the same as DiskEnd no disked were hooked.\r
270 @param DiskEnd Disk number of the last device hooked by the ROM.\r
271 @param RomShadowAddress Shadow address of PC-AT ROM\r
272 @param RomShadowSize Size of RomShadowAddress in bytes\r
273\r
274 @retval EFI_SUCCESS Thunk completed, see Regs for status.\r
275 @retval EFI_INVALID_PARAMETER PciHandle not found\r
276\r
277**/\r
278typedef\r
279EFI_STATUS\r
69686d56 280(EFIAPI *EFI_LEGACY_BIOS_INSTALL_ROM)(\r
79964ac8 281 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
282 IN EFI_HANDLE PciHandle,\r
283 IN VOID **RomImage,\r
284 OUT UINTN *Flags,\r
285 OUT UINT8 *DiskStart, OPTIONAL\r
286 OUT UINT8 *DiskEnd, OPTIONAL\r
287 OUT VOID **RomShadowAddress, OPTIONAL\r
288 OUT UINT32 *ShadowedRomSize OPTIONAL\r
289 );\r
290\r
291/**\r
292 Attempt to legacy boot the BootOption. If the EFI contexted has been\r
293 compromised this function will not return.\r
294\r
295 @param This Protocol instance pointer.\r
296 @param BootOption EFI Device Path from BootXXXX variable.\r
297 @param LoadOptionSize Size of LoadOption in size.\r
298 @param LoadOption LoadOption from BootXXXX variable\r
299\r
300 @retval EFI_SUCCESS Removable media not present\r
301\r
302**/\r
303typedef\r
304EFI_STATUS\r
69686d56 305(EFIAPI *EFI_LEGACY_BIOS_BOOT)(\r
79964ac8 306 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
307 IN BBS_BBS_DEVICE_PATH *BootOption,\r
308 IN UINT32 LoadOptionsSize,\r
309 IN VOID *LoadOptions\r
310 );\r
311\r
312/**\r
313 Update BDA with current Scroll, Num & Cap lock LEDS\r
314\r
315 @param This Protocol instance pointer.\r
316 @param Leds Status of current Scroll, Num & Cap lock LEDS\r
317 Bit 0 is Scroll Lock 0 = Not locked\r
318 Bit 1 is Num Lock\r
319 Bit 2 is Caps Lock\r
320\r
321 @retval EFI_SUCCESS Removable media not present\r
322\r
323**/\r
324typedef\r
325EFI_STATUS\r
69686d56 326(EFIAPI *EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS)(\r
79964ac8 327 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
328 IN UINT8 Leds\r
329 );\r
330\r
331/**\r
332 Retrieve legacy BBS info and assign boot priority.\r
333\r
334 @param This Protocol instance pointer.\r
335 @param HddCount Number of HDD_INFO structures\r
336 @param HddInfo Onboard IDE controller information\r
337 @param BbsCount Number of BBS_TABLE structures\r
338 @param BbsTable List BBS entries\r
339\r
340 @retval EFI_SUCCESS Tables returned\r
341\r
342**/\r
343typedef\r
344EFI_STATUS\r
69686d56 345(EFIAPI *EFI_LEGACY_BIOS_GET_BBS_INFO)(\r
79964ac8 346 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
347 OUT UINT16 *HddCount,\r
348 OUT HDD_INFO **HddInfo,\r
349 OUT UINT16 *BbsCount,\r
350 IN OUT BBS_TABLE **BbsTable\r
351 );\r
352\r
353/**\r
354 Assign drive number to legacy HDD drives prior to booting an EFI\r
355 aware OS so the OS can access drives without an EFI driver.\r
356\r
357 @param This Protocol instance pointer.\r
358 @param BbsCount Number of BBS_TABLE structures\r
359 @param BbsTable List BBS entries\r
360\r
361 @retval EFI_SUCCESS Drive numbers assigned\r
362\r
363**/\r
364typedef\r
365EFI_STATUS\r
69686d56 366(EFIAPI *EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI)(\r
79964ac8 367 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
368 OUT UINT16 *BbsCount,\r
369 OUT BBS_TABLE **BbsTable\r
370 );\r
371\r
372/**\r
373 To boot from an unconventional device like parties and/or execute\r
374 HDD diagnostics.\r
375\r
376 @param This Protocol instance pointer.\r
377 @param Attributes How to interpret the other input parameters\r
378 @param BbsEntry The 0-based index into the BbsTable for the parent\r
379 device.\r
380 @param BeerData Pointer to the 128 bytes of ram BEER data.\r
381 @param ServiceAreaData Pointer to the 64 bytes of raw Service Area data. The\r
382 caller must provide a pointer to the specific Service\r
383 Area and not the start all Service Areas.\r
384\r
385 EFI_INVALID_PARAMETER if error. Does NOT return if no error.\r
386\r
387**/\r
388typedef\r
389EFI_STATUS\r
69686d56 390(EFIAPI *EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE)(\r
79964ac8 391 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
392 IN UDC_ATTRIBUTES Attributes,\r
393 IN UINTN BbsEntry,\r
394 IN VOID *BeerData,\r
395 IN VOID *ServiceAreaData\r
396 );\r
397\r
398/**\r
399 Shadow all legacy16 OPROMs that haven't been shadowed.\r
400 Warning: Use this with caution. This routine disconnects all EFI\r
401 drivers. If used externally then caller must re-connect EFI\r
402 drivers.\r
403\r
404 @retval EFI_SUCCESS OPROMs shadowed\r
405\r
406**/\r
407typedef\r
408EFI_STATUS\r
69686d56 409(EFIAPI *EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS)(\r
79964ac8 410 IN EFI_LEGACY_BIOS_PROTOCOL *This\r
411 );\r
412\r
413/**\r
414 Get a region from the LegacyBios for S3 usage.\r
415\r
416 @param This Protocol instance pointer.\r
417 @param LegacyMemorySize Size of required region\r
418 @param Region Region to use.\r
419 00 = Either 0xE0000 or 0xF0000 block\r
420 Bit0 = 1 0xF0000 block\r
421 Bit1 = 1 0xE0000 block\r
422 @param Alignment Address alignment. Bit mapped. First non-zero\r
423 bit from right is alignment.\r
424 @param LegacyMemoryAddress Region Assigned\r
425\r
426 @retval EFI_SUCCESS Region assigned\r
427 @retval Other Region not assigned\r
428\r
429**/\r
430typedef\r
431EFI_STATUS\r
69686d56 432(EFIAPI *EFI_LEGACY_BIOS_GET_LEGACY_REGION)(\r
79964ac8 433 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
434 IN UINTN LegacyMemorySize,\r
435 IN UINTN Region,\r
436 IN UINTN Alignment,\r
437 OUT VOID **LegacyMemoryAddress\r
438 );\r
439\r
440/**\r
441 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.\r
442\r
443 @param This Protocol instance pointer.\r
444 @param LegacyMemorySize Size of data to copy\r
445 @param LegacyMemoryAddress Legacy Region destination address\r
446 Note: must be in region assigned by\r
447 LegacyBiosGetLegacyRegion\r
448 @param LegacyMemorySourceAddress\r
449 Source of data\r
450\r
451 @retval EFI_SUCCESS Region assigned\r
452 @retval EFI_ACCESS_DENIED Destination outside assigned region\r
453\r
454**/\r
455typedef\r
456EFI_STATUS\r
69686d56 457(EFIAPI *EFI_LEGACY_BIOS_COPY_LEGACY_REGION)(\r
79964ac8 458 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
459 IN UINTN LegacyMemorySize,\r
460 IN VOID *LegacyMemoryAddress,\r
461 IN VOID *LegacyMemorySourceAddress\r
462 );\r
463\r
464/**\r
465 @par Protocol Description:\r
466 Abstracts the traditional BIOS from the rest of EFI. The LegacyBoot()\r
467 member function allows the BDS to support booting a traditional OS.\r
468 EFI thunks drivers that make EFI bindings for BIOS INT services use\r
469 all the other member functions.\r
470\r
471 @param Int86\r
472 Performs traditional software INT. See the Int86() function description.\r
473\r
474 @param FarCall86\r
475 Performs a far call into Compatibility16 or traditional OpROM code.\r
476\r
477 @param CheckPciRom\r
478 Checks if a traditional OpROM exists for this device.\r
479\r
480 @param InstallPciRom\r
481 Loads a traditional OpROM in traditional OpROM address space.\r
482\r
483 @param LegacyBoot\r
484 Boots a traditional OS.\r
485\r
486 @param UpdateKeyboardLedStatus\r
487 Updates BDA to reflect the current EFI keyboard LED status.\r
488\r
489 @param GetBbsInfo\r
490 Allows an external agent, such as BIOS Setup, to get the BBS data.\r
491\r
492 @param ShadowAllLegacyOproms\r
493 Causes all legacy OpROMs to be shadowed.\r
494\r
495 @param PrepareToBootEfi\r
496 Performs all actions prior to boot. Used when booting an EFI-aware OS\r
497 rather than a legacy OS.\r
498\r
499 @param GetLegacyRegion\r
500 Allows EFI to reserve an area in the 0xE0000 or 0xF0000 block.\r
501\r
502 @param CopyLegacyRegion\r
503 Allows EFI to copy data to the area specified by GetLegacyRegion.\r
504\r
505 @param BootUnconventionalDevice\r
506 Allows the user to boot off an unconventional device such as a PARTIES partition.\r
507\r
508**/\r
509struct _EFI_LEGACY_BIOS_PROTOCOL {\r
510 EFI_LEGACY_BIOS_INT86 Int86;\r
511 EFI_LEGACY_BIOS_FARCALL86 FarCall86;\r
512 EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom;\r
513 EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom;\r
514 EFI_LEGACY_BIOS_BOOT LegacyBoot;\r
515 EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus;\r
516 EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo;\r
517 EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms;\r
518 EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi;\r
519 EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion;\r
520 EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion;\r
521 EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice;\r
522};\r
523\r
524extern EFI_GUID gEfiLegacyBiosProtocolGuid;\r
525\r
526#endif\r