summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/Library/SaPcieLib/Common/SaPcieLib.h
blob: 99f19d7b67a49f76da0b47c18d321f87c4811380 (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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/** @file
  Defines and prototypes for the library module

@copyright
  Copyright (c) 2012 Intel Corporation. All rights reserved
  This software and associated documentation (if any) is furnished
  under a license and may only be used or copied in accordance
  with the terms of the license. Except as permitted by such
  license, no part of this software or documentation may be
  reproduced, stored in a retrieval system, or transmitted in any
  form or by any means without the express written consent of
  Intel Corporation.

  This file contains an 'Intel Peripheral Driver' and uniquely
  identified as "Intel Reference Module" and is
  licensed for Intel CPUs and chipsets under the terms of your
  license agreement with Intel or your vendor.  This file may
  be modified by the user, subject to additional terms of the
  license agreement
**/
#ifndef _SA_PCIE_LIB_H_
#define _SA_PCIE_LIB_H_

#include "EfiScriptLib.h"

#define MAX_SUPPORTED_ROOT_BRIDGE_NUMBER  3
#define MAX_SUPPORTED_DEVICE_NUMBER       192
#define L0_SET                            BIT0
#define L1_SET                            BIT1
#define MAX_PAM_REG_COUNT                 7
#define PAM_REG_BASE                      0x80
#define CRID_DATA                         0x69
#define CRID_LOCK                         0x17

typedef struct {
  UINT64                Address;
  EFI_BOOT_SCRIPT_WIDTH Width;
  UINT32                Value;
} BOOT_SCRIPT_PCI_REGISTER_SAVE;

EFI_STATUS
EnumerateAllPcieDevices (
  VOID
  )
/**
  Enumerate all end point devices connected to root bridge ports and record their MMIO base address

  @param[in] None

  @exception EFI_UNSUPPORTED      PCIe capability structure not found
  @retval    EFI_SUCCESS          All done successfully
**/
;

VOID
SaPcieConfigBeforeOpRom (
  VOID
  )
/**
  Sets Common Clock, TCx-VC0 mapping, and Max Payload for PCIe

  @param[in] None

  @retval None
**/
;

VOID
SaAspm (
  VOID
  )
/**
  This function does all SA ASPM initialization

  @param[in] None

  @retval None
**/
;

VOID
EnableExtendedTag (
  VOID
  )
/**
  This function checks PEG end point device for extended tag capability and enables them if they are.

  @param[in] None

  @retval None
**/
;

VOID
SaSaveRestoreChipset (
  IN     BOOLEAN                       IsSaving,
  IN     BOOT_SCRIPT_PCI_REGISTER_SAVE PciRegistersSaveTable[],
  IN     UINTN                         PciRegistersSaveTableSize,
  IN OUT UINTN                         *PciRegistersSaveBuffer
)
/**
  This function saves/restores Chipset registers

  @param[in] IsSaving                  - TRUE for saving and FALSE for restoring
  @param[in] PciRegistersSaveTable[]   - The register table that has to be saved/restored
  @param[in] PciRegistersSaveTableSize - Size of above table
  @param[in] PciRegistersSaveBuffer    - A saving/restoring buffer for those register settings.

  @retval None
**/
;

VOID
SaSaveRestorePlatform (
  IN BOOLEAN        IsSaving
)
/**
  This function saves/restores platform relative registers

  @param[in] IsSaving                  - TRUE for saving and FALSE for restoring

  @retval None
**/
;

VOID
SaSecurityLock (
  VOID
)
/**
  This function does SA security lock

  @param[in] None

  @retval None
**/
;

VOID
SaS3Resume (
  VOID
)
/**
  This function handles SA S3 resume

  @param[in] None

  @retval None
**/
;

VOID
SaS3ResumeCallback (
  VOID
)
/**
  Wrapper function for all SA S3 resume tasks which can be a callback function.

  @param[in] None

  @retval None
**/
;

VOID
SaPcieConfigAfterOpRom (
  VOID
)
/**
  Wrapper function for all SA ASPM tasks and extended tag which can be a callback function.

  @param[in] None

  @retval None
**/
;

VOID
SaPcieEnumCallback (
  VOID
)
/**
  Wrapper function for all SA enumeration tasks which can be a callback function.

  @param[in] None

  @retval None
**/
;

VOID
SaPcieInitPolicy (
  IN DXE_PLATFORM_SA_POLICY_PROTOCOL *DxePlatformSaPolicy
)
/**
  This function will initialize all required platform policy into global veriables so no need to locate policy protocol during runtime.

  @param[in] None

  @retval None
**/
;

EFI_STATUS
SaScriptMemWrite (
  IN  UINT16                            TableName,
  IN  EFI_BOOT_SCRIPT_WIDTH             Width,
  IN  UINT64                            Address,
  IN  UINTN                             Count,
  IN  VOID                              *Buffer
)
/**
  Wrapper for boot script with opcode EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE

  @param[in] TableName - Desired boot script table
  @param[in] Width   - The width of the memory operations.
  @param[in] Address - The base address of the memory operations.
  @param[in] Count   - The number of memory operations to perform.
  @param[in] Buffer  - The source buffer from which to write the data.

  @retval EFI_NOT_FOUND - BootScriptSave Protocol not exist.
  @retval EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
**/
;

EFI_STATUS
SaScriptMemReadWrite (
  IN  UINT16                            TableName,
  IN  EFI_BOOT_SCRIPT_WIDTH             Width,
  IN  UINT64                            Address,
  IN  VOID                              *Data,
  IN  VOID                              *DataMask
)
/**
  Wrapper for boot script with opcode EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE

  @param[in] TableName - Desired boot script table
  @param[in] Width   - The width of the memory operations.
  @param[in] Address - The base address of the memory operations.
  @param[in] Data    - A pointer to the data to be OR-ed.
  @param[in] DataMask  - A pointer to the data mask to be AND-ed with the data read from the register.

  @retval EFI_NOT_FOUND - BootScriptSave Protocol not exist.
  @retval EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
**/
;

EFI_STATUS
SaScriptMemPoll (
  IN  UINT16                            TableName,
  IN  EFI_BOOT_SCRIPT_WIDTH             Width,
  IN  UINT64                            Address,
  IN  VOID                              *BitMask,
  IN  VOID                              *BitValue,
  IN  UINTN                             Duration,
  IN  UINTN                             LoopTimes
  )
/**
  Wrapper for boot script for Polling one memory mapping register

  @param[in] TableName - Desired boot script table
  @param[in] Width     - The width of the memory operations.
  @param[in] Address   - The base address of the memory operations.
  @param[in] BitMask   - A pointer to the bit mask to be AND-ed with the data read from the register.
  @param[in] BitValue  - A pointer to the data value after to be Masked.
  @param[in] Duration  - Duration in microseconds of the stall.
  @param[in] LoopTimes - The times of the register polling.

  @retval EFI_SUCCESS - The operation was executed successfully
**/
;

#endif