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