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