summaryrefslogtreecommitdiffstats
path: root/src/usr/runtime/test/hdatservicetest.H
blob: 8d5dd72de8e895f818e7a2e08b55e3c49ab6b25f (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/runtime/test/hdatservicetest.H $                      */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012                   */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __TEST_HDATSERVICETEST_H
#define __TEST_HDATSERVICETEST_H

/**
 *  @file runtimetest.H
 *
 */

#include <cxxtest/TestSuite.H>

#include <arch/ppc.H> //for MAGIC
#include <errl/errlmanager.H>
#include <runtime/runtime.H>
#include <targeting/common/commontargeting.H>
#include <attributeenums.H>
#include "../hdatstructs.H"

extern trace_desc_t* g_trac_runtime;

class HdatServiceTest: public CxxTest::TestSuite
{
  public:
    void testHdat(void)
    {
        TRACFCOMP( g_trac_runtime, "testHdat> start" );
        errlHndl_t errhdl = NULL;

        // Figure out if we expect to have this data or not
        TARGETING::Target * sys = NULL;
        TARGETING::targetService().getTopLevelTarget( sys );
        assert(sys != NULL);
        TARGETING::ATTR_PAYLOAD_KIND_type payload_kind =
          sys->getAttr<TARGETING::ATTR_PAYLOAD_KIND>();

        // Verify something in the system parms
        uint64_t sys_parms_addr = 0;
        size_t sys_parms_size = 0;
        errhdl = RUNTIME::get_host_data_section(
                                    RUNTIME::IPLPARMS_SYSTEM,
                                    0,
                                    sys_parms_addr,
                                    sys_parms_size );
        if( payload_kind == TARGETING::PAYLOAD_KIND_PHYP )
        {
            if( errhdl  )
            {
                TS_FAIL("testHdat> Error trying to locate IPLPARMS_SYSTEM");
                errlCommit(errhdl,RUNTIME_COMP_ID);
            }
            else if( sys_parms_addr == 0 )
            {
                TS_FAIL("testHdat> NULL returned for get_host_data_section(IPLPARMS_SYSTEM)");
            }
            else if( (sys_parms_size < sizeof(hdatSysParms_t))
                     || (sys_parms_size == RUNTIME::DATA_SIZE_UNKNOWN) )
            {
                TS_FAIL("testHdat> Size of IPLPARMS_SYSTEM data too small");
            }
            else
            {
                hdatSysParms_t* sys_parms = reinterpret_cast<hdatSysParms_t*>(sys_parms_addr);

                uint32_t pvr = sys_parms->hdatEffectivePvr;
                TRACFCOMP( g_trac_runtime, "PVR=%.8X", pvr );

                TARGETING::Target* procmaster = NULL;
                TARGETING::targetService().masterProcChipTargetHandle( procmaster );
                assert( procmaster != NULL );
                TARGETING::ATTR_MODEL_type model =
                  procmaster->getAttr<TARGETING::ATTR_MODEL>();

                if( (model == TARGETING::MODEL_MURANO)
                    && !((pvr & 0x00FF0000) == 0x004B0000) )
                {
                    TS_FAIL("testHdat> PVR model != 4B for Murano");
                }
                else if( (model == TARGETING::MODEL_VENICE)
                         && !((pvr & 0x00FF0000) == 0x004D0000) )
                {
                    TS_FAIL("testHdat> PVR model != 4D for Venice");
                }
            }
        }
        else
        {
            if( !errhdl )
            {
                TS_FAIL("testHdat> Did not get expected error trying to locate IPLPARMS_SYSTEM for non-PHYP Payload");
            }
            else
            {
                delete errhdl;
            }
        }



        // Verify the HostServices Node Data
        uint64_t node_data_addr = 0;
        size_t node_data_size = 0;
        errhdl = RUNTIME::get_host_data_section(
                                    RUNTIME::HSVC_NODE_DATA,
                                    0,
                                    node_data_addr,
                                    node_data_size );
        if( errhdl
            && ((payload_kind == TARGETING::PAYLOAD_KIND_PHYP) 
                || (payload_kind == TARGETING::PAYLOAD_KIND_NONE)) )
        {
            TS_FAIL("testHdat> Error trying to locate HSVC_NODE_DATA");
            errlCommit(errhdl,RUNTIME_COMP_ID);
        }
        else if( !errhdl
                 && (payload_kind != TARGETING::PAYLOAD_KIND_PHYP) 
                 && (payload_kind != TARGETING::PAYLOAD_KIND_NONE) )
        {
            TS_FAIL("testHdat> Did not get expected error trying to locate HSVC_NODE_DATA for non-PHYP/Standalone Payload");
        }
        else if( (node_data_addr == 0)
                 && (payload_kind != TARGETING::PAYLOAD_KIND_PHYP) 
                 && (payload_kind != TARGETING::PAYLOAD_KIND_NONE) )
        {
            TS_FAIL("testHdat> NULL or zero size returned for get_host_data_section(HSVC_NODE_DATA)");
        }
        else if( (node_data_size == 0)
                 || (node_data_size == RUNTIME::DATA_SIZE_UNKNOWN) )
        {
            TS_FAIL("testHdat> Size of HSVC_NODE_DATA is unexpected");
        }
        if( errhdl )
        {
            delete errhdl;
        }


        // Verify the HostServices System Data
        uint64_t sys_data_addr = 0;
        size_t sys_data_size = 0;
        errhdl = RUNTIME::get_host_data_section(
                                    RUNTIME::HSVC_SYSTEM_DATA,
                                    0,
                                    sys_data_addr,
                                    sys_data_size );
        if( errhdl
            && ((payload_kind == TARGETING::PAYLOAD_KIND_PHYP) 
                || (payload_kind == TARGETING::PAYLOAD_KIND_NONE)) )
        {
            TS_FAIL("testHdat> Error trying to locate HSVC_SYSTEM_DATA");
            errlCommit(errhdl,RUNTIME_COMP_ID);
        }
        else if( !errhdl
                 && (payload_kind != TARGETING::PAYLOAD_KIND_PHYP) 
                 && (payload_kind != TARGETING::PAYLOAD_KIND_NONE) )
        {
            TS_FAIL("testHdat> Did not get expected error trying to locate HSVC_SYSTEM_DATA for non-PHYP/Standalone Payload");
        }
        else if( ((sys_data_addr == 0) || (sys_data_size == 0))
                 && (payload_kind != TARGETING::PAYLOAD_KIND_PHYP) 
                 && (payload_kind != TARGETING::PAYLOAD_KIND_NONE) )
        {
            TS_FAIL("testHdat> NULL or zero size returned for get_host_data_section(HSVC_SYSTEM_DATA)");
        }
        else if( (sys_data_size == 0)
                 || (sys_data_size == RUNTIME::DATA_SIZE_UNKNOWN) )
        {
            TS_FAIL("testHdat> Size of HSVC_SYSTEM_DATA is unexpected");
        }
        if( errhdl )
        {
            delete errhdl;
        }

        // Verify the Dump Tables
        uint64_t dump_addr = 0;
        size_t dump_size = 0;
        errhdl = RUNTIME::get_host_data_section(
                                    RUNTIME::MS_DUMP_SRC_TBL,
                                    0,
                                    dump_addr,
                                    dump_size );
        if( errhdl && (payload_kind == TARGETING::PAYLOAD_KIND_PHYP) )
        {
            if( errhdl )
            {
                TS_FAIL("testHdat> Error trying to locate MS_DUMP_SRC_TBL");
                errlCommit(errhdl,RUNTIME_COMP_ID);
            }
            else if( dump_addr == 0 )
            {
                TS_FAIL("testHdat> NULL returned for get_host_data_section(MS_DUMP_SRC_TBL)");
            }
            else if( dump_size < 16 ) //1 entry is 16 bytes
            {
                TRACFCOMP( g_trac_runtime, "testHdat> dump_size=%d", dump_size );
                TS_FAIL("testHdat> Size of MS_DUMP_SRC_TBL data too small");
            }
        }
        else
        {
            if( !errhdl )
            {
                TS_FAIL("testHdat> Did not get expected error trying to locate MS_DUMP_SRC_TBL for non-PHYP Payload");
            }
            else
            {
                delete errhdl;
            }
        }

        errhdl = RUNTIME::get_host_data_section(
                                    RUNTIME::MS_DUMP_DST_TBL,
                                    0,
                                    dump_addr,
                                    dump_size );
        if( errhdl && (payload_kind == TARGETING::PAYLOAD_KIND_PHYP) )
        {
            if( errhdl )
            {
                TS_FAIL("testHdat> Error trying to locate MS_DUMP_DST_TBL");
                errlCommit(errhdl,RUNTIME_COMP_ID);
            }
            else if( dump_addr == 0 )
            {
                TS_FAIL("testHdat> NULL returned for get_host_data_section(MS_DUMP_DST_TBL)");
            }
            else if( dump_size < 16 ) //1 entry is 16 bytes
            {
                TRACFCOMP( g_trac_runtime, "testHdat> dump_size=%d", dump_size );
                TS_FAIL("testHdat> Size of MS_DUMP_DST_TBL data too small");
            }
        }
        else
        {
            if( !errhdl )
            {
                TS_FAIL("testHdat> Did not get expected error trying to locate MS_DUMP_DST_TBL for non-PHYP Payload");
            }
            else
            {
                delete errhdl;
            }
        }

        errhdl = RUNTIME::get_host_data_section(
                                    RUNTIME::MS_DUMP_RESULTS_TBL,
                                    0,
                                    dump_addr,
                                    dump_size );
        if( errhdl && (payload_kind == TARGETING::PAYLOAD_KIND_PHYP) )
        {
            if( errhdl )
            {
                TS_FAIL("testHdat> Error trying to locate MS_DUMP_RESULTS_TBL");
                errlCommit(errhdl,RUNTIME_COMP_ID);
            }
            else if( dump_addr == 0 )
            {
                TS_FAIL("testHdat> NULL returned for get_host_data_section(MS_DUMP_RESULTS_TBL)");
            }
            else if( dump_size < 16 ) //1 entry is 16 bytes
            {
                TRACFCOMP( g_trac_runtime, "testHdat> dump_size=%d", dump_size );
                TS_FAIL("testHdat> Size of MS_DUMP_RESULTS_TBL data too small");
            }
        }
        else
        {
            if( !errhdl )
            {
                TS_FAIL("testHdat> Did not get expected error trying to locate MS_DUMP_RESULTS_TBL for non-PHYP Payload");
            }
            else
            {
                delete errhdl;
            }
        }


        TRACFCOMP( g_trac_runtime, "testHdat> finish" );
    }

};


#endif

OpenPOWER on IntegriCloud