summaryrefslogtreecommitdiffstats
path: root/src/usr/scom/test/scomtest.H
blob: 3d7067c503d0409b85b3aad345f85ed268128b7f (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
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/scom/test/scomtest.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 __SCOMTEST_H
#define __SCOMTEST_H

/**
 *  @file scomtest.H
 *
 *  @brief Test case for SCOM code
*/

#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <errl/errltypes.H>
#include <devicefw/userif.H>
#include <fsi/fsiif.H>



extern trace_desc_t* g_trac_scom;


class ScomTest: public CxxTest::TestSuite
{
public:

    /**
     * @brief SCOM test via FSISCOM
     *     
     */
    void test_FSISCOMreadWrite(void)
    {
        TRACFCOMP( g_trac_scom, "ScomTest::test_FSISCOMreadWrite> Start" );

        uint64_t fails = 0;
        uint64_t total = 0;
        errlHndl_t l_err = NULL;

        TARGETING::Target* fsi_target = NULL;

        // Target Proc 1 - the FSI wrap-back connection in simics
        TARGETING::EntityPath epath(TARGETING::EntityPath::PATH_PHYSICAL);
        epath.addLast(TARGETING::TYPE_SYS,0);
        epath.addLast(TARGETING::TYPE_NODE,0);
        epath.addLast(TARGETING::TYPE_PROC,9);
        fsi_target = TARGETING::targetService().toTarget(epath);

        //only run if the target exists and has FSI enabled.
        if(fsi_target == NULL)
        {
            TRACFCOMP( g_trac_scom, "ScomTest::test_FSISCOMreadWrite> FSI Target not found, exiting test" );
            return;
        }
        else if((TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL == fsi_target) ||
                (fsi_target->getAttr<TARGETING::ATTR_SCOM_SWITCHES>().useXscom))
        {
            TRACFCOMP( g_trac_scom, "ScomTest::test_FSISCOMreadWrite> Target is the MASTER Sentinal or is set to use Xscom, exiting test" );
            return;
        }
        else if(0 == fsi_target->getAttr<TARGETING::ATTR_SCOM_SWITCHES>().useFsiScom)
        {
            TRACFCOMP( g_trac_scom, "ScomTest::test_FSISCOMreadWrite> useFsiScom set to zero, exiting test" );
            return;
        }

        // scratch data to use
        //@fixme: Need to either fabricate some fake registers to use or save off data before modifying SCOMs to avoid
        //   corrupting the HW.
        struct {
            uint64_t addr;
            uint64_t data;
        } test_data[] = {
            { 0x120F0000 ,0xFEEDB0B000001234}, 
            { 0x120F0166, 0xFEDCBA9876543210}, 
            { 0x00040005, 0x0000000000000000}, 
            { 0x02040004, 0xFFFFFFFFFFFFFFFF}, 

        };
        const uint64_t NUM_ADDRS = sizeof(test_data)/sizeof(test_data[0]);

        // allocate space for read data
        uint64_t read_data[NUM_ADDRS];
        size_t op_size = sizeof(uint32_t);

        // write all the test registers
        for( uint64_t x = 0; x < NUM_ADDRS; x++ )   
        {
            op_size = sizeof(uint64_t);

            total++;
            l_err = deviceWrite( fsi_target,
                                &(test_data[x].data),
                                op_size,
                                DEVICE_SCOM_ADDRESS(test_data[x].addr) );
            if( l_err )
            {
                TRACFCOMP(g_trac_scom, "ScomTest::test_FSISCOMreadWrite> Write: Error from device : addr=0x%X, RC=%X", test_data[x].addr, l_err->reasonCode() );
                TS_FAIL( "ScomTest::test_FSISCOMreadWrite> ERROR : Unexpected error log from write1" );
                fails++;
                errlCommit(l_err,SCOM_COMP_ID);
                delete l_err;
            }
        }

         // read all the test registers
        for( uint64_t x = 0; x < NUM_ADDRS; x++ )   
        {
            op_size = sizeof(uint64_t);

            total++;
            l_err = deviceRead( fsi_target,
                                 &(read_data[x]),
                                 op_size,
                                 DEVICE_SCOM_ADDRESS(test_data[x].addr) );
            if( l_err )
            {
                TRACFCOMP(g_trac_scom, "ScomTest::test_FSISCOMreadWrite> read: Error from device : addr=0x%X, RC=%X", test_data[x].addr, l_err->reasonCode() );
                TS_FAIL( "ScomTest::test_FSISCOMreadWrite> ERROR : Unexpected error log from write1" );
                fails++;
                errlCommit(l_err,SCOM_COMP_ID);
                delete l_err;
            }
            else if(read_data[x] != test_data[x].data)
            {
                TRACFCOMP(g_trac_scom, "ScomTest::test_FSISCOMreadWrite> read: Data miss-match : addr=0x%X, read_data=0x%llx, write_data=0x%llx", test_data[x].addr, read_data[x], test_data[x].data);
                TS_FAIL( "ScomTest::test_FSISCOMreadWrite> ERROR : Data miss-match between read and expected data" );
                fails++;
            }
        }

                TRACFCOMP( g_trac_scom, "ScomTest::test_FSISCOMreadWrite> %d/%d fails", fails, total );

    }


  //@todo - write tests to verify connection between XSCOM and FSISCOM

};

#endif
OpenPOWER on IntegriCloud