summaryrefslogtreecommitdiff
path: root/src/core/arm/interpreter/arminit.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2015-01-30 13:24:19 -0500
committerGravatar Lioncash2015-01-30 13:32:03 -0500
commit09a66860e235242f4bcdf52f0cf71284fb35bfa8 (patch)
tree564c496932549bf8de83b9e199f0380cd5d6f2e1 /src/core/arm/interpreter/arminit.cpp
parentarmdefs: Move some defines over to enums (diff)
downloadyuzu-09a66860e235242f4bcdf52f0cf71284fb35bfa8.tar.gz
yuzu-09a66860e235242f4bcdf52f0cf71284fb35bfa8.tar.xz
yuzu-09a66860e235242f4bcdf52f0cf71284fb35bfa8.zip
arm: Throw out a lot of unnecessary code
Diffstat (limited to 'src/core/arm/interpreter/arminit.cpp')
-rw-r--r--src/core/arm/interpreter/arminit.cpp288
1 files changed, 27 insertions, 261 deletions
diff --git a/src/core/arm/interpreter/arminit.cpp b/src/core/arm/interpreter/arminit.cpp
index 03bca2870..8ab5ef160 100644
--- a/src/core/arm/interpreter/arminit.cpp
+++ b/src/core/arm/interpreter/arminit.cpp
@@ -15,8 +15,6 @@
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 17
18//#include <unistd.h>
19
20#include "core/arm/skyeye_common/armdefs.h" 18#include "core/arm/skyeye_common/armdefs.h"
21#include "core/arm/skyeye_common/armemu.h" 19#include "core/arm/skyeye_common/armemu.h"
22 20
@@ -24,26 +22,21 @@
24* Definitions for the emulator architecture * 22* Definitions for the emulator architecture *
25\***************************************************************************/ 23\***************************************************************************/
26 24
27void ARMul_EmulateInit (void); 25void ARMul_EmulateInit();
28ARMul_State *ARMul_NewState (ARMul_State * state); 26ARMul_State* ARMul_NewState(ARMul_State* state);
29void ARMul_Reset (ARMul_State * state); 27void ARMul_Reset (ARMul_State* state);
30ARMword ARMul_DoCycle (ARMul_State * state); 28ARMword ARMul_DoCycle(ARMul_State* state);
31unsigned ARMul_DoCoPro (ARMul_State * state); 29unsigned ARMul_DoCoPro(ARMul_State* state);
32ARMword ARMul_DoProg (ARMul_State * state); 30ARMword ARMul_DoProg(ARMul_State* state);
33ARMword ARMul_DoInstr (ARMul_State * state); 31ARMword ARMul_DoInstr(ARMul_State* state);
34void ARMul_Abort (ARMul_State * state, ARMword address); 32void ARMul_Abort(ARMul_State* state, ARMword address);
35 33
36unsigned ARMul_MultTable[32] = { 34unsigned ARMul_MultTable[32] = {
37 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 35 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
38 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 16 36 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 16
39}; 37};
40ARMword ARMul_ImmedTable[4096]; /* immediate DP LHS values */ 38ARMword ARMul_ImmedTable[4096]; /* immediate DP LHS values */
41char ARMul_BitList[256]; /* number of bits in a byte table */ 39char ARMul_BitList[256]; /* number of bits in a byte table */
42
43//chy 2006-02-22 add test debugmode
44extern int debugmode;
45extern int remote_interrupt( void );
46
47 40
48void arm_dyncom_Abort(ARMul_State * state, ARMword vector) 41void arm_dyncom_Abort(ARMul_State * state, ARMword vector)
49{ 42{
@@ -51,36 +44,10 @@ void arm_dyncom_Abort(ARMul_State * state, ARMword vector)
51} 44}
52 45
53 46
54/* ahe-ykl : the following code to initialize user mode
55 code is architecture dependent and probably model dependant. */
56
57/*#include "skyeye_arch.h"
58#include "skyeye_pref.h"
59#include "skyeye_exec_info.h"
60#include "bank_defs.h"*/
61//#include "armcpu.h"
62//#include "skyeye_callback.h"
63
64/*
65 ARM_CPU_State* cpu = get_current_cpu();
66 arm_core_t* core = &cpu->core[0];
67
68 uint32_t sp = info->initial_sp;
69
70 core->Cpsr = 0x10; // User mode
71// FIXME: may need to add thumb
72core->Reg[13] = sp;
73core->Reg[10] = info->start_data;
74core->Reg[0] = 0;
75bus_read(32, sp + 4, &(core->Reg[1]));
76bus_read(32, sp + 8, &(core->Reg[2]));
77*/
78/***************************************************************************\ 47/***************************************************************************\
79* Call this routine once to set up the emulator's tables. * 48* Call this routine once to set up the emulator's tables. *
80\***************************************************************************/ 49\***************************************************************************/
81 50void ARMul_EmulateInit()
82void
83ARMul_EmulateInit (void)
84{ 51{
85 unsigned int i, j; 52 unsigned int i, j;
86 53
@@ -102,9 +69,7 @@ ARMul_EmulateInit (void)
102/***************************************************************************\ 69/***************************************************************************\
103* Returns a new instantiation of the ARMulator's state * 70* Returns a new instantiation of the ARMulator's state *
104\***************************************************************************/ 71\***************************************************************************/
105 72ARMul_State* ARMul_NewState(ARMul_State* state)
106ARMul_State *
107ARMul_NewState (ARMul_State *state)
108{ 73{
109 unsigned i, j; 74 unsigned i, j;
110 75
@@ -120,7 +85,6 @@ ARMul_NewState (ARMul_State *state)
120 state->Spsr[i] = 0; 85 state->Spsr[i] = 0;
121 state->Mode = 0; 86 state->Mode = 0;
122 87
123 state->CallDebug = FALSE;
124 state->Debug = FALSE; 88 state->Debug = FALSE;
125 state->VectorCatch = 0; 89 state->VectorCatch = 0;
126 state->Aborted = FALSE; 90 state->Aborted = FALSE;
@@ -128,34 +92,6 @@ ARMul_NewState (ARMul_State *state)
128 state->Inted = 3; 92 state->Inted = 3;
129 state->LastInted = 3; 93 state->LastInted = 3;
130 94
131 state->CommandLine = NULL;
132
133 state->EventSet = 0;
134 state->Now = 0;
135 state->EventPtr =
136 (struct EventNode **) malloc ((unsigned) EVENTLISTSIZE *
137 sizeof (struct EventNode *));
138#if DIFF_STATE
139 state->state_log = fopen("/data/state.log", "w");
140 printf("create pc log file.\n");
141#endif
142 if (state->EventPtr == NULL) {
143 printf ("SKYEYE: ARMul_NewState malloc state->EventPtr error\n");
144 exit(-1);
145 //skyeye_exit (-1);
146 }
147 for (i = 0; i < EVENTLISTSIZE; i++)
148 *(state->EventPtr + i) = NULL;
149#if SAVE_LOG
150 state->state_log = fopen("/tmp/state.log", "w");
151 printf("create pc log file.\n");
152#else
153#if DIFF_LOG
154 state->state_log = fopen("/tmp/state.log", "r");
155 printf("loaded pc log file.\n");
156#endif
157#endif
158
159#ifdef ARM61 95#ifdef ARM61
160 state->prog32Sig = LOW; 96 state->prog32Sig = LOW;
161 state->data32Sig = LOW; 97 state->data32Sig = LOW;
@@ -168,28 +104,19 @@ ARMul_NewState (ARMul_State *state)
168 state->bigendSig = LOW; 104 state->bigendSig = LOW;
169 105
170 //chy:2003-08-19 106 //chy:2003-08-19
171 state->LastTime = 0;
172 state->CP14R0_CCD = -1; 107 state->CP14R0_CCD = -1;
173 108
174 /* ahe-ykl: common function for interpret and dyncom */
175 /*sky_pref_t *pref = get_skyeye_pref();
176 if (pref->user_mode_sim)
177 register_callback(arm_user_mode_init, Bootmach_callback);
178 */
179
180 memset(&state->exclusive_tag_array[0], 0xFF, sizeof(state->exclusive_tag_array[0]) * 128); 109 memset(&state->exclusive_tag_array[0], 0xFF, sizeof(state->exclusive_tag_array[0]) * 128);
181 state->exclusive_access_state = 0; 110 state->exclusive_access_state = 0;
182 //state->cpu = (cpu_config_t *) malloc (sizeof (cpu_config_t)); 111
183 //state->mem_bank = (mem_config_t *) malloc (sizeof (mem_config_t)); 112 return state;
184 return (state);
185} 113}
186 114
187/***************************************************************************\ 115/***************************************************************************\
188* Call this routine to set ARMulator to model a certain processor * 116* Call this routine to set ARMulator to model a certain processor *
189\***************************************************************************/ 117\***************************************************************************/
190 118
191void 119void ARMul_SelectProcessor(ARMul_State* state, unsigned properties)
192ARMul_SelectProcessor (ARMul_State * state, unsigned properties)
193{ 120{
194 if (properties & ARM_Fix26_Prop) { 121 if (properties & ARM_Fix26_Prop) {
195 state->prog32Sig = LOW; 122 state->prog32Sig = LOW;
@@ -198,27 +125,16 @@ ARMul_SelectProcessor (ARMul_State * state, unsigned properties)
198 state->prog32Sig = HIGH; 125 state->prog32Sig = HIGH;
199 state->data32Sig = HIGH; 126 state->data32Sig = HIGH;
200 } 127 }
201 /* 2004-05-09 chy
202 below line sould be in skyeye_mach_XXX.c 's XXX_mach_init function
203 */
204 // state->lateabtSig = HIGH;
205 128
206 129 state->is_v4 = (properties & (ARM_v4_Prop | ARM_v5_Prop)) ? HIGH : LOW;
207 state->is_v4 = 130 state->is_v5 = (properties & ARM_v5_Prop) ? HIGH : LOW;
208 (properties & (ARM_v4_Prop | ARM_v5_Prop)) ? HIGH : LOW; 131 state->is_v5e = (properties & ARM_v5e_Prop) ? HIGH : LOW;
209 state->is_v5 = (properties & ARM_v5_Prop) ? HIGH : LOW;
210 state->is_v5e = (properties & ARM_v5e_Prop) ? HIGH : LOW;
211 state->is_XScale = (properties & ARM_XScale_Prop) ? HIGH : LOW; 132 state->is_XScale = (properties & ARM_XScale_Prop) ? HIGH : LOW;
212 state->is_iWMMXt = (properties & ARM_iWMMXt_Prop) ? HIGH : LOW; 133 state->is_iWMMXt = (properties & ARM_iWMMXt_Prop) ? HIGH : LOW;
213 /* state->is_v6 = LOW */; 134 state->is_v6 = (properties & ARM_v6_Prop) ? HIGH : LOW;
214 /* jeff.du 2010-08-05 */
215 state->is_v6 = (properties & ARM_v6_Prop) ? HIGH : LOW;
216 state->is_ep9312 = (properties & ARM_ep9312_Prop) ? HIGH : LOW; 135 state->is_ep9312 = (properties & ARM_ep9312_Prop) ? HIGH : LOW;
217 //chy 2005-09-19
218 state->is_pxa27x = (properties & ARM_PXA27X_Prop) ? HIGH : LOW; 136 state->is_pxa27x = (properties & ARM_PXA27X_Prop) ? HIGH : LOW;
219 137 state->is_v7 = (properties & ARM_v7_Prop) ? HIGH : LOW;
220 /* shenoubang 2012-3-11 */
221 state->is_v7 = (properties & ARM_v7_Prop) ? HIGH : LOW;
222 138
223 /* Only initialse the coprocessor support once we 139 /* Only initialse the coprocessor support once we
224 know what kind of chip we are dealing with. */ 140 know what kind of chip we are dealing with. */
@@ -229,11 +145,8 @@ ARMul_SelectProcessor (ARMul_State * state, unsigned properties)
229/***************************************************************************\ 145/***************************************************************************\
230* Call this routine to set up the initial machine state (or perform a RESET * 146* Call this routine to set up the initial machine state (or perform a RESET *
231\***************************************************************************/ 147\***************************************************************************/
232 148void ARMul_Reset(ARMul_State* state)
233void
234ARMul_Reset (ARMul_State * state)
235{ 149{
236 //fprintf(stderr,"armul_reset 0: state-> Cpsr 0x%x, Mode %d\n",state->Cpsr,state->Mode);
237 state->NextInstr = 0; 150 state->NextInstr = 0;
238 if (state->prog32Sig) { 151 if (state->prog32Sig) {
239 state->Reg[15] = 0; 152 state->Reg[15] = 0;
@@ -244,15 +157,13 @@ ARMul_Reset (ARMul_State * state)
244 state->Cpsr = INTBITS | SVC26MODE; 157 state->Cpsr = INTBITS | SVC26MODE;
245 state->Mode = SVC26MODE; 158 state->Mode = SVC26MODE;
246 } 159 }
247 //fprintf(stderr,"armul_reset 1: state-> Cpsr 0x%x, Mode %d\n",state->Cpsr,state->Mode); 160
248 //ARMul_CPSRAltered (state);
249 state->Bank = SVCBANK; 161 state->Bank = SVCBANK;
250 FLUSHPIPE; 162 FLUSHPIPE;
251 163
252 state->EndCondition = 0; 164 state->EndCondition = 0;
253 state->ErrorCode = 0; 165 state->ErrorCode = 0;
254 166
255 //fprintf(stderr,"armul_reset 2: state-> Cpsr 0x%x, Mode %d\n",state->Cpsr,state->Mode);
256 state->NresetSig = HIGH; 167 state->NresetSig = HIGH;
257 state->NfiqSig = HIGH; 168 state->NfiqSig = HIGH;
258 state->NirqSig = HIGH; 169 state->NirqSig = HIGH;
@@ -266,33 +177,6 @@ ARMul_Reset (ARMul_State * state)
266 state->NumIcycles = 0; 177 state->NumIcycles = 0;
267 state->NumCcycles = 0; 178 state->NumCcycles = 0;
268 state->NumFcycles = 0; 179 state->NumFcycles = 0;
269
270 //fprintf(stderr,"armul_reset 3: state-> Cpsr 0x%x, Mode %d\n",state->Cpsr,state->Mode);
271 //mmu_reset (state);
272 //fprintf(stderr,"armul_reset 4: state-> Cpsr 0x%x, Mode %d\n",state->Cpsr,state->Mode);
273
274 //mem_reset (state); /* move to memory/ram.c */
275
276 //fprintf(stderr,"armul_reset 5: state-> Cpsr 0x%x, Mode %d\n",state->Cpsr,state->Mode);
277 /*remove later. walimis 03.7.17 */
278 //io_reset(state);
279 //lcd_disable(state);
280
281 /*ywc 2005-04-07 move from ARMul_NewState , because skyeye_config.no_dbct will
282 *be configured in skyeye_option_init and it is called after ARMul_NewState*/
283 state->tea_break_ok = 0;
284 state->tea_break_addr = 0;
285 state->tea_pc = 0;
286#ifdef DBCT
287 if (!skyeye_config.no_dbct) {
288 //teawater add for arm2x86 2005.02.14-------------------------------------------
289 if (arm2x86_init (state)) {
290 printf ("SKYEYE: arm2x86_init error\n");
291 //skyeye_exit (-1);
292 }
293 //AJ2D--------------------------------------------------------------------------
294 }
295#endif
296} 180}
297 181
298 182
@@ -301,108 +185,23 @@ ARMul_Reset (ARMul_State * state)
301* (Emulate26 for a 26 bit ARM and Emulate32 for a 32 bit ARM), return the * 185* (Emulate26 for a 26 bit ARM and Emulate32 for a 32 bit ARM), return the *
302* address of the last instruction that is executed. * 186* address of the last instruction that is executed. *
303\***************************************************************************/ 187\***************************************************************************/
304 188ARMword ARMul_DoProg(ARMul_State* state)
305//teawater add DBCT_TEST_SPEED 2005.10.04---------------------------------------
306#ifdef DBCT_TEST_SPEED
307static ARMul_State *dbct_test_speed_state = NULL;
308static void
309dbct_test_speed_sig(int signo)
310{
311 printf("\n0x%llx %llu\n", dbct_test_speed_state->instr_count, dbct_test_speed_state->instr_count);
312 exit(0);
313 //skyeye_exit(0);
314}
315#endif //DBCT_TEST_SPEED
316//AJ2D--------------------------------------------------------------------------
317
318ARMword
319ARMul_DoProg (ARMul_State * state)
320{ 189{
321 ARMword pc = 0; 190 ARMword pc = 0;
322 191
323 /*
324 * 2007-01-24 removed the term-io functions by Anthony Lee,
325 * moved to "device/uart/skyeye_uart_stdio.c".
326 */
327
328//teawater add DBCT_TEST_SPEED 2005.10.04---------------------------------------
329#ifdef DBCT_TEST_SPEED
330 {
331 if (!dbct_test_speed_state) {
332 //init timer
333 struct itimerval value;
334 struct sigaction act;
335
336 dbct_test_speed_state = state;
337 state->instr_count = 0;
338 act.sa_handler = dbct_test_speed_sig;
339 act.sa_flags = SA_RESTART;
340 //cygwin don't support ITIMER_VIRTUAL or ITIMER_PROF
341#ifndef __CYGWIN__
342 if (sigaction(SIGVTALRM, &act, NULL) == -1) {
343#else
344 if (sigaction(SIGALRM, &act, NULL) == -1) {
345#endif //__CYGWIN__
346 fprintf(stderr, "init timer error.\n");
347 exit(-1);
348 //skyeye_exit(-1);
349 }
350 if (skyeye_config.dbct_test_speed_sec) {
351 value.it_value.tv_sec = skyeye_config.dbct_test_speed_sec;
352 } else {
353 value.it_value.tv_sec = DBCT_TEST_SPEED_SEC;
354 }
355 printf("dbct_test_speed_sec = %ld\n", value.it_value.tv_sec);
356 value.it_value.tv_usec = 0;
357 value.it_interval.tv_sec = 0;
358 value.it_interval.tv_usec = 0;
359#ifndef __CYGWIN__
360 if (setitimer(ITIMER_VIRTUAL, &value, NULL) == -1) {
361#else
362 if (setitimer(ITIMER_REAL, &value, NULL) == -1) {
363#endif //__CYGWIN__
364 fprintf(stderr, "init timer error.\n");
365 //skyeye_exit(-1);
366 }
367 }
368 }
369#endif //DBCT_TEST_SPEED
370//AJ2D--------------------------------------------------------------------------
371 state->Emulate = RUN; 192 state->Emulate = RUN;
372 while (state->Emulate != STOP) { 193 while (state->Emulate != STOP) {
373 state->Emulate = RUN; 194 state->Emulate = RUN;
374 195
375 /*ywc 2005-03-31 */
376 if (state->prog32Sig && ARMul_MODE32BIT) { 196 if (state->prog32Sig && ARMul_MODE32BIT) {
377#ifdef DBCT
378 if (skyeye_config.no_dbct) {
379 pc = ARMul_Emulate32 (state);
380 } else {
381 pc = ARMul_Emulate32_dbct (state);
382 }
383#else
384 pc = ARMul_Emulate32 (state); 197 pc = ARMul_Emulate32 (state);
385#endif
386 } 198 }
387
388 else { 199 else {
389 //pc = ARMul_Emulate26 (state); 200 //pc = ARMul_Emulate26 (state);
390 } 201 }
391 //chy 2006-02-22, should test debugmode first
392 //chy 2006-04-14, put below codes in ARMul_Emulate
393#if 0
394 if(debugmode)
395 if(remote_interrupt())
396 state->Emulate = STOP;
397#endif
398 } 202 }
399 203
400 /* 204 return pc;
401 * 2007-01-24 removed the term-io functions by Anthony Lee,
402 * moved to "device/uart/skyeye_uart_stdio.c".
403 */
404
405 return (pc);
406} 205}
407 206
408/***************************************************************************\ 207/***************************************************************************\
@@ -410,38 +209,17 @@ ARMul_DoProg (ARMul_State * state)
410* (Emulate26 for a 26 bit ARM and Emulate32 for a 32 bit ARM), return the * 209* (Emulate26 for a 26 bit ARM and Emulate32 for a 32 bit ARM), return the *
411* address of the instruction that is executed. * 210* address of the instruction that is executed. *
412\***************************************************************************/ 211\***************************************************************************/
413 212ARMword ARMul_DoInstr(ARMul_State* state)
414ARMword
415ARMul_DoInstr (ARMul_State * state)
416{ 213{
417 ARMword pc = 0; 214 ARMword pc = 0;
418 215
419 state->Emulate = ONCE; 216 state->Emulate = ONCE;
420 217
421 /*ywc 2005-03-31 */
422 if (state->prog32Sig && ARMul_MODE32BIT) { 218 if (state->prog32Sig && ARMul_MODE32BIT) {
423#ifdef DBCT
424 if (skyeye_config.no_dbct) {
425 pc = ARMul_Emulate32 (state);
426 } else {
427//teawater add compile switch for DBCT GDB RSP function 2005.10.21--------------
428#ifndef DBCT_GDBRSP
429 printf("DBCT GDBRSP function switch is off.\n");
430 printf("To use this function, open \"#define DBCT_GDBRSP\" in arch/arm/common/armdefs.h & recompile skyeye.\n");
431 skyeye_exit(-1);
432#endif //DBCT_GDBRSP
433//AJ2D--------------------------------------------------------------------------
434 pc = ARMul_Emulate32_dbct (state);
435 }
436#else
437 pc = ARMul_Emulate32 (state); 219 pc = ARMul_Emulate32 (state);
438#endif
439 } 220 }
440 221
441 //else 222 return pc;
442 //pc = ARMul_Emulate26 (state);
443
444 return (pc);
445} 223}
446 224
447/***************************************************************************\ 225/***************************************************************************\
@@ -449,9 +227,7 @@ ARMul_DoInstr (ARMul_State * state)
449* mode, register bank, and the saving of registers. Call with the * 227* mode, register bank, and the saving of registers. Call with the *
450* appropriate vector's memory address (0,4,8 ....) * 228* appropriate vector's memory address (0,4,8 ....) *
451\***************************************************************************/ 229\***************************************************************************/
452 230void ARMul_Abort(ARMul_State* state, ARMword vector)
453void
454ARMul_Abort (ARMul_State * state, ARMword vector)
455{ 231{
456 ARMword temp; 232 ARMword temp;
457 int isize = INSN_SIZE; 233 int isize = INSN_SIZE;
@@ -494,21 +270,11 @@ ARMul_Abort (ARMul_State * state, ARMword vector)
494 SETABORT (IBIT, SVC26MODE, isize); 270 SETABORT (IBIT, SVC26MODE, isize);
495 break; 271 break;
496 case ARMul_IRQV: /* IRQ */ 272 case ARMul_IRQV: /* IRQ */
497 //chy 2003-09-02 the if sentence seems no use
498#if 0
499 if (!state->is_XScale || !state->CPRead[13] (state, 0, &temp)
500 || (temp & ARMul_CP13_R0_IRQ))
501#endif
502 SETABORT (IBIT, 273 SETABORT (IBIT,
503 state->prog32Sig ? IRQ32MODE : IRQ26MODE, 274 state->prog32Sig ? IRQ32MODE : IRQ26MODE,
504 esize); 275 esize);
505 break; 276 break;
506 case ARMul_FIQV: /* FIQ */ 277 case ARMul_FIQV: /* FIQ */
507 //chy 2003-09-02 the if sentence seems no use
508#if 0
509 if (!state->is_XScale || !state->CPRead[13] (state, 0, &temp)
510 || (temp & ARMul_CP13_R0_FIQ))
511#endif
512 SETABORT (INTBITS, 278 SETABORT (INTBITS,
513 state->prog32Sig ? FIQ32MODE : FIQ26MODE, 279 state->prog32Sig ? FIQ32MODE : FIQ26MODE,
514 esize); 280 esize);