OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [gdb-5.0/] [sim/] [fr30/] [sim-if.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* Main simulator entry points specific to the FR30.
2
   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
3
   Contributed by Cygnus Solutions.
4
 
5
This file is part of the GNU simulators.
6
 
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2, or (at your option)
10
any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License along
18
with this program; if not, write to the Free Software Foundation, Inc.,
19
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
 
21
#include "sim-main.h"
22
#ifdef HAVE_STDLIB_H
23
#include <stdlib.h>
24
#endif
25
#include "sim-options.h"
26
#include "libiberty.h"
27
#include "bfd.h"
28
 
29
static void free_state (SIM_DESC);
30
static void print_fr30_misc_cpu (SIM_CPU *cpu, int verbose);
31
 
32
/* Records simulator descriptor so utilities like fr30_dump_regs can be
33
   called from gdb.  */
34
SIM_DESC current_state;
35
 
36
/* Cover function of sim_state_free to free the cpu buffers as well.  */
37
 
38
static void
39
free_state (SIM_DESC sd)
40
{
41
  if (STATE_MODULES (sd) != NULL)
42
    sim_module_uninstall (sd);
43
  sim_cpu_free_all (sd);
44
  sim_state_free (sd);
45
}
46
 
47
/* Create an instance of the simulator.  */
48
 
49
SIM_DESC
50
sim_open (kind, callback, abfd, argv)
51
     SIM_OPEN_KIND kind;
52
     host_callback *callback;
53
     struct _bfd *abfd;
54
     char **argv;
55
{
56
  char c;
57
  int i;
58
  SIM_DESC sd = sim_state_alloc (kind, callback);
59
 
60
  /* The cpu data is kept in a separately allocated chunk of memory.  */
61
  if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ()) != SIM_RC_OK)
62
    {
63
      free_state (sd);
64
      return 0;
65
    }
66
 
67
#if 0 /* FIXME: pc is in mach-specific struct */
68
  /* FIXME: watchpoints code shouldn't need this */
69
  {
70
    SIM_CPU *current_cpu = STATE_CPU (sd, 0);
71
    STATE_WATCHPOINTS (sd)->pc = &(PC);
72
    STATE_WATCHPOINTS (sd)->sizeof_pc = sizeof (PC);
73
  }
74
#endif
75
 
76
  if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
77
    {
78
      free_state (sd);
79
      return 0;
80
    }
81
 
82
#if 0 /* FIXME: 'twould be nice if we could do this */
83
  /* These options override any module options.
84
     Obviously ambiguity should be avoided, however the caller may wish to
85
     augment the meaning of an option.  */
86
  if (extra_options != NULL)
87
    sim_add_option_table (sd, extra_options);
88
#endif
89
 
90
  /* getopt will print the error message so we just have to exit if this fails.
91
     FIXME: Hmmm...  in the case of gdb we need getopt to call
92
     print_filtered.  */
93
  if (sim_parse_args (sd, argv) != SIM_RC_OK)
94
    {
95
      free_state (sd);
96
      return 0;
97
    }
98
 
99
#if 0
100
  /* Allocate a handler for the control registers and other devices
101
     if no memory for that range has been allocated by the user.
102
     All are allocated in one chunk to keep things from being
103
     unnecessarily complicated.  */
104
  if (sim_core_read_buffer (sd, NULL, read_map, &c, FR30_DEVICE_ADDR, 1) == 0)
105
    sim_core_attach (sd, NULL,
106
 
107
                     access_read_write,
108
 
109
                     FR30_DEVICE_ADDR, FR30_DEVICE_LEN /*nr_bytes*/,
110
 
111
                     &fr30_devices,
112
                     NULL /*buffer*/);
113
#endif
114
 
115
  /* Allocate core managed memory if none specified by user.
116
     Use address 4 here in case the user wanted address 0 unmapped.  */
117
  if (sim_core_read_buffer (sd, NULL, read_map, &c, 4, 1) == 0)
118
    sim_do_commandf (sd, "memory region 0,0x%lx", FR30_DEFAULT_MEM_SIZE);
119
 
120
  /* check for/establish the reference program image */
121
  if (sim_analyze_program (sd,
122
                           (STATE_PROG_ARGV (sd) != NULL
123
                            ? *STATE_PROG_ARGV (sd)
124
                            : NULL),
125
                           abfd) != SIM_RC_OK)
126
    {
127
      free_state (sd);
128
      return 0;
129
    }
130
 
131
  /* Establish any remaining configuration options.  */
132
  if (sim_config (sd) != SIM_RC_OK)
133
    {
134
      free_state (sd);
135
      return 0;
136
    }
137
 
138
  if (sim_post_argv_init (sd) != SIM_RC_OK)
139
    {
140
      free_state (sd);
141
      return 0;
142
    }
143
 
144
  /* Open a copy of the cpu descriptor table.  */
145
  {
146
    CGEN_CPU_DESC cd = fr30_cgen_cpu_open_1 (STATE_ARCHITECTURE (sd)->printable_name,
147
                                             CGEN_ENDIAN_BIG);
148
    for (i = 0; i < MAX_NR_PROCESSORS; ++i)
149
      {
150
        SIM_CPU *cpu = STATE_CPU (sd, i);
151
        CPU_CPU_DESC (cpu) = cd;
152
        CPU_DISASSEMBLER (cpu) = sim_cgen_disassemble_insn;
153
      }
154
    fr30_cgen_init_dis (cd);
155
  }
156
 
157
  /* Initialize various cgen things not done by common framework.
158
     Must be done after fr30_cgen_cpu_open.  */
159
  cgen_init (sd);
160
 
161
  /* Store in a global so things like sparc32_dump_regs can be invoked
162
     from the gdb command line.  */
163
  current_state = sd;
164
 
165
  return sd;
166
}
167
 
168
void
169
sim_close (sd, quitting)
170
     SIM_DESC sd;
171
     int quitting;
172
{
173
  fr30_cgen_cpu_close (CPU_CPU_DESC (STATE_CPU (sd, 0)));
174
  sim_module_uninstall (sd);
175
}
176
 
177
SIM_RC
178
sim_create_inferior (sd, abfd, argv, envp)
179
     SIM_DESC sd;
180
     struct _bfd *abfd;
181
     char **argv;
182
     char **envp;
183
{
184
  SIM_CPU *current_cpu = STATE_CPU (sd, 0);
185
  SIM_ADDR addr;
186
 
187
  if (abfd != NULL)
188
    addr = bfd_get_start_address (abfd);
189
  else
190
    addr = 0;
191
  sim_pc_set (current_cpu, addr);
192
 
193
#if 0
194
  STATE_ARGV (sd) = sim_copy_argv (argv);
195
  STATE_ENVP (sd) = sim_copy_argv (envp);
196
#endif
197
 
198
  return SIM_RC_OK;
199
}
200
 
201
void
202
sim_do_command (sd, cmd)
203
     SIM_DESC sd;
204
     char *cmd;
205
{
206
  if (sim_args_command (sd, cmd) != SIM_RC_OK)
207
    sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
208
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.