summaryrefslogtreecommitdiffstats
path: root/MdePkg/Test/Mock/Include/GoogleTest/Library/MockSmmServicesTableLib.h
blob: 0a1cb238abeb83f9624c3294d6084477149b4d1f (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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/** @file MockSmmServicesTableLib.h
  Google Test mocks for SmmServicesTableLib

  Copyright (c) Microsoft Corporation.
  SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_SMM_SERVICES_TABLE_LIB_H_
#define MOCK_SMM_SERVICES_TABLE_LIB_H_

#include <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>
extern "C" {
  #include <Uefi.h>
  #include <Library/SmmServicesTableLib.h>
}

//
// Declarations to handle usage of the SmmServicesTableLib by creating mock
//
struct MockSmmServicesTableLib {
  MOCK_INTERFACE_DECLARATION (MockSmmServicesTableLib);

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmAllocatePool,
    (
     IN  EFI_MEMORY_TYPE             PoolType,
     IN  UINTN                       Size,
     OUT VOID                        **Buffer
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmFreePool,
    (
     IN  VOID                        *Buffer
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmAllocatePages,
    (
     IN  EFI_ALLOCATE_TYPE           Type,
     IN  EFI_MEMORY_TYPE             MemoryType,
     IN  UINTN                       Pages,
     OUT EFI_PHYSICAL_ADDRESS        *Memory
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmFreePages,
    (
     IN  EFI_PHYSICAL_ADDRESS        Memory,
     IN  UINTN                       Pages
    )
    );

  // MP service
  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmStartupThisAp,
    (
     IN     EFI_AP_PROCEDURE  Procedure,
     IN     UINTN             CpuNumber,
     IN OUT VOID              *ProcArguments OPTIONAL
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmInstallProtocolInterface,
    (
     IN OUT EFI_HANDLE               *Handle,
     IN     EFI_GUID                 *Protocol,
     IN     EFI_INTERFACE_TYPE       InterfaceType,
     IN     VOID                     *Interface
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmUninstallProtocolInterface,
    (
     IN EFI_HANDLE               Handle,
     IN EFI_GUID                 *Protocol,
     IN VOID                     *Interface
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmHandleProtocol,
    (
     IN  EFI_HANDLE              Handle,
     IN  EFI_GUID                *Protocol,
     OUT VOID                    **Interface
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmRegisterProtocolNotify,
    (
     IN  CONST EFI_GUID     *Protocol,
     IN  EFI_MM_NOTIFY_FN   Function,
     OUT VOID               **Registration
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmLocateHandle,
    (
     IN     EFI_LOCATE_SEARCH_TYPE  SearchType,
     IN     EFI_GUID                *Protocol,
     IN     VOID                    *SearchKey,
     IN OUT UINTN                   *BufferSize,
     OUT    EFI_HANDLE              *Buffer
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmLocateProtocol,
    (
     IN  EFI_GUID  *Protocol,
     IN  VOID      *Registration  OPTIONAL,
     OUT VOID      **Interface
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmiManage,
    (
     IN CONST EFI_GUID  *HandlerType,
     IN CONST VOID      *Context,
     IN OUT VOID        *CommBuffer,
     IN OUT UINTN       *CommBufferSize
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmInterruptRegister,
    (
     IN  EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
     IN  CONST EFI_GUID *HandlerType,
     OUT EFI_HANDLE    *DispatchHandle
    )
    );

  MOCK_FUNCTION_DECLARATION (
    EFI_STATUS,
    gSmst_SmmInterruptUnRegister,
    (
     IN EFI_HANDLE  DispatchHandle
    )
    );
};

#endif