3 Copyright (c) 2006 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This file include all platform action which can be customized
23 #include "BdsPlatform.h"
25 #define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
27 extern BOOLEAN gConnectAllHappened
;
28 extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath
;
30 EFI_GUID
*gTableGuidArray
[] = {
31 &gEfiAcpi20TableGuid
, &gEfiAcpiTableGuid
, &gEfiSmbiosTableGuid
, &gEfiMpsTableGuid
35 // BDS Platform Functions
39 GetSystemTablesFromHob (
45 Find GUID'ed HOBs that contain EFI_PHYSICAL_ADDRESS of ACPI, SMBIOS, MPs tables
55 EFI_PEI_HOB_POINTERS GuidHob
;
56 EFI_PEI_HOB_POINTERS HobStart
;
57 EFI_PHYSICAL_ADDRESS
*Table
;
63 HobStart
.Raw
= GetHobList ();
65 // Iteratively add ACPI Table, SMBIOS Table, MPS Table to EFI System Table
67 for (Index
= 0; Index
< sizeof (gTableGuidArray
) / sizeof (*gTableGuidArray
); ++Index
) {
68 GuidHob
.Raw
= GetNextGuidHob (gTableGuidArray
[Index
], HobStart
.Raw
);
69 if (GuidHob
.Raw
!= NULL
) {
70 Table
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
73 // Check if Mps Table/Smbios Table/Acpi Table exists in E/F seg,
74 // According to UEFI Spec, we should make sure Smbios table,
75 // ACPI table and Mps tables kept in memory of specified type
77 ConvertSystemTable(gTableGuidArray
[Index
], (VOID
**)&Table
);
78 gBS
->InstallConfigurationTable (gTableGuidArray
[Index
], (VOID
*)Table
);
86 #define EFI_LDR_MEMORY_DESCRIPTOR_GUID \
87 { 0x7701d7e5, 0x7d1d, 0x4432, {0xa4, 0x68, 0x67, 0x3d, 0xab, 0x8a, 0xde, 0x60 }}
89 EFI_GUID gEfiLdrMemoryDescriptorGuid
= EFI_LDR_MEMORY_DESCRIPTOR_GUID
;
94 EFI_HOB_GUID_TYPE Hob
;
96 EFI_MEMORY_DESCRIPTOR
*MemDesc
;
107 EFI_MEMORY_DESCRIPTOR
*MemMap
;
108 EFI_MEMORY_DESCRIPTOR
*MemMapPtr
;
110 UINTN MapKey
, DescriptorSize
;
112 UINT32 DescriptorVersion
;
118 Status
= gBS
->GetMemoryMap (&MemMapSize
, MemMap
, &MapKey
, &DescriptorSize
, &DescriptorVersion
);
119 ASSERT (Status
== EFI_BUFFER_TOO_SMALL
);
120 MemMapSize
+= EFI_PAGE_SIZE
;
121 Status
= gBS
->AllocatePool (EfiBootServicesData
, MemMapSize
, &MemMap
);
122 ASSERT (Status
== EFI_SUCCESS
);
123 Status
= gBS
->GetMemoryMap (&MemMapSize
, MemMap
, &MapKey
, &DescriptorSize
, &DescriptorVersion
);
124 ASSERT (Status
== EFI_SUCCESS
);
127 ASSERT (DescriptorVersion
== EFI_MEMORY_DESCRIPTOR_VERSION
);
129 for (Index
= 0; Index
< MemMapSize
/ DescriptorSize
; Index
++) {
130 Bytes
= LShiftU64 (MemMap
->NumberOfPages
, 12);
131 DEBUG ((EFI_D_ERROR
, "%lX-%lX %lX %lX %X\n",
132 MemMap
->PhysicalStart
,
133 MemMap
->PhysicalStart
+ Bytes
- 1,
134 MemMap
->NumberOfPages
,
136 (UINTN
)MemMap
->Type
));
137 MemMap
= (EFI_MEMORY_DESCRIPTOR
*)((UINTN
)MemMap
+ DescriptorSize
);
140 gBS
->FreePool (MemMapPtr
);
150 EFI_PEI_HOB_POINTERS GuidHob
;
152 MEMORY_DESC_HOB MemoryDescHob
;
154 EFI_PHYSICAL_ADDRESS Memory
;
155 EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor
;
159 GuidHob
.Raw
= GetHobList();
161 GuidHob
.Raw
= GetNextGuidHob (&gEfiLdrMemoryDescriptorGuid
, GuidHob
.Raw
);
162 if (GuidHob
.Raw
== NULL
) {
163 DEBUG ((EFI_D_ERROR
, "Fail to get gEfiLdrMemoryDescriptorGuid from GUID HOB LIST!\n"));
166 Table
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
168 DEBUG ((EFI_D_ERROR
, "Fail to get gEfiLdrMemoryDescriptorGuid from GUID HOB LIST!\n"));
171 MemoryDescHob
.MemDescCount
= *(UINTN
*)Table
;
172 MemoryDescHob
.MemDesc
= *(EFI_MEMORY_DESCRIPTOR
**)((UINTN
)Table
+ sizeof(UINTN
));
175 // Add ACPINVS, ACPIReclaim, and Reserved memory to MemoryMap
177 for (Index
= 0; Index
< MemoryDescHob
.MemDescCount
; Index
++) {
178 if (MemoryDescHob
.MemDesc
[Index
].PhysicalStart
< 0x100000) {
181 if (MemoryDescHob
.MemDesc
[Index
].PhysicalStart
>= 0x100000000ULL
) {
184 if ((MemoryDescHob
.MemDesc
[Index
].Type
== EfiReservedMemoryType
) ||
185 (MemoryDescHob
.MemDesc
[Index
].Type
== EfiRuntimeServicesData
) ||
186 (MemoryDescHob
.MemDesc
[Index
].Type
== EfiRuntimeServicesCode
) ||
187 (MemoryDescHob
.MemDesc
[Index
].Type
== EfiACPIReclaimMemory
) ||
188 (MemoryDescHob
.MemDesc
[Index
].Type
== EfiACPIMemoryNVS
)) {
189 DEBUG ((EFI_D_ERROR
, "PhysicalStart - 0x%016lx, ", MemoryDescHob
.MemDesc
[Index
].PhysicalStart
));
190 DEBUG ((EFI_D_ERROR
, "PageNumber - 0x%016lx, ", MemoryDescHob
.MemDesc
[Index
].NumberOfPages
));
191 DEBUG ((EFI_D_ERROR
, "Attribute - 0x%016lx, ", MemoryDescHob
.MemDesc
[Index
].Attribute
));
192 DEBUG ((EFI_D_ERROR
, "Type - 0x%08x\n", MemoryDescHob
.MemDesc
[Index
].Type
));
193 if ((MemoryDescHob
.MemDesc
[Index
].Type
== EfiRuntimeServicesData
) ||
194 (MemoryDescHob
.MemDesc
[Index
].Type
== EfiRuntimeServicesCode
)) {
196 // For RuntimeSevicesData and RuntimeServicesCode, they are BFV or DxeCore.
197 // The memory type is assigned in EfiLdr
199 Status
= gDS
->GetMemorySpaceDescriptor (MemoryDescHob
.MemDesc
[Index
].PhysicalStart
, &Descriptor
);
200 if (EFI_ERROR (Status
)) {
203 if (Descriptor
.GcdMemoryType
!= EfiGcdMemoryTypeReserved
) {
205 // BFV or tested DXE core
210 // Untested DXE Core region, free and remove
212 Status
= gDS
->FreeMemorySpace (
213 MemoryDescHob
.MemDesc
[Index
].PhysicalStart
,
214 LShiftU64 (MemoryDescHob
.MemDesc
[Index
].NumberOfPages
, EFI_PAGE_SHIFT
)
216 if (EFI_ERROR (Status
)) {
217 DEBUG ((EFI_D_ERROR
, "FreeMemorySpace fail - %r!\n", Status
));
220 Status
= gDS
->RemoveMemorySpace (
221 MemoryDescHob
.MemDesc
[Index
].PhysicalStart
,
222 LShiftU64 (MemoryDescHob
.MemDesc
[Index
].NumberOfPages
, EFI_PAGE_SHIFT
)
224 if (EFI_ERROR (Status
)) {
225 DEBUG ((EFI_D_ERROR
, "RemoveMemorySpace fail - %r!\n", Status
));
230 // Convert Runtime type to BootTime type
232 if (MemoryDescHob
.MemDesc
[Index
].Type
== EfiRuntimeServicesData
) {
233 MemoryDescHob
.MemDesc
[Index
].Type
= EfiBootServicesData
;
235 MemoryDescHob
.MemDesc
[Index
].Type
= EfiBootServicesCode
;
239 // PassThrough, let below code add and alloate.
243 // ACPI or reserved memory
245 Status
= gDS
->AddMemorySpace (
246 EfiGcdMemoryTypeSystemMemory
,
247 MemoryDescHob
.MemDesc
[Index
].PhysicalStart
,
248 LShiftU64 (MemoryDescHob
.MemDesc
[Index
].NumberOfPages
, EFI_PAGE_SHIFT
),
249 MemoryDescHob
.MemDesc
[Index
].Attribute
251 if (EFI_ERROR (Status
)) {
252 DEBUG ((EFI_D_ERROR
, "AddMemorySpace fail - %r!\n", Status
));
253 if ((MemoryDescHob
.MemDesc
[Index
].Type
== EfiACPIReclaimMemory
) ||
254 (MemoryDescHob
.MemDesc
[Index
].Type
== EfiACPIMemoryNVS
)) {
256 // For EfiACPIReclaimMemory and EfiACPIMemoryNVS, it must success.
257 // For EfiReservedMemoryType, there maybe overlap. So skip check here.
259 // ASSERT_EFI_ERROR (Status);
264 Memory
= MemoryDescHob
.MemDesc
[Index
].PhysicalStart
;
265 Status
= gBS
->AllocatePages (
267 (EFI_MEMORY_TYPE
)MemoryDescHob
.MemDesc
[Index
].Type
,
268 (UINTN
)MemoryDescHob
.MemDesc
[Index
].NumberOfPages
,
271 if (EFI_ERROR (Status
)) {
272 DEBUG ((EFI_D_ERROR
, "AllocatePages fail - %r!\n", Status
));
274 // For the page added, it must be allocated.
276 // ASSERT_EFI_ERROR (Status);
285 DisableUsbLegacySupport(
291 Disabble the USB legacy Support in all Ehci and Uhci.
292 This function assume all PciIo handles have been created in system.
303 EFI_HANDLE
*HandleArray
;
304 UINTN HandleArrayCount
;
306 EFI_PCI_IO_PROTOCOL
*PciIo
;
315 // Find the usb host controller
317 Status
= gBS
->LocateHandleBuffer (
319 &gEfiPciIoProtocolGuid
,
324 if (!EFI_ERROR (Status
)) {
325 for (Index
= 0; Index
< HandleArrayCount
; Index
++) {
326 Status
= gBS
->HandleProtocol (
328 &gEfiPciIoProtocolGuid
,
331 if (!EFI_ERROR (Status
)) {
333 // Find the USB host controller controller
335 Status
= PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint8
, 0x09, 3, &Class
);
336 if (!EFI_ERROR (Status
)) {
337 if ((PCI_CLASS_SERIAL
== Class
[2]) &&
338 (PCI_CLASS_SERIAL_USB
== Class
[1])) {
339 if (PCI_IF_UHCI
== Class
[0]) {
341 // Found the UHCI, then disable the legacy support
344 Status
= PciIo
->Pci
.Write (PciIo
, EfiPciIoWidthUint16
, 0xC0, 1, &Command
);
345 } else if (PCI_IF_EHCI
== Class
[0]) {
347 // Found the EHCI, then disable the legacy support
349 Status
= PciIo
->Mem
.Read (
353 (UINT64
) 0x08, //EHC_HCCPARAMS_OFFSET
358 ExtendCap
= (HcCapParams
>> 8) & 0xFF;
360 // Disable the SMI in USBLEGCTLSTS firstly
362 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint32
, ExtendCap
+ 0x4, 1, &Value
);
364 PciIo
->Pci
.Write (PciIo
, EfiPciIoWidthUint32
, ExtendCap
+ 0x4, 1, &Value
);
367 // Get EHCI Ownership from legacy bios
369 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint32
, ExtendCap
, 1, &Value
);
370 Value
|= (0x1 << 24);
371 PciIo
->Pci
.Write (PciIo
, EfiPciIoWidthUint32
, ExtendCap
, 1, &Value
);
377 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint32
, ExtendCap
, 1, &Value
);
379 if ((Value
& 0x01010000) == 0x01000000) {
391 gBS
->FreePool (HandleArray
);
405 Platform Bds init. Incude the platform firmware vendor, revision
416 GetSystemTablesFromHob ();
421 // Append Usb Keyboard short form DevicePath into "ConInDev"
423 BdsLibUpdateConsoleVariable (
425 (EFI_DEVICE_PATH_PROTOCOL
*) &gUsbClassKeyboardDevicePath
,
431 GetPciExpressBaseAddressForRootBridge (
432 IN UINTN HostBridgeNumber
,
433 IN UINTN RootBridgeNumber
438 This routine is to get PciExpress Base Address for this RootBridge
441 HostBridgeNumber - The number of HostBridge
442 RootBridgeNumber - The number of RootBridge
445 UINT64 - PciExpressBaseAddress for this HostBridge and RootBridge
449 EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION
*PciExpressBaseAddressInfo
;
453 EFI_PEI_HOB_POINTERS GuidHob
;
456 // Get PciExpressAddressInfo Hob
458 PciExpressBaseAddressInfo
= NULL
;
460 GuidHob
.Raw
= GetFirstGuidHob (&gEfiPciExpressBaseAddressGuid
);
461 if (GuidHob
.Raw
!= NULL
) {
462 PciExpressBaseAddressInfo
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
463 BufferSize
= GET_GUID_HOB_DATA_SIZE (GuidHob
.Guid
);
469 // Search the PciExpress Base Address in the Hob for current RootBridge
471 Number
= (UINT32
)(BufferSize
/ sizeof(EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION
));
472 for (Index
= 0; Index
< Number
; Index
++) {
473 if ((PciExpressBaseAddressInfo
[Index
].HostBridgeNumber
== HostBridgeNumber
) &&
474 (PciExpressBaseAddressInfo
[Index
].RootBridgeNumber
== RootBridgeNumber
)) {
475 return PciExpressBaseAddressInfo
[Index
].PciExpressBaseAddress
;
480 // Do not find the PciExpress Base Address in the Hob
486 PatchPciRootBridgeDevicePath (
487 IN UINTN HostBridgeNumber
,
488 IN UINTN RootBridgeNumber
,
489 IN PLATFORM_ROOT_BRIDGE_DEVICE_PATH
*RootBridge
492 UINT64 PciExpressBase
;
494 PciExpressBase
= GetPciExpressBaseAddressForRootBridge (HostBridgeNumber
, RootBridgeNumber
);
496 DEBUG ((EFI_D_INFO
, "Get PciExpress Address from Hob: 0x%X\n", PciExpressBase
));
498 if (PciExpressBase
!= 0) {
499 RootBridge
->PciRootBridge
.HID
= EISA_PNP_ID(0x0A08);
519 EFI_SUCCESS - Connect RootBridge successfully.
520 EFI_STATUS - Connect RootBridge fail.
525 EFI_HANDLE RootHandle
;
528 // Patch Pci Root Bridge Device Path
530 PatchPciRootBridgeDevicePath (0, 0, &gPlatformRootBridge0
);
533 // Make all the PCI_IO protocols on PCI Seg 0 show up
535 BdsLibConnectDevicePath (gPlatformRootBridges
[0]);
537 Status
= gBS
->LocateDevicePath (
538 &gEfiDevicePathProtocolGuid
,
539 &gPlatformRootBridges
[0],
542 DEBUG ((EFI_D_INFO
, "Pci Root bridge handle is 0x%X\n", RootHandle
));
544 if (EFI_ERROR (Status
)) {
548 Status
= gBS
->ConnectController (RootHandle
, NULL
, NULL
, FALSE
);
549 if (EFI_ERROR (Status
)) {
557 PrepareLpcBridgeDevicePath (
558 IN EFI_HANDLE DeviceHandle
564 Add IsaKeyboard to ConIn,
565 add IsaSerial to ConOut, ConIn, ErrOut.
570 DeviceHandle - Handle of PCIIO protocol.
574 EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut.
575 EFI_STATUS - No LPC bridge is added.
580 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
581 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
584 Status
= gBS
->HandleProtocol (
586 &gEfiDevicePathProtocolGuid
,
589 if (EFI_ERROR (Status
)) {
592 TempDevicePath
= DevicePath
;
597 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gPnpPs2KeyboardDeviceNode
);
599 BdsLibUpdateConsoleVariable (VarConsoleInp
, DevicePath
, NULL
);
604 DevicePath
= TempDevicePath
;
605 gPnp16550ComPortDeviceNode
.UID
= 0;
607 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gPnp16550ComPortDeviceNode
);
608 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gUartDeviceNode
);
609 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gTerminalTypeDeviceNode
);
611 BdsLibUpdateConsoleVariable (VarConsoleOut
, DevicePath
, NULL
);
612 BdsLibUpdateConsoleVariable (VarConsoleInp
, DevicePath
, NULL
);
613 BdsLibUpdateConsoleVariable (VarErrorOut
, DevicePath
, NULL
);
618 DevicePath
= TempDevicePath
;
619 gPnp16550ComPortDeviceNode
.UID
= 1;
621 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gPnp16550ComPortDeviceNode
);
622 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gUartDeviceNode
);
623 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gTerminalTypeDeviceNode
);
625 BdsLibUpdateConsoleVariable (VarConsoleOut
, DevicePath
, NULL
);
626 BdsLibUpdateConsoleVariable (VarConsoleInp
, DevicePath
, NULL
);
627 BdsLibUpdateConsoleVariable (VarErrorOut
, DevicePath
, NULL
);
634 IN EFI_DEVICE_PATH_PROTOCOL
*PciDevicePath
,
635 OUT EFI_DEVICE_PATH_PROTOCOL
**GopDevicePath
640 EFI_HANDLE PciDeviceHandle
;
641 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
642 EFI_DEVICE_PATH_PROTOCOL
*TempPciDevicePath
;
643 UINTN GopHandleCount
;
644 EFI_HANDLE
*GopHandleBuffer
;
646 if (PciDevicePath
== NULL
|| GopDevicePath
== NULL
) {
647 return EFI_INVALID_PARAMETER
;
651 // Initialize the GopDevicePath to be PciDevicePath
653 *GopDevicePath
= PciDevicePath
;
654 TempPciDevicePath
= PciDevicePath
;
656 Status
= gBS
->LocateDevicePath (
657 &gEfiDevicePathProtocolGuid
,
661 if (EFI_ERROR (Status
)) {
666 // Try to connect this handle, so that GOP dirver could start on this
667 // device and create child handles with GraphicsOutput Protocol installed
668 // on them, then we get device paths of these child handles and select
669 // them as possible console device.
671 gBS
->ConnectController (PciDeviceHandle
, NULL
, NULL
, FALSE
);
673 Status
= gBS
->LocateHandleBuffer (
675 &gEfiGraphicsOutputProtocolGuid
,
680 if (!EFI_ERROR (Status
)) {
682 // Add all the child handles as possible Console Device
684 for (Index
= 0; Index
< GopHandleCount
; Index
++) {
685 Status
= gBS
->HandleProtocol (GopHandleBuffer
[Index
], &gEfiDevicePathProtocolGuid
, (VOID
*)&TempDevicePath
);
686 if (EFI_ERROR (Status
)) {
692 GetDevicePathSize (PciDevicePath
) - END_DEVICE_PATH_LENGTH
695 // In current implementation, we only enable one of the child handles
696 // as console device, i.e. sotre one of the child handle's device
697 // path to variable "ConOut"
698 // In futhure, we could select all child handles to be console device
701 *GopDevicePath
= TempDevicePath
;
704 // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()
705 // Add the integrity GOP device path.
707 BdsLibUpdateConsoleVariable (VarConsoleOutDev
, NULL
, PciDevicePath
);
708 BdsLibUpdateConsoleVariable (VarConsoleOutDev
, TempDevicePath
, NULL
);
711 gBS
->FreePool (GopHandleBuffer
);
718 PreparePciVgaDevicePath (
719 IN EFI_HANDLE DeviceHandle
725 Add PCI VGA to ConOut.
730 DeviceHandle - Handle of PCIIO protocol.
734 EFI_SUCCESS - PCI VGA is added to ConOut.
735 EFI_STATUS - No PCI VGA device is added.
740 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
741 EFI_DEVICE_PATH_PROTOCOL
*GopDevicePath
;
744 Status
= gBS
->HandleProtocol (
746 &gEfiDevicePathProtocolGuid
,
749 if (EFI_ERROR (Status
)) {
753 GetGopDevicePath (DevicePath
, &GopDevicePath
);
754 DevicePath
= GopDevicePath
;
756 BdsLibUpdateConsoleVariable (VarConsoleOut
, DevicePath
, NULL
);
762 PreparePciSerialDevicePath (
763 IN EFI_HANDLE DeviceHandle
769 Add PCI Serial to ConOut, ConIn, ErrOut.
774 DeviceHandle - Handle of PCIIO protocol.
778 EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.
779 EFI_STATUS - No PCI Serial device is added.
784 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
787 Status
= gBS
->HandleProtocol (
789 &gEfiDevicePathProtocolGuid
,
792 if (EFI_ERROR (Status
)) {
796 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gUartDeviceNode
);
797 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gTerminalTypeDeviceNode
);
799 BdsLibUpdateConsoleVariable (VarConsoleOut
, DevicePath
, NULL
);
800 BdsLibUpdateConsoleVariable (VarConsoleInp
, DevicePath
, NULL
);
801 BdsLibUpdateConsoleVariable (VarErrorOut
, DevicePath
, NULL
);
807 DetectAndPreparePlatformPciDevicePath (
808 BOOLEAN DetectVgaOnly
814 Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
818 DetectVgaOnly - Only detect VGA device if it's TRUE.
822 EFI_SUCCESS - PCI Device check and Console variable update successfully.
823 EFI_STATUS - PCI Device check or Console variable update fail.
829 EFI_HANDLE
*HandleBuffer
;
831 EFI_PCI_IO_PROTOCOL
*PciIo
;
835 // Start to check all the PciIo to find all possible device
839 Status
= gBS
->LocateHandleBuffer (
841 &gEfiPciIoProtocolGuid
,
846 if (EFI_ERROR (Status
)) {
850 for (Index
= 0; Index
< HandleCount
; Index
++) {
851 Status
= gBS
->HandleProtocol (HandleBuffer
[Index
], &gEfiPciIoProtocolGuid
, (VOID
*)&PciIo
);
852 if (EFI_ERROR (Status
)) {
857 // Check for all PCI device
859 Status
= PciIo
->Pci
.Read (
863 sizeof (Pci
) / sizeof (UINT32
),
866 if (EFI_ERROR (Status
)) {
870 if (!DetectVgaOnly
) {
872 // Here we decide whether it is LPC Bridge
874 if ((IS_PCI_LPC (&Pci
)) ||
875 ((IS_PCI_ISA_PDECODE (&Pci
)) && (Pci
.Hdr
.VendorId
== 0x8086) && (Pci
.Hdr
.DeviceId
== 0x7110))) {
877 // Add IsaKeyboard to ConIn,
878 // add IsaSerial to ConOut, ConIn, ErrOut
880 DEBUG ((EFI_D_INFO
, "Find the LPC Bridge device\n"));
881 PrepareLpcBridgeDevicePath (HandleBuffer
[Index
]);
885 // Here we decide which Serial device to enable in PCI bus
887 if (IS_PCI_16550SERIAL (&Pci
)) {
889 // Add them to ConOut, ConIn, ErrOut.
891 DEBUG ((EFI_D_INFO
, "Find the 16550 SERIAL device\n"));
892 PreparePciSerialDevicePath (HandleBuffer
[Index
]);
898 // Here we decide which VGA device to enable in PCI bus
900 if (IS_PCI_VGA (&Pci
)) {
902 // Add them to ConOut.
904 DEBUG ((EFI_D_INFO
, "Find the VGA device\n"));
905 PreparePciVgaDevicePath (HandleBuffer
[Index
]);
910 gBS
->FreePool (HandleBuffer
);
916 PlatformBdsConnectConsole (
917 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
923 Connect the predefined platform default console device. Always try to find
924 and enable the vga device if have.
928 PlatformConsole - Predfined platform default console device array.
932 EFI_SUCCESS - Success connect at least one ConIn and ConOut
933 device, there must have one ConOut device is
936 EFI_STATUS - Return the status of
937 BdsLibConnectAllDefaultConsoles ()
943 EFI_DEVICE_PATH_PROTOCOL
*VarConout
;
944 EFI_DEVICE_PATH_PROTOCOL
*VarConin
;
945 UINTN DevicePathSize
;
948 // Connect RootBridge
950 ConnectRootBridge ();
952 VarConout
= BdsLibGetVariableAndSize (
954 &gEfiGlobalVariableGuid
,
957 VarConin
= BdsLibGetVariableAndSize (
959 &gEfiGlobalVariableGuid
,
963 if (VarConout
== NULL
|| VarConin
== NULL
) {
965 // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
967 DetectAndPreparePlatformPciDevicePath (FALSE
);
970 // Have chance to connect the platform default console,
971 // the platform default console is the minimue device group
972 // the platform should support
974 for (Index
= 0; PlatformConsole
[Index
].DevicePath
!= NULL
; ++Index
) {
976 // Update the console variable with the connect type
978 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
979 BdsLibUpdateConsoleVariable (VarConsoleInp
, PlatformConsole
[Index
].DevicePath
, NULL
);
981 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
982 BdsLibUpdateConsoleVariable (VarConsoleOut
, PlatformConsole
[Index
].DevicePath
, NULL
);
984 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
985 BdsLibUpdateConsoleVariable (VarErrorOut
, PlatformConsole
[Index
].DevicePath
, NULL
);
990 // Only detect VGA device and add them to ConOut
992 DetectAndPreparePlatformPciDevicePath (TRUE
);
996 // The ConIn devices connection will start the USB bus, should disable all
997 // Usb legacy support firstly.
998 // Caution: Must ensure the PCI bus driver has been started. Since the
999 // ConnectRootBridge() will create all the PciIo protocol, it's safe here now
1001 Status
= DisableUsbLegacySupport();
1004 // Connect the all the default console with current cosole variable
1006 Status
= BdsLibConnectAllDefaultConsoles ();
1007 if (EFI_ERROR (Status
)) {
1015 PlatformBdsConnectSequence (
1020 Routine Description:
1022 Connect with predeined platform connect sequence,
1023 the OEM/IBV can customize with their own connect sequence.
1040 // Here we can get the customized platform connect sequence
1041 // Notes: we can connect with new variable which record the
1042 // last time boots connect device path sequence
1044 while (gPlatformConnectSequence
[Index
] != NULL
) {
1046 // Build the platform boot option
1048 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
1055 PlatformBdsGetDriverOption (
1056 IN OUT LIST_ENTRY
*BdsDriverLists
1060 Routine Description:
1062 Load the predefined driver option, OEM/IBV can customize this
1063 to load their own drivers
1067 BdsDriverLists - The header of the driver option link list.
1080 // Here we can get the customized platform driver option
1082 while (gPlatformDriverOption
[Index
] != NULL
) {
1084 // Build the platform boot option
1086 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
1093 PlatformBdsDiagnostics (
1094 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
1095 IN BOOLEAN QuietBoot
,
1096 IN BASEM_MEMORY_TEST BaseMemoryTest
1100 Routine Description:
1102 Perform the platform diagnostic, such like test memory. OEM/IBV also
1103 can customize this fuction to support specific platform diagnostic.
1107 MemoryTestLevel - The memory test intensive level
1109 QuietBoot - Indicate if need to enable the quiet boot
1111 BaseMemoryTest - A pointer to BdsMemoryTest()
1122 // Here we can decide if we need to show
1123 // the diagnostics screen
1124 // Notes: this quiet boot code should be remove
1125 // from the graphic lib
1128 Status
= EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
1129 if (EFI_ERROR (Status
)) {
1130 DisableQuietBoot ();
1135 // Perform system diagnostic
1137 Status
= BaseMemoryTest (MemoryTestLevel
);
1138 if (EFI_ERROR (Status
)) {
1139 DisableQuietBoot ();
1145 // Perform system diagnostic
1147 Status
= BaseMemoryTest (MemoryTestLevel
);
1152 PlatformBdsPolicyBehavior (
1153 IN OUT LIST_ENTRY
*DriverOptionList
,
1154 IN OUT LIST_ENTRY
*BootOptionList
,
1155 IN PROCESS_CAPSULES ProcessCapsules
,
1156 IN BASEM_MEMORY_TEST BaseMemoryTest
1160 Routine Description:
1162 The function will excute with as the platform policy, current policy
1163 is driven by boot mode. IBV/OEM can customize this code for their specific
1168 DriverOptionList - The header of the driver option link list
1170 BootOptionList - The header of the boot option link list
1180 EFI_EVENT UserInputDurationTime
;
1182 BDS_COMMON_OPTION
*BootOption
;
1186 EFI_BOOT_MODE BootMode
;
1189 // Init the time out value
1191 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
1194 // Load the driver option as the driver option list
1196 PlatformBdsGetDriverOption (DriverOptionList
);
1199 // Get current Boot Mode
1201 Status
= BdsLibGetBootMode (&BootMode
);
1202 DEBUG ((EFI_D_ERROR
, "Boot Mode:%x\n", BootMode
));
1205 // Go the different platform policy with different boot mode
1206 // Notes: this part code can be change with the table policy
1208 ASSERT (BootMode
== BOOT_WITH_FULL_CONFIGURATION
);
1210 // Connect platform console
1212 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
1213 if (EFI_ERROR (Status
)) {
1215 // Here OEM/IBV can customize with defined action
1217 PlatformBdsNoConsoleAction ();
1220 // Create a 300ms duration event to ensure user has enough input time to enter Setup
1222 Status
= gBS
->CreateEvent (
1227 &UserInputDurationTime
1229 ASSERT (Status
== EFI_SUCCESS
);
1230 Status
= gBS
->SetTimer (UserInputDurationTime
, TimerRelative
, 3000000);
1231 ASSERT (Status
== EFI_SUCCESS
);
1233 // Memory test and Logo show
1235 PlatformBdsDiagnostics (IGNORE
, TRUE
, BaseMemoryTest
);
1238 // Perform some platform specific connect sequence
1240 PlatformBdsConnectSequence ();
1243 // Give one chance to enter the setup if we
1244 // have the time out
1246 // BUGBUG: hard code timeout to 5 second to show logo in graphic mode.
1249 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
1253 //BdsLibConnectAll ();
1254 //BdsLibEnumerateAllBootOption (BootOptionList);
1257 // Please uncomment above ConnectAll and EnumerateAll code and remove following first boot
1258 // checking code in real production tip.
1260 // In BOOT_WITH_FULL_CONFIGURATION boot mode, should always connect every device
1261 // and do enumerate all the default boot options. But in development system board, the boot mode
1262 // cannot be BOOT_ASSUMING_NO_CONFIGURATION_CHANGES because the machine box
1263 // is always open. So the following code only do the ConnectAll and EnumerateAll at first boot.
1265 Status
= BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
1266 if (EFI_ERROR(Status
)) {
1268 // If cannot find "BootOrder" variable, it may be first boot.
1269 // Try to connect all devices and enumerate all boot options here.
1271 BdsLibConnectAll ();
1272 BdsLibEnumerateAllBootOption (BootOptionList
);
1276 // To give the User a chance to enter Setup here, if user set TimeOut is 0.
1277 // BDS should still give user a chance to enter Setup
1279 // Connect first boot option, and then check user input before exit
1281 for (Link
= BootOptionList
->ForwardLink
; Link
!= BootOptionList
;Link
= Link
->ForwardLink
) {
1282 BootOption
= CR (Link
, BDS_COMMON_OPTION
, Link
, BDS_LOAD_OPTION_SIGNATURE
);
1283 if (!IS_LOAD_OPTION_TYPE (BootOption
->Attribute
, LOAD_OPTION_ACTIVE
)) {
1285 // skip the header of the link list, becuase it has no boot option
1290 // Make sure the boot option device path connected, but ignore the BBS device path
1292 if (DevicePathType (BootOption
->DevicePath
) != BBS_DEVICE_PATH
) {
1293 BdsLibConnectDevicePath (BootOption
->DevicePath
);
1300 // Check whether the user input after the duration time has expired
1302 OldTpl
= EfiGetCurrentTpl();
1303 gBS
->RestoreTPL (TPL_APPLICATION
);
1304 gBS
->WaitForEvent (1, &UserInputDurationTime
, &Index
);
1305 gBS
->CloseEvent (UserInputDurationTime
);
1306 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
1307 gBS
->RaiseTPL (OldTpl
);
1309 if (!EFI_ERROR (Status
)) {
1311 // Enter Setup if user input
1314 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
1323 PlatformBdsBootSuccess (
1324 IN BDS_COMMON_OPTION
*Option
1328 Routine Description:
1330 Hook point after a boot attempt succeeds. We don't expect a boot option to
1331 return, so the EFI 1.0 specification defines that you will default to an
1332 interactive mode and stop processing the BootOrder list in this case. This
1333 is alos a platform implementation and can be customized by IBV/OEM.
1337 Option - Pointer to Boot Option that succeeded to boot.
1348 // If Boot returned with EFI_SUCCESS and there is not in the boot device
1349 // select loop then we need to pop up a UI and wait for user input.
1351 TmpStr
= Option
->StatusString
;
1352 if (TmpStr
!= NULL
) {
1353 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
1354 gBS
->FreePool (TmpStr
);
1360 PlatformBdsBootFail (
1361 IN BDS_COMMON_OPTION
*Option
,
1362 IN EFI_STATUS Status
,
1363 IN CHAR16
*ExitData
,
1364 IN UINTN ExitDataSize
1368 Routine Description:
1370 Hook point after a boot attempt fails.
1374 Option - Pointer to Boot Option that failed to boot.
1376 Status - Status returned from failed boot.
1378 ExitData - Exit data returned from failed boot.
1380 ExitDataSize - Exit data size returned from failed boot.
1391 // If Boot returned with failed status then we need to pop up a UI and wait
1394 TmpStr
= Option
->StatusString
;
1395 if (TmpStr
!= NULL
) {
1396 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
1397 gBS
->FreePool (TmpStr
);
1403 PlatformBdsNoConsoleAction (
1408 Routine Description:
1410 This function is remained for IBV/OEM to do some platform action,
1411 if there no console device can be connected.
1419 EFI_SUCCESS - Direct return success now.
1427 ConvertSystemTable (
1428 IN EFI_GUID
*TableGuid
,
1433 Routine Description:
1434 Convert ACPI Table /Smbios Table /MP Table if its location is lower than Address:0x100000
1436 As in legacy Bios, ACPI/Smbios/MP table is required to place in E/F Seg,
1437 So here we just check if the range is E/F seg,
1438 and if Not, assume the Memory type is EfiACPIReclaimMemory/EfiACPIMemoryNVS
1441 TableGuid - Guid of the table
1442 Table - pointer to the table
1445 EFI_SUCEESS - Convert Table successfully
1455 // If match acpi guid (1.0, 2.0, or later), Convert ACPI table according to version.
1457 AcpiHeader
= (VOID
*)(UINTN
)(*(UINT64
*)(*Table
));
1459 if (CompareGuid(TableGuid
, &gEfiAcpiTableGuid
) || CompareGuid(TableGuid
, &gEfiAcpi20TableGuid
)){
1460 if (((EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
*)AcpiHeader
)->Reserved
== 0x00){
1462 // If Acpi 1.0 Table, then RSDP structure doesn't contain Length field, use structure size
1464 AcpiTableLen
= sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
);
1465 } else if (((EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
*)AcpiHeader
)->Reserved
>= 0x02){
1467 // If Acpi 2.0 or later, use RSDP Length fied.
1469 AcpiTableLen
= ((EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER
*)AcpiHeader
)->Length
;
1472 // Invalid Acpi Version, return
1474 return EFI_UNSUPPORTED
;
1476 Status
= ConvertAcpiTable (AcpiTableLen
, Table
);
1481 // If matches smbios guid, convert Smbios table.
1483 if (CompareGuid(TableGuid
, &gEfiSmbiosTableGuid
)){
1484 Status
= ConvertSmbiosTable (Table
);
1489 // If the table is MP table?
1491 if (CompareGuid(TableGuid
, &gEfiMpsTableGuid
)){
1492 Status
= ConvertMpsTable (Table
);
1496 return EFI_UNSUPPORTED
;
1507 Routine Description:
1508 Convert RSDP of ACPI Table if its location is lower than Address:0x100000
1510 As in legacy Bios, ACPI table is required to place in E/F Seg,
1511 So here we just check if the range is E/F seg,
1512 and if Not, assume the Memory type is EfiACPIReclaimMemory/EfiACPIMemoryNVS
1515 TableLen - Acpi RSDP length
1516 Table - pointer to the table
1519 EFI_SUCEESS - Convert Table successfully
1527 EFI_PHYSICAL_ADDRESS BufferPtr
;
1530 AcpiTableOri
= (VOID
*)(UINTN
)(*(UINT64
*)(*Table
));
1531 if (((UINTN
)AcpiTableOri
< 0x100000) && ((UINTN
)AcpiTableOri
> 0xE0000)) {
1532 BufferPtr
= EFI_SYSTEM_TABLE_MAX_ADDRESS
;
1533 Status
= gBS
->AllocatePages (
1536 EFI_SIZE_TO_PAGES(TableLen
),
1539 ASSERT_EFI_ERROR (Status
);
1540 AcpiTableNew
= (VOID
*)(UINTN
)BufferPtr
;
1541 CopyMem (AcpiTableNew
, AcpiTableOri
, TableLen
);
1543 AcpiTableNew
= AcpiTableOri
;
1546 // Change configuration table Pointer
1548 *Table
= AcpiTableNew
;
1554 ConvertSmbiosTable (
1559 Routine Description:
1561 Convert Smbios Table if the Location of the SMBios Table is lower than Addres 0x100000
1563 As in legacy Bios, Smbios table is required to place in E/F Seg,
1564 So here we just check if the range is F seg,
1565 and if Not, assume the Memory type is EfiACPIMemoryNVS/EfiRuntimeServicesData
1567 Table - pointer to the table
1570 EFI_SUCEESS - Convert Table successfully
1575 SMBIOS_TABLE_ENTRY_POINT
*SmbiosTableNew
;
1576 SMBIOS_TABLE_ENTRY_POINT
*SmbiosTableOri
;
1578 UINT32 SmbiosEntryLen
;
1580 EFI_PHYSICAL_ADDRESS BufferPtr
;
1582 SmbiosTableNew
= NULL
;
1583 SmbiosTableOri
= NULL
;
1586 // Get Smibos configuration Table
1588 SmbiosTableOri
= (SMBIOS_TABLE_ENTRY_POINT
*)(UINTN
)(*(UINT64
*)(*Table
));
1590 if ((SmbiosTableOri
== NULL
) ||
1591 ((UINTN
)SmbiosTableOri
> 0x100000) ||
1592 ((UINTN
)SmbiosTableOri
< 0xF0000)){
1596 // Relocate the Smibos memory
1598 BufferPtr
= EFI_SYSTEM_TABLE_MAX_ADDRESS
;
1599 if (SmbiosTableOri
->SmbiosBcdRevision
!= 0x21) {
1600 SmbiosEntryLen
= SmbiosTableOri
->EntryPointLength
;
1603 // According to Smbios Spec 2.4, we should set entry point length as 0x1F if version is 2.1
1605 SmbiosEntryLen
= 0x1F;
1607 BufferLen
= SmbiosEntryLen
+ SYS_TABLE_PAD(SmbiosEntryLen
) + SmbiosTableOri
->TableLength
;
1608 Status
= gBS
->AllocatePages (
1611 EFI_SIZE_TO_PAGES(BufferLen
),
1614 ASSERT_EFI_ERROR (Status
);
1615 SmbiosTableNew
= (SMBIOS_TABLE_ENTRY_POINT
*)(UINTN
)BufferPtr
;
1622 // Get Smbios Structure table address, and make sure the start address is 32-bit align
1624 BufferPtr
+= SmbiosEntryLen
+ SYS_TABLE_PAD(SmbiosEntryLen
);
1626 (VOID
*)(UINTN
)BufferPtr
,
1627 (VOID
*)(UINTN
)(SmbiosTableOri
->TableAddress
),
1628 SmbiosTableOri
->TableLength
1630 SmbiosTableNew
->TableAddress
= (UINT32
)BufferPtr
;
1631 SmbiosTableNew
->IntermediateChecksum
= 0;
1632 SmbiosTableNew
->IntermediateChecksum
=
1633 CalculateCheckSum8 ((UINT8
*)SmbiosTableNew
+ 0x10, SmbiosEntryLen
-0x10);
1635 // Change the SMBIOS pointer
1637 *Table
= SmbiosTableNew
;
1648 Routine Description:
1650 Convert MP Table if the Location of the SMBios Table is lower than Addres 0x100000
1652 As in legacy Bios, MP table is required to place in E/F Seg,
1653 So here we just check if the range is E/F seg,
1654 and if Not, assume the Memory type is EfiACPIMemoryNVS/EfiRuntimeServicesData
1656 Table - pointer to the table
1659 EFI_SUCEESS - Convert Table successfully
1666 EFI_LEGACY_MP_TABLE_FLOATING_POINTER
*MpsFloatingPointerOri
;
1667 EFI_LEGACY_MP_TABLE_FLOATING_POINTER
*MpsFloatingPointerNew
;
1668 EFI_LEGACY_MP_TABLE_HEADER
*MpsTableOri
;
1669 EFI_LEGACY_MP_TABLE_HEADER
*MpsTableNew
;
1673 EFI_PHYSICAL_ADDRESS BufferPtr
;
1676 // Get MP configuration Table
1678 MpsFloatingPointerOri
= (EFI_LEGACY_MP_TABLE_FLOATING_POINTER
*)(UINTN
)(*(UINT64
*)(*Table
));
1679 if (!(((UINTN
)MpsFloatingPointerOri
<= 0x100000) &&
1680 ((UINTN
)MpsFloatingPointerOri
>= 0xF0000))){
1684 // Get Floating pointer structure length
1686 FPLength
= MpsFloatingPointerOri
->Length
* 16;
1687 Data32
= FPLength
+ SYS_TABLE_PAD (FPLength
);
1688 MpsTableOri
= (EFI_LEGACY_MP_TABLE_HEADER
*)(UINTN
)(MpsFloatingPointerOri
->PhysicalAddress
);
1689 if (MpsTableOri
!= NULL
) {
1690 Data32
+= MpsTableOri
->BaseTableLength
;
1691 Data32
+= MpsTableOri
->ExtendedTableLength
;
1692 if (MpsTableOri
->OemTablePointer
!= 0x00) {
1693 Data32
+= SYS_TABLE_PAD (Data32
);
1694 Data32
+= MpsTableOri
->OemTableSize
;
1702 BufferPtr
= EFI_SYSTEM_TABLE_MAX_ADDRESS
;
1703 Status
= gBS
->AllocatePages (
1706 EFI_SIZE_TO_PAGES(Data32
),
1709 ASSERT_EFI_ERROR (Status
);
1710 MpsFloatingPointerNew
= (EFI_LEGACY_MP_TABLE_FLOATING_POINTER
*)(UINTN
)BufferPtr
;
1711 CopyMem (MpsFloatingPointerNew
, MpsFloatingPointerOri
, FPLength
);
1713 // If Mp Table exists
1715 if (MpsTableOri
!= NULL
) {
1717 // Get Mps table length, including Ext table
1719 BufferPtr
= BufferPtr
+ FPLength
+ SYS_TABLE_PAD (FPLength
);
1720 MpsTableNew
= (EFI_LEGACY_MP_TABLE_HEADER
*)(UINTN
)BufferPtr
;
1721 CopyMem (MpsTableNew
, MpsTableOri
, MpsTableOri
->BaseTableLength
+ MpsTableOri
->ExtendedTableLength
);
1723 if ((MpsTableOri
->OemTableSize
!= 0x0000) && (MpsTableOri
->OemTablePointer
!= 0x0000)){
1724 BufferPtr
+= MpsTableOri
->BaseTableLength
+ MpsTableOri
->ExtendedTableLength
;
1725 BufferPtr
+= SYS_TABLE_PAD (BufferPtr
);
1726 OemTableNew
= (VOID
*)(UINTN
)BufferPtr
;
1727 OemTableOri
= (VOID
*)(UINTN
)MpsTableOri
->OemTablePointer
;
1728 CopyMem (OemTableNew
, OemTableOri
, MpsTableOri
->OemTableSize
);
1729 MpsTableNew
->OemTablePointer
= (UINT32
)(UINTN
)OemTableNew
;
1731 MpsTableNew
->Checksum
= 0;
1732 MpsTableNew
->Checksum
= CalculateCheckSum8 ((UINT8
*)MpsTableNew
, MpsTableOri
->BaseTableLength
);
1733 MpsFloatingPointerNew
->PhysicalAddress
= (UINT32
)(UINTN
)MpsTableNew
;
1734 MpsFloatingPointerNew
->Checksum
= 0;
1735 MpsFloatingPointerNew
->Checksum
= CalculateCheckSum8 ((UINT8
*)MpsFloatingPointerNew
, FPLength
);
1738 // Change the pointer
1740 *Table
= MpsFloatingPointerNew
;
1746 Lock the ConsoleIn device in system table. All key
1747 presses will be ignored until the Password is typed in. The only way to
1748 disable the password is to type it in to a ConIn device.
1750 @param Password Password used to lock ConIn device.
1752 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
1753 @retval EFI_UNSUPPORTED Password not found
1762 return EFI_UNSUPPORTED
;
1766 This function locks platform flash that is not allowed to be updated during normal boot path.
1767 The flash layout is platform specific.
1772 PlatformBdsLockNonUpdatableFlash (