1
0
Fork 0

move callbacks into read-only memory (Pinball/Adventure construction kit booters)

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2612
This commit is contained in:
Sebastian Strohhäcker 2006-04-22 15:25:45 +00:00
parent 1d11c37e23
commit 1d89346c16
8 changed files with 131 additions and 140 deletions

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: bios.cpp,v 1.57 2006-02-09 11:47:55 qbix79 Exp $ */
/* $Id: bios.cpp,v 1.58 2006-04-22 15:25:45 c2woody Exp $ */
#include "dosbox.h"
#include "mem.h"
@ -818,19 +818,8 @@ public:
/* INT 8 Clock IRQ Handler */
//TODO Maybe give this a special callback that will also call int 8 instead of starting
//a new system
callback[0].Install(INT8_Handler,CB_IRET,"Int 8 Clock");
callback[0].Install(INT8_Handler,CB_IRET_EOI_PIC1,"Int 8 Clock");
callback[0].Set_RealVec(0x8);
Bit16u call_int8=callback[0].Get_callback();
phys_writeb(CB_BASE+(call_int8<<4)+0,(Bit8u)0xFE); //GRP 4
phys_writeb(CB_BASE+(call_int8<<4)+1,(Bit8u)0x38); //Extra Callback instruction
phys_writew(CB_BASE+(call_int8<<4)+2,call_int8); //The immediate word
phys_writeb(CB_BASE+(call_int8<<4)+4,(Bit8u)0x50); // push ax
phys_writeb(CB_BASE+(call_int8<<4)+5,(Bit8u)0xb0); // mov al, 0x20
phys_writeb(CB_BASE+(call_int8<<4)+6,(Bit8u)0x20);
phys_writeb(CB_BASE+(call_int8<<4)+7,(Bit8u)0xe6); // out 0x20, al
phys_writeb(CB_BASE+(call_int8<<4)+8,(Bit8u)0x20);
phys_writeb(CB_BASE+(call_int8<<4)+9,(Bit8u)0x58); // pop ax
phys_writeb(CB_BASE+(call_int8<<4)+10,(Bit8u)0xcf); // iret
mem_writed(BIOS_TIMER,0); //Calculate the correct time

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: bios_disk.cpp,v 1.28 2006-04-09 13:03:24 c2woody Exp $ */
/* $Id: bios_disk.cpp,v 1.29 2006-04-22 15:25:45 c2woody Exp $ */
#include "dosbox.h"
#include "callback.h"
@ -63,24 +63,26 @@ Bits swapPosition;
void updateDPT(void) {
Bit32u tmpheads, tmpcyl, tmpsect, tmpsize;
if(imageDiskList[2] != NULL) {
PhysPt dp0physaddr=CALLBACK_PhysPointer(diskparm0);
imageDiskList[2]->Get_Geometry(&tmpheads, &tmpcyl, &tmpsect, &tmpsize);
real_writew(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0)),tmpcyl);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+2,tmpheads);
real_writew(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x3,0);
real_writew(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x5,(Bit16u)-1);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x7,0);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x8,(0xc0 | (((imageDiskList[2]->heads) > 8) << 3)));
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0x9,0);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0xa,0);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0xb,0);
real_writew(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0xc,tmpcyl);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+0xe,tmpsect);
phys_writew(dp0physaddr,tmpcyl);
phys_writeb(dp0physaddr+0x2,tmpheads);
phys_writew(dp0physaddr+0x3,0);
phys_writew(dp0physaddr+0x5,(Bit16u)-1);
phys_writeb(dp0physaddr+0x7,0);
phys_writeb(dp0physaddr+0x8,(0xc0 | (((imageDiskList[2]->heads) > 8) << 3)));
phys_writeb(dp0physaddr+0x9,0);
phys_writeb(dp0physaddr+0xa,0);
phys_writeb(dp0physaddr+0xb,0);
phys_writew(dp0physaddr+0xc,tmpcyl);
phys_writeb(dp0physaddr+0xe,tmpsect);
}
if(imageDiskList[3] != NULL) {
PhysPt dp1physaddr=CALLBACK_PhysPointer(diskparm1);
imageDiskList[3]->Get_Geometry(&tmpheads, &tmpcyl, &tmpsect, &tmpsize);
real_writew(RealSeg(CALLBACK_RealPointer(diskparm1)),RealOff(CALLBACK_RealPointer(diskparm1)),tmpcyl);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm1)),RealOff(CALLBACK_RealPointer(diskparm1))+2,tmpheads);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm1)),RealOff(CALLBACK_RealPointer(diskparm1))+0xe,tmpsect);
phys_writew(dp1physaddr,tmpcyl);
phys_writeb(dp1physaddr+0x2,tmpheads);
phys_writeb(dp1physaddr+0xe,tmpsect);
}
}
@ -488,9 +490,11 @@ void BIOS_SetupDisks(void) {
RealSetVec(0x41,CALLBACK_RealPointer(diskparm0));
RealSetVec(0x46,CALLBACK_RealPointer(diskparm1));
PhysPt dp0physaddr=CALLBACK_PhysPointer(diskparm0);
PhysPt dp1physaddr=CALLBACK_PhysPointer(diskparm1);
for(i=0;i<16;i++) {
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm0)),RealOff(CALLBACK_RealPointer(diskparm0))+i,0);
real_writeb(RealSeg(CALLBACK_RealPointer(diskparm1)),RealOff(CALLBACK_RealPointer(diskparm1))+i,0);
phys_writeb(dp0physaddr+i,0);
phys_writeb(dp1physaddr+i,0);
}
imgDTASeg = 0;

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: ems.cpp,v 1.50 2006-04-18 13:52:24 qbix79 Exp $ */
/* $Id: ems.cpp,v 1.51 2006-04-22 15:25:45 c2woody Exp $ */
#include <string.h>
#include <stdlib.h>
@ -721,12 +721,17 @@ static Bitu INT67_Handler(void) {
reg_di+=0x400; // advance pointer by 0x100*4
/* Set up three descriptor table entries */
real_writed(SegValue(ds),reg_si+0x00,0x8000ffff); // descriptor 1 (code segment)
real_writed(SegValue(ds),reg_si+0x04,0x00009a0c); // descriptor 1
real_writed(SegValue(ds),reg_si+0x08,0x0000ffff); // descriptor 2 (data segment)
real_writed(SegValue(ds),reg_si+0x0c,0x00009200); // descriptor 2
real_writed(SegValue(ds),reg_si+0x10,0x0000ffff); // descriptor 3
real_writed(SegValue(ds),reg_si+0x14,0x00009200); // descriptor 3
Bit32u cbseg_low=(CB_BASE&0xffff)<<16;
Bit32u cbseg_high=(CB_BASE&0x1f0000)>>16;
/* Descriptor 1 (code segment, callback segment) */
real_writed(SegValue(ds),reg_si+0x00,0x0000ffff|cbseg_low);
real_writed(SegValue(ds),reg_si+0x04,0x00009a00|cbseg_high);
/* Descriptor 2 (data segment, full access) */
real_writed(SegValue(ds),reg_si+0x08,0x0000ffff);
real_writed(SegValue(ds),reg_si+0x0c,0x00009200);
/* Descriptor 3 (full access) */
real_writed(SegValue(ds),reg_si+0x10,0x0000ffff);
real_writed(SegValue(ds),reg_si+0x14,0x00009200);
reg_ebx=(vcpi.pm_interface&0xffff);
reg_ah=EMM_NO_ERROR;
@ -1185,13 +1190,9 @@ public:
if (!ENABLE_VCPI) return;
/* Install a callback that handles VCPI-requests in protected mode requests */
call_vcpi.Install(&VCPI_PM_Handler,CB_RETF,"VCPI PM");
call_vcpi.Install(&VCPI_PM_Handler,CB_IRETD,"VCPI PM");
vcpi.pm_interface=(call_vcpi.Get_callback())<<4;
/* Use IRETD instead of IRET for this protected mode callback */
mem_writeb(CB_BASE+vcpi.pm_interface+4,(Bit8u)0x66);
mem_writeb(CB_BASE+vcpi.pm_interface+5,(Bit8u)0xCB); //A IRETD Instruction
/* Initialize private data area and set up descriptor tables */
SetupVCPI();

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: int10_vesa.cpp,v 1.23 2006-02-12 23:06:15 harekiet Exp $ */
/* $Id: int10_vesa.cpp,v 1.24 2006-04-22 15:25:45 c2woody Exp $ */
#include <string.h>
#include <stddef.h>
@ -443,20 +443,17 @@ void INT10_SetupVESA(void) {
int10.rom.pmode_interface_window = int10.rom.used - RealOff( int10.rom.pmode_interface );
phys_writew( Real2Phys(int10.rom.pmode_interface) + 0, int10.rom.pmode_interface_window );
callback.pmWindow=CALLBACK_Allocate();
CALLBACK_Setup(callback.pmWindow, VESA_PMSetWindow, CB_RETF, "VESA PM Set Window");
int10.rom.used += CALLBACK_SetupExtra( callback.pmWindow, CB_RETN, PhysMake(0xc000,int10.rom.used));
int10.rom.used += CALLBACK_Setup(callback.pmWindow, VESA_PMSetWindow, CB_RETN, PhysMake(0xc000,int10.rom.used), "VESA PM Set Window");
/* PM Set start call */
int10.rom.pmode_interface_start = int10.rom.used - RealOff( int10.rom.pmode_interface );
phys_writew( Real2Phys(int10.rom.pmode_interface) + 2, int10.rom.pmode_interface_start);
callback.pmStart=CALLBACK_Allocate();
CALLBACK_Setup(callback.pmStart, VESA_PMSetStart, CB_RETF, "VESA PM Set Start");
int10.rom.used += CALLBACK_SetupExtra( callback.pmStart, CB_RETN, PhysMake(0xc000,int10.rom.used));
int10.rom.used += CALLBACK_Setup(callback.pmStart, VESA_PMSetStart, CB_RETN, PhysMake(0xc000,int10.rom.used), "VESA PM Set Start");
/* PM Set Palette call */
int10.rom.pmode_interface_palette = int10.rom.used - RealOff( int10.rom.pmode_interface );
phys_writew( Real2Phys(int10.rom.pmode_interface) + 4, int10.rom.pmode_interface_palette);
callback.pmPalette=CALLBACK_Allocate();
CALLBACK_Setup(callback.pmPalette, VESA_PMSetPalette, CB_RETF, "VESA PM Set Palette");
int10.rom.used += CALLBACK_SetupExtra( callback.pmPalette, CB_RETN, PhysMake(0xc000,int10.rom.used));
int10.rom.used += CALLBACK_Setup(callback.pmPalette, VESA_PMSetPalette, CB_RETN, PhysMake(0xc000,int10.rom.used), "VESA PM Set Palette");
/* Finalize the size and clear the required ports pointer */
phys_writew( Real2Phys(int10.rom.pmode_interface) + 6, 0);
int10.rom.pmode_interface_size=int10.rom.used - RealOff( int10.rom.pmode_interface );

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: mouse.cpp,v 1.61 2006-02-13 07:48:25 qbix79 Exp $ */
/* $Id: mouse.cpp,v 1.62 2006-04-22 15:25:45 c2woody Exp $ */
#include <string.h>
#include <math.h>
@ -905,46 +905,26 @@ static Bitu INT74_Handler(void) {
return CBRET_NONE;
}
void WriteMouseIntVector(void)
{
// Create a mouse vector with weird address
// for strange mouse detection routines in Sim City & Wasteland
real_writed(0,0x33<<2,RealMake(CB_SEG+1,(call_int33<<4)-0x10+1)); // +1 = Skip NOP
};
void CreateMouseCallback(void)
{
// Create callback
call_int33=CALLBACK_Allocate();
CALLBACK_Setup(call_int33,&INT33_Handler,CB_IRET,"Mouse");
// Create a mouse vector with weird address
// for strange mouse detection routines in Sim City & Wasteland
Bit16u ofs = call_int33<<4;
phys_writeb(CB_BASE+ofs+0,(Bit8u)0x90); //NOP
phys_writeb(CB_BASE+ofs+1,(Bit8u)0xFE); //GRP 4
phys_writeb(CB_BASE+ofs+2,(Bit8u)0x38); //Extra Callback instruction
phys_writew(CB_BASE+ofs+3,call_int33); //The immediate word
phys_writeb(CB_BASE+ofs+5,(Bit8u)0xCF); //An IRET Instruction
// Write weird vector
WriteMouseIntVector();
};
void MOUSE_Init(Section* sec) {
// Callback 0x33
CreateMouseCallback();
// Callback for mouse interrupt 0x33
call_int33=CALLBACK_Allocate();
CALLBACK_Setup(call_int33,&INT33_Handler,CB_IRET,"Mouse");
// Wasteland needs low(seg(int33))!=0 and low(ofs(int33))!=0
real_writed(0,0x33<<2,RealMake(CB_SEG+1,(call_int33<<4)-0x10));
// Callback for ps2 irq
call_int74=CALLBACK_Allocate();
CALLBACK_Setup(call_int74,&INT74_Handler,CB_IRET,"int 74");
if(MOUSE_IRQ > 7) {
real_writed(0,((0x70+MOUSE_IRQ-8)<<2),CALLBACK_RealPointer(call_int74));
} else {
real_writed(0,((0x8+MOUSE_IRQ)<<2),CALLBACK_RealPointer(call_int74));
}
Bit8u hwvec=(MOUSE_IRQ>7)?(0x70+MOUSE_IRQ-8):(0x8+MOUSE_IRQ);
RealSetVec(hwvec,CALLBACK_RealPointer(call_int74));
// Callback for ps2 user callback handling
useps2callback = false; ps2callbackinit = false;
call_ps2=CALLBACK_Allocate();
CALLBACK_Setup(call_ps2,&PS2_Handler,CB_IRET,"ps2 bios callback");
ps2_callback=CALLBACK_RealPointer(call_ps2);
memset(&mouse,0,sizeof(mouse));
mouse.shown=-1; //Hide mouse on startup
mouse_reset_hardware();

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: xms.cpp,v 1.40 2006-04-14 13:53:58 qbix79 Exp $ */
/* $Id: xms.cpp,v 1.41 2006-04-22 15:25:45 c2woody Exp $ */
#include <stdlib.h>
#include <string.h>
@ -413,20 +413,9 @@ public:
Bitu i;
BIOS_ZeroExtendedSize(true);
DOS_AddMultiplexHandler(multiplex_xms);
callbackhandler.Install(&XMS_Handler,CB_RETF, "XMS Handler");
xms_callback=callbackhandler.Get_RealPointer();
Bit16u call_xms=callbackhandler.Get_callback();
/* Override the callback with one that can be hooked */
phys_writeb(CB_BASE+(call_xms<<4)+0,(Bit8u)0xeb); //jump near
phys_writeb(CB_BASE+(call_xms<<4)+1,(Bit8u)0x03); //offset
phys_writeb(CB_BASE+(call_xms<<4)+2,(Bit8u)0x90); //NOP
phys_writeb(CB_BASE+(call_xms<<4)+3,(Bit8u)0x90); //NOP
phys_writeb(CB_BASE+(call_xms<<4)+4,(Bit8u)0x90); //NOP
phys_writeb(CB_BASE+(call_xms<<4)+5,(Bit8u)0xFE); //GRP 4
phys_writeb(CB_BASE+(call_xms<<4)+6,(Bit8u)0x38); //Extra Callback instruction
phys_writew(CB_BASE+(call_xms<<4)+7,call_xms); //The immediate word
phys_writeb(CB_BASE+(call_xms<<4)+9,(Bit8u)0xCB); //A RETF Instruction
/* place hookable callback in writable memory area */
xms_callback=RealMake(DOS_GetMemory(0x1),0);
callbackhandler.Install(&XMS_Handler,CB_HOOKABLE,Real2Phys(xms_callback),"XMS Handler");
for (i=0;i<XMS_HANDLES;i++) {
xms_handles[i].free=true;