Patrick Georgi | 55189c9 | 2020-05-10 20:09:31 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 2 | |
Uwe Hermann | 6e56594 | 2008-03-01 19:06:32 +0000 | [diff] [blame] | 3 | #ifndef LAYOUT_H |
| 4 | #define LAYOUT_H |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 5 | |
| 6 | #include "common.h" |
Stefan Reinauer | 7223ab7 | 2008-01-18 16:17:44 +0000 | [diff] [blame] | 7 | #include "coreboot_tables.h" |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 8 | |
| 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 Huber | 3af6985 | 2017-01-26 23:22:46 +0100 | [diff] [blame] | 19 | #define LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED (LAYOUT_RESULT_START + 10) |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 20 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 21 | typedef enum { |
Vikram Narayanan | a8111cf | 2012-04-14 15:25:13 +0530 | [diff] [blame] | 22 | CMOS_ENTRY_ENUM = 'e', |
| 23 | CMOS_ENTRY_HEX = 'h', |
| 24 | CMOS_ENTRY_STRING = 's', |
| 25 | CMOS_ENTRY_RESERVED = 'r', |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 26 | } cmos_entry_config_t; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 27 | |
| 28 | /* This represents a CMOS parameter. */ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 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; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 36 | |
| 37 | /* This represents a possible value for a CMOS parameter of type |
| 38 | * CMOS_ENTRY_ENUM. |
| 39 | */ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 40 | typedef struct { |
| 41 | unsigned config_id; |
| 42 | unsigned long long value; |
| 43 | char text[CMOS_MAX_TEXT_LENGTH + 1]; |
| 44 | } cmos_enum_t; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 45 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 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. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 49 | */ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 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; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 55 | |
| 56 | extern const char checksum_param_name[]; |
| 57 | |
| 58 | extern unsigned cmos_checksum_start; |
| 59 | |
| 60 | extern unsigned cmos_checksum_end; |
| 61 | |
| 62 | extern unsigned cmos_checksum_index; |
| 63 | |
| 64 | typedef void (*cmos_layout_get_fn_t) (void); |
| 65 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 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); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 81 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 82 | #endif /* LAYOUT_H */ |