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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/fsi/test/fsiprestest.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* COPYRIGHT International Business Machines Corp. 2011,2014 */
/* */
/* 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 */
#ifndef __FSIPRESTEST_H
#define __FSIPRESTEST_H
/**
* @file fsiprestest.H
* @brief Test cases for the FSI presence detect.
*/
#include <trace/interface.H>
#include <cxxtest/TestSuite.H>
#include <devicefw/userif.H>
#include <targeting/common/commontargeting.H>
using namespace TARGETING;
using namespace DeviceFW;
extern trace_desc_t* g_trac_fsi;
class FSIPresTest : public CxxTest::TestSuite
{
public:
/** @brief Verify presence state matches the apparent FSI bus states.
*
* Performs a presence detect on every processor and memory, followed
* by an FSI access to the device. Ensures we get an error on every
* non-present device and we do not get an error for any present
* device.
*/
void testPresence()
{
Target* l_masterChip = NULL;
targetService().masterProcChipTargetHandle(l_masterChip);
// Filter for just processor and mem-buffers.
PredicateCTM l_proc(CLASS_NA,TYPE_PROC);
PredicateCTM l_membuf(CLASS_NA,TYPE_MEMBUF);
PredicatePostfixExpr l_expr;
l_expr.push(&l_proc).push(&l_membuf).Or();
TargetRangeFilter target(targetService().begin(),
targetService().end(),
&l_expr);
// Iterate through all processors and mem-buffers.
while(target)
{
TS_TRACE("FSI-PRES: Testing target %x",
TARGETING::get_huid(*target));
// Read presence detect.
errlHndl_t l_errl = NULL;
bool present = false;
size_t l_size = 1;
l_errl = deviceRead(*target, &present, l_size,
DEVICE_PRESENT_ADDRESS());
if (l_errl)
{
TS_FAIL("FSI-PRES: Cannot perform presence detect. %x",
TARGETING::get_huid(*target));
TRACFCOMP(g_trac_fsi,
"Failed presence detect. %x",
TARGETING::get_huid(*target));
}
else if ((*target == l_masterChip) && (!present))
{
TS_FAIL("FSI-PRES: Claiming master chip is not present!");
}
else // Attempt FSI read.
{
// Determine a valid FSI address to read.
uint64_t fsi_address = 0x1028; // CHIPID address
if (*target == l_masterChip)
{
fsi_address = 0x3474; //MFSI MVER address
}
// Perform FSI read.
uint32_t fsi_data = 0;
size_t op_size = sizeof(fsi_data);
l_errl = deviceRead(*target, &fsi_data, op_size,
DEVICE_FSI_ADDRESS(fsi_address));
// Verify we get an FSI error if device is not present or
// we do not get an FSI error if device is present.
if (present && l_errl)
{
TS_FAIL("FSI-PRES: "
"Error performing read to present device. %x",
TARGETING::get_huid(*target));
TRACFCOMP(g_trac_fsi,
"FSI-PRES: FSI-read failed with %d on %x",
l_errl->reasonCode(),
TARGETING::get_huid(*target));
// commit this log for debug
l_errl->collectTrace("UNIT_TEST",512);
errlCommit(l_errl,FSI_COMP_ID);
}
else if (!present && !l_errl)
{
TS_FAIL("FSI-PRES: No error performing "
"read to non-present device. %x",
TARGETING::get_huid(*target));
TRACFCOMP(g_trac_fsi,
"FSI-PRES: FSI-read did not fail. %x",
TARGETING::get_huid(*target));
}
else
{
TS_TRACE("FSI-PRES: Read chip-id %x on %x",
fsi_data, TARGETING::get_huid(*target));
}
// Delete any logs that got produced
if( l_errl )
{
delete l_errl;
}
}
++target;
}
}
};
#endif
|