version 0.5.2
[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_address_space *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_address_space *imem, int inr, t_addr iaddr,
57          enum brk_perm iperm, int ihit);
58   virtual ~cl_brk(void);
59
60   class cl_address_space *get_mem(void) { return(mem); }
61
62   virtual void activate(void);
63   virtual void inactivate(void);
64   virtual enum brk_type type(void)= 0;
65   virtual enum brk_event get_event(void)= 0;
66   virtual bool do_hit(void);
67 };
68
69
70 /*
71  * FETCH type of breakpoints
72  */
73
74 class cl_fetch_brk: public cl_brk
75 {
76 public:
77   uchar code;
78
79   cl_fetch_brk(class cl_address_space *imem, int inr, t_addr iaddr,
80                enum brk_perm iperm, int ihit);
81
82   virtual enum brk_type type(void);
83   virtual enum brk_event get_event(void) { return(brkNONE); }
84 };
85
86
87 /*
88  * Base of EVENT type of breakpoints
89  */
90
91 class cl_ev_brk: public cl_brk
92 {
93 public:
94   cl_ev_brk(class cl_address_space *imem, int inr, t_addr iaddr,
95             enum brk_perm iperm,
96             int ihit, enum brk_event ievent, const char *iid);
97   cl_ev_brk(class cl_address_space *imem, int inr, t_addr iaddr,
98             enum brk_perm iperm,
99             int ihit, char op);
100   enum brk_event event;
101   const char *id;
102
103   virtual enum brk_type type(void);
104   virtual enum brk_event get_event(void) { return(event); }
105   virtual bool match(struct event_rec *ev);
106 };
107
108
109 /*
110  * Collection of breakpoint sorted by address
111  */
112
113 class brk_coll: public cl_sorted_list
114 {
115 public:
116   class cl_address_space/*rom*/ *rom;
117 public:
118   brk_coll(t_index alimit, t_index adelta, class cl_address_space/*rom*/*arom);
119   virtual void *key_of(void *item);
120   virtual int  compare(void *key1, void *key2);
121
122   virtual bool there_is_event(enum brk_event ev);
123   //virtual int make_new_nr(void);
124
125   virtual void add_bp(class cl_brk *bp);
126   virtual void del_bp(t_addr addr);
127   virtual void del_bp(t_index idx, int /*dummy*/);
128   virtual class cl_brk *get_bp(t_addr addr, int *idx);
129   virtual class cl_brk *get_bp(int nr);
130   virtual bool bp_at(t_addr addr);
131 };
132
133
134 #endif
135
136 /* End of brkcl.h */