home *** CD-ROM | disk | FTP | other *** search
- {
- ════════════════════════════════════════════════════════════════════════════
-
- Visionix DOS Protected Mode Interface Unit (VDPMI)
- Copyright 1991,92,93 Visionix
- ALL RIGHTS RESERVED
-
- ────────────────────────────────────────────────────────────────────────────
-
- Revision history in reverse chronological order:
-
- Initials Date Comment
- -------- -------- -------------------------------------------------------
-
- mep 04/01/93 Finish majority of unit model.
-
- jrt 01/09/92 Added RefBuffIntr function. May move to other unit
- at a later date.
-
- jrt 12/15/92 Created.
-
- ────────────────────────────────────────────────────────────────────────────
- }
-
- Unit VDPMI;
-
-
- Uses
-
- DOS,
- VTypes,
- VGen;
-
- {────────────────────────────────────────────────────────────────────────────}
-
- {-----------------}
- { Error Constants }
- {-----------------}
-
- Const
-
- dpmiNoErr = 0;
- dpmiGenErr = $CBAD;
-
- Const
-
- {-------------------------------------------------------}
- { Bitmaps for Function Variables }
- { - hexidecimals values are considered bitwise operants }
- { and decimals are actual byte-values. }
- {-------------------------------------------------------}
-
- { VDPMISimRealIntr.Flags, }
- { VDPMICallRealProc.Flags and }
- { VDPMICallRealIntrProc }
- { - for DPMI 0.9 only. }
-
- dpmibmResetIntrCtrlA20 = $1;
-
- { VDPMIGetVersion.Flags }
-
- dpmibmRunning32bit = $1;
- dpmibmProcessorRetRealMode = $2;
- dpmibmVirtMemSupport = $4;
- dpmibmRsvp1 = $8;
-
- { VDPMIGetVersion.ProcType }
-
- dpmibm286 = 2;
- dpmibm386 = 3;
- dpmibm486 = 4;
-
- { VDPMIGetCaps.CaoFlags }
-
- dpmibmPagedAccessSupport = $1;
- dpmibmPagedDirtySupport = $1;
- dpmibmExpRestartSupport = $2;
- dpmibmDevMapSupport = $4;
- dpmibmConvMemMapSupport = $8;
- dpmibmDemandZeroFilled = $10;
- dpmibmWriteProtClientCap = $20;
- dpmibmWriteProtHostCap = $40;
-
- { VDPMIAllocLinMemory.Flags }
-
- dpmibmCreateCommitPages = $1;
-
- { VDPMIResizeLinMemory.NewFlags -> see VDPMIAllocLinMemory.Flags }
-
- dpmibmSegDescUpdateReq = $2;
-
- { VDPMIGetPageAttrs.PageAttr (each within PageAttrArr) }
-
- dpmibmPageType = $1; { 0..2 }
- dpmibmPageReadWrite = $4; { 3 }
- dpmibmAccessedBitsNext = $8; { 4 }
- dpmibmPageAccessed = $10; { 5 - see dpmibmAccessedBitsNext }
- dpmibmPageWritten = $20; { 6 - see dpmibmAccessedBitsNext }
-
- { VDPMITestDisableInts.PrevState and }
- { VDPMITestEnableInts.PrevState }
-
- dpmibmPrevDisabled = 0;
- dpmibmPrevEnabled = 1;
-
- { VDPMITestInts.State }
-
- dpmibmNowDisabled = 0;
- dpmibmNowEnabled = 1;
-
- { VDPMISetDebugWatchp.WatchType }
-
- dpmibmDebugExecute = 0;
- dpmibmDebugWrite = 1;
- dpmibmDebugReadWrite = 2;
-
- { VDPMIGetDebugWatchpState.WatchState }
-
- dpmibmWatchpExecuted = $1;
-
- { VDPMISerOneSharedMem.Flags }
-
- dpmibmSerRetWithoutSuspend = $1;
- dpmibmSerShared = $2;
-
- { VDPMIFreeSerOnSharedMem.Flags }
-
- dpmibmReleaseSharedSer = $1;
- dpmibmFreePendingSer = $2;
-
- { VDPMIGetCoprocStatus }
-
- dpmibmClientNumCoprocEnabled = $1;
- dpmibmClientIsEmuCoproc = $2;
- dpmibmNumCoprocPresent = $4;
- dpmibmHostEmuCoprocInst = $8;
- dpmibmCoprocType = $10; { 4..7 }
-
- dpmibmCoprocNone = 0;
- dpmibmCoproc80287 = 1;
- dpmibmCoproc80387 = 2;
- dpmibmCoproc80486 = 3;
-
- { VDPMISetCoProcEmulation.EmuFlags }
-
- dpmibmEnableClientNumCoproc = $1;
- dpmibmClientWillEmuCoproc = $2;
-
- {---------------------------}
- { Constants for RefBuffIntr }
- {---------------------------}
-
- Const
-
- rb_ESAX = $0001;
- rb_ESBX = $0002;
- rb_ESCX = $0003;
- rb_ESDX = $0004;
- rb_ESSI = $0005;
- rb_ESDI = $0006;
- rb_ESBP = $0007;
-
- rb_DSAX = $0011;
- rb_DSBX = $0012;
- rb_DSCX = $0013;
- rb_DSDX = $0014;
- rb_DSSI = $0015;
- rb_DSDI = $0016;
- rb_DSBP = $0017;
-
- rb_down = $0100;
- rb_up = $0200;
- rb_updown = $0300;
- rb_downup = $0300;
-
-
- {-----------------------------------}
- { DPMI Real mode register structure }
- {-----------------------------------}
-
- Type
-
- QWORD = Array[1..2] of LONGINT;
-
- TREGISTERS = REGISTERS;
-
- TDPMIErr = WORD;
-
- {---------------------------------}
-
- TDPMIRealRegs = RECORD
-
- EDI : LONGINT;
- ESI : LONGINT;
- EBP : LONGINT;
- Resp1 : LONGINT;
- EBX : LONGINT;
- EDX : LONGINT;
- ECX : LONGINT;
- EAX : LONGINT;
- Flags : WORD;
- ES : WORD;
- DS : WORD;
- FS : WORD;
- GS : WORD;
- IP : WORD;
- CS : WORD;
- SP : WORD;
- SS : WORD;
-
- END;
- PDPMIRealRegs = ^TDPMIRealRegs;
-
- {---------------------------------}
-
- TDescriptorT = RECORD
-
- DescLimit : WORD;
- DescLinBaseLo : WORD;
- DescLinBaseMid : BYTE;
- DescAccess : BYTE;
- DescExtAccess : BYTE;
- DescLinBaseHi : BYTE;
-
- END;
-
- PDescriptorT = ^TDescriptorT;
-
- {---------------------------------}
-
- PVectHandle = POINTER; { Selector:Offset }
-
- PSelOfs = POINTER; { Selector:Offset }
-
- PSelOfs32 = Array[1..6] of BYTE; { Selector:Offset-32BIT }
-
- {---------------------------------}
-
- TDescBuff = RECORD
-
- Selector : WORD;
- Descriptor : QWORD;
-
- END;
- PDescBuff = ^TDescBuff;
-
- {---------------------------------}
-
- TStackFrame16 = RECORD
-
- RetCSIP : LONGINT;
- ErrorCode : WORD;
- ExceptCSIP : LONGINT;
- Flags : WORD;
- SSSP : LONGINT;
-
- END;
- PStackFrame16 = ^TStackFrame16;
-
- {---------------------------------}
-
- TStackFrame32 = RECORD
-
- RetEIP : LONGINT;
- RetCSSel : WORD;
- Rsvp1 : WORD;
- ErrorCode : LONGINT;
- ExceptEIP : LONGINT;
- ExceptCSSel : WORD;
- Rsvp2 : WORD;
- EFlags : LONGINT;
- ESP : LONGINT;
- SS : WORD;
- Rsvp3 : WORD;
-
- END;
-
- PStackFrame32 = ^TStackFrame32;
-
- {---------------------------------}
-
- TGetCapsBuff = RECORD
-
- MajorVer : BYTE;
- MinorVer : BYTE;
- Vendor : Array[1..126] of CHAR;
-
- END;
- PGetCapsBuff = ^TGetCapsBuff;
-
- {---------------------------------}
-
- TFreeMemInfo = RECORD
-
- MaxAvailBlock : LONGINT;
- MaxUnlockPageAlloc : LONGINT;
- MaxLockPageAlloc : LONGINT;
- TotalLinAddrPages : LONGINT;
- TotalUnlockPages : LONGINT;
- FreePages : LONGINT;
- TotalPhyPages : LONGINT;
- FreeLinAddrPages : LONGINT;
- SizePageFile : LONGINT;
- Rsvp : Array[1..12] of BYTE;
-
- END;
- PFreeMemInfo = ^TFreeMemInfo;
-
- {---------------------------------}
-
- TPageAttr = Array[1..1] of WORD;
- PPageAttr = ^PPageAttr;
-
- {---------------------------------}
-
- TMemInfo = RECORD
-
- HostPhyMemAlloc : LONGINT;
- HostVirtMemAlloc : LONGINT;
- HostVirtMemAvail : LONGINT;
- CurrVirtMemAlloc : LONGINT;
- CurrVirtMemAvail : LONGINT;
- ClientVirtMemAlloc : LONGINT;
- ClientVirtMemAvail : LONGINT;
- ClientMemLocked : LONGINT;
- ClientMaxMemLocked : LONGINT;
- ClientMaxLinAddr : LONGINT;
- MaxBlockAvail : LONGINT;
- MinAllocUnit : LONGINT;
- AlignAllocUnit : LONGINT;
- Rsvp : Array[1..76] of BYTE;
-
- END;
- PMemInfo = ^TMemInfo;
-
- {---------------------------------}
-
- TRSPBuff = RECORD
-
- Desc16DataSeg : QWORD;
- Desc16CodeSeg : QWORD;
- Ofs16CallbackProc : WORD;
- Rsvp : Array[1..2] of BYTE;
- Desc32DataSeg : QWORD;
- Desc32CodeSeg : QWORD;
- Ofs32CallbackProc : LONGINT;
-
- END;
- PRSPBuff = ^TRSPBuff;
-
- {---------------------------------}
-
- TMemReqStruct = RECORD
-
- ReqMemBlockSize : LONGINT;
- AllocBlockSize : LONGINT;
- SMemHandle : LONGINT;
- LinAddr : LONGINT;
- MemBlockName : PSelOfs32;
- Rsvp1 : Array[1..2] of BYTE;
- Rsvp2 : Array[1..4] of BYTE;
-
- END;
- PMemReqStruct = ^TMemReqStruct;
-
- {---------------------------------}
-
- {────────────────────────────────────────────────────────────────────────────}
-
- { see DPMI 0.9 spec for info on these functions }
- { can be used in any environment that is a DPMI }
- { server (BP 7.0 protected mode, windows dos }
- { boxes, OS/2 dos boxes, etc. }
-
-
- Function VDPMIErrToStr( ErrCode : WORD ) : STRING;
-
- Function VDPMIInstalled : BOOLEAN;
-
- Function VDPMIInstallInfo( Var Support32bit : BOOLEAN;
- Var Processor : BYTE;
- Var MajorVer : BYTE;
- Var MinorVer : BYTE;
- Var NumParagraphs : WORD;
- Var DPMIEntry : POINTER ) : TDPMIErr;
-
- Function VDPMIAllocLDTDescriptor( NumDesc : WORD;
- Var BaseSelector : WORD ) : TDPMIErr;
-
- Function VDPMIFreeLDTDescriptor( Selector : WORD ) : TDPMIErr;
-
- Function VDPMIMapSegToSel( RealModeSeg : WORD;
- Var NewSelector : WORD ) : TDPMIErr;
-
- Function VDPMIGetSelectorDiff : TDPMIErr;
-
- Function VDPMILockSel( Selector : WORD ) : TDPMIErr;
-
- Function VDPMIUnlockSel( Selector : WORD ) : TDPMIErr;
-
- Function VDPMIGetSegmentBase( Selector : WORD;
- Var BaseAddr : LONGINT ) : TDPMIErr;
-
- Function VDPMISetSegmentBase( Selector : WORD;
- BaseAddr : LONGINT ) : TDPMIErr;
-
- Function VDPMISetSegmentLimit( Selector : WORD;
- Limit : LONGINT ) : TDPMIErr;
-
- Function VDPMISetSegmentRights( Selector : WORD;
- Rights : BYTE;
- ExtRights : BYTE ) : TDPMIErr;
-
- Function VDPMICreateAlias( Selector : WORD;
- Var NewSelector : WORD ) : TDPMIErr;
-
- Function VDPMIGetDescriptor( Selector : WORD;
- DescBuff : POINTER ) : TDPMIErr;
-
- Function VDPMISetDescriptor( Selector : WORD;
- DescBuff : POINTER ) : TDPMIErr;
-
- Function VDPMIAllocSpecDescriptor( Selector : WORD ) : TDPMIErr;
-
- Function VDPMIGetMultDescriptors( NumDescs : WORD;
- DescBuff : PDescBuff;
- Var NumDescsCopied : WORD ) : TDPMIErr;
-
- Function VDPMISetMultDescriptors( NumDescs : WORD;
- DescBuff : PDescBuff;
- Var NumDescsCopied : WORD ) : TDPMIErr;
-
- Function VDPMIAllocDOSMemory( NumParas : WORD;
- Var RealModeSeg : WORD;
- Var ProtModeSel : WORD ) : TDPMIErr;
-
- Function VDPMIFreeDOSMemory( ProtModeSel : WORD ) : TDPMIErr;
-
- Function VDPMIResizeDOSMemory( Selector : WORD;
- NewBlockParas : WORD;
- Var MaxBlockSize : WORD ) : TDPMIErr;
-
- Function VDPMIGetRealIntrVector( IntNum : WORD;
- Var Vector : POINTER ) : TDPMIErr;
-
- Function VDPMISetRealIntrVector( IntNum : WORD;
- Vector : POINTER ) : TDPMIErr;
-
- Function VDPMIGetProcExpVector( ExpNum : BYTE;
- Var Vector : PVectHandle ) : TDPMIErr;
-
- Function VDPMISetProcExpVector( ExpNum : BYTE;
- Vector : PVectHandle ) : TDPMIErr;
-
- Function VDPMIGetProtIntrVector( IntNum : WORD;
- Var Vector : PVectHandle ) : TDPMIErr;
-
- Function VDPMISetProtIntrVector( IntNum : WORD;
- Vector : PVectHandle ) : TDPMIErr;
-
- Function VDPMIGetProtExtExpProc( ExpNum : BYTE;
- Var Handler : PVectHandle ) : TDPMIErr;
-
- Function VDPMIGetRealExtExpProc( ExpNum : BYTE;
- Var Handler : PVectHandle ) : TDPMIErr;
-
- Function VDPMISetProtExtExpProc( ExpFaultNum : BYTE;
- Var Handler : PVectHandle ) : TDPMIErr;
-
- Function VDPMISetRealExtExpProc( ExpFaultNum : BYTE;
- Var Handler : PVectHandle ) : TDPMIErr;
-
- Function VDPMISimRealIntr( IntrNum : WORD;
- Flags : WORD;
- StackCopy : WORD;
- RealRegs : PDPMIRealRegs) : TDPMIErr;
-
- Function VDPMICallRealProc( Flags : WORD;
- StackCopy : WORD;
- RealRegs : PDPMIRealRegs) : TDPMIErr;
-
- Function VDPMICallRealIntrProc( Flags : WORD;
- StackCopy : WORD;
- RealRegs : PDPMIRealRegs) : TDPMIErr;
-
- Function VDPMIAllocRealCallback( ProtProc : PSelOfs;
- RealRegBuff : PDPMIRealRegs;
- Var CallBackAddr : POINTER ) : TDPMIErr;
-
- Function VDPMIFreeRealCallback( CallBackAddr : POINTER ) : TDPMIErr;
-
- Function VDPMIGetStateSRProcs( Var StateBuffSize : WORD;
- Var RealModeAddr : POINTER;
- Var ProtModeAddr : POINTER ) : TDPMIErr;
-
- Function VDPMIGetRawSwitchProcs( Var RealToProtAddr : POINTER;
- Var ProtToRealAddr : POINTER ) : TDPMIErr;
-
- Function VDPMIGetVersion( Var MajorVer : BYTE;
- Var MinorVer : BYTE;
- Var Flags : WORD;
- Var ProcType : BYTE;
- Var VirtMastPIC : BYTE;
- Var VirtSlavePIC : BYTE ) : TDPMIErr;
-
- Function VDPMIGetCaps( InfoBuffer : PGetCapsBuff;
- Var CaoFlags : WORD ) : TDPMIErr;
-
- Function VDPMIGetFreeMemory( InfoBuffer : PFreeMemInfo ) : TDPMIErr;
-
- Function VDPMIAllocMemory( Size : LONGINT;
- Var LinAddr : LONGINT;
- Var MemHandle : LONGINT ) : TDPMIErr;
-
- Function VDPMIFreeMemory( MemHandle : LONGINT ) : TDPMIErr;
-
- Function VDPMIResizeMemory( MemHandle : LONGINT;
- NewSize : LONGINT;
- Var NewMemHandle : LONGINT;
- Var NewLinAddr : LONGINT ) : TDPMIErr;
-
- Function VDPMIAllocLinMemory( LinAddr : LONGINT;
- Size : LONGINT;
- Flags : LONGINT;
- Var NewLinAddr : LONGINT;
- Var MemHandle : LONGINT ) : TDPMIErr;
-
- Function VDPMIResizeLinMemory( MemHandle : LONGINT;
- NewSize : LONGINT;
- NewFlags : LONGINT;
- Var NewLinAddr : LONGINT;
- Var NewMemHandle : LONGINT ) : TDPMIErr;
-
- Function VDPMIGetPageAttrs( MemHandle : LONGINT;
- BasePageOfs : LONGINT;
- NumPages : LONGINT;
- Var PageAttrArr : PPageAttr ) : TDPMIErr;
-
- Function VDPMIModifyPageAttrs( MemHandle : LONGINT;
- BasePageOfs : LONGINT;
- NumPages : LONGINT;
- PageAttrArr : PPageAttr;
- Var NewNumPages : LONGINT ) : TDPMIErr;
-
- Function VDPMIMapDeviceMemory( MemHandle : LONGINT;
- PageOfs : LONGINT;
- NumPages : LONGINT;
- PhyDevAddr : LONGINT ) : TDPMIErr;
-
- Function VDPMIMapConvMemory( MemHandle : LONGINT;
- PageOfs : LONGINT;
- NumPages : LONGINT;
- LinConvMemAddr : LONGINT ) : TDPMIErr;
-
- Function VDPMIGetMemorySizeBase( MemHandle : LONGINT;
- Var Size : LONGINT;
- Var BaseAddr : POINTER ) : TDPMIErr;
-
- Function VDPMIGetMemoryInfo( MemInfo : PMemInfo) : TDPMIErr;
-
- Function VDPMILockLinRegion( LinearStart : LONGINT;
- Size : LONGINT ) : TDPMIErr;
-
- Function VDPMIUnlockLinRegion( LinearStart : LONGINT;
- Size : LONGINT ) : TDPMIErr;
-
- Function VDPMIMarkRealRegionPageable( LinearStart : LONGINT;
- Size : LONGINT ) : TDPMIErr;
-
- Function VDPMIRelockRealRegion( LinearStart : LONGINT;
- Size : LONGINT ) : TDPMIErr;
-
- Function VDPMIGetPageSize( Var PageSize : LONGINT ) : TDPMIErr;
-
- Function VDPMIMarkPagesCandidate( LinearStart : LONGINT;
- Size : LONGINT ) : TDPMIErr;
-
- Function VDPMIDiscardPages( LinearStart : LONGINT;
- Size : LONGINT ) : TDPMIErr;
-
- Function VDPMINominatePages( LinearStart : LONGINT;
- Size : LONGINT ) : TDPMIErr;
-
- Function VDPMIDiscardPageContents( LinearStart : LONGINT;
- Size : LONGINT ) : TDPMIErr;
-
- Function VDPMIMapPhysicalRegion( PhysStart : LONGINT;
- Size : LONGINT;
- Var LinAddr : LONGINT ) : TDPMIErr;
-
- Function VDPMIFreePhysicalRegion( LinAddr : LONGINT ) : TDPMIErr;
-
- Function VDPMITestDisableInts( Var PrevState : BYTE ) : TDPMIErr;
-
- Function VDPMITestEnableInts( Var PrevState : BYTE ) : TDPMIErr;
-
- Function VDPMITestInts( Var State : BYTE ) : TDPMIErr;
-
- Function VDPMIGetVendorAPIEntry( VendorName : STRING;
- Var APIEntry : POINTER ) : TDPMIErr;
-
- Function VDPMISetDebugWatchp( LinAddr : LONGINT;
- WatchSize : BYTE;
- WatchType : BYTE;
- Var WatchHandle : WORD ) : TDPMIErr;
-
- Function VDPMIClearDebugWatchp( WatchHandle : WORD ) : TDPMIErr;
-
-
- Function VDPMIGetDebugWatchpState( WatchHandle : WORD;
- Var WatchState : WORD ) : TDPMIErr;
-
- Function VDPMIResetDebugWatchp( WatchHandle : WORD ) : TDPMIErr;
-
- Function VDPMIInstallRSPCallback( RSPBuff : PRSPBuff) : TDPMIErr;
-
- Function VDPMITermAndStayResident( RetCode : BYTE;
- DosParasToKeep : WORD ) : TDPMIErr;
-
- Function VDPMIAllocSharedMemory( MemReqStruct : PMemReqStruct ) : TDPMIErr;
-
- Function VDPMIFreeSharedMemory( SMemHandle : LONGINT ) : TDPMIErr;
-
- Function VDPMISerOnSharedMem( SMemHandle : LONGINT;
- Flags : WORD ) : TDPMIErr;
-
- Function VDPMIFreeSerOnSharedMem( SMemHandle : LONGINT;
- Flags : WORD ) : TDPMIErr;
-
- Function VDPMIGetCoprocStatus : WORD;
-
- Function VDPMISetCoProcEmulation( EmuFlags : WORD ) : TDPMIErr;
-
- Function RefBuffIntr( Flags : WORD;
- IntNum : BYTE;
- R : TREGISTERS;
- BuffPtr : POINTER;
- BuffSize : LONGINT ) : TDPMIErr;
-
- {────────────────────────────────────────────────────────────────────────────}
-
-