hc
2024-08-14 865dc85cff0c170305dc18e865d2cb0b537a47ec
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/** @file
  This is the driver that initializes the Intel System Agent.
 
  Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
 
  SPDX-License-Identifier: BSD-2-Clause-Patent
**/
 
#include "SaInitDxe.h"
#include "SaInit.h"
#include <Private/SaConfigHob.h>
#include <Protocol/PciEnumerationComplete.h>
#include <MemInfoHob.h>
 
///
/// Global Variables
///
extern SA_CONFIG_HOB         *mSaConfigHob;
 
/**
  SystemAgent Dxe Initialization.
 
  @param[in] ImageHandle             Handle for the image of this driver
  @param[in] SystemTable             Pointer to the EFI System Table
 
  @retval EFI_SUCCESS             The function completed successfully
  @retval EFI_OUT_OF_RESOURCES    No enough buffer to allocate
**/
EFI_STATUS
EFIAPI
SaInitEntryPointDxe (
  IN EFI_HANDLE         ImageHandle,
  IN EFI_SYSTEM_TABLE   *SystemTable
  )
{
  EFI_STATUS                Status;
  VOID                      *Registration;
 
  DEBUG ((DEBUG_INFO, "SaInitDxe Start\n"));
 
  SaInitEntryPoint ();
 
  Status = SaAcpiInit (ImageHandle);
  ASSERT_EFI_ERROR (Status);
 
  ///
  /// Create PCI Enumeration Completed callback for SA
  ///
  EfiCreateProtocolNotifyEvent (
    &gEfiPciEnumerationCompleteProtocolGuid,
    TPL_CALLBACK,
    SaPciEnumCompleteCallback,
    NULL,
    &Registration
    );
 
  DEBUG ((DEBUG_INFO, "SaInitDxe End\n"));
 
  return EFI_SUCCESS;
}
 
/**
  This function gets registered as a callback to perform SA initialization before EndOfDxe
 
  @param[in] Event     - A pointer to the Event that triggered the callback.
  @param[in] Context   - A pointer to private data registered with the callback function.
**/
VOID
EFIAPI
SaPciEnumCompleteCallback (
  IN EFI_EVENT    Event,
  IN VOID         *Context
  )
{
  EFI_STATUS          Status;
  VOID                *ProtocolPointer;
 
  DEBUG ((DEBUG_INFO, "SaPciEnumCompleteCallback Start\n"));
  ///
  /// Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
  /// if it is, we will skip it until real event is triggered
  ///
  Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid, NULL, (VOID **) &ProtocolPointer);
  if (EFI_SUCCESS != Status) {
    return;
  }
 
  gBS->CloseEvent (Event);
 
  Status = PegInitBeforeEndOfDxe ();
  if (EFI_SUCCESS != Status) {
    DEBUG ((DEBUG_WARN, "[SA] Pcie initialization before EndOfDxe Error, Status = %r \n", Status));
    ASSERT_EFI_ERROR (Status);
  }
 
  SaSaveRestore ();
  SaSecurityInit ();
  UpdateDmarPciEnumCompleteCallback ();
 
  DEBUG ((DEBUG_INFO, "SaPciEnumCompleteCallback End\n"));
  return;
}
 
/**
  This function locks the PAM register as part of the SA Security requirements.
 
  @param[in] Event     - A pointer to the Event that triggered the callback.
  @param[in] Context   - A pointer to private data registered with the callback function.
 
**/
VOID
EFIAPI
SaPamLockDxe (
  IN EFI_EVENT Event,
  IN VOID      *Context
  )
{
  DEBUG ((DEBUG_INFO, "SaPamLockDxe Start\n"));
 
  SaPamLock ();
 
  DEBUG ((DEBUG_INFO, "SaPamLockDxe End\n"));
}