| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * OpenSPARC T2 Processor File: SS_IrqSync.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_IrqSync_h__ |
| 24 | #define __SS_IrqSync_h__ |
| 25 | |
| 26 | #include "SS_Trap.h" |
| 27 | #include "SS_Strand.h" |
| 28 | |
| 29 | class SS_IrqSync |
| 30 | { |
| 31 | public: |
| 32 | SS_IrqSync( SS_Strand* s ); |
| 33 | |
| 34 | // raise() is called by the DUT to cause the simulator to take the indicated |
| 35 | // trap at the next step(). |
| 36 | void raise( SS_Trap::Type irq_type ); |
| 37 | |
| 38 | // check() is called by the simulator just before it steps an instruction. |
| 39 | // It will launch the highest priority trap that has seen store() followed by |
| 40 | // raise() if a trap is pending. If a trap is pending for too long (timed out) |
| 41 | // it will be removed and an error is printed. check() returns true if in trap |
| 42 | // was launched, false otherwise. |
| 43 | bool check() |
| 44 | { |
| 45 | cur_time++; |
| 46 | if (head) |
| 47 | return check_list(); |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | // empty the list |
| 52 | void clear_list(); |
| 53 | |
| 54 | private: |
| 55 | enum { TIME_OUT = 100 }; |
| 56 | |
| 57 | class IrqInfo |
| 58 | { |
| 59 | public: |
| 60 | IrqInfo( SS_Trap::Type _irq_type, uint_t _priority, uint64_t _time_out, IrqInfo* _next=0 ) |
| 61 | : |
| 62 | irq_type(_irq_type), |
| 63 | priority(_priority), |
| 64 | time_out(_time_out), |
| 65 | next(_next) |
| 66 | {} |
| 67 | |
| 68 | SS_Trap::Type irq_type; |
| 69 | uint_t priority; |
| 70 | uint64_t time_out; // Timeout happens when > cur_time, but is not precise!! Who cares?! |
| 71 | IrqInfo* next; |
| 72 | }; |
| 73 | |
| 74 | SS_Strand* strand; // The strand associat6ed with this IrqSync |
| 75 | uint64_t cur_time; // The current time |
| 76 | IrqInfo* head; // The head of priority ordered pending traps (interrupts) |
| 77 | |
| 78 | bool check_list(); |
| 79 | |
| 80 | // store() is called by the simulator to store a trap that has to be taken |
| 81 | // after the device under test (DUT) calls raise(). The do_time_out flag |
| 82 | // is used to force taking the trap at the next check() call. |
| 83 | |
| 84 | static void store( void* irq_sync, SS_Trap::Type irq_type, bool do_time_out ); |
| 85 | }; |
| 86 | |
| 87 | #endif |
| 88 | |