summaryrefslogtreecommitdiffstats
path: root/src/include/usr/errl/errlsctnhdr.H
blob: 12e3bef28e9b4cd2e890f3d71885a7022b05a90d (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/errl/errlsctnhdr.H $                          */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2011,2014              */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef ERRLSCTNHDR_H
#define ERRLSCTNHDR_H
/**
 *  @file errlsctnhdr.H
 *
 *  @brief  This file contain the class that abstracts the header of
 *  an error log section.  Every section in PEL binary data starts with
 *  eight bytes of data. This class manages those 8 bytes for all manner
 *  of PEL sections, including PH (private header), UH (user header),
 *  UD (user defined), etc.
 *
 */

/*****************************************************************************/
// I n c l u d e s
/*****************************************************************************/
#include <stdint.h>
#include <stdlib.h>
#include <errl/hberrltypes.H>
#include <hbotcompid.H>
#include <string.h>

namespace ERRORLOG
{

/**
 *  @brief class ErrlSctnHdr abstracts a header of each PEL section in an
 *  error log object. Objects of classes ErrlSctn, ErrlUH, ErrlPrvt
 *  have one of these.
 */
class ErrlSctnHdr
{


    // All these classes have a ErrlSctnHdr
    friend class ErrlSctn;
    friend class ErrlPrvt;
    friend class ErrlUH;
    friend class ErrlUD;
    friend class ErrlSrc;
    friend class ErrlEntry;



private:

    /**
     * @brief Section header constructor
     *
     * Comp ID, section type and version uniquely identify exactly what
     * kind of a section it is. These fields can be used by a post-dump
     * parser to call the user-supplied parser code to interpret and
     * the data nicely.
     *
     * @param[in]   i_sid           Section ID destined for iv_sid
     * @param[in]   i_slen          Section length
     * @param[in]   i_ver           Section version
     * @param[in]   i_sst           Subsection type
     * @param[in]   i_compId        Component Id of the caller
     *
     * @return void
     */
    ErrlSctnHdr( const uint16_t     i_sid,
                 const uint16_t     i_slen,
                 const uint8_t      i_ver,
                 const uint8_t      i_sst,
                 const compId_t     i_compId );




    /**
     * @brief   Default destructor
     *
     * @return void
     */
    ~ErrlSctnHdr();



    /**
     * @brief   Disabled copy constructor and assignment operator
     */
    ErrlSctnHdr(const ErrlSctnHdr& i_right);
    ErrlSctnHdr& operator=(const ErrlSctnHdr& i_right);




    /**
     * @brief Compute the flattened size of this.
     *
     * @return Size in bytes of the flattened data, which is 8
     * for an ErrlSctnHdr.
     */
    uint64_t flatSize() const;



    /**
     * @brief Flatten to buffer provided.
     *
     * @param[in,out]  o_buffer    Points to data block to be filled
     * @param[in]      i_cbBuffer  Count of bytes in buffer supplied
     *
     * @return  Count of bytes copied to caller's
     *          buffer or else zero if it does not fit.
     */
    uint64_t flatten( void * o_pbuffer, const uint64_t i_cbBuffer );

    /**
     * @brief Import flattened data 
     * @param[in] i_buf, pointer to flattened data
     * @return number of bytes consumed in the flattened data
     */
    uint64_t unflatten( const void * i_buf );


    // Instance data.
    uint16_t  iv_sid;         // section id  'PH' 'UH' etc (errlSectionId_t)
    uint16_t  iv_slen;        // section length
    uint8_t   iv_ver;         // section version
    uint8_t   iv_sst;         // subsection type
    compId_t  iv_compId;      // hostboot component id


};



//***************************************************************************

inline uint64_t ErrlSctnHdr::flatSize() const
{
    // 2 for section id (errlSectionId)
    // 2 for section len
    // 1 for ver
    // 1 for subsection type
    // 2 for component id
    CPPASSERT( 8 == sizeof( pelSectionHeader_t ));
    return sizeof( pelSectionHeader_t );
}

} // End namespace

#endif //ERRLSCTNHDR_H

OpenPOWER on IntegriCloud