diff --git a/swlibs/newpci/pcilib/fxdpmi2.c b/swlibs/newpci/pcilib/fxdpmi2.c index 58d313e..1743f17 100644 --- a/swlibs/newpci/pcilib/fxdpmi2.c +++ b/swlibs/newpci/pcilib/fxdpmi2.c @@ -37,6 +37,8 @@ #include #include static FxBool dirty; +#elif defined(__WATCOMC__) +#include #else #include #endif @@ -164,6 +166,36 @@ pciMapLinearDPMI(FxU32 busNumber, FxU32 physical_addr, /* exploit 1 -> 1 physical to linear mapping in low megabyte */ *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 FxBool onWindows; @@ -220,6 +252,18 @@ pciUnmapLinearDPMI( FxU32 linear_addr, FxU32 length ) } 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 DpmiUnmapMemory(linear_addr, length); #endif @@ -272,7 +316,7 @@ static FxBool pciMsrGetDPMI(MSRInfo* in, MSRInfo* out) { /* [dBorca] */ -#ifdef __DJGPP__ +#if defined(__DJGPP__) || defined(__WATCOMC__) return FXTRUE; #else return DpmiGetMSR((FxU32)in, (FxU32)out); @@ -283,7 +327,7 @@ static FxBool pciMsrSetDPMI(MSRInfo* in, MSRInfo* out) { /* [dBorca] */ -#ifdef __DJGPP__ +#if defined(__DJGPP__) || defined(__WATCOMC__) return FXTRUE; #else return DpmiSetMSR((FxU32)in, (FxU32)out); @@ -295,7 +339,7 @@ static FxBool pciOutputStringDPMI(const char* msg) { /* [dBorca] */ -#ifdef __DJGPP__ +#if defined(__DJGPP__) || defined(__WATCOMC__) printf("%s", msg); return FXTRUE; #else @@ -308,7 +352,7 @@ pciSetPermissionDPMI(const FxU32 addrBase, const FxU32 addrLen, const FxBool writePermP) { /* [dBorca] */ -#ifdef __DJGPP__ +#if defined(__DJGPP__) || defined(__WATCOMC__) return FXTRUE; #else return DpmiLinearRangeSetPermission(addrBase, addrLen, writePermP); @@ -319,7 +363,7 @@ static FxBool pciSetPassThroughBaseDPMI(FxU32* baseAddr, FxU32 baseAddrLen) { /* [dBorca] */ -#ifdef __DJGPP__ +#if defined(__DJGPP__) || defined(__WATCOMC__) return FXTRUE; #else return DpmiSetPassThroughBase(baseAddr, baseAddrLen);