DOSBox-X
|
00001 /* 00002 * Copyright (C) 2002-2020 The DOSBox Team 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with this program; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 00020 #ifndef DOSBOX_CALLBACK_H 00021 #define DOSBOX_CALLBACK_H 00022 00023 #ifndef DOSBOX_MEM_H 00024 #include "mem.h" 00025 #endif 00026 00027 typedef Bitu (*CallBack_Handler)(void); 00028 extern CallBack_Handler CallBack_Handlers[]; 00029 00030 enum { CB_RETN,CB_RETF,CB_RETF8,CB_IRET,CB_IRETD,CB_IRET_STI,CB_IRET_EOI_PIC1, 00031 CB_IRQ0,CB_IRQ1,CB_IRQ1_BREAK,CB_IRQ9,CB_IRQ12,CB_IRQ12_RET,CB_IRQ6_PCJR,CB_MOUSE, 00032 /*CB_INT28,*/CB_INT29,CB_INT16,CB_HOOKABLE,CB_TDE_IRET,CB_IPXESR,CB_IPXESR_RET, 00033 CB_INT21,CB_INT13,CB_VESA_WAIT,CB_VESA_PM,CB_IRET_EOI_PIC2,CB_CPM, 00034 CB_RETF_STI,CB_RETF_CLI}; 00035 00036 /* NTS: Cannot make runtime configurable, because CB_MAX is used to define an array */ 00037 #define CB_MAX 128U 00038 #define CB_SIZE 32U 00039 00040 /* we can make THESE configurable though! */ 00041 //#define CB_SEG 0xF000 00042 //#define CB_SOFFSET 0x1000 00043 extern Bit16u CB_SEG,CB_SOFFSET; 00044 00045 enum { 00046 CBRET_NONE=0,CBRET_STOP=1 00047 }; 00048 00049 extern Bit8u lastint; 00050 00051 static INLINE RealPt CALLBACK_RealPointer(Bitu callback) { 00052 return RealMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE)); 00053 } 00054 static INLINE PhysPt CALLBACK_PhysPointer(Bitu callback) { 00055 return PhysMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE)); 00056 } 00057 00058 static inline PhysPt CALLBACK_GetBase(void) { 00059 return (PhysPt)(((PhysPt)CB_SEG << (PhysPt)4U) + (PhysPt)CB_SOFFSET); 00060 } 00061 00062 Bit8u CALLBACK_Allocate(); 00063 00064 void CALLBACK_Idle(void); 00065 00066 00067 void CALLBACK_RunRealInt(Bit8u intnum); 00068 void CALLBACK_RunRealFar(Bit16u seg,Bit16u off); 00069 void CALLBACK_RunRealFarInt(Bit16u seg,Bit16u off); 00070 00071 bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* descr); 00072 Bitu CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,PhysPt addr,const char* descr); 00073 00074 void CALLBACK_SetDescription(Bitu nr, const char* descr); 00075 const char* CALLBACK_GetDescription(Bitu nr); 00076 00077 void CALLBACK_SCF(bool val); 00078 void CALLBACK_SZF(bool val); 00079 void CALLBACK_SIF(bool val); 00080 00081 extern Bitu call_priv_io; 00082 00083 00084 class CALLBACK_HandlerObject{ 00085 private: 00086 bool installed; 00087 Bitu m_callback; 00088 enum {NONE,SETUP,SETUPAT} m_type; 00089 struct { 00090 RealPt old_vector; 00091 Bit8u interrupt; 00092 bool installed; 00093 } vectorhandler; 00094 public: 00095 CALLBACK_HandlerObject():installed(false),m_callback(0/*NULL*/),m_type(NONE) { 00096 vectorhandler.installed=false; 00097 } 00098 ~CALLBACK_HandlerObject(); 00099 00100 //Install and allocate a callback. 00101 void Install(CallBack_Handler handler,Bitu type,const char* description); 00102 void Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description); 00103 00104 void Uninstall(); 00105 00106 //Only allocate a callback number 00107 void Allocate(CallBack_Handler handler,const char* description=0); 00108 Bit16u Get_callback() { 00109 return (Bit16u)m_callback; 00110 } 00111 RealPt Get_RealPointer() { 00112 return CALLBACK_RealPointer(m_callback); 00113 } 00114 void Set_RealVec(Bit8u vec,bool reinstall=false); 00115 }; 00116 #endif