Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
6.9 KiB

  1. /* SCCSID = @(#)vm.h 4.2 86/07/21 */
  2. /*
  3. * vm.h
  4. *
  5. * The following macros are used to define
  6. * the virtual memory model.
  7. */
  8. /* Definition for FPN type (file page number */
  9. typedef unsigned short FPN;
  10. #define LG2FPN 1
  11. /* Length of long in bits */
  12. #define LONGLN (BYTELN*sizeof(long))
  13. /* Log (base 2) of page size */
  14. #define LG2PAG 9
  15. /* Log (base 2) of memory size */
  16. #define LG2MEM 31
  17. /* Length of page in bytes */
  18. #define PAGLEN (1U << LG2PAG)
  19. /* Page offset of virtual address */
  20. #define OFFSET(x) ((short)((x) & ~(~0L << LG2PAG)))
  21. /* Page number of virtual address */
  22. #define PAGE(x) ((x) >> LG2PAG)
  23. /* Virtual address of page table entry for some virtual address x */
  24. #define PTADDR(x) (((x) >> (LG2PAG - LG2FPN)) & (~0L << LG2FPN))
  25. /* Page number of page table entry for some virtual address x */
  26. #define PTPAGE(x) ((x) >> (LG2PAG + LG2PAG - LG2FPN))
  27. /* Upper virtual address limit of PT0 */
  28. #define LG2LP0 (LG2MEM - LG2PAG + LG2FPN)
  29. #define LIMPT0 (1L << LG2LP0)
  30. /* Upper virtual address limit of PT1 */
  31. #define LG2LP1 (LG2LP0 - LG2PAG + LG2FPN)
  32. #define LIMPT1 (1L << LG2LP1)
  33. /* Upper virtual address limit of PT2 */
  34. #define LG2LP2 (LG2LP1 - LG2PAG + LG2FPN)
  35. #define LIMPT2 (1L << LG2LP2)
  36. /* Length of PT2 in entries (longs) */
  37. #define PT2LEN (1L << (LG2LP1 - LG2PAG))
  38. /* Maximum number of page buffers (hash table can be chars if MAXBUF <= 128) */
  39. #if CPU386
  40. #define MAXBUF 128
  41. #elif OSEGEXE
  42. #define MAXBUF 96
  43. #else
  44. #define MAXBUF 64
  45. #endif
  46. /* Virtual memory area definitions */
  47. /*
  48. * REMEMBER !!!!!!!!!!!!!!!!!!
  49. *
  50. * EVERY item you store in virtual memory MUST !!!!!
  51. * meet the condition PAGLEN % sizeof(your-item) == 0.
  52. */
  53. #define AREASYMS LIMPT0 /* Symbol table VM area start */
  54. #define AREASRCLIN (AREASYMS + (RBMAX << SYMSCALE))
  55. /* $$SRCLINES area start */
  56. #define AREAPROPLST (AREASRCLIN + (1L << 20))
  57. #define AREABAKPAT (AREAPROPLST + LXIVK)
  58. #if EXE386
  59. /* Begin area definitions for linear-executable */
  60. #define AREAIMPS (AREABAKPAT + LXIVK)
  61. /* Imported names table area */
  62. #define AREAEAT (AREAIMPS + 10*MEGABYTE)
  63. /* Export Address Table area */
  64. #define AREAEATAUX (AREAEAT + MEGABYTE)
  65. /* Auxiliary Data Table area */
  66. #define AREAEP (AREAEATAUX + MEGABYTE)
  67. /* Entry point area */
  68. #define LG2BKT 6 /* Log of hash bucket size */
  69. #define BKTLEN (1 << LG2BKT) /* Bucket length in bytes */
  70. #define AREAHRC (AREAEP + (LXIVK * sizeof(EPTYPE)))
  71. /* Chained relocation hash tables */
  72. #define AREARC (AREAHRC + MEGABYTE)
  73. /* Chained relocation hash buckets */
  74. #define AREANAMEPTR (AREARC + ((long) BKTLEN << WORDLN))
  75. /* Export Name Pointer Table */
  76. #define NAMEPTRSIZE MEGABYTE /* 1Mb */
  77. #define AREAORD (AREANAMEPTR + NAMEPTRSIZE)
  78. /* Export Ordinal Table */
  79. #define ORDTABSIZE 8*LXIVK /* 0.5Mb */
  80. #define AREAEXPNAME (AREAORD + ORDTABSIZE)
  81. /* Export Name Table */
  82. #define EXPNAMESIZE 64*MEGABYTE /* 64Mb */
  83. #define AREAST (AREAEXPNAME + EXPNAMESIZE)
  84. #define AREAMOD (AREAST + LXIVK)
  85. /* Module Reference Table Area */
  86. #define AREAHD (AREAMOD + MEGABYTE)
  87. #define AREAPDIR (AREAHD + MEGABYTE)
  88. #define AREAIMPMOD (AREAPDIR + MEGABYTE)
  89. #define AREAFPAGE (AREAIMPMOD + MEGABYTE)
  90. #define AREACV (AREAFPAGE + MEGABYTE)
  91. #define AREASORT (AREACV + (32*MEGABYTE))
  92. #define AREAEXESTR (AREASORT + LXIVK)
  93. #define AREACONTRIBUTION (AREAEXESTR + LXIVK)
  94. #define AREAPAGERANGE (AREACONTRIBUTION + LXIVK)
  95. #define AREACVDNT (AREAPAGERANGE + (8*MEGABYTE))
  96. #define AREAFSA (AREACVDNT + LXIVK)
  97. /* Segment area start */
  98. #define AREASA(sa) (mpsaVMArea[sa]) /* Virtual address of nth object */
  99. #define AREAFREE (0xffffffffL)
  100. /* First free VM address */
  101. #else
  102. /* Begin area definitions for protect-mode exes */
  103. #define AREANRNT (AREABAKPAT + LXIVK)
  104. #define AREARNT (AREANRNT + LXIVK)
  105. #define AREAIMPS (AREARNT + LXIVK)
  106. /* Imported names table area */
  107. #define AREAET (AREAIMPS + LXIVK)
  108. /* Entry Table area */
  109. #define AREAEP (AREAET + LXIVK)/* Entry point area */
  110. #define LG2BKT 6 /* Log of hash bucket size */
  111. #define BKTLEN (1 << LG2BKT) /* Bucket length in bytes */
  112. #define AREAHRC (AREAEP + (LXIVK * sizeof(EPTYPE)))
  113. /* Chained relocation hash tables */
  114. #define AREARC (AREAHRC + ((long) SAMAX * PAGLEN / 2))
  115. /* Chained relocation hash buckets */
  116. #define AREAST (AREARC + ((long) BKTLEN << WORDLN))
  117. #define AREAMOD (AREAST + LXIVK)/* Module Reference Table Area */
  118. #define AREASORT (AREAMOD + LXIVK)
  119. #define AREAEXESTR (AREASORT + (LXIVK << 2))
  120. #define AREACONTRIBUTION (AREAEXESTR + LXIVK)
  121. #define AREACVDNT (AREACONTRIBUTION + LXIVK)
  122. #define AREAFSA (AREACVDNT + LXIVK)
  123. #define AREASA(sa) (AREAFSA + ((long) (sa) << WORDLN))
  124. /* Virtual address of nth segment */
  125. #define AREAFREE (AREAFSA + ((long) SAMAX << WORDLN))
  126. /* First free VM address */
  127. #define AREACV (AREAPACKRGRLE + MEGABYTE)
  128. #endif
  129. /* Virtual memory area definitions for DOS 3 exes */
  130. #define AREAFSG AREAFSA /* Segment area start */
  131. #define AREARGRLE (AREAFSG + ((long) GSNMAX << 16))
  132. /* Relocation table area start */
  133. #define LG2ARLE 17 /* Log (base 2) of reloc table size */
  134. #define AREAPACKRGRLE (AREARGRLE + (IOVMAX * (1L << LG2ARLE)))
  135. /* Packed relocation area start */
  136. #define VPLIB1ST (1L << (LG2MEM - LG2PAG))
  137. /* First page of library area
  138. * NOTE: This page number cannot
  139. * be derived from any legal virtual
  140. * address. Libraries will always be
  141. * accessed by page number.
  142. */
  143. /* Index of virtual page touched most recently */
  144. short picur;