blob: 10eccbc669451550edaefd14245081f34584a89a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/**
* @file errlmanager.C
*
* @brief Implementation of ErrlManager class
*/
/*****************************************************************************/
// I n c l u d e s
/*****************************************************************************/
#include <errl/errlmanager.H>
#include <trace/interface.H>
#include <errl/errlentry.H>
namespace ERRORLOG
{
extern trace_desc_t* g_trac_errl;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
ErrlManager::ErrlManager()
:iv_currLogId(0)
{
//@todo
// This is done in order to avoid reading logID from PNOR for every
// error log created.
// When ErrlManager singleton instantiated:
// 1. Parse the last committed error from PNOR
// 2. Get the logID from that error
// 3. Load iv_currLogId with that value.
// 4. When next error is committed, assign the next ID value to it
// before writing to PNOR.
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
ErrlManager::~ErrlManager()
{
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void ErrlManager::commitErrLog(errlHndl_t& io_err)
{
// If NULL, put out warning trace
if (io_err == NULL)
{
TRACFCOMP(g_trac_errl, "commitErrLog() - NULL pointer");
}
else
{
TRACFCOMP( g_trac_errl, "commitErrLog()> Reasoncode=%X, Id=%d", io_err->reasonCode(), io_err->logId() );
//@fixme - an id is already assigned in the constructor, which one do we want?
// Assign a unique error ID to the committed log
//uint32_t l_errId = getUniqueErrId();
//io_err->setLogId(l_errId);
// @todo:
// - Flatten error into PNOR
delete io_err;
io_err = NULL;
}
return;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
uint32_t ErrlManager::getUniqueErrId()
{
return (__sync_add_and_fetch(&iv_currLogId, 1));
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void errlCommit(errlHndl_t& io_err)
{
ERRORLOG::theErrlManager::instance().commitErrLog(io_err);
return;
}
} // End namespace
|