Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / csr / src / SS_Csr.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: SS_Csr.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 SS_CSR_H
#define SS_CSR_H
/************************************************************************
**
** Copyright (C) 2006, 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 "SS_Io.h"
#include "MemoryTransaction.h"
class SS_Csr
{
public:
// a derived class must define a static access_io() function to be
// registered in SS_Io to handle I/O address operation.
//static int access_io(void* obj, int sid, int type, uint64_t addr, uint32_t size, uint64_t* data, uint64_t bitmask);
SS_Csr() : followme_(false) { }
/**
* potential read access type includes: READ, INTERNAL, etc.
*
* INTERNAL will allow read from WO registers/fields.
*/
virtual int read64(SS_Paddr pa,
uint64_t *data,
int access=MemoryTransaction::READ,
int sid=-1)
{ return SS_Io::NOT_HANDLED; }
/**
* potential write access type includes: WRITE, INTERNAL, FOLLOW_ME,
* MEM_SLAM, LITTLE_ENDIAN, etc
*
* when set FOLLOW_ME, write a csr follow-me value to the corresponding
* csr register, the write does not affect the real csr register value, the
* follow-me value is kept in a special queue, and follows a "FIFO &
* use-once-and discard" rule.
*
* INTERNAL will allow write to RO (and non-reserved) registers/fields.
*/
virtual int write64(SS_Paddr pa,
uint64_t value,
int access=MemoryTransaction::WRITE,
int sid=-1)
{ return SS_Io::NOT_HANDLED; }
void set_followme(bool val) { followme_ = val; }
bool get_followme() { return followme_; }
protected:
// a derived class should define a address_map() function to check on
// valid csr address ranges.
SS_Io::access_io_status address_map( SS_Paddr paddr, int access, int sid) { return SS_Io::NOT_HANDLED; }
bool followme_;
};
#endif /* SS_CSR_RANGE_H */