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
|
/** @file
Error Counting for PEG training.
@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
**/
#include "PcieTraining.h"
#ifdef PEG_FLAG
UINT32
OpenMonitor (
IN EFI_PEI_SERVICES **PeiServices,
IN SA_PLATFORM_POLICY_PPI *SaPlatformPolicyPpi,
IN PEI_STALL_PPI *StallPpi
)
{
UINT32 MonitorPort;
InitMonitor (SaPlatformPolicyPpi->PlatformData->MchBar, SaPlatformPolicyPpi->PlatformData->GdxcBar);
MonitorPort = EnableMonitor ();
FullMonitorReset (MonitorPort);
ProgramMonitor (MonitorPort, PeiServices, StallPpi);
return MonitorPort;
}
VOID
CloseMonitor (
IN SA_PLATFORM_POLICY_PPI *SaPlatformPolicyPpi,
IN UINT32 MonitorPort
)
{
FullMonitorReset (MonitorPort);
DisableMonitor ();
TearDownMonitor (SaPlatformPolicyPpi->PlatformData->MchBar, SaPlatformPolicyPpi->PlatformData->GdxcBar);
return;
}
UINT32
SaPcieGetErrorCount (
IN UINT32 MonitorPort,
IN UINT8 PcieController
)
{
UINT32 Data32;
Data32 = Mmio32 (MonitorPort, (0xC + (PcieController * 0x10)));
return Data32;
}
VOID
SaPcieClearErrorCount (
IN UINT32 MonitorPort,
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_STALL_PPI *StallPpi
)
{
FullMonitorReset (MonitorPort);
ProgramMonitor (MonitorPort, PeiServices, StallPpi);
return;
}
VOID
InitMonitor (
IN UINT32 MchBar,
IN UINT32 GdxcBar
)
{
Mmio32 (MchBar, 0x6430) = 0x3;
Mmio32 (MchBar, 0x6434) = 0x76543210;
McD1PciCfg32 (0x630) = 0xB;
McD1PciCfg32 (0x600) = 0x60B;
McD1PciCfg32 (0x604) = 0x76543980;
McD1F1PciCfg32 (0x600) = 0x60B;
McD1F1PciCfg32 (0x604) = 0x76543280;
McD1F2PciCfg32 (0x600) = 0xB;
McD1F2PciCfg32 (0x604) = 0x76543210;
Mmio32 (MchBar, 0x6438) = 0x680000;
Mmio32 (GdxcBar, 0xA04) = 0xA;
return;
}
VOID
TearDownMonitor (
IN UINT32 MchBar,
IN UINT32 GdxcBar
)
{
Mmio32 (MchBar, 0x6430) = 0x0;
Mmio32 (MchBar, 0x6434) = 0x0;
McD1PciCfg32 (0x630) = 0x0;
McD1PciCfg32 (0x600) = 0x0;
McD1PciCfg32 (0x604) = 0x0;
McD1F1PciCfg32 (0x600) = 0x0;
McD1F1PciCfg32 (0x604) = 0x0;
McD1F2PciCfg32 (0x600) = 0x0;
McD1F2PciCfg32 (0x604) = 0x0;
Mmio32 (MchBar, 0x6438) = 0x0;
Mmio32 (GdxcBar, 0xA04) = 0x0;
return;
}
UINT32
EnableMonitor (
VOID
)
{
UINT32 Data32;
Data32 = (McD0PciCfg32 (0140) & ~(07));
Mmio32Or (Data32, 0124, 040000);
Mmio64 (Data32, 0700020) = (UINT64) SA_PEI_MONITOR_OFFSET;
Mmio16Or (Data32, 0700004, 02);
return SA_PEI_MONITOR_OFFSET;
}
VOID
DisableMonitor (
VOID
)
{
UINT32 Data32;
Data32 = (McD0PciCfg32 (0140) & ~(07));
Mmio16And (Data32, 0700004, 0177775);
Mmio64And (Data32, 0700020, 07777);
Mmio32And (Data32, 0124, 037777737777);
return;
}
VOID
FullMonitorReset (
IN UINT32 MonitorPort
)
{
Mmio32 (MonitorPort, 0x0) = 0x40000;
Mmio32 (MonitorPort, 0x4) = 0x0;
Mmio32 (MonitorPort, 0x10) = 0x40000;
Mmio32 (MonitorPort, 0x14) = 0x0;
Mmio32 (MonitorPort, 0x20) = 0x40000;
Mmio32 (MonitorPort, 0x24) = 0x0;
Mmio32 (MonitorPort, 0x8) = 0xFF000000;
Mmio32 (MonitorPort, 0x18) = 0xFF000000;
Mmio32 (MonitorPort, 0x28) = 0xFF000000;
Mmio32 (MonitorPort, 0xC) = 0x0;
Mmio32 (MonitorPort, 0x1C) = 0x0;
Mmio32 (MonitorPort, 0x2C) = 0x0;
return;
}
VOID
ProgramMonitor (
IN UINT32 MonitorPort,
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_STALL_PPI *StallPpi
)
{
Mmio32 (MonitorPort, 0x4) = 0xA100;
Mmio32 (MonitorPort, 0x14) = 0xA101;
Mmio32 (MonitorPort, 0x24) = 0xA102;
Mmio32 (MonitorPort, 0x0) = 0x110000;
StallPpi->Stall (PeiServices, StallPpi, 1 * STALL_ONE_MILLI_SECOND);
Mmio32 (MonitorPort, 0x0) = 0x22100;
Mmio32 (MonitorPort, 0x10) = 0x22101;
Mmio32 (MonitorPort, 0x20) = 0x22102;
return;
}
#endif // PEG_FLAG
|