Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / common / include / pcie_tlp.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: pcie_tlp.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
*
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ========== Copyright Header End ============================================
*/
#ifndef _PCIE_TLP_H_
#define _PCIE_TLP_H_
#include "pcie.h"
struct CommonTLP {
struct {
uint32_t :1,fmt:2,type:5,:1,TC:3,:4,TD:1,EP:1,attr:2,:2,length:10;
}word_0;
CommonTLP(){
memset(&word_0, 0, sizeof(word_0));
}
};
struct MemTLP:public CommonTLP {
struct {
uint32_t rid:16,tag:8, first_dw_be:4, last_dw_be:4;
}word_1;
uint32_t addr1;
uint32_t addr2;
MemTLP(){
memset(&word_1,0x0,sizeof(word_1));
addr1 =0x0;
addr2 =0x0;
}
MemTLP(bool wr,uint64_t vaddr,uint64_t count,uint16_t requesterId){
memset(&word_1,0x0,sizeof(word_1));
addr1 =0x0;
addr2 =0x0;
if(wr){
if( vaddr >> 32 )
word_0.fmt = 0x3;
else
word_0.fmt = 0x2;
}
else{
if( vaddr >> 32 )
word_0.fmt = 0x1;
else
word_0.fmt = 0x0;
}
/* length in DW, count is in #bytes */
word_0.length = (uint16_t)(count/4);
word_1.rid = requesterId;
if(vaddr >> 32){
addr1 = (uint32_t)(vaddr >> 32);
addr2 = (((uint32_t)vaddr)& ~0x3);
}
else{
addr1 = (uint32_t)(vaddr & ~0x3);
}
}
};
struct CmplTLP:public CommonTLP {
struct {
uint32_t cid:16,cmpl_stat:3, bcm:1,word_count:12;
}word_1;
struct {
uint32_t rid:16,tag:8,:1,lower_addr:7;
}word_2;
uint32_t reserved;
CmplTLP(){
memset(&word_1,0x0,sizeof(word_1));
memset(&word_2,0x0,sizeof(word_2));
reserved = 0x0;
}
CmplTLP(bool data,int cmplStatus,uint16_t completerId,uint16_t requesterId){
/* initialize all fields to zero */
memset(&word_1,0x0,sizeof(word_1));
memset(&word_2,0x0,sizeof(word_2));
reserved = 0x0;
word_0.type = 0xa;
if(data)
word_0.fmt = 0x2;
else
word_0.fmt = 0x0;
word_2.rid = requesterId;
word_1.cid = completerId;
/*
if(cmplStatus == SC){
word_1.cmpl_stat = SUCCESSFUL_CMPL;
}
else if(cmplStatus == UR){
word_1.cmpl_stat = UNSUPPORTED_REQUEST;
}
else if(cmplStatus == CRS){
word_1.cmpl_stat = CONF_REQUEST_RETRY;
}
else if(cmplStatus == CA){
word_1.cmpl_stat = COMPLETER_ABORT;
}
*/
word_1.cmpl_stat = cmplStatus;
}
CmplTLP(bool data,int cmplStatus,uint16_t completerId,uint16_t requesterId,bool poison){
/* initialize all fields to zero */
memset(&word_1,0x0,sizeof(word_1));
memset(&word_2,0x0,sizeof(word_2));
reserved = 0x0;
word_0.type = 0xa;
if(data)
word_0.fmt = 0x2;
else
word_0.fmt = 0x0;
word_2.rid = requesterId;
word_1.cid = completerId;
/*
if(cmplStatus == SC){
word_1.cmpl_stat = SUCCESSFUL_CMPL;
}
else if(cmplStatus == UR){
word_1.cmpl_stat = UNSUPPORTED_REQUEST;
}
else if(cmplStatus == CRS){
word_1.cmpl_stat = CONF_REQUEST_RETRY;
}
else if(cmplStatus == CA){
word_1.cmpl_stat = COMPLETER_ABORT;
}
*/
word_1.cmpl_stat = cmplStatus;
if(poison)
word_0.EP = 0x1;
}
};
struct IOTLP:public CommonTLP {
struct {
uint32_t rid:16,tag:8, first_dw_be:4, last_dw_be:4;
}word_1;
uint32_t addr1;
uint32_t reserved;
IOTLP(){
memset(&word_1,0x0,sizeof(word_1));
addr1 =0x0;
reserved =0x0;
}
IOTLP(bool wr,uint64_t vaddr,uint64_t count,uint16_t requesterId){
memset(&word_1,0x0,sizeof(word_1));
addr1 =0x0;
reserved =0x0;
word_0.type = 0x2;
if(wr){
word_0.fmt = 0x2;
}
else{
word_0.fmt = 0x0;
}
/* length in DW, count is in #bytes */
word_0.length = (uint16_t)(count/4);
word_1.rid = requesterId;
addr1 = (uint32_t)(vaddr & ~0x3);
}
};
struct CfgTLP:public CommonTLP {
struct {
uint32_t rid:16,tag:8, first_dw_be:4, last_dw_be:4;
}word_1;
struct {
uint32_t cid:16,:4,ext_reg:4,reg:6,:2;
}word_2;
uint32_t reserved;
CfgTLP(){
memset(&word_1,0x0,sizeof(word_1));
memset(&word_2,0x0,sizeof(word_2));
reserved = 0x0;
}
CfgTLP(bool type,bool wr,uint16_t completerId,uint16_t requesterId,uint16_t regNum){
/* initialize all fields to zero */
memset(&word_1,0x0,sizeof(word_1));
memset(&word_2,0x0,sizeof(word_2));
reserved = 0x0;
if(type){
word_0.type = 0x5;
}
else{
word_0.type = 0x4;
}
if(wr)
word_0.fmt = 0x2;
else
word_0.fmt = 0x0;
word_1.rid = requesterId;
word_2.cid = completerId;
word_2.reg = (regNum & 0x3f);
word_2.ext_reg = ((regNum >> 0x6) & 0xf);
}
};
struct MsgTLP:public CommonTLP {
struct {
uint32_t rid:16,tag:8, msg_code:8;
}word_1;
uint32_t addr1;
uint32_t addr2;
MsgTLP(){
memset(&word_1,0x0,sizeof(word_1));
addr1 = 0x0;
addr2 = 0x0;
}
MsgTLP(bool data,uint8_t msg_code,uint16_t requesterId,uint32_t add1=0,uint32_t add2=0){
/* initialize all fields to zero */
memset(&word_1,0x0,sizeof(word_1));
addr1 = 0x0;
addr2 = 0x0;
word_0.type = 0x10; // for now assume all msgs routed to rc
if(data)
word_0.fmt = 0x3;
else
word_0.fmt = 0x1;
word_1.msg_code = (uint8_t)msg_code;
word_1.rid = requesterId;
if(word_0.type == 0x11){
addr1 = add1;
addr2 = add2;
}
}
};
#endif // PCIE_TLP_H