coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
memory.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <baseboard/variants.h>
4 #include <console/console.h>
5 #include <gpio.h>
6 #include <spd_bin.h>
7 #include <string.h>
8 #include <variant/gpio.h>
9 #include <amdblocks/dimm_spd.h>
10 
12 {
13  gpio_t pads[] = {
14  [3] = MEM_CONFIG3,
15  [2] = MEM_CONFIG2,
16  [1] = MEM_CONFIG1,
17  [0] = MEM_CONFIG0,
18  };
19 
20  return gpio_base2_value(pads, ARRAY_SIZE(pads));
21 }
22 
24  char *buf, size_t len)
25 {
27 
28  printk(BIOS_INFO, "%s SPD index %d\n", __func__, spd_index);
29 
30  void *spd = (void *)spd_cbfs_map(spd_index);
31  if (!spd) {
32  printk(BIOS_ERR, "spd.bin not found\n");
33  return -1;
34  }
35 
36  if (len != CONFIG_DIMM_SPD_SIZE) {
37  printk(BIOS_ERR, "spd.bin is not the correct size\n");
38  return -1;
39  }
40 
41  memcpy(buf, spd, len);
42 
43  return 0;
44 }
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
uint32_t gpio_base2_value(const gpio_t gpio[], int num_gpio)
Definition: gpio.c:30
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
static uint8_t * buf
Definition: uart.c:7
int __weak variant_memory_sku(void)
Definition: memory.c:74
static const int spd_index[32]
Definition: memory.c:10
#define MEM_CONFIG0
Definition: gpio.h:10
#define MEM_CONFIG3
Definition: gpio.h:13
#define MEM_CONFIG1
Definition: gpio.h:11
#define MEM_CONFIG2
Definition: gpio.h:12
int __weak variant_mainboard_read_spd(uint8_t spdAddress, char *buf, size_t len)
Definition: memory.c:23
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
uintptr_t spd_cbfs_map(u8 spd_index)
Definition: spd_bin.c:217
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8