1 | /** @file -- VariablePolicyExtraInitRuntimeDxe.c
|
---|
2 | This file contains extra init and deinit routines that register and unregister
|
---|
3 | VariableAddressChange callbacks.
|
---|
4 |
|
---|
5 | Copyright (c) Microsoft Corporation.
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #include <Library/UefiBootServicesTableLib.h>
|
---|
11 | #include <Library/UefiRuntimeServicesTableLib.h>
|
---|
12 |
|
---|
13 | extern EFI_GET_VARIABLE mGetVariableHelper;
|
---|
14 | extern UINT8 *mPolicyTable;
|
---|
15 | STATIC BOOLEAN mIsVirtualAddrConverted;
|
---|
16 | STATIC EFI_EVENT mVariablePolicyLibVirtualAddressChangeEvent = NULL;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | For the RuntimeDxe version of this lib, convert internal pointer addresses to virtual addresses.
|
---|
20 |
|
---|
21 | @param[in] Event Event whose notification function is being invoked.
|
---|
22 | @param[in] Context The pointer to the notification function's context, which
|
---|
23 | is implementation-dependent.
|
---|
24 | **/
|
---|
25 | STATIC
|
---|
26 | VOID
|
---|
27 | EFIAPI
|
---|
28 | VariablePolicyLibVirtualAddressCallback (
|
---|
29 | IN EFI_EVENT Event,
|
---|
30 | IN VOID *Context
|
---|
31 | )
|
---|
32 | {
|
---|
33 | gRT->ConvertPointer (0, (VOID **)&mPolicyTable);
|
---|
34 | gRT->ConvertPointer (0, (VOID **)&mGetVariableHelper);
|
---|
35 | mIsVirtualAddrConverted = TRUE;
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 | /**
|
---|
40 | An extra init hook that enables the RuntimeDxe library instance to
|
---|
41 | register VirtualAddress change callbacks. Among other things.
|
---|
42 |
|
---|
43 | @retval EFI_SUCCESS Everything is good. Continue with init.
|
---|
44 | @retval Others Uh... don't continue.
|
---|
45 |
|
---|
46 | **/
|
---|
47 | EFI_STATUS
|
---|
48 | VariablePolicyExtraInit (
|
---|
49 | VOID
|
---|
50 | )
|
---|
51 | {
|
---|
52 | return gBS->CreateEventEx (EVT_NOTIFY_SIGNAL,
|
---|
53 | TPL_NOTIFY,
|
---|
54 | VariablePolicyLibVirtualAddressCallback,
|
---|
55 | NULL,
|
---|
56 | &gEfiEventVirtualAddressChangeGuid,
|
---|
57 | &mVariablePolicyLibVirtualAddressChangeEvent);
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | /**
|
---|
62 | An extra deinit hook that enables the RuntimeDxe library instance to
|
---|
63 | register VirtualAddress change callbacks. Among other things.
|
---|
64 |
|
---|
65 | @retval EFI_SUCCESS Everything is good. Continue with deinit.
|
---|
66 | @retval Others Uh... don't continue.
|
---|
67 |
|
---|
68 | **/
|
---|
69 | EFI_STATUS
|
---|
70 | VariablePolicyExtraDeinit (
|
---|
71 | VOID
|
---|
72 | )
|
---|
73 | {
|
---|
74 | EFI_STATUS Status;
|
---|
75 |
|
---|
76 | Status = EFI_SUCCESS;
|
---|
77 | if (mIsVirtualAddrConverted) {
|
---|
78 | Status = gBS->CloseEvent (mVariablePolicyLibVirtualAddressChangeEvent);
|
---|
79 | }
|
---|
80 | else {
|
---|
81 | Status = EFI_SUCCESS;
|
---|
82 | }
|
---|
83 |
|
---|
84 | return Status;
|
---|
85 | }
|
---|