No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gdb6 / sim / common / sim-cpu.c
blob0e6d52c1dd12eec6892a87b9277b808d061ce319
1 /* CPU support.
2 Copyright (C) 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
5 This file is part of GDB, the GNU debugger.
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.
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.
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. */
21 #include "sim-main.h"
22 #include "bfd.h"
24 /* Allocate space for all cpus in the simulator.
25 Space for the cpu must currently exist prior to parsing ARGV.
26 EXTRA_BYTES is additional space to allocate for the sim_cpu struct. */
27 /* ??? wip. better solution must wait. */
29 SIM_RC
30 sim_cpu_alloc_all (SIM_DESC sd, int ncpus, int extra_bytes)
32 int c;
34 for (c = 0; c < ncpus; ++c)
35 STATE_CPU (sd, c) = sim_cpu_alloc (sd, extra_bytes);
36 return SIM_RC_OK;
39 /* Allocate space for a cpu object.
40 EXTRA_BYTES is additional space to allocate for the sim_cpu struct. */
42 sim_cpu *
43 sim_cpu_alloc (SIM_DESC sd, int extra_bytes)
45 return zalloc (sizeof (sim_cpu) + extra_bytes);
48 /* Free all resources held by all cpus. */
50 void
51 sim_cpu_free_all (SIM_DESC sd)
53 int c;
55 for (c = 0; c < MAX_NR_PROCESSORS; ++c)
56 if (STATE_CPU (sd, c))
57 sim_cpu_free (STATE_CPU (sd, c));
60 /* Free all resources used by CPU. */
62 void
63 sim_cpu_free (sim_cpu *cpu)
65 zfree (cpu);
68 /* PC utilities. */
70 sim_cia
71 sim_pc_get (sim_cpu *cpu)
73 return (* CPU_PC_FETCH (cpu)) (cpu);
76 void
77 sim_pc_set (sim_cpu *cpu, sim_cia newval)
79 (* CPU_PC_STORE (cpu)) (cpu, newval);