mem.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Memory and machine-specific definitions. Used in C and assembler.
  3. */
  4. /*
  5. * Sizes
  6. */
  7. #define BI2BY 8 /* bits per byte */
  8. #define BI2WD 32 /* bits per word */
  9. #define BY2WD 4 /* bytes per word */
  10. #define BY2V 8 /* bytes per vlong */
  11. #define BY2PG 8192 /* bytes per page */
  12. #define WD2PG (BY2PG/BY2WD) /* words per page */
  13. #define PGSHIFT 13 /* log(BY2PG) */
  14. #define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
  15. #define PGROUND(s) ROUND(s, BY2PG)
  16. #define BLOCKALIGN 8
  17. #define BY2PTE 8 /* bytes per pte entry */
  18. #define PTE2PG (BY2PG/BY2PTE) /* pte entries per page */
  19. #define MAXMACH 1 /* max # cpus system can run */
  20. #define KSTACK 4096 /* Size of kernel stack */
  21. /*
  22. * Time
  23. */
  24. #define HZ 100 /* clock frequency */
  25. #define MS2HZ (1000/HZ)
  26. #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
  27. /*
  28. * Magic registers
  29. */
  30. #define MACH 15 /* R15 is m-> */
  31. #define USER 14 /* R14 is up-> */
  32. /*
  33. * Fundamental addresses
  34. */
  35. /* XXX MACHADDR, MACHP(n) */
  36. /*
  37. * MMU
  38. *
  39. * A PTE is 64 bits, but a ulong is 32! Hence we encode
  40. * the PTEs specially for fault.c, and decode them in putmmu().
  41. * This means that we can only map the first 2G of physical
  42. * space via putmmu() - ie only physical memory, not devices.
  43. */
  44. #define PTEVALID 0x3301
  45. #define PTEKVALID 0x1101
  46. #define PTEASM 0x0010
  47. #define PTEGH(s) ((s)<<5)
  48. #define PTEWRITE 0
  49. #define PTERONLY 0x4
  50. #define PTEUNCACHED 0
  51. #define PPN(n) (((n)>>PGSHIFT)<<14)
  52. #define FIXPTE(x) ((((uvlong)(x)>>14)<<32)|((x) & 0x3fff))
  53. #define PTEPFN(pa) (((uvlong)(pa)>>PGSHIFT)<<32)
  54. #define NCOLOR 1
  55. #define getpgcolor(a) 0
  56. #define PTEMAPMEM (1024*1024)
  57. #define PTEPERTAB (PTEMAPMEM/BY2PG)
  58. #define SEGMAPSIZE 512
  59. #define SSEGMAPSIZE 16
  60. /*
  61. * Address spaces
  62. */
  63. #define UZERO 0 /* base of user address space */
  64. #define UTZERO (UZERO+BY2PG) /* first address in user text */
  65. #define USTKTOP (TSTKTOP-TSTKSIZ*BY2PG) /* byte just beyond user stack */
  66. #define TSTKTOP KZERO /* top of temporary stack */
  67. #define TSTKSIZ 100
  68. #define KZERO 0x80000000 /* base of kernel address space */
  69. #define KTZERO (KZERO+0x400000) /* first address in kernel text */
  70. #define USTKSIZE (4*1024*1024) /* size of user stack */
  71. /*
  72. * Palcode instructions a la OSF/1
  73. */
  74. #define PALbpt 0x80
  75. #define PALbugchk 0x81
  76. #define PALcallsys 0x83
  77. #define PALimb 0x86
  78. #define PALgentrap 0xaa
  79. #define PALrdunique 0x9e
  80. #define PALwrunique 0x9f
  81. #define PALhalt 0x00
  82. #define PALdraina 0x02
  83. #define PALcserve 0x09
  84. #define PALrdps 0x36
  85. #define PALrdusp 0x3a
  86. #define PALrdval 0x32
  87. #define PALretsys 0x3d
  88. #define PALrti 0x3f
  89. #define PALswpctx 0x30
  90. #define PALswpipl 0x35
  91. #define PALtbi 0x33
  92. #define PALwhami 0x3c
  93. #define PALwrent 0x34
  94. #define PALwrfen 0x2b
  95. #define PALwrkgp 0x37
  96. #define PALwrusp 0x38
  97. #define PALwrval 0x31
  98. #define PALwrvptptr 0x2d
  99. /*
  100. * Plus some useful VMS ones (needed at early boot time)
  101. */
  102. #define PALmfpr_pcbb 0x12
  103. #define PALmfpr_ptbr 0x15
  104. #define PALmfpr_vptb 0x29
  105. #define PALldqp 0x03
  106. #define PALstqp 0x04
  107. #define PALswppal 0x0a
  108. /*
  109. * Processor Status (as returned by rdps)
  110. */
  111. #define UMODE 0x8
  112. #define IPL 0x7
  113. #define isphys(x) (((ulong)x&KZERO)!=0)