summaryrefslogtreecommitdiffstats
path: root/src/include/usr/dump/dumpif.H
blob: 0b616be747ea5cbca974621f31142d02b123d0e7 (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/dump/dumpif.H $                               */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2012,2020                        */
/* [+] 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 __DUMPIF_H
#define __DUMPIF_H

#include <hdat/hdat.H>

/** @file  dumpif.H
 *  @brief Provides the external interfaces for dump.
 *            - copy dump data from src to destination
 *            - Send Mbox Msg for dump status
 */

namespace DUMP
{

    /**
     * @brief DUMP Message Types 
     */

    enum DUMP_MSG_TYPE
    {
        DUMP_MSG_START_MSG_TYPE = 0x000000B1,
        DUMP_MSG_END_MSG_TYPE = 0x000000B2,
        DUMP_MSG_ERROR_MSG_TYPE = 0x000000B3,

    };

    // The following are #defines  needed for Dump Testing.. These are the
    // default memory locations for MDST, MDDT, MDRT when running withoutPHYPab
    // The data range is defined in vmmconst.h so this test space is saved.

    /* Chunk of physical memory used for Dump Source Table */
    #define DUMP_TEST_SRC_MEM_ADDR  DUMP_TEST_MEMORY_ADDR
    #define DUMP_TEST_SRC_MEM_SIZE  MEGABYTE

    /* Chunk of physical memory used for Dump Destination Table */
    #define DUMP_TEST_DST_MEM_ADDR (DUMP_TEST_SRC_MEM_ADDR +  \
    DUMP_TEST_SRC_MEM_SIZE)


    #define DUMP_TEST_DST_MEM_SIZE  MEGABYTE

    /* Chunk of physical memory used for Dump Results Table */
    #define DUMP_TEST_RESULTS_MEM_ADDR (DUMP_TEST_DST_MEM_ADDR + \
    DUMP_TEST_DST_MEM_SIZE)


    #define DUMP_TEST_RESULTS_MEM_SIZE   MEGABYTE

    // Data location where the src, destination tables point to. (The actual
    // data)
    #define DUMP_TEST_SRC_DATA_AREA (DUMP_TEST_RESULTS_MEM_ADDR +   \
    DUMP_TEST_RESULTS_MEM_SIZE)


    #define DUMP_TEST_DST_DATA_AREA (DUMP_TEST_SRC_DATA_AREA + \
    DUMP_TEST_DATA_SIZE)

    #define DUMP_TEST_DATA_SIZE           MEGABYTE

    // default enums to point out the start and end of the DUMP Tables in memory
    #define DUMP_TEST_TABLE_START DUMP_TEST_SRC_MEM_ADDR
    #define DUMP_TEST_TABLE_SIZE (DUMP_TEST_SRC_MEM_SIZE +   \
    DUMP_TEST_DST_MEM_SIZE + DUMP_TEST_RESULTS_MEM_SIZE)


    #define DUMP_TEST_TABLE_END (DUMP_TEST_TABLE_START + DUMP_TEST_TABLE_SIZE)

    // In addition to the dump table locations we have scratch data area that is
    // used to put the SRC data that the MDST will point to.

    // This is the size of all the Data used for Dump testing
    #define DUMP_TEST_ALL_SIZE  (DUMP_TEST_TABLE_SIZE + (2*MEGABYTE))

    // This is the ending address of test Data area
    #define DUMP_TEST_ALL_END  (DUMP_TEST_TABLE_START + DUMP_TEST_ALL_SIZE)


    //These structures are defined in the HDAT spec
    //The MDST and MDDT have this format.
    struct dumpEntry
    {
        uint64_t dataAddr;
        uint16_t data_type;    // Used by payload
        uint16_t reserved;
        uint32_t dataSize;
    } PACKED;

    //The MDRT has this format.
    struct resultsEntry
    {
        uint64_t srcAddr;
        uint64_t destAddr;
        uint64_t dataSize;
        uint64_t reserved;
    } PACKED;


    // Processor Dump Area table format
    struct procDumpAreaEntry
    {
        uint32_t threadRegSize;        // Architected reg data size per thread
        uint8_t  threadRegVersion;     // Data format version
        uint8_t  reserved1[11];        // Reserved
        uint64_t dstArrayAddr;         // Hypervisor passed destination addresss
        uint8_t  reserved2[4];         // Reserved
        uint32_t dstArraySize;         // Hypervisor passed destination size
        uint64_t capArrayAddr;         // Actual destination address (filled by HB)
        uint8_t  reserved3[4];         // Reserved
        uint32_t capArraySize;         // Actual destination size (filled by HB)
    } PACKED;

    // Host formatted architected register data content (as per HDAT spec)
    struct hostArchRegDataHdr
    {
        uint32_t pir;
        uint8_t  coreState;
        uint8_t  reserved[3];
        HDAT::hdatHDIFDataArray_t iv_regArrayHdr;
    } PACKED;

    #define DUMP_ARCH_REG_TYPE_GPR	0x01
    #define DUMP_ARCH_REG_TYPE_SPR	0x02

    // Architected register data content entries
    union reg_t
    {
        char name[sizeof(uint32_t)*2];
        struct
        {
            uint32_t type;
            uint32_t num;
        }PACKED;
    }PACKED;

    struct hostArchRegDataEntry
    {
        reg_t reg;
        uint64_t regVal;
    } PACKED;

    // Structure version used to share SPR/GPR register data between
    // SBE and HB
    #define REG_DUMP_SBE_HB_STRUCT_VER 0x1

    // Structure version used to share SPR/GPR register data between
    // HB and OPAL
    #define REG_DUMP_HDAT_STRUCT_VER 0x1

    /* Processor architected dump header. This header is per processor*/
    struct sbeArchRegDumpProcHdr_t
    {
        uint8_t  ownerId;        /* FSP or SBE */
        uint8_t  version;        /* Interface version number*/
        uint16_t core_cnt;       /* Actual number of core whose register  data will be obtained */
        uint16_t thread_cnt;     /* Total number of thread whose register data will be obtained */
        uint16_t reg_cnt;        /* Max number of registers per thread */
    } PACKED;   //8Bytes

    // SBE formatted architected registers data
    // (Common structure between SBE and Hostboot)
    struct sbeArchRegDumpThreadHdr_t
    {
        uint32_t  pir;         // PIR value of thread corresponding to register
        uint32_t  coreState:8; // State of core in which this thread is present
        uint32_t  reserved:24;
    } PACKED;

    /**
     *  @brief Defines the structure for storing the SPR/GPR register data
     *
     *  @var isRegDataValid   :'1'- Variable regVal will contain valid register 
     *                         '0'- Variable regVal will contain fapiRC value
     *
     *  @var isLastReg        :'1' - Data is collected for the last SPR/GPR register
     *                         '0' - otherwise.
     *
     *  @var isFfdcPresent    :'1' - Failing FAPI FFDC is shared
     *                         '0' - Failing FFDC is not present
     *
     *  @var reserved0        :Reserved for future use and padding
     *
     *  @var regType          :Indicates type of register(SPR/GPR)
     *
     *  @var reserved1        :Reserved for future use and padding
     *
     *  @var regNum           :Address of the SPR/GPR register
     *
     *  @var regVal           :if isRegDataValid is '0'  - Valid Register value
     *                            isRegDataValid is '!=0'- fapiRC value.
     */
    struct sbeArchRegDumpEntries_t
    {
        uint64_t isRegDataValid:1;
        uint64_t isLastReg:1;
        uint64_t isFfdcPresent:1;
        uint64_t reseverd0:5;
        uint64_t regType:8;
        uint64_t reserved1:16;
        uint64_t regNum:32;
        uint64_t regVal;
    } PACKED;

    /**
    * @brief This function copies the architected register data content
    * from SBE reserved memory to hypervisor allocated memory
    *
    * @param[in]   void
    *
    * @return  errlHndl_t
    */
    errlHndl_t copyArchitectedRegs(void);

    /**
     * @brief This function is a wrapper function that calls
     *   getHostDataPtrs to get the MDDT, MDST, MDRT pointers
     *   and then passes those values to the copySrcToDest
     *   routine that performs the copy
     *
     * @param[in]   void
     *
     * @return  errlHndl_t
     */
     errlHndl_t doDumpCollect(void);

     /**
      * @brief This function copies the data and sizes retrieved from the
      * MDST(source table) to the addresses indicated by the MDDT(destination
      * table).   Each write is then logged in the MDRT (results table) with
      * source addr, destination addr and size
      *
      * @param[in]   srcTableEntry     Ptr to the first MDST entry
      * @param[in]   srcTableSize      Size of the entire MDST
      *
      * @param[in]   destTableAddr     Ptr to the first MDDT entry
      * @param[in]   destTableSize     Size of the entire MDDT
      *
      * @param[in]   resultsTableAddr  Ptr to the first MDRT entry
      * @param[in]   resultsTableSize  Size of the entire MDRT
      *
      * @return  errlHndl_t
      */
     errlHndl_t copySrcToDest(dumpEntry *srcTableEntry, uint64_t srcTableSize,
                              dumpEntry *destTableEntry, uint64_t destTableSize,
                              resultsEntry *resultsTableEntry,
                              uint64_t resultsTableSize);

    /**
     * @brief This function handles sending the mailbox message to the Fsp to
     *      notify of Dump Status.  Start, error or complete.  If Error or
     *      complete types are requested, the dump results table is passed
     *      to the FSP.
     *
     * @param[in] i_type - The type of DUMP msg being written.
     *
     * @return errlHndl_t - NULL if successful, otherwise a pointer to the error
     *      log.
     */
    errlHndl_t sendMboxMsg (DUMP_MSG_TYPE i_type);



} // end of namespace


#endif
OpenPOWER on IntegriCloud