memtest86plus/system/spd.h
01e3 771d6d4dca
Split SPD parsing and printing code from smbus.c to spd.c (#426)
* Split SPD parsing and printing code from smbus.c to spd.c

Move all SPD parsing and printing code from smbus.{c,h} to spd.{c,h}.

Introduce parse_spd() function, moving the parse_spd_* selection logic
from print_smbus_startup_info(), allowing to keep parse_spd_* static.

Remove static from get_spd() and update print_smbus_startup_info()
to use parse_spd() which also simplifies the code flow.

Move LINE_SPD into display.h and rename it to ROW_SPD. Update print_spdi()
to use explicit row number where the SPD info needs to be printed.

Rename ram_info into ram_info_t, rename print_smbus_startup_info()
into print_spd_startup_info.

Do not initialize ram.freq to 0, this is the initial value already.

Do not set curspd.isValid to False, the first thing that parse_spd()
does is setting the entire struct to 0, that also sets isValid to False.

print_spd_startup_info() from smbus.c is technically a skeleton now
so each arch can have its own version, adjusted as needed. Once
LA64 changes land, we can think how we can even make it arch agnostic.

* Add -fexcess-precision=standard to CFLAGS for build(32,64)/Makefile

Recent switch from -std=c11 to -std=gnu11 done in 53ca89f ("Add
initial NUMA awareness support") introduced a regression in SPD
parsing code (and potentially in other places) due to change of
floating point precision. Restore the original behavior by
adding -fexcess-precision=standard to CFLAGS.

Bug: https://github.com/memtest86plus/memtest86plus/issues/425
Fixes: 53ca89f8ae
2024-08-08 02:41:19 +02:00

51 lines
1.0 KiB
C

#ifndef _SPD_H_
#define _SPD_H_
/**
* SPDX-License-Identifier: GPL-2.0
*
* \file
*
* Provides access to SPD parsing and printing functions.
*
* Copyright (C) 2004-2023 Sam Demeulemeester.
*/
#define SPD_SKU_LEN 32
typedef struct spd_infos {
bool isValid;
uint8_t slot_num;
uint16_t jedec_code;
uint32_t module_size;
char *type;
char sku[SPD_SKU_LEN + 1];
uint8_t XMP;
uint16_t freq;
bool hasECC;
uint8_t fab_year;
uint8_t fab_week;
uint16_t tCL;
uint8_t tCL_dec;
uint16_t tRCD;
uint16_t tRP;
uint16_t tRAS;
uint16_t tRC;
} spd_info;
typedef struct ram_infos {
uint16_t freq;
uint16_t tCL;
uint8_t tCL_dec;
uint16_t tRCD;
uint16_t tRP;
uint16_t tRAS;
char *type;
} ram_info_t;
extern ram_info_t ram;
void print_spdi(spd_info spdi, uint8_t lidx);
void parse_spd(spd_info *spdi, uint8_t slot_idx);
#endif // SPD_H