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