Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_Signal.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: SS_Signal.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#ifndef __SS_Signal_h__
24#define __SS_Signal_h__
25
26#include "BL_Mutex.h"
27#include "SS_BreakPoint.h"
28#include "SS_Tte.h"
29#include "SS_Trap.h"
30
31class SS_Tlb;
32class SS_Strand;
33
34class SS_Signal
35{
36 public:
37 // The Type are the signal types used in Vonk to tell a
38 // strand to do something before the next instruction
39
40 enum Type
41 {
42 FREE, // Explict free signal
43 RUNNING, // Change in running status of the strand
44 FLUSH_TTE, // Tell the strand to remove cached TTE from decode cache
45 FLUSH_VA, // Tell the strand to flush the opcode(2) (64 bit) at given va
46 FLUSH_8B, // Tell the strand to flush 8 bytes at given pa
47 FLUSH_8K, // Tell the strand to flush an 8k page at given pa
48 FLUSH_ALL, // Tell the strand to flush the whole Icache (decode cache)
49 BREAKPOINT, // Tell the strand it hit a breakpoint
50 EXTERNAL_INTERRUPT, // An external interrupt (cross call, dev mondo, ..)
51 SET_INST_BRKPT // Update sim_state.ib_enabled(x)
52 };
53
54 SS_Signal( Type t ) : type(t), next(0) {}
55
56 void init( Type t, SS_Signal* n=0 ) { type =t; next = n; }
57
58 Type type;
59 SS_Signal* next; // Link the signals in a list
60
61 union
62 {
63 bool running; // New running status
64 bool ib_enable; // New inst breakpoint check status
65 SS_BreakPoint* breakpoint; // The breakpoint that hit
66 int_t irq_type; // The (trap) type of the interrupt
67 SS_Tte* tte; // The TTE to demap from decode cache, 0 is all TTEs
68 SS_Vaddr flush_va; // The va of the double word to flush from the icache
69 SS_Paddr flush_pa; // The va of the double word to flush from the icache
70 };
71 union
72 {
73 SS_Tlb* tlb; // Flush tte flush from which tlb
74 bool irq_raise; // True raise irq, False retract irq
75 };
76
77 void dump();
78
79 static SS_Signal* free_list;
80 static BL_Mutex free_mutex;
81
82 static SS_Signal* alloc_block();
83 static const uint_t NR_BLOCK_SIGNAL = 256;
84
85
86 // alloc() returns a SS_Signal instance with type set to type.
87 // Don't use this function if you have direct access to a SS_Strand.
88 // Use s->msg.make_signal(type) if you can.
89
90 inline static SS_Signal* alloc( SS_Signal::Type type )
91 {
92 free_mutex.lock();
93 SS_Signal* help = free_list;
94 if (help == 0)
95 help = alloc_block();
96 else
97 free_list = help->next;
98 free_mutex.unlock();
99 help->init(type);
100 return help;
101 }
102
103 // frees a list of SS_Signal blocks
104 // All elements of the list to free must be marked as type=FREE.
105 inline static void list_free( SS_Signal* head, SS_Signal* tail )
106 {
107 free_mutex.lock();
108 tail->next = free_list;
109 free_list = head;
110 free_mutex.unlock();
111 }
112};
113
114#endif