* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: SS_BaseCsr.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 ============================================
/************************************************************************
** 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_CsrAttribute.h"
#include "MemoryTransaction.h"
* class represents csr follow-me data
FollowMeData() : addr(0), data(0), sid(-1) { }
FollowMeData(SS_Paddr _addr
, uint64_t _data
, int _sid
) :
addr(_addr
), data(_data
), sid(_sid
) { }
// make sure there is no conflict with MemoryTransaction::Access_T
NO_FOLLOW_ME
= 1 << 10 // internal access, do not pop follow-me value
static void access( void* obj
,
virtual int read64( SS_Paddr addr
,
int access
=MemoryTransaction::READ
,
virtual int write64( SS_Paddr addr
,
int access
=MemoryTransaction::WRITE
,
virtual std::string
toString() const
return std::string("SS_BaseCs::toString() not implemented");
int64_t findAttributeEntryNdx(SS_Paddr addr
,
const RegisterAttribute
*const attributeTable
,
const RegisterAttribute
* const
findAttributeEntry(SS_Paddr addr
,
const RegisterAttribute
*const attributeTable
,
void warmReset(std::vector
<std::vector
<RegisterValue
>*>* values
,
uint64_t reverseByteOrder(uint64_t value
, bool littleEndian
);
uint64_t forceWrite(uint64_t inputData
,
const RegisterAttribute
* attribute
,
uint64_t normalWrite(uint64_t inputData
,
const RegisterAttribute
* attribute
,
* if a derived class needs to register its address range, the derived
* class should overwrite the regAddrSpace() function.
virtual void regAddrSpace() { /* default, do nothing */ }
* local I/O address <-> global I/O address conversion,
virtual SS_Paddr
local2global(SS_Paddr addr
, int sid
) { return addr
; }
virtual SS_Paddr
global2local(SS_Paddr addr
) { return addr
; }
virtual SS_Paddr
addr_node0(SS_Paddr addr
) { return addr
; }
virtual bool is_global_addr(SS_Paddr addr
) { return true; }
virtual int get_node_id(SS_Paddr addr
) { return 0; }
SS_BaseCsr(std::string className
,
const RegisterAttribute
* const attributeTable
,
int nrAttributeEntries
) :
attributeTable_(attributeTable
),
nrAttributeEntries_(nrAttributeEntries
),
values_(new std::vector
<std::vector
<RegisterValue
>*>[nrAttributeEntries
])
const std::string className_
;
// Attribute table for derived class
const RegisterAttribute
* const attributeTable_
;
// Nr entries in attribute table
const int nrAttributeEntries_
;
void registerAddressSpace(RegisterAttribute
*attributeTable
,
const std::string
&descr
);
// values_ is a 3-dimention structure, the top level has an 1-to-1
// mapping with each CSR entry in the corresponding RegisterAttribute
// table, the second level has one entry for each node (i.e., cpu), the
// third level is a structure of vector<RegisterValue>, where each entry
// represents an addr entity of a (CSR,node-id,addr) triple of a particular
// CSR in the RegisterAttribute table. The reason for having a vector at
// the third level is that each CSR entry in the RegisterAttribute table
// can spawn out one or more addrs, depending on the CSR's (count,stride)
std::vector
<std::vector
<RegisterValue
>*>* values_
;
// the followme_ is a list of objects, each object represents a csr
// follow-me value, the objects are kept in FIFO order, once an object
// in the list is used, it should be removed from the list, as follow-me
// uses "use-once-and-discard" scheme.
std::list
<FollowMeData
> followme_
;
// gaddr - global I/O address, laddr - local I/O address
int write64_notCsr( SS_Paddr gaddr
, uint64_t data
);
int read64_notCsr( SS_Paddr gaddr
, SS_Paddr laddr
, uint64_t* data
);
int read_memimage( SS_Paddr gaddr
, SS_Paddr laddr
, uint64_t* data
);