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