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