1 /* This file is part of the program psim.
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.
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.
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.
30 #include "registers.h"
31 #include "device_tree.h"
35 #include "interrupts.h"
42 #ifndef CONST_ATTRIBUTE
43 #define CONST_ATTRIBUTE __attribute__((__const__))
46 /* typedef struct _cpu cpu;
48 Declared in basics.h because it is used opaquely throughout the
52 /* Create a cpu object */
54 INLINE_CPU cpu *cpu_create
61 INLINE_CPU void cpu_init
64 /* Find our way home */
66 INLINE_CPU psim *cpu_system
67 (cpu *processor) CONST_ATTRIBUTE;
69 INLINE_CPU cpu_mon *cpu_monitor
70 (cpu *processor) CONST_ATTRIBUTE;
73 (cpu *processor) CONST_ATTRIBUTE;
75 INLINE_CPU event_queue *cpu_event_queue
79 /* The processors local concept of time */
81 INLINE_CPU signed64 cpu_get_time_base
84 INLINE_CPU void cpu_set_time_base
88 INLINE_CPU signed32 cpu_get_decrementer
91 INLINE_CPU void cpu_set_decrementer
93 signed32 decrementer);
96 /* manipulate the program counter
98 The program counter is not included in the register file. Instead
99 it is extracted and then later restored (set, reset, halt). This
100 is to give the user of the cpu (and the compiler) the chance to
101 minimize the need to load/store the cpu's PC value. (Especially in
102 the case of a single processor) */
104 INLINE_CPU void cpu_set_program_counter
106 unsigned_word new_program_counter);
108 INLINE_CPU unsigned_word cpu_get_program_counter
111 INLINE_CPU void cpu_restart
115 INLINE_CPU void cpu_halt
122 #if WITH_IDECODE_CACHE_SIZE
123 /* Return the cache entry that matches the given CIA. No guarentee
124 that the cache entry actually contains the instruction for that
127 INLINE_CPU idecode_cache *cpu_icache_entry
131 INLINE_CPU void cpu_flush_icache
136 /* reveal the processors VM:
138 At first sight it may seem better to, instead of exposing the cpu's
139 inner vm maps, to have the cpu its self provide memory manipulation
140 functions. (eg cpu_instruction_fetch() cpu_data_read_4())
142 Unfortunatly in addition to these functions is the need (for the
143 debugger) to be able to read/write to memory in ways that violate
144 the vm protection (eg store breakpoint instruction in the
147 INLINE_CPU vm_data_map *cpu_data_map
150 INLINE_CPU vm_instruction_map *cpu_instruction_map
154 /* grant access to the reservation information */
155 typedef struct _memory_reservation {
159 } memory_reservation;
161 INLINE_CPU memory_reservation *cpu_reservation
165 INLINE_CPU void cpu_print_info
172 This model exploits the PowerPC's requirement for a synchronization
173 to occure after (or before) the update of any context controlling
174 register. All context sync points must call the sync function
175 below to when ever a synchronization point is reached */
177 INLINE_CPU registers *cpu_registers
178 (cpu *processor) CONST_ATTRIBUTE;
180 INLINE_CPU void cpu_synchronize_context
183 INLINE_CPU model_data *cpu_model
184 (cpu *processor) CONST_ATTRIBUTE;
186 #define IS_PROBLEM_STATE(PROCESSOR) \
187 (CURRENT_ENVIRONMENT == OPERATING_ENVIRONMENT \
188 ? (cpu_registers(PROCESSOR)->msr & msr_problem_state) \
191 #define IS_64BIT_MODE(PROCESSOR) \
192 (WITH_TARGET_WORD_BITSIZE == 64 \
193 ? (CURRENT_ENVIRONMENT == OPERATING_ENVIRONMENT \
194 ? (cpu_registers(PROCESSOR)->msr & msr_64bit_mode) \
198 #define IS_FP_AVAILABLE(PROCESSOR) \
199 (CURRENT_ENVIRONMENT == OPERATING_ENVIRONMENT \
200 ? (cpu_registers(PROCESSOR)->msr & msr_floating_point_available) \