00001 00005 /* 00006 * Copyright (C) 2004 Bregmasoft 00007 * 00008 * This program is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU General Public License as published by the Free 00010 * Software Foundation; either version 2 of the License, or (at your option) 00011 * any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, but WITHOUT 00014 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00016 * more details. 00017 * 00018 * You should have received a copy of the GNU General Public License along 00019 * with this program; if not, write to the Free Software Foundation, Inc., 59 00020 * Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 #ifndef ZYGOMA_INTERRUPT_H_ 00023 #define ZYGOMA_INTERRUPT_H_ 00024 00025 #include <list> 00026 #include <vector> 00027 00028 00029 namespace Zygoma 00030 { 00049 class Interrupt 00050 { 00051 public: 00052 virtual ~Interrupt() = 0; 00053 00065 virtual bool phase1(int interruptNumber, void* serviceData) = 0; 00066 00075 virtual void phase2(int interruptNumber, void* serviceData) = 0; 00076 }; 00077 00078 00082 inline Interrupt:: 00083 ~Interrupt() 00084 { } 00085 00086 00090 struct ISR 00091 { 00092 ISR(Interrupt* serviceObject, void* serviceData) 00093 : m_serviceObject(serviceObject) 00094 , m_serviceData(serviceData) 00095 { } 00096 00097 Interrupt* m_serviceObject; 00098 void* m_serviceData; 00099 }; 00100 00102 typedef std::list<ISR> ISRChain; 00103 00105 typedef std::vector<ISRChain> ISRTable; 00106 00107 00112 class InterruptDispatcher 00113 { 00114 public: 00115 InterruptDispatcher(std::size_t tableSize); 00116 00117 void dispatchInterrupt(int interruptNumber); 00118 00119 private: 00120 ISRTable m_isrTable; 00121 }; 00122 } 00123 00124 #endif // ZYGOMA_INTERRUPT_H_