Debian Codegraph @

include/callback.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /* $Id: callback.h,v 1.26 2009-08-23 17:24:54 c2woody Exp $ */
20
21 #ifndef DOSBOX_CALLBACK_H
22 #define DOSBOX_CALLBACK_H
23
24 #ifndef DOSBOX_MEM_H
25 #include "mem.h"
26 #endif
27
28 typedef Bitu (*CallBack_Handler)(void);
29 extern CallBack_Handler CallBack_Handlers[];
30
31 enum { CB_RETN,CB_RETF,CB_RETF8,CB_IRET,CB_IRETD,CB_IRET_STI,CB_IRET_EOI_PIC1,
32 CB_IRQ0,CB_IRQ1,CB_IRQ9,CB_IRQ12,CB_IRQ12_RET,CB_IRQ6_PCJR,CB_MOUSE,
33 CB_INT29,CB_INT16,CB_HOOKABLE,CB_TDE_IRET,CB_IPXESR,CB_IPXESR_RET,
34 CB_INT21 };
35
36 #define CB_MAX 128
37 #define CB_SIZE 32
38 #define CB_SEG 0xF000
39 #define CB_SOFFSET 0x1000
40
41 enum {
42 CBRET_NONE=0,CBRET_STOP=1
43 };
44
45 extern Bit8u lastint;
46
47 static INLINE RealPt CALLBACK_RealPointer(Bitu callback) {
48 return RealMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE));
49 }
50 static INLINE PhysPt CALLBACK_PhysPointer(Bitu callback) {
51 return PhysMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE));
52 }
53
54 static INLINE PhysPt CALLBACK_GetBase(void) {
55 return (CB_SEG << 4) + CB_SOFFSET;
56 }
57
58 Bitu CALLBACK_Allocate();
59
60 void CALLBACK_Idle(void);
61
62
63 void CALLBACK_RunRealInt(Bit8u intnum);
64 void CALLBACK_RunRealFar(Bit16u seg,Bit16u off);
65
66 bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* descr);
67 Bitu CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,PhysPt addr,const char* descr);
68
69 const char* CALLBACK_GetDescription(Bitu callback);
70 bool CALLBACK_Free(Bitu callback);
71
72 void CALLBACK_SCF(bool val);
73 void CALLBACK_SZF(bool val);
74 void CALLBACK_SIF(bool val);
75
76 extern Bitu call_priv_io;
77
78
79 class CALLBACK_HandlerObject{
80 private:
81 bool installed;
82 Bitu m_callback;
83 enum {NONE,SETUP,SETUPAT} m_type;
84 struct {
85 RealPt old_vector;
86 Bit8u interrupt;
87 bool installed;
88 } vectorhandler;
89 public:
90 CALLBACK_HandlerObject():installed(false),m_type(NONE) {
91 vectorhandler.installed=false;
92 }
93 ~CALLBACK_HandlerObject();
94
95 //Install and allocate a callback.
96 void Install(CallBack_Handler handler,Bitu type,const char* description);
97 void Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description);
98
99 //Only allocate a callback number
100 void Allocate(CallBack_Handler handler,const char* description=0);
101 Bit16u Get_callback() {
102 return (Bit16u)m_callback;
103 }
104 RealPt Get_RealPointer() {
105 return CALLBACK_RealPointer(m_callback);
106 }
107 void Set_RealVec(Bit8u vec);
108 };
109 #endif