b5ed8a800c32468b840eb3befc0ad22619e94380
[fw/sdcc] / sim / ucsim / sim.src / brkcl.h
1 /*
2  * Simulator of microcontrollers (sim.src/brkcl.h)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING.  If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
27
28 #ifndef SIM_BRKCL_HEADER
29 #define SIM_BRKCL_HEADER
30
31 #include "ddconfig.h"
32
33 // prj
34 #include "pobjcl.h"
35 #include "stypes.h"
36
37 // sim
38 #include "memcl.h"
39
40
41 /*
42  * Base object of breakpoints
43  */
44
45 class cl_brk: public cl_base
46 {
47 protected:
48   class cl_mem *mem;
49 public:
50   int nr;
51   t_addr addr;
52   enum  brk_perm perm;  // permanency (FIX,DYNAMIC)
53   int   hit;
54   int   cnt;
55
56   cl_brk(class cl_mem *imem, int inr, t_addr iaddr,
57          enum brk_perm iperm, int ihit);
58   virtual ~cl_brk(void);
59
60   virtual void activate(void);
61   virtual void inactivate(void);
62   virtual enum brk_type type(void)= 0;
63   virtual enum brk_event get_event(void)= 0;
64   virtual bool do_hit(void);
65 };
66
67
68 /*
69  * FETCH type of breakpoints
70  */
71
72 class cl_fetch_brk: public cl_brk
73 {
74 public:
75   uchar code;
76
77   cl_fetch_brk(class cl_mem *imem, int inr, t_addr iaddr,
78                enum brk_perm iperm, int ihit);
79
80   virtual enum brk_type type(void);
81   virtual enum brk_event get_event(void) { return(brkNONE); }
82 };
83
84
85 /*
86  * Base of EVENT type of breakpoints
87  */
88
89 class cl_ev_brk: public cl_brk
90 {
91 public:
92   cl_ev_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
93             int ihit, enum brk_event ievent, const char *iid);
94   cl_ev_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
95             int ihit, char op);
96   enum brk_event event;
97   const char *id;
98
99   virtual enum brk_type type(void);
100   virtual enum brk_event get_event(void) { return(event); }
101   virtual bool match(struct event_rec *ev);
102 };
103
104
105 /* 
106  * WRITE IRAM
107  */
108
109 /*class cl_wi_brk: public cl_ev_brk
110 {
111 public:
112   cl_wi_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
113             int ihit);
114
115   virtual bool match(struct event_rec *ev);
116 };*/
117
118
119 /* 
120  * READ IRAM
121  */
122
123 /*class cl_ri_brk: public cl_ev_brk
124 {
125 public:
126   cl_ri_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
127             int ihit);
128
129   virtual bool match(struct event_rec *ev);
130 };*/
131
132
133 /* 
134  * WRITE XRAM
135  */
136
137 /*class cl_wx_brk: public cl_ev_brk
138 {
139 public:
140   cl_wx_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
141             int ihit);
142
143   virtual bool match(struct event_rec *ev);
144 };*/
145
146
147 /* 
148  * READ XRAM
149  */
150
151 /*class cl_rx_brk: public cl_ev_brk
152 {
153 public:
154   cl_rx_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
155             int ihit);
156
157   virtual bool match(struct event_rec *ev);
158 };*/
159
160
161 /* 
162  * WRITE SFR
163  */
164
165 /*class cl_ws_brk: public cl_ev_brk
166 {
167 public:
168   cl_ws_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
169             int ihit);
170
171   virtual bool match(struct event_rec *ev);
172 };*/
173
174
175 /* 
176  * READ SFR
177  */
178
179 /*class cl_rs_brk: public cl_ev_brk
180 {
181 public:
182   cl_rs_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
183             int ihit);
184
185   virtual bool match(struct event_rec *ev);
186 };*/
187
188
189 /* 
190  * READ CODE
191  */
192
193 /*class cl_rc_brk: public cl_ev_brk
194 {
195 public:
196   cl_rc_brk(class cl_mem *imem, int inr, t_addr iaddr, enum brk_perm iperm,
197             int ihit);
198
199   virtual bool match(struct event_rec *ev);
200 };*/
201
202
203 /*
204  * Collection of breakpoint sorted by address
205  */
206
207 class brk_coll: public cl_sorted_list
208 {
209 public:
210   class cl_mem/*rom*/ *rom;
211 public:
212   brk_coll(t_index alimit, t_index adelta, class cl_mem/*rom*/ *arom);
213   virtual void *key_of(void *item);
214   virtual int  compare(void *key1, void *key2);
215
216   virtual bool there_is_event(enum brk_event ev);
217   //virtual int make_new_nr(void);
218
219   virtual void add_bp(class cl_brk *bp);
220   virtual void del_bp(t_addr addr);
221   virtual void del_bp(t_index idx, int /*dummy*/);
222   virtual class cl_brk *get_bp(t_addr addr, int *idx);
223   virtual class cl_brk *get_bp(int nr);
224   virtual bool bp_at(t_addr addr);
225 };
226
227
228 #endif
229
230 /* End of brkcl.h */