coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
eeprom.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <assert.h>
4 #include <soc/ramstage.h>
5 #include <types.h>
6 
8  struct __packed {
9  char name[50];
10  char manufacturer[50];
17  };
18  uint8_t raw[0x80];
19 };
20 
21 _Static_assert(sizeof(union eeprom_dimm_layout) == 0x80,
22  "union eeprom_dimm_layout has invalid size!");
23 
26  union {
27  struct __packed {
28  char cpu_name[50];
31  char pch_name[50];
32  union eeprom_dimm_layout dimm[4];
33  };
34  uint8_t raw_layout[617];
35  };
36 };
37 
38 _Static_assert(sizeof(struct eeprom_board_layout) == (617 + sizeof(uint32_t)),
39  "struct eeprom_board_layout has invalid size!");
40 
43  union {
44  struct __packed {
56  };
57  uint8_t raw_settings[11];
58  };
59 };
60 
61 _Static_assert(sizeof(struct eeprom_board_settings) == (11 + sizeof(uint32_t)),
62  "struct eeprom_board_settings has invalid size!");
63 
68 };
69 
70 #define HERMES_SERIAL_NUMBER_LENGTH 32
71 
72 /* The EEPROM on address 0x57 has the following vendor defined layout: */
74  union {
75  uint8_t RawFSPMUPD[0x600];
76  FSPM_UPD mupd;
77  };
78  union {
79  uint8_t RawFSPSUPD[0xc00];
80  FSPS_UPD supd;
81  };
82  union {
83  uint8_t RawBoardLayout[0x400];
84  struct eeprom_board_layout BoardLayout;
85  };
86  char system_serial_number[HERMES_SERIAL_NUMBER_LENGTH];
87  char board_serial_number[HERMES_SERIAL_NUMBER_LENGTH];
88  uint8_t BootOrder[0x8c0];
89  union {
90  uint8_t RawBoardSetting[0xf8];
91  struct eeprom_board_settings BoardSettings;
92  };
93  union {
94  uint8_t RawBMCSetting[0x8];
95  struct eeprom_bmc_settings BMCSettings;
96  };
97 };
98 
99 _Static_assert(sizeof(FSPM_UPD) <= 0x600, "FSPM_UPD too big");
100 _Static_assert(sizeof(FSPS_UPD) <= 0xc00, "FSPS_UPD too big");
101 _Static_assert(sizeof(struct eeprom_layout) == 0x2000, "EEPROM layout size mismatch");
102 
103 bool eeprom_read_buffer(void *blob, size_t read_offset, size_t size);
104 int check_signature(const size_t offset, const uint64_t signature);
107 uint8_t get_bmc_hsi(void);
108 void report_eeprom_error(const size_t off);
109 bool write_board_settings(const struct eeprom_board_layout *new_layout);
110 
111 #define READ_EEPROM(section_type, section_name, dest, opt_name) \
112  do { \
113  typeof(dest->opt_name) __tmp; \
114  size_t __off = offsetof(struct eeprom_layout, section_name); \
115  bool ret = eeprom_read_buffer(&__tmp, \
116  __off + offsetof(section_type, opt_name), \
117  sizeof(__tmp)); \
118  if (ret) { \
119  report_eeprom_error(__off + offsetof(section_type, opt_name)); \
120  } else { \
121  dest->opt_name = __tmp; \
122  } \
123  } while (0)
124 
125 #define READ_EEPROM_FSP_M(dest, opt_name) READ_EEPROM(FSPM_UPD, RawFSPMUPD, dest, opt_name)
126 #define READ_EEPROM_FSP_S(dest, opt_name) READ_EEPROM(FSPS_UPD, RawFSPSUPD, dest, opt_name)
static size_t offset
Definition: flashconsole.c:16
bool write_board_settings(const struct eeprom_board_layout *new_layout)
Definition: eeprom.c:183
void report_eeprom_error(const size_t off)
Definition: eeprom.c:135
struct eeprom_bmc_settings * get_bmc_settings(void)
Definition: eeprom.c:73
_Static_assert(sizeof(union eeprom_dimm_layout)==0x80, "union eeprom_dimm_layout has invalid size!")
uint8_t get_bmc_hsi(void)
Definition: eeprom.c:91
#define HERMES_SERIAL_NUMBER_LENGTH
Definition: eeprom.h:70
struct eeprom_board_settings * get_board_settings(void)
Definition: eeprom.c:59
bool eeprom_read_buffer(void *blob, size_t read_offset, size_t size)
Definition: eeprom.c:103
int check_signature(const size_t offset, const uint64_t signature)
Definition: eeprom.c:20
unsigned int uint32_t
Definition: stdint.h:14
unsigned long long uint64_t
Definition: stdint.h:17
unsigned char uint8_t
Definition: stdint.h:8
Definition: x86.c:23
uint8_t pcie_mux
Definition: eeprom.h:65
uint8_t efp3_displayport
Definition: eeprom.h:67
uint32_t signature
Definition: eeprom.h:25
uint8_t cpu_count
Definition: eeprom.h:29
uint32_t cpu_max_non_turbo_frequency
Definition: eeprom.h:30
uint8_t front_panel_audio
Definition: eeprom.h:52
uint8_t pxe_boot_capability
Definition: eeprom.h:53
uint8_t wake_on_usb
Definition: eeprom.h:48
uint32_t signature
Definition: eeprom.h:42
uint8_t secureboot
Definition: eeprom.h:45
uint8_t primary_video
Definition: eeprom.h:46
uint8_t deep_sx_enabled
Definition: eeprom.h:47
uint8_t blue_rear_vref
Definition: eeprom.h:51
uint8_t usb_powered_in_s5
Definition: eeprom.h:49
uint8_t pink_rear_vref
Definition: eeprom.h:54
uint8_t power_state_after_g3
Definition: eeprom.h:50
uint8_t vtx_disabled
Definition: eeprom.h:55
FSPM_UPD mupd
Definition: eeprom.h:76
FSPS_UPD supd
Definition: eeprom.h:80
uint8_t raw[0x80]
Definition: eeprom.h:18