memtest86plus/system/cpuinfo.h

143 lines
4.7 KiB
C
Raw Permalink Normal View History

2020-05-24 21:30:55 +01:00
// SPDX-License-Identifier: GPL-2.0
#ifndef CPUINFO_H
#define CPUINFO_H
/**
* \file
*
2020-05-24 21:30:55 +01:00
* Provides information about the CPU type, clock speed and cache sizes.
*
*//*
* Copyright (C) 2020-2022 Martin Whitaker.
2023-04-24 00:29:37 +02:00
* Copyright (C) 2004-2023 Sam Demeulemeester.
2020-05-24 21:30:55 +01: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_ARL 0x1130 // Core 15th Gen (Arrow 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-24 00:29:37 +02: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 15:33:28 +02: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 15:33:28 +02: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_K1A_STP 0x8200 // Zen5 (Strix Point)
#define IMC_K1A_GRG 0x8210 // Zen5 (Granite Ridge)
#define IMC_K1A_KRN 0x8220 // Zen5 (Krackan)
#define IMC_K1A_STH 0x8230 // Zen5 (Strix Halo)
#define IMC_K1A_MDS 0x8240 // Zen6 (Medusa)
Add LoongArch support (#410) * lib/assert: Add LoongArch assert support Added LoongArch break 3 assert instruction. Signed-off-by: Chao Li <lichao@loongson.cn> * lib/barrier: Add barrier method for LoongArch Added LoongArch barriers in barrier_spin_wait and barrier_halt_wait functions. Signed-off-by: Chao Li <lichao@loognson.cn> * lib/spinlock: Add LoongArch CPU pause Because the LoongArch haven't pause instruction, using eight nops to replace the pause. Signed-off-by: Chao Li <lichao@loongson.cn> * lib/string: Make LoongArch use the string function in the file Since LoongArch GCC doesn't have built-in string functions, use the string function instance in the sting.c Signed-off-by: Chao Li <lichao@loongson.cn> * lib/unistd: Add LoongArch CPU pause Because the LoongArch haven't pause instruction, using eight nops to replace the pause. Signed-off-by: Chao Li <lichao@loongson.cn> * system/acpi: Reduce the way of search RSDP for non-x86 ARCHs Searching RSDP from legacy BIOS EDBA and reserved areas is available only on i386 and x64. Signed-off-by: Chao Li <lichao@loongson.cn> * system/cache: Add LoongArch64 cache operations support Added cache operations support for LoongArch64. Signed-off-by: Chao Li <lichao@loongson.cn> * system/cpuid: Add the compile limit Make the `cpuid` function action only on i386/x64. Signed-off-by: Chao Li <lichao@loongson.cn> * system/heap: Add heap support for LoongArch64 LoongArch64 uses the low 256MB as the low memory. Signed-off-by: Chao Li <lichao@loongson.cn> * system/memrw: Add 8-bit and 16-bit memory operations Added 8-bit and 16-bit memory access operations, which 8-bit uses `movb` and 16-bit is `movw`. Signed-off-by: Chao Li <lichao@loongson.cn> * system/memrw: Add LoongArch memory access operations Added 8/16/32/64-bit memory access operations for LoongArch64. Signed-off-by: Chao Li <lichao@loongson.cn> * system: Add Loongson PCI vendor ID and Loongson 7A chipset EHCI workaround 1. Added Loongson PCI vendor ID. 2. Added Loongson 7A chipset ECHI workaround. Signed-off-by: Chao Li <lichao@loongson.cn> * system/io: Add LoongArch64 IO port operations Added IO port operations for LoongArch64. Signed-off-by: Chao Li <lichao@loongson.cn> * system/reloc64: Add LoongArch64 relocations support Added R_LARCH_RELATIVE and R_LARCH_NONE relocations support for LoongArch64. Signed-off-by: Chao Li <lichao@loongson.cn> * system/serial: Add Loongson CPU serial port support Add the serial port address perfix of Loongson CPU and obtain serial port clock method. Signed-off-by: Chao Li <lichao@loongson.cn> * system/smbus: Rename smbus.c to i2c_x86.c Renamed the smbus.c to i2c_x86.c in i386 and x64 platforms. Signed-off-by: Chao Li <lichao@loongson.cn> * system/smp: Add LoongArch SMP support Added LoongArch multi-core support and a way of map to node numbers if the NUMA is enabled. Signed-off-by: Chao Li <lichao@loongson.cn> * system/timers: Add LoongArch supports In LoongArch, there is a stable counter that is independent of other clocks, it like the TSC in x64. Using it to count the ticks per millisecond. Signed-off-by: Chao Li <lichao@loongson.cn> * system/tsc: Add LoongArch support Usually the frequency of stable counter is not same to CPU frequency, so using the performance counter for the delay operations. Signed-off-by: Chao Li <lichao@loongson.cn> * system/usbhcd: Add LoongArch MMIO perfix Added LoongArch64 MMIO address perfix, use for address the PCI memory space. Signed-off-by: Chao Li <lichao@loongson.cn> * system/usbhcd: Add Loongson 7A2000 chipset OHCI BAR offset fix If the BAR address is not fixed for the Loongson 7A2000 OHCI controller, some prots will not be usable, This change currently only affects the LoongArch platform. Signed-off-by: Chao Li <lichao@loongson.cn> * system: Add the way to IO access via MMIO Usually, it is access the IO like PCI IO via MMIO on non-X86 ARCHs, so a method to access IO via MMIO is added. Signed-off-by: Chao Li <lichao@loongson.cn> * system: Add the way to access PCI memory space via MMIO Some uniformly address ARCHs access the PCI memory depended the MMIO, so the method to access PCI memory via MMIO is added. Signed-off-by: Chao Li <lichao@loongson.cn> * app: Add LoongArch version support Reduced the version field by two characters to support ARCH name abbreviations with more than three characters, and added "la64" ARCH version display. Singed-off-by: Chao Li <lichao@loongson.cn> * test/block_move: Add block move test via ASM for LoongArch Add block move test inline assembly instance for LoongArch. Signed-off-by: Chao Li <lichao@loongson.cn> * test/mov_inv_fixed: Add LoongArch ASM version word write operation Add LoongArch ASM version word write cycle if it uses the HAND_OPTIMISED. Signed-off-by: Chao Li <lichao@loongson.cn> * boot: Adjust the AP stack size for LoongArch LoongArch exception will store all of the GP, FP and CSR on stack, it need more stack size, make LoongArch AP using 2KB stack size. Signed-off-by: Chao Li <lichao@loongson.cn> * boot/efisetup: Add LoongArch CPU halt instruction Add "idle 0" for LoongArch Signed-off-by: Chao Li <lichao@loongson.cn> * boot/efi: Limiting the ms_abi using scope Make the ms_abi only work on i386 and x64. Signed-off-by: Chao Li <lichao@loongson.cn> * system/imc/loongson: Add Loongson LoongArch IMC support Added the Loongson LoongArch CPU IMC instance, support read out the IMC sequence, currently only supports reading MC0. Signed-off-by: Chao Li <lichao@loongson.cn> * app/loongarch: Add intrrupt handler for LoongArch Added the LoongArch IRQ handler support. Signed-off-by: Chao Li <lichao@loongson.cn> * system/loongarch: Add LoongArch ARCH specific files Added LoongArch ARCH specific files: cpuid.c, cpuinfo.c, hwctrl.c, memctrl.c, temperature.c, vmem.c, registers.h They use the same pubilc API for i386 and x64 platforms. Signed-off-by: Chao Li <lichao@loongson.cn> * boot: Add LoongArch startup and header Added the header.S and startup64.S for LoongArch, CPU works on: 1. Page mode. 2. Load and store is cacheable. 3. Instructions is cacheable. 4. DMWn 0 and 1 is used. 5. To access non-cacheable areas, use the perfix 0x8000000000000000. Signed-off Chao Li <lichao@loongson.cn> * build64/la64: Add LoongArch64 build files Add infrastructure files to build memtest86 plus for LoongArch64 platform. Signed-off-by: Chao Li <lichao@loongson.cn> * workflows: Add LoongArch64 CI supports Adjust workflow logci, remvoe 32 and 64 wordsize, replace with "i386, x86_64 and la64", add LoongArch64 build CI check. Signed-off-by: Chao Li <lichao@loongson.cn> --------- Signed-off-by: Chao Li <lichao@loongson.cn> Signed-off-by: Chao Li <lichao@loognson.cn>
2024-08-30 19:38:46 +08:00
#define IMC_LSLA 0xC000 // Loongson LoongArch family
#define IMC_LA464 0xC010 // LA464 (Loongson 3th Gen)
#define IMC_LA664 0xC011 // LA664 (Loongson 4th Gen)
/**
2020-05-24 21:30:55 +01:00
* A string identifying the CPU make and model.
*/
extern const char *cpu_model;
/**
2020-05-24 21:30:55 +01:00
* The size of the L1 cache in KB.
*/
extern int l1_cache;
/**
2020-05-24 21:30:55 +01:00
* The size of the L2 cache in KB.
*/
extern int l2_cache;
/**
2020-05-24 21:30:55 +01: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 21:30:55 +01:00
* The TSC clock speed in kHz. Assumed to be the nominal CPU clock speed.
*/
extern uint32_t clks_per_msec;
/**
2020-05-24 21:30:55 +01: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 21:30:55 +01:00
#endif // CPUINFO_H