Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / sim / common / sim-cpu.c
CommitLineData
c906108c 1/* CPU support.
88b9d363 2 Copyright (C) 1998-2022 Free Software Foundation, Inc.
c906108c
SS
3 Contributed by Cygnus Solutions.
4
5This file is part of GDB, the GNU debugger.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
4744ac1b
JB
9the Free Software Foundation; either version 3 of the License, or
10(at your option) any later version.
c906108c
SS
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
4744ac1b
JB
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 19
6df01ab8
MF
20/* This must come before any other includes. */
21#include "defs.h"
22
b3f8962b
TV
23#include <stdlib.h>
24
c906108c
SS
25#include "sim-main.h"
26#include "bfd.h"
27
28/* Allocate space for all cpus in the simulator.
d5a71b11 29 Space for the cpu must currently exist prior to parsing ARGV. */
c906108c
SS
30/* ??? wip. better solution must wait. */
31
32SIM_RC
d5a71b11 33sim_cpu_alloc_all (SIM_DESC sd, int ncpus)
c906108c
SS
34{
35 int c;
36
37 for (c = 0; c < ncpus; ++c)
d5a71b11 38 STATE_CPU (sd, c) = sim_cpu_alloc (sd);
c906108c
SS
39 return SIM_RC_OK;
40}
41
42/* Allocate space for a cpu object.
43 EXTRA_BYTES is additional space to allocate for the sim_cpu struct. */
44
45sim_cpu *
d5a71b11 46sim_cpu_alloc (SIM_DESC sd)
c906108c 47{
d5a71b11
MF
48 int extra_bytes = 0;
49
50#ifdef CGEN_ARCH
1c636da0 51 extra_bytes += cgen_cpu_max_extra_bytes (sd);
d5a71b11
MF
52#endif
53
c906108c
SS
54 return zalloc (sizeof (sim_cpu) + extra_bytes);
55}
56
57/* Free all resources held by all cpus. */
58
59void
60sim_cpu_free_all (SIM_DESC sd)
61{
62 int c;
63
64 for (c = 0; c < MAX_NR_PROCESSORS; ++c)
65 if (STATE_CPU (sd, c))
66 sim_cpu_free (STATE_CPU (sd, c));
67}
68
69/* Free all resources used by CPU. */
70
71void
72sim_cpu_free (sim_cpu *cpu)
73{
d79fe0d6 74 free (cpu);
c906108c
SS
75}
76\f
77/* PC utilities. */
78
79sim_cia
80sim_pc_get (sim_cpu *cpu)
81{
82 return (* CPU_PC_FETCH (cpu)) (cpu);
83}
84
85void
86sim_pc_set (sim_cpu *cpu, sim_cia newval)
87{
88 (* CPU_PC_STORE (cpu)) (cpu, newval);
89}
This page took 1.10627 seconds and 4 git commands to generate.