added DOS/OpenWatcom support

This commit is contained in:
dborca
2004-10-04 09:43:39 +00:00
parent f4ddf221d6
commit 0633a3231f

View File

@@ -37,6 +37,8 @@
#include <dpmi.h> #include <dpmi.h>
#include <sys/nearptr.h> #include <sys/nearptr.h>
static FxBool dirty; static FxBool dirty;
#elif defined(__WATCOMC__)
#include <i86.h>
#else #else
#include <fxmemmap.h> #include <fxmemmap.h>
#endif #endif
@@ -164,6 +166,36 @@ pciMapLinearDPMI(FxU32 busNumber, FxU32 physical_addr,
/* exploit 1 -> 1 physical to linear mapping in low megabyte */ /* exploit 1 -> 1 physical to linear mapping in low megabyte */
*linear_addr = physical_addr; *linear_addr = physical_addr;
} }
#elif defined(__WATCOMC__)
if (physical_addr >= 0x100000) {
union REGS r;
/* Hack alert:
* because of the TILE shit, we must enhance the mapped area
*/
FxU32 len = *length * 3 / 2;
/* function 0x800 (Physical Address Mapping) */
r.w.ax = 0x800;
/*
** BX:CX = physical address
** SI:DI = length
*/
r.w.bx = ( FxU16 ) ( physical_addr >> 16 );
r.w.cx = ( FxU16 ) ( physical_addr & 0x0000FFFF );
r.w.si = ( FxU16 ) ( len >> 16 );
r.w.di = ( FxU16 ) ( len & 0x0000FFFF );
int386( 0x31, &r, &r );
/* if cflag set then an error occured */
if ( r.w.cflag ) {
return FXFALSE;
}
*linear_addr = (r.w.bx << 16) | r.w.cx;
} else {
/* exploit 1 -> 1 physical to linear mapping in low megabyte */
*linear_addr = physical_addr;
}
#else #else
FxBool onWindows; FxBool onWindows;
@@ -220,6 +252,18 @@ pciUnmapLinearDPMI( FxU32 linear_addr, FxU32 length )
} }
return FXFALSE; return FXFALSE;
#elif defined(__WATCOMC__)
union REGS r;
/* function 0x801 (Free Physical Address Mapping) */
r.w.ax = 0x801;
/* BX:CX = physical address */
r.w.bx = ( FxU16 ) ( linear_addr >> 16 );
r.w.cx = ( FxU16 ) ( linear_addr & 0x0000FFFF );
int386( 0x31, &r, &r );
return (r.w.cflag == 0);
#else #else
DpmiUnmapMemory(linear_addr, length); DpmiUnmapMemory(linear_addr, length);
#endif #endif
@@ -272,7 +316,7 @@ static FxBool
pciMsrGetDPMI(MSRInfo* in, MSRInfo* out) pciMsrGetDPMI(MSRInfo* in, MSRInfo* out)
{ {
/* [dBorca] */ /* [dBorca] */
#ifdef __DJGPP__ #if defined(__DJGPP__) || defined(__WATCOMC__)
return FXTRUE; return FXTRUE;
#else #else
return DpmiGetMSR((FxU32)in, (FxU32)out); return DpmiGetMSR((FxU32)in, (FxU32)out);
@@ -283,7 +327,7 @@ static FxBool
pciMsrSetDPMI(MSRInfo* in, MSRInfo* out) pciMsrSetDPMI(MSRInfo* in, MSRInfo* out)
{ {
/* [dBorca] */ /* [dBorca] */
#ifdef __DJGPP__ #if defined(__DJGPP__) || defined(__WATCOMC__)
return FXTRUE; return FXTRUE;
#else #else
return DpmiSetMSR((FxU32)in, (FxU32)out); return DpmiSetMSR((FxU32)in, (FxU32)out);
@@ -295,7 +339,7 @@ static FxBool
pciOutputStringDPMI(const char* msg) pciOutputStringDPMI(const char* msg)
{ {
/* [dBorca] */ /* [dBorca] */
#ifdef __DJGPP__ #if defined(__DJGPP__) || defined(__WATCOMC__)
printf("%s", msg); printf("%s", msg);
return FXTRUE; return FXTRUE;
#else #else
@@ -308,7 +352,7 @@ pciSetPermissionDPMI(const FxU32 addrBase, const FxU32 addrLen,
const FxBool writePermP) const FxBool writePermP)
{ {
/* [dBorca] */ /* [dBorca] */
#ifdef __DJGPP__ #if defined(__DJGPP__) || defined(__WATCOMC__)
return FXTRUE; return FXTRUE;
#else #else
return DpmiLinearRangeSetPermission(addrBase, addrLen, writePermP); return DpmiLinearRangeSetPermission(addrBase, addrLen, writePermP);
@@ -319,7 +363,7 @@ static FxBool
pciSetPassThroughBaseDPMI(FxU32* baseAddr, FxU32 baseAddrLen) pciSetPassThroughBaseDPMI(FxU32* baseAddr, FxU32 baseAddrLen)
{ {
/* [dBorca] */ /* [dBorca] */
#ifdef __DJGPP__ #if defined(__DJGPP__) || defined(__WATCOMC__)
return FXTRUE; return FXTRUE;
#else #else
return DpmiSetPassThroughBase(baseAddr, baseAddrLen); return DpmiSetPassThroughBase(baseAddr, baseAddrLen);