summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/slave_sbe/proc_tp_collect_dbg_data/proc_tp_collect_dbg_data.C
blob: 4ff333420e874916ce9ae49731225d405e7bf327 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/slave_sbe/proc_tp_collect_dbg_data/proc_tp_collect_dbg_data.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,2015                        */
/* [+] 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                                                     */
// $Id: proc_tp_collect_dbg_data.C,v 1.7 2014/10/03 20:25:36 jmcgill Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/proc_tp_collect_dbg_data.C,v $
//------------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2012
// *! All Rights Reserved -- Property of IBM
//------------------------------------------------------------------------------
// *! TITLE       : proc_tp_collect_dbg_data.C
// *! DESCRIPTION : Procedure to collect TP debug data
// *!
// *! OWNER NAME : Benedikt Geukes        Email: bgeukes@de.ibm.com
// *!
// *! ADDITIONAL COMMENTS :
// *!
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//  Includes
//------------------------------------------------------------------------------
#include <proc_tp_collect_dbg_data.H>
#include <utility>
//------------------------------------------------------------------------------
// Constant definitions
//------------------------------------------------------------------------------

const uint32_t PROC_TP_COLLECT_DBG_DATA_FSI_SHIFT_CTRL 	= 0x00000043;
const uint32_t PERV_VITL_CHAIN_RING_ADDRESS = 0x0103800C;
const uint32_t TP_VITL_SPY_MAX_SPY_RANGES = 24;


//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------

extern "C" {

// HWP entry point, comments in header
fapi::ReturnCode proc_tp_collect_dbg_data(const fapi::Target & i_target,
                                          fapi::ReturnCode & o_rc)
{
    fapi::ReturnCode rc;
    uint32_t rc_ecmd = 0;

	ecmdDataBufferBase ring_data;
    ecmdDataBufferBase spy_data;
    uint32_t ring_length;
    uint32_t spy_length;
    uint32_t spy_offsets[TP_VITL_SPY_MAX_SPY_RANGES];
	ecmdDataBufferBase fsi_data(32);
	ecmdDataBufferBase scom_data(64);

    // mark HWP entry
    FAPI_INF("proc_tp_collect_dbg_data: Start");

    do
    {
		// Setting Prevent AutoStart Bit to avoid scan chain corruption
        rc = fapiGetCfamRegister(i_target, CFAM_FSI_SBE_VITAL_0x0000281C, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiGetCfamRegister error (CFAM_FSI_SBE_VITAL_0x0000281c)");
            break;
        }
        
        rc_ecmd |= fsi_data.setBit(1);
        rc_ecmd |= fsi_data.setBit(3);
        if (rc_ecmd)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error 0x%x setting up FSI SBE Vital Register",
                     rc_ecmd);
            rc.setEcmdError(rc_ecmd);
            break;
        }

        rc = fapiPutCfamRegister(i_target, CFAM_FSI_SBE_VITAL_0x0000281C, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiPutCfamRegister error (CFAM_FSI_SBE_VITAL_0x0000281C)");
            break;
        }
		
		
        // Setting FSI Shift Speed
        rc = fapiGetCfamRegister(i_target, CFAM_FSI_SHIFT_CTRL_0x00000C10, fsi_data);
        if (rc)
        {
        	FAPI_ERR("proc_tp_collect_dbg_data: fapiGetCfamRegister error (CFAM_FSI_SHIFT_CTRL_0x00000C10)");
            break;
        }
        
        rc_ecmd |= fsi_data.setWord(0,PROC_TP_COLLECT_DBG_DATA_FSI_SHIFT_CTRL);
        if (rc_ecmd)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error 0x%x setting up FSI SHIFT CTRL register data buffer",
                     rc_ecmd);
            rc.setEcmdError(rc_ecmd);
            break;
        }

        rc = fapiPutCfamRegister(i_target, CFAM_FSI_SHIFT_CTRL_0x00000C10, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiPutCfamRegister error (CFAM_FSI_SHIFT_CTRL_0x00000C10)");
            break;
        }
        
        // Changing Fences for Vital scan
        rc = fapiGetCfamRegister(i_target, CFAM_FSI_GP3_0x00002812, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiGetCfamRegister error (CFAM_FSI_GP3_0x00002812)");
            break;
        }
        
        rc_ecmd |= fsi_data.clearBit(23);
        rc_ecmd |= fsi_data.setBit(24);
        rc_ecmd |= fsi_data.setBit(25);
        rc_ecmd |= fsi_data.setBit(26);
        rc_ecmd |= fsi_data.clearBit(27);
        if (rc_ecmd)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error 0x%x setting up FSI GP3 data buffer",
                     rc_ecmd);
            rc.setEcmdError(rc_ecmd);
            break;
        }
        
        rc = fapiPutCfamRegister(i_target, CFAM_FSI_GP3_0x00002812, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiPutCfamRegister error (CFAM_FSI_GP3_0x00002812)");
            break;
        }
        
        rc = fapiGetCfamRegister(i_target, CFAM_FSI_GP3_MIRROR_0x0000281B, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiGetCfamRegister error (CFAM_FSI_GP3_MIRROR_0x0000281B)");
            break;
        }
        
        rc_ecmd |= fsi_data.setBit(16);
        if (rc_ecmd)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error 0x%x setting up FSI GP3 MIRROR data buffer",
                     rc_ecmd);
            rc.setEcmdError(rc_ecmd);
            break;
        }
        
        rc = fapiPutCfamRegister(i_target, CFAM_FSI_GP3_MIRROR_0x0000281B, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiPutCfamRegister error (CFAM_FSI_GP3_MIRROR_0x0000281B)");
            break;
        }
        
        rc = fapiGetCfamRegister(i_target, CFAM_FSI_GP3_MIRROR_0x0000281B, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiGetCfamRegister error (CFAM_FSI_GP3_MIRROR_0x0000281B)");
            break;
        }
        
        rc_ecmd |= fsi_data.setBit(26);
        if (rc_ecmd)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error 0x%x setting up FSI GP3 MIRROR data buffer",
                     rc_ecmd);
            rc.setEcmdError(rc_ecmd);
            break;
        }
        
        rc = fapiPutCfamRegister(i_target, CFAM_FSI_GP3_MIRROR_0x0000281B, fsi_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: fapiPutCfamRegister error (CFAM_FSI_GP3_MIRROR_0x0000281B)");
            break;
        }

        // obtain ring/spy attribute data
        rc = FAPI_ATTR_GET(ATTR_PROC_PERV_VITL_LENGTH, &i_target, ring_length);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error from FAPI_ATTR_GET (ATTR_PROC_PERV_VITL_LENGTH)");
            break;
        }

        rc = FAPI_ATTR_GET(ATTR_PROC_TP_VITL_SPY_LENGTH, &i_target, spy_length);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error from FAPI_ATTR_GET (ATTR_PROC_TP_VITL_SPY_LENGTH)");
            break;
        }

        rc = FAPI_ATTR_GET(ATTR_PROC_TP_VITL_SPY_OFFSETS, &i_target, spy_offsets);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error from FAPI_ATTR_GET (ATTR_PROC_TP_VITL_SPY_OFFSETS)");
            break;
        }

        rc_ecmd |= ring_data.setBitLength(ring_length);
        rc_ecmd |= spy_data.setBitLength(spy_length);
        if (rc_ecmd)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error 0x%x sizing FFDC data buffers",
                     rc_ecmd);
            rc.setEcmdError(rc_ecmd);
            break;
        }
        
        // collect data from ring
        rc = fapiGetRing(i_target, PERV_VITL_CHAIN_RING_ADDRESS, ring_data);
        if (rc)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error from fapiGetRing (PERV_VITL_CHAIN)");
            break;
        }

        // extract spy data from ring image
        uint32_t spy_offset_curr = 0;
        for (uint32_t spy_offset_index = 0;
             spy_offset_index < TP_VITL_SPY_MAX_SPY_RANGES;
             spy_offset_index++)
        {
            if (spy_offsets[spy_offset_index] == 0xFFFFFFFF)
            {
                break;
            }

            uint32_t first = ((spy_offsets[spy_offset_index] >> 16) & 0xFFFF);
            uint32_t second = (spy_offsets[spy_offset_index] & 0xFFFF);

            uint32_t chunk_size = (second - first + 1);
            rc_ecmd |= spy_data.insert(ring_data,
                                       spy_offset_curr,
                                       chunk_size,
                                       first);
            spy_offset_curr += chunk_size;
        }

        if (rc_ecmd)
        {
            FAPI_ERR("proc_tp_collect_dbg_data: Error 0x%x forming FFDC spy data buffer",
                     rc_ecmd);
            rc.setEcmdError(rc_ecmd);
            break;
        }

        ecmdDataBufferBase & VITL_DATA = spy_data;
        FAPI_ADD_INFO_TO_HWP_ERROR(o_rc, RC_TP_COLLECT_DBG_DATA);

    } while(0);

    // mark HWP exit
    FAPI_INF("proc_tp_collect_dbg_data: End");
    return rc;
}


} // extern "C"
OpenPOWER on IntegriCloud