Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_Model.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: SS_Model.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_Model_h__
25#define __SS_Model_h__
26
27#include "SS_Node.h"
28#include "SS_Cpu.h"
29#include "SS_Strand.h"
30#include "SS_MemErrDetector.h"
31
32class SS_Model : public SS_Node
33{
34 public:
35 // SS_Model() takes as version number argument. The version is
36 // used for versioning snapshots. If the snaphot files becomes
37 // different then we should use a new version number (+1)
38
39 // potential error/exception posted by sub-component like I/O space. Use
40 // each bit to represent an error type.
41 enum ErrorBit
42 {
43 IO_RSVD_READ = 0x1 << 0
44 };
45 enum
46 {
47 MAX_ERROR_SIZE=1024
48 };
49
50 friend ErrorBit operator|( ErrorBit a, ErrorBit b ) { return ErrorBit(int(a)|int(b)); }
51 friend ErrorBit operator&( ErrorBit a, ErrorBit b ) { return ErrorBit(int(a)&int(b)); }
52 friend ErrorBit operator~( ErrorBit a ) { return ErrorBit(~int(a)); }
53
54 SS_Model();
55
56 void hard_reset();
57 // intp is used to indicate whether a WMR trap should be triggered (at
58 // strand level). A warm_reset() with intp=false will reset registers
59 // to warm_reset state, but will not invoke the WMR trap routine.
60 void warm_reset(bool intp=true);
61 void xtrn_reset();
62
63 enum { MAX_CPU_COUNT = 64 }; // Current limit, just ficticious
64
65 // create_cpu() create a given number of cpus and adds them to
66 // the cpus that have already been created.
67
68 virtual void create_cpu( uint_t no_cpu ) = 0;
69 virtual void create_cpu_dynamic( uint_t no_cpu, int no_core=1 ) { create_cpu(no_cpu); }
70
71 // cpu_cnt() returns the number of cpu's available in the model
72
73 uint_t cpu_cnt() { return cpu_count; }
74
75 // cpu[] is the area of created cpu instances
76
77 SS_Cpu* cpu[MAX_CPU_COUNT];
78
79 // snapshot() is called to take a snapshot of the whole model
80
81 virtual void snapshot( SS_SnapShot& );
82
83 // flush() broadcasts the flush to all the strands in the cpus.
84 // SS_Strand is the strand that issues the flush. When this returns
85 // false it means the flush is not broadcast: 1 strand running case.
86
87 bool flush( SS_Strand* s, SS_Paddr pa, uint_t size );
88
89 // flush() flush pa frin the decode cache of all strands. This
90 // flush is very usefull for frontends.
91
92 void flush( SS_Paddr pa );
93
94 // ras_flush() is called to flush RAS related cache models if a
95 // flush or flushw instrucion is executed
96 void ras_flush( SS_Strand* requesting_strand, SS_Paddr pa, uint64_t size, SS_MemErrDetector::CacheType type );
97
98 // ras enable from frontend
99 virtual void ras_enable(char* cmd);
100
101 // place holder for posting errors
102 ErrorBit get_error( int strand_id ) { assert(strand_id<MAX_ERROR_SIZE); return errors[strand_id]; }
103 void set_error( int strand_id, ErrorBit err ) { assert(strand_id<MAX_ERROR_SIZE); errors[strand_id] = err; }
104 void clr_error( int strand_id, ErrorBit err ) { assert(strand_id<MAX_ERROR_SIZE); errors[strand_id] = errors[strand_id] & ~err; }
105
106 protected:
107 uint_t cpu_count; // Number of cpu objects set in cpu array
108
109 ErrorBit errors[MAX_ERROR_SIZE];
110};
111
112#endif