1 | /**@file
|
---|
2 | Install a callback to do smm relocation.
|
---|
3 |
|
---|
4 | Copyright (c) 2024, Intel Corporation. All rights reserved.
|
---|
5 |
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include <Library/DebugLib.h>
|
---|
10 | #include <Library/PeiServicesLib.h>
|
---|
11 | #include <Library/SmmRelocationLib.h>
|
---|
12 | #include <Ppi/MpServices2.h>
|
---|
13 | #include "Platform.h"
|
---|
14 |
|
---|
15 | /**
|
---|
16 | Notification function called when EDKII_PEI_MP_SERVICES2_PPI becomes available.
|
---|
17 |
|
---|
18 | @param[in] PeiServices Indirect reference to the PEI Services Table.
|
---|
19 | @param[in] NotifyDescriptor Address of the notification descriptor data
|
---|
20 | structure.
|
---|
21 | @param[in] Ppi Address of the PPI that was installed.
|
---|
22 |
|
---|
23 | @return Status of the notification. The status code returned from this
|
---|
24 | function is ignored.
|
---|
25 | **/
|
---|
26 | STATIC
|
---|
27 | EFI_STATUS
|
---|
28 | EFIAPI
|
---|
29 | OnMpServices2Available (
|
---|
30 | IN EFI_PEI_SERVICES **PeiServices,
|
---|
31 | IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
|
---|
32 | IN VOID *Ppi
|
---|
33 | )
|
---|
34 | {
|
---|
35 | EDKII_PEI_MP_SERVICES2_PPI *MpServices2;
|
---|
36 | EFI_STATUS Status;
|
---|
37 |
|
---|
38 | DEBUG ((DEBUG_INFO, "%a: %a\n", gEfiCallerBaseName, __func__));
|
---|
39 |
|
---|
40 | MpServices2 = Ppi;
|
---|
41 |
|
---|
42 | //
|
---|
43 | // Smm Relocation Initialize.
|
---|
44 | //
|
---|
45 | Status = SmmRelocationInit (MpServices2);
|
---|
46 | if (EFI_ERROR (Status)) {
|
---|
47 | DEBUG ((DEBUG_WARN, "OnMpServices2Available: Not able to execute Smm Relocation Init. Status: %r\n", Status));
|
---|
48 | }
|
---|
49 |
|
---|
50 | return EFI_SUCCESS;
|
---|
51 | }
|
---|
52 |
|
---|
53 | //
|
---|
54 | // Notification object for registering the callback, for when
|
---|
55 | // EDKII_PEI_MP_SERVICES2_PPI becomes available.
|
---|
56 | //
|
---|
57 | STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR mMpServices2Notify = {
|
---|
58 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | // Flags
|
---|
59 | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
---|
60 | &gEdkiiPeiMpServices2PpiGuid, // Guid
|
---|
61 | OnMpServices2Available // Notify
|
---|
62 | };
|
---|
63 |
|
---|
64 | VOID
|
---|
65 | RelocateSmBase (
|
---|
66 | VOID
|
---|
67 | )
|
---|
68 | {
|
---|
69 | EFI_STATUS Status;
|
---|
70 |
|
---|
71 | Status = PeiServicesNotifyPpi (&mMpServices2Notify);
|
---|
72 | if (EFI_ERROR (Status)) {
|
---|
73 | DEBUG ((
|
---|
74 | DEBUG_ERROR,
|
---|
75 | "%a: failed to set up MP Services2 callback: %r\n",
|
---|
76 | __func__,
|
---|
77 | Status
|
---|
78 | ));
|
---|
79 | }
|
---|
80 | }
|
---|