summaryrefslogtreecommitdiffstats
path: root/src/include/usr/sbeio/sbe_ffdc_parser.H
blob: a18d8a1ad527f664d923230606cacfab5b4cfe0d (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/sbeio/sbe_ffdc_parser.H $                     */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2012,2017                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* 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 __SBEFFDC_H
#define __SBEFFDC_H

#include <xscom/piberror.H>

/**
 * @file sbe_ffdc_parser.H
 * @brief SBE FFDC package parser
 */


namespace SBEIO
{

/*
 * @brief Type to hold the ffdc package
 * This struct also holds the size and the RC
*/
struct ffdc_package
{
    void * ffdcPtr;
    uint32_t rc;
    size_t size;
};

class SbeFFDCParser
{
    public:

        /**
         * @brief Constructor
         */
        SbeFFDCParser() = default;

        /**
         * @brief Destructor
         */
        ~SbeFFDCParser();

        /**
         * @brief Parses the FFDC data package
         *  @param[in]  i_ffdcPackageBuffer Memory buffer contains FFDC package
         *
         */
        void parseFFDCData(void * i_ffdcPackageBuffer);

        /**
         * @brief Returns number of FFDC packages found
         *  @retval: number of FFDC packages found
         */
        uint8_t getTotalPackages();

        /**
         * @brief Get the raw ffdc package stored
         *  @retval: return pointer to raw ffdc package
         *  @param[in]  i_index  index number
         */
        void * getFFDCPackage(uint8_t i_index);

        /**
         * @brief Get the return code of the package
         *  @retval: return code of the ffdc package
         *  @param[in]  i_index  index number
         */
        uint32_t getPackageRC(uint8_t i_index);

        /**
         * @brief Returns the size of a ffdc package (bytes)
         *  @retval: length of data stored
         *  @param[in]  i_index  index number
         */
        uint32_t getPackageLength(uint8_t i_index);

        /**
         * @brief: converts fapi2 rc to pib rc
         * @param[in]: i_index index in the ffdc package
         */
        PIB::PibError getPibRc (uint8_t i_index);
    private:

        /**
         * @brief List of ffdc packages
         */
        std::vector<ffdc_package *> iv_ffdcPackages;

        /**
         * @brief constants to keep track while parsing
         */
        const uint16_t iv_ffdcMagicByte = 0xFFDC;
        const uint8_t iv_ffdcWordLen = 4;
        const uint8_t iv_headerWordInBytes = iv_ffdcWordLen * 2;
        const uint8_t iv_ffdcPackageSize = 2;

        /**
         * @brief Store the data words found in FFDC package
         *  @param[in]  i_ffdcPackage   FFDC package to store
         *  @param[in]  i_rc            the RC word
         *  @param[in]  i_packageLen    length of package
         */

        void addFFDCPackage(void * i_ffdcPackage, uint32_t i_rc,
                            uint32_t i_packageLen);

};

}

#endif
OpenPOWER on IntegriCloud