summaryrefslogtreecommitdiffstats
path: root/src/occ_gpe0/firdata/fir_data_collect.c
blob: a2af34fcf0bc0d03b6a0d86d719f9587542f6e32 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/occ_405/firdata/fir_data_collect.c $                      */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,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                                                     */


#include <fir_data_collect.h>
#include <scom.h>
#include <occ_service_codes.h>
#include <errl.h>
#include "tpc_firmware_registers.h"
#include "tpc_register_addresses.h"
#include <trac.h>
#include <homer.h>
#include <firData.h>

FIR_HEAP_BUFFER(uint8_t G_fir_heap[FIR_HEAP_SECTION_SIZE]);
FIR_PARMS_BUFFER(uint8_t G_fir_data_parms[FIR_PARMS_SECTION_SIZE]);
uint32_t G_fir_master = FIR_OCC_NOT_FIR_MASTER;

/*
 * Function Specification
 *
 * Name: fir_data_collect
 *
 * Description: Collects FIR data on checkstop.
 *
 * End Function Specification
 */
void fir_data_collect(void)
{

    int32_t l_rc = 0;

    // Homer data section and size
    uint8_t *l_hBuf = (uint8_t*) FIR_PARMS_SECTION_BASE_ADDRESS;
    uint32_t l_hBufSize = HOMER_FIR_PARM_SIZE;
    // PNOR working buffer in SRAM and size
    uint8_t *l_pBuf = (uint8_t*) FIR_HEAP_SECTION_BASE_ADDRESS;
    uint32_t l_pBufSize = FIR_HEAP_SECTION_SIZE;

    l_rc = FirData_captureCsFirData(l_hBuf,
                                    l_hBufSize,
                                    l_pBuf,
                                    l_pBufSize);

    // Trace the rc only, error logs cannot be collected in this state
    TRAC_IMP("Checkstop FIR data capture completed with rc=%d", l_rc);
}


/*
 * Function Specification
 *
 * Name: pnor_access_ok
 *
 * Description: Determines if it is ok for this OCC to access the PNOR.
 *
 * End Function Specification
 */
// TODO: This code is not allowed currently, as it relies on performing scom operations.
#if 0
bool pnor_access_allowed(void)
{
    /* BMC ownership of the PNOR is indicated by bit 18 in TPC_GP0 */
    int         l_rc = 0;
    tpc_gp0_t   l_tp_gp0_read;
    bool        l_access_allowed = FALSE;

    l_tp_gp0_read.words.high_order = 0x00000000;
    l_tp_gp0_read.words.low_order = 0x00000000;

    l_rc = getscom_ffdc(TPC_GP0, (uint64_t *)&l_tp_gp0_read, NULL);

    if (l_rc == 0)
    {
        if ((l_tp_gp0_read.words.high_order & TPC_GP0_BIT18_PNOR_OWNER_MASK) == 0)
        {
            TRAC_INFO("PNOR access allowed at this time");
            l_access_allowed = TRUE;
        }
        else
        {
            TRAC_INFO("PNOR access NOT allowed at this time, tpc_gp0.hi = 0x%08x",
                     l_tp_gp0_read.words.high_order);

            /* @
             * @errortype
             * @moduleid    FIR_DATA_MID
             * @reasoncode  INTERNAL_FAILURE
             * @userdata1   TPC_GP0 high word
             * @userdata4   ERC_PNOR_OWNERSHIP_NOT_AVAILABLE
             * @devdesc     PNOR access not allowed at this time.
             */
            errlHndl_t l_errl = createErrl(
                        FIR_DATA_MID,                   /*ModId */
                        INTERNAL_FAILURE,               /*Reasoncode */
                        ERC_PNOR_OWNERSHIP_NOT_AVAILABLE,    /*Extended reasoncode */
                        ERRL_SEV_INFORMATIONAL,         /*Severity */
                        NULL,                           /*Trace Buf */
                        DEFAULT_TRACE_SIZE,             /*Trace Size */
                        l_tp_gp0_read.words.high_order, /*Userdata1 */
                        0                               /*Userdata2 */
                        );

            /* Commit log */
            commitErrl(&l_errl);
        }
    }
    else
    {
        /* getscom failure */
        TRAC_ERR("TPC_GP0 getscom failure rc = 0x%08x", -l_rc );

        /* @
         * @errortype
         * @moduleid    FIR_DATA_MID
         * @reasoncode  INTERNAL_HW_FAILURE
         * @userdata1   getscom failure rc
         * @userdata4   ERC_GETSCOM_TPC_GP0_FAILURE
         * @devdesc     Failure determining PNOR ownership.  Cannot read TPC_GP0.
         */
        errlHndl_t l_errl = createErrl(
                    FIR_DATA_MID,                   /*ModId */
                    INTERNAL_HW_FAILURE,            /*Reasoncode */
                    ERC_GETSCOM_TPC_GP0_FAILURE,    /*Extended reasoncode */
                    ERRL_SEV_PREDICTIVE,            /*Severity */
                    NULL,                           /*Trace Buf */
                    DEFAULT_TRACE_SIZE,             /*Trace Size */
                    l_rc,                           /*Userdata1 */
                    0                               /*Userdata2 */
                    );

        /* Callout firmware */
        addCalloutToErrl(l_errl,
                         ERRL_CALLOUT_TYPE_COMPONENT_ID,
                         ERRL_COMPONENT_ID_FIRMWARE,
                         ERRL_CALLOUT_PRIORITY_HIGH);

        /* Commit log */
        commitErrl(&l_errl);
    }

    return l_access_allowed;
}
#endif
OpenPOWER on IntegriCloud