summaryrefslogtreecommitdiffstats
path: root/src/usr/mbox/test/mboxddtest.H
blob: a1920d8917d10b4aa78b5a53cfc0ae0e02c577c3 (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
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/mbox/test/mboxddtest.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 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 __MBOXDDTEST_H
#define __MBOXDDTEST_H

/**
 *  @file mboxddtest.H
 *
 *  @brief Test cases for MBOX Device Driver
*/

#include <cxxtest/TestSuite.H>
#include <errl/errlentry.H>
#include <errl/hberrltypes.H>
#include <limits.h>
#include <devicefw/driverif.H>
#include <mbox/mboxif.H>

extern trace_desc_t* g_trac_mbox;

using namespace TARGETING;

class MboxDDTest : public CxxTest::TestSuite
{
  public:

    /**
     * @brief MBOX DD test - Write (STUB)
     *        Perform basic write operation
     */
    void testWrite(void)
    {
        TRACFCOMP(g_trac_mbox, "MboxDDTest::testWrite(STUB)> Begin");
        /*
         * This test function should be updated to perform TWO write
         * operations. Without the SIMICS data loopback update, this
         * should cause errors to occur due to no ack back from FSP.
         *
         * Currently, without proper SIMICS support, this test function
         * will be stubbed out to allow checkin of this file.
         */
        TRACFCOMP(g_trac_mbox, "MboxDDTest::testWrite(STUB)> End");
    }

    /**
     * @brief MBOX DD test - Write/Read
     *        Perform basic write then read operation
     *        Requires SIMICS data loopback from SP-to-Host (PIB-to-LBUS)
     */
    void _testWriteRead(void)
    {
        uint64_t o_status = 0;
        errlHndl_t l_err = NULL;
        uint32_t in_mboxMsg [] = {0x12345678, 0x14785236, 0x96325874,
                                  0x98765432, 0x78910112, 0x66660000};
        size_t in_size = sizeof(in_mboxMsg);
        uint32_t out_mboxMsg[16] = {0};
        size_t out_size = sizeof(out_mboxMsg);

        TRACFCOMP(g_trac_mbox, "MboxDDTest::testWriteRead> Begin");

        TARGETING::EntityPath epath(TARGETING::EntityPath::PATH_PHYSICAL);
        epath.addLast(TARGETING::TYPE_SYS,0);
        epath.addLast(TARGETING::TYPE_NODE,0);
        epath.addLast(TARGETING::TYPE_PROC,0);

        l_err = DeviceFW::deviceWrite(
                TARGETING::targetService().toTarget(epath),
                static_cast<void*>(in_mboxMsg),in_size,
                DEVICE_MBOX_ADDRESS(&o_status));
        if (l_err)
        {
            TS_FAIL("Unable to write to mailbox device.\n");
        }

        l_err = DeviceFW::deviceRead(
                TARGETING::targetService().toTarget(epath),
                static_cast<void*>(out_mboxMsg),out_size,
                DEVICE_MBOX_ADDRESS(&o_status));
        if (l_err)
        {
            TS_FAIL("Unable to read mailbox device.\n");
        }
        if (o_status != 0x00000005)//Xdn & PIB Pending
        {
            TS_FAIL("PIB interrupt register shows unexpected interrupt.\n");
        }

        for (uint32_t i=0; i<sizeof(in_mboxMsg)/sizeof(uint32_t); ++i)
        {
            if (out_mboxMsg[i] != in_mboxMsg[i])
            {
                TS_FAIL("Loopback data area mismatch.\n");
                break;
            }
        }

        TRACFCOMP(g_trac_mbox, "MboxDDTest::testWriteRead> End");
    };

};     

#endif
OpenPOWER on IntegriCloud