diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2014-08-13 15:28:13 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2014-09-24 16:15:04 -0500 |
commit | 35cdaf24fa1b3f4fd4816726d45c750212b83daf (patch) | |
tree | d16774a6efaeae6dc6bdaed1d24780ad0f6a1219 /src/usr/trace/service.C | |
parent | ce53b72773377075da4e6d05a2b5b77e8d217748 (diff) | |
download | talos-hostboot-35cdaf24fa1b3f4fd4816726d45c750212b83daf.tar.gz talos-hostboot-35cdaf24fa1b3f4fd4816726d45c750212b83daf.zip |
Support for serial console.
Change-Id: Ia1b11f68cc4be175076562b7daf0291b14df498b
Origin: Google Shared Technology
RTC: 97495
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13250
Tested-by: Jenkins Server
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/trace/service.C')
-rw-r--r-- | src/usr/trace/service.C | 97 |
1 files changed, 96 insertions, 1 deletions
diff --git a/src/usr/trace/service.C b/src/usr/trace/service.C index 28beac950..db5ea8590 100644 --- a/src/usr/trace/service.C +++ b/src/usr/trace/service.C @@ -5,7 +5,10 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* [+] Google Inc. */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -34,6 +37,10 @@ #include <util/singleton.H> #include <assert.h> #include <time.h> +#include <config.h> +#include <console/consoleif.H> +#include <stdio.h> +#include <ctype.h> namespace TRACE { @@ -68,6 +75,15 @@ namespace TRACE } } + #ifdef CONFIG_CONSOLE_OUTPUT_TRACE + { + va_list args; + va_copy(args, i_args); + CONSOLE::vdisplayf(i_td->iv_compName, i_fmt, i_args); + va_end(args); + } + #endif + do { // Get the right buffer for this component. @@ -224,6 +240,85 @@ namespace TRACE } } + #ifdef CONFIG_CONSOLE_OUTPUT_TRACE + { + // Output binary data. + // Format is: + // ~[0x0000] 01234567 01234567 01234567 01234567 *012345689abcdef* + static size_t BINARY_FORMAT_LENGTH = 69; + + size_t pos = 0; + char* output = strdup(i_fmt); + size_t output_size = strlen(output)+1; + while(pos < i_size) + { + char bin_output[BINARY_FORMAT_LENGTH]; + + // Create length header. + size_t bin_pos = sprintf(bin_output, + "~[0x%04hx]", (uint16_t) pos); + + // Create hex representation. + for (int i =0 ; i < 16; ++i) + { + if ((i % 4) == 0) + { + bin_output[bin_pos++] = ' '; + } + if ((pos + i) < i_size) + { + sprintf(&bin_output[bin_pos], + "%02x", ((const char*)i_ptr)[pos+i]); + bin_pos += 2; + } + else + { + bin_output[bin_pos++] = ' '; + bin_output[bin_pos++] = ' '; + } + } + + for (int i = 0; i < 4; ++i) + { + bin_output[bin_pos++] = ' '; + } + bin_output[bin_pos++] = '*'; + + // Create ascii representation. + for(int i = 0; i< 16; ++i) + { + char ch = ' '; + if ((pos + i) < i_size) + { + ch = ((const char*) i_ptr)[pos+i]; + if (!isprint(ch)) + { + ch = '.'; + } + } + bin_output[bin_pos++] = ch; + } + bin_output[bin_pos++] = '*'; + bin_output[bin_pos++] = '\0'; + + // Append to output string. + output = static_cast<char*>( + realloc(output, output_size + BINARY_FORMAT_LENGTH)); + strcat(output, "\n"); + strcat(output, bin_output); + output_size += BINARY_FORMAT_LENGTH; + + pos += 16; + } + + // Output full binary dump. + CONSOLE::displayf(i_td->iv_compName, output); + free(output); + + } + #endif + + do { // Get the right buffer for this component. |