Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / common / include / pcie_tlp.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: pcie_tlp.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23#ifndef _PCIE_TLP_H_
24#define _PCIE_TLP_H_
25
26#include "pcie.h"
27
28struct CommonTLP {
29 struct {
30 uint32_t :1,fmt:2,type:5,:1,TC:3,:4,TD:1,EP:1,attr:2,:2,length:10;
31 }word_0;
32 CommonTLP(){
33 memset(&word_0, 0, sizeof(word_0));
34 }
35};
36
37struct MemTLP:public CommonTLP {
38 struct {
39 uint32_t rid:16,tag:8, first_dw_be:4, last_dw_be:4;
40 }word_1;
41 uint32_t addr1;
42 uint32_t addr2;
43
44 MemTLP(){
45 memset(&word_1,0x0,sizeof(word_1));
46 addr1 =0x0;
47 addr2 =0x0;
48 }
49
50 MemTLP(bool wr,uint64_t vaddr,uint64_t count,uint16_t requesterId){
51 memset(&word_1,0x0,sizeof(word_1));
52 addr1 =0x0;
53 addr2 =0x0;
54
55 if(wr){
56 if( vaddr >> 32 )
57 word_0.fmt = 0x3;
58 else
59 word_0.fmt = 0x2;
60 }
61 else{
62 if( vaddr >> 32 )
63 word_0.fmt = 0x1;
64 else
65 word_0.fmt = 0x0;
66 }
67
68 /* length in DW, count is in #bytes */
69 word_0.length = (uint16_t)(count/4);
70
71 word_1.rid = requesterId;
72 if(vaddr >> 32){
73 addr1 = (uint32_t)(vaddr >> 32);
74 addr2 = (((uint32_t)vaddr)& ~0x3);
75 }
76 else{
77 addr1 = (uint32_t)(vaddr & ~0x3);
78 }
79 }
80
81};
82
83struct CmplTLP:public CommonTLP {
84 struct {
85 uint32_t cid:16,cmpl_stat:3, bcm:1,word_count:12;
86 }word_1;
87 struct {
88 uint32_t rid:16,tag:8,:1,lower_addr:7;
89 }word_2;
90 uint32_t reserved;
91
92 CmplTLP(){
93 memset(&word_1,0x0,sizeof(word_1));
94 memset(&word_2,0x0,sizeof(word_2));
95 reserved = 0x0;
96 }
97
98 CmplTLP(bool data,int cmplStatus,uint16_t completerId,uint16_t requesterId){
99 /* initialize all fields to zero */
100 memset(&word_1,0x0,sizeof(word_1));
101 memset(&word_2,0x0,sizeof(word_2));
102 reserved = 0x0;
103 word_0.type = 0xa;
104 if(data)
105 word_0.fmt = 0x2;
106 else
107 word_0.fmt = 0x0;
108
109 word_2.rid = requesterId;
110 word_1.cid = completerId;
111/*
112 if(cmplStatus == SC){
113 word_1.cmpl_stat = SUCCESSFUL_CMPL;
114 }
115 else if(cmplStatus == UR){
116 word_1.cmpl_stat = UNSUPPORTED_REQUEST;
117 }
118 else if(cmplStatus == CRS){
119 word_1.cmpl_stat = CONF_REQUEST_RETRY;
120 }
121 else if(cmplStatus == CA){
122 word_1.cmpl_stat = COMPLETER_ABORT;
123 }
124*/
125 word_1.cmpl_stat = cmplStatus;
126 }
127
128 CmplTLP(bool data,int cmplStatus,uint16_t completerId,uint16_t requesterId,bool poison){
129 /* initialize all fields to zero */
130 memset(&word_1,0x0,sizeof(word_1));
131 memset(&word_2,0x0,sizeof(word_2));
132 reserved = 0x0;
133 word_0.type = 0xa;
134 if(data)
135 word_0.fmt = 0x2;
136 else
137 word_0.fmt = 0x0;
138
139 word_2.rid = requesterId;
140 word_1.cid = completerId;
141/*
142 if(cmplStatus == SC){
143 word_1.cmpl_stat = SUCCESSFUL_CMPL;
144 }
145 else if(cmplStatus == UR){
146 word_1.cmpl_stat = UNSUPPORTED_REQUEST;
147 }
148 else if(cmplStatus == CRS){
149 word_1.cmpl_stat = CONF_REQUEST_RETRY;
150 }
151 else if(cmplStatus == CA){
152 word_1.cmpl_stat = COMPLETER_ABORT;
153 }
154*/
155 word_1.cmpl_stat = cmplStatus;
156 if(poison)
157 word_0.EP = 0x1;
158 }
159
160};
161
162struct IOTLP:public CommonTLP {
163 struct {
164 uint32_t rid:16,tag:8, first_dw_be:4, last_dw_be:4;
165 }word_1;
166 uint32_t addr1;
167 uint32_t reserved;
168
169 IOTLP(){
170 memset(&word_1,0x0,sizeof(word_1));
171 addr1 =0x0;
172 reserved =0x0;
173 }
174
175 IOTLP(bool wr,uint64_t vaddr,uint64_t count,uint16_t requesterId){
176 memset(&word_1,0x0,sizeof(word_1));
177 addr1 =0x0;
178 reserved =0x0;
179
180 word_0.type = 0x2;
181 if(wr){
182 word_0.fmt = 0x2;
183 }
184 else{
185 word_0.fmt = 0x0;
186 }
187
188 /* length in DW, count is in #bytes */
189 word_0.length = (uint16_t)(count/4);
190
191 word_1.rid = requesterId;
192 addr1 = (uint32_t)(vaddr & ~0x3);
193 }
194
195};
196
197struct CfgTLP:public CommonTLP {
198 struct {
199 uint32_t rid:16,tag:8, first_dw_be:4, last_dw_be:4;
200 }word_1;
201 struct {
202 uint32_t cid:16,:4,ext_reg:4,reg:6,:2;
203 }word_2;
204 uint32_t reserved;
205
206 CfgTLP(){
207 memset(&word_1,0x0,sizeof(word_1));
208 memset(&word_2,0x0,sizeof(word_2));
209 reserved = 0x0;
210 }
211
212 CfgTLP(bool type,bool wr,uint16_t completerId,uint16_t requesterId,uint16_t regNum){
213 /* initialize all fields to zero */
214 memset(&word_1,0x0,sizeof(word_1));
215 memset(&word_2,0x0,sizeof(word_2));
216 reserved = 0x0;
217 if(type){
218 word_0.type = 0x5;
219 }
220 else{
221 word_0.type = 0x4;
222 }
223 if(wr)
224 word_0.fmt = 0x2;
225 else
226 word_0.fmt = 0x0;
227
228 word_1.rid = requesterId;
229 word_2.cid = completerId;
230
231 word_2.reg = (regNum & 0x3f);
232 word_2.ext_reg = ((regNum >> 0x6) & 0xf);
233 }
234};
235
236struct MsgTLP:public CommonTLP {
237 struct {
238 uint32_t rid:16,tag:8, msg_code:8;
239 }word_1;
240 uint32_t addr1;
241 uint32_t addr2;
242
243 MsgTLP(){
244 memset(&word_1,0x0,sizeof(word_1));
245 addr1 = 0x0;
246 addr2 = 0x0;
247 }
248
249 MsgTLP(bool data,uint8_t msg_code,uint16_t requesterId,uint32_t add1=0,uint32_t add2=0){
250 /* initialize all fields to zero */
251 memset(&word_1,0x0,sizeof(word_1));
252 addr1 = 0x0;
253 addr2 = 0x0;
254 word_0.type = 0x10; // for now assume all msgs routed to rc
255 if(data)
256 word_0.fmt = 0x3;
257 else
258 word_0.fmt = 0x1;
259
260 word_1.msg_code = (uint8_t)msg_code;
261
262 word_1.rid = requesterId;
263
264 if(word_0.type == 0x11){
265 addr1 = add1;
266 addr2 = add2;
267 }
268 }
269};
270
271
272#endif // PCIE_TLP_H
273