2007-07-12 18:35:42 +02:00
|
|
|
/*****************************************************************************\
|
|
|
|
* lbtable.c
|
|
|
|
*****************************************************************************
|
|
|
|
* Copyright (C) 2002-2005 The Regents of the University of California.
|
|
|
|
* Produced at the Lawrence Livermore National Laboratory.
|
|
|
|
* Written by Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>
|
|
|
|
* and Stefan Reinauer <stepan@openbios.org>.
|
|
|
|
* UCRL-CODE-2003-012
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2008-03-01 20:06:32 +01:00
|
|
|
* This file is part of nvramtool, a utility for reading/writing coreboot
|
2008-01-18 16:33:49 +01:00
|
|
|
* parameters and displaying information from the coreboot table.
|
2008-03-01 20:06:32 +01:00
|
|
|
* For details, see http://coreboot.org/nvramtool.
|
2007-07-12 18:35:42 +02:00
|
|
|
*
|
|
|
|
* Please also read the file DISCLAIMER which is included in this software
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License (as published by the
|
|
|
|
* Free Software Foundation) version 2, dated June 1991.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
|
|
|
* conditions of the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
Remove address from GPLv2 headers
As per discussion with lawyers[tm], it's not a good idea to
shorten the license header too much - not for legal reasons
but because there are tools that look for them, and giving
them a standard pattern simplifies things.
However, we got confirmation that we don't have to update
every file ever added to coreboot whenever the FSF gets a
new lease, but can drop the address instead.
util/kconfig is excluded because that's imported code that
we may want to synchronize every now and then.
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *MA[, ]*02110-1301[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 59 Temple Place[-, ]*Suite 330, Boston, MA *02111-1307[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.:Foundation, Inc.:" {} +
$ find * -type f
-a \! -name \*.patch \
-a \! -name \*_shipped \
-a \! -name LICENSE_GPL \
-a \! -name LGPL.txt \
-a \! -name COPYING \
-a \! -name DISCLAIMER \
-exec sed -i "/Foundation, Inc./ N;s:Foundation, Inc.* USA\.* *:Foundation, Inc. :;s:Foundation, Inc. $:Foundation, Inc.:" {} +
Change-Id: Icc968a5a5f3a5df8d32b940f9cdb35350654bef9
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/9233
Tested-by: build bot (Jenkins)
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-03-26 15:17:45 +01:00
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.
|
2007-07-12 18:35:42 +02:00
|
|
|
\*****************************************************************************/
|
|
|
|
|
2012-05-24 22:36:30 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <inttypes.h>
|
2008-09-18 16:49:33 +02:00
|
|
|
#include <string.h>
|
2012-10-22 10:41:42 +02:00
|
|
|
#ifndef __MINGW32__
|
2007-07-12 18:35:42 +02:00
|
|
|
#include <sys/mman.h>
|
2012-10-22 10:41:42 +02:00
|
|
|
#endif
|
2007-07-12 18:35:42 +02:00
|
|
|
#include "common.h"
|
2008-01-18 17:17:44 +01:00
|
|
|
#include "coreboot_tables.h"
|
2007-07-12 18:35:42 +02:00
|
|
|
#include "ip_checksum.h"
|
|
|
|
#include "lbtable.h"
|
|
|
|
#include "layout.h"
|
|
|
|
#include "cmos_lowlevel.h"
|
|
|
|
#include "hexdump.h"
|
2011-01-21 08:24:08 +01:00
|
|
|
#include "cbfs.h"
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
typedef void (*lbtable_print_fn_t) (const struct lb_record * rec);
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2008-01-18 16:33:49 +01:00
|
|
|
/* This structure represents an item in the coreboot table that may be
|
2007-07-12 18:35:42 +02:00
|
|
|
* displayed using the -l option.
|
|
|
|
*/
|
2010-01-13 22:00:23 +01:00
|
|
|
typedef struct {
|
|
|
|
uint32_t tag;
|
|
|
|
const char *name;
|
|
|
|
const char *description;
|
|
|
|
const char *nofound_msg;
|
|
|
|
lbtable_print_fn_t print_fn;
|
|
|
|
} lbtable_choice_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long start; /* address of first byte of memory range */
|
|
|
|
unsigned long end; /* address of last byte of memory range */
|
|
|
|
} mem_range_t;
|
|
|
|
|
|
|
|
static const struct lb_header *lbtable_scan(unsigned long start,
|
|
|
|
unsigned long end,
|
|
|
|
int *bad_header_count,
|
|
|
|
int *bad_table_count);
|
|
|
|
static const char *lbrec_tag_to_str(uint32_t tag);
|
|
|
|
static void memory_print_fn(const struct lb_record *rec);
|
|
|
|
static void mainboard_print_fn(const struct lb_record *rec);
|
|
|
|
static void cmos_opt_table_print_fn(const struct lb_record *rec);
|
|
|
|
static void print_option_record(const struct cmos_entries *cmos_entry);
|
|
|
|
static void print_enum_record(const struct cmos_enums *cmos_enum);
|
|
|
|
static void print_defaults_record(const struct cmos_defaults *cmos_defaults);
|
|
|
|
static void print_unknown_record(const struct lb_record *cmos_item);
|
|
|
|
static void option_checksum_print_fn(const struct lb_record *rec);
|
|
|
|
static void string_print_fn(const struct lb_record *rec);
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char memory_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows information about system memory.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char mainboard_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows information about your mainboard.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char version_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows coreboot version information.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char extra_version_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows extra coreboot version information.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
static const char build_desc[] = " This shows coreboot build information.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char compile_time_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows when coreboot was compiled.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
static const char compile_by_desc[] = " This shows who compiled coreboot.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char compile_host_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows the name of the machine that compiled coreboot.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char compile_domain_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows the domain name of the machine that compiled coreboot.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char compiler_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows the name of the compiler used to build coreboot.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char linker_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows the name of the linker used to build coreboot.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char assembler_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows the name of the assembler used to build coreboot.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char cmos_opt_table_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This does a low-level dump of the CMOS option table. The table "
|
|
|
|
"contains\n"
|
|
|
|
" information about the layout of the values that coreboot stores in\n"
|
|
|
|
" nonvolatile RAM.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char option_checksum_desc[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
" This shows the location of the CMOS checksum and the area over which it "
|
|
|
|
"is\n" " calculated.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char generic_nofound_msg[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
"%s: Item %s not found in coreboot table.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char nofound_msg_cmos_opt_table[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
"%s: Item %s not found in coreboot table. Apparently, the "
|
|
|
|
"coreboot installed on this system was built without specifying "
|
|
|
|
"CONFIG_HAVE_OPTION_TABLE.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
static const char nofound_msg_option_checksum[] =
|
2010-01-13 22:00:23 +01:00
|
|
|
"%s: Item %s not found in coreboot table. Apparently, you are "
|
|
|
|
"using coreboot v1.\n";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2009-03-17 15:39:36 +01:00
|
|
|
int fd;
|
|
|
|
|
2008-01-18 16:33:49 +01:00
|
|
|
/* This is the number of items from the coreboot table that may be displayed
|
2007-07-12 18:35:42 +02:00
|
|
|
* using the -l option.
|
|
|
|
*/
|
|
|
|
#define NUM_LBTABLE_CHOICES 14
|
|
|
|
|
2008-01-18 16:33:49 +01:00
|
|
|
/* These represent the various items from the coreboot table that may be
|
2007-07-12 18:35:42 +02:00
|
|
|
* displayed using the -l option.
|
|
|
|
*/
|
|
|
|
static const lbtable_choice_t lbtable_choices[NUM_LBTABLE_CHOICES] =
|
2010-01-13 22:00:23 +01:00
|
|
|
{ {LB_TAG_MEMORY, "memory",
|
|
|
|
memory_desc, generic_nofound_msg,
|
|
|
|
memory_print_fn},
|
|
|
|
{LB_TAG_MAINBOARD, "mainboard",
|
|
|
|
mainboard_desc, generic_nofound_msg,
|
|
|
|
mainboard_print_fn},
|
|
|
|
{LB_TAG_VERSION, "version",
|
|
|
|
version_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_EXTRA_VERSION, "extra_version",
|
|
|
|
extra_version_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_BUILD, "build",
|
|
|
|
build_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_COMPILE_TIME, "compile_time",
|
|
|
|
compile_time_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_COMPILE_BY, "compile_by",
|
|
|
|
compile_by_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_COMPILE_HOST, "compile_host",
|
|
|
|
compile_host_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_COMPILE_DOMAIN, "compile_domain",
|
|
|
|
compile_domain_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_COMPILER, "compiler",
|
|
|
|
compiler_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_LINKER, "linker",
|
|
|
|
linker_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_ASSEMBLER, "assembler",
|
|
|
|
assembler_desc, generic_nofound_msg,
|
|
|
|
string_print_fn},
|
|
|
|
{LB_TAG_CMOS_OPTION_TABLE, "cmos_opt_table",
|
|
|
|
cmos_opt_table_desc, nofound_msg_cmos_opt_table,
|
|
|
|
cmos_opt_table_print_fn},
|
|
|
|
{LB_TAG_OPTION_CHECKSUM, "option_checksum",
|
|
|
|
option_checksum_desc, nofound_msg_option_checksum,
|
|
|
|
option_checksum_print_fn}
|
|
|
|
};
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2008-01-18 16:33:49 +01:00
|
|
|
/* The coreboot table resides in low physical memory, which we access using
|
2007-07-12 18:35:42 +02:00
|
|
|
* /dev/mem. These are ranges of physical memory that should be scanned for a
|
2008-01-18 16:33:49 +01:00
|
|
|
* coreboot table.
|
2007-07-12 18:35:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define NUM_MEM_RANGES 2
|
|
|
|
|
|
|
|
static const mem_range_t mem_ranges[NUM_MEM_RANGES] =
|
2010-01-13 22:00:23 +01:00
|
|
|
{ {0x00000000, 0x00000fff},
|
|
|
|
{0x000f0000, 0x000fffff}
|
|
|
|
};
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/* Pointer to low physical memory that we access by calling mmap() on
|
|
|
|
* /dev/mem.
|
|
|
|
*/
|
|
|
|
static const void *low_phys_mem;
|
2013-02-21 14:03:47 +01:00
|
|
|
/* impossible value since not page aligned: first map request will happen */
|
|
|
|
static unsigned long low_phys_base = 0x1;
|
|
|
|
|
|
|
|
/* count of mapped pages */
|
|
|
|
static unsigned long mapped_pages = 0;
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2008-01-18 16:33:49 +01:00
|
|
|
/* Pointer to coreboot table. */
|
2007-07-12 18:35:42 +02:00
|
|
|
static const struct lb_header *lbtable = NULL;
|
|
|
|
|
|
|
|
static const hexdump_format_t format =
|
2011-01-18 13:14:08 +01:00
|
|
|
{ 12, 4, " ", " | ", " ", " | ", '.' };
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* vtophys
|
|
|
|
*
|
|
|
|
* Convert a virtual address to a physical address. 'vaddr' is a virtual
|
|
|
|
* address in the address space of the current process. It points to
|
|
|
|
* somewhere in the chunk of memory that we mapped by calling mmap() on
|
|
|
|
* /dev/mem. This macro converts 'vaddr' to a physical address.
|
|
|
|
****************************************************************************/
|
|
|
|
#define vtophys(vaddr) (((unsigned long) vaddr) - \
|
2009-03-17 15:39:36 +01:00
|
|
|
((unsigned long) low_phys_mem) + low_phys_base)
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* phystov
|
|
|
|
*
|
|
|
|
* Convert a physical address to a virtual address. 'paddr' is a physical
|
|
|
|
* address. This macro converts 'paddr' to a virtual address in the address
|
|
|
|
* space of the current process. The virtual to physical mapping was set up
|
|
|
|
* by calling mmap() on /dev/mem.
|
|
|
|
****************************************************************************/
|
|
|
|
#define phystov(paddr) (((unsigned long) low_phys_mem) + \
|
2009-03-17 15:39:36 +01:00
|
|
|
((unsigned long) paddr) - low_phys_base)
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2013-02-21 14:03:47 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* map_pages
|
|
|
|
*
|
|
|
|
* Maps just enough pages to cover base_address + length
|
|
|
|
* and updates affected variables
|
|
|
|
****************************************************************************/
|
|
|
|
static void map_pages(unsigned long base_address, unsigned long length)
|
|
|
|
{
|
|
|
|
unsigned long num_pages = (length +
|
|
|
|
(base_address & (getpagesize() - 1)) +
|
|
|
|
getpagesize() - 1) >> 12;
|
|
|
|
base_address &= ~(getpagesize() - 1);
|
|
|
|
|
|
|
|
/* no need to do anything */
|
|
|
|
if ((low_phys_base == base_address) && (mapped_pages == num_pages)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (low_phys_mem) {
|
|
|
|
munmap((void *)low_phys_mem, mapped_pages << 12);
|
|
|
|
}
|
|
|
|
if ((low_phys_mem = mmap(NULL, num_pages << 12, PROT_READ, MAP_SHARED, fd,
|
|
|
|
(off_t) base_address)) == MAP_FAILED) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"%s: Failed to mmap /dev/mem at %lx: %s\n",
|
|
|
|
prog_name, base_address, strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
low_phys_base = base_address;
|
|
|
|
}
|
|
|
|
|
2007-07-12 18:35:42 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* get_lbtable
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Find the coreboot table and set global variable lbtable to point to it.
|
2007-07-12 18:35:42 +02:00
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
void get_lbtable(void)
|
|
|
|
{
|
|
|
|
int i, bad_header_count, bad_table_count, bad_headers, bad_tables;
|
|
|
|
|
|
|
|
if (lbtable != NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* The coreboot table is located in low physical memory, which may be
|
|
|
|
* conveniently accessed by calling mmap() on /dev/mem.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((fd = open("/dev/mem", O_RDONLY, 0)) < 0) {
|
|
|
|
fprintf(stderr, "%s: Can not open /dev/mem for reading: %s\n",
|
|
|
|
prog_name, strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bad_header_count = 0;
|
|
|
|
bad_table_count = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_MEM_RANGES; i++) {
|
2013-02-21 14:03:47 +01:00
|
|
|
lbtable = lbtable_scan(mem_ranges[i].start, mem_ranges[i].end,
|
2010-01-13 22:00:23 +01:00
|
|
|
&bad_headers, &bad_tables);
|
|
|
|
|
|
|
|
if (lbtable != NULL)
|
|
|
|
return; /* success: we found it! */
|
|
|
|
|
|
|
|
bad_header_count += bad_headers;
|
|
|
|
bad_table_count += bad_tables;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr,
|
|
|
|
"%s: coreboot table not found. coreboot does not appear to\n"
|
|
|
|
" be installed on this system. Scanning for the table "
|
|
|
|
"produced the\n"
|
|
|
|
" following results:\n\n"
|
|
|
|
" %d valid signatures were found with bad header "
|
|
|
|
"checksums.\n"
|
|
|
|
" %d valid headers were found with bad table "
|
|
|
|
"checksums.\n", prog_name, bad_header_count, bad_table_count);
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* dump_lbtable
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Do a low-level dump of the coreboot table.
|
2007-07-12 18:35:42 +02:00
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
void dump_lbtable(void)
|
|
|
|
{
|
|
|
|
const char *p, *data;
|
|
|
|
uint32_t bytes_processed;
|
|
|
|
const struct lb_record *lbrec;
|
|
|
|
|
|
|
|
p = ((const char *)lbtable) + lbtable->header_bytes;
|
|
|
|
printf("Coreboot table at physical address 0x%lx:\n"
|
|
|
|
" signature: 0x%x (ASCII: %c%c%c%c)\n"
|
|
|
|
" header_bytes: 0x%x (decimal: %d)\n"
|
|
|
|
" header_checksum: 0x%x (decimal: %d)\n"
|
|
|
|
" table_bytes: 0x%x (decimal: %d)\n"
|
|
|
|
" table_checksum: 0x%x (decimal: %d)\n"
|
|
|
|
" table_entries: 0x%x (decimal: %d)\n\n",
|
2011-01-18 13:12:47 +01:00
|
|
|
vtophys(lbtable), lbtable->signature32,
|
2010-01-13 22:00:23 +01:00
|
|
|
lbtable->signature[0], lbtable->signature[1],
|
|
|
|
lbtable->signature[2], lbtable->signature[3],
|
|
|
|
lbtable->header_bytes, lbtable->header_bytes,
|
|
|
|
lbtable->header_checksum, lbtable->header_checksum,
|
|
|
|
lbtable->table_bytes, lbtable->table_bytes,
|
|
|
|
lbtable->table_checksum, lbtable->table_checksum,
|
|
|
|
lbtable->table_entries, lbtable->table_entries);
|
|
|
|
|
|
|
|
if ((lbtable->table_bytes == 0) != (lbtable->table_entries == 0)) {
|
|
|
|
printf
|
|
|
|
("Inconsistent values for table_bytes and table_entries!!!\n"
|
|
|
|
"They should be either both 0 or both nonzero.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lbtable->table_bytes == 0) {
|
|
|
|
printf("The coreboot table is empty!!!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (bytes_processed = 0;;) {
|
|
|
|
lbrec = (const struct lb_record *)&p[bytes_processed];
|
|
|
|
printf(" %s record at physical address 0x%lx:\n"
|
|
|
|
" tag: 0x%x (decimal: %d)\n"
|
|
|
|
" size: 0x%x (decimal: %d)\n"
|
|
|
|
" data:\n",
|
|
|
|
lbrec_tag_to_str(lbrec->tag), vtophys(lbrec), lbrec->tag,
|
|
|
|
lbrec->tag, lbrec->size, lbrec->size);
|
|
|
|
|
|
|
|
data = ((const char *)lbrec) + sizeof(*lbrec);
|
|
|
|
hexdump(data, lbrec->size - sizeof(*lbrec), vtophys(data),
|
|
|
|
stdout, &format);
|
|
|
|
|
|
|
|
bytes_processed += lbrec->size;
|
|
|
|
|
|
|
|
if (bytes_processed >= lbtable->table_bytes)
|
|
|
|
break;
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* list_lbtable_choices
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* List names and informational blurbs for items from the coreboot table
|
2007-07-12 18:35:42 +02:00
|
|
|
* that may be displayed using the -l option.
|
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
void list_lbtable_choices(void)
|
|
|
|
{
|
|
|
|
int i;
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
for (i = 0;;) {
|
|
|
|
printf("%s:\n%s",
|
|
|
|
lbtable_choices[i].name, lbtable_choices[i].description);
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
if (++i >= NUM_LBTABLE_CHOICES)
|
|
|
|
break;
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* list_lbtable_item
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Show the coreboot table item specified by 'item'.
|
2007-07-12 18:35:42 +02:00
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
void list_lbtable_item(const char item[])
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const struct lb_record *rec;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_LBTABLE_CHOICES; i++) {
|
|
|
|
if (strcmp(item, lbtable_choices[i].name) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == NUM_LBTABLE_CHOICES) {
|
|
|
|
fprintf(stderr, "%s: Invalid coreboot table item %s.\n",
|
|
|
|
prog_name, item);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((rec = find_lbrec(lbtable_choices[i].tag)) == NULL) {
|
|
|
|
fprintf(stderr, lbtable_choices[i].nofound_msg, prog_name,
|
|
|
|
lbtable_choices[i].name);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
lbtable_choices[i].print_fn(rec);
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* lbtable_scan
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Scan the chunk of memory specified by 'start' and 'end' for a coreboot
|
2007-07-12 18:35:42 +02:00
|
|
|
* table. The first 4 bytes of the table are marked by the signature
|
|
|
|
* { 'L', 'B', 'I', 'O' }. 'start' and 'end' indicate the addresses of the
|
|
|
|
* first and last bytes of the chunk of memory to be scanned. For instance,
|
|
|
|
* values of 0x10000000 and 0x1000ffff for 'start' and 'end' specify a 64k
|
|
|
|
* chunk of memory starting at address 0x10000000. 'start' and 'end' are
|
2013-02-21 14:03:47 +01:00
|
|
|
* physical addresses.
|
2007-07-12 18:35:42 +02:00
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* If a coreboot table is found, return a pointer to it. Otherwise return
|
2007-07-12 18:35:42 +02:00
|
|
|
* NULL. On return, *bad_header_count and *bad_table_count are set as
|
|
|
|
* follows:
|
|
|
|
*
|
|
|
|
* *bad_header_count:
|
|
|
|
* Indicates the number of times in which a valid signature was found
|
|
|
|
* but the header checksum was invalid.
|
|
|
|
*
|
|
|
|
* *bad_table_count:
|
|
|
|
* Indicates the number of times in which a header with a valid
|
|
|
|
* checksum was found but the table checksum was invalid.
|
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static const struct lb_header *lbtable_scan(unsigned long start,
|
|
|
|
unsigned long end,
|
|
|
|
int *bad_header_count,
|
|
|
|
int *bad_table_count)
|
|
|
|
{
|
2011-01-18 13:12:47 +01:00
|
|
|
static const char signature[4] = { 'L', 'B', 'I', 'O' };
|
2010-01-13 22:00:23 +01:00
|
|
|
const struct lb_header *table;
|
|
|
|
const struct lb_forward *forward;
|
2013-02-21 14:03:47 +01:00
|
|
|
unsigned long p;
|
2010-01-13 22:00:23 +01:00
|
|
|
uint32_t sig;
|
|
|
|
|
|
|
|
assert(end >= start);
|
2011-01-18 13:12:47 +01:00
|
|
|
memcpy(&sig, signature, sizeof(sig));
|
2010-01-13 22:00:23 +01:00
|
|
|
table = NULL;
|
|
|
|
*bad_header_count = 0;
|
|
|
|
*bad_table_count = 0;
|
|
|
|
|
|
|
|
/* Look for signature. Table is aligned on 16-byte boundary. Therefore
|
|
|
|
* only check every fourth 32-bit memory word. As the loop is coded below,
|
|
|
|
* this function will behave in a reasonable manner for ALL possible values
|
|
|
|
* for 'start' and 'end': even weird boundary cases like 0x00000000 and
|
|
|
|
* 0xffffffff on a 32-bit architecture.
|
|
|
|
*/
|
2013-02-21 14:03:47 +01:00
|
|
|
map_pages(start, end - start);
|
|
|
|
for (p = start;
|
|
|
|
(p <= end) &&
|
|
|
|
(end - p >= (sizeof(uint32_t) - 1)); p += 4) {
|
|
|
|
if (*(uint32_t*)phystov(p) != sig)
|
2010-01-13 22:00:23 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* We found a valid signature. */
|
2013-02-21 14:03:47 +01:00
|
|
|
table = (const struct lb_header *)phystov(p);
|
2010-01-13 22:00:23 +01:00
|
|
|
|
|
|
|
/* validate header checksum */
|
|
|
|
if (compute_ip_checksum((void *)table, sizeof(*table))) {
|
|
|
|
(*bad_header_count)++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-02-21 14:03:47 +01:00
|
|
|
map_pages(p, table->table_bytes + sizeof(*table));
|
2010-01-13 22:00:23 +01:00
|
|
|
/* validate table checksum */
|
|
|
|
if (table->table_checksum !=
|
|
|
|
compute_ip_checksum(((char *)table) + sizeof(*table),
|
|
|
|
table->table_bytes)) {
|
|
|
|
(*bad_table_count)++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checksums are ok: we found it! */
|
|
|
|
/* But it may just be a forwarding table, so look if there's a forwarder */
|
|
|
|
lbtable = table;
|
|
|
|
forward = (struct lb_forward *)find_lbrec(LB_TAG_FORWARD);
|
|
|
|
lbtable = NULL;
|
|
|
|
|
|
|
|
if (forward) {
|
|
|
|
uint64_t new_phys = forward->forward;
|
2013-02-21 14:03:47 +01:00
|
|
|
table = lbtable_scan(new_phys, new_phys + getpagesize(),
|
2010-01-13 22:00:23 +01:00
|
|
|
bad_header_count, bad_table_count);
|
|
|
|
}
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* find_lbrec
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Find the record in the coreboot table that matches 'tag'. Return pointer
|
2007-07-12 18:35:42 +02:00
|
|
|
* to record on success or NULL if record not found.
|
|
|
|
****************************************************************************/
|
2011-03-10 08:52:02 +01:00
|
|
|
const struct lb_record *find_lbrec(uint32_t tag)
|
2010-01-13 22:00:23 +01:00
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
uint32_t bytes_processed;
|
|
|
|
const struct lb_record *lbrec;
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
p = ((const char *)lbtable) + lbtable->header_bytes;
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
for (bytes_processed = 0;
|
|
|
|
bytes_processed < lbtable->table_bytes;
|
|
|
|
bytes_processed += lbrec->size) {
|
|
|
|
lbrec = (const struct lb_record *)&p[bytes_processed];
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
if (lbrec->tag == tag)
|
|
|
|
return lbrec;
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* lbrec_tag_to_str
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Return a pointer to the string representation of the given coreboot table
|
2007-07-12 18:35:42 +02:00
|
|
|
* tag.
|
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static const char *lbrec_tag_to_str(uint32_t tag)
|
|
|
|
{
|
|
|
|
switch (tag) {
|
|
|
|
case LB_TAG_UNUSED:
|
|
|
|
return "UNUSED";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_MEMORY:
|
|
|
|
return "MEMORY";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_HWRPB:
|
|
|
|
return "HWRPB";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_MAINBOARD:
|
|
|
|
return "MAINBOARD";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_VERSION:
|
|
|
|
return "VERSION";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_EXTRA_VERSION:
|
|
|
|
return "EXTRA_VERSION";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_BUILD:
|
|
|
|
return "BUILD";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_COMPILE_TIME:
|
|
|
|
return "COMPILE_TIME";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_COMPILE_BY:
|
|
|
|
return "COMPILE_BY";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_COMPILE_HOST:
|
|
|
|
return "COMPILE_HOST";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_COMPILE_DOMAIN:
|
|
|
|
return "COMPILE_DOMAIN";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_COMPILER:
|
|
|
|
return "COMPILER";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_LINKER:
|
|
|
|
return "LINKER";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_ASSEMBLER:
|
|
|
|
return "ASSEMBLER";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_SERIAL:
|
|
|
|
return "SERIAL";
|
2009-03-17 15:39:36 +01:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_CONSOLE:
|
|
|
|
return "CONSOLE";
|
2009-03-17 15:39:36 +01:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_FORWARD:
|
|
|
|
return "FORWARD";
|
2009-03-17 15:39:36 +01:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_CMOS_OPTION_TABLE:
|
|
|
|
return "CMOS_OPTION_TABLE";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
case LB_TAG_OPTION_CHECKSUM:
|
|
|
|
return "OPTION_CHECKSUM";
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* memory_print_fn
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Display function for 'memory' item of coreboot table.
|
2007-07-12 18:35:42 +02:00
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void memory_print_fn(const struct lb_record *rec)
|
|
|
|
{
|
|
|
|
const struct lb_memory *p;
|
|
|
|
const char *mem_type;
|
|
|
|
const struct lb_memory_range *ranges;
|
|
|
|
uint64_t size, start, end;
|
|
|
|
int i, entries;
|
|
|
|
|
|
|
|
p = (const struct lb_memory *)rec;
|
|
|
|
entries = (p->size - sizeof(*p)) / sizeof(p->map[0]);
|
|
|
|
ranges = p->map;
|
|
|
|
|
|
|
|
if (entries == 0) {
|
|
|
|
printf("No memory ranges were found.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0;;) {
|
|
|
|
switch (ranges[i].type) {
|
|
|
|
case LB_MEM_RAM:
|
|
|
|
mem_type = "AVAILABLE";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LB_MEM_RESERVED:
|
|
|
|
mem_type = "RESERVED";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LB_MEM_TABLE:
|
|
|
|
mem_type = "CONFIG_TABLE";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
mem_type = "UNKNOWN";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = unpack_lb64(ranges[i].size);
|
|
|
|
start = unpack_lb64(ranges[i].start);
|
|
|
|
end = start + size - 1;
|
|
|
|
printf("%s memory:\n"
|
2012-05-24 22:36:30 +02:00
|
|
|
" from physical addresses 0x%016" PRIx64
|
|
|
|
" to 0x%016" PRIx64 "\n size is 0x%016" PRIx64
|
|
|
|
" bytes (%" PRId64 " in decimal)\n",
|
|
|
|
mem_type, start, end, size, size);
|
2010-01-13 22:00:23 +01:00
|
|
|
|
|
|
|
if (++i >= entries)
|
|
|
|
break;
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* mainboard_print_fn
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Display function for 'mainboard' item of coreboot table.
|
2007-07-12 18:35:42 +02:00
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void mainboard_print_fn(const struct lb_record *rec)
|
|
|
|
{
|
|
|
|
const struct lb_mainboard *p;
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
p = (const struct lb_mainboard *)rec;
|
|
|
|
printf("Vendor: %s\n"
|
|
|
|
"Part number: %s\n",
|
|
|
|
&p->strings[p->vendor_idx], &p->strings[p->part_number_idx]);
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* cmos_opt_table_print_fn
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Display function for 'cmos_opt_table' item of coreboot table.
|
2007-07-12 18:35:42 +02:00
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void cmos_opt_table_print_fn(const struct lb_record *rec)
|
|
|
|
{
|
|
|
|
const struct cmos_option_table *p;
|
|
|
|
const struct lb_record *cmos_item;
|
|
|
|
uint32_t bytes_processed, bytes_for_entries;
|
|
|
|
const char *q;
|
|
|
|
|
|
|
|
p = (const struct cmos_option_table *)rec;
|
|
|
|
q = ((const char *)p) + p->header_length;
|
|
|
|
bytes_for_entries = p->size - p->header_length;
|
|
|
|
|
|
|
|
printf("CMOS option table at physical address 0x%lx:\n"
|
|
|
|
" tag: 0x%x (decimal: %d)\n"
|
|
|
|
" size: 0x%x (decimal: %d)\n"
|
|
|
|
" header_length: 0x%x (decimal: %d)\n\n",
|
|
|
|
vtophys(p), p->tag, p->tag, p->size, p->size, p->header_length,
|
|
|
|
p->header_length);
|
|
|
|
|
|
|
|
if (p->header_length > p->size) {
|
|
|
|
printf
|
|
|
|
("Header length for CMOS option table is greater than the size "
|
|
|
|
"of the entire table including header!!!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bytes_for_entries == 0) {
|
|
|
|
printf("The CMOS option table is empty!!!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (bytes_processed = 0;;) {
|
|
|
|
cmos_item = (const struct lb_record *)&q[bytes_processed];
|
|
|
|
|
|
|
|
switch (cmos_item->tag) {
|
|
|
|
case LB_TAG_OPTION:
|
|
|
|
print_option_record((const struct cmos_entries *)
|
|
|
|
cmos_item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LB_TAG_OPTION_ENUM:
|
|
|
|
print_enum_record((const struct cmos_enums *)cmos_item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LB_TAG_OPTION_DEFAULTS:
|
|
|
|
print_defaults_record((const struct cmos_defaults *)
|
|
|
|
cmos_item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
print_unknown_record(cmos_item);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
bytes_processed += cmos_item->size;
|
|
|
|
|
|
|
|
if (bytes_processed >= bytes_for_entries)
|
|
|
|
break;
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* print_option_record
|
|
|
|
*
|
|
|
|
* Display "option" record from CMOS option table.
|
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void print_option_record(const struct cmos_entries *cmos_entry)
|
|
|
|
{
|
|
|
|
static const size_t S_BUFSIZE = 80;
|
|
|
|
char s[S_BUFSIZE];
|
|
|
|
|
|
|
|
switch (cmos_entry->config) {
|
|
|
|
case 'e':
|
|
|
|
strcpy(s, "ENUM");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'h':
|
|
|
|
strcpy(s, "HEX");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'r':
|
|
|
|
strcpy(s, "RESERVED");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
snprintf(s, S_BUFSIZE, "UNKNOWN: value is 0x%x (decimal: %d)",
|
|
|
|
cmos_entry->config, cmos_entry->config);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" OPTION record at physical address 0x%lx:\n"
|
|
|
|
" tag: 0x%x (decimal: %d)\n"
|
|
|
|
" size: 0x%x (decimal: %d)\n"
|
|
|
|
" bit: 0x%x (decimal: %d)\n"
|
|
|
|
" length: 0x%x (decimal: %d)\n"
|
|
|
|
" config: %s\n"
|
|
|
|
" config_id: 0x%x (decimal: %d)\n"
|
|
|
|
" name: %s\n",
|
|
|
|
vtophys(cmos_entry), cmos_entry->tag, cmos_entry->tag,
|
|
|
|
cmos_entry->size, cmos_entry->size, cmos_entry->bit,
|
|
|
|
cmos_entry->bit, cmos_entry->length, cmos_entry->length, s,
|
|
|
|
cmos_entry->config_id, cmos_entry->config_id, cmos_entry->name);
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* print_enum_record
|
|
|
|
*
|
|
|
|
* Display "enum" record from CMOS option table.
|
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void print_enum_record(const struct cmos_enums *cmos_enum)
|
|
|
|
{
|
|
|
|
printf(" ENUM record at physical address 0x%lx:\n"
|
|
|
|
" tag: 0x%x (decimal: %d)\n"
|
|
|
|
" size: 0x%x (decimal: %d)\n"
|
|
|
|
" config_id: 0x%x (decimal: %d)\n"
|
|
|
|
" value: 0x%x (decimal: %d)\n"
|
|
|
|
" text: %s\n",
|
|
|
|
vtophys(cmos_enum), cmos_enum->tag, cmos_enum->tag,
|
|
|
|
cmos_enum->size, cmos_enum->size, cmos_enum->config_id,
|
|
|
|
cmos_enum->config_id, cmos_enum->value, cmos_enum->value,
|
|
|
|
cmos_enum->text);
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* print_defaults_record
|
|
|
|
*
|
|
|
|
* Display "defaults" record from CMOS option table.
|
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void print_defaults_record(const struct cmos_defaults *cmos_defaults)
|
|
|
|
{
|
|
|
|
printf(" DEFAULTS record at physical address 0x%lx:\n"
|
|
|
|
" tag: 0x%x (decimal: %d)\n"
|
|
|
|
" size: 0x%x (decimal: %d)\n"
|
|
|
|
" name_length: 0x%x (decimal: %d)\n"
|
|
|
|
" name: %s\n"
|
|
|
|
" default_set:\n",
|
|
|
|
vtophys(cmos_defaults), cmos_defaults->tag, cmos_defaults->tag,
|
|
|
|
cmos_defaults->size, cmos_defaults->size,
|
|
|
|
cmos_defaults->name_length, cmos_defaults->name_length,
|
|
|
|
cmos_defaults->name);
|
|
|
|
hexdump(cmos_defaults->default_set, CMOS_IMAGE_BUFFER_SIZE,
|
|
|
|
vtophys(cmos_defaults->default_set), stdout, &format);
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* print_unknown_record
|
|
|
|
*
|
|
|
|
* Display record of unknown type from CMOS option table.
|
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void print_unknown_record(const struct lb_record *cmos_item)
|
|
|
|
{
|
|
|
|
const char *data;
|
|
|
|
|
|
|
|
printf(" UNKNOWN record at physical address 0x%lx:\n"
|
|
|
|
" tag: 0x%x (decimal: %d)\n"
|
|
|
|
" size: 0x%x (decimal: %d)\n"
|
|
|
|
" data:\n",
|
|
|
|
vtophys(cmos_item), cmos_item->tag, cmos_item->tag,
|
|
|
|
cmos_item->size, cmos_item->size);
|
|
|
|
data = ((const char *)cmos_item) + sizeof(*cmos_item);
|
|
|
|
hexdump(data, cmos_item->size - sizeof(*cmos_item), vtophys(data),
|
|
|
|
stdout, &format);
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* option_checksum_print_fn
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Display function for 'option_checksum' item of coreboot table.
|
2007-07-12 18:35:42 +02:00
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void option_checksum_print_fn(const struct lb_record *rec)
|
|
|
|
{
|
|
|
|
struct cmos_checksum *p;
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
p = (struct cmos_checksum *)rec;
|
|
|
|
printf("CMOS checksum from bit %d to bit %d\n"
|
|
|
|
"at position %d is type %s.\n",
|
|
|
|
p->range_start, p->range_end, p->location,
|
|
|
|
(p->type == CHECKSUM_PCBIOS) ? "PC BIOS" : "NONE");
|
|
|
|
}
|
2007-07-12 18:35:42 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* string_print_fn
|
|
|
|
*
|
2008-01-18 16:33:49 +01:00
|
|
|
* Display function for a generic item of coreboot table that simply
|
2007-07-12 18:35:42 +02:00
|
|
|
* consists of a string.
|
|
|
|
****************************************************************************/
|
2010-01-13 22:00:23 +01:00
|
|
|
static void string_print_fn(const struct lb_record *rec)
|
|
|
|
{
|
|
|
|
const struct lb_string *p;
|
2007-07-12 18:35:42 +02:00
|
|
|
|
2010-01-13 22:00:23 +01:00
|
|
|
p = (const struct lb_string *)rec;
|
|
|
|
printf("%s\n", p->string);
|
|
|
|
}
|