1d4d79e5ee4c3f5cc267e8b25484f2eb44f8da88
[fw/sdcc] / sim / ucsim / cmd.src / cmdconf.cc
1 /*
2  * Simulator of microcontrollers (cmd.src/cmdconf.cc)
3  *
4  * Copyright (C) 2001,01 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 // prj
29 #include "globals.h"
30 #include "utils.h"
31
32 // sim
33 #include "simcl.h"
34
35 // local
36 #include "cmdconfcl.h"
37
38
39 /*
40  * Command: conf
41  *----------------------------------------------------------------------------
42  */
43
44 //int
45 //cl_conf_cmd::do_work(class cl_sim *sim,
46 //                   class cl_cmdline *cmdline, class cl_console *con)
47 COMMAND_DO_WORK_UC(cl_conf_cmd)
48 {
49   int i;
50
51   con->dd_printf("ucsim version %s\n", VERSIONSTR);
52   con->dd_printf("Type of microcontroller: %s\n", uc->id_string());
53   con->dd_printf("Controller has %d hardware element(s).\n",
54                  uc->hws->count);
55   for (i= 0; i < uc->hws->count; i++)
56     {
57       class cl_hw *hw= (class cl_hw *)(uc->hws->at(i));
58       con->dd_printf("  %s[%d]\n", hw->id_string, hw->id);
59     }
60   con->dd_printf("Memories:\n");
61   for (i= MEM_ROM; i < MEM_TYPES; i++)
62     {
63       class cl_mem *mem= (class cl_mem *)(uc->mems->at(i));
64       if (mem)
65         con->dd_printf("  %s size= 0x%06x %6d width= %2d class= \"%s\"\n",
66                        mem->id_string(), mem->size, mem->size, mem->width,
67                        (mem->class_name)?(mem->class_name):"unknown");
68     }
69   return(0);
70 }
71
72 /*
73  * Command: conf addmem
74  *----------------------------------------------------------------------------
75  */
76
77 //int
78 //cl_conf_addmem_cmd::do_work(class cl_sim *sim,
79 //                          class cl_cmdline *cmdline, class cl_console *con)
80 COMMAND_DO_WORK_UC(cl_conf_addmem_cmd)
81 {
82   class cl_mem *mem= 0;
83   class cl_cmd_arg *params[4]= { cmdline->param(0),
84                                  cmdline->param(1),
85                                  cmdline->param(2),
86                                  cmdline->param(3) };
87   char *mem_class;
88
89   if (cmdline->syntax_match(uc, STRING)) {
90     mem_class= params[0]->value.string.string;
91     enum mem_class type;
92     type= (enum mem_class)get_string_id(mem_classes, mem_class, -1);
93     mem= uc->mk_mem(type, mem_class);
94     if (mem)
95       {
96         class cl_mem *m= uc->mem(type);
97         if (m)
98           delete m;
99         uc->mems->put_at(type, mem);
100       }
101     else
102       con->dd_printf("Can not make memory \"%s\"\n", mem_class);
103   }
104   return(DD_FALSE);
105 }
106
107
108 /* End of cmd.src/cmdconf.cc */