blob: 02652e0d8e897b7d83a82287efb527b3e5839b4d [file] [log] [blame]
Patrick Georgi55189c92020-05-10 20:09:31 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer6540ae52007-07-12 16:35:42 +00002
Uwe Hermann6e565942008-03-01 19:06:32 +00003#ifndef LAYOUT_H
4#define LAYOUT_H
Stefan Reinauer6540ae52007-07-12 16:35:42 +00005
6#include "common.h"
Stefan Reinauer7223ab72008-01-18 16:17:44 +00007#include "coreboot_tables.h"
Stefan Reinauer6540ae52007-07-12 16:35:42 +00008
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)
Nico Huber3af69852017-01-26 23:22:46 +010019#define LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED (LAYOUT_RESULT_START + 10)
Stefan Reinauer6540ae52007-07-12 16:35:42 +000020
Stefan Reinauer90b96b62010-01-13 21:00:23 +000021typedef enum {
Vikram Narayanana8111cf2012-04-14 15:25:13 +053022 CMOS_ENTRY_ENUM = 'e',
23 CMOS_ENTRY_HEX = 'h',
24 CMOS_ENTRY_STRING = 's',
25 CMOS_ENTRY_RESERVED = 'r',
Stefan Reinauer90b96b62010-01-13 21:00:23 +000026} cmos_entry_config_t;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000027
28/* This represents a CMOS parameter. */
Stefan Reinauer90b96b62010-01-13 21:00:23 +000029typedef 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;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000036
37/* This represents a possible value for a CMOS parameter of type
38 * CMOS_ENTRY_ENUM.
39 */
Stefan Reinauer90b96b62010-01-13 21:00:23 +000040typedef struct {
41 unsigned config_id;
42 unsigned long long value;
43 char text[CMOS_MAX_TEXT_LENGTH + 1];
44} cmos_enum_t;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000045
Stefan Reinauer90b96b62010-01-13 21:00:23 +000046/* 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.
Stefan Reinauer6540ae52007-07-12 16:35:42 +000049 */
Stefan Reinauer90b96b62010-01-13 21:00:23 +000050typedef 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;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000055
56extern const char checksum_param_name[];
57
58extern unsigned cmos_checksum_start;
59
60extern unsigned cmos_checksum_end;
61
62extern unsigned cmos_checksum_index;
63
64typedef void (*cmos_layout_get_fn_t) (void);
65
Stefan Reinauer90b96b62010-01-13 21:00:23 +000066void register_cmos_layout_get_fn(cmos_layout_get_fn_t fn);
67void get_cmos_layout(void);
68int add_cmos_entry(const cmos_entry_t * e, const cmos_entry_t ** conflict);
69const cmos_entry_t *find_cmos_entry(const char name[]);
70const cmos_entry_t *first_cmos_entry(void);
71const cmos_entry_t *next_cmos_entry(const cmos_entry_t * last);
72int add_cmos_enum(const cmos_enum_t * e);
73const cmos_enum_t *find_cmos_enum(unsigned config_id, unsigned long long value);
74const cmos_enum_t *first_cmos_enum(void);
75const cmos_enum_t *next_cmos_enum(const cmos_enum_t * last);
76const cmos_enum_t *first_cmos_enum_id(unsigned config_id);
77const cmos_enum_t *next_cmos_enum_id(const cmos_enum_t * last);
78int is_checksum_name(const char name[]);
79int checksum_layout_to_bytes(cmos_checksum_layout_t * layout);
80void checksum_layout_to_bits(cmos_checksum_layout_t * layout);
Stefan Reinauer6540ae52007-07-12 16:35:42 +000081
Stefan Reinauer90b96b62010-01-13 21:00:23 +000082#endif /* LAYOUT_H */