From cf61dc391d030f8071a9bfdf6a030d2713c9ecb8 Mon Sep 17 00:00:00 2001 From: spashabk-in Date: Wed, 29 Aug 2018 06:12:10 -0500 Subject: SBE logs on serial console Print relevant information of SBE on serial console cmvc-prereq: 1071648 Change-Id: I17c38a06efef37defaefa3ef041635ed5b101270 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/65446 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: RAJA DAS Reviewed-by: Sachin Gupta --- src/sbefw/core/ipl.C | 2 ++ src/sbefw/core/sbeConsole.C | 40 ++++++++++++++++++++++++++++++++-------- src/sbefw/core/sbeConsole.H | 34 ++++++++++++++++++++++++++++++---- 3 files changed, 64 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/sbefw/core/ipl.C b/src/sbefw/core/ipl.C index d817be60..14dd3162 100644 --- a/src/sbefw/core/ipl.C +++ b/src/sbefw/core/ipl.C @@ -28,6 +28,7 @@ #include "sbeFFDC.H" #include "ipl.H" +#include "sbeConsole.H" #include "sbeglobals.H" #include "p9n2_perv_scom_addresses.H" @@ -121,6 +122,7 @@ void sbeDoContinuousIpl() auto istepMap = &istepTableEntry->istepMinorArr[step-1]; if(istepMap->istepWrapper != NULL) { + SBE_MSG_CONSOLE("istep ", istepTableEntry->istepMajorNum, ".", step); rc = istepMap->istepWrapper(istepMap->istepHwp); } bool checkstop = isSystemCheckstop(); diff --git a/src/sbefw/core/sbeConsole.C b/src/sbefw/core/sbeConsole.C index 6f0db4ef..d3d3f3f6 100644 --- a/src/sbefw/core/sbeConsole.C +++ b/src/sbefw/core/sbeConsole.C @@ -246,16 +246,40 @@ void uartUnLock(void) pk_halt(); } } + +void sbeMsgConsole(uint32_t num) +{ + // 8 chars for max unit32_t and a null terminator + char num_str[9] = {}; + + int i = 0; + if(num == 0) + num_str[0] = '0'; + while(num) + { + num_str[i++] = (num % 10) + '0'; + num /= 10; + } + + // reverse string + char *start = num_str, *end = num_str + i-1; + while(start < end) + { + char temp = *start; + *start = *end; + *end = temp; + start++; + end--; + } + + sbeMsgConsole((char*)(num_str)); +} + void sbeMsgConsole(char const *msg) { - if(SBE_GLOBAL->sbeUartActive) + size_t c = 0; + while(msg[c] != '\0') { - size_t c = 0; - while(msg[c] != '\0') - { - uartPutChar(msg[c++]); - } + uartPutChar(msg[c++]); } - else - SBE_DEBUG("uart is not active"); } diff --git a/src/sbefw/core/sbeConsole.H b/src/sbefw/core/sbeConsole.H index fe9b5734..d8b85670 100644 --- a/src/sbefw/core/sbeConsole.H +++ b/src/sbefw/core/sbeConsole.H @@ -6,6 +6,7 @@ /* OpenPOWER sbe Project */ /* */ /* Contributors Listed Below - COPYRIGHT 2018 */ +/* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -34,16 +35,34 @@ _SBE_MSG_CONSOLE(msg); \ _SBE_MSG_CONSOLE("\n\r"); \ SBE_UART_UNLOCK; + #define SBE_MSG_CONSOLE_2(msg1, msg2) \ SBE_UART_LOCK; \ _SBE_MSG_CONSOLE(msg1); \ - _SBE_MSG_CONSOLE(" "); \ _SBE_MSG_CONSOLE(msg2); \ _SBE_MSG_CONSOLE("\n\r"); \ SBE_UART_UNLOCK; + +#define SBE_MSG_CONSOLE_3(msg1, msg2, msg3) \ + SBE_UART_LOCK; \ + _SBE_MSG_CONSOLE(msg1); \ + _SBE_MSG_CONSOLE(msg2); \ + _SBE_MSG_CONSOLE(msg3); \ + _SBE_MSG_CONSOLE("\n\r"); \ + SBE_UART_UNLOCK; + +#define SBE_MSG_CONSOLE_4(msg1, msg2, msg3, msg4) \ + SBE_UART_LOCK; \ + _SBE_MSG_CONSOLE(msg1); \ + _SBE_MSG_CONSOLE(msg2); \ + _SBE_MSG_CONSOLE(msg3); \ + _SBE_MSG_CONSOLE(msg4); \ + _SBE_MSG_CONSOLE("\n\r"); \ + SBE_UART_UNLOCK; + #define SBE_MSG_CONSOLE_HELPER_CALL(count, ...) SBE_MSG_CONSOLE_ ## count(__VA_ARGS__) #define SBE_MSG_CONSOLE_HELPER(count, ...) SBE_MSG_CONSOLE_HELPER_CALL(count, __VA_ARGS__) -#define SBE_MSG_CONSOLE(...) SBE_MSG_CONSOLE_HELPER(VARG_COUNT(__VA_ARGS__), __VA_ARGS__) +#define SBE_MSG_CONSOLE(...) SBE_MSG_CONSOLE_CHECK(__VA_ARGS__) #ifndef SBE_CONSOLE_SUPPORT @@ -52,6 +71,7 @@ #define SBE_UART_LOCK #define SBE_UART_UNLOCK #define _SBE_MSG_CONSOLE(msg) +#define SBE_MSG_CONSOLE_CHECK(...) #else @@ -60,11 +80,16 @@ #define SBE_UART_LOCK uartLock() #define SBE_UART_UNLOCK uartUnLock() +#define SBE_MSG_CONSOLE_CHECK(...) \ + if(SBE_GLOBAL->sbeUartActive) \ + { \ + SBE_MSG_CONSOLE_HELPER(VARG_COUNT(__VA_ARGS__), __VA_ARGS__) \ + } // SBE messages #define SBE_CONSOLE_WELCOME_MSG ("\n\r--== Welcome to SBE - CommitId[" STRINGIFY(SBE_COMMIT_ID) "] ==--") -#define _SBE_MSG_CONSOLE(msg) \ - sbeMsgConsole(msg) +#define _SBE_MSG_CONSOLE(msg) sbeMsgConsole(msg) + #define LPC_IO_SPACE 0xD0010000 #define LPC_MAX_IO_SPACE (64*1024) @@ -73,6 +98,7 @@ void uartDisable(void); void uartLock(void); void uartUnLock(void); void sbeMsgConsole(char const *msg); +void sbeMsgConsole(uint32_t num); // /** UART Register Offsets */ enum -- cgit v1.2.1