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