summaryrefslogtreecommitdiffstats
path: root/src/usr/expaccess/errlud_expscom.H
blob: acb17bc2c55db9d71e927b164a05c611ab3fffdd (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/expaccess/errlud_expscom.H $                          */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2019                             */
/* [+] 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 __ERRLUD_EXPSCOM_H
#define __ERRLUD_EXPSCOM_H

/**
 *  @file errlud_expscom.H
 *  @brief Utility functions to add Explorer logs to your hostboot error
 */
#include <stdint.h>

#include <errl/errluserdetails.H>

//  targeting support
#include    <targeting/common/commontargeting.H>
#include    <targeting/common/utilFilter.H>

namespace EXPSCOM
{
/**
 * @brief Enum for what kind of Explorer log
 */
enum exp_log_type : uint8_t
{
    ACTIVE_LOG = 1, // RAM error section
    SAVED_LOG  = 2  // SPI flash error section
};

/**
 * @brief Adds Explorer log data to platform log
 *        Grabs explorer error log based on type and then breaks that data
 *        into smaller user-data sections adding them to the platform log.
 *        Note: First section will be the smallest and contain the most recent
 *        trace data.  Probably contains most relevent traces, so try to make
 *        always fit in the error log.
 * @param i_type - what kind of explorer error log to add
 * @param i_ocmb - Explorer target
 * @param io_errl - Platform error log to add logs into
 * @return true if explorer error data added, else false
 */
bool expAddLog( const exp_log_type i_type,
                TARGETING::Target * i_ocmb,
                errlHndl_t & io_errl );



/**
 * @brief Header data of every explorer error log user-data section
 */
struct explog_section_header_t
{
    uint16_t packet_num;      // ordering byte (0 = first packet)
    uint32_t offset_exp_log;  // offset where data portion started in full explorer log
    uint16_t error_data_size; // size of data portion following header

    explog_section_header_t()
      : packet_num(0),
        offset_exp_log(0),
        error_data_size(0)
    {}
} __attribute__((__packed__));

// Break large explorer log data into smaller error sections
// to avoid dropping important debug data.
// Make most important first section smaller so this won't get dropped
const uint16_t FIRST_EXPLORER_DATA_SECTION_SIZE     = 0x0100;
const uint16_t FOLLOWING_EXPLORER_DATA_SECTION_SIZE = 0x0200;


/**
 * @class ExpscomActiveLogUD
 *
 * Adds Explorer Active log information to an error log as user detail
 * Data is from Explorer RAM
 *
 */
class ExpscomActiveLogUD : public ERRORLOG::ErrlUserDetails
{
  public:
    /**
     *  @brief Constructor
     *
     *  @param i_header_info  Meta information added to beginning of section
     *  @param i_data_portion Pointer to portion of Active log data
     *
     */
    ExpscomActiveLogUD( const explog_section_header_t & i_header_info,
                          const uint8_t * i_data_portion );

    /**
     *  @brief Destructor
     */
    virtual ~ExpscomActiveLogUD();

    // Disabled
    ExpscomActiveLogUD() = delete;
    ExpscomActiveLogUD(ExpscomActiveLogUD &) = delete;
    ExpscomActiveLogUD & operator=(ExpscomActiveLogUD &) = delete;
};




/**
 * @class ExpscomSavedLogUD
 *
 * Adds Explorer Saved log information to an error log as user detail
 * Data is from Explorer SPI flash
 *
 */
class ExpscomSavedLogUD : public ERRORLOG::ErrlUserDetails
{
  public:
    /**
     *  @brief Constructor
     *
     *  @param i_header_info  Meta information added to beginning of section
     *  @param i_data_portion Pointer to portion of Saved error data
     *
     */
    ExpscomSavedLogUD( const explog_section_header_t & i_header_info,
                       const uint8_t * i_data_portion );

    /**
     *  @brief Destructor
     */
    virtual ~ExpscomSavedLogUD();

    // Disabled
    ExpscomSavedLogUD() = delete;
    ExpscomSavedLogUD(ExpscomSavedLogUD &) = delete;
    ExpscomSavedLogUD & operator=(ExpscomSavedLogUD &) = delete;
};

}

#endif
OpenPOWER on IntegriCloud