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