Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_Signal.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: SS_Signal.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_Signal_h__
#define __SS_Signal_h__
#include "BL_Mutex.h"
#include "SS_BreakPoint.h"
#include "SS_Tte.h"
#include "SS_Trap.h"
class SS_Tlb;
class SS_Strand;
class SS_Signal
{
public:
// The Type are the signal types used in Vonk to tell a
// strand to do something before the next instruction
enum Type
{
FREE, // Explict free signal
RUNNING, // Change in running status of the strand
FLUSH_TTE, // Tell the strand to remove cached TTE from decode cache
FLUSH_VA, // Tell the strand to flush the opcode(2) (64 bit) at given va
FLUSH_8B, // Tell the strand to flush 8 bytes at given pa
FLUSH_8K, // Tell the strand to flush an 8k page at given pa
FLUSH_ALL, // Tell the strand to flush the whole Icache (decode cache)
BREAKPOINT, // Tell the strand it hit a breakpoint
EXTERNAL_INTERRUPT, // An external interrupt (cross call, dev mondo, ..)
SET_INST_BRKPT // Update sim_state.ib_enabled(x)
};
SS_Signal( Type t ) : type(t), next(0) {}
void init( Type t, SS_Signal* n=0 ) { type =t; next = n; }
Type type;
SS_Signal* next; // Link the signals in a list
union
{
bool running; // New running status
bool ib_enable; // New inst breakpoint check status
SS_BreakPoint* breakpoint; // The breakpoint that hit
int_t irq_type; // The (trap) type of the interrupt
SS_Tte* tte; // The TTE to demap from decode cache, 0 is all TTEs
SS_Vaddr flush_va; // The va of the double word to flush from the icache
SS_Paddr flush_pa; // The va of the double word to flush from the icache
};
union
{
SS_Tlb* tlb; // Flush tte flush from which tlb
bool irq_raise; // True raise irq, False retract irq
};
void dump();
static SS_Signal* free_list;
static BL_Mutex free_mutex;
static SS_Signal* alloc_block();
static const uint_t NR_BLOCK_SIGNAL = 256;
// alloc() returns a SS_Signal instance with type set to type.
// Don't use this function if you have direct access to a SS_Strand.
// Use s->msg.make_signal(type) if you can.
inline static SS_Signal* alloc( SS_Signal::Type type )
{
free_mutex.lock();
SS_Signal* help = free_list;
if (help == 0)
help = alloc_block();
else
free_list = help->next;
free_mutex.unlock();
help->init(type);
return help;
}
// frees a list of SS_Signal blocks
// All elements of the list to free must be marked as type=FREE.
inline static void list_free( SS_Signal* head, SS_Signal* tail )
{
free_mutex.lock();
tail->next = free_list;
free_list = head;
free_mutex.unlock();
}
};
#endif