Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / pli / src / SS_IrqSync.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: SS_IrqSync.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_IrqSync_h__
#define __SS_IrqSync_h__
#include "SS_Trap.h"
#include "SS_Strand.h"
class SS_IrqSync
{
public:
SS_IrqSync( SS_Strand* s );
// raise() is called by the DUT to cause the simulator to take the indicated
// trap at the next step().
void raise( SS_Trap::Type irq_type );
// check() is called by the simulator just before it steps an instruction.
// It will launch the highest priority trap that has seen store() followed by
// raise() if a trap is pending. If a trap is pending for too long (timed out)
// it will be removed and an error is printed. check() returns true if in trap
// was launched, false otherwise.
bool check()
{
cur_time++;
if (head)
return check_list();
return false;
}
// empty the list
void clear_list();
private:
enum { TIME_OUT = 100 };
class IrqInfo
{
public:
IrqInfo( SS_Trap::Type _irq_type, uint_t _priority, uint64_t _time_out, IrqInfo* _next=0 )
:
irq_type(_irq_type),
priority(_priority),
time_out(_time_out),
next(_next)
{}
SS_Trap::Type irq_type;
uint_t priority;
uint64_t time_out; // Timeout happens when > cur_time, but is not precise!! Who cares?!
IrqInfo* next;
};
SS_Strand* strand; // The strand associat6ed with this IrqSync
uint64_t cur_time; // The current time
IrqInfo* head; // The head of priority ordered pending traps (interrupts)
bool check_list();
// store() is called by the simulator to store a trap that has to be taken
// after the device under test (DUT) calls raise(). The do_time_out flag
// is used to force taking the trap at the next check() call.
static void store( void* irq_sync, SS_Trap::Type irq_type, bool do_time_out );
};
#endif