mb/google/fatcat: Move CSE sync at payload
[coreboot.git] / util / nvramtool / layout.h
blob02652e0d8e897b7d83a82287efb527b3e5839b4d
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef LAYOUT_H
4 #define LAYOUT_H
6 #include "common.h"
7 #include "coreboot_tables.h"
9 #define LAYOUT_ENTRY_OVERLAP (LAYOUT_RESULT_START + 0)
10 #define LAYOUT_ENTRY_BAD_LENGTH (LAYOUT_RESULT_START + 1)
11 #define LAYOUT_DUPLICATE_ENUM (LAYOUT_RESULT_START + 2)
12 #define LAYOUT_SUMMED_AREA_START_NOT_ALIGNED (LAYOUT_RESULT_START + 3)
13 #define LAYOUT_SUMMED_AREA_END_NOT_ALIGNED (LAYOUT_RESULT_START + 4)
14 #define LAYOUT_CHECKSUM_LOCATION_NOT_ALIGNED (LAYOUT_RESULT_START + 5)
15 #define LAYOUT_INVALID_SUMMED_AREA (LAYOUT_RESULT_START + 6)
16 #define LAYOUT_CHECKSUM_OVERLAPS_SUMMED_AREA (LAYOUT_RESULT_START + 7)
17 #define LAYOUT_SUMMED_AREA_OUT_OF_RANGE (LAYOUT_RESULT_START + 8)
18 #define LAYOUT_CHECKSUM_LOCATION_OUT_OF_RANGE (LAYOUT_RESULT_START + 9)
19 #define LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED (LAYOUT_RESULT_START + 10)
21 typedef enum {
22 CMOS_ENTRY_ENUM = 'e',
23 CMOS_ENTRY_HEX = 'h',
24 CMOS_ENTRY_STRING = 's',
25 CMOS_ENTRY_RESERVED = 'r',
26 } cmos_entry_config_t;
28 /* This represents a CMOS parameter. */
29 typedef struct {
30 unsigned bit;
31 unsigned length;
32 cmos_entry_config_t config;
33 unsigned config_id;
34 char name[CMOS_MAX_NAME_LENGTH + 1];
35 } cmos_entry_t;
37 /* This represents a possible value for a CMOS parameter of type
38 * CMOS_ENTRY_ENUM.
40 typedef struct {
41 unsigned config_id;
42 unsigned long long value;
43 char text[CMOS_MAX_TEXT_LENGTH + 1];
44 } cmos_enum_t;
46 /* This represents the location of the CMOS checksum and the area over
47 * which it is computed. Depending on the context, the values may be
48 * represented as either bit positions or byte positions.
50 typedef struct {
51 unsigned summed_area_start; /* first checksummed location */
52 unsigned summed_area_end; /* last checksummed location */
53 unsigned checksum_at; /* location of checksum */
54 } cmos_checksum_layout_t;
56 extern const char checksum_param_name[];
58 extern unsigned cmos_checksum_start;
60 extern unsigned cmos_checksum_end;
62 extern unsigned cmos_checksum_index;
64 typedef void (*cmos_layout_get_fn_t) (void);
66 void register_cmos_layout_get_fn(cmos_layout_get_fn_t fn);
67 void get_cmos_layout(void);
68 int add_cmos_entry(const cmos_entry_t * e, const cmos_entry_t ** conflict);
69 const cmos_entry_t *find_cmos_entry(const char name[]);
70 const cmos_entry_t *first_cmos_entry(void);
71 const cmos_entry_t *next_cmos_entry(const cmos_entry_t * last);
72 int add_cmos_enum(const cmos_enum_t * e);
73 const cmos_enum_t *find_cmos_enum(unsigned config_id, unsigned long long value);
74 const cmos_enum_t *first_cmos_enum(void);
75 const cmos_enum_t *next_cmos_enum(const cmos_enum_t * last);
76 const cmos_enum_t *first_cmos_enum_id(unsigned config_id);
77 const cmos_enum_t *next_cmos_enum_id(const cmos_enum_t * last);
78 int is_checksum_name(const char name[]);
79 int checksum_layout_to_bytes(cmos_checksum_layout_t * layout);
80 void checksum_layout_to_bits(cmos_checksum_layout_t * layout);
82 #endif /* LAYOUT_H */