summaryrefslogtreecommitdiffstats
path: root/src/usr/errl/errluh.C
blob: cdaaa16195e54951d1c93ffb53a01bbc76aee17c (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/errl/errluh.C $
//
//  IBM CONFIDENTIAL
//
//  COPYRIGHT International Business Machines Corp. 2011
//
//  p1
//
//  Object Code Only (OCO) source materials
//  Licensed Internal Code Source Materials
//  IBM HostBoot Licensed Internal Code
//
//  The source code for this program is not published or other-
//  wise divested of its trade secrets, irrespective of what has
//  been deposited with the U.S. Copyright Office.
//
//  Origin: 30
//
//  IBM_PROLOG_END
/**
 *  @file errluh.C
 *
 *  @brief  Code to manage the contents of the user header
 *  section of an error log.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hbotcompid.H>
#include <errl/errlentry.H>




namespace ERRORLOG
{


extern trace_desc_t* g_trac_errl;


/*****************************************************************************/
// Constructor

ErrlUH::ErrlUH( errlSeverity_t i_sev  ) :
  iv_header( ERRL_SID_USER_HEADER,
             ErrlUH::SLEN,
             ErrlUH::VER,
             ErrlUH::SST,
             0),   // Component ID is zero until commit time
  iv_severity( i_sev ),
  iv_etype( ERRL_ETYPE_NOT_APPLICABLE ),
  iv_ssid( EPUB_FIRMWARE_SUBSYS  ),   // 0x80 here yields SRC B180xxxx
  iv_domain( ERRL_DOMAIN_DEFAULT ),
  iv_vector( ERRL_VECTOR_DEFAULT ),
  iv_actions( ERRL_ACTION_NONE ),
  iv_scope( ERRL_SCOPE_PLATFORM )
{

}



/***************************************************************************/
// Data Export

uint64_t ErrlUH::flatten( void * io_pBuffer, const uint64_t i_cbBuffer )
{
    uint64_t l_rc = 0;


    // compile-type assertion
    CPPASSERT( 24 == sizeof( pelUserHeaderSection_t ));


    if( i_cbBuffer >= iv_header.iv_slen )
    {
        pelUserHeaderSection_t * p;
        p = static_cast<pelUserHeaderSection_t*>(io_pBuffer);
        memset( p, 0, sizeof(*p));

        // Get the ErrlSctnHdr to flatten its data first.
        iv_header.flatten( &p->sectionheader, i_cbBuffer );

        // Set the ErrlUH instance data items in to the
        // flat user header PEL struct.
        p->ssid              = iv_ssid;
        p->scope             = iv_scope;
        p->sev               = iv_severity;
        p->etype             = iv_etype;
        p->domain            = iv_domain;
        p->vector            = iv_vector;
        p->actions           = iv_actions;

        // Return count of bytes flattened
        l_rc = iv_header.iv_slen;
    }
    else
    {
         TRACFCOMP( g_trac_errl, "ErrlUH::flatten: buffer too small" );
    }
    return l_rc;
}






}  // namespace
OpenPOWER on IntegriCloud