summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMonte Copeland <copelanm@us.ibm.com>2011-08-11 15:57:40 -0500
committerMonte K. Copeland <copelanm@us.ibm.com>2011-08-16 13:24:44 -0500
commitf24bf89ab0cb82fee8ab80ed6f5aa8142e3db462 (patch)
tree8647432fc82bbd34becc2ebcd7f50f2fccd469b8 /src/include
parent802274b948ef4a52deb4285368a086f669d3913b (diff)
downloadtalos-hostboot-f24bf89ab0cb82fee8ab80ed6f5aa8142e3db462.tar.gz
talos-hostboot-f24bf89ab0cb82fee8ab80ed6f5aa8142e3db462.zip
Changes to errl to commit error logs to L3 RAM 7
Change-Id: Ic058a5b9ea6f8f1d79fc0ff30097cc32f18423bd Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/221 Reviewed-by: Monte K. Copeland <copelanm@us.ibm.com> Tested-by: Jenkins Server
Diffstat (limited to 'src/include')
-rw-r--r--src/include/assert.h21
-rw-r--r--src/include/usr/errl/errlentry.H217
-rw-r--r--src/include/usr/errl/errlmanager.H28
-rw-r--r--src/include/usr/errl/errltypes.H99
4 files changed, 283 insertions, 82 deletions
diff --git a/src/include/assert.h b/src/include/assert.h
index a8f3fb664..1abeb5e2a 100644
--- a/src/include/assert.h
+++ b/src/include/assert.h
@@ -156,6 +156,27 @@ void __assert(AssertBehavior i_assertb, int i_line);
#define crit_assert(expr,...) { }
#endif
+
+
+/** @brief Make an assertion at compile time. If Boolean expression exp
+ * is false, then the compile will stop with an error. Example usage:
+ * CPPASSERT( 2 == sizeof(compId_t));
+ * which would be used in front of errl flattening code that assumes
+ * compId_t is 2 bytes in size. Also with the use of -f short-enums
+ * compiler switch, one could assert
+ * CPPASSERT( 1 == sizeof(errlEventType_t));
+ * If the assertion fails, it will be a wakeup call that the errlEventType_t
+ * enum has grown larger than a byte in size. The mechanism to abend the
+ * compile when the expression is false is to cause a typedef of a char array
+ * that is -1 bytes in size.
+ *
+ * Similar: #define CHECK_SIZE(DATA, EXPECTED_SIZE)\
+ * typedef char CHECKSIZEVAR[(EXPECTED_SIZE == sizeof(DATA)) -1]
+ *
+ */
+#define CPPASSERT(exp) typedef char compile_time_assert_failed[2*((exp)!=0)-1]
+
+
#ifdef __cplusplus
};
#endif
diff --git a/src/include/usr/errl/errlentry.H b/src/include/usr/errl/errlentry.H
index 71d2102ae..7e9d91a50 100644
--- a/src/include/usr/errl/errlentry.H
+++ b/src/include/usr/errl/errlentry.H
@@ -29,7 +29,7 @@ class ErrlSctn;
class ErrlFFDC;
/**
- * @brief Host Boot Error log entry class.
+ * @brief Host Boot Error log entry class.
* This class contains all of the entry management logic and necessary
* information to create a PEL or IPMI event type logs.
* A pointer to this class is known as an errlHndl_t (the error log handle)
@@ -43,7 +43,7 @@ class ErrlEntry
public:
/**
- * @brief ErrlEntry constructor. Builds an error log with info
+ * @brief ErrlEntry constructor. Builds an error log with info
* constructed from the input.
* Event type, Sub System, SRC type, and Terminate state are defaulted
* to the most common values for Host Boot environment. These values
@@ -66,7 +66,7 @@ public:
* in the primary SRC
* @param[in] i_user2 64 bits of user data which are placed
* in the primary SRC
- * @return None
+ * @return None
*/
ErrlEntry(const errlSeverity_t i_sev,
const uint8_t i_modId,
@@ -79,7 +79,9 @@ public:
*
* Releases all resources owned by the handle. If the log has not
* been committed, it effectively aborts the log.
- * All logs (committed or not) must be deleted to avoid a resource leak.
+ * All logs not committed must be deleted to avoid a resource leak.
+ * Committing an error log via ErrlManager will cause ErrlManager
+ * to delete the log after saving it.
*
* @return None
*
@@ -92,6 +94,7 @@ public:
* problem is perceived to be. The severity is
* initially set by the parameter in the constructor
* and can be changed at any point thereafter.
+ * See errl/errltypes.H
*
* @return Current Log Severity
*
@@ -105,37 +108,70 @@ public:
* initially set by the parameter in the constructor
* and can be changed at any point thereafter.
*
- * @return void
+ * @param[in] i_sev Severity. See errl/errltypes.H
*
+ * @return void
*/
void setSev(const errlSeverity_t i_sev);
+
/**
- * @brief Returns the log's reason code
- *
- * @return uint16_t
+ * @brief Get reason code. See errl/errlreasoncodes.H
*
+ * @return reason code
*/
uint16_t reasonCode() const;
/**
- * @brief Returns the log's event type
+ * @brief Set reason code
+ *
+ * @param[in] i_reasonCode The reason code. The upper byte
+ * of a reason code is the component ID.
+ * See errl/errlreasoncodes.H
+ *
+ * @return void
+ */
+ void setReasonCode( const uint16_t i_reasonCode );
+
+ /**
+ * @brief Get module id. See errl/errlreasoncodes.H
+ *
+ * @return module id
+ */
+ uint8_t moduleId() const;
+
+
+
+ /**
+ * @brief Set module id
*
+ * @param[in] i_moduleId The module ID. See errl/errlreasoncodes.H
+ *
+ * @return void
+ */
+ void setModuleId( const uint8_t i_moduleId );
+
+
+ /**
+ * @brief Get the event type of the error log.
+ * See errl/errltypes.H
* @return errlEventType_t
*
*/
errlEventType_t eventType() const;
/**
- * @brief Set the log's event type
- *
- * @return void
- *
- */
+ * @brief Set the log's event type
+ *
+ * @param[in] i_eventType Event type. See errl/errltypes.H
+ *
+ * @return void
+ *
+ */
void setEventType(const errlEventType_t i_eventType);
/**
- * @brief Returns the log's sub system
+ * @brief Returns the log's sub system. See errl/errltypes.H
*
* @return epubSubSystem_t
*
@@ -143,15 +179,17 @@ public:
epubSubSystem_t subSys() const;
/**
- * @brief Set the log's sub system
+ * @brief Set the log's ePub sub system type.
*
- * @return void
+ * @param[in] i_subSys Subsystem type. See errl/errltypes.H
*
+ * @return void
*/
void setSubSys(const epubSubSystem_t i_subSys);
+
/**
- * @brief Returns the log's SRC type
+ * @brief Returns the log's SRC type. See errl/errltypes.H
*
* @return srcType_t
*
@@ -161,13 +199,16 @@ public:
/**
* @brief Set the log's SRC type
*
- * @return void
+ * @param[in] i_srcType The SRC type for this error log. See
+ * errl/errltypes.H
*
+ * @return void
*/
void setSrcType(const srcType_t i_srcType);
/**
- * @brief Returns the log's terminate state type
+ * @brief Returns the log's terminate state type. See
+ * errl/errltypes.H
*
* @return errlTermState_t
*
@@ -177,6 +218,8 @@ public:
/**
* @brief Set the log's Terminating state
*
+ * @param[in] i_termState See errl/errltypes.H
+ *
* @return void
*
*/
@@ -194,6 +237,7 @@ public:
* which classifies the data. This in
* conjunction with the version can be used
* to decode the data.
+ *
* @return Pointer to FFDC section if successfully added.
* NULL if fails
*/
@@ -211,35 +255,48 @@ public:
* function is called earlier.
* @param[in] i_dataPtr Points to data block to be added
* @param[in] i_dataLen Length of data in bytes
+ *
* @return void
*/
void appendToFFDC(ErrlFFDC* i_ffdcSctnPtr,
const void *i_dataPtr,
const uint32_t i_dataLen);
-private:
+
+
+
+
/**
- * @brief Disabled copy constructor and assignment operator
- */
- ErrlEntry(const ErrlEntry& i_right);
- ErrlEntry& operator=(const ErrlEntry& i_right);
+ * @brief Compute the flattened size of an error log.
+ *
+ * @return size in bytes of the flattened data.
+ */
+ uint64_t flattenedSize();
+
/**
- * @brief Add a data section to error log object
+ * @brief Flatten the data to caller's buffer.
*
- * @param[in] i_sctn Pointer to data section to be added
+ * @param[in,out] io_buffer Points to data block to be filled
+ * @param[in] i_cbBuffer Count of bytes in buffer supplied
*
- * @return void
+ * @return Count of bytes copied to caller's
+ * buffer or else zero if it does not fit.
*/
- void addSection(ErrlSctn* i_sctn);
+ uint64_t flatten( void * io_buffer, const uint64_t i_cbBuffer );
+
+
+
+
+private:
/**
- * @brief Returns the unique Error Entry Id. This ID is assigned to
- * the entry when it's created.
- * This is to be called by ErrlManager only.
- * @return 32 bit unsigned identifier
- */
- uint32_t logId() const;
+ * @brief Disabled copy constructor and assignment operator
+ */
+ ErrlEntry(const ErrlEntry& i_right);
+ ErrlEntry& operator=(const ErrlEntry& i_right);
+
+
/**
* @brief Set the log's id
@@ -247,14 +304,17 @@ private:
* set this log's ID to a unique input number.
* This is to be called by ErrlManager only.
*
+ * There is no call to get the log id because it
+ * would just be zero until the log is committed.
+ *
+ * @param[in] i_val Log ID as assigned by ErrlManager
+ *
* @return void
*/
void setLogId(const uint32_t i_val);
- //@todo - Need to add serialization interfaces for ErrlSctn object.
- // Serialization method (boost serialization?) is for HostBoot
- // is currently not yet determined.
- // Note: stream is currently not supported
+
+
#if 0
@@ -334,21 +394,19 @@ private:
#endif
private:
-
// Data Members
- uint16_t iv_reasonCode; // Component ID and reason code, 2 nibbles each
- errlSeverity_t iv_sev; // Log severity
- errlEventType_t iv_eventType; // Event type
- epubSubSystem_t iv_subSys; // Sub system
- srcType_t iv_srcType; // SRC type
- errlTermState_t iv_termState; // Terminate state
- uint8_t iv_modId; // Module ID
- uint64_t iv_user1; // Optional user data 1
- uint64_t iv_user2; // Optional user data 2
- uint32_t iv_logId; // This log's unique ID
-
- // Sections in this log object
- std::vector<ErrlSctn*> iv_sections;
+ uint16_t iv_reasonCode; // Comp ID and reason code, 2 nibbles ea
+ errlSeverity_t iv_sev; // Log severity
+ errlEventType_t iv_eventType; // Event type
+ epubSubSystem_t iv_subSys; // Sub system
+ srcType_t iv_srcType; // SRC type
+ errlTermState_t iv_termState; // Terminate state
+ uint8_t iv_modId; // Module ID
+ uint64_t iv_user1; // Optional user data 1
+ uint64_t iv_user2; // Optional user data 2
+ uint64_t iv_CreationTime; // Time of instantiation
+ uint32_t iv_logId; // This log's unique ID
+ std::vector<ErrlSctn*> iv_SectionVector; // list of user sections
};
@@ -360,48 +418,65 @@ private:
////////////////////////////////////////////////////////////////////////////
inline errlSeverity_t ErrlEntry::sev() const
{
- return (iv_sev);
+ return iv_sev;
}
-////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////
inline void ErrlEntry::setSev(const errlSeverity_t i_sev)
{
iv_sev = i_sev;
return;
}
+
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
inline uint16_t ErrlEntry::reasonCode() const
{
- return (iv_reasonCode);
+ return iv_reasonCode;
+}
+
+inline void ErrlEntry::setReasonCode( const uint16_t i_reasonCode )
+{
+ iv_reasonCode = i_reasonCode;
+ return;
}
+
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
-inline errlEventType_t ErrlEntry::eventType() const
+inline uint8_t ErrlEntry::moduleId() const
+{
+ return iv_modId;
+}
+
+inline void ErrlEntry::setModuleId( const uint8_t i_moduleId )
{
- return (iv_eventType);
+ iv_modId = i_moduleId;
+ return;
}
+
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
+inline errlEventType_t ErrlEntry::eventType() const
+{
+ return iv_eventType;
+}
+
inline void ErrlEntry::setEventType(const errlEventType_t i_eventType)
{
iv_eventType = i_eventType;
return;
}
+
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
inline epubSubSystem_t ErrlEntry::subSys() const
{
- return (iv_subSys);
+ return iv_subSys;
}
-////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////
inline void ErrlEntry::setSubSys(const epubSubSystem_t i_subSys)
{
iv_subSys = i_subSys;
@@ -413,11 +488,9 @@ inline void ErrlEntry::setSubSys(const epubSubSystem_t i_subSys)
////////////////////////////////////////////////////////////////////////////
inline srcType_t ErrlEntry::srcType() const
{
- return (iv_srcType);
+ return iv_srcType;
}
-////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////
inline void ErrlEntry::setSrcType(const srcType_t i_srcType)
{
iv_srcType = i_srcType;
@@ -428,11 +501,9 @@ inline void ErrlEntry::setSrcType(const srcType_t i_srcType)
////////////////////////////////////////////////////////////////////////////
inline errlTermState_t ErrlEntry::termState() const
{
- return (iv_termState);
+ return iv_termState;
}
-////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////
inline void ErrlEntry::setTermState(const errlTermState_t i_termState)
{
iv_termState = i_termState;
@@ -440,18 +511,10 @@ inline void ErrlEntry::setTermState(const errlTermState_t i_termState)
}
////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////
-inline uint32_t ErrlEntry::logId() const
-{
- return (iv_logId);
-}
-
-////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////
+// Called by errlmanager at log commit time.
inline void ErrlEntry::setLogId(const uint32_t i_val)
{
iv_logId = i_val;
- return;
}
} // End namespace
diff --git a/src/include/usr/errl/errlmanager.H b/src/include/usr/errl/errlmanager.H
index 559353d87..445188f5a 100644
--- a/src/include/usr/errl/errlmanager.H
+++ b/src/include/usr/errl/errlmanager.H
@@ -14,10 +14,15 @@
#include <stdlib.h>
#include <util/singleton.H>
#include <errl/errltypes.H>
+#include <sys/sync.h>
+#include <vector>
+#include <kernel/timemgr.H>
namespace ERRORLOG
{
+
+
/**
* @brief Global function to log an error
* Writes the log to PNOR where committed logs are kept.
@@ -79,7 +84,7 @@ public:
* @brief Returns a unique error log ID
*
* This routine generates a unique Error ID and assign it to
- * the input error log
+ * the input error log. Mutates iv_currLogId.
*
* @return Unique generated error log ID
*/
@@ -112,9 +117,28 @@ private:
ErrlManager(const ErrlManager& i_right);
ErrlManager& operator=(const ErrlManager& i_right);
-
+ /**
+ * @brief
+ * Current log ID: increment this when assigning log ID to a new errlog
+ * as it is being committed.
+ */
uint32_t iv_currLogId;
+
+ /**
+ * @brief
+ * Pointer to the header that preceeds the error log storage buffer
+ * in L3 RAM. This may go away when we adopt PNOR, or else become
+ * instance variables instead of a pointer pointing within the
+ * storage buffer.
+ */
+ storage_header_t * iv_pStorage;
+
+ /**
+ * @brief Serialization for error log commits.
+ */
+ mutex_t iv_mutex;
+
};
} // End namespace
diff --git a/src/include/usr/errl/errltypes.H b/src/include/usr/errl/errltypes.H
index ca1deef9f..94f630f72 100644
--- a/src/include/usr/errl/errltypes.H
+++ b/src/include/usr/errl/errltypes.H
@@ -8,6 +8,9 @@
* This header file contains the definition of ErrlEntry related
* parameters.
*
+ * This file will be included by error log parsers that run
+ * on pool machines, so the stuff in here needs to be generic.
+ *
*/
/**
@@ -55,7 +58,8 @@ namespace ERRORLOG
{
/**
- * @brief Enumeration of error log severity
+ * @brief Enumeration of error log severity.
+ * Needs to fit into 1 byte for flattening purposes.
*/
enum errlSeverity_t
{
@@ -67,11 +71,12 @@ enum errlSeverity_t
/**
* @brief Event (error) type
+ * Needs to fit into 1 byte for flattening purposes.
*/
enum errlEventType_t
{
- ERRL_ETYPE_NOT_APPLICABLE = 0,
- ERRL_ETYPE_DUMP_NOTIFICATION = 8,
+ ERRL_ETYPE_NOT_APPLICABLE = 0x00,
+ ERRL_ETYPE_DUMP_NOTIFICATION = 0x08,
ERRL_ETYPE_USER_DECONFIG = 0x20,
ERRL_ETYPE_SYS_DECONFIG = 0x21,
ERRL_ETYPE_CONCURRENT_MAINTENANCE = 0x40,
@@ -80,6 +85,7 @@ enum errlEventType_t
/**
* @brief Error log call out priority
+ * Needs to fit into 1 byte for flattening purposes.
*/
enum callOutPriority_t
{
@@ -90,6 +96,7 @@ enum callOutPriority_t
/**
* @brief Error log procedure Id
+ * Needs to fit into 1 byte for flattening purposes.
*/
enum epubProcedureId_t
{
@@ -98,6 +105,7 @@ enum epubProcedureId_t
/**
* @brief Sub system definitions
+ * Needs to fit into 1 byte for flattening purposes.
*/
enum epubSubSystem_t
{
@@ -107,6 +115,7 @@ enum epubSubSystem_t
/**
* @brief Terminating flag definitions
+ * Needs to fit into 1 word (32-bits) for flattening purposes.
*/
enum errlTermState_t
{
@@ -117,6 +126,7 @@ enum errlTermState_t
/**
* @brief SRC type definitions
+ * Needs to fit into 1 byte for flattening purposes.
*/
enum srcType_t
{
@@ -127,6 +137,89 @@ enum srcType_t
};
+/**
+ * @brief This is the size of the storage buffer, presently
+ * in L3 RAM. When this storage is filled, no more error logs
+ * will be committed. The L3 RAM storage is g_ErrlStorage[]
+ * declared in errlmanager.C in BSS data. This will change
+ * when switching to PNOR.
+ */
+const uint32_t ERRL_STORAGE_SIZE = 65536;
+
+
+
+/**
+ * @brief Flattened error log header structure contains the basic
+ * instance variables of the ErrlEntry class. Note the
+ * alignment of the fields, and that the structure is packed.
+ */
+typedef struct errl_header
+{
+ uint32_t cbytes; // count of bytes in this struct
+ uint32_t csections; // count of sections in this error log
+ uint16_t reasonCode; // reason code
+ uint8_t unused1; // need this for alignment
+ uint8_t modId; // module id
+ uint8_t sev; // severity
+ uint8_t eventType; // event type
+ uint8_t subSys; // subsystem
+ uint8_t srcType; // SRC type
+ uint32_t termState; // Terminate state
+ uint32_t logId; // This log's unique ID
+ uint64_t user1; // Optional user data 1
+ uint64_t user2; // Optional user data 2
+ uint64_t CreationTime; // time error log was created
+} __attribute__((packed)) errl_header_t;
+
+
+
+/**
+ * @brief Error logs may have a number of sections/FFDC sections added.
+ * This is a section header that preceeds the user-defined
+ * data that follows this header. Note the alignment of the fields,
+ * and that this structure is packed.
+ */
+typedef struct section_header
+{
+ uint32_t cbHeader; // count of bytes in this struct (flattening)
+ uint32_t cbSection; // count of bytes in the user-added data
+ uint16_t compId; // component id
+ uint8_t sctnVer; // section version
+ uint8_t subSect; // subsection
+} __attribute__((packed)) section_header_t;
+
+
+/**
+ * @brief The RAM storage for committed error logs starts with this
+ * header. This structure is org'ed at &g_ErrlStorage[0]. All
+ * offsets are based from &g_achErrlStorage[0], so the first
+ * marker will appear at offset sizeof( storage_header_t )
+ */
+typedef struct storage_header
+{
+ uint32_t cbStorage; // count of bytes in buffer
+ uint32_t cInserted; // count of logs ever commited
+ uint32_t offsetStart; // start-of-list marker
+ uint32_t offsetMarker; // next-insertion marker
+} __attribute__((packed)) storage_header_t;
+
+
+
+
+/**
+ * @brief The storage buffer is a series of flattened error logs
+ * interspersed with markers.
+ * A typical marker will give the offset to the next marker and also
+ * the length of the flattened error log data.
+ */
+typedef struct marker
+{
+ uint32_t offsetNext;
+ uint32_t length;
+} __attribute__((packed)) marker_t;
+
+
+
} // End namespace
#endif // ERRLTYPES_H
OpenPOWER on IntegriCloud