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
|
// IBM_PROLOG_BEGIN_TAG
// This is an automatically generated prolog.
//
// $Source: src/usr/intr/test/intrtest.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 __INTRTEST_H
#define __INTRTEST_H
#include <cxxtest/TestSuite.H>
#include <intr/interrupt.H>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <kernel/console.H>
#include <targeting/targetservice.H>
#include <targeting/util.H>
#include <sys/time.h>
#include <sys/mmio.h>
extern trace_desc_t * g_trac_intr;
class IntrTest: public CxxTest::TestSuite
{
public:
/**
* @brief INTR test setup values
*/
void test_verifyState( void )
{
// TODO Temporaritly DISABLE in VBU until P8 support is verfied
if( TARGETING::is_vpo() )
{
return;
}
//// Add support for second chip (dummy)
////uint32_t fake_pir = 0x00000001 << 5; // P7
//uint32_t fake_pir = 0x00000001 << 7; // P8
//msg_q_t intr_msgQ = msg_q_resolve(INTR_MSGQ);
//msg_t * msg = msg_allocate();
//msg->type = INTR::MSG_INTR_ADD_CPU_USR;
//msg->data[0] = fake_pir;
//msg_sendrecv(intr_msgQ, msg);
//msg_free(msg);
// all the simics registers
for(uint64_t chip = 0; chip < 1; ++chip)
{
// simics P8 appears to support 8 threads on 1 core.
// simics P7 appears to support 4 threads on 2 cores.
// for P7, pretending to have 8 threads works because the
// bit fields for cores and threads are contiguous so we can
// let the thread count overflow into the core field. so this
// works for p7 as well.
for(uint64_t thread = 0; thread < 8; ++thread)
{
uint64_t offset = (chip << 20) | (thread << 12);
uint32_t * addr =
reinterpret_cast<uint32_t *>(iv_baseAddr + offset);
if(offset == 0) // Master cpu
{
if(*addr != 0xFF000000)
{
TS_FAIL
("INTR:Master cpu not initialized-XIRR@%p=0x%08x",
addr,*addr);
}
}
// TODO remove restriction when/if simics supports
// more than 2 chips and 4 threads each
if (chip < 2 && thread < 4)
{
if(offset != 0 && *addr != 0)
{
TS_FAIL("INTR:Chip %ld Thread %ld bad XIRR@%p=0x%08x",
chip,thread,addr,*addr);
}
if(*(addr+4) != 0x40000000 ||
*(addr+5) != 0x40000000 ||
*(addr+6) != 0xC0000000)
{
TS_FAIL("INTR:Chip %ld Thread %ld bad LINKS"
" 0x%08x 0x%08x 0x%08x",
chip,thread,
*(addr+4),*(addr+5),*(addr+6));
}
}
}
}
}
/**
* @brief Disable then Enable interrupt handling
*/
void test_enableDisable( void )
{
// TODO Temporaritly DISABLE in VBU until P8 support is confirmed
if( TARGETING::is_vpo() )
{
return;
}
uint32_t * addr = reinterpret_cast<uint32_t *>(iv_baseAddr);
errlHndl_t err = INTR::disableExternalInterrupts();
if(err)
{
TS_FAIL("INTR::disableExternalInterrupts returned error log");
delete err;
err = NULL;
}
if((*addr & 0xFF000000) != 0)
{
TS_FAIL("INTR not disabled. Addr %p",addr);
}
err = INTR::enableExternalInterrupts();
if(err)
{
TS_FAIL("INTR::enableExternalInterrupts returned error log");
delete err;
err = NULL;
}
if((*addr & 0xFF000000) != 0xFF000000)
{
TS_FAIL("INTR not enabled. Addr %p", addr);
}
}
/**
* @brief Register an interrupt message queue, force an interrupt,
* then handle the interrupt.
*/
void test_intr( void )
{
// TODO Temporaritly DISABLE in VBU until P8 support is confirmed
if( TARGETING::is_vpo() )
{
return;
}
errlHndl_t err = NULL;
// Need to register a msgq
msg_q_t msgQ = msg_q_create();
err = INTR::registerMsgQ(msgQ,INTR::INTERPROC);
if(err)
{
TS_FAIL("Errl from INTR::registerMsgQ()");
delete err;
err = NULL;
}
// Force an interrupt by writing to the MFFR on master
volatile uint8_t * mfrr =
reinterpret_cast<uint8_t *>(iv_baseAddr+12);
*(mfrr) = 0x55;
*(mfrr) = 0xff;
msg_t* msg = msg_wait(msgQ); // wait for interrupt msg
TRACFCOMP(g_trac_intr,"Interrupt handled! Type=%lx",msg->type);
if(msg->type != INTR::INTERPROC)
{
TS_FAIL("INTR::unexpected interrupt type %lx",msg->type);
}
msg_respond(msgQ,msg);
msgQ = INTR::unRegisterMsgQ(INTR::INTERPROC);
if(msgQ)
{
msg_q_destroy(msgQ);
}
else
{
TS_FAIL("INTR::unRegisterMsgQ failed");
}
}
IntrTest() : CxxTest::TestSuite()
{
iv_baseAddr = reinterpret_cast<uint64_t>
(mmio_dev_map(reinterpret_cast<void*>(cv_realAddr),THIRTYTWO_MB));
TRACDCOMP(g_trac_intr,"IntrTest()> iv_baseAddr=0x%.X",iv_baseAddr);
};
~IntrTest()
{
mmio_dev_unmap(reinterpret_cast<void*>(iv_baseAddr));
};
private:
uint64_t iv_baseAddr;
static const uint64_t cv_realAddr;
};
//note: this must be changed if the BAR changes
const uint64_t IntrTest::cv_realAddr = 0x3fbff9000000ul;
#endif
|