Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / fnx / vlib / FNXPCIEXactor / include / FNXPCIEXactorExports.vri
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: FNXPCIEXactorExports.vri
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35// **************************************************************************
36// Copyright (c) 2003 by Sun Microsystems Inc.
37//
38// All rights reserved. No part of this design may be reproduced stored
39// in a retrieval system, or transmitted, in any form or by any means,
40// electronic, mechanical, photocopying, recording, or otherwise, without
41// prior written permission of Sun Microsystems, Inc.
42//
43// Sun Proprietary and Confidential
44//
45// File_Name : /vobs/eagle/verif/asic/fnx/common/vlib/FNXPCIEXactor/include/FNXPCIEXactorExports.vri
46// Creation_Date : Wed Aug 27 2003
47// Created by : Jeff Banta
48// Version : %auto-insertion% (current checked-out version)
49// Last_Update : %auto-insertion% (last time check-in)
50// Description : FNX PCIE Xactor Exported Tasks
51//
52// Revision History : <-NOTE- put the latest entry at the bottom of the list>
53//
54// <mm/dd/yy> <who> <revision note>
55// 08/27/03 jbanta Created
56//
57// ********************************************************************************
58
59#include "FNXPCIEXactor.vrh"
60#include "FNXPCIEXactorReportMacros.vri"
61
62/////////////////////////////////////////////////
63// Global Denali Register Callback Handler
64//
65// Places Denali Register Callbacks Into FNX Denali Device's Register Callback Mailbox
66export task FNXPCIEXactorRegCbTask(integer id, integer access, integer portNum)
67{
68 denaliPcieDevice denDev;
69 denaliPcieDeviceList devList;
70 FNXPCIEXactorRegCbRecord regCbRecord;
71 FNXPCIEXactorDenaliDevice fnxDev;
72 denali_root_monitor_PCIEXactorDenaliDevice denali_root_monitor_Dev;
73 bit [31:0] bData, bMask;
74 bit [63:0] address;
75 integer iWidth, iErr, status;
76 ReportClass MyReport;
77 string ClassName = "Global";
78 string MethodName = "FNXPCIEXactorRegCbTask";
79// int denali_root_monitor_id;
80 bit root_monitor_id = 0;
81
82
83 iErr = DenaliDDVaccCbkGetDataAndMask( iWidth, bData, bMask, address );
84
85 // Gen Denali Device Associated With Callback
86 devList = new();
87 denDev = devList.getDeviceFromId( id-1 );
88 if ( denDev === null ) {
89 MyReport = new();
90 PCIEX_QR_D3( "Denali Device Retrieved From Id=%0d is Null. Not Processing.", id-1 );
91 return;
92 }
93/*
94 //
95 printf( "AC: inside FNXPCIEExports, Id=%0d \n", id);
96 status = DenaliDDVgetIdByName("`tb_top.pcieA", endpoint_id, );
97 status = DenaliDDVgetIdByName("`tb_top.", denali_root_monitor_id, );
98 if (status == 0) {
99 if (id == endpoint_id) {
100 // endpoint_device
101 newDev = fnxDev;
102 }
103 if (id == denali_root_monitor_id) {
104 newDev = denali_root_monitor_Dev;
105 }
106 else {
107 printf("ERROR, id = %d does not match root_monitor id %d, nor endpoint id %d \n", id, endpoint_id, denali_root_monitor_id);
108 }
109 }
110 //
111
112*/
113
114 // Cast Assign to FNX PCIE Xactor Specific Device
115 status = cast_assign( fnxDev, denDev, CHECK );
116 if (status == 0) {
117 root_monitor_id = 1;
118 status = cast_assign( denali_root_monitor_Dev, denDev, CHECK );
119 }
120 if (status == 0) {
121 MyReport = new();
122 PCIEX_QR_ERR( "Cast Assign to FNXPCIEXactorDenaliDevice Failed" );
123 return;
124 }
125
126 // Retrive Report Class From FNX PCIE Device
127 if (!root_monitor_id) {
128 MyReport = fnxDev.CreateReport();
129
130 // Place Register Callback Into Device Queue
131 regCbRecord = new( address,
132 bData,
133 portNum,
134 access );
135 fnxDev.PushRegCbRecord( regCbRecord );
136
137 PCIEX_QR_D3( "Callback Enqueued for Device=%s:\n %s", fnxDev.getInstName(), regCbRecord.GetStr() );
138
139 // Wait For Transactor To Process Callback Record
140 regCbRecord.WaitUntilProcessed();
141
142 PCIEX_QR_D3( "Callback Processed for Device=%s:\n %s", fnxDev.getInstName(), regCbRecord.GetStr() );
143 }
144 else {
145 MyReport = denali_root_monitor_Dev.CreateReport();
146
147 // Place Register Callback Into Device Queue
148 regCbRecord = new( address,
149 bData,
150 portNum,
151 access );
152 denali_root_monitor_Dev.PushRegCbRecord( regCbRecord );
153
154 PCIEX_QR_D3( "Callback Enqueued for Device=%s:\n %s", denali_root_monitor_Dev.getInstName(), regCbRecord.GetStr() );
155
156 // Wait For Transactor To Process Callback Record
157 regCbRecord.WaitUntilProcessed();
158
159 PCIEX_QR_D3( "Callback Processed for Device=%s:\n %s", denali_root_monitor_Dev.getInstName(), regCbRecord.GetStr() );
160
161 }
162}
163
164/////////////////////////////////////////////////
165// Global Denali Packet Callback Handler
166//
167// Place Denali Packet Callbacks Into FNX Denali Device's Register Callback Mailbox
168export task FNXPCIEXactorPktCbTask(integer devId, integer transId, integer irsn, integer itype)
169{
170 denaliPcieCbReasonT rsn;
171 denaliPciePktTypeT type;
172 denaliPcieDevice denDev;
173 denaliPcieDeviceList devList;
174 denaliPciePacket denPkt;
175 denaliPcieRawPacket rawDenPkt;
176 denaliPcieBaseData baseData;
177 denaliPcieErrorTypeT covPt;
178
179 FNXPCIEXactorDenaliDevice fnxDev;
180 denali_root_monitor_PCIEXactorDenaliDevice denali_root_monitor_Dev;
181 FNXPCIEXactorPktCbRecord pktCbRecord;
182 integer status;
183 ReportClass MyReport;
184
185 string ClassName = "Global";
186 string MethodName = "FNXPCIEXactorPktCbTask";
187
188 bit root_monitor_id = 0;
189
190 // Get Denali Device Associated With Callback
191 devList = new();
192 denDev = devList.getDeviceFromId( devId );
193 if ( denDev === null ) {
194 MyReport = new();
195 PCIEX_QR_D1 ( "Denali Device Retrieved From Id=%0d is Null. Not Processing.", devId );
196 return;
197 }
198
199 // Cast Assign to FNX PCIE Xactor Specific Device
200 status = cast_assign( fnxDev, denDev, CHECK );
201 if (status == 0 ) {
202 root_monitor_id = 1;
203 status = cast_assign( denali_root_monitor_Dev, denDev, CHECK );
204 printf("process cast_assign of denali_root_monitor in FNXPCIEXactorExports, method = %s", MethodName);
205 }
206 if (status == 0) {
207 MyReport = new();
208 PCIEX_QR_ERR( "Cast Assign to FNXPCIEXactorDenaliDevice Failed" );
209 return;
210 }
211
212 if (!root_monitor_id) {
213 // Retrive Report Class From FNX PCIE Device
214 MyReport = fnxDev.CreateReport();
215
216 // Determine Reason and Type of Callback
217 if (cast_assign(rsn, irsn, CHECK) == 0) {
218 PCIEX_QR_ERR( "Cast Assign Failed for Callback Rsn=%0d\n", irsn );
219 return;
220 }
221 if (cast_assign(type, itype, CHECK) == 0) {
222 PCIEX_QR_ERR( "Cast Assign Failed for Callback Type=%0d\n", itype );
223 return;
224 }
225
226 // Create Callback Record and Add Reason and Type
227 pktCbRecord = new();
228 pktCbRecord.Rsn = rsn;
229 pktCbRecord.Type = type;
230
231 // Get Denali Packet Associated With Callback
232 if (rsn === PCIE_CB_PL_RX_start_packet || rsn === PCIE_CB_PL_RX_end_packet) {
233 denPkt = fnxDev.getCbPkt( transId );
234 if ( denPkt === null ) {
235 PCIEX_QR_D3( "WARNING:Denali Packet Retrieved From Device=%s is Null rsn=%0d type=%0d transId=%0d PCIE_CB_RX_discard=%0d PCIE_CB_assert_pass=%0d PCIE_CB_TL_transmit_queue_enter=%0d", fnxDev.getInstName(),rsn,type,transId,PCIE_CB_RX_discard,PCIE_CB_assert_pass,PCIE_CB_TL_transmit_queue_enter );
236 return;
237 }
238 }
239 // NOTE: PCIE_CB_assert_pass Callbacks May Not Have a Packet Assoicated With Them
240 else if (rsn !== PCIE_CB_assert_pass) {
241 denPkt = fnxDev.getCbPkt( transId );
242 if ( denPkt === null ) {
243 PCIEX_QR_ERR( "Denali Packet Retrieved From Device=%s is Null rsn=%0d type=%0d transId=%0d PCIE_CB_RX_discard=%0d PCIE_CB_assert_pass=%0d PCIE_CB_TL_transmit_queue_enter=%0d", fnxDev.getInstName(),rsn,type,transId,PCIE_CB_RX_discard,PCIE_CB_assert_pass,PCIE_CB_TL_transmit_queue_enter );
244 return;
245 }
246 }
247 else {
248 // Add Assert Coverage Point to Callback Record
249 denPkt = null;
250 baseData = new();
251 if (denaliVeraGetPacketBaseFields( transId,
252 baseData.pktType,
253 baseData.ipg,
254 baseData.callback,
255 baseData.errInjectLen,
256 baseData.err,
257 baseData.pktDataLen,
258 baseData.internalUserDataIndex,
259 baseData.pktDelay,
260 baseData.pktInfo,
261 baseData.pktErrInfo) === 0) {
262 cast_assign( covPt, baseData.err );
263 }
264 else
265 covPt = PCIE_NO_ERROR;
266 pktCbRecord.covPt = covPt;
267 }
268
269 // Add Denali Pkt to Callback Record
270 pktCbRecord.Pkt = denPkt;
271
272 fnxDev.PushPktCbRecord( pktCbRecord );
273
274 PCIEX_QR_D3( "Callback Enqueued for Device=%s:\n %s", fnxDev.getInstName(), pktCbRecord.GetStr() );
275
276 // Wait For Transactor To Process Callback Record
277 pktCbRecord.WaitUntilProcessed();
278
279 PCIEX_QR_D3( "Callback Processed for Device=%s:\n %s", fnxDev.getInstName(), pktCbRecord.GetStr() );
280
281 }
282 else {
283
284
285 // Retrive Report Class From FNX PCIE Device
286 MyReport = denali_root_monitor_Dev.CreateReport();
287
288 // Determine Reason and Type of Callback
289 if (cast_assign(rsn, irsn, CHECK) == 0) {
290 PCIEX_QR_ERR( "Cast Assign Failed for Callback Rsn=%0d\n", irsn );
291 return;
292 }
293 if (cast_assign(type, itype, CHECK) == 0) {
294 PCIEX_QR_ERR( "Cast Assign Failed for Callback Type=%0d\n", itype );
295 return;
296 }
297
298 // Create Callback Record and Add Reason and Type
299 pktCbRecord = new();
300 pktCbRecord.Rsn = rsn;
301 pktCbRecord.Type = type;
302
303 // Get Denali Packet Associated With Callback
304 // NOTE: PCIE_CB_assert_pass Callbacks May Not Have a Packet Assoicated With Them
305 if (rsn !== PCIE_CB_assert_pass) {
306 denPkt = denali_root_monitor_Dev.getCbPkt( transId );
307 if ( denPkt === null ) {
308 PCIEX_QR_ERR( "Denali Packet Retrieved From Device=%s is Null", denali_root_monitor_Dev.getInstName() );
309 return;
310 }
311 }
312 else {
313 // Add Assert Coverage Point to Callback Record
314 denPkt = null;
315 baseData = new();
316 if (denaliVeraGetPacketBaseFields( transId,
317 baseData.pktType,
318 baseData.ipg,
319 baseData.callback,
320 baseData.errInjectLen,
321 baseData.err,
322 baseData.pktDataLen,
323 baseData.internalUserDataIndex,
324 baseData.pktDelay,
325 baseData.pktInfo,
326 baseData.pktErrInfo) === 0) {
327 cast_assign( covPt, baseData.err );
328 }
329 else
330 covPt = PCIE_NO_ERROR;
331 pktCbRecord.covPt = covPt;
332 }
333
334 // Add Denali Pkt to Callback Record
335 pktCbRecord.Pkt = denPkt;
336
337 denali_root_monitor_Dev.PushPktCbRecord( pktCbRecord );
338
339 PCIEX_QR_D3( "Callback Enqueued for Device=%s:\n %s", denali_root_monitor_Dev.getInstName(), pktCbRecord.GetStr() );
340
341 // Wait For Transactor To Process Callback Record
342 pktCbRecord.WaitUntilProcessed();
343
344 PCIEX_QR_D3( "Callback Processed for Device=%s:\n %s", denali_root_monitor_Dev.getInstName(), pktCbRecord.GetStr() );
345
346 }
347}