test: vdm.inc Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# vdm.inc

Go to the documentation of this file.

    00001 ;++
    00002 ;
    00003 ;  Copyright (c) 1989  Microsoft Corporation
    00004 ;
    00005 ;  Module Name:
    00006 ;
    00007 ;     vdm.inc
    00008 ;
    00009 ;  Abstract:
    00010 ;
    00011 ;     This module contains the structure and constant definitions for
    00012 ;     the vdm component
    00013 ;
    00014 ;  Author:
    00015 ;
    00016 ;     Dave Hastings (daveh) 20-Feb-1992
    00017 ;
    00018 ;  Revision History
    00019 ;     Sudeepb (30-Nov-1992)
    00020 ;     Merged all the equates in one place
    00021 ;
    00022 ;--
    00023 .386p
    00024
    00025 TRUE                    equ 1
    00026 FALSE                   equ 0
    00027
    00028 ;
    00029 ; Macro's to only do locked memory operations on MP systems
    00030 ;
    00031
    00032 IFDEF NT_UP
    00033 MPLOCK equ <>
    00034 ELSE
    00035 MPLOCK equ <lock>
    00036 ENDIF
    00037
    00038         page , 132
    00039         subttl "Macro to dispatch exception"
    00040
    00041 ;++
    00042 ;
    00043 ; Macro Description:
    00044 ;
    00045 ;    This macro allocates exception record on stack, sets up exception
    00046 ;    record using specified parameters and finally sets up arguments
    00047 ;    and calls _KiDispatchException.
    00048 ;
    00049 ; Arguments:
    00050 ;
    00051 ;    ExcepCode - Exception code to put into exception record
    00052 ;    ExceptFlags - Exception flags to put into exception record
    00053 ;    ExceptRecord - Associated exception record
    00054 ;    ExceptAddress - Addr of instruction which the hardware exception occurs
    00055 ;    NumParms - Number of additional parameters
    00056 ;    ParameterList - the additional parameter list
    00057 ;
    00058 ; Return Value:
    00059 ;
    00060 ;    None.
    00061 ;
    00062 ;--
    00063
    00064 DISPATCH_EXCEPTION macro ExceptCode, ExceptFlags, ExceptRecord, ExceptAddress,\
    00065                          NumParms, ParameterList
    00066         local de10, de20
    00067
    00068 ; Set up exception record for raising exception
    00069
    00070 ?i      =       0
    00071         sub     esp, ExceptionRecordSize + NumParms * 4
    00072                                         ; allocate exception record
    00073         mov     dword ptr [esp]+ErExceptionCode, ExceptCode
    00074                                         ; set up exception code
    00075         mov     dword ptr [esp]+ErExceptionFlags, ExceptFlags
    00076                                         ; set exception flags
    00077         mov     dword ptr [esp]+ErExceptionRecord, ExceptRecord
    00078                                         ; set associated exception record
    00079         mov     dword ptr [esp]+ErExceptionAddress, ExceptAddress
    00080         mov     dword ptr [esp]+ErNumberParameters, NumParms
    00081                                         ; set number of parameters
    00082         IRP     z, <ParameterList>
    00083         mov     dword ptr [esp]+(ErExceptionInformation+?i*4), z
    00084 ?i      =       ?i + 1
    00085         ENDM
    00086
    00087 ; set up arguments and call _KiDispatchException
    00088
    00089         mov     ecx, esp                ; (ecx)->exception record
    00090
    00091         test    dword ptr [ebp]+TsEFlags,EFLAGS_V86_MASK
    00092         jz      de10
    00093
    00094         mov     eax,0FFFFh
    00095         jmp     de20
    00096
    00097 de10:   mov     eax,[ebp]+TsSegCs
    00098 de20:   and     eax,MODE_MASK
    00099
    00100 ; 1 - set first chance TRUE
    00101 ; eax - PreviousMode
    00102 ; ebp - trap frame addr
    00103 ; 0 - Null exception frame
    00104 ; ecx - exception record addr
    00105
    00106 ; dispatchexception as appropriate
    00107         stdCall _KiDispatchException, <ecx, 0, ebp, eax, 1>
    00108 IFDEF STD_CALL
    00109         add     esp,ExceptionRecordSize + NumParms*4
    00110 ELSE
    00111         add     esp,20 + ExceptionRecordSize + NumParms*4
    00112 ENDIF
    00113
    00114         ENDM
    00115
    00116
    00117 ;
    00118 ; Prefix Flags
    00119 ;
    00120
    00121 PREFIX_ES               equ 00000100h
    00122 PREFIX_CS               equ 00000200h
    00123 PREFIX_SS               equ 00000400h
    00124 PREFIX_DS               equ 00000800h
    00125 PREFIX_FS               equ 00001000h
    00126 PREFIX_GS               equ 00002000h
    00127 PREFIX_OPER32           equ 00004000h
    00128 PREFIX_ADDR32           equ 00008000h
    00129 PREFIX_LOCK             equ 00010000h
    00130 PREFIX_REPNE            equ 00020000h
    00131 PREFIX_REP              equ 00040000h
    00132 PREFIX_SEG_ALL          equ 00003f00h
    00133
    00134 NUM_OPCODE              equ 255
    00135 ;
    00136 ; Reginfo structure
    00137 ;
    00138
    00139 RegInfo struc
    00140 RiSegSs         dd 0
    00141 RiEsp           dd 0
    00142 RiEFlags        dd 0
    00143 RiSegCs         dd 0
    00144 RiEip           dd 0
    00145 RiTrapFrame     dd 0
    00146 RiCsLimit       dd 0
    00147 RiCsBase        dd 0
    00148 RiCsFlags       dd 0
    00149 RiSsLimit       dd 0
    00150 RiSsBase        dd 0
    00151 RiSsFlags       dd 0
    00152 RiPrefixFlags   dd 0
    00153 RiOperand       dd 0
    00154 RegInfo ends
    00155 REGINFOSIZE     EQU 56
    00156
    00157 MAX_VDM_ADDR    EQU 0FFFFFFH
    00158
    00159 DR7_GLOBAL      EQU 002AAH
    00160
    00161 ;
    00162 ;Fast Read/Write Defines
    00163 ;
    00164
    00165 SVC_DEMFASTREAD     equ 42h
    00166 SVC_DEMFASTWRITE    equ 43h
    00167 DOS_BOP             equ 50h
    00168
    00169 ;
    00170 ;
    00171 ; Size of Exception Record
    00172 ;
    00173
    00174 ExceptionRecordSize = (ErNumberParameters + 4 + 3) AND 0fffffffcH ;
    00175
    00176 ;
    00177 ; Magic value
    00178 ;
    00179
    00180 OPCODE_MAGIC    equ  00f5ah
    00181
    00182 ;++
    00183 ;       diBEGIN - BEGIN index table
    00184 ;
    00185 ;       ENTRY   name = name of di table
    00186 ;               badindex = local label for unspecified entries
    00187 ;
    00188 ;       EXIT    ?sindex = specific entry index
    00189 ;               ?badindex = default index for unspecified entries
    00190 ;--
    00191
    00192 diBEGIN macro   name,badindex           ;; Beginning of dispatch table
    00193         ?sopc  = 0
    00194         ?badindex = badindex
    00195 name    label   byte                    ;; Start of dispatch table
    00196 endm
    00197
    00198 ;++
    00199 ;       dtI - SPECIFIC index table entry
    00200 ;
    00201 ;       ENTRY   opc = opcode value
    00202 ;               index  = INDEX_ value corresponding to opcode
    00203 ;               ?badindex = unspecified entry index
    00204 ;               ?sopc = specific entry index
    00205 ;
    00206 ;       EXIT    Unspecified entries prior to "index" filled in;
    00207 ;               Specified entry filled in.
    00208 ;               ?sopc = next index to fill in;
    00209 ;--
    00210
    00211 dtI     macro   opc,index               ;; Specific entry in dispatch table
    00212         if ?sopc gt opc
    00213             %out dtI: opcode out of order
    00214             .err
    00215         else
    00216             if ?sopc lt opc             ;; Fill unspecified entries
    00217                 rept opc - ?sopc
    00218                    db   ?badindex
    00219                 endm
    00220             endif
    00221             db    index                 ;; Specified entry
    00222             ?sopc = opc+1               ;; Set new start index
    00223         endif
    00224 endm
    00225
    00226 ;++
    00227 ;       diEND - END index table
    00228 ;
    00229 ;       ENTRY   index = highest entry in table
    00230 ;               ?sopc = specific entry index
    00231 ;
    00232 ;       EXIT    rest of the table filled in
    00233 ;--
    00234
    00235 diEND   macro   index                   ;; End of dispatch table
    00236         if ?sopc lt index               ;; Fill in rest of table
    00237             rept index - ?sopc
    00238                 db    ?badindex
    00239             endm
    00240         db      ?badindex               ;; fill in last entry of table!
    00241         endif
    00242 endm
    00243
    00244
    00245 ;++
    00246 ;       dtBEGIN - BEGIN dispatch table
    00247 ;
    00248 ;       ENTRY   name = name of dt table
    00249 ;               badaddr = local label for unspecified entries
    00250 ;
    00251 ;       EXIT    ?sindex = specific entry index
    00252 ;               ?badaddr = default handler for unspecified entries
    00253 ;--
    00254
    00255 dtBEGIN macro   name,badaddr            ;; Beginning of dispatch table
    00256         ?sindex  = 0
    00257         ?badaddr = badaddr
    00258 name    label   dword                   ;; Start of dispatch table
    00259 endm
    00260
    00261 ;++
    00262 ;       dtS - SPECIFIC dispatch table entry
    00263 ;
    00264 ;       ENTRY   index = index of entry
    00265 ;               addr  = address of handler
    00266 ;               ?badaddr = unspecified entry handler
    00267 ;               ?sindex = specific entry index
    00268 ;
    00269 ;       EXIT    Unspecified entries prior to "index" filled in;
    00270 ;               Specified entry filled in.
    00271 ;               ?sindex = next index to fill in;
    00272 ;--
    00273
    00274 dtS     macro   index,addr              ;; Specific entry in dispatch table
    00275         if ?sindex gt index
    00276             %out dtS: index out of order
    00277             .err
    00278         else
    00279             if ?sindex lt index         ;; Fill unspecified entries
    00280                 rept index - ?sindex
    00281                    dd   offset FLAT:?badaddr
    00282                 endm
    00283             endif
    00284             dd    offset FLAT:addr      ;; Specified entry
    00285             ?sindex = index+1           ;; Set new start index
    00286         endif
    00287 endm
    00288
    00289 ;++
    00290 ;       dtEND - END dispatch table
    00291 ;
    00292 ;       ENTRY   index = highest entry in table
    00293 ;               ?sindex = specific entry index
    00294 ;
    00295 ;       EXIT    rest of the table filled in
    00296 ;--
    00297
    00298 dtEND   macro   index                   ;; End of dispatch table
    00299         if ?sindex lt index             ;; Fill in rest of table
    00300             rept index - ?sindex
    00301                 dd    offset FLAT:?badaddr
    00302             endm
    00303         dd offset FLAT:?badaddr         ;; fill in last entry of table!
    00304         endif
    00305 endm
    00306
    00307 ;++
    00308 ;       CsToLinearPM
    00309 ;
    00310 ;--
    00311
    00312 CsToLinearPM    macro sel, erraddr
    00313         lea     eax,[esi].RiCsLimit
    00314         push    eax
    00315         lea     eax,[esi].RiCsBase
    00316         push    eax
    00317         lea     eax,[esi].RiCsFlags
    00318         push    eax
    00319         push    sel
    00320
    00321 IFDEF STD_CALL
    00322         call    _Ki386GetSelectorParameters@16
    00323 ELSE
    00324         call    _Ki386GetSelectorParameters
    00325         add     esp,10h
    00326 ENDIF
    00327         or      al,al
    00328         jz      erraddr
    00329
    00330         test    [esi].RiCsFlags,SEL_TYPE_EXECUTE
    00331         jz      erraddr
    00332
    00333         test    [esi].RiCsFlags,SEL_TYPE_2GIG
    00334         jz      @f
    00335
    00336         ; Correct limit value for granularity
    00337         shl     [esi].RiCsLimit,12
    00338         or      [esi].RiCsLimit,0FFFh
    00339 @@:
    00340 endm
    00341
    00342 ;++
    00343 ;       CsToLinearV86
    00344 ;
    00345 ;--
    00346
    00347 CsToLinearV86 macro
    00348         movzx   eax,word ptr [esi].RiSegCs
    00349         shl     eax,4
    00350         mov     [esi].RiCsBase,eax
    00351         mov     [esi].RiCsLimit,0FFFFh
    00352         mov     [esi].RiCsFlags,0
    00353 endm