ucsim-0.2.37-pre3 into cvs
[fw/sdcc] / sim / ucsim / sim.src / brkcl.h
1 /*
2  * Simulator of microcontrollers (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 BRKCL_HEADER
29 #define 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 public:
48   int nr;
49   t_addr addr;
50   enum  brk_perm perm;  // permanency (FIX,DYNAMIC)
51   int   hit;
52   int   cnt;
53
54   cl_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
55   ~cl_brk(void);
56
57   virtual enum brk_type type(void)= 0;
58   virtual bool do_hit(void);
59 };
60
61
62 /*
63  * FETCH type of breakpoints
64  */
65
66 class cl_fetch_brk: public cl_brk
67 {
68 public:
69   uchar code;
70
71   cl_fetch_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
72
73   virtual enum brk_type type(void);
74 };
75
76
77 /*
78  * Base of EVENT type of breakpoints
79  */
80
81 class cl_ev_brk: public cl_brk
82 {
83 public:
84   cl_ev_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit,
85             enum brk_event ievent, const char *iid);
86
87   enum brk_event event;
88   const char *id;
89
90   virtual enum brk_type type(void);
91   virtual bool match(struct event_rec *ev);
92 };
93
94
95 /* 
96  * WRITE IRAM
97  */
98
99 class cl_wi_brk: public cl_ev_brk
100 {
101 public:
102   cl_wi_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
103
104   virtual bool match(struct event_rec *ev);
105 };
106
107
108 /* 
109  * READ IRAM
110  */
111
112 class cl_ri_brk: public cl_ev_brk
113 {
114 public:
115   cl_ri_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
116
117   virtual bool match(struct event_rec *ev);
118 };
119
120
121 /* 
122  * WRITE XRAM
123  */
124
125 class cl_wx_brk: public cl_ev_brk
126 {
127 public:
128   cl_wx_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
129
130   virtual bool match(struct event_rec *ev);
131 };
132
133
134 /* 
135  * READ XRAM
136  */
137
138 class cl_rx_brk: public cl_ev_brk
139 {
140 public:
141   cl_rx_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
142
143   virtual bool match(struct event_rec *ev);
144 };
145
146
147 /* 
148  * WRITE SFR
149  */
150
151 class cl_ws_brk: public cl_ev_brk
152 {
153 public:
154   cl_ws_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
155
156   virtual bool match(struct event_rec *ev);
157 };
158
159
160 /* 
161  * READ SFR
162  */
163
164 class cl_rs_brk: public cl_ev_brk
165 {
166 public:
167   cl_rs_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
168
169   virtual bool match(struct event_rec *ev);
170 };
171
172
173 /* 
174  * READ CODE
175  */
176
177 class cl_rc_brk: public cl_ev_brk
178 {
179 public:
180   cl_rc_brk(int inr, t_addr iaddr, enum brk_perm iperm, int ihit);
181
182   virtual bool match(struct event_rec *ev);
183 };
184
185
186 /*
187  * Collection of breakpoint sorted by address
188  */
189
190 class brk_coll: public cl_sorted_list
191 {
192 public:
193   class cl_rom *rom;
194 public:
195   brk_coll(t_index alimit, t_index adelta, class cl_rom *arom);
196   virtual void *key_of(void *item);
197   virtual int  compare(void *key1, void *key2);
198
199   virtual bool there_is_event(enum brk_event ev);
200   virtual int make_new_nr(void);
201
202   virtual void add_bp(class cl_brk *bp);
203   virtual void del_bp(t_addr addr);
204   virtual class cl_brk *get_bp(t_addr addr, int *idx);
205   virtual bool bp_at(t_addr addr);
206 };
207
208
209 #endif
210
211 /* End of brkcl.h */