* sim/ucsim/cmd.src/info.cc, sim/ucsim/cmd.src/bp.cc,
[fw/sdcc] / sim / ucsim / cmd.src / info.cc
1 /*
2  * Simulator of microcontrollers (cmd.src/info.cc)
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 #include <stdlib.h>
29 #include "i_string.h"
30
31 // sim.src
32 #include "simcl.h"
33
34 // local
35 #include "infocl.h"
36
37
38 /*
39  * INFO BREAKPOINTS command
40  */
41
42 //int
43 //cl_info_bp_cmd::do_work(class cl_sim *sim,
44 //                      class cl_cmdline *cmdline, class cl_console_base *con)
45 COMMAND_DO_WORK_UC(cl_info_bp_cmd)
46 {
47   int i;
48
49   con->dd_printf("Num Type       Disp Hit   Cnt   Address  What\n");
50   for (i= 0; i < uc->fbrk->count; i++)
51     {
52       class cl_brk *fb= (class cl_brk *)(uc->fbrk->at(i));
53       const char *s= uc->disass(fb->addr, NULL);
54       con->dd_printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", fb->nr,
55                      "fetch", (fb->perm==brkFIX)?"keep":"del ",
56                      fb->hit, fb->cnt,
57                      fb->addr, s);
58       free((char *)s);
59     }
60   for (i= 0; i < uc->ebrk->count; i++)
61     {
62       class cl_ev_brk *eb= (class cl_ev_brk *)(uc->ebrk->at(i));
63       con->dd_printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", eb->nr,
64                      "event", (eb->perm==brkFIX)?"keep":"del ",
65                      eb->hit, eb->cnt,
66                      eb->addr, eb->id);
67     }
68   /*t_addr a;
69   class cl_rom *r= (class cl_rom *)(sim->uc->mem(MEM_ROM));
70   for (a= 0; a < sim->uc->get_mem_size(MEM_ROM); a++)
71     {
72       if (r->bp_map->get(a))
73         con->dd_printf("0x%06x\n", a);
74         }*/
75   return(0);
76 }
77
78
79 /*
80  * INFO REGISTERS command
81  */
82
83 //int
84 //cl_info_reg_cmd::do_work(class cl_sim *sim,
85 //                       class cl_cmdline *cmdline, class cl_console_base *con)
86 COMMAND_DO_WORK_UC(cl_info_reg_cmd)
87 {
88   uc->print_regs(con);
89   return(0);
90 }
91
92
93 /*
94  * INFO HW command
95  */
96
97 //int
98 //cl_info_hw_cmd::do_work(class cl_sim *sim,
99 //                      class cl_cmdline *cmdline, class cl_console_base *con)
100 COMMAND_DO_WORK_UC(cl_info_hw_cmd)
101 {
102   class cl_hw *hw;
103   class cl_cmd_arg *params[4]= { cmdline->param(0),
104                                  cmdline->param(1),
105                                  cmdline->param(2),
106                                  cmdline->param(3) };
107
108   if (cmdline->syntax_match(uc, HW)) {
109     hw= params[0]->value.hw;
110     hw->print_info(con);
111   }
112   else
113     con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
114
115   return(DD_FALSE);
116 }
117
118
119 /*
120  * INFO STACK command
121  */
122
123 //int
124 //cl_info_stack_cmd::do_work(class cl_sim *sim,
125 //                          class cl_cmdline *cmdline, class cl_console_base *con)
126 COMMAND_DO_WORK_UC(cl_info_stack_cmd)
127 {
128   int i;
129
130   cl_stack_op::info_head(con);
131   for (i= uc->stack_ops->count-1; i >= 0; i--)
132     {
133       class cl_stack_op *so= (class cl_stack_op *)(uc->stack_ops->at(i));
134       so->info(con, uc);
135     }
136   return(DD_FALSE);
137 }
138
139
140 /*
141  * INFO MMEORY command
142  *----------------------------------------------------------------------------
143  */
144
145 COMMAND_DO_WORK_UC(cl_info_memory_cmd)
146 {
147   int i;
148
149   con->dd_printf("Memory chips:\n");
150   for (i= 0; i < uc->memchips->count; i++)
151     {
152       class cl_memory_chip *m= (class cl_memory_chip *)(uc->memchips->at(i));
153       if (m)
154         con->dd_printf("  0x%06x-0x%06x %8d %s (%d,%s,%s)\n",
155                        m->get_start_address(),
156                        m->highest_valid_address(),
157                        m->get_size(),
158                        m->get_name(),
159                        m->width, m->data_format, m->addr_format);
160     }
161   con->dd_printf("Address spaces:\n");
162   for (i= 0; i < uc->address_spaces->count; i++)
163     {
164       class cl_address_space *m=
165         (class cl_address_space *)(uc->address_spaces->at(i));
166       if (m)
167         con->dd_printf("  0x%06x-0x%06x %8d %s (%d,%s,%s)\n",
168                        m->get_start_address(),
169                        m->highest_valid_address(),
170                        m->get_size(),
171                        m->get_name(),
172                        m->width, m->data_format, m->addr_format);
173     }
174   con->dd_printf("Address decoders:\n");
175   for (i= 0; i < uc->address_spaces->count; i++)
176     {
177       class cl_address_space *m=
178         (class cl_address_space *)(uc->address_spaces->at(i));
179       int j;
180       for (j= 0; j < m->decoders->count; j++)
181         {
182           class cl_address_decoder *d=
183             (class cl_address_decoder *)(m->decoders->at(j));
184           con->dd_printf("%2d ", j);
185           if (d->address_space)
186             {
187               con->dd_printf("%s ", d->address_space->get_name("unknown"));
188               con->dd_printf(d->address_space->addr_format, d->as_begin);
189               con->dd_printf(" ");
190               con->dd_printf(d->address_space->addr_format, d->as_end);
191             }
192           else
193             con->dd_printf("x");
194           con->dd_printf(" -> ");
195           if (d->memchip)
196             {
197               con->dd_printf("%s ", d->memchip->get_name("unknown"));
198               con->dd_printf(d->memchip->addr_format, d->chip_begin);
199             }
200           else
201             con->dd_printf("x");
202           con->dd_printf(" %s\n", (d->activated)?"activated":"inactive");
203         }
204     }
205   return(0);
206 }
207
208
209 /* End of cmd.src/info.cc */