Stefan Reinauer ([email protected]) just uploaded a new patch set to 
gerrit, which you can find at http://review.coreboot.org/2114

-gerrit

commit 1560718f8d10dd0394e3df6f7bdc4fee54034ce5
Author: Stefan Reinauer <[email protected]>
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 <[email protected]>
---
 util/cbmem/cbmem.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)

diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index df00684..cc98e56 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -283,6 +283,29 @@ static void dump_timestamps(void)
        unmap_memory();
 }
 
+/* dump the cbmem console */
+static void dump_console(void)
+{
+       void *console_p;
+
+       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.
+        */
+       printf("%s", (char *)console_p + 8);
+
+       unmap_memory();
+}
+
+
 void print_version(void)
 {
        printf("cbmem v%s -- ", CBMEM_VERSION);
@@ -303,6 +326,9 @@ void print_usage(const char *name)
 {
        printf("usage: %s [-vh?]\n", name);
        printf("\n"
+            "   -c | --console:                   verbose (debugging) output\n"
+            "   -t | --timestamps:                verbose (debugging) output\n"
+            "   -V | --verbose:                   verbose (debugging) output\n"
             "   -v | --version:                   print the version\n"
             "   -h | --help:                      print this help\n"
             "\n");
@@ -314,18 +340,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 +393,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);

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to