/*static char *SCCSID = "@(#)pldlocal.h   6.7 92/02/24";*/
/***    PLDLOCAL.H - Process Level Dump Local API Definitions
 *
 *      SCCSID = @(#)pldlocal.h  6.7 92/08/31
 *
 *      THIS IS AN OS/2 VERSION 2.x SPECIFIC FILE
 *
 *       Copyright (c) IBM Corporation 1992
 *
 *       All Rights Reserved
 *
 *      This file defines the Local interfaces for the Process Level Dump.
 *
 *****************************************************************************
 *  Change                                                               Chg *
 *  Activity      Date    BY   Reason                                    Num *
 *  --------      ----    ---  -------                                   --- *
 *  74428       10/04/93  ARJ  Added Module Name for Dump Formatter      001 *
 *  92585       08/26/94  ARJ  Added Process Level Dump Request Types    002 *
 *****************************************************************************
 */

#ifndef PLDLOCAL
#define PLDLOCAL

/*
 *   The global variable DumpProcess (declared in INIT\INICMD.ASM), which
 *   indicates on which drive to place the process dump log file (or is 0
 *   if process dumps are disabled), may be altered during bootup by
 *   placing DUMPPROCESS=x in CONFIG.SYS or by the API DosDumpProcess
 */

extern   CHAR     DumpProcess;          /* Dump drive letter set to Null   */

/*
 *  Pointers for mapping arena, object and context records.  These
 *  pointers point one element before the start of the arrays of
 *  arena object and context records.  They enable mapping of BMP32
 *  handles to be faster because 1 does not need to be subtracted
 *  from the handle before it is mapped.
 *** these fields are coppied from dos\memory\vmlocal.h
 */

VMOB                    *pobvmZero;             /* pobvmOne-1 */
VMAR                    *parvmZero;             /* parvmOne-1 */

/***LP  pldArMap - map an arena record handle to its arena record
 ***               this is a copy of VMArMap from
 ***               dos\memory\vmlocal.h
 *
 *      Given an arena record handle, return a pointer to the
 *      corresponding arena record.  No handle verification is done.
 *
 *      pldArMap (har)
 *
 *      ENTRY   har             - arena record handle (VMHAR)
 *      RETURN  VMAR *          - pointer to arena record
 *
 *      CALLS   NONE
 *
 *      WARNING This function is implemented as a macro.
 *
 *      EFFECTS NONE
 */

#define pldArMap(x)      (parvmZero + (VMHAR)(x))
                                        /* Map handle to pointer */

/***LP  pldHandleMap - map an object record handle to its object record
 ***                   this is a copy of VMHandleMap from
 ***                   dos\memory\vmlocal.h
 *
 *      Given a handle, return a pointer to the corresponding
 *      object record.  No handle verification is done.
 *
 *      pldHandleMap (hob)
 *
 *      ENTRY   hob             - object record handle (VMHOB)
 *      RETURN  VMOB *          - pointer to object record
 *
 *      CALLS   NONE
 *
 *      WARNING This function is implemented as a macro.
 *
 *      EFFECTS NONE
 */

#define pldHandleMap(x)  (pobvmZero + (VMHOB)(x))
                                        /* Map handle to pointer */

/***EK+ PLD_tcb - Process Level Dump TCB DATA Definitions
 *
 */
typedef struct _tcbdata {
        struct _tcbdata  *PLD_tcb_next;       /* addres of NEXT _tcbdata   */
        unsigned long  PLD_tcb_cnt;           /* Actual Num of TCBs        */
        PLD_TCBENTRY   tcbent[PLD_MAX];       /* TCB Summary Data          */
} PLD_TCBDATA;

/*end*/

/***EK+ PLD_vmar - Process Level Dump VMAR Data Definitions
 *
 */
typedef struct _vmardata {
        struct _vmardata *PLD_vmar_next;       /* addres of NEXT _vmarhdr  */
        unsigned long  PLD_vmar_cnt;          /* Actual Num of Arena Record*/
        VMAR          *PLD_vmar_array[PLD_MAX];/* Array of VMAR   pointers */
} PLD_VMARDATA;

/*end*/

/***EK+ PLD_vmob - Process Level Dump VMOB Data Definitions
 *
 */
typedef struct _vmobdata {
        struct _vmobdata *PLD_vmob_next;      /* address of NEXT _vmobdata */
        unsigned long  PLD_vmob_cnt;          /* Actual Num of Object Rec  */
        VMOB          *PLD_vmob_array[PLD_MAX];/* Array of VMOB   pointers */
} PLD_VMOBDATA;

/*end*/

/***EK+ PLD_mte - Process Level Dump MTE DATA Definitions
 *
 */
typedef struct _mtedata {
        struct _mtedata *PLD_mte_next;        /* addres of NEXT  _mtedata  */
        unsigned long  PLD_mte_cnt;           /* Actual Num of MTEs        */
        ldrmte_t      *PLD_mte_array[PLD_MAX]; /* Array of MTE    pointers */
        ldrsmte_t     *PLD_smte_array[PLD_MAX];/* Array of SMTE   pointers */
        unsigned long  PLD_smte_objtab_array[PLD_MAX];/* LDR Object Table  */
        unsigned long  PLD_smte_objtab_size[PLD_MAX];/* SMTE object table  */
        unsigned long  PLD_mte_modname_array[PLD_MAX];/* mte_modname   A001*/
        unsigned long  PLD_smte_path_array[PLD_MAX];/* smte_path       A001*/
        unsigned long  PLD_smte_path_size[PLD_MAX]; /* smte_pathlen    A001*/
} PLD_MTEDATA;

/*end*/

/***EK+ LDT Entry Definitions used by Process Level Dump
 *
 */
#define  BIT0          0x01
#define  BIT1          0x02
#define  BIT2          0x04
#define  BIT3          0x08
#define  BIT4          0x10
#define  BIT5          0x20
#define  BIT6          0x40
#define  BIT7          0x80

#define  SBIT          BIT4
#define  DPLBITS   (BIT5|BIT6)

#define  DescriptorValid(p)      (p)->flags & SBIT
#define  DPLValue(p)             ((((p)->flags) & DPLBITS) >> 5)

#define  MAXLDTENTRIES   8192
#define  RPL_TI_SIZE        3
#define  TI              0x04

/*end*/

/***EK+ LDT Entry Format used by Process Level Dump
 *
 */
typedef struct _ldtentry {
   USHORT       Limit0_15;
   USHORT       Base0_15;
   UCHAR        Base16_23;
   USHORT       flags;
   UCHAR        Base24_31;
} LDTENTRY;

/*end*/

/***EK+ PLD_ldt - Process Level Dump LDT Data Definitions
 *
 */
typedef struct _ldtarray {
        unsigned long  PLD_ldt_sel;            /* selector for the ldtentry*/
        LDTENTRY       PLD_ldt;                /* Array of LDT entries     */
} PLD_LDTARRAY;

/*end*/

/***EK+ PLD_ldt - Process Level Dump LDT Data Definitions
 *
 */
typedef struct _ldtdata {
        struct _ldtdata  *PLD_ldt_next;        /* addr  of ldtentry table  */
        unsigned long  PLD_ldt_cnt;            /* actual number this seg   */
        PLD_LDTARRAY   ldta[MAXLDTENTRIES];    /* .........................*/
} PLD_LDTDATA;

/*end*/

/***LT+ kPDPB - Kernel Process Dump Buffer structure
 *
 *      This structure is held in the PROCDUMP stack for the
 *      duration of a single Process Dump.
 *
 *
 */

typedef struct kPDPB_s {
        PLD_MH         mh;                 /* Main Header                 */
        PLD_PH         ph;                 /* Process Header              */
        PLD_TCBHDR     tcbH;               /* Thread Control Block Header */
        PLD_TCBDATA    tcbD;               /* Thread Control Block data   */
        PLD_VMARHDR    vmarH;              /* Arena Record Header         */
        PLD_VMARDATA   vmarD;              /* Arena Record data           */
        PLD_VMOBHDR    vmobH;              /* Object Record Header        */
        PLD_VMOBDATA   vmobD;              /* Object Record Data          */
        PLD_MTEHDR     mteH;               /* Module Table Entry Header   */
        PLD_MTEDATA    mteD;               /* Module Table Entry Data     */
        PLD_LDTHDR     ldtH;               /* Logical Data Table Entry Hdr*/
        PLD_LDTDATA    ldtD;               /* Logical Data Table Entry Data */
        PLD_RET_CODE   myrc;               /* PLD Return codes             */
} kPDPB_t;

/*end*/

/***EK+ PLD - Process Level Dump Return Codes
 *
 *      These values are placed in the ReqType field of the uPDPB upon
 *      exit from DosProcDump.
 *
 *      These numbers identify which command succeeded or failed.
 *
 */

/* Command completed successfully                                         */
#define PLD_Success            0L

/* Command incomplete                                                     */
#define PLD_Error              1L

/*end*/

/***EK+ PLD - Process Level Dump Request Types
 *
 *      Test section was added by defect 92585.                     A002
 *
 *      These values are internal use only. 
 *
 *      They should not be published, in any user documentation.                                    
 *
 *      INPUT:                                                        
 *             0xXXYYRRRR                                             
 *               XX   - is to zero  reserved for future use            
 *                 YY - is the requested area to be dumped            
 *               RRRR - is always zero                                
 *
 *      OUTPUT:                                                       
 *             0xXXYYRRRR                                             
 *               XX   - is to zero  reserved for future use            
 *                 YY - is the requested area to be dumped            
 *               RRRR - is the return code for writting that             
 *                      area to the dump file 
 *
 *      NOTE:                                                         
 *             The header information is always dumped, it is not     
 *             optional.
 *
 */

/* This AREA was not requested in the DUMP - Return Code            A002  */
#define PLD_DMP_NOT_REQ        0x0000ffff

/* Dump all of the Process Level Dump Information                   A002  */
#define PLD_DMP_ALL            0x00ff0000

/* Dump VMAR information                                            A002  */
#define PLD_DMP_VMAR           0x00010000

/* Dump VMOB information                                            A002  */
#define PLD_DMP_VMOB           0x00020000

/* Dump MTE  information                                            A002  */
#define PLD_DMP_MTE            0x00040000

/* Dump THREAD information                                          A002  */
#define PLD_DMP_THREAD         0x00080000

/* Dump LDT  information                                            A002  */
#define PLD_DMP_LDT            0x00100000

/*end*/

#endif
