summaryrefslogtreecommitdiffstats
path: root/src/occApplet/productApplet/cmdhDbugCmd.c
blob: 2ef7788654148705afc9081d113c52248d7b3501 (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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/******************************************************************************
// @file cmdhDebugCmd.c
// @brief CMDH Debug Command
*/
/******************************************************************************
 *
 *       @page ChangeLogs Change Logs
 *       @section cmdhDbugCmd.c CMDHDEBUGCMD.c
 *       @verbatim
 *
 *   Flag    Def/Fea    Userid    Date        Description
 *   ------- ---------- --------  ----------  ----------------------------------
 *   @th00d             thallet   04/25/2012  created
 *   @nh004   864941    neilhsu   12/20/2012  Support get/delete errl & added trace info
 *   @th031   878471    thallet   04/15/2013  Centaur Throttles
 *   @th032             thallet   04/26/2013  Tuleta HW Bringup
 *   @th036   881677    thallet   05/07/2013  Cleanup
 *   @gm006  SW224414   milesg    09/16/2013  Reset and FFDC improvements
 *   @rt001  897459     tapiar    10/02/2013  Update module ids with unique ids
 *   @fk002  905632     fmkassem  11/05/2013  Remove CriticalPathMonitor code
 *
 *  @endverbatim
 *
 *///*************************************************************************/


//*************************************************************************
// Includes
//*************************************************************************
#include <common_types.h>       // imageHdr_t declaration and image header macro
#include <occ_service_codes.h>  // For reason code
#include <aplt_service_codes.h> // For test applet module ID
#include <errl.h>               // For error handle
#include <trac.h>               // For traces
#include <state.h>
#include <appletId.h>
#include <cmdhDbugCmd.h>
#include <cmdh_fsp.h>
#include <cmdh_fsp_cmds.h>
#include <centaur_data.h>
#include <gpe_data.h>
#include <proc_data.h>
#include <apss.h>

//*************************************************************************
// Externs
//*************************************************************************

//*************************************************************************
// Macros
//*************************************************************************

//*************************************************************************
// Defines/Enums
//*************************************************************************
#define CMDH_DBUG_APPLET_ID  "Cmdh_Dbug_Aplt\0"

//*************************************************************************
// Structures
//*************************************************************************

//*************************************************************************
// Globals
//*************************************************************************

//*************************************************************************
// Function Prototypes
//*************************************************************************

//*************************************************************************
// Functions
//*************************************************************************

// Function Specification
//
// Name:  dbug_err_inject
//
// Description: Injects an error
//
// Flow:  --/--/--    FN=
//
// End Function Specification
void dbug_err_inject(const cmdh_fsp_cmd_t * i_cmd_ptr,
                           cmdh_fsp_rsp_t * i_rsp_ptr)  // @nh004c
{
    errlHndl_t l_err;
    cmdh_dbug_inject_errl_query_t *l_cmd_ptr = (cmdh_dbug_inject_errl_query_t*) i_cmd_ptr;

    i_rsp_ptr->data_length[0] = 0;
    i_rsp_ptr->data_length[1] = 0;
    i_rsp_ptr->rc = ERRL_RC_SUCCESS;

    if(!strncmp(l_cmd_ptr->comp, "RST", OCC_TRACE_NAME_SIZE)) //@gm006
    {
        l_err = createErrl(TEST_APLT_MODID_ERRLTEST,     //modId
                           INTERNAL_FAILURE,             //reasoncode
                           OCC_NO_EXTENDED_RC,           //Extended reason code
                           ERRL_SEV_PREDICTIVE,          //Severity
                           NULL,                         //Trace Buf
                           DEFAULT_TRACE_SIZE,           //Trace Size
                           0xff,                         //userdata1
                           0);                           //userdata2

        if (INVALID_ERR_HNDL == l_err)
        {
            i_rsp_ptr->rc = ERRL_RC_INTERNAL_FAIL;
        }

        addCalloutToErrl(l_err,
                         ERRL_CALLOUT_TYPE_HUID,         //callout type (HUID/CompID)
                         G_sysConfigData.proc_huid,      //callout data
                         ERRL_CALLOUT_PRIORITY_HIGH);    //priority

        REQUEST_RESET(l_err);
    }
    else
    {
        l_err = createErrl(TEST_APLT_MODID_ERRLTEST,     //modId
                           INTERNAL_FAILURE,             //reasoncode
                           OCC_NO_EXTENDED_RC,           //Extended reason code
                           ERRL_SEV_UNRECOVERABLE,       //Severity
                           TRAC_get_td(l_cmd_ptr->comp), //Trace Buf
                           DEFAULT_TRACE_SIZE,           //Trace Size
                           0xff,                         //userdata1
                           0);                           //userdata2

        if (INVALID_ERR_HNDL == l_err)
        {
            i_rsp_ptr->rc = ERRL_RC_INTERNAL_FAIL;
        }

        // Commit Error log
        commitErrl(&l_err);
    }

    if (i_rsp_ptr->rc == ERRL_RC_INTERNAL_FAIL)
    {
        TRAC_ERR("cmdh_dbug_inject_errl: Fail creating ERR Log\n");
    }
    else
    {
        TRAC_INFO("cmdh_dbug_inject_errl: inject errl for COMP : %s\n", l_cmd_ptr->comp);
    }

    return;
}

// Function Specification
//
// Name:  dbug_centaur_dump
//
// Description: Injects an error
//
// Flow:  --/--/--    FN=
//
// End Function Specification
void dbug_centaur_dump(const cmdh_fsp_cmd_t * i_cmd_ptr,
                             cmdh_fsp_rsp_t * i_rsp_ptr)  // @nh004c
{
    uint16_t l_datalen = 0;
    uint8_t l_jj=0;

    // Determine the size of the data we are returning
    l_datalen = (sizeof(MemData) * MAX_NUM_CENTAURS);

    // Fill out the response with the data we are returning
    for(l_jj=0; l_jj < MAX_NUM_CENTAURS; l_jj++)
    {
        MemData * l_sensor_cache_ptr =
            cent_get_centaur_data_ptr(l_jj);

        memcpy((void *) &(i_rsp_ptr->data[l_jj*sizeof(MemData)]),
                (void *) l_sensor_cache_ptr,
                sizeof(MemData));
    }

    // Fill out the rest of the response data
    i_rsp_ptr->data_length[0] = CONVERT_UINT16_UINT8_HIGH(l_datalen);
    i_rsp_ptr->data_length[1] = CONVERT_UINT16_UINT8_LOW(l_datalen);
    i_rsp_ptr->rc             = ERRL_RC_SUCCESS;


    return;
}


// Function Specification
//
// Name:  dbug_apss_dump
//
// Description: Dumps the APSS power measurement raw ADC / GPIO data
//
// Flow:  --/--/--    FN=
//
// End Function Specification
void dbug_apss_dump(const cmdh_fsp_cmd_t * i_cmd_ptr,
                          cmdh_fsp_rsp_t * i_rsp_ptr)
{
    uint16_t l_datalen = 0;

    // Determine the size of the data we are returning
    l_datalen = (sizeof(apssPwrMeasStruct_t));

    memcpy((void *) &(i_rsp_ptr->data[0]),
                (void *) &G_apss_pwr_meas,
                sizeof(apssPwrMeasStruct_t));

    // Fill out the rest of the response data
    i_rsp_ptr->data_length[0] = CONVERT_UINT16_UINT8_HIGH(l_datalen);
    i_rsp_ptr->data_length[1] = CONVERT_UINT16_UINT8_LOW(l_datalen);
    i_rsp_ptr->rc             = ERRL_RC_SUCCESS;


    return;
}


// Function Specification
//
// Name:  dbug_proc_data_dump
//
// Description: Dumps the processor core data
//
// Flow:  --/--/--    FN=
//
// End Function Specification
void dbug_proc_data_dump(const cmdh_fsp_cmd_t * i_cmd_ptr,
                               cmdh_fsp_rsp_t * i_rsp_ptr)
{
    uint16_t l_datalen = 0;
    uint8_t l_jj=0;

    // Determine the size of the data we are returning
    l_datalen = (sizeof(CoreData) * MAX_NUM_CORES);

    // Fill out the response with the data we are returning
    for(l_jj=0; l_jj < MAX_NUM_CORES; l_jj++)
    {
        CoreData * l_core_data_ptr =
            proc_get_bulk_core_data_ptr(l_jj);

        memcpy((void *) &(i_rsp_ptr->data[l_jj*sizeof(CoreData)]),
                (void *) l_core_data_ptr,
                sizeof(CoreData));
    }

    // Fill out the rest of the response data
    i_rsp_ptr->data_length[0] = CONVERT_UINT16_UINT8_HIGH(l_datalen);
    i_rsp_ptr->data_length[1] = CONVERT_UINT16_UINT8_LOW(l_datalen);
    i_rsp_ptr->rc             = ERRL_RC_SUCCESS;


    return;
}

// Function Specification
//
// Name:  cmdhDbugCmd
//
// Description:   Entry-point for CMDH Debug Commands
//
// Flow: --/--/--    FN=
//
// End Function Specification
errlHndl_t cmdhDbugCmd(void * i_arg)
{
    errlHndl_t               l_errl    = NULL;
    cmdhDbugCmdAppletArg_t * l_arg     = (cmdhDbugCmdAppletArg_t *) i_arg;
    cmdh_fsp_cmd_t *         l_cmd_ptr = l_arg->i_cmd_ptr;
    cmdh_fsp_rsp_t *         l_rsp_ptr = l_arg->io_rsp_ptr;
    uint8_t                  l_sub_cmd = 0;

    // Sub Command for debug is always first byte of data
    l_sub_cmd = l_cmd_ptr->data[0];

    // Trace that a debug command was run
    TRAC_INFO("Debug Command via Applet: Sub:0x%02x\n", l_sub_cmd);

    // Build up a successful default response
    l_rsp_ptr->rc = ERRL_RC_SUCCESS;
    l_rsp_ptr->data_length[0] = 0;
    l_rsp_ptr->data_length[1] = 0;

    switch ( l_sub_cmd )
    {
        case DBUG_INJECT_ERRL:
            dbug_err_inject(l_cmd_ptr, l_rsp_ptr);
            break;

        case DBUG_CENTAUR_SENSOR_CACHE:
             dbug_centaur_dump(l_cmd_ptr, l_rsp_ptr);
             break;

        case DBUG_DUMP_RAW_AD:
             dbug_apss_dump(l_cmd_ptr, l_rsp_ptr);
             break;

        case DBUG_DUMP_PROC_DATA:
             dbug_proc_data_dump(l_cmd_ptr, l_rsp_ptr);
             break;

        case DBUG_READ_SCOM:            // Obsolete
        case DBUG_PUT_SCOM:             // Obsolete
        case DBUG_POKE:                 // Can't allow in trusted
        case DBUG_GET_TRACE:
        case DBUG_CLEAR_TRACE:
        case DBUG_SET_PEXE_EVENT:
        case DBUG_DUMP_THEMAL:
        case DBUG_DUMP_POWER:
        case DBUG_MEM_PWR_CTL:
        case DBUG_PERFCOUNT:
        case DBUG_TEST_INTF:
        case DBUG_SET_BUS_SPEED:        // Obsolete
        case DBUG_FAN_CONTROL:          // Obsolete
        case DBUG_IIC_READ:             // Obsolete
        case DBUG_IIC_WRITE:            // Obsolete
        case DBUG_GPIO_READ:
        case DBUG_CALCULATE_MAX_DIFF:
        case DBUG_FORCE_ELOG:
        case DBUG_SWITCH_PHASE:
        case DBUG_INJECT_ERR:
        case DBUG_VERIFY_V_F:
        case DBUG_DUMP_PPM_DATA:
        default:
            l_rsp_ptr->rc = ERRL_RC_INVALID_DATA;
            break;
    } //end switch


    return l_errl;
}





/*****************************************************************************/
// Image Header
/*****************************************************************************/
IMAGE_HEADER (G_cmdhDbugCmd,cmdhDbugCmd,CMDH_DBUG_APPLET_ID,OCC_APLT_CMDH_DBUG);

OpenPOWER on IntegriCloud