summaryrefslogtreecommitdiffstats
path: root/src/usr/pnor/test/pnorddtest.H
blob: 400114ffa7e35cfc8d75d67a6f2c1def3ef35a56 (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
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/pnor/test/pnorddtest.H $
//
//  IBM CONFIDENTIAL
//
//  COPYRIGHT International Business Machines Corp. 2011
//
//  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 other-
//  wise divested of its trade secrets, irrespective of what has
//  been deposited with the U.S. Copyright Office.
//
//  Origin: 30
//
//  IBM_PROLOG_END
#ifndef __PNORDDTEST_H
#define __PNORDDTEST_H

/**
 *  @file pnorddtest.H
 *
 *  @brief Test case for PNOR Resource Provider
*/

#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <errl/errltypes.H>
#include <pnor/pnorif.H>
#include <devicefw/userif.H>

#define BASE_SCRATCH_SPACE 2*1024*1024+1024*512  //2.5MB offset in fake PNOR

extern trace_desc_t* g_trac_pnor;
using namespace TARGETING;


class PnorDdTest : public CxxTest::TestSuite
{
  public:

    /**
     * @brief PNOR DD readWriteTest
     *        Write some data to PNOR and read it back again
     *        Using fakePNOR scratch space (2.5 - 3 MB)
     */
    void test_readwrite(void)
    {
      //@TODO: make this table driven so it can test more values
      //@TODO: Add some more interesting tests

      TARGETING::Target* l_testTarget = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL;
      size_t l_size = sizeof(uint64_t); 
      errlHndl_t l_err = NULL;
      uint64_t fails = 0;
      uint64_t total = 4;

      do{
        TS_TRACE("PnorDdTest::test_readwrite: starting");

        // Perform PnorDD Write 1
        uint64_t l_address = BASE_SCRATCH_SPACE+0x100;
        uint64_t l_writeData = 0x12345678FEEDB0B0;
        l_err = deviceWrite(l_testTarget,
                            &l_writeData,
                            l_size,
                            DEVICE_PNOR_ADDRESS(0, l_address));
        if (l_err)
            {
          TS_FAIL("PnorDdTest::test_readwrite: PNORDD write 1: deviceWrite() failed! Error committed.");
          fails++;
          break;
            }


        // Perform PnorDD Write 2
        l_address = BASE_SCRATCH_SPACE+0x108;
        l_writeData = 0xFEEDBEEF000ABCDE;
        l_err = deviceWrite(l_testTarget,
                            &l_writeData,
                            l_size,
                            DEVICE_PNOR_ADDRESS(0, l_address));
        if (l_err)
            {
          TS_FAIL("PnorDdTest::test_readwrite: PNORDD write 2: deviceWrite() failed! Error committed.");
          fails++;
          break;
            }

        // Perform PnorDD read 1
        l_address = BASE_SCRATCH_SPACE+0x100;
        uint64_t l_readData = 0;
        l_err = deviceRead(l_testTarget,
                           &l_readData,
                           l_size,
                           DEVICE_PNOR_ADDRESS(0, l_address));
        if (l_err)
            {
          TS_FAIL("PnorDdTest::test_readwrite: PNORDD read 1: deviceRead() failed! Error committed.");
          fails++;
          break;
            }
        else if(l_readData != 0x12345678FEEDB0B0)
            {
          TS_FAIL("PnorDdTest::test_readwrite: PNORDD read 1: Read data not expected value. Addr: 0x%llx, ExpData: 0x12345678FEEDB0B0, ActData: 0x%llx",
                  l_address, (long long unsigned)l_readData);
          fails++;
          break;
            }

        // Perform PnorDD read 2
        l_address = BASE_SCRATCH_SPACE+0x108;
        l_err = deviceRead(l_testTarget,
                           &l_readData,
                           l_size,
                           DEVICE_PNOR_ADDRESS(0, l_address));
        if (l_err)
            {
          TS_FAIL("PnorDdTest::test_readwrite: PNORDD read 2: deviceRead() failed! Error committed.");
          break;
            }
        else if(l_readData != 0xFEEDBEEF000ABCDE)
            {
          TS_FAIL("PnorDdTest::test_readwrite: PNORDD read 2: Read data not expected value. Addr: 0x%llx, ExpData: 0xFEEDBEEF000ABCDE, ActData: 0x%llx",
                  l_address, (long long unsigned)l_readData );
          fails++;
          break;
            }

          }while(0);


          TRACFCOMP(g_trac_pnor, "PnorDdTest::test_readwrite> %d/%d fails", fails, total );

    };


/*Not really a real test, just using to verify ext image is loading properly.
Leaving it commented out because the test-case will not dynamically find the extended image based on the TOC
//    void testPnorDD2(void)
    {

      TARGETING::Target* l_testTarget = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL;
      size_t l_size = sizeof(uint64_t); 
      errlHndl_t l_err = NULL;

      do{
        TS_TRACE("testPnorDD2: starting");

        //Read fakeext data
        uint64_t l_address = 0x690;
        uint64_t l_readData = 0;
        l_err = deviceRead(l_testTarget,
                           &l_readData,
                           l_size,
                           DEVICE_PNOR_ADDRESS(0, l_address));
        if (l_err)
            {
          TS_FAIL("testPnorDD2: PNORDD read fakeext: deviceRead() failed! Error committed.");
          break;
            }
        else
            {
          TS_TRACE("testPnorDD2: PNORDD read fakeext, Address 0x%llx, Data %llx",
                   l_address,
                   (long long unsigned)l_readData);
            }

        //Read fakeext data
        l_address = 0x698;
        l_readData = 0;
        l_err = deviceRead(l_testTarget,
                           &l_readData,
                           l_size,
                           DEVICE_PNOR_ADDRESS(0, l_address));
        if (l_err)
            {
          TS_FAIL("testPnorDD2: PNORDD read fakeext: deviceRead() failed! Error committed.");
          break;
            }
        else
            {
          TS_TRACE("testPnorDD2: PNORDD read fakeext, Address 0x%llx, Data %llx",
                   l_address,
                   (long long unsigned)l_readData);
            }


          }while(0);


          //@TODO: Add total fail/pass count trace to know how many passed.

    };

*/
};     


#endif
OpenPOWER on IntegriCloud