0.2.38-pre1 implements AVR instructions
[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_cmdline *cmdline, class cl_console *con)
44 {
45   int i;
46   char *s;
47
48   con->printf("Num Type       Disp Hit   Cnt   Address  What\n");
49   for (i= 0; i < sim->uc->fbrk->count; i++)
50     {
51       class cl_brk *fb= (class cl_brk *)(sim->uc->fbrk->at(i));
52       s= sim->uc->disass(fb->addr, NULL);
53       con->printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", fb->nr,
54                   "fetch", (fb->perm==brkFIX)?"keep":"del ",
55                   fb->hit, fb->cnt,
56                   fb->addr, s);
57       free(s);
58     }
59   for (i= 0; i < sim->uc->ebrk->count; i++)
60     {
61       class cl_ev_brk *eb= (class cl_ev_brk *)(sim->uc->ebrk->at(i));
62       con->printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", eb->nr,
63                   "event", (eb->perm==brkFIX)?"keep":"del ",
64                   eb->hit, eb->cnt,
65                   eb->addr, eb->id);
66     }
67   /*t_addr a;
68   class cl_rom *r= (class cl_rom *)(sim->uc->mem(MEM_ROM));
69   for (a= 0; a < sim->uc->get_mem_size(MEM_ROM); a++)
70     {
71       if (r->bp_map->get(a))
72         con->printf("0x%06x\n", a);
73         }*/
74   return(0);
75 }
76
77
78 /*
79  * INFO REGISTERS command
80  */
81
82 int
83 cl_info_reg_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
84 {
85   sim->uc->print_regs(con);
86   return(0);
87 }
88
89
90 /*
91  * INFO HW command
92  */
93
94 int
95 cl_info_hw_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
96 {
97   class cl_cmd_arg *params[4]= { cmdline->param(0),
98                                  cmdline->param(1),
99                                  cmdline->param(2),
100                                  cmdline->param(3) };
101   char *p0;
102   enum hw_cath cath;
103   class cl_hw *hw;
104   int i= 0;
105
106   if (params[0] == 0)
107     {
108       con->printf("Cathegory missing\n");
109       return(0);
110     }
111   p0= (params[0])->get_svalue();
112   if (strstr(p0, "t") == p0)
113     cath= HW_TIMER;
114   else if (strstr(p0, "u") == p0)
115     cath= HW_UART;
116   else if (strstr(p0, "po") == p0)
117     cath= HW_PORT;
118   else if (strstr(p0, "pc") == p0)
119     cath= HW_PCA;
120   else if (strstr(p0, "i") == p0)
121     cath= HW_INTERRUPT;
122   else if (strstr(p0, "w") == p0)
123     cath= HW_WDT;
124   else
125     {
126       con->printf("Unknown cathegory\n");
127       return(0);
128     }
129   if (params[1] == 0)
130     {
131       // no ID
132       hw= sim->uc->get_hw(cath, &i);
133       while (hw)
134         {
135           hw->print_info(con);
136           i++;
137           hw= sim->uc->get_hw(cath, &i);
138         }
139     }
140   else
141     {
142       // ID given
143       int id= (params[1])->get_ivalue();
144       hw= sim->uc->get_hw(cath, id, &i);
145       while (hw)
146         {
147           hw->print_info(con);
148           i++;
149           hw= sim->uc->get_hw(cath, id, &i);
150         }      
151     }
152   return(0);
153 }
154
155
156 /* End of cmd.src/info.cc */