* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: MemoryTransaction.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 ============================================
//============================================================================
// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
// THIS FILE IS ONLY HERE FOR BACKWARDS COMPATIBILITY. DO NOT WRITE NEW CODE
// THAT DEPENDS ON THIS CLASS AND DO NOT ADD MORE CODE TO THIS CLASS HERE.
// THE ORIGINAL OF THIS FILE IS IN THE RIESLING REPOSITORY.
//============================================================================
#ifndef _MEMORYTRANSACTION_H__
#define _MEMORYTRANSACTION_H__
class MemoryTransaction
{
typedef enum { DATA
, INSTR
} RefT
;
READ
= 1 << 0, // read access
WRITE
= 1 << 1, // write access
ATOMIC
= 1 << 2, // atomic instruction
INTERNAL
= 1 << 3, // internal read/write, allow access to RO/WO area
TABLE_WALK
= 1 << 4, // the memory transaction is generated by hardware table walk, rather then instruction fetch or LSU operation.
NO_WRITE
= 1 << 5, // do not overwrite data in the object
MEM_SLAM
= 1 << 6, // testbench slam a data into (read-only) memory section.
FOLLOW_ME
= 1 << 7, // indicate the value is a follow-me
LITTLE_ENDIAN
= 1 << 8, // data in little endian format
NOP
= 1 << 9, // silently ignore the read/write
DEBUG
= 1 << 31 // last item, for debug purpose
typedef uint32_t AccessT
;
MemoryTransaction( VaddrT vaddr
,AccessT a
, uint_t id
=0 )
* @param orig The MemoryTransaction object to copy.
MemoryTransaction( const MemoryTransaction
&orig
)
for (uint_t i
= 0; i
< ((size_
+ 7) >> 3); i
++)
data_
[i
] = orig
.data_
[i
];
* @param rhs The right hand side of the assignment operator.
* @return The lvalue of the assignment.
const MemoryTransaction
& operator=( const MemoryTransaction
&rhs
)
for (uint_t i
= 0; i
< ((size_
+ 7) >> 3); i
++)
* Return a string representation of this MemoryTransaction object.
std::string
toString() const{
os
<< "reference type: " << ( ref_
== DATA
? "data" : "instruction" ) << "\n";
os
<< "access type: " << ( access_
== READ
? "read" : "write" ) << "\n";
os
<< "virtual addr: 0x" << RIESLING_VADDR_FORMAT
<< vaddr_
<< "\n";
os
<< "physical addr: 0x" << RIESLING_VADDR_FORMAT
<< paddr_
<< "\n";
for( uint_t i
= 0; i
< ((size_
+ 7) >> 3); i
++)
os
<< "0x" << data_
[i
] << " ";
* Return the virtual address of the transaction
VaddrT
vaddr() const { return vaddr_
; }
VaddrT
getVaddr() const { return vaddr_
; }
* Set the virtual address of the transaction
void vaddr( VaddrT va
) { vaddr_
= va
; }
* Return the physical address of the transaction
PaddrT
paddr() const { return paddr_
; }
PaddrT
getPaddr() const { return paddr_
; }
* Set the physcial address of the transaction
void paddr( PaddrT pa
) { paddr_
= pa
; }
* Return the type of the transaction, either DATA or INSTR
RefT
referenceType() const { return ref_
; }
RefT
getReferenceType() const { return ref_
; }
* Set the type of the transaction, either DATA or INSTR
void referenceType( RefT r
) { ref_
= r
; }
* Set access characteristics of the transaction.
* @param val The value of the access word. The following values can be
* ored into the access word:
* READ - a read transaction
* WRITE - a write transaction
* INTERNAL - an internal transaction mean that the transaction may
* not be subject to some MMU checks
void reset_access() { access_
= 0; }
void access( AccessT val
)
assert((val
& (READ
|WRITE
)) && (val
& (READ
|WRITE
)) != (READ
|WRITE
));
AccessT
access() const { return access_
; }
AccessT
getAccess() const { return access_
; }
void size( uint_t s
) { size_
= s
; }
uint8_t size() const { return size_
; }
uint64_t getData ( uint_t dword
= 0 ) const { return data_
[dword
]; }
void setData( uint_t dword
, uint64_t data
) { data_
[dword
] = data
; }
void setData( uint64_t data
) { data_
[0] = data
; }
void setData( uint64_t *data
) {
bool readXact() const { return access_
& READ
; }
bool writeXact() const { return access_
& WRITE
; }
bool internalXact() const { return access_
& INTERNAL
; }
bool memSlamXact() const { return access_
& MEM_SLAM
; }
bool debugXact() const { return access_
& DEBUG
; }
bool tablewalk() const { return access_
& TABLE_WALK
; }
bool noWriteXact() const { return access_
& NO_WRITE
; }
bool followmeXact() const { return access_
& FOLLOW_ME
; }
bool atomicXact() const { return access_
& ATOMIC
; }
bool noOperationXact() const { return access_
& NOP
; }
void setStrand( uint_t id
) { strand
= id
; }
uint_t
getStrand() const { return strand
; }
uint_t strand
; // The strand that generated the transaction.
VaddrT vaddr_
; // The virtual address of the access
PaddrT paddr_
; // The physical address of the access
RefT ref_
; // DATA/INSTR access
AccessT access_
; // READ/WRITE and other flags
uint_t size_
; // The number of bytes this transaction is accessing
uint64_t data_
[8]; // Largest request is 64 bytes
#endif /* __MEMORYTRANSACTION_H__ */