Beispiel #1
0
void GUImain( void )
{
#if defined(__OSI__) || __WATCOMC__ < 1000
    {
    long    result;

#if defined(__OSI__)
    _Extender = 1;
#endif
    result = DPMIAllocateLDTDescriptors( 1 );
    if( result < 0 ) {
        StartupErr( LIT( Unable_to_get_rm_sel ) );
    }
    _ExtenderRealModeSelector = result & 0xffff;
    if( DPMISetSegmentLimit( _ExtenderRealModeSelector, 0xfffff ) ) {
        StartupErr( LIT( Unable_to_get_rm_sel ) );
    }
    }
#endif
    SaveOrigVectors();
    Orig28.a = MyGetRMVector( 0x28 );

    RMData.a = DPMIAllocateDOSMemoryBlock( _NBPARAS( RMSegEnd - RMSegStart ) );
    if( RMData.s.pm == 0 ) {
        StartupErr( LIT( Unable_to_alloc_DOS_mem ) );
    }
    PMData = MK_FP( RMData.s.pm, 0 );
    _fmemcpy( PMData, RMSegStart, RMSegEnd - RMSegStart );
    if( _osmajor == 2 ) {
        PMData->fail = 0;
    } else {
        PMData->fail = 3;
    }
    DebugMain();
}
Beispiel #2
0
void __far __fortran __nTinySetDTA( void __far *a )
{
    long                rc;
    unsigned long       base;

    /*
     * get a DTA descriptor that will survive across the 16/32 bit
     * interface
     */
    if( DTA == 0 ) {
        rc = DPMIAllocateLDTDescriptors( 1 );
        if( rc <= 0 ) return;
        /*
         * set up a basic DTA descriptor
         */
        DTA = (unsigned short) rc;
        DPMISetSegmentLimit( DTA, sizeof(tiny_find_t) );
        DPMISetDescriptorAccessRights( DTA, DPL+ACCESS_DATA16 );
    }

    base = DPMIGetSegmentBaseAddress( FP_SEG( a ) );
    base += FP_OFF( a );
    DPMISetSegmentBaseAddress( DTA, base );
    _fTinySetDTA( MK_FP( DTA,0) );
}
Beispiel #3
0
static char *SetTrapHandler( void )
{
    char                dummy;
    long                result;
    descriptor          desc;
    version_info        ver;

    PMData->vecttable1[DOS4G_COMM_VECTOR].s.segment = RMData.segm.rm;
    PMData->vecttable1[DOS4G_COMM_VECTOR].s.offset = RM_OFF( Interrupt15 );
    PMData->vecttable2[DOS4G_COMM_VECTOR].s.segment = RMData.segm.rm;
    PMData->vecttable2[DOS4G_COMM_VECTOR].s.offset = RM_OFF( Interrupt15 );
    if( IntrState == IS_NONE ) {
        DPMIGetVersion( &ver );
        if( (ver.major_version >= 1 || ver.minor_version > 90) || DPMICheck == 2 ) {
            RawPMtoRMSwitchAddr = DPMIRawPMtoRMAddr();
            PMData->switchaddr.a= DPMIRawRMtoPMAddr();
        }
        if( RawPMtoRMSwitchAddr == 0
         || PMData->switchaddr.a == 0
         || DPMICheck == 1 ) {
            IntrState = IS_RATIONAL;
        } else {
            PMData->saveaddr.a = DPMISavePMStateAddr();
            PMData->savesize   = DPMISaveStateSize();
            if( PMData->savesize == 0 ) {
                PMData->saveseg.dpmi_adr = 0;
            } else {
                PMData->saveseg.dpmi_adr = DPMIAllocateDOSMemoryBlock(
                                            _NBPARAS(PMData->savesize*2) );
                if( PMData->saveseg.segm.pm == 0 ) {
                    return( TC_ERR_OUT_OF_DOS_MEMORY );
                }
            }
            PMData->othersaved = false;
            result = DPMIAllocateLDTDescriptors( 1 );
            if( result < 0 ) {
                return( TC_ERR_CANT_LOAD_TRAP );
            }
            DPMIGetDescriptor( FP_SEG( PMData ), &desc );
            PMData->pmode_cs   = (unsigned_16)result;
            desc.xtype.use32 = 0;
            desc.type.execute = 1;
            DPMISetDescriptor( PMData->pmode_cs, &desc );
            PMData->pmode_eip  = RM_OFF( BackFromRealMode );
            PMData->pmode_ds   = FP_SEG( &PMData );
            PMData->pmode_es   = PMData->pmode_ds;
            PMData->pmode_ss   = FP_SEG( &dummy );
            IntrState = IS_DPMI;
        }
    }
    if( IntrState == IS_RATIONAL ) {
        MySetRMVector( TRAP_VECTOR, RMData.segm.rm, RM_OFF( RMTrapHandler ) );
    }
    return( NULL );
}
Beispiel #4
0
SELECTOR rsi_sel_new_absolute( long base_addr, unsigned size )
{
    if( USESDPMI() ) {
        SELECTOR    sel;
        descriptor  g;
        long        rc;

        if( (rc = DPMIAllocateLDTDescriptors( 1 )) < 0 )
            return( NULL_SEL );
        sel = rc;
        DPMIGetDescriptor( sel, &g );
        --size;
        g.lim_0_15 = size;
        g.lim_16_19 = size / 256 / 256;
        g.base_0_15 = base_addr;
        g.base_16_23 = base_addr >> 16;
        g.base_24_31 = base_addr >> 24;
        if( DPMISetDescriptor( sel, &g ) != 0 ) {
            DPMIFreeLDTDescriptor( sel );
            return( NULL_SEL );
        }
        return( sel );
    } else {