]> Git Repo - binutils.git/blob - sim/ppc/cpu.h
More scheduling stuff
[binutils.git] / sim / ppc / cpu.h
1 /*  This file is part of the program psim.
2
3     Copyright (C) 1994-1995, Andrew Cagney <[email protected]>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14  
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  
19     */
20
21
22 #ifndef _CPU_H_
23 #define _CPU_H_
24
25 #ifndef INLINE_CPU
26 #define INLINE_CPU
27 #endif
28
29 #include "basics.h"
30 #include "registers.h"
31 #include "device_tree.h"
32 #include "corefile.h"
33 #include "vm.h"
34 #include "events.h"
35 #include "interrupts.h"
36 #include "psim.h"
37 #include "icache.h"
38 #include "itable.h"
39 #include "mon.h"
40 #include "model.h"
41 #include "function_unit.h"
42
43
44 /* typedef struct _cpu cpu;
45
46    Declared in basics.h because it is used opaquely throughout the
47    code */
48
49
50 /* Create a cpu object */
51
52 INLINE_CPU cpu *cpu_create
53 (psim *system,
54  core *memory,
55  event_queue *events,
56  cpu_mon *monitor,
57  int cpu_nr);
58
59 INLINE_CPU void cpu_init
60 (cpu *processor);
61
62 /* Find our way home */
63
64 INLINE_CPU psim *cpu_system
65 (cpu *processor);
66
67 INLINE_CPU cpu_mon *cpu_monitor
68 (cpu *processor);
69
70 INLINE_CPU int cpu_nr
71 (cpu *processor);
72
73 INLINE_CPU event_queue *cpu_event_queue
74 (cpu *processor);
75
76
77 /* The processors local concept of time */
78
79 INLINE_CPU signed64 cpu_get_time_base
80 (cpu *processor);
81
82 INLINE_CPU void cpu_set_time_base
83 (cpu *processor,
84  signed64 time_base);
85
86 INLINE_CPU signed32 cpu_get_decrementer
87 (cpu *processor);
88
89 INLINE_CPU void cpu_set_decrementer
90 (cpu *processor,
91  signed32 decrementer);
92
93
94 /* manipulate the program counter
95
96    The program counter is not included in the register file.  Instead
97    it is extracted and then later restored (set, reset, halt).  This
98    is to give the user of the cpu (and the compiler) the chance to
99    minimize the need to load/store the cpu's PC value.  (Especially in
100    the case of a single processor) */
101
102 INLINE_CPU void cpu_set_program_counter
103 (cpu *processor,
104  unsigned_word new_program_counter);
105
106 INLINE_CPU unsigned_word cpu_get_program_counter
107 (cpu *processor);
108
109 INLINE_CPU void cpu_restart
110 (cpu *processor,
111  unsigned_word nia);
112
113 INLINE_CPU void cpu_halt
114 (cpu *processor,
115  unsigned_word nia,
116  stop_reason reason,
117  int signal);
118
119
120 #if WITH_IDECODE_CACHE_SIZE
121 /* Return the cache entry that matches the given CIA.  No guarentee
122    that the cache entry actually contains the instruction for that
123    address */
124
125 INLINE_CPU idecode_cache *cpu_icache_entry
126 (cpu *processor,
127  unsigned_word cia);
128
129 INLINE_CPU void cpu_flush_icache
130 (cpu *processor);
131 #endif
132
133
134 /* reveal the processors VM:
135
136    At first sight it may seem better to, instead of exposing the cpu's
137    inner vm maps, to have the cpu its self provide memory manipulation
138    functions. (eg cpu_instruction_fetch() cpu_data_read_4())
139
140    Unfortunatly in addition to these functions is the need (for the
141    debugger) to be able to read/write to memory in ways that violate
142    the vm protection (eg store breakpoint instruction in the
143    instruction map). */
144
145 INLINE_CPU vm_data_map *cpu_data_map
146 (cpu *processor);
147
148 INLINE_CPU vm_instruction_map *cpu_instruction_map
149 (cpu *processor);
150
151
152 /* grant access to the reservation information */
153 typedef struct _memory_reservation {
154   int valid;
155   unsigned_word addr;
156   unsigned_word data;
157 } memory_reservation;
158
159 INLINE_CPU memory_reservation *cpu_reservation
160 (cpu *processor);
161
162
163 INLINE_CPU void cpu_print_info
164 (cpu *processor,
165  int verbose);
166
167
168 /* Registers:
169
170    This model exploits the PowerPC's requirement for a synchronization
171    to occure after (or before) the update of any context controlling
172    register.  All context sync points must call the sync function
173    below to when ever a synchronization point is reached */
174
175 INLINE_CPU registers *cpu_registers
176 (cpu *processor);
177
178 INLINE_CPU void cpu_synchronize_context
179 (cpu *processor);
180
181 INLINE_CPU function_unit *cpu_function_unit
182 (cpu *processor);
183
184 INLINE_CPU model_data *cpu_model
185 (cpu *processor);
186
187 #define IS_PROBLEM_STATE(PROCESSOR) \
188 (CURRENT_ENVIRONMENT == OPERATING_ENVIRONMENT \
189  ? (cpu_registers(PROCESSOR)->msr & msr_problem_state) \
190  : 1)
191
192 #define IS_64BIT_MODE(PROCESSOR) \
193 (WITH_TARGET_WORD_BITSIZE == 64 \
194  ? (CURRENT_ENVIRONMENT == OPERATING_ENVIRONMENT \
195     ? (cpu_registers(PROCESSOR)->msr & msr_64bit_mode) \
196     : 1) \
197  : 0)
198
199 #define IS_FP_AVAILABLE(PROCESSOR) \
200 (CURRENT_ENVIRONMENT == OPERATING_ENVIRONMENT \
201  ? (cpu_registers(PROCESSOR)->msr & msr_floating_point_available) \
202  : 1)
203
204 #endif
This page took 0.032802 seconds and 4 git commands to generate.