Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / memsync / src / LoadStoreBuffer.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: LoadStoreBuffer.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 _LOADSTOREBUFFER_H
#define _LOADSTOREBUFFER_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 <assert.h>
#include "MemorySyncDefs.h"
#include "LoadStoreCmd.h"
#include "LoadStoreEntry.h"
#include <list>
#include <cstring>
class LoadStoreBuffer {
public:
/**
* Default constructor
*/
LoadStoreBuffer();
/**
* Copy constructor
*
* @param orig The LoadStoreBuffer object to copy.
*/
LoadStoreBuffer( const LoadStoreBuffer &orig );
/**
* Destructor
*/
virtual ~LoadStoreBuffer();
/**
* 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 LoadStoreBuffer &rhs ) const;
/**
* Assignment operator
*
* @param rhs The right hand side of the assignment operator.
* @return The lvalue of the assignment.
*/
const LoadStoreBuffer & operator=( const LoadStoreBuffer &rhs );
/**
* Return a string representation of this LoadStoreBuffer object.
*/
std::string toString() const;
void setBufName (char* name) { strcpy (bufName_, name); }
char* getBufName () { return bufName_; }
void insert (LoadStoreCmd& cmd);
std::list<LoadStoreEntry>::iterator pushBack(LoadStoreEntry& cmd);
void erase(std::list<LoadStoreEntry>::iterator ii);
void popFront();
void popBack(int count=1);
std::list<LoadStoreEntry>::iterator findMatchY2O(uint64_t addr, uint8_t size_vector);
std::list<LoadStoreEntry>::iterator findMatchY2O(uint64_t id, uint64_t addr, uint8_t size_vector);
std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t addr, uint8_t size_vector);
std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t id, uint64_t addr, uint8_t size_vector);
std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t addr, enum LS_ENTRY_STATE state, uint64_t addrMask);
std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t addr);
std::list<LoadStoreEntry>::iterator findNotIssuedO2Y(uint64_t addr);
std::list<LoadStoreEntry>::iterator find1stNonExe();
std::list<LoadStoreEntry>::iterator find1stNonExeMatchedAddr(uint64_t addr);
std::list<LoadStoreEntry>::iterator find1stNonExeOrMatchedAddrAtomic(uint64_t addr);
std::list<LoadStoreEntry>::iterator findNeedTDataO2Y(uint64_t addr);
/**
* Method to find data bypassing
* <p>
* This method attempts to find matched entry that satisfies the data access request.
* Note that the search is from back to front, i.e., young to old.
* <p>
* The rule of searching is <br>
* - partial fulfill the request, return buf_.end()
* - fully comply with the request, return the matched entry's iterator
* - no match, try next
* @param addr address to be matched, the 3 least significant bits are ignored
* @param size_vector valid bytes of data to ask
* @return entry iterator that satisfies the request; otherwise, return buf_.end()
*/
std::list<LoadStoreEntry>::iterator findDataBypassing (uint64_t addr, uint8_t size_vector);
std::list<LoadStoreEntry>::iterator findN2DataBypassing (uint64_t addr, uint8_t size_vector);
std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t addr, bool rmo, uint64_t addrMask);
std::list<LoadStoreEntry>::iterator LoadStoreBuffer::find1stNonExeFetch(uint64_t addr);
std::list<LoadStoreEntry>::iterator find1stNoLink(uint64_t id, uint64_t addr, uint64_t addrMask);
std::list<LoadStoreEntry>::reference front() { return buf_.front(); }
std::list<LoadStoreEntry>::iterator end() { return buf_.end(); }
std::list<LoadStoreEntry>::iterator begin() { return buf_.begin(); }
std::list<LoadStoreEntry>::size_type size() { return buf_.size(); }
std::list<LoadStoreEntry>* getBufPtr() { return &buf_; }
/*
* empty the buffer
*/
void empty();
std::list<LoadStoreEntry>::iterator queryBack();
/**
*
*/
void markPop();
protected:
private:
std::list<LoadStoreEntry> buf_;
char bufName_[30];
};
#endif /* _LOADSTOREBUFFER_H */