Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / memsync / src / RieslingInterface.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: RieslingInterface.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 _RIESLINGINTERFACE_H
#define _RIESLINGINTERFACE_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."
**
*************************************************************************/
#define N2MODEL something_sane
#include <iostream>
#include "MemoryTransaction.h"
#include "MemorySyncDefs.h"
#include "MemorySyncMessage.h"
#include "SS_Io.h"
class RieslingInterface{
public:
static int max_strands;
static int strands_per_core;
static int cores_per_cpu;
/**
* Default constructor
*/
RieslingInterface()
:io(&SS_Io::io)
{};
/**
* Destructor
*/
virtual ~RieslingInterface(){};
uint64_t readMemory(uint32_t cid, uint32_t tid, uint64_t addr, uint_t size, int convert=1);
void writeMemory(uint32_t cid, uint32_t tid, uint64_t addr, uint64_t data, uint_t size, int convert=1);
void slamMemory(uint32_t cid, uint32_t tid, uint64_t addr, uint64_t data, uint_t size, int convert=1);
uint64_t convertPA(int cid, int tid, uint64_t pa);
void setMaxStrands(int strands) { max_strands= strands; }
void setCoreStrands(int strands) { strands_per_core= strands; }
void setCpuCores(int cores) { cores_per_cpu = cores; }
uint64_t getBits(uint64_t data, int ubit, int lbit, bool shift=false) {
if (((ubit - lbit) >= 63) || (ubit < lbit)) {
return data;
}
else {
uint64_t newData = (data >> lbit) & ((1ULL << (ubit - lbit + 1)) - 1);
if (shift == true) {
// shift data back to its original bit-location
newData = newData << lbit;
}
//std::cerr << "DBX: data=0x" << std::hex << data << " (ub=" << std::dec << ubit << " lb=" << lbit << ") newData=0x" << std::hex << newData << std::endl;//DBX
return newData;
}
}
private:
SS_Io *io;
};
#endif /* _RIESLINGINTERFACE_H */