1
0
Fork 0

fix manual uninstall functions for callback/io-handler objects; cleanup

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3725
This commit is contained in:
Sebastian Strohhäcker 2011-06-19 13:21:11 +00:00
parent 34f49734f3
commit df67bd2afb
2 changed files with 34 additions and 31 deletions

View file

@ -45,7 +45,7 @@ Bitu CALLBACK_Allocate(void) {
for (Bitu i=1;(i<CB_MAX);i++) {
if (CallBack_Handlers[i]==&illegal_handler) {
CallBack_Handlers[i]=0;
return i;
return i;
}
}
E_Exit("CALLBACK:Can't allocate handler.");
@ -56,7 +56,7 @@ void CALLBACK_DeAllocate(Bitu in) {
CallBack_Handlers[in]=&illegal_handler;
}
void CALLBACK_Idle(void) {
/* this makes the cpu execute instructions to handle irq's and then come back */
Bitu oldIF=GETFLAG(IF);
@ -69,7 +69,7 @@ void CALLBACK_Idle(void) {
reg_eip=oldeip;
SegSet16(cs,oldcs);
SETFLAGBIT(IF,oldIF);
if (!CPU_CycleAutoAdjust && CPU_Cycles>0)
if (!CPU_CycleAutoAdjust && CPU_Cycles>0)
CPU_Cycles=0;
}
@ -108,24 +108,24 @@ void CALLBACK_RunRealInt(Bit8u intnum) {
}
void CALLBACK_SZF(bool val) {
Bit16u tempf = mem_readw(SegPhys(ss)+reg_sp+4);
if (val) tempf |= FLAG_ZF;
else tempf &= ~FLAG_ZF;
mem_writew(SegPhys(ss)+reg_sp+4,tempf);
Bit16u tempf = mem_readw(SegPhys(ss)+reg_sp+4);
if (val) tempf |= FLAG_ZF;
else tempf &= ~FLAG_ZF;
mem_writew(SegPhys(ss)+reg_sp+4,tempf);
}
void CALLBACK_SCF(bool val) {
Bit16u tempf = mem_readw(SegPhys(ss)+reg_sp+4);
if (val) tempf |= FLAG_CF;
else tempf &= ~FLAG_CF;
mem_writew(SegPhys(ss)+reg_sp+4,tempf);
Bit16u tempf = mem_readw(SegPhys(ss)+reg_sp+4);
if (val) tempf |= FLAG_CF;
else tempf &= ~FLAG_CF;
mem_writew(SegPhys(ss)+reg_sp+4,tempf);
}
void CALLBACK_SIF(bool val) {
Bit16u tempf = mem_readw(SegPhys(ss)+reg_sp+4);
if (val) tempf |= FLAG_IF;
else tempf &= ~FLAG_IF;
mem_writew(SegPhys(ss)+reg_sp+4,tempf);
Bit16u tempf = mem_readw(SegPhys(ss)+reg_sp+4);
if (val) tempf |= FLAG_IF;
else tempf &= ~FLAG_IF;
mem_writew(SegPhys(ss)+reg_sp+4,tempf);
}
void CALLBACK_SetDescription(Bitu nr, const char* descr) {
@ -142,7 +142,7 @@ const char* CALLBACK_GetDescription(Bitu nr) {
}
Bitu CALLBACK_SetupExtra(Bitu callback, Bitu type, PhysPt physAddress, bool use_cb=true) {
if (callback>=CB_MAX)
if (callback>=CB_MAX)
return 0;
switch (type) {
case CB_RETN:
@ -471,7 +471,7 @@ void CALLBACK_HandlerObject::Uninstall(){
//See if we are the current handler. if so restore the old one
if(RealGetVec(vectorhandler.interrupt) == Get_RealPointer()) {
RealSetVec(vectorhandler.interrupt,vectorhandler.old_vector);
} else
} else
LOG(LOG_MISC,LOG_WARN)("Interrupt vector changed on %X %s",vectorhandler.interrupt,CALLBACK_GetDescription(m_callback));
}
CALLBACK_RemoveSetup(m_callback);
@ -483,6 +483,7 @@ void CALLBACK_HandlerObject::Uninstall(){
if(CallBack_Description[m_callback]) delete [] CallBack_Description[m_callback];
CallBack_Description[m_callback] = 0;
CALLBACK_DeAllocate(m_callback);
installed=false;
}
CALLBACK_HandlerObject::~CALLBACK_HandlerObject(){
@ -495,7 +496,7 @@ void CALLBACK_HandlerObject::Install(CallBack_Handler handler,Bitu type,const ch
m_type=SETUP;
m_callback=CALLBACK_Allocate();
CALLBACK_Setup(m_callback,handler,type,description);
} else E_Exit("Allready installed");
} else E_Exit("Callback handler object already installed");
}
void CALLBACK_HandlerObject::Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description){
if(!installed) {
@ -503,7 +504,7 @@ void CALLBACK_HandlerObject::Install(CallBack_Handler handler,Bitu type,PhysPt a
m_type=SETUP;
m_callback=CALLBACK_Allocate();
CALLBACK_Setup(m_callback,handler,type,addr,description);
} else E_Exit("Allready installed");
} else E_Exit("Callback handler object already installed");
}
void CALLBACK_HandlerObject::Allocate(CallBack_Handler handler,const char* description) {
@ -513,7 +514,7 @@ void CALLBACK_HandlerObject::Allocate(CallBack_Handler handler,const char* descr
m_callback=CALLBACK_Allocate();
CALLBACK_SetDescription(m_callback,description);
CallBack_Handlers[m_callback]=handler;
} else E_Exit("Allready installed");
} else E_Exit("Callback handler object already installed");
}
void CALLBACK_HandlerObject::Set_RealVec(Bit8u vec){
@ -552,7 +553,7 @@ void CALLBACK_Init(Section* /*sec*/) {
CALLBACK_Setup(call_default,&default_handler,CB_IRET,"default");
call_default2=CALLBACK_Allocate();
CALLBACK_Setup(call_default2,&default_handler,CB_IRET,"default");
/* Only setup default handler for first part of interrupt table */
for (Bit16u ct=0;ct<0x60;ct++) {
real_writed(0,ct*4,CALLBACK_RealPointer(call_default));

View file

@ -44,7 +44,7 @@ static Bitu IO_ReadDefault(Bitu port,Bitu iolen) {
io_readhandlers[0][port]=IO_ReadBlocked;
return 0xff;
case 2:
return
return
(io_readhandlers[0][port+0](port+0,1) << 0) |
(io_readhandlers[0][port+1](port+1,1) << 8);
case 4:
@ -58,7 +58,7 @@ static Bitu IO_ReadDefault(Bitu port,Bitu iolen) {
void IO_WriteDefault(Bitu port,Bitu val,Bitu iolen) {
switch (iolen) {
case 1:
LOG(LOG_IO,LOG_WARN)("Writing %02X to port %04X",val,port);
LOG(LOG_IO,LOG_WARN)("Writing %02X to port %04X",val,port);
io_writehandlers[0][port]=IO_WriteBlocked;
break;
case 2:
@ -115,12 +115,13 @@ void IO_ReadHandleObject::Install(Bitu port,IO_ReadHandler * handler,Bitu mask,B
m_mask=mask;
m_range=range;
IO_RegisterReadHandler(port,handler,mask,range);
} else E_Exit("IO_readHandler allready installed port %x",port);
} else E_Exit("IO_readHandler already installed port %x",port);
}
void IO_ReadHandleObject::Uninstall(){
if(!installed) return;
IO_FreeReadHandler(m_port,m_mask,m_range);
installed=false;
}
IO_ReadHandleObject::~IO_ReadHandleObject(){
@ -134,12 +135,13 @@ void IO_WriteHandleObject::Install(Bitu port,IO_WriteHandler * handler,Bitu mask
m_mask=mask;
m_range=range;
IO_RegisterWriteHandler(port,handler,mask,range);
} else E_Exit("IO_writeHandler allready installed port %x",port);
} else E_Exit("IO_writeHandler already installed port %x",port);
}
void IO_WriteHandleObject::Uninstall() {
if(!installed) return;
IO_FreeWriteHandler(m_port,m_mask,m_range);
installed=false;
}
IO_WriteHandleObject::~IO_WriteHandleObject(){
@ -164,7 +166,7 @@ static Bits IOFaultCore(void) {
Bits ret=CPU_Core_Full_Run();
CPU_CycleLeft+=CPU_Cycles;
if (ret<0) E_Exit("Got a dosbox close machine in IO-fault core?");
if (ret)
if (ret)
return ret;
if (!iof_queue.used) E_Exit("IO-faul Core without IO-faul");
IOF_Entry * entry=&iof_queue.entries[iof_queue.used-1];
@ -194,7 +196,7 @@ inline void IO_USEC_read_delay_old() {
inline void IO_USEC_write_delay_old() {
if(CPU_CycleMax > static_cast<Bit32s>((IODELAY_WRITE_MICROS*1000.0))) {
// this could be calculated whenever CPU_CycleMax changes
Bits delaycyc = static_cast<Bits>((CPU_CycleMax/1000)*IODELAY_WRITE_MICROS);
Bits delaycyc = static_cast<Bits>((CPU_CycleMax/1000)*IODELAY_WRITE_MICROS);
if(CPU_Cycles > delaycyc) CPU_Cycles -= delaycyc;
else CPU_Cycles = 0;
}
@ -212,7 +214,7 @@ inline void IO_USEC_read_delay() {
}
inline void IO_USEC_write_delay() {
Bits delaycyc = CPU_CycleMax/IODELAY_WRITE_MICROSk;
Bits delaycyc = CPU_CycleMax/IODELAY_WRITE_MICROSk;
if(GCC_UNLIKELY(CPU_Cycles < 3*delaycyc)) delaycyc=0;
CPU_Cycles -= delaycyc;
CPU_IODelayRemoved += delaycyc;
@ -413,7 +415,7 @@ Bitu IO_ReadB(Bitu port) {
iof_queue.used--;
retval = reg_al;
reg_dx = old_dx;
reg_dx = old_dx;
memcpy(&lflags,&old_lflags,sizeof(LazyFlags));
cpudecoder=old_cpudecoder;
return retval;
@ -450,7 +452,7 @@ Bitu IO_ReadW(Bitu port) {
iof_queue.used--;
retval = reg_ax;
reg_dx = old_dx;
reg_dx = old_dx;
memcpy(&lflags,&old_lflags,sizeof(LazyFlags));
cpudecoder=old_cpudecoder;
}
@ -486,7 +488,7 @@ Bitu IO_ReadD(Bitu port) {
iof_queue.used--;
retval = reg_eax;
reg_dx = old_dx;
reg_dx = old_dx;
memcpy(&lflags,&old_lflags,sizeof(LazyFlags));
cpudecoder=old_cpudecoder;
} else {