]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Csm / LegacyBiosDxe / LegacyBiosInterface.h
1 /** @file
2
3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _LEGACY_BIOS_INTERFACE_
10 #define _LEGACY_BIOS_INTERFACE_
11
12 #include <FrameworkDxe.h>
13 #include <IndustryStandard/Pci.h>
14 #include <IndustryStandard/SmBios.h>
15 #include <IndustryStandard/Acpi10.h>
16
17 #include <Guid/SmBios.h>
18 #include <Guid/Acpi.h>
19 #include <Guid/DxeServices.h>
20 #include <Guid/LegacyBios.h>
21 #include <Guid/StatusCodeDataTypeId.h>
22 #include <Guid/ImageAuthentication.h>
23
24 #include <Protocol/BlockIo.h>
25 #include <Protocol/LoadedImage.h>
26 #include <Protocol/PciIo.h>
27 #include <Protocol/Cpu.h>
28 #include <Protocol/Timer.h>
29 #include <Protocol/IsaIo.h>
30 #include <Protocol/LegacyRegion2.h>
31 #include <Protocol/SimpleTextIn.h>
32 #include <Protocol/LegacyInterrupt.h>
33 #include <Protocol/LegacyBios.h>
34 #include <Protocol/DiskInfo.h>
35 #include <Protocol/GenericMemoryTest.h>
36 #include <Protocol/LegacyBiosPlatform.h>
37 #include <Protocol/DevicePath.h>
38 #include <Protocol/Legacy8259.h>
39 #include <Protocol/PciRootBridgeIo.h>
40 #include <Protocol/SerialIo.h>
41 #include <Protocol/SuperIo.h>
42 #include <Protocol/IoMmu.h>
43
44 #include <Library/BaseLib.h>
45 #include <Library/DebugLib.h>
46 #include <Library/UefiLib.h>
47 #include <Library/BaseMemoryLib.h>
48 #include <Library/ReportStatusCodeLib.h>
49 #include <Library/UefiRuntimeServicesTableLib.h>
50 #include <Library/HobLib.h>
51 #include <Library/UefiDriverEntryPoint.h>
52 #include <Library/MemoryAllocationLib.h>
53 #include <Library/UefiBootServicesTableLib.h>
54 #include <Library/IoLib.h>
55 #include <Library/PcdLib.h>
56 #include <Library/DevicePathLib.h>
57 #include <Library/DxeServicesTableLib.h>
58 #include <Library/DebugAgentLib.h>
59
60 //
61 // BUGBUG: This entry maybe changed to PCD in future and wait for
62 // redesign of BDS library
63 //
64 #define MAX_BBS_ENTRIES 0x100
65
66 //
67 // Thunk Status Codes
68 // (These apply only to errors with the thunk and not to the code that was
69 // thunked to.)
70 //
71 #define THUNK_OK 0x00
72 #define THUNK_ERR_A20_UNSUP 0x01
73 #define THUNK_ERR_A20_FAILED 0x02
74
75 //
76 // Vector base definitions
77 //
78 //
79 // 8259 Hardware definitions
80 //
81 #define LEGACY_MODE_BASE_VECTOR_MASTER 0x08
82 #define LEGACY_MODE_BASE_VECTOR_SLAVE 0x70
83
84 //
85 // The original PC used INT8-F for master PIC. Since these mapped over
86 // processor exceptions TIANO moved the master PIC to INT68-6F.
87 //
88 // The vector base for slave PIC is set as 0x70 for PC-AT compatibility.
89 //
90 #define PROTECTED_MODE_BASE_VECTOR_MASTER 0x68
91 #define PROTECTED_MODE_BASE_VECTOR_SLAVE 0x70
92
93 //
94 // When we call CSM16 functions, some CSM16 use es:[offset + 0xabcd] to get data passed from CSM32,
95 // offset + 0xabcd could overflow which exceeds 0xFFFF which is invalid in real mode.
96 // So this will keep offset as small as possible to avoid offset overflow in real mode.
97 //
98 #define NORMALIZE_EFI_SEGMENT(_Adr) (UINT16) (((UINTN) (_Adr)) >> 4)
99 #define NORMALIZE_EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xf)
100
101 //
102 // Trace defines
103 //
104 //
105 #define LEGACY_BDA_TRACE 0x000
106 #define LEGACY_BIOS_TRACE 0x040
107 #define LEGACY_BOOT_TRACE 0x080
108 #define LEGACY_CMOS_TRACE 0x0C0
109 #define LEGACY_IDE_TRACE 0x100
110 #define LEGACY_MP_TRACE 0x140
111 #define LEGACY_PCI_TRACE 0x180
112 #define LEGACY_SIO_TRACE 0x1C0
113
114 #define LEGACY_PCI_TRACE_000 LEGACY_PCI_TRACE + 0x00
115 #define LEGACY_PCI_TRACE_001 LEGACY_PCI_TRACE + 0x01
116 #define LEGACY_PCI_TRACE_002 LEGACY_PCI_TRACE + 0x02
117 #define LEGACY_PCI_TRACE_003 LEGACY_PCI_TRACE + 0x03
118 #define LEGACY_PCI_TRACE_004 LEGACY_PCI_TRACE + 0x04
119 #define LEGACY_PCI_TRACE_005 LEGACY_PCI_TRACE + 0x05
120 #define LEGACY_PCI_TRACE_006 LEGACY_PCI_TRACE + 0x06
121 #define LEGACY_PCI_TRACE_007 LEGACY_PCI_TRACE + 0x07
122 #define LEGACY_PCI_TRACE_008 LEGACY_PCI_TRACE + 0x08
123 #define LEGACY_PCI_TRACE_009 LEGACY_PCI_TRACE + 0x09
124 #define LEGACY_PCI_TRACE_00A LEGACY_PCI_TRACE + 0x0A
125 #define LEGACY_PCI_TRACE_00B LEGACY_PCI_TRACE + 0x0B
126 #define LEGACY_PCI_TRACE_00C LEGACY_PCI_TRACE + 0x0C
127 #define LEGACY_PCI_TRACE_00D LEGACY_PCI_TRACE + 0x0D
128 #define LEGACY_PCI_TRACE_00E LEGACY_PCI_TRACE + 0x0E
129 #define LEGACY_PCI_TRACE_00F LEGACY_PCI_TRACE + 0x0F
130
131 #define BDA_VIDEO_MODE 0x49
132
133 #define IDE_PI_REGISTER_PNE BIT0
134 #define IDE_PI_REGISTER_SNE BIT2
135
136 typedef struct {
137 UINTN PciSegment;
138 UINTN PciBus;
139 UINTN PciDevice;
140 UINTN PciFunction;
141 UINT32 ShadowAddress;
142 UINT32 ShadowedSize;
143 UINT8 DiskStart;
144 UINT8 DiskEnd;
145 } ROM_INSTANCE_ENTRY;
146
147 //
148 // Values for RealModeGdt
149 //
150 #if defined (MDE_CPU_IA32)
151
152 #define NUM_REAL_GDT_ENTRIES 3
153 #define CONVENTIONAL_MEMORY_TOP 0xA0000 // 640 KB
154 #define INITIAL_VALUE_BELOW_1K 0x0
155
156 #elif defined (MDE_CPU_X64)
157
158 #define NUM_REAL_GDT_ENTRIES 8
159 #define CONVENTIONAL_MEMORY_TOP 0xA0000 // 640 KB
160 #define INITIAL_VALUE_BELOW_1K 0x0
161
162 #endif
163
164 #pragma pack(1)
165
166 //
167 // Define what a processor GDT looks like
168 //
169 typedef struct {
170 UINT32 LimitLo : 16;
171 UINT32 BaseLo : 16;
172 UINT32 BaseMid : 8;
173 UINT32 Type : 4;
174 UINT32 System : 1;
175 UINT32 Dpl : 2;
176 UINT32 Present : 1;
177 UINT32 LimitHi : 4;
178 UINT32 Software : 1;
179 UINT32 Reserved : 1;
180 UINT32 DefaultSize : 1;
181 UINT32 Granularity : 1;
182 UINT32 BaseHi : 8;
183 } GDT32;
184
185 typedef struct {
186 UINT16 LimitLow;
187 UINT16 BaseLow;
188 UINT8 BaseMid;
189 UINT8 Attribute;
190 UINT8 LimitHi;
191 UINT8 BaseHi;
192 } GDT64;
193
194 //
195 // Define what a processor descriptor looks like
196 // This data structure must be kept in sync with ASM STRUCT in Thunk.inc
197 //
198 typedef struct {
199 UINT16 Limit;
200 UINT64 Base;
201 } DESCRIPTOR64;
202
203 typedef struct {
204 UINT16 Limit;
205 UINT32 Base;
206 } DESCRIPTOR32;
207
208 //
209 // Low stub lay out
210 //
211 #define LOW_STACK_SIZE (8 * 1024) // 8k?
212 #define EFI_MAX_E820_ENTRY 100
213 #define FIRST_INSTANCE 1
214 #define NOT_FIRST_INSTANCE 0
215
216 #if defined (MDE_CPU_IA32)
217 typedef struct {
218 //
219 // Space for the code
220 // The address of Code is also the beginning of the relocated Thunk code
221 //
222 CHAR8 Code[4096]; // ?
223 //
224 // The address of the Reverse Thunk code
225 // Note that this member CONTAINS the address of the relocated reverse thunk
226 // code unlike the member variable 'Code', which IS the address of the Thunk
227 // code.
228 //
229 UINT32 LowReverseThunkStart;
230
231 //
232 // Data for the code (cs releative)
233 //
234 DESCRIPTOR32 GdtDesc; // Protected mode GDT
235 DESCRIPTOR32 IdtDesc; // Protected mode IDT
236 UINT32 FlatSs;
237 UINT32 FlatEsp;
238
239 UINT32 LowCodeSelector; // Low code selector in GDT
240 UINT32 LowDataSelector; // Low data selector in GDT
241 UINT32 LowStack;
242 DESCRIPTOR32 RealModeIdtDesc;
243
244 //
245 // real-mode GDT (temporary GDT with two real mode segment descriptors)
246 //
247 GDT32 RealModeGdt[NUM_REAL_GDT_ENTRIES];
248 DESCRIPTOR32 RealModeGdtDesc;
249
250 //
251 // Members specifically for the reverse thunk
252 // The RevReal* members are used to store the current state of real mode
253 // before performing the reverse thunk. The RevFlat* members must be set
254 // before calling the reverse thunk assembly code.
255 //
256 UINT16 RevRealDs;
257 UINT16 RevRealSs;
258 UINT32 RevRealEsp;
259 DESCRIPTOR32 RevRealIdtDesc;
260 UINT16 RevFlatDataSelector; // Flat data selector in GDT
261 UINT32 RevFlatStack;
262
263 //
264 // A low memory stack
265 //
266 CHAR8 Stack[LOW_STACK_SIZE];
267
268 //
269 // Stack for flat mode after reverse thunk
270 // @bug - This may no longer be necessary if the reverse thunk interface
271 // is changed to have the flat stack in a different location.
272 //
273 CHAR8 RevThunkStack[LOW_STACK_SIZE];
274
275 //
276 // Legacy16 Init memory map info
277 //
278 EFI_TO_COMPATIBILITY16_INIT_TABLE EfiToLegacy16InitTable;
279
280 EFI_TO_COMPATIBILITY16_BOOT_TABLE EfiToLegacy16BootTable;
281
282 CHAR8 InterruptRedirectionCode[32];
283 EFI_LEGACY_INSTALL_PCI_HANDLER PciHandler;
284 EFI_DISPATCH_OPROM_TABLE DispatchOpromTable;
285 BBS_TABLE BbsTable[MAX_BBS_ENTRIES];
286 } LOW_MEMORY_THUNK;
287
288 #elif defined (MDE_CPU_X64)
289
290 typedef struct {
291 //
292 // Space for the code
293 // The address of Code is also the beginning of the relocated Thunk code
294 //
295 CHAR8 Code[4096]; // ?
296
297 //
298 // Data for the code (cs releative)
299 //
300 DESCRIPTOR64 X64GdtDesc; // Protected mode GDT
301 DESCRIPTOR64 X64IdtDesc; // Protected mode IDT
302 UINTN X64Ss;
303 UINTN X64Esp;
304
305 UINTN RealStack;
306 DESCRIPTOR32 RealModeIdtDesc;
307 DESCRIPTOR32 RealModeGdtDesc;
308
309 //
310 // real-mode GDT (temporary GDT with two real mode segment descriptors)
311 //
312 GDT64 RealModeGdt[NUM_REAL_GDT_ENTRIES];
313 UINT64 PageMapLevel4;
314
315 //
316 // A low memory stack
317 //
318 CHAR8 Stack[LOW_STACK_SIZE];
319
320 //
321 // Legacy16 Init memory map info
322 //
323 EFI_TO_COMPATIBILITY16_INIT_TABLE EfiToLegacy16InitTable;
324
325 EFI_TO_COMPATIBILITY16_BOOT_TABLE EfiToLegacy16BootTable;
326
327 CHAR8 InterruptRedirectionCode[32];
328 EFI_LEGACY_INSTALL_PCI_HANDLER PciHandler;
329 EFI_DISPATCH_OPROM_TABLE DispatchOpromTable;
330 BBS_TABLE BbsTable[MAX_BBS_ENTRIES];
331 } LOW_MEMORY_THUNK;
332
333 #endif
334
335 //
336 // PnP Expansion Header
337 //
338 typedef struct {
339 UINT32 PnpSignature;
340 UINT8 Revision;
341 UINT8 Length;
342 UINT16 NextHeader;
343 UINT8 Reserved1;
344 UINT8 Checksum;
345 UINT32 DeviceId;
346 UINT16 MfgPointer;
347 UINT16 ProductNamePointer;
348 UINT8 Class;
349 UINT8 SubClass;
350 UINT8 Interface;
351 UINT8 DeviceIndicators;
352 UINT16 Bcv;
353 UINT16 DisconnectVector;
354 UINT16 Bev;
355 UINT16 Reserved2;
356 UINT16 StaticResourceVector;
357 } LEGACY_PNP_EXPANSION_HEADER;
358
359 typedef struct {
360 UINT8 PciSegment;
361 UINT8 PciBus;
362 UINT8 PciDevice;
363 UINT8 PciFunction;
364 UINT16 Vid;
365 UINT16 Did;
366 UINT16 SysSid;
367 UINT16 SVid;
368 UINT8 Class;
369 UINT8 SubClass;
370 UINT8 Interface;
371 UINT8 Reserved;
372 UINTN RomStart;
373 UINTN ManufacturerString;
374 UINTN ProductNameString;
375 } LEGACY_ROM_AND_BBS_TABLE;
376
377 //
378 // Structure how EFI has mapped a devices HDD drive numbers.
379 // Boot to EFI aware OS or shell requires this mapping when
380 // 16-bit CSM assigns drive numbers.
381 // This mapping is ignored booting to a legacy OS.
382 //
383 typedef struct {
384 UINT8 PciSegment;
385 UINT8 PciBus;
386 UINT8 PciDevice;
387 UINT8 PciFunction;
388 UINT8 StartDriveNumber;
389 UINT8 EndDriveNumber;
390 } LEGACY_EFI_HDD_TABLE;
391
392 //
393 // This data is passed to Leacy16Boot
394 //
395 typedef enum {
396 EfiAcpiAddressRangeMemory = 1,
397 EfiAcpiAddressRangeReserved = 2,
398 EfiAcpiAddressRangeACPI = 3,
399 EfiAcpiAddressRangeNVS = 4,
400 EfiAddressRangePersistentMemory = 7
401 } EFI_ACPI_MEMORY_TYPE;
402
403 typedef struct {
404 UINT64 BaseAddr;
405 UINT64 Length;
406 EFI_ACPI_MEMORY_TYPE Type;
407 } EFI_E820_ENTRY64;
408
409 typedef struct {
410 UINT32 BassAddrLow;
411 UINT32 BaseAddrHigh;
412 UINT32 LengthLow;
413 UINT32 LengthHigh;
414 EFI_ACPI_MEMORY_TYPE Type;
415 } EFI_E820_ENTRY;
416
417 #pragma pack()
418
419 extern BBS_TABLE *mBbsTable;
420
421 extern EFI_GENERIC_MEMORY_TEST_PROTOCOL *gGenMemoryTest;
422
423 extern BOOLEAN mEndOfDxe;
424
425 #define PORT_70 0x70
426 #define PORT_71 0x71
427
428 #define CMOS_0A 0x0a ///< Status register A
429 #define CMOS_0D 0x0d ///< Status register D
430 #define CMOS_0E 0x0e ///< Diagnostic Status
431 #define CMOS_0F 0x0f ///< Shutdown status
432 #define CMOS_10 0x10 ///< Floppy type
433 #define CMOS_12 0x12 ///< IDE type
434 #define CMOS_14 0x14 ///< Same as BDA 40:10
435 #define CMOS_15 0x15 ///< Low byte of base memory in 1k increments
436 #define CMOS_16 0x16 ///< High byte of base memory in 1k increments
437 #define CMOS_17 0x17 ///< Low byte of 1MB+ memory in 1k increments - max 15 MB
438 #define CMOS_18 0x18 ///< High byte of 1MB+ memory in 1k increments - max 15 MB
439 #define CMOS_19 0x19 ///< C: extended drive type
440 #define CMOS_1A 0x1a ///< D: extended drive type
441 #define CMOS_2E 0x2e ///< Most significient byte of standard checksum
442 #define CMOS_2F 0x2f ///< Least significient byte of standard checksum
443 #define CMOS_30 0x30 ///< CMOS 0x17
444 #define CMOS_31 0x31 ///< CMOS 0x18
445 #define CMOS_32 0x32 ///< Century byte
446
447 //
448 // 8254 Timer registers
449 //
450 #define TIMER0_COUNT_PORT 0x40
451 #define TIMER1_COUNT_PORT 0x41
452 #define TIMER2_COUNT_PORT 0x42
453 #define TIMER_CONTROL_PORT 0x43
454
455 //
456 // Timer 0, Read/Write LSB then MSB, Square wave output, binary count use.
457 //
458 #define TIMER0_CONTROL_WORD 0x36
459
460 #define LEGACY_BIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('L', 'B', 'I', 'T')
461 typedef struct {
462 UINTN Signature;
463
464 EFI_HANDLE Handle;
465 EFI_LEGACY_BIOS_PROTOCOL LegacyBios;
466
467 EFI_HANDLE ImageHandle;
468
469 //
470 // CPU Architectural Protocol
471 //
472 EFI_CPU_ARCH_PROTOCOL *Cpu;
473
474 //
475 // Timer Architectural Protocol
476 //
477 EFI_TIMER_ARCH_PROTOCOL *Timer;
478 BOOLEAN TimerUses8254;
479
480 //
481 // Protocol to Lock and Unlock 0xc0000 - 0xfffff
482 //
483 EFI_LEGACY_REGION2_PROTOCOL *LegacyRegion;
484
485 EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *LegacyBiosPlatform;
486
487 //
488 // Interrupt control for thunk and PCI IRQ
489 //
490 EFI_LEGACY_8259_PROTOCOL *Legacy8259;
491
492 //
493 // PCI Interrupt PIRQ control
494 //
495 EFI_LEGACY_INTERRUPT_PROTOCOL *LegacyInterrupt;
496
497 //
498 // Generic Memory Test
499 //
500 EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenericMemoryTest;
501
502 //
503 // TRUE if PCI Interrupt Line registers have been programmed.
504 //
505 BOOLEAN PciInterruptLine;
506
507 //
508 // Code space below 1MB needed by thunker to transition to real mode.
509 // Contains stack and real mode code fragments
510 //
511 LOW_MEMORY_THUNK *IntThunk;
512
513 //
514 // Starting shadow address of the Legacy BIOS
515 //
516 UINT32 BiosStart;
517 UINT32 LegacyBiosImageSize;
518
519 //
520 // Start of variables used by CsmItp.mac ITP macro file and/os LegacyBios
521 //
522 UINT8 Dump[4];
523
524 //
525 // $EFI Legacy16 code entry info in memory < 1 MB;
526 //
527 EFI_COMPATIBILITY16_TABLE *Legacy16Table;
528 VOID *Legacy16InitPtr;
529 VOID *Legacy16BootPtr;
530 VOID *InternalIrqRoutingTable;
531 UINT32 NumberIrqRoutingEntries;
532 VOID *BbsTablePtr;
533 VOID *HddTablePtr;
534 UINT32 NumberHddControllers;
535
536 //
537 // Cached copy of Legacy16 entry point
538 //
539 UINT16 Legacy16CallSegment;
540 UINT16 Legacy16CallOffset;
541
542 //
543 // Returned from $EFI and passed in to OPROMS
544 //
545 UINT16 PnPInstallationCheckSegment;
546 UINT16 PnPInstallationCheckOffset;
547
548 //
549 // E820 table
550 //
551 EFI_E820_ENTRY E820Table[EFI_MAX_E820_ENTRY];
552 UINT32 NumberE820Entries;
553
554 //
555 // True if legacy VGA INT 10h handler installed
556 //
557 BOOLEAN VgaInstalled;
558
559 //
560 // Number of IDE drives
561 //
562 UINT8 IdeDriveCount;
563
564 //
565 // Current Free Option ROM space. An option ROM must NOT go past
566 // BiosStart.
567 //
568 UINT32 OptionRom;
569
570 //
571 // Save Legacy16 unexpected interrupt vector. Reprogram INT 68-6F from
572 // EFI values to legacy value just before boot.
573 //
574 UINT32 BiosUnexpectedInt;
575 UINT32 ThunkSavedInt[8];
576 UINT16 ThunkSeg;
577 LEGACY_EFI_HDD_TABLE *LegacyEfiHddTable;
578 UINT16 LegacyEfiHddTableIndex;
579 UINT8 DiskEnd;
580 UINT8 Disk4075;
581 UINT16 TraceIndex;
582 UINT16 Trace[0x200];
583
584 //
585 // Indicate that whether GenericLegacyBoot is entered or not
586 //
587 BOOLEAN LegacyBootEntered;
588
589 //
590 // CSM16 PCI Interface Version
591 //
592 UINT16 Csm16PciInterfaceVersion;
593 } LEGACY_BIOS_INSTANCE;
594
595 #pragma pack(1)
596
597 /*
598 40:00-01 Com1
599 40:02-03 Com2
600 40:04-05 Com3
601 40:06-07 Com4
602 40:08-09 Lpt1
603 40:0A-0B Lpt2
604 40:0C-0D Lpt3
605 40:0E-0E Ebda segment
606 40:10-11 MachineConfig
607 40:12 Bda12 - skip
608 40:13-14 MemSize below 1MB
609 40:15-16 Bda15_16 - skip
610 40:17 Keyboard Shift status
611 40:18-19 Bda18_19 - skip
612 40:1A-1B Key buffer head
613 40:1C-1D Key buffer tail
614 40:1E-3D Bda1E_3D- key buffer -skip
615 40:3E-3F FloppyData 3E = Calibration status 3F = Motor status
616 40:40 FloppyTimeout
617 40:41-74 Bda41_74 - skip
618 40:75 Number of HDD drives
619 40:76-77 Bda76_77 - skip
620 40:78-79 78 = Lpt1 timeout, 79 = Lpt2 timeout
621 40:7A-7B 7A = Lpt3 timeout, 7B = Lpt4 timeout
622 40:7C-7D 7C = Com1 timeout, 7D = Com2 timeout
623 40:7E-7F 7E = Com3 timeout, 7F = Com4 timeout
624 40:80-81 Pointer to start of key buffer
625 40:82-83 Pointer to end of key buffer
626 40:84-87 Bda84_87 - skip
627 40:88 HDD Data Xmit rate
628 40:89-8f skip
629 40:90 Floppy data rate
630 40:91-95 skip
631 40:96 Keyboard Status
632 40:97 LED Status
633 40:98-101 skip
634 */
635 typedef struct {
636 UINT16 Com1;
637 UINT16 Com2;
638 UINT16 Com3;
639 UINT16 Com4;
640 UINT16 Lpt1;
641 UINT16 Lpt2;
642 UINT16 Lpt3;
643 UINT16 Ebda;
644 UINT16 MachineConfig;
645 UINT8 Bda12;
646 UINT16 MemSize;
647 UINT8 Bda15_16[0x02];
648 UINT8 ShiftStatus;
649 UINT8 Bda18_19[0x02];
650 UINT16 KeyHead;
651 UINT16 KeyTail;
652 UINT16 Bda1E_3D[0x10];
653 UINT16 FloppyData;
654 UINT8 FloppyTimeout;
655 UINT8 Bda41_74[0x34];
656 UINT8 NumberOfDrives;
657 UINT8 Bda76_77[0x02];
658 UINT16 Lpt1_2Timeout;
659 UINT16 Lpt3_4Timeout;
660 UINT16 Com1_2Timeout;
661 UINT16 Com3_4Timeout;
662 UINT16 KeyStart;
663 UINT16 KeyEnd;
664 UINT8 Bda84_87[0x4];
665 UINT8 DataXmit;
666 UINT8 Bda89_8F[0x07];
667 UINT8 FloppyXRate;
668 UINT8 Bda91_95[0x05];
669 UINT8 KeyboardStatus;
670 UINT8 LedStatus;
671 } BDA_STRUC;
672 #pragma pack()
673
674 #define LEGACY_BIOS_INSTANCE_FROM_THIS(this) CR (this, LEGACY_BIOS_INSTANCE, LegacyBios, LEGACY_BIOS_INSTANCE_SIGNATURE)
675
676 /**
677 Thunk to 16-bit real mode and execute a software interrupt with a vector
678 of BiosInt. Regs will contain the 16-bit register context on entry and
679 exit.
680
681 @param This Protocol instance pointer.
682 @param BiosInt Processor interrupt vector to invoke
683 @param Regs Register contexted passed into (and returned) from thunk to
684 16-bit mode
685
686 @retval FALSE Thunk completed, and there were no BIOS errors in the target code.
687 See Regs for status.
688 @retval TRUE There was a BIOS erro in the target code.
689
690 **/
691 BOOLEAN
692 EFIAPI
693 LegacyBiosInt86 (
694 IN EFI_LEGACY_BIOS_PROTOCOL *This,
695 IN UINT8 BiosInt,
696 IN EFI_IA32_REGISTER_SET *Regs
697 );
698
699 /**
700 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
701 16-bit register context on entry and exit. Arguments can be passed on
702 the Stack argument
703
704 @param This Protocol instance pointer.
705 @param Segment Segment of 16-bit mode call
706 @param Offset Offset of 16-bit mdoe call
707 @param Regs Register contexted passed into (and returned) from
708 thunk to 16-bit mode
709 @param Stack Caller allocated stack used to pass arguments
710 @param StackSize Size of Stack in bytes
711
712 @retval FALSE Thunk completed, and there were no BIOS errors in
713 the target code. See Regs for status.
714 @retval TRUE There was a BIOS erro in the target code.
715
716 **/
717 BOOLEAN
718 EFIAPI
719 LegacyBiosFarCall86 (
720 IN EFI_LEGACY_BIOS_PROTOCOL *This,
721 IN UINT16 Segment,
722 IN UINT16 Offset,
723 IN EFI_IA32_REGISTER_SET *Regs,
724 IN VOID *Stack,
725 IN UINTN StackSize
726 );
727
728 /**
729 Test to see if a legacy PCI ROM exists for this device. Optionally return
730 the Legacy ROM instance for this PCI device.
731
732 @param This Protocol instance pointer.
733 @param PciHandle The PCI PC-AT OPROM from this devices ROM BAR will
734 be loaded
735 @param RomImage Return the legacy PCI ROM for this device
736 @param RomSize Size of ROM Image
737 @param Flags Indicates if ROM found and if PC-AT.
738
739 @retval EFI_SUCCESS Legacy Option ROM available for this device
740 @retval EFI_UNSUPPORTED Legacy Option ROM not supported.
741
742 **/
743 EFI_STATUS
744 EFIAPI
745 LegacyBiosCheckPciRom (
746 IN EFI_LEGACY_BIOS_PROTOCOL *This,
747 IN EFI_HANDLE PciHandle,
748 OUT VOID **RomImage OPTIONAL,
749 OUT UINTN *RomSize OPTIONAL,
750 OUT UINTN *Flags
751 );
752
753 /**
754 Assign drive number to legacy HDD drives prior to booting an EFI
755 aware OS so the OS can access drives without an EFI driver.
756 Note: BBS compliant drives ARE NOT available until this call by
757 either shell or EFI.
758
759 @param This Protocol instance pointer.
760 @param BbsCount Number of BBS_TABLE structures
761 @param BbsTable List BBS entries
762
763 @retval EFI_SUCCESS Drive numbers assigned
764
765 **/
766 EFI_STATUS
767 EFIAPI
768 LegacyBiosPrepareToBootEfi (
769 IN EFI_LEGACY_BIOS_PROTOCOL *This,
770 OUT UINT16 *BbsCount,
771 OUT BBS_TABLE **BbsTable
772 );
773
774 /**
775 To boot from an unconventional device like parties and/or execute
776 HDD diagnostics.
777
778 @param This Protocol instance pointer.
779 @param Attributes How to interpret the other input parameters
780 @param BbsEntry The 0-based index into the BbsTable for the parent
781 device.
782 @param BeerData Pointer to the 128 bytes of ram BEER data.
783 @param ServiceAreaData Pointer to the 64 bytes of raw Service Area data.
784 The caller must provide a pointer to the specific
785 Service Area and not the start all Service Areas.
786 EFI_INVALID_PARAMETER if error. Does NOT return if no error.
787
788 **/
789 EFI_STATUS
790 EFIAPI
791 LegacyBiosBootUnconventionalDevice (
792 IN EFI_LEGACY_BIOS_PROTOCOL *This,
793 IN UDC_ATTRIBUTES Attributes,
794 IN UINTN BbsEntry,
795 IN VOID *BeerData,
796 IN VOID *ServiceAreaData
797 );
798
799 /**
800 Load a legacy PC-AT OPROM on the PciHandle device. Return information
801 about how many disks were added by the OPROM and the shadow address and
802 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
803
804 @param This Protocol instance pointer.
805 @param PciHandle The PCI PC-AT OPROM from this devices ROM BAR will
806 be loaded. This value is NULL if RomImage is
807 non-NULL. This is the normal case.
808 @param RomImage A PCI PC-AT ROM image. This argument is non-NULL
809 if there is no hardware associated with the ROM
810 and thus no PciHandle, otherwise is must be NULL.
811 Example is PXE base code.
812 @param Flags Indicates if ROM found and if PC-AT.
813 @param DiskStart Disk number of first device hooked by the ROM. If
814 DiskStart is the same as DiskEnd no disked were
815 hooked.
816 @param DiskEnd Disk number of the last device hooked by the ROM.
817 @param RomShadowAddress Shadow address of PC-AT ROM
818 @param RomShadowedSize Size of RomShadowAddress in bytes
819
820 @retval EFI_SUCCESS Legacy ROM loaded for this device
821 @retval EFI_INVALID_PARAMETER PciHandle not found
822 @retval EFI_UNSUPPORTED There is no PCI ROM in the ROM BAR or no onboard
823 ROM
824
825 **/
826 EFI_STATUS
827 EFIAPI
828 LegacyBiosInstallPciRom (
829 IN EFI_LEGACY_BIOS_PROTOCOL *This,
830 IN EFI_HANDLE PciHandle,
831 IN VOID **RomImage,
832 OUT UINTN *Flags,
833 OUT UINT8 *DiskStart OPTIONAL,
834 OUT UINT8 *DiskEnd OPTIONAL,
835 OUT VOID **RomShadowAddress OPTIONAL,
836 OUT UINT32 *RomShadowedSize OPTIONAL
837 );
838
839 /**
840 Fill in the standard BDA for Keyboard LEDs
841
842 @param This Protocol instance pointer.
843 @param Leds Current LED status
844
845 @retval EFI_SUCCESS It should always work.
846
847 **/
848 EFI_STATUS
849 EFIAPI
850 LegacyBiosUpdateKeyboardLedStatus (
851 IN EFI_LEGACY_BIOS_PROTOCOL *This,
852 IN UINT8 Leds
853 );
854
855 /**
856 Get all BBS info
857
858 @param This Protocol instance pointer.
859 @param HddCount Number of HDD_INFO structures
860 @param HddInfo Onboard IDE controller information
861 @param BbsCount Number of BBS_TABLE structures
862 @param BbsTable List BBS entries
863
864 @retval EFI_SUCCESS Tables returned
865 @retval EFI_NOT_FOUND resource not found
866 @retval EFI_DEVICE_ERROR can not get BBS table
867
868 **/
869 EFI_STATUS
870 EFIAPI
871 LegacyBiosGetBbsInfo (
872 IN EFI_LEGACY_BIOS_PROTOCOL *This,
873 OUT UINT16 *HddCount,
874 OUT HDD_INFO **HddInfo,
875 OUT UINT16 *BbsCount,
876 OUT BBS_TABLE **BbsTable
877 );
878
879 /**
880 Shadow all legacy16 OPROMs that haven't been shadowed.
881 Warning: Use this with caution. This routine disconnects all EFI
882 drivers. If used externally then caller must re-connect EFI
883 drivers.
884
885 @param This Protocol instance pointer.
886
887 @retval EFI_SUCCESS OPROMs shadowed
888
889 **/
890 EFI_STATUS
891 EFIAPI
892 LegacyBiosShadowAllLegacyOproms (
893 IN EFI_LEGACY_BIOS_PROTOCOL *This
894 );
895
896 /**
897 Attempt to legacy boot the BootOption. If the EFI contexted has been
898 compromised this function will not return.
899
900 @param This Protocol instance pointer.
901 @param BbsDevicePath EFI Device Path from BootXXXX variable.
902 @param LoadOptionsSize Size of LoadOption in size.
903 @param LoadOptions LoadOption from BootXXXX variable
904
905 @retval EFI_SUCCESS Removable media not present
906
907 **/
908 EFI_STATUS
909 EFIAPI
910 LegacyBiosLegacyBoot (
911 IN EFI_LEGACY_BIOS_PROTOCOL *This,
912 IN BBS_BBS_DEVICE_PATH *BbsDevicePath,
913 IN UINT32 LoadOptionsSize,
914 IN VOID *LoadOptions
915 );
916
917 /**
918 Allocate memory < 1 MB and copy the thunker code into low memory. Se up
919 all the descriptors.
920
921 @param Private Private context for Legacy BIOS
922
923 @retval EFI_SUCCESS Should only pass.
924
925 **/
926 EFI_STATUS
927 LegacyBiosInitializeThunk (
928 IN LEGACY_BIOS_INSTANCE *Private
929 );
930
931 /**
932 Fill in the standard BDA and EBDA stuff before Legacy16 load
933
934 @param Private Legacy BIOS Instance data
935
936 @retval EFI_SUCCESS It should always work.
937
938 **/
939 EFI_STATUS
940 LegacyBiosInitBda (
941 IN LEGACY_BIOS_INSTANCE *Private
942 );
943
944 /**
945 Collect IDE Inquiry data from the IDE disks
946
947 @param Private Legacy BIOS Instance data
948 @param HddInfo Hdd Information
949 @param Flag Reconnect IdeController or not
950
951 @retval EFI_SUCCESS It should always work.
952
953 **/
954 EFI_STATUS
955 LegacyBiosBuildIdeData (
956 IN LEGACY_BIOS_INSTANCE *Private,
957 IN HDD_INFO **HddInfo,
958 IN UINT16 Flag
959 );
960
961 /**
962 Enable ide controller. This gets disabled when LegacyBoot.c is about
963 to run the Option ROMs.
964
965 @param Private Legacy BIOS Instance data
966
967
968 **/
969 VOID
970 EnableIdeController (
971 IN LEGACY_BIOS_INSTANCE *Private
972 );
973
974 /**
975 If the IDE channel is in compatibility (legacy) mode, remove all
976 PCI I/O BAR addresses from the controller.
977
978 @param IdeController The handle of target IDE controller
979
980
981 **/
982 VOID
983 InitLegacyIdeController (
984 IN EFI_HANDLE IdeController
985 );
986
987 /**
988 Program the interrupt routing register in all the PCI devices. On a PC AT system
989 this register contains the 8259 IRQ vector that matches its PCI interrupt.
990
991 @param Private Legacy BIOS Instance data
992
993 @retval EFI_SUCCESS Succeed.
994 @retval EFI_ALREADY_STARTED All PCI devices have been processed.
995
996 **/
997 EFI_STATUS
998 PciProgramAllInterruptLineRegisters (
999 IN LEGACY_BIOS_INSTANCE *Private
1000 );
1001
1002 /**
1003 Collect EFI Info about legacy devices.
1004
1005 @param Private Legacy BIOS Instance data
1006
1007 @retval EFI_SUCCESS It should always work.
1008
1009 **/
1010 EFI_STATUS
1011 LegacyBiosBuildSioData (
1012 IN LEGACY_BIOS_INSTANCE *Private
1013 );
1014
1015 /**
1016 Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol
1017 to chose the order. Skip any devices that have already have legacy
1018 BIOS run.
1019
1020 @param Private Protocol instance pointer.
1021
1022 @retval EFI_SUCCESS Succeed.
1023 @retval EFI_UNSUPPORTED Cannot get VGA device handle.
1024
1025 **/
1026 EFI_STATUS
1027 PciShadowRoms (
1028 IN LEGACY_BIOS_INSTANCE *Private
1029 );
1030
1031 /**
1032 Fill in the standard BDA and EBDA stuff prior to legacy Boot
1033
1034 @param Private Legacy BIOS Instance data
1035
1036 @retval EFI_SUCCESS It should always work.
1037
1038 **/
1039 EFI_STATUS
1040 LegacyBiosCompleteBdaBeforeBoot (
1041 IN LEGACY_BIOS_INSTANCE *Private
1042 );
1043
1044 /**
1045 Fill in the standard CMOS stuff before Legacy16 load
1046
1047 @param Private Legacy BIOS Instance data
1048
1049 @retval EFI_SUCCESS It should always work.
1050
1051 **/
1052 EFI_STATUS
1053 LegacyBiosInitCmos (
1054 IN LEGACY_BIOS_INSTANCE *Private
1055 );
1056
1057 /**
1058 Fill in the standard CMOS stuff prior to legacy Boot
1059
1060 @param Private Legacy BIOS Instance data
1061
1062 @retval EFI_SUCCESS It should always work.
1063
1064 **/
1065 EFI_STATUS
1066 LegacyBiosCompleteStandardCmosBeforeBoot (
1067 IN LEGACY_BIOS_INSTANCE *Private
1068 );
1069
1070 /**
1071 Contains the code that is copied into low memory (below 640K).
1072 This code reflects interrupts 0x68-0x6f to interrupts 0x08-0x0f.
1073 This template must be copied into low memory, and the IDT entries
1074 0x68-0x6F must be point to the low memory copy of this code. Each
1075 entry is 4 bytes long, so IDT entries 0x68-0x6F can be easily
1076 computed.
1077
1078 **/
1079 VOID
1080 InterruptRedirectionTemplate (
1081 VOID
1082 );
1083
1084 /**
1085 Build the E820 table.
1086
1087 @param Private Legacy BIOS Instance data
1088 @param Size Size of E820 Table
1089
1090 @retval EFI_SUCCESS It should always work.
1091
1092 **/
1093 EFI_STATUS
1094 LegacyBiosBuildE820 (
1095 IN LEGACY_BIOS_INSTANCE *Private,
1096 OUT UINTN *Size
1097 );
1098
1099 /**
1100 This function is to put all AP in halt state.
1101
1102 @param Private Legacy BIOS Instance data
1103
1104 **/
1105 VOID
1106 ShutdownAPs (
1107 IN LEGACY_BIOS_INSTANCE *Private
1108 );
1109
1110 /**
1111 Worker function for LegacyBiosGetFlatDescs, retrieving content of
1112 specific registers.
1113
1114 @param IntThunk Pointer to IntThunk of Legacy BIOS context.
1115
1116 **/
1117 VOID
1118 GetRegisters (
1119 LOW_MEMORY_THUNK *IntThunk
1120 );
1121
1122 /**
1123 Routine for calling real thunk code.
1124
1125 @param RealCode The address of thunk code.
1126 @param BiosInt The Bios interrupt vector number.
1127 @param CallAddress The address of 16-bit mode call.
1128
1129 @return Status returned by real thunk code
1130
1131 **/
1132 UINTN
1133 CallRealThunkCode (
1134 UINT8 *RealCode,
1135 UINT8 BiosInt,
1136 UINT32 CallAddress
1137 );
1138
1139 /**
1140 Routine for generating soft interrupt.
1141
1142 @param Vector The interrupt vector number.
1143
1144 **/
1145 VOID
1146 GenerateSoftInit (
1147 UINT8 Vector
1148 );
1149
1150 /**
1151 Allocate memory for legacy usage.
1152
1153 @param AllocateType The type of allocation to perform.
1154 @param MemoryType The type of memory to allocate.
1155 @param StartPageAddress Start address of range
1156 @param Pages Number of pages to allocate
1157 @param Result Result of allocation
1158
1159 @retval EFI_SUCCESS Legacy16 code loaded
1160 @retval Other No protocol installed, unload driver.
1161
1162 **/
1163 EFI_STATUS
1164 AllocateLegacyMemory (
1165 IN EFI_ALLOCATE_TYPE AllocateType,
1166 IN EFI_MEMORY_TYPE MemoryType,
1167 IN EFI_PHYSICAL_ADDRESS StartPageAddress,
1168 IN UINTN Pages,
1169 OUT EFI_PHYSICAL_ADDRESS *Result
1170 );
1171
1172 /**
1173 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
1174
1175 @param This Protocol instance pointer.
1176 @param LegacyMemorySize Size of required region
1177 @param Region Region to use. 00 = Either 0xE0000 or 0xF0000
1178 block Bit0 = 1 0xF0000 block Bit1 = 1 0xE0000
1179 block
1180 @param Alignment Address alignment. Bit mapped. First non-zero
1181 bit from right is alignment.
1182 @param LegacyMemoryAddress Region Assigned
1183
1184 @retval EFI_SUCCESS Region assigned
1185 @retval EFI_ACCESS_DENIED Procedure previously invoked
1186 @retval Other Region not assigned
1187
1188 **/
1189 EFI_STATUS
1190 EFIAPI
1191 LegacyBiosGetLegacyRegion (
1192 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1193 IN UINTN LegacyMemorySize,
1194 IN UINTN Region,
1195 IN UINTN Alignment,
1196 OUT VOID **LegacyMemoryAddress
1197 );
1198
1199 /**
1200 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
1201
1202 @param This Protocol instance pointer.
1203 @param LegacyMemorySize Size of data to copy
1204 @param LegacyMemoryAddress Legacy Region destination address Note: must
1205 be in region assigned by
1206 LegacyBiosGetLegacyRegion
1207 @param LegacyMemorySourceAddress Source of data
1208
1209 @retval EFI_SUCCESS Region assigned
1210 @retval EFI_ACCESS_DENIED Destination outside assigned region
1211
1212 **/
1213 EFI_STATUS
1214 EFIAPI
1215 LegacyBiosCopyLegacyRegion (
1216 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1217 IN UINTN LegacyMemorySize,
1218 IN VOID *LegacyMemoryAddress,
1219 IN VOID *LegacyMemorySourceAddress
1220 );
1221
1222 /**
1223 Find Legacy16 BIOS image in the FLASH device and shadow it into memory. Find
1224 the $EFI table in the shadow area. Thunk into the Legacy16 code after it had
1225 been shadowed.
1226
1227 @param Private Legacy BIOS context data
1228
1229 @retval EFI_SUCCESS Legacy16 code loaded
1230 @retval Other No protocol installed, unload driver.
1231
1232 **/
1233 EFI_STATUS
1234 ShadowAndStartLegacy16 (
1235 IN LEGACY_BIOS_INSTANCE *Private
1236 );
1237
1238 /**
1239 Checks the state of the floppy and if media is inserted.
1240
1241 This routine checks the state of the floppy and if media is inserted.
1242 There are 3 cases:
1243 No floppy present - Set BBS entry to ignore
1244 Floppy present & no media - Set BBS entry to lowest priority. We cannot
1245 set it to ignore since 16-bit CSM will
1246 indicate no floppy and thus drive A: is
1247 unusable. CSM-16 will not try floppy since
1248 lowest priority and thus not incur boot
1249 time penality.
1250 Floppy present & media - Set BBS entry to some priority.
1251
1252 @return State of floppy media
1253
1254 **/
1255 UINT8
1256 HasMediaInFloppy (
1257 VOID
1258 );
1259
1260 /**
1261 Identify drive data must be updated to actual parameters before boot.
1262 This requires updating the checksum, if it exists.
1263
1264 @param IdentifyDriveData ATA Identify Data
1265 @param Checksum checksum of the ATA Identify Data
1266
1267 @retval EFI_SUCCESS checksum calculated
1268 @retval EFI_SECURITY_VIOLATION IdentifyData invalid
1269
1270 **/
1271 EFI_STATUS
1272 CalculateIdentifyDriveChecksum (
1273 IN UINT8 *IdentifyDriveData,
1274 OUT UINT8 *Checksum
1275 );
1276
1277 /**
1278 Identify drive data must be updated to actual parameters before boot.
1279
1280 @param IdentifyDriveData ATA Identify Data
1281
1282 **/
1283 VOID
1284 UpdateIdentifyDriveData (
1285 IN UINT8 *IdentifyDriveData
1286 );
1287
1288 /**
1289 Complete build of BBS TABLE.
1290
1291 @param Private Legacy BIOS Instance data
1292 @param BbsTable BBS Table passed to 16-bit code
1293
1294 @retval EFI_SUCCESS Removable media not present
1295
1296 **/
1297 EFI_STATUS
1298 LegacyBiosBuildBbs (
1299 IN LEGACY_BIOS_INSTANCE *Private,
1300 IN BBS_TABLE *BbsTable
1301 );
1302
1303 /**
1304 Read CMOS register through index/data port.
1305
1306 @param[in] Index The index of the CMOS register to read.
1307
1308 @return The data value from the CMOS register specified by Index.
1309
1310 **/
1311 UINT8
1312 LegacyReadStandardCmos (
1313 IN UINT8 Index
1314 );
1315
1316 /**
1317 Write CMOS register through index/data port.
1318
1319 @param[in] Index The index of the CMOS register to write.
1320 @param[in] Value The value of CMOS register to write.
1321
1322 @return The value written to the CMOS register specified by Index.
1323
1324 **/
1325 UINT8
1326 LegacyWriteStandardCmos (
1327 IN UINT8 Index,
1328 IN UINT8 Value
1329 );
1330
1331 /**
1332 Calculate the new standard CMOS checksum and write it.
1333
1334 @param Private Legacy BIOS Instance data
1335
1336 @retval EFI_SUCCESS Calculate 16-bit checksum successfully
1337
1338 **/
1339 EFI_STATUS
1340 LegacyCalculateWriteStandardCmosChecksum (
1341 VOID
1342 );
1343
1344 /**
1345 Test to see if a legacy PCI ROM exists for this device. Optionally return
1346 the Legacy ROM instance for this PCI device.
1347
1348 @param[in] This Protocol instance pointer.
1349 @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded
1350 @param[out] RomImage Return the legacy PCI ROM for this device
1351 @param[out] RomSize Size of ROM Image
1352 @param[out] RuntimeImageLength Runtime size of ROM Image
1353 @param[out] Flags Indicates if ROM found and if PC-AT.
1354 @param[out] OpromRevision Revision of the PCI Rom
1355 @param[out] ConfigUtilityCodeHeaderPointer of Configuration Utility Code Header
1356
1357 @return EFI_SUCCESS Legacy Option ROM available for this device
1358 @return EFI_ALREADY_STARTED This device is already managed by its Oprom
1359 @return EFI_UNSUPPORTED Legacy Option ROM not supported.
1360
1361 **/
1362 EFI_STATUS
1363 LegacyBiosCheckPciRomEx (
1364 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1365 IN EFI_HANDLE PciHandle,
1366 OUT VOID **RomImage OPTIONAL,
1367 OUT UINTN *RomSize OPTIONAL,
1368 OUT UINTN *RuntimeImageLength OPTIONAL,
1369 OUT UINTN *Flags OPTIONAL,
1370 OUT UINT8 *OpromRevision OPTIONAL,
1371 OUT VOID **ConfigUtilityCodeHeader OPTIONAL
1372 );
1373
1374 /**
1375 Relocate this image under 4G memory for IPF.
1376
1377 @param ImageHandle Handle of driver image.
1378 @param SystemTable Pointer to system table.
1379
1380 @retval EFI_SUCCESS Image successfully relocated.
1381 @retval EFI_ABORTED Failed to relocate image.
1382
1383 **/
1384 EFI_STATUS
1385 RelocateImageUnder4GIfNeeded (
1386 IN EFI_HANDLE ImageHandle,
1387 IN EFI_SYSTEM_TABLE *SystemTable
1388 );
1389
1390 /**
1391 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
1392 16-bit register context on entry and exit. Arguments can be passed on
1393 the Stack argument
1394
1395 @param This Protocol instance pointer.
1396 @param Segment Segment of 16-bit mode call
1397 @param Offset Offset of 16-bit mdoe call
1398 @param Regs Register contexted passed into (and returned) from thunk to
1399 16-bit mode
1400 @param Stack Caller allocated stack used to pass arguments
1401 @param StackSize Size of Stack in bytes
1402
1403 @retval FALSE Thunk completed, and there were no BIOS errors in the target code.
1404 See Regs for status.
1405 @retval TRUE There was a BIOS erro in the target code.
1406
1407 **/
1408 BOOLEAN
1409 EFIAPI
1410 InternalLegacyBiosFarCall (
1411 IN EFI_LEGACY_BIOS_PROTOCOL *This,
1412 IN UINT16 Segment,
1413 IN UINT16 Offset,
1414 IN EFI_IA32_REGISTER_SET *Regs,
1415 IN VOID *Stack,
1416 IN UINTN StackSize
1417 );
1418
1419 /**
1420 Load a legacy PC-AT OpROM for VGA controller.
1421
1422 @param Private Driver private data.
1423
1424 @retval EFI_SUCCESS Legacy ROM successfully installed for this device.
1425 @retval EFI_DEVICE_ERROR No VGA device handle found, or native EFI video
1426 driver cannot be successfully disconnected, or VGA
1427 thunk driver cannot be successfully connected.
1428
1429 **/
1430 EFI_STATUS
1431 LegacyBiosInstallVgaRom (
1432 IN LEGACY_BIOS_INSTANCE *Private
1433 );
1434
1435 #endif