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