## @file\r
# Coreboot Payload Package\r
#\r
-# Provides drivers and definitions to create uefi payload for coreboot. \r
+# Provides drivers and definitions to create uefi payload for coreboot.\r
#\r
# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials are licensed and made available under \r
-# the terms and conditions of the BSD License that accompanies this distribution. \r
+# This program and the accompanying materials are licensed and made available under\r
+# the terms and conditions of the BSD License that accompanies this distribution.\r
# The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php. \r
-# \r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+# http://opensource.org/licenses/bsd-license.php.\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
##\r
\r
PACKAGE_NAME = CorebootPayloadPkg\r
PACKAGE_GUID = 58ABC905-951E-472e-8590-77BA8A50BE63\r
PACKAGE_VERSION = 0.1\r
- \r
+\r
[LibraryClasses]\r
- \r
+\r
[Guids]\r
#\r
## Defines the token space for the Coreboot Payload Package PCDs.\r
#\r
- gUEfiCorebootPayloadPkgTokenSpaceGuid = {0x1d127ea, 0xf6f1, 0x4ef6, {0x94, 0x15, 0x8a, 0x0, 0x0, 0x93, 0xf8, 0x9d}} \r
- \r
+ gUEfiCorebootPayloadPkgTokenSpaceGuid = {0x1d127ea, 0xf6f1, 0x4ef6, {0x94, 0x15, 0x8a, 0x0, 0x0, 0x93, 0xf8, 0x9d}}\r
+\r
#\r
# Gop Temp\r
#\r
[PcdsFixedAtBuild, PcdsPatchableInModule]\r
\r
[PcdsDynamic, PcdsDynamicEx]\r
- \r
+\r
--- /dev/null
+/** @file\r
+ This file include all platform action which can be customized\r
+ by IBV/OEM.\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "PlatformBootManager.h"\r
+#include "PlatformConsole.h"\r
+\r
+/**\r
+ Return the index of the load option in the load option array.\r
+\r
+ The function consider two load options are equal when the\r
+ OptionType, Attributes, Description, FilePath and OptionalData are equal.\r
+\r
+ @param Key Pointer to the load option to be found.\r
+ @param Array Pointer to the array of load options to be found.\r
+ @param Count Number of entries in the Array.\r
+\r
+ @retval -1 Key wasn't found in the Array.\r
+ @retval 0 ~ Count-1 The index of the Key in the Array.\r
+**/\r
+INTN\r
+PlatformFindLoadOption (\r
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,\r
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,\r
+ IN UINTN Count\r
+)\r
+{\r
+ UINTN Index;\r
+\r
+ for (Index = 0; Index < Count; Index++) {\r
+ if ((Key->OptionType == Array[Index].OptionType) &&\r
+ (Key->Attributes == Array[Index].Attributes) &&\r
+ (StrCmp (Key->Description, Array[Index].Description) == 0) &&\r
+ (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&\r
+ (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&\r
+ (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {\r
+ return (INTN) Index;\r
+ }\r
+ }\r
+\r
+ return -1;\r
+}\r
+\r
+/**\r
+ Register a boot option using a file GUID in the FV.\r
+\r
+ @param FileGuid The file GUID name in FV.\r
+ @param Description The boot option description.\r
+ @param Attributes The attributes used for the boot option loading.\r
+**/\r
+VOID\r
+PlatformRegisterFvBootOption (\r
+ EFI_GUID *FileGuid,\r
+ CHAR16 *Description,\r
+ UINT32 Attributes\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN OptionIndex;\r
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;\r
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;\r
+ UINTN BootOptionCount;\r
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;\r
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);\r
+ DevicePath = AppendDevicePathNode (\r
+ DevicePathFromHandle (LoadedImage->DeviceHandle),\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &FileNode\r
+ );\r
+\r
+ Status = EfiBootManagerInitializeLoadOption (\r
+ &NewOption,\r
+ LoadOptionNumberUnassigned,\r
+ LoadOptionTypeBoot,\r
+ Attributes,\r
+ Description,\r
+ DevicePath,\r
+ NULL,\r
+ 0\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
+\r
+ OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);\r
+\r
+ if (OptionIndex == -1) {\r
+ Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ EfiBootManagerFreeLoadOption (&NewOption);\r
+ EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);\r
+ }\r
+}\r
+\r
+/**\r
+ Do the platform specific action before the console is connected.\r
+\r
+ Such as:\r
+ Update console variable;\r
+ Register new Driver#### or Boot####;\r
+ Signal ReadyToLock event.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerBeforeConsole (\r
+ VOID\r
+)\r
+{\r
+ EFI_INPUT_KEY Enter;\r
+ EFI_INPUT_KEY F2;\r
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
+\r
+ PlatformConsoleInit ();\r
+\r
+ //\r
+ // Register ENTER as CONTINUE key\r
+ //\r
+ Enter.ScanCode = SCAN_NULL;\r
+ Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;\r
+ EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);\r
+\r
+ //\r
+ // Map F2 to Boot Manager Menu\r
+ //\r
+ F2.ScanCode = SCAN_F2;\r
+ F2.UnicodeChar = CHAR_NULL;\r
+ EfiBootManagerGetBootManagerMenu (&BootOption);\r
+ EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);\r
+\r
+ //\r
+ // Register UEFI Shell\r
+ //\r
+ PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", LOAD_OPTION_ACTIVE);\r
+}\r
+\r
+/**\r
+ Do the platform specific action after the console is connected.\r
+\r
+ Such as:\r
+ Dynamically switch output mode;\r
+ Signal console ready platform customized event;\r
+ Run diagnostics like memory testing;\r
+ Connect certain devices;\r
+ Dispatch aditional option roms.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerAfterConsole (\r
+ VOID\r
+)\r
+{\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;\r
+\r
+ Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;\r
+ White.Blue = White.Green = White.Red = White.Reserved = 0xFF;\r
+\r
+ EfiBootManagerConnectAll ();\r
+ EfiBootManagerRefreshAllBootOption ();\r
+\r
+ Print (\r
+ L"\n"\r
+ L"F2 to enter Boot Manager Menu.\n"\r
+ L"ENTER to boot directly.\n"\r
+ L"\n"\r
+ );\r
+\r
+}\r
+\r
+/**\r
+ This function is called each second during the boot manager waits the timeout.\r
+\r
+ @param TimeoutRemain The remaining timeout.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerWaitCallback (\r
+ UINT16 TimeoutRemain\r
+)\r
+{\r
+ return;\r
+}\r
--- /dev/null
+/**@file\r
+ Head file for BDS Platform specific code\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef _PLATFORM_BOOT_MANAGER_H\r
+#define _PLATFORM_BOOT_MANAGER_H\r
+\r
+#include <PiDxe.h>\r
+#include <Protocol/LoadedImage.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiBootManagerLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/DxeServicesLib.h>\r
+#include <Library/BootLogoLib.h>\r
+\r
+\r
+typedef struct {\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ UINTN ConnectType;\r
+} PLATFORM_CONSOLE_CONNECT_ENTRY;\r
+\r
+extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];\r
+\r
+#define gEndEntire \\r
+ { \\r
+ END_DEVICE_PATH_TYPE,\\r
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,\\r
+ END_DEVICE_PATH_LENGTH,\\r
+ 0\\r
+ }\r
+\r
+#define CONSOLE_OUT BIT0\r
+#define CONSOLE_IN BIT1\r
+#define STD_ERROR BIT2\r
+\r
+typedef struct {\r
+ VENDOR_DEVICE_PATH VendorDevicePath;\r
+ UINT32 Instance;\r
+} WIN_NT_VENDOR_DEVICE_PATH_NODE;\r
+\r
+//\r
+// Below is the platform console device path\r
+//\r
+typedef struct {\r
+ VENDOR_DEVICE_PATH NtBus;\r
+ WIN_NT_VENDOR_DEVICE_PATH_NODE SerialDevice;\r
+ UART_DEVICE_PATH Uart;\r
+ VENDOR_DEVICE_PATH TerminalType;\r
+ EFI_DEVICE_PATH_PROTOCOL End;\r
+} NT_ISA_SERIAL_DEVICE_PATH;\r
+\r
+typedef struct {\r
+ VENDOR_DEVICE_PATH NtBus;\r
+ WIN_NT_VENDOR_DEVICE_PATH_NODE NtGopDevice;\r
+ EFI_DEVICE_PATH_PROTOCOL End;\r
+} NT_PLATFORM_GOP_DEVICE_PATH;\r
+\r
+/**\r
+ Use SystemTable Conout to stop video based Simple Text Out consoles from going\r
+ to the video device. Put up LogoFile on every video device that is a console.\r
+\r
+ @param[in] LogoFile File name of logo to display on the center of the screen.\r
+\r
+ @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
+ @retval EFI_UNSUPPORTED Logo not found\r
+\r
+**/\r
+EFI_STATUS\r
+PlatformBootManagerEnableQuietBoot (\r
+ IN EFI_GUID *LogoFile\r
+);\r
+\r
+/**\r
+ Use SystemTable Conout to turn on video based Simple Text Out consoles. The\r
+ Simple Text Out screens will now be synced up with all non video output devices\r
+\r
+ @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
+\r
+**/\r
+EFI_STATUS\r
+PlatformBootManagerDisableQuietBoot (\r
+ VOID\r
+);\r
+\r
+/**\r
+ Show progress bar with title above it. It only works in Graphics mode.\r
+\r
+ @param TitleForeground Foreground color for Title.\r
+ @param TitleBackground Background color for Title.\r
+ @param Title Title above progress bar.\r
+ @param ProgressColor Progress bar color.\r
+ @param Progress Progress (0-100)\r
+ @param PreviousValue The previous value of the progress.\r
+\r
+ @retval EFI_STATUS Success update the progress bar\r
+\r
+**/\r
+EFI_STATUS\r
+PlatformBootManagerShowProgress (\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,\r
+ IN CHAR16 *Title,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,\r
+ IN UINTN Progress,\r
+ IN UINTN PreviousValue\r
+);\r
+\r
+#endif // _PLATFORM_BOOT_MANAGER_H\r
--- /dev/null
+## @file\r
+# Include all platform action which can be customized by IBV/OEM.\r
+#\r
+# Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PlatformBootManagerLib\r
+ FILE_GUID = F0D9063A-DADB-4185-85E2-D7ACDA93F7A6\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 EBC\r
+#\r
+\r
+[Sources]\r
+ PlatformData.c\r
+ PlatformConsole.c\r
+ PlatformConsole.h\r
+ PlatformBootManager.c\r
+ PlatformBootManager.h\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+ CorebootPayloadPkg/CorebootPayloadPkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ UefiBootServicesTableLib\r
+ UefiRuntimeServicesTableLib\r
+ UefiLib\r
+ UefiBootManagerLib\r
+ PcdLib\r
+ DxeServicesLib\r
+ MemoryAllocationLib\r
+ DevicePathLib\r
+ HiiLib\r
+ PrintLib\r
+\r
+[Guids]\r
+\r
+\r
+[Protocols]\r
+ gEfiGenericMemTestProtocolGuid ## CONSUMES\r
+ gEfiGraphicsOutputProtocolGuid ## CONSUMES\r
+ gEfiUgaDrawProtocolGuid ## CONSUMES\r
+ gEfiBootLogoProtocolGuid ## CONSUMES\r
+\r
+[Pcd]\r
+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
+ gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand\r
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootlogoOnlyEnable\r
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile\r
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile\r
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate\r
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits\r
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity\r
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits\r
--- /dev/null
+/** @file\r
+This file include all platform action which can be customized by IBV/OEM.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "PlatformBootManager.h"\r
+#include "PlatformConsole.h"\r
+\r
+#define PCI_DEVICE_PATH_NODE(Func, Dev) \\r
+ { \\r
+ { \\r
+ HARDWARE_DEVICE_PATH, \\r
+ HW_PCI_DP, \\r
+ { \\r
+ (UINT8) (sizeof (PCI_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \\r
+ } \\r
+ }, \\r
+ (Func), \\r
+ (Dev) \\r
+ }\r
+\r
+#define PNPID_DEVICE_PATH_NODE(PnpId) \\r
+ { \\r
+ { \\r
+ ACPI_DEVICE_PATH, \\r
+ ACPI_DP, \\r
+ { \\r
+ (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \\r
+ }, \\r
+ }, \\r
+ EISA_PNP_ID((PnpId)), \\r
+ 0 \\r
+ }\r
+\r
+#define gPciRootBridge \\r
+ PNPID_DEVICE_PATH_NODE(0x0A03)\r
+\r
+#define gPnp16550ComPort \\r
+ PNPID_DEVICE_PATH_NODE(0x0501)\r
+\r
+#define gUartVendor \\r
+ { \\r
+ { \\r
+ HARDWARE_DEVICE_PATH, \\r
+ HW_VENDOR_DP, \\r
+ { \\r
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \\r
+ } \\r
+ }, \\r
+ {0xD3987D4B, 0x971A, 0x435F, {0x8C, 0xAF, 0x49, 0x67, 0xEB, 0x62, 0x72, 0x41}} \\r
+ }\r
+\r
+#define gUart \\r
+ { \\r
+ { \\r
+ MESSAGING_DEVICE_PATH, \\r
+ MSG_UART_DP, \\r
+ { \\r
+ (UINT8) (sizeof (UART_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \\r
+ } \\r
+ }, \\r
+ 0, \\r
+ 115200, \\r
+ 8, \\r
+ 1, \\r
+ 1 \\r
+ }\r
+\r
+#define gPcAnsiTerminal \\r
+ { \\r
+ { \\r
+ MESSAGING_DEVICE_PATH, \\r
+ MSG_VENDOR_DP, \\r
+ { \\r
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \\r
+ } \\r
+ }, \\r
+ DEVICE_PATH_MESSAGING_PC_ANSI \\r
+ }\r
+\r
+\r
+ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;\r
+UART_DEVICE_PATH gUartDeviceNode = gUart;\r
+VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;\r
+VENDOR_DEVICE_PATH gUartDeviceVendorNode = gUartVendor;\r
+\r
+//\r
+// Predefined platform root bridge\r
+//\r
+PLATFORM_ROOT_BRIDGE_DEVICE_PATH gPlatformRootBridge0 = {\r
+ gPciRootBridge,\r
+ gEndEntire\r
+};\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[] = {\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &gPlatformRootBridge0,\r
+ NULL\r
+};\r
+\r
+BOOLEAN mDetectVgaOnly;\r
+\r
+/**\r
+ Add UART to ConOut, ConIn, ErrOut.\r
+\r
+ @param[in] DeviceHandle - LPC device path.\r
+\r
+ @retval EFI_SUCCESS - Serial console is added to ConOut, ConIn, and ErrOut.\r
+ @retval EFI_STATUS - No serial console is added.\r
+**/\r
+EFI_STATUS\r
+PrepareLpcBridgeDevicePath (\r
+ IN EFI_HANDLE DeviceHandle\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ DevicePath = NULL;\r
+ Status = gBS->HandleProtocol (\r
+ DeviceHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID*)&DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Register COM1\r
+ //\r
+ DevicePath = AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *)NULL, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceVendorNode);\r
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+\r
+ EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
+ EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
+ EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Return the GOP device path in the platform.\r
+\r
+ @param[in] PciDevicePath - Device path for the PCI graphics device.\r
+ @param[out] GopDevicePath - Return the device path with GOP installed.\r
+\r
+ @retval EFI_SUCCESS - PCI VGA is added to ConOut.\r
+ @retval EFI_INVALID_PARAMETER - The device path parameter is invalid.\r
+ @retval EFI_STATUS - No GOP device found.\r
+**/\r
+EFI_STATUS\r
+GetGopDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath\r
+)\r
+{\r
+ UINTN Index;\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE PciDeviceHandle;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;\r
+ UINTN GopHandleCount;\r
+ EFI_HANDLE *GopHandleBuffer;\r
+ ACPI_ADR_DEVICE_PATH AcpiAdr;\r
+ EFI_DEVICE_PATH_PROTOCOL *MyDevicePath;\r
+\r
+ if (PciDevicePath == NULL || GopDevicePath == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ MyDevicePath = NULL;\r
+\r
+ //\r
+ // Initialize the GopDevicePath to be PciDevicePath\r
+ //\r
+ *GopDevicePath = PciDevicePath;\r
+ TempPciDevicePath = PciDevicePath;\r
+\r
+ Status = gBS->LocateDevicePath (\r
+ &gEfiDevicePathProtocolGuid,\r
+ &TempPciDevicePath,\r
+ &PciDeviceHandle\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Try to connect this handle, so that GOP dirver could start on this\r
+ // device and create child handles with GraphicsOutput Protocol installed\r
+ // on them, then we get device paths of these child handles and select\r
+ // them as possible console device.\r
+ //\r
+ AcpiAdr.Header.Type = ACPI_DEVICE_PATH;\r
+ AcpiAdr.Header.SubType = ACPI_ADR_DP;\r
+ AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL, 8, 0);\r
+\r
+ SetDevicePathNodeLength (&AcpiAdr.Header, sizeof (ACPI_ADR_DEVICE_PATH));\r
+\r
+ MyDevicePath = AppendDevicePathNode(MyDevicePath, (EFI_DEVICE_PATH_PROTOCOL*)&AcpiAdr);\r
+\r
+ gBS->ConnectController (PciDeviceHandle, NULL, MyDevicePath, FALSE);\r
+\r
+ FreePool(MyDevicePath);\r
+\r
+ Status = gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ NULL,\r
+ &GopHandleCount,\r
+ &GopHandleBuffer\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Add all the child handles as possible Console Device\r
+ //\r
+ for (Index = 0; Index < GopHandleCount; Index++) {\r
+ Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+ if (CompareMem (\r
+ PciDevicePath,\r
+ TempDevicePath,\r
+ GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH\r
+ ) == 0) {\r
+ //\r
+ // In current implementation, we only enable one of the child handles\r
+ // as console device, i.e. sotre one of the child handle's device\r
+ // path to variable "ConOut"\r
+ // In futhure, we could select all child handles to be console device\r
+ //\r
+ *GopDevicePath = TempDevicePath;\r
+\r
+ //\r
+ // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()\r
+ // Add the integrity GOP device path.\r
+ //\r
+ EfiBootManagerUpdateConsoleVariable (ConOut, NULL, PciDevicePath);\r
+ EfiBootManagerUpdateConsoleVariable (ConOut, TempDevicePath, NULL);\r
+ }\r
+ }\r
+ gBS->FreePool (GopHandleBuffer);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Add PCI VGA to ConOut, ConIn, ErrOut.\r
+\r
+ @param[in] DeviceHandle - Handle of PciIo protocol.\r
+\r
+ @retval EFI_SUCCESS - PCI VGA is added to ConOut.\r
+ @retval EFI_STATUS - No PCI VGA device is added.\r
+\r
+**/\r
+EFI_STATUS\r
+PreparePciVgaDevicePath (\r
+ IN EFI_HANDLE DeviceHandle\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r
+\r
+ DevicePath = NULL;\r
+ Status = gBS->HandleProtocol (\r
+ DeviceHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID*)&DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ GetGopDevicePath (DevicePath, &GopDevicePath);\r
+ DevicePath = GopDevicePath;\r
+\r
+ EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Add PCI Serial to ConOut, ConIn, ErrOut.\r
+\r
+ @param[in] DeviceHandle - Handle of PciIo protocol.\r
+\r
+ @retval EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.\r
+ @retval EFI_STATUS - No PCI Serial device is added.\r
+\r
+**/\r
+EFI_STATUS\r
+PreparePciSerialDevicePath (\r
+ IN EFI_HANDLE DeviceHandle\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ DevicePath = NULL;\r
+ Status = gBS->HandleProtocol (\r
+ DeviceHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID*)&DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+\r
+ EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
+ EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
+ EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ For every PCI instance execute a callback function.\r
+\r
+ @param[in] Id - The protocol GUID for callback\r
+ @param[in] CallBackFunction - The callback function\r
+ @param[in] Context - The context of the callback\r
+\r
+ @retval EFI_STATUS - Callback function failed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VisitAllInstancesOfProtocol (\r
+ IN EFI_GUID *Id,\r
+ IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r
+ IN VOID *Context\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN HandleCount;\r
+ EFI_HANDLE *HandleBuffer;\r
+ UINTN Index;\r
+ VOID *Instance;\r
+\r
+ //\r
+ // Start to check all the PciIo to find all possible device\r
+ //\r
+ HandleCount = 0;\r
+ HandleBuffer = NULL;\r
+ Status = gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ Id,\r
+ NULL,\r
+ &HandleCount,\r
+ &HandleBuffer\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ for (Index = 0; Index < HandleCount; Index++) {\r
+ Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+\r
+ Status = (*CallBackFunction) (\r
+ HandleBuffer[Index],\r
+ Instance,\r
+ Context\r
+ );\r
+ }\r
+\r
+ gBS->FreePool (HandleBuffer);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ For every PCI instance execute a callback function.\r
+\r
+ @param[in] Handle - The PCI device handle\r
+ @param[in] Instance - The instance of the PciIo protocol\r
+ @param[in] Context - The context of the callback\r
+\r
+ @retval EFI_STATUS - Callback function failed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VisitingAPciInstance (\r
+ IN EFI_HANDLE Handle,\r
+ IN VOID *Instance,\r
+ IN VOID *Context\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ PCI_TYPE00 Pci;\r
+\r
+ PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;\r
+\r
+ //\r
+ // Check for all PCI device\r
+ //\r
+ Status = PciIo->Pci.Read (\r
+ PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ sizeof (Pci) / sizeof (UINT32),\r
+ &Pci\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (\r
+ Handle,\r
+ PciIo,\r
+ &Pci\r
+ );\r
+\r
+}\r
+\r
+\r
+/**\r
+ For every PCI instance execute a callback function.\r
+\r
+ @param[in] CallBackFunction - Callback function pointer\r
+\r
+ @retval EFI_STATUS - Callback function failed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VisitAllPciInstances (\r
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r
+)\r
+{\r
+ return VisitAllInstancesOfProtocol (\r
+ &gEfiPciIoProtocolGuid,\r
+ VisitingAPciInstance,\r
+ (VOID*)(UINTN) CallBackFunction\r
+ );\r
+}\r
+\r
+\r
+/**\r
+ Do platform specific PCI Device check and add them to\r
+ ConOut, ConIn, ErrOut.\r
+\r
+ @param[in] Handle - Handle of PCI device instance\r
+ @param[in] PciIo - PCI IO protocol instance\r
+ @param[in] Pci - PCI Header register block\r
+\r
+ @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
+ @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DetectAndPreparePlatformPciDevicePath (\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN PCI_TYPE00 *Pci\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationEnable,\r
+ EFI_PCI_DEVICE_ENABLE,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ if (!mDetectVgaOnly) {\r
+ //\r
+ // Here we decide whether it is LPC Bridge\r
+ //\r
+ if ((IS_PCI_LPC (Pci)) ||\r
+ ((IS_PCI_ISA_PDECODE (Pci)) &&\r
+ (Pci->Hdr.VendorId == 0x8086)\r
+ )\r
+ ) {\r
+ //\r
+ // Add IsaKeyboard to ConIn,\r
+ // add IsaSerial to ConOut, ConIn, ErrOut\r
+ //\r
+ DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));\r
+ PrepareLpcBridgeDevicePath (Handle);\r
+ return EFI_SUCCESS;\r
+ }\r
+ //\r
+ // Here we decide which Serial device to enable in PCI bus\r
+ //\r
+ if (IS_PCI_16550SERIAL (Pci)) {\r
+ //\r
+ // Add them to ConOut, ConIn, ErrOut.\r
+ //\r
+ DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));\r
+ PreparePciSerialDevicePath (Handle);\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Here we decide which VGA device to enable in PCI bus\r
+ //\r
+ if (IS_PCI_VGA (Pci)) {\r
+ //\r
+ // Add them to ConOut.\r
+ //\r
+ DEBUG ((EFI_D_INFO, "Found PCI VGA device\n"));\r
+ PreparePciVgaDevicePath (Handle);\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
+\r
+ @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.\r
+\r
+ @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
+ @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
+\r
+**/\r
+EFI_STATUS\r
+DetectAndPreparePlatformPciDevicePaths (\r
+ BOOLEAN DetectVgaOnly\r
+)\r
+{\r
+ mDetectVgaOnly = DetectVgaOnly;\r
+ return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);\r
+}\r
+\r
+\r
+/**\r
+ The function will connect root bridge\r
+\r
+ @return EFI_SUCCESS Connect RootBridge successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+ConnectRootBridge (\r
+ VOID\r
+)\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE RootHandle;\r
+\r
+ //\r
+ // Make all the PCI_IO protocols on PCI Seg 0 show up\r
+ //\r
+ Status = gBS->LocateDevicePath (\r
+ &gEfiDevicePathProtocolGuid,\r
+ &gPlatformRootBridges[0],\r
+ &RootHandle\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Platform console init. Include the platform firmware vendor, revision\r
+ and so crc check.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformConsoleInit (\r
+ VOID\r
+)\r
+{\r
+ gUartDeviceNode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);\r
+ gUartDeviceNode.DataBits = PcdGet8 (PcdUartDefaultDataBits);\r
+ gUartDeviceNode.Parity = PcdGet8 (PcdUartDefaultParity);\r
+ gUartDeviceNode.StopBits = PcdGet8 (PcdUartDefaultStopBits);\r
+\r
+ ConnectRootBridge ();\r
+\r
+ //\r
+ // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
+ //\r
+ DetectAndPreparePlatformPciDevicePaths (FALSE);\r
+}\r
--- /dev/null
+/** @file\r
+Head file for BDS Platform specific code\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef _PLATFORM_CONSOLE_H\r
+#define _PLATFORM_CONSOLE_H\r
+\r
+#include <PiDxe.h>\r
+#include <IndustryStandard/Pci.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Protocol/PciIo.h>\r
+\r
+#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)\r
+#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)\r
+\r
+//\r
+// Type definitions\r
+//\r
+\r
+//\r
+// Platform Root Bridge\r
+//\r
+typedef struct {\r
+ ACPI_HID_DEVICE_PATH PciRootBridge;\r
+ EFI_DEVICE_PATH_PROTOCOL End;\r
+} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(\r
+ IN EFI_HANDLE Handle,\r
+ IN VOID *Instance,\r
+ IN VOID *Context\r
+);\r
+\r
+/**\r
+ @param[in] Handle - Handle of PCI device instance\r
+ @param[in] PciIo - PCI IO protocol instance\r
+ @param[in] Pci - PCI Header register block\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN PCI_TYPE00 *Pci\r
+);\r
+\r
+/**\r
+ Platform console init. Include the platform firmware vendor, revision\r
+ and so crc check.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformConsoleInit (\r
+ VOID\r
+);\r
+\r
+#endif\r
--- /dev/null
+/**@file\r
+ Defined the platform specific device path which will be filled to\r
+ ConIn/ConOut variables.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include "PlatformBootManager.h"\r
+\r
+///\r
+/// Predefined platform default console device path\r
+///\r
+PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {\r
+ {\r
+ NULL,\r
+ 0\r
+ }\r
+};\r