#define SCCSID  "@(#)vmdata.c   6.3 91/10/30"

/*
 *       IBM/Microsoft Confidential
 *
 *       Copyright (c) IBM Corporation 1987, 1989
 *       Copyright (c) Microsoft Corporation 1987, 1989
 *
 *       All Rights Reserved
 */

#define INCL_DOSERRORS
#include <os2.h>

#define INCL_DOSP
#include <os2p.h>

#define FNO_NUM  FNO_VMDATA_C
#include <fnomem.h>
#include <fnomem.h>
#include <osmac.h>

#include <pgexport.h>
#include <vmexport.h>
#include <vmlocal.h>
#include <tkexport.h>        // for vmkh.h
#include <vmkh.h>            // must be after tkexport.h for KSEM definition

/***LD+ Global heap data common to both resident and swappable heaps */

// Moved to sdata.asm for System Anchor Block - f122427
extern VMHKH    hkhCurrMax;             /* Current maximum heap handle */

ulong_t         vmladdrMinKH;           /* Minimum heap address */
ulong_t         vmladdrMaxKH;           /* Maximum heap address */
VMKH            apkh[hkh_MAX + 1];      /* Array of heap header pointers */
#ifdef VMSTRICT
ulong_t         vmkhGflags = 0;         /* Global heap flags */
#endif
/*end*/

/***LD+ Logging Flags for Debug Kernel                          */

#ifdef VMSTRICT
ulong_t         vmLogFlags = 0;         /* Debug: Logging Flags */
#endif
/*end*/

/***LD+ LVMAT - Common arena per-type info */

VMAT atvm[VMAT_MAX + 1] =
  {
    /*  Private tiled arena per-type info */

    {
      VMAT_PT_laddrInitMin,                     /* Initial minimum bdry */
      VMAT_PT_laddrInitMax,                     /* Initial maximum bdry */
      VMAT_PT_laddrAbsMin,                      /* Abs minimum boundary */
      VMAT_PT_laddrAbsMax,                      /* Abs maximum boundary */
      VMAT_PT_cbInitBetween,                    /* Spacer before start */
      VMAT_PT_lHashNumbMask,                    /* Hash number mask */
      VMAT_PT_lHashNumbShift,                   /* Hash number shift */
      VMAT_PT_lHashNumbAbsMax,                  /* Max hash table index */
      VMAT_PT_lHashMinSize,                     /* Min hash table size */
      VMAT_PT_lbmNumbMask,                      /* Bitmap number mask */
      VMAT_PT_lbmNumbShift,                     /* Bitmap number shift */
      VMAT_PT_lbmNumbAbsMax,                    /* Abs Max bitmap # */
      VMAT_PT_lbdMinSize,                       /* Min bitmap dir size */
      VMAT_PT_lbmeNumbMask,                     /* Bitmap entry # mask */
      VMAT_PT_lbmeNumbShift,                    /* Bitmap entry # shift */
      VMAT_PT_lbmeNumbAbsMax,                   /* Abs Max bitmap entry */
      VMAT_PT_lbmeBitNumbMask,                  /* Bit number mask */
      VMAT_PT_lbmeBitNumbShift,                 /* Bit number shift */
      VMAT_PT_flInit,                           /* Initial flags */
      VMAT_PT_lGran,                            /* Granularity */
      VMAT_PT_laddrMinNoWrap,                   /* Min no wrap laddr */
      VMAT_PT_laddrMaxNoWrap,                   /* Max no wrap laddr */
      HARNULL,
    },

    /*  Private MVDM arena per-type info */

    {
      VMAT_PM_laddrInitMin,                     /* Initial minimum bdry */
      VMAT_PM_laddrInitMax,                     /* Initial maximum bdry */
      VMAT_PM_laddrAbsMin,                      /* Abs minimum boundary */
      VMAT_PM_laddrAbsMax,                      /* Abs maximum boundary */
      VMAT_PM_cbInitBetween,                    /* Spacer before start */
      VMAT_PM_lHashNumbMask,                    /* Hash number mask */
      VMAT_PM_lHashNumbShift,                   /* Hash number shift */
      VMAT_PM_lHashNumbAbsMax,                  /* Max hash table index */
      VMAT_PM_lHashMinSize,                     /* Min hash table size */
      VMAT_PM_lbmNumbMask,                      /* Bitmap number mask */
      VMAT_PM_lbmNumbShift,                     /* Bitmap number shift */
      VMAT_PM_lbmNumbAbsMax,                    /* Abs Max bitmap # */
      VMAT_PM_lbdMinSize,                       /* Min bitmap dir size */
      VMAT_PM_lbmeNumbMask,                     /* Bitmap entry # mask */
      VMAT_PM_lbmeNumbShift,                    /* Bitmap entry # shift */
      VMAT_PM_lbmeNumbAbsMax,                   /* Abs Max bitmap entry */
      VMAT_PM_lbmeBitNumbMask,                  /* Bit number mask */
      VMAT_PM_lbmeBitNumbShift,                 /* Bit number shift */
      VMAT_PM_flInit,                           /* Initial flags */
      VMAT_PM_lGran,                            /* Granularity */
      VMAT_PM_laddrMinNoWrap,                   /* Min no wrap laddr */
      VMAT_PM_laddrMaxNoWrap,                   /* Max no wrap laddr */
      HARNULL,
    },

    /*  Shared tiled arena per-type info */

    {
      VMAT_ST_laddrInitMin,                     /* Initial minimum bdry */
      VMAT_ST_laddrInitMax,                     /* Initial maximum bdry */
      VMAT_ST_laddrAbsMin,                      /* Abs minimum boundary */
      VMAT_ST_laddrAbsMax,                      /* Abs maximum boundary */
// GSR start
//    VMAT_ST_cbInitBetween,                    /* Spacer before start */
      0x098f0000l,
// GSR end
      VMAT_ST_lHashNumbMask,                    /* Hash number mask */
      VMAT_ST_lHashNumbShift,                   /* Hash number shift */
      VMAT_ST_lHashNumbAbsMax,                  /* Max hash table index */
      VMAT_ST_lHashMinSize,                     /* Min hash table size */
      VMAT_ST_lbmNumbMask,                      /* Bitmap number mask */
      VMAT_ST_lbmNumbShift,                     /* Bitmap number shift */
      VMAT_ST_lbmNumbAbsMax,                    /* Abs Max bitmap # */
      VMAT_ST_lbdMinSize,                       /* Min bitmap dir size */
      VMAT_ST_lbmeNumbMask,                     /* Bitmap entry # mask */
      VMAT_ST_lbmeNumbShift,                    /* Bitmap entry # shift */
      VMAT_ST_lbmeNumbAbsMax,                   /* Abs Max bitmap entry */
      VMAT_ST_lbmeBitNumbMask,                  /* Bit number mask */
      VMAT_ST_lbmeBitNumbShift,                 /* Bit number shift */
      VMAT_ST_flInit,                           /* Initial flags */
      VMAT_ST_lGran,                            /* Granularity */
      VMAT_ST_laddrMinNoWrap,                   /* Min no wrap laddr */
      VMAT_ST_laddrMaxNoWrap,                   /* Max no wrap laddr */
      HARNULL,
    },

    /*  System arena per-type info */

    {
      VMAT_SY_laddrInitMin,                     /* Initial minimum bdry */
      VMAT_SY_laddrInitMax,                     /* Initial maximum bdry */
      VMAT_SY_laddrAbsMin,                      /* Abs minimum boundary */
      VMAT_SY_laddrAbsMax,                      /* Abs maximum boundary */
      VMAT_SY_cbInitBetween,                    /* Spacer before start */
      VMAT_SY_lHashNumbMask,                    /* Hash number mask */
      VMAT_SY_lHashNumbShift,                   /* Hash number shift */
      VMAT_SY_lHashNumbAbsMax,                  /* Max hash table index */
      VMAT_SY_lHashMinSize,                     /* Min hash table size */
      VMAT_SY_lbmNumbMask,                      /* Bitmap number mask */
      VMAT_SY_lbmNumbShift,                     /* Bitmap number shift */
      VMAT_SY_lbmNumbAbsMax,                    /* Abs Max bitmap # */
      VMAT_SY_lbdMinSize,                       /* Min bitmap dir size */
      VMAT_SY_lbmeNumbMask,                     /* Bitmap entry # mask */
      VMAT_SY_lbmeNumbShift,                    /* Bitmap entry # shift */
      VMAT_SY_lbmeNumbAbsMax,                   /* Abs Max bitmap entry */
      VMAT_SY_lbmeBitNumbMask,                  /* Bit number mask */
      VMAT_SY_lbmeBitNumbShift,                 /* Bit number shift */
      VMAT_SY_flInit,                           /* Initial flags */
      VMAT_SY_lGran,                            /* Granularity */
      VMAT_SY_laddrMinNoWrap,                   /* Min no wrap laddr */
      VMAT_SY_laddrMaxNoWrap,                   /* Max no wrap laddr */
      HARNULL,
    }
  };

/*  ahvmSys.ah_laddrAbsMin = MINSYSPAGE << PAGESHIFT;
                                         Set absolute minimum page
                                           of system arena for use by
                                           bitmap routines.  Note that
                                           we distinguish between this
                                           absolute minimum page and the
                                           minimum page in the sentinel
                                           although for the system arena
                                           both are the same */
/*end*/
