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