]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c
CorebootPayloadPkg: Use SerialDxe in MdeModulePkg
[mirror_edk2.git] / CorebootPayloadPkg / Library / PlatformHookLib / PlatformHookLib.c
diff --git a/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c b/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c
new file mode 100644 (file)
index 0000000..10fd332
--- /dev/null
@@ -0,0 +1,56 @@
+/** @file\r
+  Platform Hook Library instance for UART device upon coreboot.\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 <Base.h>\r
+#include <Uefi/UefiBaseType.h>\r
+#include <Library/PlatformHookLib.h>\r
+#include <Library/CbParseLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+/**\r
+  Performs platform specific initialization required for the CPU to access\r
+  the hardware associated with a SerialPortLib instance.  This function does\r
+  not intiailzie the serial port hardware itself.  Instead, it initializes\r
+  hardware devices that are required for the CPU to access the serial port\r
+  hardware.  This function may be called more than once.\r
+\r
+  @retval RETURN_SUCCESS       The platform specific initialization succeeded.\r
+  @retval RETURN_DEVICE_ERROR  The platform specific initialization could not be completed.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PlatformHookSerialPortInitialize (\r
+  VOID\r
+  )\r
+{\r
+  RETURN_STATUS     Status;\r
+  UINT32            SerialRegBase;\r
+  UINT32            SerialRegAccessType;\r
+\r
+  Status = CbParseSerialInfo (&SerialRegBase, &SerialRegAccessType, NULL);\r
+  if (RETURN_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (SerialRegAccessType == 2) { //MMIO\r
+    PcdSetBoolS (PcdSerialUseMmio, TRUE);\r
+  } else { //IO\r
+    PcdSetBoolS (PcdSerialUseMmio, FALSE);\r
+  }\r
+  PcdSet64S (PcdSerialRegisterBase, (UINT64) SerialRegBase);\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r