memtest86plus/system/memctrl.h
Sam Demeulemeester 7aeac7271f
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

58 lines
1.2 KiB
C

// SPDX-License-Identifier: GPL-2.0
#ifndef MEMCTRL_H
#define MEMCTRL_H
/**
* \file
*
* Provides information about the memory controller status
* (running DRAM configuration, ECC, ...) and other
* platform-specific data
*
*//*
* Copyright (C) 2004-2023 Sam Demeulemeester.
*/
typedef struct __attribute__((packed)) imc_infos {
char *type;
uint16_t family;
uint16_t freq;
uint16_t width;
uint16_t tCL;
uint8_t tCL_dec;
uint16_t tRCD;
uint16_t tRP;
uint16_t tRAS;
} imc_info_t;
typedef enum {
ECC_ERR_NONE,
ECC_ERR_CORRECTED,
ECC_ERR_UNCORRECTED
} ecc_error_type_t;
typedef struct __attribute__((packed)) ecc_status {
bool ecc_enabled;
ecc_error_type_t err_type;
uint64_t err_adr;
uint32_t err_col;
uint32_t err_row;
uint32_t err_rank;
uint32_t err_bank;
} ecc_info_t;
/**
* Current DRAM configuration of the Integrated Memory Controller
*/
extern imc_info_t imc;
/**
* Current ECC Status of the Integrated Memory Controller
*/
extern ecc_info_t ecc_status;
void memctrl_init(void);
#endif // MEMCTRL_H