1 /* Definitions to support devices that can generate interrupts. 2 Copyright 2001, 2002 Brian R. Gaeke. 3 Copyright 2002, 2003 Paul Twohey. 4 5 This file is part of VMIPS. 6 7 VMIPS is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published by the 9 Free Software Foundation; either version 2 of the License, or (at your 10 option) any later version. 11 12 VMIPS is distributed in the hope that it will be useful, but 13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 for more details. 16 17 You should have received a copy of the GNU General Public License along 18 with VMIPS; if not, write to the Free Software Foundation, Inc., 19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 20 21 #ifndef _DEVICEINT_H_ 22 #define _DEVICEINT_H_ 23 24 #include "intctrl.h" 25 26 /* Interrupt lines that DeviceInts can use. 27 These constants correspond to the bits of the Interrupt Pending (IP) 28 field of the Cause register of CP0, and to the bits of the Interrupt Mask 29 (IM) field of the Status register of CP0. See cpzeroreg.h. */ 30 #define IRQ7 0x00008000 31 #define IRQ6 0x00004000 32 #define IRQ5 0x00002000 33 #define IRQ4 0x00001000 34 #define IRQ3 0x00000800 35 #define IRQ2 0x00000400 36 37 /* These are for use by software only, NOT hardware! */ 38 #define IRQ1 0x00000200 39 #define IRQ0 0x00000100 40 41 /* A class which describes a device that can trigger hardware interrupts 42 in the processor. DeviceInts can be connected to an IntCtrl 43 (interrupt controller). */ 44 class DeviceInt { 45 public: 46 /* Given a value (LINE) representing one of the bits of the 47 Cause register (IRQ7 .. IRQ0 in deviceint.h), return a string 48 that describes the corresponding interrupt line. The string is 49 returned in a static buffer, so the next call to strlineno will 50 overwrite the result. */ 51 static char *strlineno(uint32 line); 52 53 /* Return the bit of the CP0 Status and Cause registers corresponding 54 to interrupt line number NUM, or 0 if no such interrupt line exists. */ 55 static uint32 num2irq(uint32 num); 56 ~DeviceInt()57 virtual ~DeviceInt() { } 58 59 protected: 60 /* Assert an interrupt request on interrupt line LINE, which 61 must be one of the IRQ7 .. IRQ0 constants in deviceint.h. An 62 interrupt thus asserted remains asserted until it is explicitly 63 deasserted. */ 64 void assertInt(uint32 line); 65 66 /* Deassert an interrupt request on interrupt line LINE, which 67 must be one of the IRQ7 .. IRQ0 constants in deviceint.h. Note 68 that if one device deasserts the interrupt request, that doesn't 69 necessarily mean that the interrupt line will go to zero; 70 another device may be sharing the same interrupt line. */ 71 void deassertInt(uint32 line); 72 73 /* This method, in derived classes, should return a string describing 74 the device. */ 75 virtual const char *descriptor_str(void) const = 0; 76 77 DeviceInt(); 78 79 private: 80 void reportAssert(uint32 line); 81 void reportAssertDisconnected(uint32 line); 82 void reportDeassert(uint32 line); 83 void reportDeassertDisconnected(uint32 line); 84 85 friend class IntCtrl; 86 87 uint32 lines_connected; 88 uint32 lines_asserted; 89 bool opt_reportirq; 90 }; 91 92 #endif /* _DEVICEINT_H_ */ 93