/*static char *SCCSID = "@(#)mmph.h	6.4 91/09/18";*/
/****************************************************************************/
/*                                                                          */
/*                       IBM/Microsoft Confidential                         */
/*                                                                          */
/*                 Copyright (c) IBM Corporation  1987, 1990                */
/*                 Copyright (c) Microsoft Corp.  1987, 1990                */
/*                           All Rights Reserved                            */
/* b726910 SFB 09/17/91  place finddir 33/04 and sdl 33/09 dekko hooks back */
/*                       into the code. The cracked path data needed to be  */
/*                       added back in.                                     */
/****************************************************************************/
/*                                   */
/*  MMPH Pinball macro include file  */
/*                                   */

#define PINBALL_MMIOPH 1
#include <perfhook.h>

#define FP_SEG(fp) (*((unsigned *)&(fp) + 1))
#define FP_OFF(fp) (*((unsigned *)&(fp)))

/***
 *  Public variable used by the kernel's performance hook macros. This
 *  declaration must reside here as DLL do not define their infoseg
 *  pointer with this name.
 */
extern           PGINFOSEG         pGIS;               /* Kernel infoseg data  */


/***
 *  Local variable used by the kernel's performance hook macros. Again this
 *  declaration must be here because it uses the above extern variable.
 */
static unsigned char far *      RMT;

#define SET_DEKKO_ADDRESS3(infoseg_ptr) \
    FP_SEG(dekko_addr) = infoseg_ptr->SIS_MMIOBase; \
    FP_OFF(dekko_addr) = 0;


/****************************************************************************/
/*                                                                          */
/*      FILESYSTEM (HPFS): Internal Interface  -  Major Code 33h            */
/*                                                                          */
/****************************************************************************/

#if defined(MMIOPH)

                                                // cache\addhash.c
#define MMPHPreAddHash()             \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3301)  \
        WRITE_DWORD_VALUE(pbuf->lsnSec) \
        }

                                                // cache\setdirt.c
#define MMPHPreAddLW()               \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3302)  \
        WRITE_DWORD_VALUE(pbuf->lsnSec) \
        }


                                                // cache\cch.c
#define MMPHPreCCH()                 \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3303)  \
        WRITE_DWORD_VALUE(lsn)       \
        }

                                                // dir\finddir.c
#define MMPHPreFindDir()                  \
        RMT = pGIS->amecRAS;              \
        if (TEST_TRACING(RMT,0x33)){      \
        SET_DEKKO_ADDRESS3(pGIS)          \
        WRITE_MAJMNR_CODES(0x3304)        \
        WRITE_CRACKED_PATH(pcpDirToFind); \
        }



                                                // lazy\lazywrit.c
#define MMPHPreLazyWriter()          \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3305)  \
        WRITE_WORD_VALUE(cbufDirty)  \
        }
                                                // dir\lde.c
#define MMPHPreLDE()                 \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3306)  \
        WRITE_BYTE_VALUE(bAction)    \
        WRITE_NUMB_STRING(pspName)   \
        }

                                                // cache\rdbuf.c
#define MMPHPreRDBufOrGetInBuf()     \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3307)  \
        WRITE_DWORD_VALUE(lsn)       \
        }

                                                // read\readdir.c
#define MMPHPreReadDir()             \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3308)  \
        WRITE_DWORD_VALUE(vlsnStart) \
        WRITE_DWORD_VALUE(culRunLen) \
        }

                                                // dir\sdl.c
#define MMPHPreSDL()                 \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES(0x3309)   \
        WRITE_CRACKED_PATH(pcpPath); \
        }


                                                // write\sdw.c
#define MMPHPreSDW()                 \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x330A)  \
        WRITE_DWORD_VALUE(lsnStart)  \
        WRITE_WORD_VALUE(cusXfer)    \
        }

                                                // cache\flw.c
#define MMPHPreFLW()                 \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x330B)  \
        }

                                                // lazy\lwwrite.c
#define MMPHPreLWWrite()             \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x330C)  \
        WRITE_WORD_VALUE(pbuf)      \
        WRITE_DWORD_VALUE(pbuf->lsnSec) \
        }

                                                // fs_\fs_ocrea.c
#define MMPHPreFS_Open()             \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x330D)  \
        }

                                                // fs_\fs_read.c
#define MMPHPreFS_Read()             \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x330E)  \
        }
                                                // fs_\fs_write.c
#define MMPHPreFS_Write()            \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x330F)  \
        }
                                                // dir\splitdir.c
#define MMPHPreSplitDir()            \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3311)  \
        }
                                                // dir\adjust.c
#define MMPHPreAdjust()              \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3312)  \
        }
                                                // read\sdr.c
#define MMPHPreSDR()                 \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3313)  \
        WRITE_DWORD_VALUE(lsnStart)  \
        WRITE_WORD_VALUE(cusXfer)    \
        }

                                                // cache\addhash.c

#define MMPHPostAddHash()            \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3381)  \
        }

                                                // cache\setdirt.c
#define MMPHPostAddLW()              \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3382)  \
        }


                                                // cache\cch.c
#define MMPHPostCCH()                \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3383)  \
        WRITE_DWORD_VALUE(pbuf)      \
        }


                                                // dir\finddir.c
#define MMPHPostFindDir()            \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3384)  \
        WRITE_WORD_VALUE(rc)         \
        }
                                                // lazy\lwwrite.c
#define MMPHPostLazyWriter()         \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3385)  \
        }

                                                // dir\lde.c
#define MMPHPostLDE()                \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3386)  \
        WRITE_WORD_VALUE(rc)         \
        }

                                                // cache\rdbuf.c
#define MMPHPostRDBufOrGetInBuf()    \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3387)  \
        WRITE_DWORD_VALUE(*ppbuf)    \
        }


                                                // read\readdir.c
#define MMPHPostReadDir()            \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3388)  \
        }
                                                // dir\sdl.c
#define MMPHPostSDL()                \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3389)  \
        WRITE_DWORD_VALUE(rc)        \
        }

                                                // write\sdw.c
#define MMPHPostSDW()                \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x338A)  \
        }
                                                // cache\flw.c
#define MMPHPostFLW()                \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x338B)  \
        }
                                                // lazy\lazywrit.c
#define MMPHPostLWWrite()            \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x338C)  \
        }

                                                // fs_\fs_ocrea.c
#define MMPHPostFS_Open()            \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x338D)  \
        }

                                                // fs_\fs_read.c
#define MMPHPostFS_Read()            \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x338E)  \
        }
                                                // fs_\fs_write.c
#define MMPHPostFS_Write()           \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x338F)  \
        }
                                                // dir\splitdir.c
#define MMPHPostSplitDir()           \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3391)  \
        }
                                                // dis\adjust.c
#define MMPHPostAdjust()             \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3392)  \
        WRITE_WORD_VALUE(rc)         \
        }
                                                // read\sdr.c
#define MMPHPostSDR()                \
        RMT = pGIS->amecRAS;         \
        if (TEST_TRACING(RMT,0x33)){ \
        SET_DEKKO_ADDRESS3(pGIS)     \
        WRITE_MAJMNR_CODES (0x3393)  \
        }


#else                                          /* define the null macros for */
                                               /*   non-performance builds   */
#define MMPHPreAddHash()
#define MMPHPostAddHash()

#define MMPHPreAddLW()
#define MMPHPostAddLW()

#define MMPHPreCCH()
#define MMPHPostCCH()

#define MMPHPreFindDir()
#define MMPHPostFindDir()

#define MMPHPreLazyWriter()
#define MMPHPostLazyWriter()

#define MMPHPreLDE()
#define MMPHPostLDE()

#define MMPHPreRDBufOrGetInBuf()
#define MMPHPostRDBufOrGetInBuf()

#define MMPHPreReadDir()
#define MMPHPostReadDir()

#define MMPHPreSDL()
#define MMPHPostSDL()

#define MMPHPreSDW()
#define MMPHPostSDW()

#define MMPHPreFLW()
#define MMPHPostFLW()

#define MMPHPreLWWrite()
#define MMPHPostLWWrite()

#define MMPHPreFS_Open()
#define MMPHPostFS_Open()

#define MMPHPreFS_Read()
#define MMPHPostFS_Read()

#define MMPHPreFS_Write()
#define MMPHPostFS_Write()

#define MMPHPreSplitDir()
#define MMPHPostSplitDir()

#define MMPHPreAdjust()
#define MMPHPostAdjust()

#define MMPHPreSDR()
#define MMPHPostSDR()

#endif
