home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Boot_Images / 2.11_on_rl02 / pdpsim.tz / pdpsim / pdp11_defs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-29  |  8.2 KB  |  285 lines

  1. /* pdp11_defs.h: PDP-11 simulator definitions
  2.  
  3.    Copyright (c) 1993, 1994, 1996,
  4.    Robert M Supnik, Digital Equipment Corporation
  5.    Commercial use prohibited
  6.  
  7.    The author gratefully acknowledges the help of Max Burnet, Megan Gentry,
  8.    and John Wilson in resolving questions about the PDP-11
  9. */
  10.  
  11. #include "sim_defs.h"                    /* simulator defns */
  12. #include <setjmp.h>
  13.  
  14. /* Constants */
  15.  
  16. #define VASIZE        0200000                /* 2**16 */
  17. #define VAMASK        (VASIZE - 1)            /* 2**16 - 1 */
  18. #define MEMSIZE     000760000            /* 2**18 - 2**13 */
  19. #define IOPAGEBASE    017760000            /* 2**22 - 2**13 */
  20. #define STKLIM        0400
  21.  
  22. /* Protection modes */
  23.  
  24. #define KERNEL        0
  25. #define SUPER        1
  26. #define UNUSED        2
  27. #define USER        3
  28.  
  29. /* I/O access modes */
  30.  
  31. #define READ        0
  32. #define READC        1                /* read console */
  33. #define WRITE        2
  34. #define WRITEC        3                /* write console */
  35. #define WRITEB        4
  36.  
  37. /* PSW */
  38.  
  39. #define    PSW_V_C        0                /* condition codes */
  40. #define PSW_V_V        1
  41. #define PSW_V_Z        2
  42. #define PSW_V_N     3
  43. #define PSW_V_TBIT     4                /* trace trap */
  44. #define PSW_V_IPL    5                /* int priority */
  45. #define PSW_V_RS    11                /* register set */
  46. #define PSW_V_PM    12                /* previous mode */
  47. #define PSW_V_CM    14                /* current mode */
  48. #define PSW_RW        0174357                /* read/write bits */
  49.  
  50. /* FPS */
  51.  
  52. #define    FPS_V_C        0                /* condition codes */
  53. #define FPS_V_V        1
  54. #define FPS_V_Z        2
  55. #define FPS_V_N     3
  56. #define FPS_V_T        5                /* truncate */
  57. #define FPS_V_L        6                /* long */
  58. #define FPS_V_D        7                /* double */
  59. #define FPS_V_IC    8                /* ic err int */
  60. #define FPS_V_IV    9                /* overflo err int */
  61. #define FPS_V_IU    10                /* underflo err int */
  62. #define FPS_V_IUV    11                /* undef var err int */
  63. #define FPS_V_ID    14                /* int disable */
  64. #define FPS_V_ER    15                /* error */
  65.  
  66. /* PIRQ */
  67.  
  68. #define PIRQ_PIR1    0001000
  69. #define PIRQ_PIR2    0002000
  70. #define PIRQ_PIR3    0004000
  71. #define PIRQ_PIR4    0010000
  72. #define PIRQ_PIR5    0020000
  73. #define PIRQ_PIR6    0040000
  74. #define PIRQ_PIR7    0100000
  75. #define PIRQ_IMP    0177356                /* implemented bits */
  76. #define PIRQ_RW        0177000                /* read/write bits */
  77.  
  78. /* MMR0 */
  79.  
  80. #define MMR0_MME    0000001                /* mem mgt enable */
  81. #define MMR0_V_PAGE    1                /* offset to pageno */
  82. #define MMR0_RO        0020000                /* read only error */
  83. #define MMR0_PL        0040000                /* page lnt error */
  84. #define MMR0_NR        0100000                /* no access error */
  85. #define MMR0_FREEZE    0160000                /* if set, no update */
  86. #define MMR0_IMP    0160177                /* implemented bits */
  87. #define MMR0_RW        0160001                /* read/write bits */
  88.  
  89. /* MMR3 */
  90.  
  91. #define    MMR3_UDS    001                /* user dspace enbl */
  92. #define MMR3_SDS    002                /* super dspace enbl */
  93. #define MMR3_KDS    004                /* krnl dspace enbl */
  94. #define MMR3_CSM    010                /* CSM enable */
  95. #define MMR3_M22E    020                /* 22b mem mgt enbl */
  96. #define MMR3_BME    040                /* DMA bus map enbl */
  97. #define MMR3_IMP    077                /* implemented bits */
  98. #define MMR3_RW        077                /* read/write bits */
  99.  
  100. /* PDR */
  101.  
  102. #define PDR_NR        0000002                /* non-resident ACF */
  103. #define PDR_ED        0000010                /* expansion dir */
  104. #define PDR_W        0000100                /* written flag */
  105. #define PDR_PLF        0077400                /* page lnt field */
  106. #define PDR_IMP        0177516                /* implemented bits */
  107. #define PDR_RW        0177416                /* read/write bits */
  108.  
  109. /* Virtual address */
  110.  
  111. #define VA_DF        0017777                /* displacement */
  112. #define VA_BN        0017700                /* block number */
  113. #define VA_V_APF    13                /* offset to APF */
  114. #define VA_V_DS        16                /* offset to space */
  115. #define VA_V_MODE    17                /* offset to mode */
  116. #define VA_DS        (1u << VA_V_DS)            /* data space flag */
  117.  
  118. /* CPUERR */
  119.  
  120. #define CPUE_RED    0004                /* red stack */
  121. #define CPUE_YEL    0010                /* yellow stack */
  122. #define CPUE_TMO    0020                /* IO page nxm */
  123. #define CPUE_NXM    0040                /* memory nxm */
  124. #define CPUE_ODD    0100                /* odd address */
  125. #define CPUE_HALT    0200                /* HALT not kernel */
  126. #define CPUE_IMP    0374                /* implemented bits */
  127.  
  128. /* Floating point accumulators */
  129.  
  130. struct fpac {
  131.     unsigned int    l;                /* low 32b */
  132.     unsigned int    h;                /* high 32b */
  133. };
  134. typedef struct fpac fpac_t;
  135.  
  136. /* Device CSRs */
  137.  
  138. #define CSR_V_GO    0                /* go */
  139. #define CSR_V_IE    6                /* interrupt enable */
  140. #define CSR_V_DONE    7                /* done */
  141. #define CSR_V_BUSY    11                /* busy */
  142. #define CSR_V_ERR    15                /* error */
  143. #define CSR_GO        (1u << CSR_V_GO)
  144. #define CSR_IE        (1u << CSR_V_IE)
  145. #define CSR_DONE    (1u << CSR_V_DONE)
  146. #define CSR_BUSY    (1u << CSR_V_BUSY)
  147. #define CSR_ERR        (1u << CSR_V_ERR)
  148.  
  149. /* Simulator stop codes; codes 1:TRAP_V_MAX correspond to traps 0:TRAPMAX-1 */
  150.  
  151. #define STOP_HALT    TRAP_V_MAX + 1            /* HALT instruction */
  152. #define STOP_IBKPT    TRAP_V_MAX + 2            /* instruction bkpt */
  153. #define STOP_WAIT    TRAP_V_MAX + 3            /* wait, no events */
  154. #define STOP_VECABORT    TRAP_V_MAX + 4            /* abort vector read */
  155. #define STOP_SPABORT    TRAP_V_MAX + 5            /* abort trap push */
  156. #define IORETURN(f,v)    ((f)? (v): SCPE_OK)        /* cond error return */
  157.  
  158. /* Trap masks, descending priority order, following J-11
  159.    An interrupt summary bit is kept with traps, to minimize overhead
  160. */
  161.  
  162. #define TRAP_V_RED    0                /* red stk abort  4 */
  163. #define TRAP_V_ODD    1                /* odd address      4 */
  164. #define TRAP_V_MME    2                /* mem mgt    250 */
  165. #define TRAP_V_NXM    3                /* nx memory      4 */
  166. #define TRAP_V_PAR    4                /* parity err    114 */
  167. #define TRAP_V_PRV    5                /* priv inst      4 */
  168. #define TRAP_V_ILL    6                /* illegal inst     10 */
  169. #define TRAP_V_BPT    7                /* BPT         14 */
  170. #define TRAP_V_IOT    8                /* IOT         20 */
  171. #define TRAP_V_EMT    9                /* EMT         30 */
  172. #define TRAP_V_TRAP    10                /* TRAP         34 */
  173. #define TRAP_V_TRC    11                /* T bit     14 */
  174. #define TRAP_V_YEL    12                /* stack      4 */
  175. #define TRAP_V_PWRFL    13                /* power fail     24 */
  176. #define TRAP_V_FPE    14                /* fpe        244 */
  177. #define TRAP_V_MAX    15                /* intr = max trp # */
  178. #define TRAP_RED    (1u << TRAP_V_RED)
  179. #define TRAP_ODD    (1u << TRAP_V_ODD)
  180. #define TRAP_MME    (1u << TRAP_V_MME)
  181. #define TRAP_NXM    (1u << TRAP_V_NXM)
  182. #define TRAP_PAR    (1u << TRAP_V_PAR)
  183. #define TRAP_PRV    (1u << TRAP_V_PRV)
  184. #define TRAP_ILL    (1u << TRAP_V_ILL)
  185. #define TRAP_BPT    (1u << TRAP_V_BPT)
  186. #define TRAP_IOT    (1u << TRAP_V_IOT)
  187. #define TRAP_EMT    (1u << TRAP_V_EMT)
  188. #define TRAP_TRAP    (1u << TRAP_V_TRAP)
  189. #define TRAP_TRC    (1u << TRAP_V_TRC)
  190. #define TRAP_YEL    (1u << TRAP_V_YEL)
  191. #define TRAP_PWRFL    (1u << TRAP_V_PWRFL)
  192. #define TRAP_FPE    (1u << TRAP_V_FPE)
  193. #define TRAP_INT    (1u << TRAP_V_MAX)
  194. #define TRAP_ALL    ((1u << TRAP_V_MAX) - 1)    /* all traps */
  195.  
  196. #define VEC_RED        0004                /* trap vectors */
  197. #define VEC_ODD        0004
  198. #define VEC_MME        0250
  199. #define VEC_NXM        0004
  200. #define VEC_PAR        0114
  201. #define VEC_PRV        0004
  202. #define VEC_ILL        0010
  203. #define VEC_BPT        0014
  204. #define VEC_IOT        0020
  205. #define VEC_EMT        0030
  206. #define VEC_TRAP    0034
  207. #define VEC_TRC        0014
  208. #define VEC_YEL        0004
  209. #define VEC_PWRFL    0024
  210. #define VEC_FPE        0244
  211.  
  212. /* Interrupt assignments, priority is right to left
  213.  
  214.    <3:0> =    BR7, <3> = PIR7
  215.    <7:4> =    BR6, <7> = PIR6
  216.    <15:8> =    BR5, <15> = PIR5
  217.    <28:16> =    BR4, <28> = PIR4
  218.    <29> =    PIR3
  219.    <30> =    PIR2
  220.    <31> =    PIR1
  221. */
  222.  
  223. #define INT_V_PIR7    3
  224. #define INT_V_CLK    4
  225. #define INT_V_PIR6    7
  226. #define INT_V_RK    8
  227. #define INT_V_RL    9
  228. #define INT_V_RX    10
  229. #define INT_V_PIR5    15
  230. #define INT_V_TTI    16
  231. #define INT_V_TTO    17
  232. #define INT_V_PTR    18
  233. #define INT_V_PTP    19
  234. #define INT_V_LPT    20
  235. #define INT_V_PIR4    28
  236. #define INT_V_PIR3    29
  237. #define INT_V_PIR2    30
  238. #define INT_V_PIR1    31
  239.  
  240. #define INT_PIR7    (1u << INT_V_PIR7)
  241. #define INT_CLK        (1u << INT_V_CLK)
  242. #define INT_PIR6    (1u << INT_V_PIR6)
  243. #define INT_RK        (1u << INT_V_RK)
  244. #define INT_RL        (1u << INT_V_RL)
  245. #define INT_RX        (1u << INT_V_RX)
  246. #define INT_PIR5    (1u << INT_V_PIR5)
  247. #define INT_PTR        (1u << INT_V_PTR)
  248. #define INT_PTP        (1u << INT_V_PTP)
  249. #define INT_TTI        (1u << INT_V_TTI)
  250. #define INT_TTO        (1u << INT_V_TTO)
  251. #define INT_LPT        (1u << INT_V_LPT)
  252. #define INT_PIR4    (1u << INT_V_PIR4)
  253. #define INT_PIR3    (1u << INT_V_PIR3)
  254. #define INT_PIR2    (1u << INT_V_PIR2)
  255. #define INT_PIR1    (1u << INT_V_PIR1)
  256.  
  257. #define INT_IPL7    0x00000000            /* int level masks */
  258. #define INT_IPL6    0x0000000F
  259. #define INT_IPL5    0x000000FF
  260. #define INT_IPL4    0x0000FFFF
  261. #define INT_IPL3    0x1FFFFFFF
  262. #define INT_IPL2    0x3FFFFFFF
  263. #define INT_IPL1    0x7FFFFFFF
  264. #define INT_IPL0    0xFFFFFFFF
  265.  
  266. #define VEC_PIRQ    0240                /* interrupt vectors */
  267. #define VEC_TTI        0060
  268. #define VEC_TTO        0064
  269. #define VEC_PTR        0070
  270. #define VEC_PTP        0074
  271. #define VEC_CLK        0100
  272. #define VEC_LPT        0200
  273. #define VEC_RK        0220
  274. #define VEC_RL        0160
  275. #define VEC_RX        0264
  276.  
  277. /* CPU and FPU macros */
  278.  
  279. #define update_MM ((MMR0 & (MMR0_FREEZE + MMR0_MME)) == MMR0_MME)
  280. #define setTRAP(name) trap_req = trap_req | (name)
  281. #define setCPUERR(name) CPUERR = CPUERR | (name)
  282. #define ABORT(val) longjmp (save_env, (val))
  283. #define SP R[6]
  284. #define PC R[7]
  285.