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