Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_Access.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: SS_Access.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23
24#ifndef __SS_Access_h__
25#define __SS_Access_h__
26
27#include "SS_Types.h"
28#include "BL_Utils.h"
29
30// SS_Access describes the Sun Sparc memory accesses with a single
31// function. They are used in the I/O devices to handle access.
32
33class SS_Access
34{
35 public:
36 enum Type
37 {
38 LOAD,
39 STORE,
40 STP, // data[0] = store, data[1] = byte mask
41 SWAP, // call: data[0] = rd, return: data[0] = new rd
42 CAS, // call: data[0] = rd, data[1] = rs2, return: data[0] = new rd
43 LDST // call: data[0] ignored, return: data[0] = rd
44 };
45
46 typedef void (*Func) ( void* obj, uint_t sid, Type, SS_Paddr, uint_t size, uint64_t* data );
47
48 // ok() returns true when the access is valid and supported
49 // in terms of available SunSparc memory operations.
50
51 static bool ok( Type type, SS_Paddr pa, uint_t size )
52 {
53 if (!is_power_of_two(size))
54 return false;
55 if ((pa & (size - 1)) != 0)
56 return false;
57 switch (type)
58 {
59 case LOAD: return (size != 32) && (size <= 64);
60 case STORE: return (size != 32) && (size <= 64);
61 case STP: return (size == 8);
62 case SWAP: return (size == 4);
63 case CAS: return (size == 4) || (size == 8);
64 case LDST: return (size == 1);
65 default: return false;
66 }
67 }
68};
69
70#endif