CorebootPayloadPkg: Use SerialDxe in MdeModulePkg
[mirror_edk2.git] / CorebootPayloadPkg / Library / PlatformHookLib / PlatformHookLib.c
1 /** @file
2 Platform Hook Library instance for UART device upon coreboot.
3
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <Base.h>
16 #include <Uefi/UefiBaseType.h>
17 #include <Library/PlatformHookLib.h>
18 #include <Library/CbParseLib.h>
19 #include <Library/PcdLib.h>
20
21 /**
22 Performs platform specific initialization required for the CPU to access
23 the hardware associated with a SerialPortLib instance. This function does
24 not intiailzie the serial port hardware itself. Instead, it initializes
25 hardware devices that are required for the CPU to access the serial port
26 hardware. This function may be called more than once.
27
28 @retval RETURN_SUCCESS The platform specific initialization succeeded.
29 @retval RETURN_DEVICE_ERROR The platform specific initialization could not be completed.
30
31 **/
32 RETURN_STATUS
33 EFIAPI
34 PlatformHookSerialPortInitialize (
35 VOID
36 )
37 {
38 RETURN_STATUS Status;
39 UINT32 SerialRegBase;
40 UINT32 SerialRegAccessType;
41
42 Status = CbParseSerialInfo (&SerialRegBase, &SerialRegAccessType, NULL);
43 if (RETURN_ERROR (Status)) {
44 return Status;
45 }
46
47 if (SerialRegAccessType == 2) { //MMIO
48 PcdSetBoolS (PcdSerialUseMmio, TRUE);
49 } else { //IO
50 PcdSetBoolS (PcdSerialUseMmio, FALSE);
51 }
52 PcdSet64S (PcdSerialRegisterBase, (UINT64) SerialRegBase);
53
54 return RETURN_SUCCESS;
55 }
56