Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 1 | /*****************************************************************************\ |
| 2 | * layout.h |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 3 | ***************************************************************************** |
| 4 | * Copyright (C) 2002-2005 The Regents of the University of California. |
| 5 | * Produced at the Lawrence Livermore National Laboratory. |
| 6 | * Written by Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>. |
| 7 | * UCRL-CODE-2003-012 |
| 8 | * All rights reserved. |
| 9 | * |
Uwe Hermann | 6e56594 | 2008-03-01 19:06:32 +0000 | [diff] [blame] | 10 | * This file is part of nvramtool, a utility for reading/writing coreboot |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 11 | * parameters and displaying information from the coreboot table. |
Uwe Hermann | 6e56594 | 2008-03-01 19:06:32 +0000 | [diff] [blame] | 12 | * For details, see http://coreboot.org/nvramtool. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 13 | * |
| 14 | * Please also read the file DISCLAIMER which is included in this software |
| 15 | * distribution. |
| 16 | * |
| 17 | * This program is free software; you can redistribute it and/or modify it |
| 18 | * under the terms of the GNU General Public License (as published by the |
| 19 | * Free Software Foundation) version 2, dated June 1991. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, but |
| 22 | * WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and |
| 24 | * conditions of the GNU General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU General Public License along |
| 27 | * with this program; if not, write to the Free Software Foundation, Inc., |
Stefan Reinauer | ac7a2d2 | 2009-09-23 21:53:25 +0000 | [diff] [blame] | 28 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 29 | \*****************************************************************************/ |
| 30 | |
Uwe Hermann | 6e56594 | 2008-03-01 19:06:32 +0000 | [diff] [blame] | 31 | #ifndef LAYOUT_H |
| 32 | #define LAYOUT_H |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 33 | |
| 34 | #include "common.h" |
Stefan Reinauer | 7223ab7 | 2008-01-18 16:17:44 +0000 | [diff] [blame] | 35 | #include "coreboot_tables.h" |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 36 | |
| 37 | #define LAYOUT_ENTRY_OVERLAP (LAYOUT_RESULT_START + 0) |
| 38 | #define LAYOUT_ENTRY_BAD_LENGTH (LAYOUT_RESULT_START + 1) |
| 39 | #define LAYOUT_DUPLICATE_ENUM (LAYOUT_RESULT_START + 2) |
| 40 | #define LAYOUT_SUMMED_AREA_START_NOT_ALIGNED (LAYOUT_RESULT_START + 3) |
| 41 | #define LAYOUT_SUMMED_AREA_END_NOT_ALIGNED (LAYOUT_RESULT_START + 4) |
| 42 | #define LAYOUT_CHECKSUM_LOCATION_NOT_ALIGNED (LAYOUT_RESULT_START + 5) |
| 43 | #define LAYOUT_INVALID_SUMMED_AREA (LAYOUT_RESULT_START + 6) |
| 44 | #define LAYOUT_CHECKSUM_OVERLAPS_SUMMED_AREA (LAYOUT_RESULT_START + 7) |
| 45 | #define LAYOUT_SUMMED_AREA_OUT_OF_RANGE (LAYOUT_RESULT_START + 8) |
| 46 | #define LAYOUT_CHECKSUM_LOCATION_OUT_OF_RANGE (LAYOUT_RESULT_START + 9) |
| 47 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 48 | typedef enum { |
Vikram Narayanan | a8111cf | 2012-04-14 15:25:13 +0530 | [diff] [blame^] | 49 | CMOS_ENTRY_ENUM = 'e', |
| 50 | CMOS_ENTRY_HEX = 'h', |
| 51 | CMOS_ENTRY_STRING = 's', |
| 52 | CMOS_ENTRY_RESERVED = 'r', |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 53 | } cmos_entry_config_t; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 54 | |
| 55 | /* This represents a CMOS parameter. */ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 56 | typedef struct { |
| 57 | unsigned bit; |
| 58 | unsigned length; |
| 59 | cmos_entry_config_t config; |
| 60 | unsigned config_id; |
| 61 | char name[CMOS_MAX_NAME_LENGTH + 1]; |
| 62 | } cmos_entry_t; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 63 | |
| 64 | /* This represents a possible value for a CMOS parameter of type |
| 65 | * CMOS_ENTRY_ENUM. |
| 66 | */ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 67 | typedef struct { |
| 68 | unsigned config_id; |
| 69 | unsigned long long value; |
| 70 | char text[CMOS_MAX_TEXT_LENGTH + 1]; |
| 71 | } cmos_enum_t; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 72 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 73 | /* This represents the location of the CMOS checksum and the area over |
| 74 | * which it is computed. Depending on the context, the values may be |
| 75 | * represented as either bit positions or byte positions. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 76 | */ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 77 | typedef struct { |
| 78 | unsigned summed_area_start; /* first checksummed location */ |
| 79 | unsigned summed_area_end; /* last checksummed location */ |
| 80 | unsigned checksum_at; /* location of checksum */ |
| 81 | } cmos_checksum_layout_t; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 82 | |
| 83 | extern const char checksum_param_name[]; |
| 84 | |
| 85 | extern unsigned cmos_checksum_start; |
| 86 | |
| 87 | extern unsigned cmos_checksum_end; |
| 88 | |
| 89 | extern unsigned cmos_checksum_index; |
| 90 | |
| 91 | typedef void (*cmos_layout_get_fn_t) (void); |
| 92 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 93 | void register_cmos_layout_get_fn(cmos_layout_get_fn_t fn); |
| 94 | void get_cmos_layout(void); |
| 95 | int add_cmos_entry(const cmos_entry_t * e, const cmos_entry_t ** conflict); |
| 96 | const cmos_entry_t *find_cmos_entry(const char name[]); |
| 97 | const cmos_entry_t *first_cmos_entry(void); |
| 98 | const cmos_entry_t *next_cmos_entry(const cmos_entry_t * last); |
| 99 | int add_cmos_enum(const cmos_enum_t * e); |
| 100 | const cmos_enum_t *find_cmos_enum(unsigned config_id, unsigned long long value); |
| 101 | const cmos_enum_t *first_cmos_enum(void); |
| 102 | const cmos_enum_t *next_cmos_enum(const cmos_enum_t * last); |
| 103 | const cmos_enum_t *first_cmos_enum_id(unsigned config_id); |
| 104 | const cmos_enum_t *next_cmos_enum_id(const cmos_enum_t * last); |
| 105 | int is_checksum_name(const char name[]); |
| 106 | int checksum_layout_to_bytes(cmos_checksum_layout_t * layout); |
| 107 | void checksum_layout_to_bits(cmos_checksum_layout_t * layout); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 108 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 109 | #endif /* LAYOUT_H */ |