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