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