Stefan Reinauer (stefan.reinauer@coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2114
-gerrit
commit 81124070b8cac3a33411e4f0809976fa7f213f57 Author: Stefan Reinauer stefan.reinauer@coreboot.org Date: Mon Jan 7 13:37:12 2013 -0800
cbmem utility: Add option to dump cbmem console
This adds an option to the cbmem utility to dump the cbmem console. To keep the utility backwards compatible, specifying -c disables printing of time stamps. To print both console and time stamps, run the utility with -ct
Change-Id: Idd2dbf32c3c44f857c2f41e6c817c5ab13155d6f Signed-off-by: Stefan Reinauer reinauer@google.com --- util/cbmem/cbmem.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-)
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index df00684..bcbc9ce 100644 --- a/util/cbmem/cbmem.c +++ b/util/cbmem/cbmem.c @@ -283,6 +283,41 @@ static void dump_timestamps(void) unmap_memory(); }
+/* dump the cbmem console */ +static void dump_console(void) +{ + void *console_p; + char *console_c; + uint32_t size; + + if (console.tag != LB_TAG_CBMEM_CONSOLE) { + fprintf(stderr, "No console found in coreboot table.\n"); + return; + } + + console_p = map_memory((unsigned long)console.cbmem_addr); + /* The in-memory format of the console area is: + * u32 size + * u32 cursor + * char console[size] + * Hence we have to add 8 to get to the actual console string. + */ + size = *(uint32_t *)console_p; + console_c = malloc(size + 1); + if (!console_c) { + fprintf(stderr, "Not enough memory for console.\n"); + exit(1); + } + + memcpy(console_c, console_p + 8, size); + console_c[size] = 0; + + printf("%s", console_c); + + unmap_memory(); +} + + void print_version(void) { printf("cbmem v%s -- ", CBMEM_VERSION); @@ -303,6 +338,9 @@ void print_usage(const char *name) { printf("usage: %s [-vh?]\n", name); printf("\n" + " -c | --console: print cbmem console\n" + " -t | --timestamps: print timestamp information\n" + " -V | --verbose: verbose (debugging) output\n" " -v | --version: print the version\n" " -h | --help: print this help\n" "\n"); @@ -314,18 +352,30 @@ int main(int argc, char** argv) int j; static const int possible_base_addresses[] = { 0, 0xf0000 };
- int print_timestamps = 1; + int print_defaults = 1; + int print_console = 0; + int print_timestamps = 0;
int opt, option_index = 0; static struct option long_options[] = { + {"console", 0, 0, 'c'}, + {"timestamps", 0, 0, 't'}, {"verbose", 0, 0, 'V'}, {"version", 0, 0, 'v'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0} }; - while ((opt = getopt_long(argc, argv, "Vvh?", + while ((opt = getopt_long(argc, argv, "ctVvh?", long_options, &option_index)) != EOF) { switch (opt) { + case 'c': + print_console = 1; + print_defaults = 0; + break; + case 't': + print_timestamps = 1; + print_defaults = 0; + break; case 'V': verbose = 1; break; @@ -355,7 +405,10 @@ int main(int argc, char** argv) break; }
- if (print_timestamps) + if (print_console) + dump_console(); + + if (print_defaults || print_timestamps) dump_timestamps();
close(fd);