Debian Codegraph @

src/vendorcode/amd/pi/00730F01/Proc/CPU/cpuRegisters.h

raw symbols SCIP
1 /* SPDX-License-Identifier: BSD-3-Clause */
2
3 /* $NoKeywords:$ */
4 /**
5 * @file
6 *
7 * AMD CPU Register Table Related Functions
8 *
9 * Contains the definition of the CPU CPUID MSRs and PCI registers with BKDG recommended values
10 *
11 * @xrefitem bom "File Content Label" "Release Content"
12 * @e project: AGESA
13 * @e sub-project: CPU
14 * @e \$Revision: 282320 $ @e \$Date: 2014-01-09 20:13:34 -0600 (Thu, 09 Jan 2014) $
15 *
16 */
17 /*****************************************************************************
18 *
19 * Copyright (c) 2008 - 2014, Advanced Micro Devices, Inc.
20 * All rights reserved.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions are met:
24 * * Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * * Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
30 * its contributors may be used to endorse or promote products derived
31 * from this software without specific prior written permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
37 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 *
44 ***************************************************************************/
45
46 #ifndef _CPU_REGISTERS_H_
47 #define _CPU_REGISTERS_H_
48
49 #include "cpuFamRegisters.h"
50 /*
51 *--------------------------------------------------------------
52 *
53 * M O D U L E S U S E D
54 *
55 *---------------------------------------------------------------
56 */
57
58 /*
59 *--------------------------------------------------------------
60 *
61 * D E F I N I T I O N S / M A C R O S
62 *
63 *---------------------------------------------------------------
64 */
65
66 #undef BIT0
67 #undef BIT1
68 #undef BIT2
69 #undef BIT3
70 #undef BIT4
71 #undef BIT5
72 #undef BIT6
73 #undef BIT7
74 #undef BIT8
75 #undef BIT9
76 #undef BIT10
77 #undef BIT10
78 #undef BIT11
79 #undef BIT12
80 #undef BIT13
81 #undef BIT14
82 #undef BIT15
83 #undef BIT16
84 #undef BIT17
85 #undef BIT18
86 #undef BIT19
87 #undef BIT20
88 #undef BIT21
89 #undef BIT22
90 #undef BIT23
91 #undef BIT24
92 #undef BIT25
93 #undef BIT26
94 #undef BIT27
95 #undef BIT28
96 #undef BIT29
97 #undef BIT30
98 #undef BIT31
99 #undef BIT32
100 #undef BIT33
101 #undef BIT34
102 #undef BIT35
103 #undef BIT36
104 #undef BIT37
105 #undef BIT38
106 #undef BIT39
107 #undef BIT40
108 #undef BIT41
109 #undef BIT42
110 #undef BIT43
111 #undef BIT44
112 #undef BIT45
113 #undef BIT46
114 #undef BIT47
115 #undef BIT48
116 #undef BIT49
117 #undef BIT40
118 #undef BIT41
119 #undef BIT42
120 #undef BIT43
121 #undef BIT44
122 #undef BIT45
123 #undef BIT46
124 #undef BIT47
125 #undef BIT48
126 #undef BIT49
127 #undef BIT50
128 #undef BIT51
129 #undef BIT52
130 #undef BIT53
131 #undef BIT54
132 #undef BIT55
133 #undef BIT56
134 #undef BIT57
135 #undef BIT58
136 #undef BIT59
137 #undef BIT60
138 #undef BIT61
139 #undef BIT62
140 #undef BIT63
141
142 #define BIT0 0x0000000000000001ull
143 #define BIT1 0x0000000000000002ull
144 #define BIT2 0x0000000000000004ull
145 #define BIT3 0x0000000000000008ull
146 #define BIT4 0x0000000000000010ull
147 #define BIT5 0x0000000000000020ull
148 #define BIT6 0x0000000000000040ull
149 #define BIT7 0x0000000000000080ull
150 #define BIT8 0x0000000000000100ull
151 #define BIT9 0x0000000000000200ull
152 #define BIT10 0x0000000000000400ull
153 #define BIT11 0x0000000000000800ull
154 #define BIT12 0x0000000000001000ull
155 #define BIT13 0x0000000000002000ull
156 #define BIT14 0x0000000000004000ull
157 #define BIT15 0x0000000000008000ull
158 #define BIT16 0x0000000000010000ull
159 #define BIT17 0x0000000000020000ull
160 #define BIT18 0x0000000000040000ull
161 #define BIT19 0x0000000000080000ull
162 #define BIT20 0x0000000000100000ull
163 #define BIT21 0x0000000000200000ull
164 #define BIT22 0x0000000000400000ull
165 #define BIT23 0x0000000000800000ull
166 #define BIT24 0x0000000001000000ull
167 #define BIT25 0x0000000002000000ull
168 #define BIT26 0x0000000004000000ull
169 #define BIT27 0x0000000008000000ull
170 #define BIT28 0x0000000010000000ull
171 #define BIT29 0x0000000020000000ull
172 #define BIT30 0x0000000040000000ull
173 #define BIT31 0x0000000080000000ull
174 #define BIT32 0x0000000100000000ull
175 #define BIT33 0x0000000200000000ull
176 #define BIT34 0x0000000400000000ull
177 #define BIT35 0x0000000800000000ull
178 #define BIT36 0x0000001000000000ull
179 #define BIT37 0x0000002000000000ull
180 #define BIT38 0x0000004000000000ull
181 #define BIT39 0x0000008000000000ull
182 #define BIT40 0x0000010000000000ull
183 #define BIT41 0x0000020000000000ull
184 #define BIT42 0x0000040000000000ull
185 #define BIT43 0x0000080000000000ull
186 #define BIT44 0x0000100000000000ull
187 #define BIT45 0x0000200000000000ull
188 #define BIT46 0x0000400000000000ull
189 #define BIT47 0x0000800000000000ull
190 #define BIT48 0x0001000000000000ull
191 #define BIT49 0x0002000000000000ull
192 #define BIT50 0x0004000000000000ull
193 #define BIT51 0x0008000000000000ull
194 #define BIT52 0x0010000000000000ull
195 #define BIT53 0x0020000000000000ull
196 #define BIT54 0x0040000000000000ull
197 #define BIT55 0x0080000000000000ull
198 #define BIT56 0x0100000000000000ull
199 #define BIT57 0x0200000000000000ull
200 #define BIT58 0x0400000000000000ull
201 #define BIT59 0x0800000000000000ull
202 #define BIT60 0x1000000000000000ull
203 #define BIT61 0x2000000000000000ull
204 #define BIT62 0x4000000000000000ull
205 #define BIT63 0x8000000000000000ull
206
207 /// CPUID related registers
208 #define AMD_CPUID_FMF 0x80000001ul // Family Model Features information
209 #define AMD_CPUID_APICID_LPC_BID 0x00000001ul // Local APIC ID, Logical Processor Count, Brand ID
210 #define AMD_CPUID_L2L3Cache_L2TLB 0x80000006ul
211 #define CPUID_ASSOCIATIVITY_DISABLED 0x00
212 #define CPUID_ASSOCIATIVITY_1_WAY 0x01
213 #define CPUID_ASSOCIATIVITY_2_WAY 0x02
214 #define CPUID_ASSOCIATIVITY_4_WAY 0x04
215 #define CPUID_ASSOCIATIVITY_8_WAY 0x06
216 #define CPUID_ASSOCIATIVITY_16_WAY 0x08
217 #define CPUID_ASSOCIATIVITY_32_WAY 0x0A
218 #define CPUID_ASSOCIATIVITY_48_WAY 0x0B
219 #define CPUID_ASSOCIATIVITY_64_WAY 0x0C
220 #define CPUID_ASSOCIATIVITY_96_WAY 0x0D
221 #define CPUID_ASSOCIATIVITY_128_WAY 0x0E
222 #define CPUID_ASSOCIATIVITY_FULLY 0x0F
223 #define AMD_CPUID_TLB_L1Cache 0x80000005ul
224 #define AMD_CPUID_L1L2Tlb1GIdentifiers 0x80000019ul
225 #define AMD_CPUID_APM 0x80000007ul
226 #define LOCAL_APIC_ID 24
227 #define LOGICAL_PROCESSOR_COUNT 16
228 #define AMD_CPUID_ASIZE_PCCOUNT 0x80000008ul // Address Size, Physical Core Count
229
230 /// CPU Logical ID Transfer
231 typedef struct {
232 UINT32 RawId; ///< RawID
233 UINT64 LogicalId; ///< LogicalID
234 } CPU_LOGICAL_ID_XLAT;
235
236 /// Logical CPU ID Table
237 typedef struct {
238 IN UINT32 Elements; ///< Number of Elements
239 IN CPU_LOGICAL_ID_XLAT *LogicalIdTable; ///< CPU Logical ID Transfer table Pointer
240 } LOGICAL_ID_TABLE;
241
242 // MSRs
243 // ------------------------
244 #define MCG_CTL_P 0x00000100ul // bit 8 for MCG_CTL_P under MSRR
245 #define MSR_MCG_CAP 0x00000179ul
246 #define DBG_CTL_MSR 0x000001D9ul
247 #define MSR_MC0_CTL 0x00000400ul
248 #define MSR_MC0_STATUS 0x00000401ul
249 #define MSR_MC0_MISC 0x00000403ul
250 #define MSR_MC1_MISC 0x00000407ul
251 #define MSR_MC2_MISC 0x0000040Bul
252 #define MSR_MC4_MISC0 0x00000413ul
253 #define MSR_MC5_MISC 0x00000417ul
254 #define MSR_MC4_MISC1 0xC0000408ul
255 #define MSR_MC5_STATUS 0x00000415ul
256 #define MSR_MC6_STATUS 0x00000419ul
257
258 #define MSR_APIC_BAR 0x0000001Bul
259 #define MSR_PATCH_LEVEL 0x0000008Bul
260
261 #define CPUID_LONG_MODE_ADDR 0x80000008ul
262
263 #define MSR_EXTENDED_FEATURE_EN 0xC0000080ul
264 #define MSR_MC_MISC_LINK_THRESHOLD 0xC0000408ul
265 #define MSR_MC_MISC_L3_THRESHOLD 0xC0000409ul
266 #define MSR_PATCH_LOADER 0xC0010020ul
267
268 /// Patch Loader Register
269 typedef struct {
270 UINT64 PatchBase:32; ///< Linear address of patch header address block
271 UINT64 SBZ:32; ///< Should be zero
272 } PATCH_LOADER_MSR;
273
274 #define MSR_SYS_CFG 0xC0010010ul // SYSCFG - F15 Shared
275 #define MSR_TOM2 0xC001001Dul // TOP_MEM2 - F15 Shared
276 #define MSR_MC0_CTL_MASK 0xC0010044ul // MC0 Control Mask
277 #define MSR_MC1_CTL_MASK 0xC0010045ul // MC1 Control Mask
278 #define MSR_MC2_CTL_MASK 0xC0010046ul // MC2 Control Mask
279 #define MSR_MC4_CTL_MASK 0xC0010048ul // MC4 Control Mask
280
281 #define MSR_CPUID_FEATS 0xC0011004ul // CPUID Features
282 #define MSR_CPUID_EXT_FEATS 0xC0011005ul // CPUID Extended Features
283 #define MSR_HDT_CFG 0xC001100Aul
284 #define MSR_HWCR 0xC0010015ul
285 #define MSR_NB_CFG 0xC001001Ful // NB Config
286 #define CPU_WDT_CFG 0xC0010074ul
287 #define ENABLE_CF8_EXT_CFG 0x00004000ul // [46]
288 #define INIT_APIC_CPUID_LO 0x00400000ul // [54]
289 #define MSR_CU_SPMCTL 0xC0010281ul
290 #define MSR_CpuWdtCfg 0xC0010074ul // CPU Watchdog Timer
291 #define MSR_LS_CFG 0xC0011020ul
292 #define MSR_IC_CFG 0xC0011021ul // ICache Config - F15 Shared
293 #define MSR_DC_CFG 0xC0011022ul
294 #define MSR_ME_CFG 0xC0011029ul
295 #define MSR_BU_CFG 0xC0011023ul
296 #define MSR_CU_CFG 0xC0011023ul // F15 Shared
297 #define MSR_DE_CFG 0xC0011029ul // F15 Shared
298 #define MSR_BU_CFG2 0xC001102Aul
299 #define MSR_CU_CFG2 0xC001102Aul // F15 Shared
300 #define MSR_BU_CFG3 0xC001102Bul
301 #define MSR_CU_CFG3 0xC001102Bul // F15 Shared
302 #define MSR_LS_CFG2 0xC001102Dul
303 #define MSR_CU_PFTCFG 0xC001102Ful
304 #define MSR_IBS_OP_DATA3 0xC0011037ul
305 #define MSR_C001_1070 0xC0011070ul // F15 Shared
306 #define MSR_L2I_CFG 0xC00110A0ul // F16 shared
307 #define MSR_CU_CBBCFG 0xC00110A1ul // F15 CZ
308
309
310 #define MSR_CPUID_NAME_STRING0 0xC0010030ul // First CPUID namestring register
311 #define MSR_CPUID_NAME_STRING1 0xC0010031ul
312 #define MSR_CPUID_NAME_STRING2 0xC0010032ul
313 #define MSR_CPUID_NAME_STRING3 0xC0010033ul
314 #define MSR_CPUID_NAME_STRING4 0xC0010034ul
315 #define MSR_CPUID_NAME_STRING5 0xC0010035ul // Last CPUID namestring register
316 #define MSR_MMIO_Cfg_Base 0xC0010058ul // MMIO Configuration Base Address Register
317 #define MSR_BIST 0xC0010060ul // BIST Results register
318 #define MSR_OSVW_ID_Length 0xC0010140ul
319 #define MSR_OSVW_Status 0xC0010141ul
320 #define MSR_NB_PERF_CTL0 0xC0010240ul
321 #define MSR_NB_PERF_CTR0 0xC0010241ul
322 #define MSR_NB_PERF_CTL1 0xC0010242ul
323 #define MSR_NB_PERF_CTR1 0xC0010243ul
324 #define MSR_NB_PERF_CTL2 0xC0010244ul
325 #define MSR_NB_PERF_CTR2 0xC0010245ul
326 #define MSR_NB_PERF_CTL3 0xC0010246ul
327 #define MSR_NB_PERF_CTR3 0xC0010247ul
328 #define CU_SPMCTL 0xC0010281ul // Streaming Performance Monitor Control
329 #define MSR_PERF_CONTROL3 0xC0010003ul // Performance control register number 3
330 #define MSR_PERF_COUNTER3 0xC0010007ul // Performance counter register number 3
331 #define PERF_RESERVE_BIT_MASK 0x030FFFDFFFFFull // Mask of the Performance control Reserve bits
332 #define PERF_CAR_CORRUPTION_EVENT 0x040040F0E2ul // Configure the controller to capture the
333 // CAR Corruption
334 // FUNC_0 registers
335 // ----------------
336 #define LINK_INIT_CTRL 0x6C
337 #define LINK_INIT_CTRL_REQ_DIS 0x02 // [1] = ReqDis
338 #define LINK_INIT_COLD_RST_DET BIT4
339 #define LINK_INIT_BIOS_RST_DET_0 BIT5
340 #define LINK_INIT_BIOS_RST_DET_1 BIT9
341 #define LINK_INIT_BIOS_RST_DET_2 BIT10
342 #define LINK_INIT_BIOS_RST_DET BIT9 | BIT10
343 #define EXTENDED_NODE_ID 0x160
344
345 #define CORE_CTRL 0x1DC
346 #define CORE_CTRL_CORE1_EN 0x00000002ul
347 #define CORE_CTRL_CORE2_EN 0x00000004ul
348 #define CORE_CTRL_CORE3_EN 0x00000008ul
349 #define CORE_CTRL_CORE4_EN 0x00000010ul
350 #define CORE_CTRL_CORE5_EN 0x00000020ul
351 #define CORE_CTRL_CORE6_EN 0x00000040ul
352 #define CORE_CTRL_CORE7_EN 0x00000080ul
353 #define CORE_CTRL_CORE8_EN 0x00000100ul
354 #define CORE_CTRL_CORE9_EN 0x00000200ul
355
356 // FUNC_3 registers
357 // ----------------
358 #define HARDWARE_THERMAL_CTRL_REG 0x64
359 #define SOFTWARE_THERMAL_CTRL_REG 0x68
360
361 #define ACPI_PSC_0_REG 0x80 // ACPI Power State Control Registers
362 #define ACPI_PSC_4_REG 0x84
363
364 #define NB_CFG_HIGH_REG 0x8C
365 #define POWER_CTRL_MISCELLANEOUS_REG 0xA0
366 #define CLOCK_POWER_TIMING_CTRL2_REG 0xDC
367 #define NORTH_BRIDGE_CAPABILITIES_REG 0xE8
368 #define MULTI_NODE_CPU 29
369 #define CPUID_FMR 0xFC // Family / Model registers
370 #define DOWNCORE_CTRL 0x190 // Downcore Control Register
371
372 #define LINK_TO_XCS_TOKEN_COUNT_REG_3X148 0x148
373 #define REG_HT4_PHY_OFFSET_BASE_4X180 0x180
374 #define REG_HT4_PHY_DATA_PORT_BASE_4X184 0x184
375
376 // FUNC_5 registers
377 // ----------------
378 #define COMPUTE_UNIT_STATUS 0x80
379 #define NORTH_BRIDGE_CAPABILITIES_2_REG 0x84
380
381
382 // Misc. defines.
383 #define PCI_DEV_BASE 24
384
385 #define CPUID_STEPPING_MASK 0x0000000Ful
386 #define CPUID_BASE_MODEL_MASK 0x000000F0ul
387 #define CPUID_BASE_FAMILY_MASK 0x00000F00ul
388 #define CPUID_EXT_MODEL_MASK 0x000F0000ul
389 #define CPUID_EXT_FAMILY_MASK 0x0FF00000ul
390
391 #define TN_SOCKET_FP2 0
392 #define TN_SOCKET_FS1 1
393 #define TN_SOCKET_FM2 2
394 #define KV_SOCKET_FP3 0
395 #define KV_SOCKET_FM2r2 1
396 #define CZ_SOCKET_FP4 0 /// @todo : update value when BKDG updates
397 #define CZ_SOCKET_FM2r2 1 /// @todo : update value when BKDG updates
398 #define KB_SOCKET_FT3 0
399 #define KB_SOCKET_FS1b 1
400 #define ML_SOCKET_FT3b 0
401 #define SOCKET_IGNORE 0xF
402
403 #define LAPIC_BASE_ADDR_MASK 0x0000FFFFFFFFF000ull
404 #define APIC_EXT_BRDCST_MASK 0x000E0000ul
405 #define APIC_ENABLE_BIT 0x00000800ul
406 #define LOCAL_APIC_ADDR 0xFEE00000ul
407 #define INT_CMD_REG_LO 0x300
408 #define INT_CMD_REG_HI 0x310
409 #define REMOTE_MSG_REG 0x380
410 #define REMOTE_READ_REG 0xC0
411 #define APIC_ID_REG 0x20
412 #define APIC20_ApicId 24
413 #define CMD_REG_TO_READ_DATA 0x338
414
415 #define MAX_CORE_ID_SIZE 8
416 #define MAX_CORE_ID_MASK ((1 << MAX_CORE_ID_SIZE) - 1)
417
418 /*-------------------------
419 * Default definitions
420 *-------------------------
421 */
422 #define DOWNCORE_MASK_SINGLE 0xFFFFFFFEul
423 #define DOWNCORE_MASK_DUAL 0xFFFFFFFCul
424 #define DOWNCORE_MASK_TRI 0xFFFFFFF8ul
425 #define DOWNCORE_MASK_FOUR 0xFFFFFFF0ul
426 #define DOWNCORE_MASK_FIVE 0xFFFFFFE0ul
427 #define DOWNCORE_MASK_SIX 0xFFFFFFC0ul
428 #define DOWNCORE_MASK_SEVEN 0xFFFFFF80ul
429 #define DOWNCORE_MASK_EIGHT 0xFFFFFF00ul
430 #define DOWNCORE_MASK_TEN 0xFFFFFC00ul
431 #define DOWNCORE_MASK_TWELVE 0xFFFFF000ul
432 #define DOWNCORE_MASK_FOURTEEN 0xFFFFC000ul
433 #define DOWNCORE_MASK_DUAL_COMPUTE_UNIT 0xFFFFFFFAul
434 #define DOWNCORE_MASK_TRI_COMPUTE_UNIT 0xFFFFFFEAul
435 #define DOWNCORE_MASK_FOUR_COMPUTE_UNIT 0xFFFFFFAAul
436 #define DOWNCORE_MASK_FIVE_COMPUTE_UNIT 0xFFFFFEAAul
437 #define DOWNCORE_MASK_SIX_COMPUTE_UNIT 0xFFFFFAAAul
438 #define DOWNCORE_MASK_SEVEN_COMPUTE_UNIT 0xFFFFEAAAul
439 #define DOWNCORE_MASK_EIGHT_COMPUTE_UNIT 0xFFFFAAAAul
440
441 #define DELIVERY_STATUS BIT13
442 #define REMOTE_READ_STAT_MASK 0x00030000ul
443 #define REMOTE_DELIVERY_PENDING 0x00010000ul
444 #define REMOTE_DELIVERY_DONE 0x00020000ul
445
446 /*
447 * --------------------------------------------------------------------------------------
448 *
449 * D E F I N E S / T Y P E D E F S / S T R U C T U R E S
450 *
451 * --------------------------------------------------------------------------------------
452 */
453
454 /// CpuEarly param type
455 typedef struct {
456 IN UINT8 MemInitPState; ///< Pstate value during memory initial
457 IN PLATFORM_CONFIGURATION PlatformConfig; ///< Runtime configurable user options
458 } AMD_CPU_EARLY_PARAMS;
459
460 /// CPUID
461 typedef enum {
462 REG_EAX, ///< EAX
463 REG_EBX, ///< EBX
464 REG_ECX, ///< ECX
465 REG_EDX ///< EDX
466 } CPUID_REG;
467
468 #endif // _CPU_REGISTERS_H_
469