Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / memsync / src / MemoryAccessBuffer.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: MemoryAccessBuffer.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 _MEMORYACCESSBUFFER_H
#define _MEMORYACCESSBUFFER_H
/************************************************************************
**
** Copyright (C) 2002, Sun Microsystems, Inc.
**
** Sun considers its source code as an unpublished, proprietary
** trade secret and it is available only under strict license provisions.
** This copyright notice is placed here only to protect Sun in the event
** the source is deemed a published work. Disassembly, decompilation,
** or other means of reducing the object code to human readable form
** is prohibited by the license agreement under which this code is
** provided to the user or company in possession of this copy."
**
*************************************************************************/
#include <iostream>
#include <list>
#include <vector>
#include "MemorySyncDefs.h"
#include "LoadStoreCmd.h"
#include "MemoryAccessEntry.h"
#include "TsoChecker.h"
using namespace Tso;
class MemoryAccessBuffer {
public:
/**
* Default constructor
*/
MemoryAccessBuffer();
/**
* Copy constructor
*
* @param orig The MemoryAccessBuffer object to copy.
*/
MemoryAccessBuffer( const MemoryAccessBuffer &orig );
/**
* Destructor
*/
virtual ~MemoryAccessBuffer();
/**
* Equality operator
*
* @param rhs The right hand side of the equality operator
* @return Return true if this objec and rhs are equal,
* otherwise return false
*/
bool operator==( const MemoryAccessBuffer &rhs ) const;
/**
* Assignment operator
*
* @param rhs The right hand side of the assignment operator.
* @return The lvalue of the assignment.
*/
const MemoryAccessBuffer & operator=( const MemoryAccessBuffer &rhs );
/**
* Return a string representation of this MemoryAccessBuffer object.
*/
std::string toString() const;
std::list<MemoryAccessEntry>::iterator end() { return buf_.end(); }
std::list<MemoryAccessEntry>::iterator begin() { return buf_.begin(); }
void insert(enum MEM_CMD cmd);
void dequeue(std::list<MemoryAccessEntry>::iterator ii);
std::list<MemoryAccessEntry>::iterator findL1InstrEntry(LoadStoreCmd& cmd);
std::list<MemoryAccessEntry>::iterator findL1DataEntry(LoadStoreCmd& cmd);
std::list<MemoryAccessEntry>::iterator
findL2DataEntry(std::list<MemoryAccessEntry>::iterator from, LoadStoreCmd& cmd);
std::list<MemoryAccessEntry>::iterator findStoreInvStoreUpdateSrc(LoadStoreCmd& cmd);
std::list<MemoryAccessEntry>::iterator findStoreAckSrc(LoadStoreCmd& cmd);
std::list<MemoryAccessEntry>::iterator findLoadFillSrc(LoadStoreCmd& cmd);
std::list<MemoryAccessEntry>::iterator findFetchFillSrc(LoadStoreCmd& cmd);
std::list<MemoryAccessEntry>::iterator findEvictInvSrc(LoadStoreCmd& cmd);
std::list<MemoryAccessEntry>::iterator matchedL2Miss(std::list<MemoryAccessEntry>::iterator ii);
std::list<MemoryAccessEntry>::iterator pushBack(MemoryAccessEntry& entry);
void popFront(std::vector<MemoryAccessEntry>* wdbuf,
Tso::TsoChecker* tsoChecker);
/**
* erase entries of specified strand-id
*/
void empty(int tid=-1);
/**
* pop the last load entry of a particular strand out of the queue
*/
void popBack(int tid, int count=1);
void popBackStore(std::list<MemoryAccessEntry>::iterator& jj);
/**
* functions to ensure load entries maintain correct data after a store
* entry is poped due to error injection
*/
std::list<MemoryAccessEntry>::iterator findL1DataEntry(std::list<MemoryAccessEntry>::iterator from, uint32_t cid, uint32_t tid, uint64_t addr);
std::list<MemoryAccessEntry>::iterator findL2DataEntry(std::list<MemoryAccessEntry>::iterator from, uint32_t cid, uint32_t tid, uint64_t addr, bool executed=false);
std::list<MemoryAccessEntry>::iterator findLoadFillSrc(std::list<MemoryAccessEntry>::iterator endMark, uint32_t cid, uint32_t tid, uint64_t addr, bool noFault=false);
uint64_t getL1Data(std::list<MemoryAccessEntry>::iterator from, uint32_t cid, uint32_t tid, uint64_t addr);
uint64_t getL2Data(std::list<MemoryAccessEntry>::iterator from, uint32_t cid, uint32_t tid, uint64_t addr, bool executed=false);
void refreshLoadEntry(std::list<MemoryAccessEntry>::iterator fromMark);
void setRieslingInterface(RieslingInterface* rs) { rif_ = rs; }
uint64_t merge (uint64_t todata, uint64_t fromdata, uint8_t mgvec);
uint64_t byteMask(const uint8_t vbyte);
/**
* search for the first matching dma_store entry with inv_vec==0
*/
std::list<MemoryAccessEntry>::iterator findDmaStoreEntry(LoadStoreCmd& cmd, int type);
std::list<MemoryAccessEntry>::iterator findDmaStoreStart(LoadStoreCmd& cmd, int type);
bool updateMemory(std::list<MemoryAccessEntry>::iterator stCommit);
protected:
private:
std::list<MemoryAccessEntry> buf_;
RieslingInterface* rif_;
};
#endif /* _MEMORYACCESSBUFFER_H */