1 /*
2  * Copyright (c) 2016 Charles Anthony
3  * Copyright (c) 2021 The DPS8M Development Team
4  *
5  * All rights reserved.
6  *
7  * This software is made available under the terms of the ICU
8  * License, version 1.8.1 or later.  For more details, see the
9  * LICENSE.md file at the top-level directory of this distribution.
10  */
11 
12 #ifdef TESTING
13 
14 # ifndef Hdbg_def
15 #  define Hdbg_def
16 
17 #  if 0
18 void hdbg_mark (void);
19 #  endif
20 t_stat hdbg_size (int32 arg, UNUSED const char * buf);
21 t_stat hdbg_print (int32 arg, UNUSED const char * buf);
22 t_stat hdbg_cpu_mask (UNUSED int32 arg, const char * buf);
23 t_stat hdbgSegmentNumber (UNUSED int32 arg, const char * buf);
24 t_stat hdbgBlacklist (UNUSED int32 arg, const char * buf);
25 
26 void hdbgTrace (const char * ctx);
27 void hdbgPrint (void);
28 enum hdbgIEFP_e
29   {
30     hdbgIEFP_abs_bar_read,
31     hdbgIEFP_abs_read,
32     hdbgIEFP_bar_read,
33     hdbgIEFP_read,
34     hdbgIEFP_abs_bar_write,
35     hdbgIEFP_abs_write,
36     hdbgIEFP_bar_write,
37     hdbgIEFP_write
38   };
39 void hdbgIEFP (enum hdbgIEFP_e type, word15 segno, word18 offset, const char * ctx);
40 void hdbgMRead (word24 addr, word36 data, const char * ctx);
41 void hdbgMWrite (word24 addr, word36 data, const char * ctx);
42 void hdbgFault (_fault faultNumber, _fault_subtype subFault,
43                 const char * faultMsg, const char * ctx);
44 void hdbgIntrSet (uint inum, uint cpuUnitIdx, uint scuUnitIdx, const char * ctx);
45 void hdbgIntr (uint intr_pair_addr, const char * ctx);
46 void hdbgNote (const char * ctx, const char * fmt, ...)
47 #  ifdef __GNUC__
48   __attribute__ ((format (printf, 2, 3)))
49 #  endif
50 ;
51 
52 // Keep sync'd with regNames
53 enum hregs_t
54   {
55     hreg_A,
56     hreg_Q,
57     hreg_X0, hreg_X1, hreg_X2, hreg_X3, hreg_X4, hreg_X5, hreg_X6, hreg_X7,
58     hreg_AR0, hreg_AR1, hreg_AR2, hreg_AR3, hreg_AR4, hreg_AR5, hreg_AR6, hreg_AR7,
59     hreg_PR0, hreg_PR1, hreg_PR2, hreg_PR3, hreg_PR4, hreg_PR5, hreg_PR6, hreg_PR7,
60     hreg_Y, hreg_Z,
61     hreg_IR,
62     hreg_DSBR,
63   };
64 void hdbgRegR (enum hregs_t type, word36 data, const char * ctx);
65 void hdbgRegW (enum hregs_t type, word36 data, const char * ctx);
66 struct par_s;
67 void hdbgPARegR (enum hregs_t type, struct par_s * data, const char * ctx);
68 void hdbgPARegW (enum hregs_t type, struct par_s * data, const char * ctx);
69 struct dsbr_s;
70 #  if 0
71 void hdbgDSBRRegR (enum hregs_t type, struct dsbr_s * data, const char * ctx);
72 void hdbgDSBRRegW (enum hregs_t type, struct dsbr_s * data, const char * ctx);
73 #  endif
74 void hdbgAPURead (word15 segno, word18 offset, word24 final, word36 data, const char * ctx);
75 void hdbgAPUWrite (word15 segno, word18 offset, word24 final, word36 data, const char * ctx);
76 
77 #  define HDBGMRead(a, d, c) hdbgMRead (a, d, c)
78 #  define HDBGMWrite(a, d, c) hdbgMWrite (a, d, c)
79 #  define HDBGIEFP(t, s, o, c) hdbgIEFP (t, s, o, c);
80 #  define HDBGAPURead(s, o, f, d, c) hdbgAPURead (s, o, f, d, c)
81 #  define HDBGAPUWrite(s, o, f, d, c) hdbgAPUWrite (s, o, f, d, c)
82 #  define HDBGRegAR(c) hdbgRegR (hreg_A, cpu.rA, c)
83 #  define HDBGRegAW(c) hdbgRegW (hreg_A, cpu.rA, c)
84 #  define HDBGRegQR(c) hdbgRegR (hreg_Q, cpu.rQ, c)
85 #  define HDBGRegQW(c) hdbgRegW (hreg_Q, cpu.rQ, c)
86 #  define HDBGRegXR(i, c) hdbgRegR (hreg_X0+(i), (word36) cpu.rX[i], c)
87 #  define HDBGRegXW(i, c) hdbgRegW (hreg_X0+(i), (word36) cpu.rX[i], c)
88 #  define HDBGRegYR(c) hdbgRegR (hreg_Y, (word36) cpu.rY, c)
89 #  define HDBGRegYW(c) hdbgRegW (hreg_Y, (word36) cpu.rY, c)
90 #  define HDBGRegZR(r, c) hdbgRegR (hreg_Z, (word36) r, c)
91 #  define HDBGRegZW(r, c) hdbgRegW (hreg_Z, (word36) r, c)
92 #  define HDBGRegPRR(i, c) hdbgPARegR (hreg_PR0+(i), & cpu.PAR[i], c)
93 #  define HDBGRegPRW(i, c) hdbgPARegW (hreg_PR0+(i), & cpu.PAR[i], c)
94 #  define HDBGRegARR(i, c) hdbgPARegR (hreg_AR0+(i), & cpu.PAR[i], c)
95 #  define HDBGRegARW(i, c) hdbgPARegW (hreg_AR0+(i), & cpu.PAR[i], c)
96 #  if 0
97 #   define HDBGRegDSBRR(i, c) hdbgDSBRRegR (hreg_AR0+(i), & cpu.PAR[i], c)
98 #   define HDBGRegDSBRW(i, c) hdbgDSBRRegW (hreg_AR0+(i), & cpu.PAR[i], c)
99 #  endif
100 #  define HDBGRegIR(c) hdbgRegW (hreg_IR, (word36) cpu.cu.IR, c)
101 #  define HDBGTrace(c) hdbgTrace(c)
102 #  define HDBGIntr(i, c) hdbgIntr(i, c)
103 #  define HDBGIntrSet(i, c, s, ctx) hdbgIntrSet(i, c, s, ctx)
104 #  define HDBGFault(n, s, m, c) hdbgFault(n, s, m, c)
105 #  define HDBGPrint() hdbgPrint()
106 # endif
107 #endif
108