summaryrefslogtreecommitdiffstats
path: root/UefiPayloadPkg/Library/BaseSerialPortLibHob/DxeBaseSerialPortLibHob.c
blob: 6106e9a933ebbb805399dd14d63fb30a9cfa4fc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/** @file
  UART Serial Port library functions.

  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/
#include <Uefi.h>

extern BOOLEAN  mBaseSerialPortLibHobAtRuntime;

/**
  Set mSerialIoUartLibAtRuntime flag as TRUE after ExitBootServices.

  @param[in]  Event   The Event that is being processed.
  @param[in]  Context The Event Context.

**/
STATIC
VOID
EFIAPI
BaseSerialPortLibHobExitBootServicesEvent (
  IN EFI_EVENT  Event,
  IN VOID       *Context
  )
{
  mBaseSerialPortLibHobAtRuntime = TRUE;
}

/**
  The constructor function registers a callback for the ExitBootServices event.

  @param[in]  ImageHandle   The firmware allocated handle for the EFI image.
  @param[in]  SystemTable   A pointer to the EFI System Table.

  @retval EFI_SUCCESS   The operation completed successfully.
  @retval other         Either the serial port failed to initialize or the
                        ExitBootServices event callback registration failed.
**/
EFI_STATUS
EFIAPI
DxeBaseSerialPortLibHobConstructor (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  EFI_EVENT  SerialPortLibHobExitBootServicesEvent;

  return SystemTable->BootServices->CreateEvent (
                                      EVT_SIGNAL_EXIT_BOOT_SERVICES,
                                      TPL_NOTIFY,
                                      BaseSerialPortLibHobExitBootServicesEvent,
                                      NULL,
                                      &SerialPortLibHobExitBootServicesEvent
                                      );
}