memtest86plus/system/cpuinfo.h

133 lines
4.2 KiB
C
Raw Normal View History

2020-05-24 15:30:55 -05:00
// SPDX-License-Identifier: GPL-2.0
#ifndef CPUINFO_H
#define CPUINFO_H
/**
* \file
*
2020-05-24 15:30:55 -05:00
* Provides information about the CPU type, clock speed and cache sizes.
*
*//*
* Copyright (C) 2020-2022 Martin Whitaker.
2023-04-23 17:29:37 -05:00
* Copyright (C) 2004-2023 Sam Demeulemeester.
2020-05-24 15:30:55 -05:00
*/
#include <stdbool.h>
#include <stdint.h>
/**
* IMC Definition
*/
#define IMC_NHM 0x1000 // Core i7 1st Gen 45 nm (Nehalem/Bloomfield)
#define IMC_WMR 0x1010 // Core 1st Gen 32 nm (Westmere)
#define IMC_SNB 0x1020 // Core 2nd Gen (Sandy Bridge)
#define IMC_IVB 0x1030 // Core 3rd Gen (Ivy Bridge)
#define IMC_HSW 0x1040 // Core 4th Gen (Haswell)
#define IMC_BDW 0x1050 // Core 5th Gen (Broadwell)
#define IMC_SKL 0x1060 // Core 6th Gen (Sky Lake-S/H/E)
#define IMC_KBL 0x1070 // Core 7/8/9th Gen (Kaby/Coffee/Comet Lake)
#define IMC_CNL 0x1080 // Cannon Lake
#define IMC_RKL 0x1090 // Core 11th Gen (Rocket Lake)
#define IMC_ADL 0x1100 // Core 12th Gen (Alder Lake-S)
#define IMC_RPL 0x1110 // Core 13th Gen (Raptor Lake)
#define IMC_MTL 0x1120 // Core 14th Gen (Meteor Lake)
#define IMC_NHM_E 0x2010 // Core i7 1st Gen 45 nm (Nehalem-E)
#define IMC_SNB_E 0x2020 // Core 2nd Gen (Sandy Bridge-E)
#define IMC_IVB_E 0x2030 // Core 3rd Gen (Ivy Bridge-E)
#define IMC_HSW_E 0x2040 // Core 3rd Gen (Haswell-E)
#define IMC_SKL_SP 0x2050 // Skylake/Cascade Lake/Cooper Lake (Server)
#define IMC_BDW_E 0x2060 // Broadwell-E (Server)
#define IMC_BDW_DE 0x2070 // Broadwell-DE (Server)
#define IMC_ICL_SP 0x2080 // Ice Lake-SP/DE (Server)
#define IMC_SPR 0x2090 // Sapphire Rapids (Server)
#define IMC_HSW_ULT 0x3010 // Core 4th Gen (Haswell-ULT)
#define IMC_SKL_UY 0x3020 // Core 6th Gen (Sky Lake-U/Y)
#define IMC_KBL_UY 0x3030 // Core 7/8/9th Gen (Kaby/Coffee/Comet/Amber Lake-U/Y)
#define IMC_ICL 0x3040 // Core 10th Gen (IceLake-Y)
#define IMC_TGL 0x3050 // Core 11th Gen (Tiger Lake-U)
2023-04-23 17:29:37 -05:00
#define IMC_ADL_N 0x3061 // Core 12th Gen (Alder Lake-N - Gracemont E-Cores only)
#define IMC_BYT 0x4010 // Atom Bay Trail
#define IMC_SLT 0x4020 // Atom Silverthorne / Diamondville
#define IMC_PNV 0x4030 // Atom Pineview
#define IMC_CLT 0x4040 // Atom Clover Trail / Cloverview
#define IMC_CDT 0x4050 // Atom Cedar Trail / Cedarview
#define IMC_TNC 0x4060 // Atom Tunnel Creek / Lincroft
#define IMC_K8 0x8000 // Old K8
#define IMC_K10 0x8010 // K10 (Family 10h & 11h)
#define IMC_K12 0x8020 // A-Series APU (Family 12h)
#define IMC_K14 0x8030 // C- / E- / Z- Series APU (Family 14h)
#define IMC_K15 0x8040 // FX Series (Family 15h)
#define IMC_K16 0x8050 // Kabini & related (Family 16h)
#define IMC_K17 0x8060 // Zen & Zen2 (Family 17h)
#define IMC_K18 0x8070 // Hygon (Family 18h)
Add Memory Controller Registers polling to get current DRAM Timings/Frequency (#306) Read the memory controller configuration (instead of just relying on SPD data) to get the actual live settings. Currently supported platforms: * Intel SNB to RPL (Core 2nd Gen to Core 13th Gen) - Desktop only (no Server nor Mobile) * AMD SMR to RPL (Zen to Zen4) - Desktop only (no Server, Mobile nor APU). Individual commits below for archival: * First functions skeleton for reading IMC/ECC Registers * Change directory name from 'chipsets' to 'mch' (Memory Controller Hub) * Add Intel HSW and fix new files encoding * First Intel HSW IMC implementation * Add an option to disable MCH registers polling * Remove old include from Makefiles * Better Makefile and padding fixes * Statically init 'imc' struct to generate string relocation record * Small typos & code fixes * Add IMC support for Intel Core 6/7/8/9th Gen (SKL/KBL/CFL/CML) This is a bit more complex than Haswell and below because MMIO switched to 64-bit with Skylake (lot of) betatesting needed * Add IMC read support for Intel SNB/IVB (2nd/3rd gen Core) * Fix hard-lock on Intel SNB/IVB due to wrong access type on MCHBAR pointer * Move AMD SMN Registers & offsets to a specific header file * Add IMC Read support for AMD Zen/Zen2 CPUs * Change 'IMC' to 'MCH' in Makefiles to match actual mch/ directory * Add IMC Reading support for Intel ADL&RPL CPUs (Core Gen12&13) * Add support for Intel Rocket Lake (Core 11th Gen) and AMD Vermeer * Add IMC reading for AMD Zen4 'Raphael' AM5 CPUs * Various Cleanup #1 Change terminology from Intel-based 'MCH' (Memory Controller Hub) to more universal 'IMC' (Integrated Memory Controller) Integrate imc_type var into imc struct. Remove previously created AMD SNM header file * Various Cleanup 2 * Change DDR5 display format for IMC specs DDR5 Freq can be > 10000 and timings up to 63-127-127-127, which overwflow the available space. This commit remove the raw frequency on DDR5 (which may be incorrect due to Gear mechanism) and leave a bit of space to display the Gear engaged in the future
2023-05-12 08:33:28 -05:00
#define IMC_K19_VRM 0x8080 // Zen3 (Family 19h - Vermeer)
#define IMC_K19_CZN 0x8081 // Cezanne APU
#define IMC_K19_CHL 0x8090 // Zen3 Chagall TR
Add Memory Controller Registers polling to get current DRAM Timings/Frequency (#306) Read the memory controller configuration (instead of just relying on SPD data) to get the actual live settings. Currently supported platforms: * Intel SNB to RPL (Core 2nd Gen to Core 13th Gen) - Desktop only (no Server nor Mobile) * AMD SMR to RPL (Zen to Zen4) - Desktop only (no Server, Mobile nor APU). Individual commits below for archival: * First functions skeleton for reading IMC/ECC Registers * Change directory name from 'chipsets' to 'mch' (Memory Controller Hub) * Add Intel HSW and fix new files encoding * First Intel HSW IMC implementation * Add an option to disable MCH registers polling * Remove old include from Makefiles * Better Makefile and padding fixes * Statically init 'imc' struct to generate string relocation record * Small typos & code fixes * Add IMC support for Intel Core 6/7/8/9th Gen (SKL/KBL/CFL/CML) This is a bit more complex than Haswell and below because MMIO switched to 64-bit with Skylake (lot of) betatesting needed * Add IMC read support for Intel SNB/IVB (2nd/3rd gen Core) * Fix hard-lock on Intel SNB/IVB due to wrong access type on MCHBAR pointer * Move AMD SMN Registers & offsets to a specific header file * Add IMC Read support for AMD Zen/Zen2 CPUs * Change 'IMC' to 'MCH' in Makefiles to match actual mch/ directory * Add IMC Reading support for Intel ADL&RPL CPUs (Core Gen12&13) * Add support for Intel Rocket Lake (Core 11th Gen) and AMD Vermeer * Add IMC reading for AMD Zen4 'Raphael' AM5 CPUs * Various Cleanup #1 Change terminology from Intel-based 'MCH' (Memory Controller Hub) to more universal 'IMC' (Integrated Memory Controller) Integrate imc_type var into imc struct. Remove previously created AMD SNM header file * Various Cleanup 2 * Change DDR5 display format for IMC specs DDR5 Freq can be > 10000 and timings up to 63-127-127-127, which overwflow the available space. This commit remove the raw frequency on DDR5 (which may be incorrect due to Gear mechanism) and leave a bit of space to display the Gear engaged in the future
2023-05-12 08:33:28 -05:00
#define IMC_K19_RBT 0x8100 // Zen3+ (Rembrandt)
#define IMC_K19_RPL 0x8110 // Zen4 (Raphael)
#define IMC_K19_PHX 0x8120 // Zen4 (Phoenix)
#define IMC_K19_STK 0x81A0 // Zen4 (Storm Peak)
#define IMC_K19_GRG 0x8150 // Zen5 (Granite Ridge)
/**
2020-05-24 15:30:55 -05:00
* A string identifying the CPU make and model.
*/
extern const char *cpu_model;
/**
2020-05-24 15:30:55 -05:00
* The size of the L1 cache in KB.
*/
extern int l1_cache;
/**
2020-05-24 15:30:55 -05:00
* The size of the L2 cache in KB.
*/
extern int l2_cache;
/**
2020-05-24 15:30:55 -05:00
* The size of the L3 cache in KB.
*/
extern int l3_cache;
/**
* The bandwidth of the L1 cache
*/
extern uint32_t l1_cache_speed;
/**
* The bandwidth of the L2 cache
*/
extern uint32_t l2_cache_speed;
/**
* The bandwidth of the L3 cache
*/
extern uint32_t l3_cache_speed;
/**
* The bandwidth of the RAM
*/
extern uint32_t ram_speed;
/**
2020-05-24 15:30:55 -05:00
* The TSC clock speed in kHz. Assumed to be the nominal CPU clock speed.
*/
extern uint32_t clks_per_msec;
/**
2020-05-24 15:30:55 -05:00
* Determines the CPU info and stores it in the exported variables.
*/
void cpuinfo_init(void);
/**
* Determines the RAM & caches bandwidth and stores it in the exported variables.
*/
void membw_init(void);
2020-05-24 15:30:55 -05:00
#endif // CPUINFO_H