Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 1 | /*****************************************************************************\ |
| 2 | * lbtable.c |
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 | * and Stefan Reinauer <stepan@openbios.org>. |
| 8 | * UCRL-CODE-2003-012 |
| 9 | * All rights reserved. |
| 10 | * |
Uwe Hermann | 6e56594 | 2008-03-01 19:06:32 +0000 | [diff] [blame] | 11 | * This file is part of nvramtool, a utility for reading/writing coreboot |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 12 | * parameters and displaying information from the coreboot table. |
Uwe Hermann | 6e56594 | 2008-03-01 19:06:32 +0000 | [diff] [blame] | 13 | * For details, see http://coreboot.org/nvramtool. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 14 | * |
| 15 | * Please also read the file DISCLAIMER which is included in this software |
| 16 | * distribution. |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or modify it |
| 19 | * under the terms of the GNU General Public License (as published by the |
| 20 | * Free Software Foundation) version 2, dated June 1991. |
| 21 | * |
| 22 | * This program is distributed in the hope that it will be useful, but |
| 23 | * WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF |
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and |
| 25 | * conditions of the GNU General Public License for more details. |
| 26 | * |
| 27 | * You should have received a copy of the GNU General Public License along |
| 28 | * with this program; if not, write to the Free Software Foundation, Inc., |
Stefan Reinauer | ac7a2d2 | 2009-09-23 21:53:25 +0000 | [diff] [blame] | 29 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 30 | \*****************************************************************************/ |
| 31 | |
Stefan Reinauer | 9981cad | 2012-05-24 13:36:30 -0700 | [diff] [blame] | 32 | #include <stdint.h> |
| 33 | #include <inttypes.h> |
Stefan Reinauer | 297b91c | 2008-09-18 14:49:33 +0000 | [diff] [blame] | 34 | #include <string.h> |
Zheng Bao | 5451672 | 2012-10-22 16:41:42 +0800 | [diff] [blame] | 35 | #ifndef __MINGW32__ |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 36 | #include <sys/mman.h> |
Zheng Bao | 5451672 | 2012-10-22 16:41:42 +0800 | [diff] [blame] | 37 | #endif |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 38 | #include "common.h" |
Stefan Reinauer | 7223ab7 | 2008-01-18 16:17:44 +0000 | [diff] [blame] | 39 | #include "coreboot_tables.h" |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 40 | #include "ip_checksum.h" |
| 41 | #include "lbtable.h" |
| 42 | #include "layout.h" |
| 43 | #include "cmos_lowlevel.h" |
| 44 | #include "hexdump.h" |
Patrick Georgi | 269e932 | 2011-01-21 07:24:08 +0000 | [diff] [blame] | 45 | #include "cbfs.h" |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 46 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 47 | typedef void (*lbtable_print_fn_t) (const struct lb_record * rec); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 48 | |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 49 | /* This structure represents an item in the coreboot table that may be |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 50 | * displayed using the -l option. |
| 51 | */ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 52 | typedef struct { |
| 53 | uint32_t tag; |
| 54 | const char *name; |
| 55 | const char *description; |
| 56 | const char *nofound_msg; |
| 57 | lbtable_print_fn_t print_fn; |
| 58 | } lbtable_choice_t; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 59 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 60 | typedef struct { |
| 61 | unsigned long start; /* address of first byte of memory range */ |
| 62 | unsigned long end; /* address of last byte of memory range */ |
| 63 | } mem_range_t; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 64 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 65 | static const struct lb_header *lbtable_scan(unsigned long start, |
| 66 | unsigned long end, |
| 67 | int *bad_header_count, |
| 68 | int *bad_table_count); |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 69 | static const char *lbrec_tag_to_str(uint32_t tag); |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 70 | static void memory_print_fn(const struct lb_record *rec); |
| 71 | static void mainboard_print_fn(const struct lb_record *rec); |
| 72 | static void cmos_opt_table_print_fn(const struct lb_record *rec); |
| 73 | static void print_option_record(const struct cmos_entries *cmos_entry); |
| 74 | static void print_enum_record(const struct cmos_enums *cmos_enum); |
| 75 | static void print_defaults_record(const struct cmos_defaults *cmos_defaults); |
| 76 | static void print_unknown_record(const struct lb_record *cmos_item); |
| 77 | static void option_checksum_print_fn(const struct lb_record *rec); |
| 78 | static void string_print_fn(const struct lb_record *rec); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 79 | |
| 80 | static const char memory_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 81 | " This shows information about system memory.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 82 | |
| 83 | static const char mainboard_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 84 | " This shows information about your mainboard.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 85 | |
| 86 | static const char version_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 87 | " This shows coreboot version information.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 88 | |
| 89 | static const char extra_version_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 90 | " This shows extra coreboot version information.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 91 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 92 | static const char build_desc[] = " This shows coreboot build information.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 93 | |
| 94 | static const char compile_time_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 95 | " This shows when coreboot was compiled.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 96 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 97 | static const char compile_by_desc[] = " This shows who compiled coreboot.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 98 | |
| 99 | static const char compile_host_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 100 | " This shows the name of the machine that compiled coreboot.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 101 | |
| 102 | static const char compile_domain_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 103 | " This shows the domain name of the machine that compiled coreboot.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 104 | |
| 105 | static const char compiler_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 106 | " This shows the name of the compiler used to build coreboot.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 107 | |
| 108 | static const char linker_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 109 | " This shows the name of the linker used to build coreboot.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 110 | |
| 111 | static const char assembler_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 112 | " This shows the name of the assembler used to build coreboot.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 113 | |
| 114 | static const char cmos_opt_table_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 115 | " This does a low-level dump of the CMOS option table. The table " |
| 116 | "contains\n" |
| 117 | " information about the layout of the values that coreboot stores in\n" |
| 118 | " nonvolatile RAM.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 119 | |
| 120 | static const char option_checksum_desc[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 121 | " This shows the location of the CMOS checksum and the area over which it " |
| 122 | "is\n" " calculated.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 123 | |
| 124 | static const char generic_nofound_msg[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 125 | "%s: Item %s not found in coreboot table.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 126 | |
| 127 | static const char nofound_msg_cmos_opt_table[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 128 | "%s: Item %s not found in coreboot table. Apparently, the " |
| 129 | "coreboot installed on this system was built without specifying " |
| 130 | "CONFIG_HAVE_OPTION_TABLE.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 131 | |
| 132 | static const char nofound_msg_option_checksum[] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 133 | "%s: Item %s not found in coreboot table. Apparently, you are " |
| 134 | "using coreboot v1.\n"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 135 | |
Stefan Reinauer | 764fe40 | 2009-03-17 14:39:36 +0000 | [diff] [blame] | 136 | int fd; |
| 137 | |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 138 | /* This is the number of items from the coreboot table that may be displayed |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 139 | * using the -l option. |
| 140 | */ |
| 141 | #define NUM_LBTABLE_CHOICES 14 |
| 142 | |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 143 | /* These represent the various items from the coreboot table that may be |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 144 | * displayed using the -l option. |
| 145 | */ |
| 146 | static const lbtable_choice_t lbtable_choices[NUM_LBTABLE_CHOICES] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 147 | { {LB_TAG_MEMORY, "memory", |
| 148 | memory_desc, generic_nofound_msg, |
| 149 | memory_print_fn}, |
| 150 | {LB_TAG_MAINBOARD, "mainboard", |
| 151 | mainboard_desc, generic_nofound_msg, |
| 152 | mainboard_print_fn}, |
| 153 | {LB_TAG_VERSION, "version", |
| 154 | version_desc, generic_nofound_msg, |
| 155 | string_print_fn}, |
| 156 | {LB_TAG_EXTRA_VERSION, "extra_version", |
| 157 | extra_version_desc, generic_nofound_msg, |
| 158 | string_print_fn}, |
| 159 | {LB_TAG_BUILD, "build", |
| 160 | build_desc, generic_nofound_msg, |
| 161 | string_print_fn}, |
| 162 | {LB_TAG_COMPILE_TIME, "compile_time", |
| 163 | compile_time_desc, generic_nofound_msg, |
| 164 | string_print_fn}, |
| 165 | {LB_TAG_COMPILE_BY, "compile_by", |
| 166 | compile_by_desc, generic_nofound_msg, |
| 167 | string_print_fn}, |
| 168 | {LB_TAG_COMPILE_HOST, "compile_host", |
| 169 | compile_host_desc, generic_nofound_msg, |
| 170 | string_print_fn}, |
| 171 | {LB_TAG_COMPILE_DOMAIN, "compile_domain", |
| 172 | compile_domain_desc, generic_nofound_msg, |
| 173 | string_print_fn}, |
| 174 | {LB_TAG_COMPILER, "compiler", |
| 175 | compiler_desc, generic_nofound_msg, |
| 176 | string_print_fn}, |
| 177 | {LB_TAG_LINKER, "linker", |
| 178 | linker_desc, generic_nofound_msg, |
| 179 | string_print_fn}, |
| 180 | {LB_TAG_ASSEMBLER, "assembler", |
| 181 | assembler_desc, generic_nofound_msg, |
| 182 | string_print_fn}, |
| 183 | {LB_TAG_CMOS_OPTION_TABLE, "cmos_opt_table", |
| 184 | cmos_opt_table_desc, nofound_msg_cmos_opt_table, |
| 185 | cmos_opt_table_print_fn}, |
| 186 | {LB_TAG_OPTION_CHECKSUM, "option_checksum", |
| 187 | option_checksum_desc, nofound_msg_option_checksum, |
| 188 | option_checksum_print_fn} |
| 189 | }; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 190 | |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 191 | /* The coreboot table resides in low physical memory, which we access using |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 192 | * /dev/mem. These are ranges of physical memory that should be scanned for a |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 193 | * coreboot table. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 194 | */ |
| 195 | |
| 196 | #define NUM_MEM_RANGES 2 |
| 197 | |
| 198 | static const mem_range_t mem_ranges[NUM_MEM_RANGES] = |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 199 | { {0x00000000, 0x00000fff}, |
| 200 | {0x000f0000, 0x000fffff} |
| 201 | }; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 202 | |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 203 | /* Pointer to low physical memory that we access by calling mmap() on |
| 204 | * /dev/mem. |
| 205 | */ |
| 206 | static const void *low_phys_mem; |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 207 | /* impossible value since not page aligned: first map request will happen */ |
| 208 | static unsigned long low_phys_base = 0x1; |
| 209 | |
| 210 | /* count of mapped pages */ |
| 211 | static unsigned long mapped_pages = 0; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 212 | |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 213 | /* Pointer to coreboot table. */ |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 214 | static const struct lb_header *lbtable = NULL; |
| 215 | |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 216 | static const hexdump_format_t format = |
Patrick Georgi | 024ec85 | 2011-01-18 12:14:08 +0000 | [diff] [blame] | 217 | { 12, 4, " ", " | ", " ", " | ", '.' }; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 218 | |
| 219 | /**************************************************************************** |
| 220 | * vtophys |
| 221 | * |
| 222 | * Convert a virtual address to a physical address. 'vaddr' is a virtual |
| 223 | * address in the address space of the current process. It points to |
| 224 | * somewhere in the chunk of memory that we mapped by calling mmap() on |
| 225 | * /dev/mem. This macro converts 'vaddr' to a physical address. |
| 226 | ****************************************************************************/ |
| 227 | #define vtophys(vaddr) (((unsigned long) vaddr) - \ |
Stefan Reinauer | 764fe40 | 2009-03-17 14:39:36 +0000 | [diff] [blame] | 228 | ((unsigned long) low_phys_mem) + low_phys_base) |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 229 | |
| 230 | /**************************************************************************** |
| 231 | * phystov |
| 232 | * |
| 233 | * Convert a physical address to a virtual address. 'paddr' is a physical |
| 234 | * address. This macro converts 'paddr' to a virtual address in the address |
| 235 | * space of the current process. The virtual to physical mapping was set up |
| 236 | * by calling mmap() on /dev/mem. |
| 237 | ****************************************************************************/ |
| 238 | #define phystov(paddr) (((unsigned long) low_phys_mem) + \ |
Stefan Reinauer | 764fe40 | 2009-03-17 14:39:36 +0000 | [diff] [blame] | 239 | ((unsigned long) paddr) - low_phys_base) |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 240 | |
| 241 | /**************************************************************************** |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 242 | * map_pages |
| 243 | * |
| 244 | * Maps just enough pages to cover base_address + length |
| 245 | * and updates affected variables |
| 246 | ****************************************************************************/ |
| 247 | static void map_pages(unsigned long base_address, unsigned long length) |
| 248 | { |
| 249 | unsigned long num_pages = (length + |
| 250 | (base_address & (getpagesize() - 1)) + |
| 251 | getpagesize() - 1) >> 12; |
| 252 | base_address &= ~(getpagesize() - 1); |
| 253 | |
| 254 | /* no need to do anything */ |
| 255 | if ((low_phys_base == base_address) && (mapped_pages == num_pages)) { |
| 256 | return; |
| 257 | } |
| 258 | |
| 259 | if (low_phys_mem) { |
| 260 | munmap((void *)low_phys_mem, mapped_pages << 12); |
| 261 | } |
| 262 | if ((low_phys_mem = mmap(NULL, num_pages << 12, PROT_READ, MAP_SHARED, fd, |
| 263 | (off_t) base_address)) == MAP_FAILED) { |
| 264 | fprintf(stderr, |
| 265 | "%s: Failed to mmap /dev/mem at %lx: %s\n", |
| 266 | prog_name, base_address, strerror(errno)); |
| 267 | exit(1); |
| 268 | } |
| 269 | low_phys_base = base_address; |
| 270 | } |
| 271 | |
| 272 | /**************************************************************************** |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 273 | * get_lbtable |
| 274 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 275 | * Find the coreboot table and set global variable lbtable to point to it. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 276 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 277 | void get_lbtable(void) |
| 278 | { |
| 279 | int i, bad_header_count, bad_table_count, bad_headers, bad_tables; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 280 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 281 | if (lbtable != NULL) |
| 282 | return; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 283 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 284 | /* The coreboot table is located in low physical memory, which may be |
| 285 | * conveniently accessed by calling mmap() on /dev/mem. |
| 286 | */ |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 287 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 288 | if ((fd = open("/dev/mem", O_RDONLY, 0)) < 0) { |
| 289 | fprintf(stderr, "%s: Can not open /dev/mem for reading: %s\n", |
| 290 | prog_name, strerror(errno)); |
| 291 | exit(1); |
| 292 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 293 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 294 | bad_header_count = 0; |
| 295 | bad_table_count = 0; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 296 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 297 | for (i = 0; i < NUM_MEM_RANGES; i++) { |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 298 | lbtable = lbtable_scan(mem_ranges[i].start, mem_ranges[i].end, |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 299 | &bad_headers, &bad_tables); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 300 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 301 | if (lbtable != NULL) |
| 302 | return; /* success: we found it! */ |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 303 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 304 | bad_header_count += bad_headers; |
| 305 | bad_table_count += bad_tables; |
| 306 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 307 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 308 | fprintf(stderr, |
| 309 | "%s: coreboot table not found. coreboot does not appear to\n" |
| 310 | " be installed on this system. Scanning for the table " |
| 311 | "produced the\n" |
| 312 | " following results:\n\n" |
| 313 | " %d valid signatures were found with bad header " |
| 314 | "checksums.\n" |
| 315 | " %d valid headers were found with bad table " |
| 316 | "checksums.\n", prog_name, bad_header_count, bad_table_count); |
| 317 | exit(1); |
| 318 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 319 | |
| 320 | /**************************************************************************** |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 321 | * dump_lbtable |
| 322 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 323 | * Do a low-level dump of the coreboot table. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 324 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 325 | void dump_lbtable(void) |
| 326 | { |
| 327 | const char *p, *data; |
| 328 | uint32_t bytes_processed; |
| 329 | const struct lb_record *lbrec; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 330 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 331 | p = ((const char *)lbtable) + lbtable->header_bytes; |
| 332 | printf("Coreboot table at physical address 0x%lx:\n" |
| 333 | " signature: 0x%x (ASCII: %c%c%c%c)\n" |
| 334 | " header_bytes: 0x%x (decimal: %d)\n" |
| 335 | " header_checksum: 0x%x (decimal: %d)\n" |
| 336 | " table_bytes: 0x%x (decimal: %d)\n" |
| 337 | " table_checksum: 0x%x (decimal: %d)\n" |
| 338 | " table_entries: 0x%x (decimal: %d)\n\n", |
Patrick Georgi | 2601697 | 2011-01-18 12:12:47 +0000 | [diff] [blame] | 339 | vtophys(lbtable), lbtable->signature32, |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 340 | lbtable->signature[0], lbtable->signature[1], |
| 341 | lbtable->signature[2], lbtable->signature[3], |
| 342 | lbtable->header_bytes, lbtable->header_bytes, |
| 343 | lbtable->header_checksum, lbtable->header_checksum, |
| 344 | lbtable->table_bytes, lbtable->table_bytes, |
| 345 | lbtable->table_checksum, lbtable->table_checksum, |
| 346 | lbtable->table_entries, lbtable->table_entries); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 347 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 348 | if ((lbtable->table_bytes == 0) != (lbtable->table_entries == 0)) { |
| 349 | printf |
| 350 | ("Inconsistent values for table_bytes and table_entries!!!\n" |
| 351 | "They should be either both 0 or both nonzero.\n"); |
| 352 | return; |
| 353 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 354 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 355 | if (lbtable->table_bytes == 0) { |
| 356 | printf("The coreboot table is empty!!!\n"); |
| 357 | return; |
| 358 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 359 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 360 | for (bytes_processed = 0;;) { |
| 361 | lbrec = (const struct lb_record *)&p[bytes_processed]; |
| 362 | printf(" %s record at physical address 0x%lx:\n" |
| 363 | " tag: 0x%x (decimal: %d)\n" |
| 364 | " size: 0x%x (decimal: %d)\n" |
| 365 | " data:\n", |
| 366 | lbrec_tag_to_str(lbrec->tag), vtophys(lbrec), lbrec->tag, |
| 367 | lbrec->tag, lbrec->size, lbrec->size); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 368 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 369 | data = ((const char *)lbrec) + sizeof(*lbrec); |
| 370 | hexdump(data, lbrec->size - sizeof(*lbrec), vtophys(data), |
| 371 | stdout, &format); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 372 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 373 | bytes_processed += lbrec->size; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 374 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 375 | if (bytes_processed >= lbtable->table_bytes) |
| 376 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 377 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 378 | printf("\n"); |
| 379 | } |
| 380 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 381 | |
| 382 | /**************************************************************************** |
| 383 | * list_lbtable_choices |
| 384 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 385 | * List names and informational blurbs for items from the coreboot table |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 386 | * that may be displayed using the -l option. |
| 387 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 388 | void list_lbtable_choices(void) |
| 389 | { |
| 390 | int i; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 391 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 392 | for (i = 0;;) { |
| 393 | printf("%s:\n%s", |
| 394 | lbtable_choices[i].name, lbtable_choices[i].description); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 395 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 396 | if (++i >= NUM_LBTABLE_CHOICES) |
| 397 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 398 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 399 | printf("\n"); |
| 400 | } |
| 401 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 402 | |
| 403 | /**************************************************************************** |
| 404 | * list_lbtable_item |
| 405 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 406 | * Show the coreboot table item specified by 'item'. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 407 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 408 | void list_lbtable_item(const char item[]) |
| 409 | { |
| 410 | int i; |
| 411 | const struct lb_record *rec; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 412 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 413 | for (i = 0; i < NUM_LBTABLE_CHOICES; i++) { |
| 414 | if (strcmp(item, lbtable_choices[i].name) == 0) |
| 415 | break; |
| 416 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 417 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 418 | if (i == NUM_LBTABLE_CHOICES) { |
| 419 | fprintf(stderr, "%s: Invalid coreboot table item %s.\n", |
| 420 | prog_name, item); |
| 421 | exit(1); |
| 422 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 423 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 424 | if ((rec = find_lbrec(lbtable_choices[i].tag)) == NULL) { |
| 425 | fprintf(stderr, lbtable_choices[i].nofound_msg, prog_name, |
| 426 | lbtable_choices[i].name); |
| 427 | exit(1); |
| 428 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 429 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 430 | lbtable_choices[i].print_fn(rec); |
| 431 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 432 | |
| 433 | /**************************************************************************** |
| 434 | * lbtable_scan |
| 435 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 436 | * Scan the chunk of memory specified by 'start' and 'end' for a coreboot |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 437 | * table. The first 4 bytes of the table are marked by the signature |
| 438 | * { 'L', 'B', 'I', 'O' }. 'start' and 'end' indicate the addresses of the |
| 439 | * first and last bytes of the chunk of memory to be scanned. For instance, |
| 440 | * values of 0x10000000 and 0x1000ffff for 'start' and 'end' specify a 64k |
| 441 | * chunk of memory starting at address 0x10000000. 'start' and 'end' are |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 442 | * physical addresses. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 443 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 444 | * If a coreboot table is found, return a pointer to it. Otherwise return |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 445 | * NULL. On return, *bad_header_count and *bad_table_count are set as |
| 446 | * follows: |
| 447 | * |
| 448 | * *bad_header_count: |
| 449 | * Indicates the number of times in which a valid signature was found |
| 450 | * but the header checksum was invalid. |
| 451 | * |
| 452 | * *bad_table_count: |
| 453 | * Indicates the number of times in which a header with a valid |
| 454 | * checksum was found but the table checksum was invalid. |
| 455 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 456 | static const struct lb_header *lbtable_scan(unsigned long start, |
| 457 | unsigned long end, |
| 458 | int *bad_header_count, |
| 459 | int *bad_table_count) |
| 460 | { |
Patrick Georgi | 2601697 | 2011-01-18 12:12:47 +0000 | [diff] [blame] | 461 | static const char signature[4] = { 'L', 'B', 'I', 'O' }; |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 462 | const struct lb_header *table; |
| 463 | const struct lb_forward *forward; |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 464 | unsigned long p; |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 465 | uint32_t sig; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 466 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 467 | assert(end >= start); |
Patrick Georgi | 2601697 | 2011-01-18 12:12:47 +0000 | [diff] [blame] | 468 | memcpy(&sig, signature, sizeof(sig)); |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 469 | table = NULL; |
| 470 | *bad_header_count = 0; |
| 471 | *bad_table_count = 0; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 472 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 473 | /* Look for signature. Table is aligned on 16-byte boundary. Therefore |
| 474 | * only check every fourth 32-bit memory word. As the loop is coded below, |
| 475 | * this function will behave in a reasonable manner for ALL possible values |
| 476 | * for 'start' and 'end': even weird boundary cases like 0x00000000 and |
| 477 | * 0xffffffff on a 32-bit architecture. |
| 478 | */ |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 479 | map_pages(start, end - start); |
| 480 | for (p = start; |
| 481 | (p <= end) && |
| 482 | (end - p >= (sizeof(uint32_t) - 1)); p += 4) { |
| 483 | if (*(uint32_t*)phystov(p) != sig) |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 484 | continue; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 485 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 486 | /* We found a valid signature. */ |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 487 | table = (const struct lb_header *)phystov(p); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 488 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 489 | /* validate header checksum */ |
| 490 | if (compute_ip_checksum((void *)table, sizeof(*table))) { |
| 491 | (*bad_header_count)++; |
| 492 | continue; |
| 493 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 494 | |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 495 | map_pages(p, table->table_bytes + sizeof(*table)); |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 496 | /* validate table checksum */ |
| 497 | if (table->table_checksum != |
| 498 | compute_ip_checksum(((char *)table) + sizeof(*table), |
| 499 | table->table_bytes)) { |
| 500 | (*bad_table_count)++; |
| 501 | continue; |
| 502 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 503 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 504 | /* checksums are ok: we found it! */ |
| 505 | /* But it may just be a forwarding table, so look if there's a forwarder */ |
| 506 | lbtable = table; |
| 507 | forward = (struct lb_forward *)find_lbrec(LB_TAG_FORWARD); |
| 508 | lbtable = NULL; |
Stefan Reinauer | 764fe40 | 2009-03-17 14:39:36 +0000 | [diff] [blame] | 509 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 510 | if (forward) { |
| 511 | uint64_t new_phys = forward->forward; |
Patrick Georgi | 1278142 | 2013-02-21 14:03:47 +0100 | [diff] [blame] | 512 | table = lbtable_scan(new_phys, new_phys + getpagesize(), |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 513 | bad_header_count, bad_table_count); |
| 514 | } |
| 515 | return table; |
| 516 | } |
| 517 | |
| 518 | return NULL; |
| 519 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 520 | |
| 521 | /**************************************************************************** |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 522 | * find_lbrec |
| 523 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 524 | * Find the record in the coreboot table that matches 'tag'. Return pointer |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 525 | * to record on success or NULL if record not found. |
| 526 | ****************************************************************************/ |
Mathias Krause | 155c379 | 2011-03-10 07:52:02 +0000 | [diff] [blame] | 527 | const struct lb_record *find_lbrec(uint32_t tag) |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 528 | { |
| 529 | const char *p; |
| 530 | uint32_t bytes_processed; |
| 531 | const struct lb_record *lbrec; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 532 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 533 | p = ((const char *)lbtable) + lbtable->header_bytes; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 534 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 535 | for (bytes_processed = 0; |
| 536 | bytes_processed < lbtable->table_bytes; |
| 537 | bytes_processed += lbrec->size) { |
| 538 | lbrec = (const struct lb_record *)&p[bytes_processed]; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 539 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 540 | if (lbrec->tag == tag) |
| 541 | return lbrec; |
| 542 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 543 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 544 | return NULL; |
| 545 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 546 | |
| 547 | /**************************************************************************** |
| 548 | * lbrec_tag_to_str |
| 549 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 550 | * Return a pointer to the string representation of the given coreboot table |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 551 | * tag. |
| 552 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 553 | static const char *lbrec_tag_to_str(uint32_t tag) |
| 554 | { |
| 555 | switch (tag) { |
| 556 | case LB_TAG_UNUSED: |
| 557 | return "UNUSED"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 558 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 559 | case LB_TAG_MEMORY: |
| 560 | return "MEMORY"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 561 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 562 | case LB_TAG_HWRPB: |
| 563 | return "HWRPB"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 564 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 565 | case LB_TAG_MAINBOARD: |
| 566 | return "MAINBOARD"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 567 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 568 | case LB_TAG_VERSION: |
| 569 | return "VERSION"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 570 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 571 | case LB_TAG_EXTRA_VERSION: |
| 572 | return "EXTRA_VERSION"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 573 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 574 | case LB_TAG_BUILD: |
| 575 | return "BUILD"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 576 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 577 | case LB_TAG_COMPILE_TIME: |
| 578 | return "COMPILE_TIME"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 579 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 580 | case LB_TAG_COMPILE_BY: |
| 581 | return "COMPILE_BY"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 582 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 583 | case LB_TAG_COMPILE_HOST: |
| 584 | return "COMPILE_HOST"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 585 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 586 | case LB_TAG_COMPILE_DOMAIN: |
| 587 | return "COMPILE_DOMAIN"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 588 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 589 | case LB_TAG_COMPILER: |
| 590 | return "COMPILER"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 591 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 592 | case LB_TAG_LINKER: |
| 593 | return "LINKER"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 594 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 595 | case LB_TAG_ASSEMBLER: |
| 596 | return "ASSEMBLER"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 597 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 598 | case LB_TAG_SERIAL: |
| 599 | return "SERIAL"; |
Stefan Reinauer | 764fe40 | 2009-03-17 14:39:36 +0000 | [diff] [blame] | 600 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 601 | case LB_TAG_CONSOLE: |
| 602 | return "CONSOLE"; |
Stefan Reinauer | 764fe40 | 2009-03-17 14:39:36 +0000 | [diff] [blame] | 603 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 604 | case LB_TAG_FORWARD: |
| 605 | return "FORWARD"; |
Stefan Reinauer | 764fe40 | 2009-03-17 14:39:36 +0000 | [diff] [blame] | 606 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 607 | case LB_TAG_CMOS_OPTION_TABLE: |
| 608 | return "CMOS_OPTION_TABLE"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 609 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 610 | case LB_TAG_OPTION_CHECKSUM: |
| 611 | return "OPTION_CHECKSUM"; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 612 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 613 | default: |
| 614 | break; |
| 615 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 616 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 617 | return "UNKNOWN"; |
| 618 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 619 | |
| 620 | /**************************************************************************** |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 621 | * memory_print_fn |
| 622 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 623 | * Display function for 'memory' item of coreboot table. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 624 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 625 | static void memory_print_fn(const struct lb_record *rec) |
| 626 | { |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 627 | const struct lb_memory *p; |
| 628 | const char *mem_type; |
| 629 | const struct lb_memory_range *ranges; |
| 630 | uint64_t size, start, end; |
| 631 | int i, entries; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 632 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 633 | p = (const struct lb_memory *)rec; |
| 634 | entries = (p->size - sizeof(*p)) / sizeof(p->map[0]); |
| 635 | ranges = p->map; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 636 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 637 | if (entries == 0) { |
| 638 | printf("No memory ranges were found.\n"); |
| 639 | return; |
| 640 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 641 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 642 | for (i = 0;;) { |
| 643 | switch (ranges[i].type) { |
| 644 | case LB_MEM_RAM: |
| 645 | mem_type = "AVAILABLE"; |
| 646 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 647 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 648 | case LB_MEM_RESERVED: |
| 649 | mem_type = "RESERVED"; |
| 650 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 651 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 652 | case LB_MEM_TABLE: |
| 653 | mem_type = "CONFIG_TABLE"; |
| 654 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 655 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 656 | default: |
| 657 | mem_type = "UNKNOWN"; |
| 658 | break; |
| 659 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 660 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 661 | size = unpack_lb64(ranges[i].size); |
| 662 | start = unpack_lb64(ranges[i].start); |
| 663 | end = start + size - 1; |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 664 | printf("%s memory:\n" |
Stefan Reinauer | 9981cad | 2012-05-24 13:36:30 -0700 | [diff] [blame] | 665 | " from physical addresses 0x%016" PRIx64 |
| 666 | " to 0x%016" PRIx64 "\n size is 0x%016" PRIx64 |
| 667 | " bytes (%" PRId64 " in decimal)\n", |
| 668 | mem_type, start, end, size, size); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 669 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 670 | if (++i >= entries) |
| 671 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 672 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 673 | printf("\n"); |
| 674 | } |
| 675 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 676 | |
| 677 | /**************************************************************************** |
| 678 | * mainboard_print_fn |
| 679 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 680 | * Display function for 'mainboard' item of coreboot table. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 681 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 682 | static void mainboard_print_fn(const struct lb_record *rec) |
| 683 | { |
| 684 | const struct lb_mainboard *p; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 685 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 686 | p = (const struct lb_mainboard *)rec; |
| 687 | printf("Vendor: %s\n" |
| 688 | "Part number: %s\n", |
| 689 | &p->strings[p->vendor_idx], &p->strings[p->part_number_idx]); |
| 690 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 691 | |
| 692 | /**************************************************************************** |
| 693 | * cmos_opt_table_print_fn |
| 694 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 695 | * Display function for 'cmos_opt_table' item of coreboot table. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 696 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 697 | static void cmos_opt_table_print_fn(const struct lb_record *rec) |
| 698 | { |
| 699 | const struct cmos_option_table *p; |
| 700 | const struct lb_record *cmos_item; |
| 701 | uint32_t bytes_processed, bytes_for_entries; |
| 702 | const char *q; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 703 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 704 | p = (const struct cmos_option_table *)rec; |
| 705 | q = ((const char *)p) + p->header_length; |
| 706 | bytes_for_entries = p->size - p->header_length; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 707 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 708 | printf("CMOS option table at physical address 0x%lx:\n" |
| 709 | " tag: 0x%x (decimal: %d)\n" |
| 710 | " size: 0x%x (decimal: %d)\n" |
| 711 | " header_length: 0x%x (decimal: %d)\n\n", |
| 712 | vtophys(p), p->tag, p->tag, p->size, p->size, p->header_length, |
| 713 | p->header_length); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 714 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 715 | if (p->header_length > p->size) { |
| 716 | printf |
| 717 | ("Header length for CMOS option table is greater than the size " |
| 718 | "of the entire table including header!!!\n"); |
| 719 | return; |
| 720 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 721 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 722 | if (bytes_for_entries == 0) { |
| 723 | printf("The CMOS option table is empty!!!\n"); |
| 724 | return; |
| 725 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 726 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 727 | for (bytes_processed = 0;;) { |
| 728 | cmos_item = (const struct lb_record *)&q[bytes_processed]; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 729 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 730 | switch (cmos_item->tag) { |
| 731 | case LB_TAG_OPTION: |
| 732 | print_option_record((const struct cmos_entries *) |
| 733 | cmos_item); |
| 734 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 735 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 736 | case LB_TAG_OPTION_ENUM: |
| 737 | print_enum_record((const struct cmos_enums *)cmos_item); |
| 738 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 739 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 740 | case LB_TAG_OPTION_DEFAULTS: |
| 741 | print_defaults_record((const struct cmos_defaults *) |
| 742 | cmos_item); |
| 743 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 744 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 745 | default: |
| 746 | print_unknown_record(cmos_item); |
| 747 | break; |
| 748 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 749 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 750 | bytes_processed += cmos_item->size; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 751 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 752 | if (bytes_processed >= bytes_for_entries) |
| 753 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 754 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 755 | printf("\n"); |
| 756 | } |
| 757 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 758 | |
| 759 | /**************************************************************************** |
| 760 | * print_option_record |
| 761 | * |
| 762 | * Display "option" record from CMOS option table. |
| 763 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 764 | static void print_option_record(const struct cmos_entries *cmos_entry) |
| 765 | { |
| 766 | static const size_t S_BUFSIZE = 80; |
| 767 | char s[S_BUFSIZE]; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 768 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 769 | switch (cmos_entry->config) { |
| 770 | case 'e': |
| 771 | strcpy(s, "ENUM"); |
| 772 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 773 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 774 | case 'h': |
| 775 | strcpy(s, "HEX"); |
| 776 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 777 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 778 | case 'r': |
| 779 | strcpy(s, "RESERVED"); |
| 780 | break; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 781 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 782 | default: |
| 783 | snprintf(s, S_BUFSIZE, "UNKNOWN: value is 0x%x (decimal: %d)", |
| 784 | cmos_entry->config, cmos_entry->config); |
| 785 | break; |
| 786 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 787 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 788 | printf(" OPTION record at physical address 0x%lx:\n" |
| 789 | " tag: 0x%x (decimal: %d)\n" |
| 790 | " size: 0x%x (decimal: %d)\n" |
| 791 | " bit: 0x%x (decimal: %d)\n" |
| 792 | " length: 0x%x (decimal: %d)\n" |
| 793 | " config: %s\n" |
| 794 | " config_id: 0x%x (decimal: %d)\n" |
| 795 | " name: %s\n", |
| 796 | vtophys(cmos_entry), cmos_entry->tag, cmos_entry->tag, |
| 797 | cmos_entry->size, cmos_entry->size, cmos_entry->bit, |
| 798 | cmos_entry->bit, cmos_entry->length, cmos_entry->length, s, |
| 799 | cmos_entry->config_id, cmos_entry->config_id, cmos_entry->name); |
| 800 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 801 | |
| 802 | /**************************************************************************** |
| 803 | * print_enum_record |
| 804 | * |
| 805 | * Display "enum" record from CMOS option table. |
| 806 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 807 | static void print_enum_record(const struct cmos_enums *cmos_enum) |
| 808 | { |
| 809 | printf(" ENUM record at physical address 0x%lx:\n" |
| 810 | " tag: 0x%x (decimal: %d)\n" |
| 811 | " size: 0x%x (decimal: %d)\n" |
| 812 | " config_id: 0x%x (decimal: %d)\n" |
| 813 | " value: 0x%x (decimal: %d)\n" |
| 814 | " text: %s\n", |
| 815 | vtophys(cmos_enum), cmos_enum->tag, cmos_enum->tag, |
| 816 | cmos_enum->size, cmos_enum->size, cmos_enum->config_id, |
| 817 | cmos_enum->config_id, cmos_enum->value, cmos_enum->value, |
| 818 | cmos_enum->text); |
| 819 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 820 | |
| 821 | /**************************************************************************** |
| 822 | * print_defaults_record |
| 823 | * |
| 824 | * Display "defaults" record from CMOS option table. |
| 825 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 826 | static void print_defaults_record(const struct cmos_defaults *cmos_defaults) |
| 827 | { |
| 828 | printf(" DEFAULTS record at physical address 0x%lx:\n" |
| 829 | " tag: 0x%x (decimal: %d)\n" |
| 830 | " size: 0x%x (decimal: %d)\n" |
| 831 | " name_length: 0x%x (decimal: %d)\n" |
| 832 | " name: %s\n" |
| 833 | " default_set:\n", |
| 834 | vtophys(cmos_defaults), cmos_defaults->tag, cmos_defaults->tag, |
| 835 | cmos_defaults->size, cmos_defaults->size, |
| 836 | cmos_defaults->name_length, cmos_defaults->name_length, |
| 837 | cmos_defaults->name); |
| 838 | hexdump(cmos_defaults->default_set, CMOS_IMAGE_BUFFER_SIZE, |
| 839 | vtophys(cmos_defaults->default_set), stdout, &format); |
| 840 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 841 | |
| 842 | /**************************************************************************** |
| 843 | * print_unknown_record |
| 844 | * |
| 845 | * Display record of unknown type from CMOS option table. |
| 846 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 847 | static void print_unknown_record(const struct lb_record *cmos_item) |
| 848 | { |
| 849 | const char *data; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 850 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 851 | printf(" UNKNOWN record at physical address 0x%lx:\n" |
| 852 | " tag: 0x%x (decimal: %d)\n" |
| 853 | " size: 0x%x (decimal: %d)\n" |
| 854 | " data:\n", |
| 855 | vtophys(cmos_item), cmos_item->tag, cmos_item->tag, |
| 856 | cmos_item->size, cmos_item->size); |
| 857 | data = ((const char *)cmos_item) + sizeof(*cmos_item); |
| 858 | hexdump(data, cmos_item->size - sizeof(*cmos_item), vtophys(data), |
| 859 | stdout, &format); |
| 860 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 861 | |
| 862 | /**************************************************************************** |
| 863 | * option_checksum_print_fn |
| 864 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 865 | * Display function for 'option_checksum' item of coreboot table. |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 866 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 867 | static void option_checksum_print_fn(const struct lb_record *rec) |
| 868 | { |
| 869 | struct cmos_checksum *p; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 870 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 871 | p = (struct cmos_checksum *)rec; |
| 872 | printf("CMOS checksum from bit %d to bit %d\n" |
| 873 | "at position %d is type %s.\n", |
| 874 | p->range_start, p->range_end, p->location, |
| 875 | (p->type == CHECKSUM_PCBIOS) ? "PC BIOS" : "NONE"); |
| 876 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 877 | |
| 878 | /**************************************************************************** |
| 879 | * string_print_fn |
| 880 | * |
Stefan Reinauer | f527e70 | 2008-01-18 15:33:49 +0000 | [diff] [blame] | 881 | * Display function for a generic item of coreboot table that simply |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 882 | * consists of a string. |
| 883 | ****************************************************************************/ |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 884 | static void string_print_fn(const struct lb_record *rec) |
| 885 | { |
| 886 | const struct lb_string *p; |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 887 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 888 | p = (const struct lb_string *)rec; |
| 889 | printf("%s\n", p->string); |
| 890 | } |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 891 | |