coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spd.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <cbfs.h>
4 #include <console/console.h>
5 
6 #include "spd.h"
7 
8 /* Get SPD data for on-board memory */
10 {
12  int spd_index;
13  size_t spd_file_len;
14  char *spd_file;
15 
16  spd_index = 0;
17 
18  spd_file = cbfs_map("spd.bin", &spd_file_len);
19  if (!spd_file)
20  die("SPD data not found.");
21 
22  if (spd_file_len < ((spd_index + 1) * SPD_LEN)) {
24  "SPD index override to 0 due to incorrect SPD index.\n");
25  spd_index = 0;
26  }
27 
28  if (spd_file_len < SPD_LEN)
29  die("Missing SPD data.");
30 
31  /* Assume same memory in both channels */
32  spd_index *= SPD_LEN;
33  spd_data = (uint8_t *)(spd_file + spd_index);
34 
35  /* Make sure a valid SPD was found */
36  if (spd_data[0] == 0)
37  die("Invalid SPD data.");
38 
39  return spd_data;
40 }
static void * cbfs_map(const char *name, size_t *size_out)
Definition: cbfs.h:246
#define printk(level,...)
Definition: stdlib.h:16
void __noreturn die(const char *fmt,...)
Definition: die.c:17
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define SPD_LEN
Definition: spd.c:22
static const int spd_index[32]
Definition: memory.c:10
uint8_t * mainboard_find_spd_data()
Definition: spd.c:9
static u8 spd_data[CONFIG_DIMM_MAX *CONFIG_DIMM_SPD_SIZE]
Definition: smbuslib.c:70
unsigned char uint8_t
Definition: stdint.h:8