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