summaryrefslogtreecommitdiff
path: root/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Runtime.c
blob: de7144739c4cae1921371a931dc9408fc65a744d (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/** @file
  Permanently disable the library instance in DXE_RUNTIME_DRIVER modules when
  exiting boot services.

  Copyright (C) Red Hat
  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
  Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>

  SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <Uefi/UefiSpec.h>

#include "Ram.h"

STATIC EFI_EVENT  mExitBootServicesEvent;

/**
  Notification function that is triggered when the boot service
  ExitBootServices() is called.

  @param[in] Event    Event whose notification function is being invoked. Here,
                      unused.

  @param[in] Context  The pointer to the notification function's context, which
                      is implementation-dependent. Here, unused.
**/
STATIC
VOID
EFIAPI
ExitBootServicesNotify (
  IN EFI_EVENT  Event,
  IN VOID       *Context
  )
{
  mDebugLibFdtPL011UartAddress         = 0;
  mDebugLibFdtPL011UartPermanentStatus = RETURN_ABORTED;
}

/**
  Library instance constructor, registering ExitBootServicesNotify().

  @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.

  @return              Error codes propagated from CreateEvent(); the
                       registration of ExitBootServicesNotify() failed.
**/
EFI_STATUS
EFIAPI
DxeRuntimeDebugLibFdtPL011UartConstructor (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  return SystemTable->BootServices->CreateEvent (
                                      EVT_SIGNAL_EXIT_BOOT_SERVICES,
                                      TPL_CALLBACK,
                                      ExitBootServicesNotify,
                                      NULL /* NotifyContext */,
                                      &mExitBootServicesEvent
                                      );
}

/**
  Library instance destructor, deregistering ExitBootServicesNotify().

  @param[in] ImageHandle  The firmware-allocated handle for the EFI image.

  @param[in] SystemTable  A pointer to the EFI System Table.

  @retval EFI_SUCCESS  Library instance tear-down complete.

  @return              Error codes propagated from CloseEvent(); the
                       deregistration of ExitBootServicesNotify() failed.
**/
EFI_STATUS
EFIAPI
DxeRuntimeDebugLibFdtPL011UartDestructor (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  return SystemTable->BootServices->CloseEvent (mExitBootServicesEvent);
}