Statistics
| Branch: | Revision:

root / target-ppc / translate_init.c @ ee4e83ed

History | View | Annotate | Download (257.3 kB)

1
/*
2
 *  PowerPC CPU initialization for qemu.
3
 *
4
 *  Copyright (c) 2003-2007 Jocelyn Mayer
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20

    
21
/* A lot of PowerPC definition have been included here.
22
 * Most of them are not usable for now but have been kept
23
 * inside "#if defined(TODO) ... #endif" statements to make tests easier.
24
 */
25

    
26
#include "dis-asm.h"
27
#include "host-utils.h"
28

    
29
//#define PPC_DUMP_CPU
30
//#define PPC_DEBUG_SPR
31
//#define PPC_DEBUG_IRQ
32

    
33
struct ppc_def_t {
34
    const unsigned char *name;
35
    uint32_t pvr;
36
    uint64_t insns_flags;
37
    uint64_t msr_mask;
38
    uint8_t mmu_model;
39
    uint8_t excp_model;
40
    uint8_t bus_model;
41
    uint8_t pad;
42
    uint32_t flags;
43
    int bfd_mach;
44
    void (*init_proc)(CPUPPCState *env);
45
    int (*check_pow)(CPUPPCState *env);
46
};
47

    
48
/* For user-mode emulation, we don't emulate any IRQ controller */
49
#if defined(CONFIG_USER_ONLY)
50
#define PPC_IRQ_INIT_FN(name)                                                 \
51
static inline void glue(glue(ppc, name),_irq_init) (CPUPPCState *env)         \
52
{                                                                             \
53
}
54
#else
55
#define PPC_IRQ_INIT_FN(name)                                                 \
56
void glue(glue(ppc, name),_irq_init) (CPUPPCState *env);
57
#endif
58

    
59
PPC_IRQ_INIT_FN(40x);
60
PPC_IRQ_INIT_FN(6xx);
61
PPC_IRQ_INIT_FN(970);
62

    
63
/* Generic callbacks:
64
 * do nothing but store/retrieve spr value
65
 */
66
#ifdef PPC_DUMP_SPR_ACCESSES
67
static void spr_read_generic (void *opaque, int sprn)
68
{
69
    gen_op_load_dump_spr(sprn);
70
}
71

    
72
static void spr_write_generic (void *opaque, int sprn)
73
{
74
    gen_op_store_dump_spr(sprn);
75
}
76
#else
77
static void spr_read_generic (void *opaque, int sprn)
78
{
79
    gen_op_load_spr(sprn);
80
}
81

    
82
static void spr_write_generic (void *opaque, int sprn)
83
{
84
    gen_op_store_spr(sprn);
85
}
86
#endif
87

    
88
#if !defined(CONFIG_USER_ONLY)
89
static void spr_write_clear (void *opaque, int sprn)
90
{
91
    gen_op_mask_spr(sprn);
92
}
93
#endif
94

    
95
/* SPR common to all PowerPC */
96
/* XER */
97
static void spr_read_xer (void *opaque, int sprn)
98
{
99
    gen_op_load_xer();
100
}
101

    
102
static void spr_write_xer (void *opaque, int sprn)
103
{
104
    gen_op_store_xer();
105
}
106

    
107
/* LR */
108
static void spr_read_lr (void *opaque, int sprn)
109
{
110
    gen_op_load_lr();
111
}
112

    
113
static void spr_write_lr (void *opaque, int sprn)
114
{
115
    gen_op_store_lr();
116
}
117

    
118
/* CTR */
119
static void spr_read_ctr (void *opaque, int sprn)
120
{
121
    gen_op_load_ctr();
122
}
123

    
124
static void spr_write_ctr (void *opaque, int sprn)
125
{
126
    gen_op_store_ctr();
127
}
128

    
129
/* User read access to SPR */
130
/* USPRx */
131
/* UMMCRx */
132
/* UPMCx */
133
/* USIA */
134
/* UDECR */
135
static void spr_read_ureg (void *opaque, int sprn)
136
{
137
    gen_op_load_spr(sprn + 0x10);
138
}
139

    
140
/* SPR common to all non-embedded PowerPC */
141
/* DECR */
142
#if !defined(CONFIG_USER_ONLY)
143
static void spr_read_decr (void *opaque, int sprn)
144
{
145
    gen_op_load_decr();
146
}
147

    
148
static void spr_write_decr (void *opaque, int sprn)
149
{
150
    gen_op_store_decr();
151
}
152
#endif
153

    
154
/* SPR common to all non-embedded PowerPC, except 601 */
155
/* Time base */
156
static void spr_read_tbl (void *opaque, int sprn)
157
{
158
    gen_op_load_tbl();
159
}
160

    
161
static void spr_read_tbu (void *opaque, int sprn)
162
{
163
    gen_op_load_tbu();
164
}
165

    
166
__attribute__ (( unused ))
167
static void spr_read_atbl (void *opaque, int sprn)
168
{
169
    gen_op_load_atbl();
170
}
171

    
172
__attribute__ (( unused ))
173
static void spr_read_atbu (void *opaque, int sprn)
174
{
175
    gen_op_load_atbu();
176
}
177

    
178
#if !defined(CONFIG_USER_ONLY)
179
static void spr_write_tbl (void *opaque, int sprn)
180
{
181
    gen_op_store_tbl();
182
}
183

    
184
static void spr_write_tbu (void *opaque, int sprn)
185
{
186
    gen_op_store_tbu();
187
}
188

    
189
__attribute__ (( unused ))
190
static void spr_write_atbl (void *opaque, int sprn)
191
{
192
    gen_op_store_atbl();
193
}
194

    
195
__attribute__ (( unused ))
196
static void spr_write_atbu (void *opaque, int sprn)
197
{
198
    gen_op_store_atbu();
199
}
200
#endif
201

    
202
#if !defined(CONFIG_USER_ONLY)
203
/* IBAT0U...IBAT0U */
204
/* IBAT0L...IBAT7L */
205
static void spr_read_ibat (void *opaque, int sprn)
206
{
207
    gen_op_load_ibat(sprn & 1, (sprn - SPR_IBAT0U) / 2);
208
}
209

    
210
static void spr_read_ibat_h (void *opaque, int sprn)
211
{
212
    gen_op_load_ibat(sprn & 1, (sprn - SPR_IBAT4U) / 2);
213
}
214

    
215
static void spr_write_ibatu (void *opaque, int sprn)
216
{
217
    gen_op_store_ibatu((sprn - SPR_IBAT0U) / 2);
218
}
219

    
220
static void spr_write_ibatu_h (void *opaque, int sprn)
221
{
222
    gen_op_store_ibatu((sprn - SPR_IBAT4U) / 2);
223
}
224

    
225
static void spr_write_ibatl (void *opaque, int sprn)
226
{
227
    gen_op_store_ibatl((sprn - SPR_IBAT0L) / 2);
228
}
229

    
230
static void spr_write_ibatl_h (void *opaque, int sprn)
231
{
232
    gen_op_store_ibatl((sprn - SPR_IBAT4L) / 2);
233
}
234

    
235
/* DBAT0U...DBAT7U */
236
/* DBAT0L...DBAT7L */
237
static void spr_read_dbat (void *opaque, int sprn)
238
{
239
    gen_op_load_dbat(sprn & 1, (sprn - SPR_DBAT0U) / 2);
240
}
241

    
242
static void spr_read_dbat_h (void *opaque, int sprn)
243
{
244
    gen_op_load_dbat(sprn & 1, ((sprn - SPR_DBAT4U) / 2) + 4);
245
}
246

    
247
static void spr_write_dbatu (void *opaque, int sprn)
248
{
249
    gen_op_store_dbatu((sprn - SPR_DBAT0U) / 2);
250
}
251

    
252
static void spr_write_dbatu_h (void *opaque, int sprn)
253
{
254
    gen_op_store_dbatu(((sprn - SPR_DBAT4U) / 2) + 4);
255
}
256

    
257
static void spr_write_dbatl (void *opaque, int sprn)
258
{
259
    gen_op_store_dbatl((sprn - SPR_DBAT0L) / 2);
260
}
261

    
262
static void spr_write_dbatl_h (void *opaque, int sprn)
263
{
264
    gen_op_store_dbatl(((sprn - SPR_DBAT4L) / 2) + 4);
265
}
266

    
267
/* SDR1 */
268
static void spr_read_sdr1 (void *opaque, int sprn)
269
{
270
    gen_op_load_sdr1();
271
}
272

    
273
static void spr_write_sdr1 (void *opaque, int sprn)
274
{
275
    gen_op_store_sdr1();
276
}
277

    
278
/* 64 bits PowerPC specific SPRs */
279
/* ASR */
280
#if defined(TARGET_PPC64)
281
__attribute__ (( unused ))
282
static void spr_read_asr (void *opaque, int sprn)
283
{
284
    gen_op_load_asr();
285
}
286

    
287
__attribute__ (( unused ))
288
static void spr_write_asr (void *opaque, int sprn)
289
{
290
    gen_op_store_asr();
291
}
292
#endif
293
#endif
294

    
295
/* PowerPC 601 specific registers */
296
/* RTC */
297
static void spr_read_601_rtcl (void *opaque, int sprn)
298
{
299
    gen_op_load_601_rtcl();
300
}
301

    
302
static void spr_read_601_rtcu (void *opaque, int sprn)
303
{
304
    gen_op_load_601_rtcu();
305
}
306

    
307
#if !defined(CONFIG_USER_ONLY)
308
static void spr_write_601_rtcu (void *opaque, int sprn)
309
{
310
    gen_op_store_601_rtcu();
311
}
312

    
313
static void spr_write_601_rtcl (void *opaque, int sprn)
314
{
315
    gen_op_store_601_rtcl();
316
}
317

    
318
static void spr_write_hid0_601 (void *opaque, int sprn)
319
{
320
    DisasContext *ctx = opaque;
321

    
322
    gen_op_store_hid0_601();
323
    /* Must stop the translation as endianness may have changed */
324
    GEN_STOP(ctx);
325
}
326
#endif
327

    
328
/* Unified bats */
329
#if !defined(CONFIG_USER_ONLY)
330
static void spr_read_601_ubat (void *opaque, int sprn)
331
{
332
    gen_op_load_601_bat(sprn & 1, (sprn - SPR_IBAT0U) / 2);
333
}
334

    
335
static void spr_write_601_ubatu (void *opaque, int sprn)
336
{
337
    gen_op_store_601_batu((sprn - SPR_IBAT0U) / 2);
338
}
339

    
340
static void spr_write_601_ubatl (void *opaque, int sprn)
341
{
342
    gen_op_store_601_batl((sprn - SPR_IBAT0L) / 2);
343
}
344
#endif
345

    
346
/* PowerPC 40x specific registers */
347
#if !defined(CONFIG_USER_ONLY)
348
static void spr_read_40x_pit (void *opaque, int sprn)
349
{
350
    gen_op_load_40x_pit();
351
}
352

    
353
static void spr_write_40x_pit (void *opaque, int sprn)
354
{
355
    gen_op_store_40x_pit();
356
}
357

    
358
static void spr_write_40x_dbcr0 (void *opaque, int sprn)
359
{
360
    DisasContext *ctx = opaque;
361

    
362
    gen_op_store_40x_dbcr0();
363
    /* We must stop translation as we may have rebooted */
364
    GEN_STOP(ctx);
365
}
366

    
367
static void spr_write_40x_sler (void *opaque, int sprn)
368
{
369
    gen_op_store_40x_sler();
370
}
371

    
372
static void spr_write_booke_tcr (void *opaque, int sprn)
373
{
374
    gen_op_store_booke_tcr();
375
}
376

    
377
static void spr_write_booke_tsr (void *opaque, int sprn)
378
{
379
    gen_op_store_booke_tsr();
380
}
381
#endif
382

    
383
/* PowerPC 403 specific registers */
384
/* PBL1 / PBU1 / PBL2 / PBU2 */
385
#if !defined(CONFIG_USER_ONLY)
386
static void spr_read_403_pbr (void *opaque, int sprn)
387
{
388
    gen_op_load_403_pb(sprn - SPR_403_PBL1);
389
}
390

    
391
static void spr_write_403_pbr (void *opaque, int sprn)
392
{
393
    gen_op_store_403_pb(sprn - SPR_403_PBL1);
394
}
395

    
396
static void spr_write_pir (void *opaque, int sprn)
397
{
398
    gen_op_store_pir();
399
}
400
#endif
401

    
402
#if !defined(CONFIG_USER_ONLY)
403
/* Callback used to write the exception vector base */
404
static void spr_write_excp_prefix (void *opaque, int sprn)
405
{
406
    gen_op_store_excp_prefix();
407
    gen_op_store_spr(sprn);
408
}
409

    
410
static void spr_write_excp_vector (void *opaque, int sprn)
411
{
412
    DisasContext *ctx = opaque;
413

    
414
    if (sprn >= SPR_BOOKE_IVOR0 && sprn <= SPR_BOOKE_IVOR15) {
415
        gen_op_store_excp_vector(sprn - SPR_BOOKE_IVOR0);
416
        gen_op_store_spr(sprn);
417
    } else if (sprn >= SPR_BOOKE_IVOR32 && sprn <= SPR_BOOKE_IVOR37) {
418
        gen_op_store_excp_vector(sprn - SPR_BOOKE_IVOR32 + 32);
419
        gen_op_store_spr(sprn);
420
    } else {
421
        printf("Trying to write an unknown exception vector %d %03x\n",
422
               sprn, sprn);
423
        GEN_EXCP_PRIVREG(ctx);
424
    }
425
}
426
#endif
427

    
428
#if defined(CONFIG_USER_ONLY)
429
#define spr_register(env, num, name, uea_read, uea_write,                     \
430
                     oea_read, oea_write, initial_value)                      \
431
do {                                                                          \
432
     _spr_register(env, num, name, uea_read, uea_write, initial_value);       \
433
} while (0)
434
static inline void _spr_register (CPUPPCState *env, int num,
435
                                  const unsigned char *name,
436
                                  void (*uea_read)(void *opaque, int sprn),
437
                                  void (*uea_write)(void *opaque, int sprn),
438
                                  target_ulong initial_value)
439
#else
440
static inline void spr_register (CPUPPCState *env, int num,
441
                                 const unsigned char *name,
442
                                 void (*uea_read)(void *opaque, int sprn),
443
                                 void (*uea_write)(void *opaque, int sprn),
444
                                 void (*oea_read)(void *opaque, int sprn),
445
                                 void (*oea_write)(void *opaque, int sprn),
446
                                 target_ulong initial_value)
447
#endif
448
{
449
    ppc_spr_t *spr;
450

    
451
    spr = &env->spr_cb[num];
452
    if (spr->name != NULL ||env-> spr[num] != 0x00000000 ||
453
#if !defined(CONFIG_USER_ONLY)
454
        spr->oea_read != NULL || spr->oea_write != NULL ||
455
#endif
456
        spr->uea_read != NULL || spr->uea_write != NULL) {
457
        printf("Error: Trying to register SPR %d (%03x) twice !\n", num, num);
458
        exit(1);
459
    }
460
#if defined(PPC_DEBUG_SPR)
461
    printf("*** register spr %d (%03x) %s val " ADDRX "\n", num, num, name,
462
           initial_value);
463
#endif
464
    spr->name = name;
465
    spr->uea_read = uea_read;
466
    spr->uea_write = uea_write;
467
#if !defined(CONFIG_USER_ONLY)
468
    spr->oea_read = oea_read;
469
    spr->oea_write = oea_write;
470
#endif
471
    env->spr[num] = initial_value;
472
}
473

    
474
/* Generic PowerPC SPRs */
475
static void gen_spr_generic (CPUPPCState *env)
476
{
477
    /* Integer processing */
478
    spr_register(env, SPR_XER, "XER",
479
                 &spr_read_xer, &spr_write_xer,
480
                 &spr_read_xer, &spr_write_xer,
481
                 0x00000000);
482
    /* Branch contol */
483
    spr_register(env, SPR_LR, "LR",
484
                 &spr_read_lr, &spr_write_lr,
485
                 &spr_read_lr, &spr_write_lr,
486
                 0x00000000);
487
    spr_register(env, SPR_CTR, "CTR",
488
                 &spr_read_ctr, &spr_write_ctr,
489
                 &spr_read_ctr, &spr_write_ctr,
490
                 0x00000000);
491
    /* Interrupt processing */
492
    spr_register(env, SPR_SRR0, "SRR0",
493
                 SPR_NOACCESS, SPR_NOACCESS,
494
                 &spr_read_generic, &spr_write_generic,
495
                 0x00000000);
496
    spr_register(env, SPR_SRR1, "SRR1",
497
                 SPR_NOACCESS, SPR_NOACCESS,
498
                 &spr_read_generic, &spr_write_generic,
499
                 0x00000000);
500
    /* Processor control */
501
    spr_register(env, SPR_SPRG0, "SPRG0",
502
                 SPR_NOACCESS, SPR_NOACCESS,
503
                 &spr_read_generic, &spr_write_generic,
504
                 0x00000000);
505
    spr_register(env, SPR_SPRG1, "SPRG1",
506
                 SPR_NOACCESS, SPR_NOACCESS,
507
                 &spr_read_generic, &spr_write_generic,
508
                 0x00000000);
509
    spr_register(env, SPR_SPRG2, "SPRG2",
510
                 SPR_NOACCESS, SPR_NOACCESS,
511
                 &spr_read_generic, &spr_write_generic,
512
                 0x00000000);
513
    spr_register(env, SPR_SPRG3, "SPRG3",
514
                 SPR_NOACCESS, SPR_NOACCESS,
515
                 &spr_read_generic, &spr_write_generic,
516
                 0x00000000);
517
}
518

    
519
/* SPR common to all non-embedded PowerPC, including 601 */
520
static void gen_spr_ne_601 (CPUPPCState *env)
521
{
522
    /* Exception processing */
523
    spr_register(env, SPR_DSISR, "DSISR",
524
                 SPR_NOACCESS, SPR_NOACCESS,
525
                 &spr_read_generic, &spr_write_generic,
526
                 0x00000000);
527
    spr_register(env, SPR_DAR, "DAR",
528
                 SPR_NOACCESS, SPR_NOACCESS,
529
                 &spr_read_generic, &spr_write_generic,
530
                 0x00000000);
531
    /* Timer */
532
    spr_register(env, SPR_DECR, "DECR",
533
                 SPR_NOACCESS, SPR_NOACCESS,
534
                 &spr_read_decr, &spr_write_decr,
535
                 0x00000000);
536
    /* Memory management */
537
    spr_register(env, SPR_SDR1, "SDR1",
538
                 SPR_NOACCESS, SPR_NOACCESS,
539
                 &spr_read_sdr1, &spr_write_sdr1,
540
                 0x00000000);
541
}
542

    
543
/* BATs 0-3 */
544
static void gen_low_BATs (CPUPPCState *env)
545
{
546
#if !defined(CONFIG_USER_ONLY)
547
    spr_register(env, SPR_IBAT0U, "IBAT0U",
548
                 SPR_NOACCESS, SPR_NOACCESS,
549
                 &spr_read_ibat, &spr_write_ibatu,
550
                 0x00000000);
551
    spr_register(env, SPR_IBAT0L, "IBAT0L",
552
                 SPR_NOACCESS, SPR_NOACCESS,
553
                 &spr_read_ibat, &spr_write_ibatl,
554
                 0x00000000);
555
    spr_register(env, SPR_IBAT1U, "IBAT1U",
556
                 SPR_NOACCESS, SPR_NOACCESS,
557
                 &spr_read_ibat, &spr_write_ibatu,
558
                 0x00000000);
559
    spr_register(env, SPR_IBAT1L, "IBAT1L",
560
                 SPR_NOACCESS, SPR_NOACCESS,
561
                 &spr_read_ibat, &spr_write_ibatl,
562
                 0x00000000);
563
    spr_register(env, SPR_IBAT2U, "IBAT2U",
564
                 SPR_NOACCESS, SPR_NOACCESS,
565
                 &spr_read_ibat, &spr_write_ibatu,
566
                 0x00000000);
567
    spr_register(env, SPR_IBAT2L, "IBAT2L",
568
                 SPR_NOACCESS, SPR_NOACCESS,
569
                 &spr_read_ibat, &spr_write_ibatl,
570
                 0x00000000);
571
    spr_register(env, SPR_IBAT3U, "IBAT3U",
572
                 SPR_NOACCESS, SPR_NOACCESS,
573
                 &spr_read_ibat, &spr_write_ibatu,
574
                 0x00000000);
575
    spr_register(env, SPR_IBAT3L, "IBAT3L",
576
                 SPR_NOACCESS, SPR_NOACCESS,
577
                 &spr_read_ibat, &spr_write_ibatl,
578
                 0x00000000);
579
    spr_register(env, SPR_DBAT0U, "DBAT0U",
580
                 SPR_NOACCESS, SPR_NOACCESS,
581
                 &spr_read_dbat, &spr_write_dbatu,
582
                 0x00000000);
583
    spr_register(env, SPR_DBAT0L, "DBAT0L",
584
                 SPR_NOACCESS, SPR_NOACCESS,
585
                 &spr_read_dbat, &spr_write_dbatl,
586
                 0x00000000);
587
    spr_register(env, SPR_DBAT1U, "DBAT1U",
588
                 SPR_NOACCESS, SPR_NOACCESS,
589
                 &spr_read_dbat, &spr_write_dbatu,
590
                 0x00000000);
591
    spr_register(env, SPR_DBAT1L, "DBAT1L",
592
                 SPR_NOACCESS, SPR_NOACCESS,
593
                 &spr_read_dbat, &spr_write_dbatl,
594
                 0x00000000);
595
    spr_register(env, SPR_DBAT2U, "DBAT2U",
596
                 SPR_NOACCESS, SPR_NOACCESS,
597
                 &spr_read_dbat, &spr_write_dbatu,
598
                 0x00000000);
599
    spr_register(env, SPR_DBAT2L, "DBAT2L",
600
                 SPR_NOACCESS, SPR_NOACCESS,
601
                 &spr_read_dbat, &spr_write_dbatl,
602
                 0x00000000);
603
    spr_register(env, SPR_DBAT3U, "DBAT3U",
604
                 SPR_NOACCESS, SPR_NOACCESS,
605
                 &spr_read_dbat, &spr_write_dbatu,
606
                 0x00000000);
607
    spr_register(env, SPR_DBAT3L, "DBAT3L",
608
                 SPR_NOACCESS, SPR_NOACCESS,
609
                 &spr_read_dbat, &spr_write_dbatl,
610
                 0x00000000);
611
    env->nb_BATs += 4;
612
#endif
613
}
614

    
615
/* BATs 4-7 */
616
static void gen_high_BATs (CPUPPCState *env)
617
{
618
#if !defined(CONFIG_USER_ONLY)
619
    spr_register(env, SPR_IBAT4U, "IBAT4U",
620
                 SPR_NOACCESS, SPR_NOACCESS,
621
                 &spr_read_ibat_h, &spr_write_ibatu_h,
622
                 0x00000000);
623
    spr_register(env, SPR_IBAT4L, "IBAT4L",
624
                 SPR_NOACCESS, SPR_NOACCESS,
625
                 &spr_read_ibat_h, &spr_write_ibatl_h,
626
                 0x00000000);
627
    spr_register(env, SPR_IBAT5U, "IBAT5U",
628
                 SPR_NOACCESS, SPR_NOACCESS,
629
                 &spr_read_ibat_h, &spr_write_ibatu_h,
630
                 0x00000000);
631
    spr_register(env, SPR_IBAT5L, "IBAT5L",
632
                 SPR_NOACCESS, SPR_NOACCESS,
633
                 &spr_read_ibat_h, &spr_write_ibatl_h,
634
                 0x00000000);
635
    spr_register(env, SPR_IBAT6U, "IBAT6U",
636
                 SPR_NOACCESS, SPR_NOACCESS,
637
                 &spr_read_ibat_h, &spr_write_ibatu_h,
638
                 0x00000000);
639
    spr_register(env, SPR_IBAT6L, "IBAT6L",
640
                 SPR_NOACCESS, SPR_NOACCESS,
641
                 &spr_read_ibat_h, &spr_write_ibatl_h,
642
                 0x00000000);
643
    spr_register(env, SPR_IBAT7U, "IBAT7U",
644
                 SPR_NOACCESS, SPR_NOACCESS,
645
                 &spr_read_ibat_h, &spr_write_ibatu_h,
646
                 0x00000000);
647
    spr_register(env, SPR_IBAT7L, "IBAT7L",
648
                 SPR_NOACCESS, SPR_NOACCESS,
649
                 &spr_read_ibat_h, &spr_write_ibatl_h,
650
                 0x00000000);
651
    spr_register(env, SPR_DBAT4U, "DBAT4U",
652
                 SPR_NOACCESS, SPR_NOACCESS,
653
                 &spr_read_dbat_h, &spr_write_dbatu_h,
654
                 0x00000000);
655
    spr_register(env, SPR_DBAT4L, "DBAT4L",
656
                 SPR_NOACCESS, SPR_NOACCESS,
657
                 &spr_read_dbat_h, &spr_write_dbatl_h,
658
                 0x00000000);
659
    spr_register(env, SPR_DBAT5U, "DBAT5U",
660
                 SPR_NOACCESS, SPR_NOACCESS,
661
                 &spr_read_dbat_h, &spr_write_dbatu_h,
662
                 0x00000000);
663
    spr_register(env, SPR_DBAT5L, "DBAT5L",
664
                 SPR_NOACCESS, SPR_NOACCESS,
665
                 &spr_read_dbat_h, &spr_write_dbatl_h,
666
                 0x00000000);
667
    spr_register(env, SPR_DBAT6U, "DBAT6U",
668
                 SPR_NOACCESS, SPR_NOACCESS,
669
                 &spr_read_dbat_h, &spr_write_dbatu_h,
670
                 0x00000000);
671
    spr_register(env, SPR_DBAT6L, "DBAT6L",
672
                 SPR_NOACCESS, SPR_NOACCESS,
673
                 &spr_read_dbat_h, &spr_write_dbatl_h,
674
                 0x00000000);
675
    spr_register(env, SPR_DBAT7U, "DBAT7U",
676
                 SPR_NOACCESS, SPR_NOACCESS,
677
                 &spr_read_dbat_h, &spr_write_dbatu_h,
678
                 0x00000000);
679
    spr_register(env, SPR_DBAT7L, "DBAT7L",
680
                 SPR_NOACCESS, SPR_NOACCESS,
681
                 &spr_read_dbat_h, &spr_write_dbatl_h,
682
                 0x00000000);
683
    env->nb_BATs += 4;
684
#endif
685
}
686

    
687
/* Generic PowerPC time base */
688
static void gen_tbl (CPUPPCState *env)
689
{
690
    spr_register(env, SPR_VTBL,  "TBL",
691
                 &spr_read_tbl, SPR_NOACCESS,
692
                 &spr_read_tbl, SPR_NOACCESS,
693
                 0x00000000);
694
    spr_register(env, SPR_TBL,   "TBL",
695
                 SPR_NOACCESS, SPR_NOACCESS,
696
                 SPR_NOACCESS, &spr_write_tbl,
697
                 0x00000000);
698
    spr_register(env, SPR_VTBU,  "TBU",
699
                 &spr_read_tbu, SPR_NOACCESS,
700
                 &spr_read_tbu, SPR_NOACCESS,
701
                 0x00000000);
702
    spr_register(env, SPR_TBU,   "TBU",
703
                 SPR_NOACCESS, SPR_NOACCESS,
704
                 SPR_NOACCESS, &spr_write_tbu,
705
                 0x00000000);
706
}
707

    
708
/* Softare table search registers */
709
static void gen_6xx_7xx_soft_tlb (CPUPPCState *env, int nb_tlbs, int nb_ways)
710
{
711
#if !defined(CONFIG_USER_ONLY)
712
    env->nb_tlb = nb_tlbs;
713
    env->nb_ways = nb_ways;
714
    env->id_tlbs = 1;
715
    spr_register(env, SPR_DMISS, "DMISS",
716
                 SPR_NOACCESS, SPR_NOACCESS,
717
                 &spr_read_generic, SPR_NOACCESS,
718
                 0x00000000);
719
    spr_register(env, SPR_DCMP, "DCMP",
720
                 SPR_NOACCESS, SPR_NOACCESS,
721
                 &spr_read_generic, SPR_NOACCESS,
722
                 0x00000000);
723
    spr_register(env, SPR_HASH1, "HASH1",
724
                 SPR_NOACCESS, SPR_NOACCESS,
725
                 &spr_read_generic, SPR_NOACCESS,
726
                 0x00000000);
727
    spr_register(env, SPR_HASH2, "HASH2",
728
                 SPR_NOACCESS, SPR_NOACCESS,
729
                 &spr_read_generic, SPR_NOACCESS,
730
                 0x00000000);
731
    spr_register(env, SPR_IMISS, "IMISS",
732
                 SPR_NOACCESS, SPR_NOACCESS,
733
                 &spr_read_generic, SPR_NOACCESS,
734
                 0x00000000);
735
    spr_register(env, SPR_ICMP, "ICMP",
736
                 SPR_NOACCESS, SPR_NOACCESS,
737
                 &spr_read_generic, SPR_NOACCESS,
738
                 0x00000000);
739
    spr_register(env, SPR_RPA, "RPA",
740
                 SPR_NOACCESS, SPR_NOACCESS,
741
                 &spr_read_generic, &spr_write_generic,
742
                 0x00000000);
743
#endif
744
}
745

    
746
/* SPR common to MPC755 and G2 */
747
static void gen_spr_G2_755 (CPUPPCState *env)
748
{
749
    /* SGPRs */
750
    spr_register(env, SPR_SPRG4, "SPRG4",
751
                 SPR_NOACCESS, SPR_NOACCESS,
752
                 &spr_read_generic, &spr_write_generic,
753
                 0x00000000);
754
    spr_register(env, SPR_SPRG5, "SPRG5",
755
                 SPR_NOACCESS, SPR_NOACCESS,
756
                 &spr_read_generic, &spr_write_generic,
757
                 0x00000000);
758
    spr_register(env, SPR_SPRG6, "SPRG6",
759
                 SPR_NOACCESS, SPR_NOACCESS,
760
                 &spr_read_generic, &spr_write_generic,
761
                 0x00000000);
762
    spr_register(env, SPR_SPRG7, "SPRG7",
763
                 SPR_NOACCESS, SPR_NOACCESS,
764
                 &spr_read_generic, &spr_write_generic,
765
                 0x00000000);
766
    /* External access control */
767
    /* XXX : not implemented */
768
    spr_register(env, SPR_EAR, "EAR",
769
                 SPR_NOACCESS, SPR_NOACCESS,
770
                 &spr_read_generic, &spr_write_generic,
771
                 0x00000000);
772
}
773

    
774
/* SPR common to all 7xx PowerPC implementations */
775
static void gen_spr_7xx (CPUPPCState *env)
776
{
777
    /* Breakpoints */
778
    /* XXX : not implemented */
779
    spr_register(env, SPR_DABR, "DABR",
780
                 SPR_NOACCESS, SPR_NOACCESS,
781
                 &spr_read_generic, &spr_write_generic,
782
                 0x00000000);
783
    /* XXX : not implemented */
784
    spr_register(env, SPR_IABR, "IABR",
785
                 SPR_NOACCESS, SPR_NOACCESS,
786
                 &spr_read_generic, &spr_write_generic,
787
                 0x00000000);
788
    /* Cache management */
789
    /* XXX : not implemented */
790
    spr_register(env, SPR_ICTC, "ICTC",
791
                 SPR_NOACCESS, SPR_NOACCESS,
792
                 &spr_read_generic, &spr_write_generic,
793
                 0x00000000);
794
    /* XXX : not implemented */
795
    spr_register(env, SPR_L2CR, "L2CR",
796
                 SPR_NOACCESS, SPR_NOACCESS,
797
                 &spr_read_generic, &spr_write_generic,
798
                 0x00000000);
799
    /* Performance monitors */
800
    /* XXX : not implemented */
801
    spr_register(env, SPR_MMCR0, "MMCR0",
802
                 SPR_NOACCESS, SPR_NOACCESS,
803
                 &spr_read_generic, &spr_write_generic,
804
                 0x00000000);
805
    /* XXX : not implemented */
806
    spr_register(env, SPR_MMCR1, "MMCR1",
807
                 SPR_NOACCESS, SPR_NOACCESS,
808
                 &spr_read_generic, &spr_write_generic,
809
                 0x00000000);
810
    /* XXX : not implemented */
811
    spr_register(env, SPR_PMC1, "PMC1",
812
                 SPR_NOACCESS, SPR_NOACCESS,
813
                 &spr_read_generic, &spr_write_generic,
814
                 0x00000000);
815
    /* XXX : not implemented */
816
    spr_register(env, SPR_PMC2, "PMC2",
817
                 SPR_NOACCESS, SPR_NOACCESS,
818
                 &spr_read_generic, &spr_write_generic,
819
                 0x00000000);
820
    /* XXX : not implemented */
821
    spr_register(env, SPR_PMC3, "PMC3",
822
                 SPR_NOACCESS, SPR_NOACCESS,
823
                 &spr_read_generic, &spr_write_generic,
824
                 0x00000000);
825
    /* XXX : not implemented */
826
    spr_register(env, SPR_PMC4, "PMC4",
827
                 SPR_NOACCESS, SPR_NOACCESS,
828
                 &spr_read_generic, &spr_write_generic,
829
                 0x00000000);
830
    /* XXX : not implemented */
831
    spr_register(env, SPR_SIAR, "SIAR",
832
                 SPR_NOACCESS, SPR_NOACCESS,
833
                 &spr_read_generic, SPR_NOACCESS,
834
                 0x00000000);
835
    /* XXX : not implemented */
836
    spr_register(env, SPR_UMMCR0, "UMMCR0",
837
                 &spr_read_ureg, SPR_NOACCESS,
838
                 &spr_read_ureg, SPR_NOACCESS,
839
                 0x00000000);
840
    /* XXX : not implemented */
841
    spr_register(env, SPR_UMMCR1, "UMMCR1",
842
                 &spr_read_ureg, SPR_NOACCESS,
843
                 &spr_read_ureg, SPR_NOACCESS,
844
                 0x00000000);
845
    /* XXX : not implemented */
846
    spr_register(env, SPR_UPMC1, "UPMC1",
847
                 &spr_read_ureg, SPR_NOACCESS,
848
                 &spr_read_ureg, SPR_NOACCESS,
849
                 0x00000000);
850
    /* XXX : not implemented */
851
    spr_register(env, SPR_UPMC2, "UPMC2",
852
                 &spr_read_ureg, SPR_NOACCESS,
853
                 &spr_read_ureg, SPR_NOACCESS,
854
                 0x00000000);
855
    /* XXX : not implemented */
856
    spr_register(env, SPR_UPMC3, "UPMC3",
857
                 &spr_read_ureg, SPR_NOACCESS,
858
                 &spr_read_ureg, SPR_NOACCESS,
859
                 0x00000000);
860
    /* XXX : not implemented */
861
    spr_register(env, SPR_UPMC4, "UPMC4",
862
                 &spr_read_ureg, SPR_NOACCESS,
863
                 &spr_read_ureg, SPR_NOACCESS,
864
                 0x00000000);
865
    /* XXX : not implemented */
866
    spr_register(env, SPR_USIAR, "USIAR",
867
                 &spr_read_ureg, SPR_NOACCESS,
868
                 &spr_read_ureg, SPR_NOACCESS,
869
                 0x00000000);
870
    /* External access control */
871
    /* XXX : not implemented */
872
    spr_register(env, SPR_EAR, "EAR",
873
                 SPR_NOACCESS, SPR_NOACCESS,
874
                 &spr_read_generic, &spr_write_generic,
875
                 0x00000000);
876
}
877

    
878
static void gen_spr_thrm (CPUPPCState *env)
879
{
880
    /* Thermal management */
881
    /* XXX : not implemented */
882
    spr_register(env, SPR_THRM1, "THRM1",
883
                 SPR_NOACCESS, SPR_NOACCESS,
884
                 &spr_read_generic, &spr_write_generic,
885
                 0x00000000);
886
    /* XXX : not implemented */
887
    spr_register(env, SPR_THRM2, "THRM2",
888
                 SPR_NOACCESS, SPR_NOACCESS,
889
                 &spr_read_generic, &spr_write_generic,
890
                 0x00000000);
891
    /* XXX : not implemented */
892
    spr_register(env, SPR_THRM3, "THRM3",
893
                 SPR_NOACCESS, SPR_NOACCESS,
894
                 &spr_read_generic, &spr_write_generic,
895
                 0x00000000);
896
}
897

    
898
/* SPR specific to PowerPC 604 implementation */
899
static void gen_spr_604 (CPUPPCState *env)
900
{
901
    /* Processor identification */
902
    spr_register(env, SPR_PIR, "PIR",
903
                 SPR_NOACCESS, SPR_NOACCESS,
904
                 &spr_read_generic, &spr_write_pir,
905
                 0x00000000);
906
    /* Breakpoints */
907
    /* XXX : not implemented */
908
    spr_register(env, SPR_IABR, "IABR",
909
                 SPR_NOACCESS, SPR_NOACCESS,
910
                 &spr_read_generic, &spr_write_generic,
911
                 0x00000000);
912
    /* XXX : not implemented */
913
    spr_register(env, SPR_DABR, "DABR",
914
                 SPR_NOACCESS, SPR_NOACCESS,
915
                 &spr_read_generic, &spr_write_generic,
916
                 0x00000000);
917
    /* Performance counters */
918
    /* XXX : not implemented */
919
    spr_register(env, SPR_MMCR0, "MMCR0",
920
                 SPR_NOACCESS, SPR_NOACCESS,
921
                 &spr_read_generic, &spr_write_generic,
922
                 0x00000000);
923
    /* XXX : not implemented */
924
    spr_register(env, SPR_MMCR1, "MMCR1",
925
                 SPR_NOACCESS, SPR_NOACCESS,
926
                 &spr_read_generic, &spr_write_generic,
927
                 0x00000000);
928
    /* XXX : not implemented */
929
    spr_register(env, SPR_PMC1, "PMC1",
930
                 SPR_NOACCESS, SPR_NOACCESS,
931
                 &spr_read_generic, &spr_write_generic,
932
                 0x00000000);
933
    /* XXX : not implemented */
934
    spr_register(env, SPR_PMC2, "PMC2",
935
                 SPR_NOACCESS, SPR_NOACCESS,
936
                 &spr_read_generic, &spr_write_generic,
937
                 0x00000000);
938
    /* XXX : not implemented */
939
    spr_register(env, SPR_PMC3, "PMC3",
940
                 SPR_NOACCESS, SPR_NOACCESS,
941
                 &spr_read_generic, &spr_write_generic,
942
                 0x00000000);
943
    /* XXX : not implemented */
944
    spr_register(env, SPR_PMC4, "PMC4",
945
                 SPR_NOACCESS, SPR_NOACCESS,
946
                 &spr_read_generic, &spr_write_generic,
947
                 0x00000000);
948
    /* XXX : not implemented */
949
    spr_register(env, SPR_SIAR, "SIAR",
950
                 SPR_NOACCESS, SPR_NOACCESS,
951
                 &spr_read_generic, SPR_NOACCESS,
952
                 0x00000000);
953
    /* XXX : not implemented */
954
    spr_register(env, SPR_SDA, "SDA",
955
                 SPR_NOACCESS, SPR_NOACCESS,
956
                 &spr_read_generic, SPR_NOACCESS,
957
                 0x00000000);
958
    /* External access control */
959
    /* XXX : not implemented */
960
    spr_register(env, SPR_EAR, "EAR",
961
                 SPR_NOACCESS, SPR_NOACCESS,
962
                 &spr_read_generic, &spr_write_generic,
963
                 0x00000000);
964
}
965

    
966
/* SPR specific to PowerPC 603 implementation */
967
static void gen_spr_603 (CPUPPCState *env)
968
{
969
    /* External access control */
970
    /* XXX : not implemented */
971
    spr_register(env, SPR_EAR, "EAR",
972
                 SPR_NOACCESS, SPR_NOACCESS,
973
                 &spr_read_generic, &spr_write_generic,
974
                 0x00000000);
975
}
976

    
977
/* SPR specific to PowerPC G2 implementation */
978
static void gen_spr_G2 (CPUPPCState *env)
979
{
980
    /* Memory base address */
981
    /* MBAR */
982
    /* XXX : not implemented */
983
    spr_register(env, SPR_MBAR, "MBAR",
984
                 SPR_NOACCESS, SPR_NOACCESS,
985
                 &spr_read_generic, &spr_write_generic,
986
                 0x00000000);
987
    /* System version register */
988
    /* SVR */
989
    /* XXX : TODO: initialize it to an appropriate value */
990
    spr_register(env, SPR_SVR, "SVR",
991
                 SPR_NOACCESS, SPR_NOACCESS,
992
                 &spr_read_generic, SPR_NOACCESS,
993
                 0x00000000);
994
    /* Exception processing */
995
    spr_register(env, SPR_BOOKE_CSRR0, "CSRR0",
996
                 SPR_NOACCESS, SPR_NOACCESS,
997
                 &spr_read_generic, &spr_write_generic,
998
                 0x00000000);
999
    spr_register(env, SPR_BOOKE_CSRR1, "CSRR1",
1000
                 SPR_NOACCESS, SPR_NOACCESS,
1001
                 &spr_read_generic, &spr_write_generic,
1002
                 0x00000000);
1003
    /* Breakpoints */
1004
    /* XXX : not implemented */
1005
    spr_register(env, SPR_DABR, "DABR",
1006
                 SPR_NOACCESS, SPR_NOACCESS,
1007
                 &spr_read_generic, &spr_write_generic,
1008
                 0x00000000);
1009
    /* XXX : not implemented */
1010
    spr_register(env, SPR_DABR2, "DABR2",
1011
                 SPR_NOACCESS, SPR_NOACCESS,
1012
                 &spr_read_generic, &spr_write_generic,
1013
                 0x00000000);
1014
    /* XXX : not implemented */
1015
    spr_register(env, SPR_IABR, "IABR",
1016
                 SPR_NOACCESS, SPR_NOACCESS,
1017
                 &spr_read_generic, &spr_write_generic,
1018
                 0x00000000);
1019
    /* XXX : not implemented */
1020
    spr_register(env, SPR_IABR2, "IABR2",
1021
                 SPR_NOACCESS, SPR_NOACCESS,
1022
                 &spr_read_generic, &spr_write_generic,
1023
                 0x00000000);
1024
    /* XXX : not implemented */
1025
    spr_register(env, SPR_IBCR, "IBCR",
1026
                 SPR_NOACCESS, SPR_NOACCESS,
1027
                 &spr_read_generic, &spr_write_generic,
1028
                 0x00000000);
1029
    /* XXX : not implemented */
1030
    spr_register(env, SPR_DBCR, "DBCR",
1031
                 SPR_NOACCESS, SPR_NOACCESS,
1032
                 &spr_read_generic, &spr_write_generic,
1033
                 0x00000000);
1034
}
1035

    
1036
/* SPR specific to PowerPC 602 implementation */
1037
static void gen_spr_602 (CPUPPCState *env)
1038
{
1039
    /* ESA registers */
1040
    /* XXX : not implemented */
1041
    spr_register(env, SPR_SER, "SER",
1042
                 SPR_NOACCESS, SPR_NOACCESS,
1043
                 &spr_read_generic, &spr_write_generic,
1044
                 0x00000000);
1045
    /* XXX : not implemented */
1046
    spr_register(env, SPR_SEBR, "SEBR",
1047
                 SPR_NOACCESS, SPR_NOACCESS,
1048
                 &spr_read_generic, &spr_write_generic,
1049
                 0x00000000);
1050
    /* XXX : not implemented */
1051
    spr_register(env, SPR_ESASRR, "ESASRR",
1052
                 SPR_NOACCESS, SPR_NOACCESS,
1053
                 &spr_read_generic, &spr_write_generic,
1054
                 0x00000000);
1055
    /* Floating point status */
1056
    /* XXX : not implemented */
1057
    spr_register(env, SPR_SP, "SP",
1058
                 SPR_NOACCESS, SPR_NOACCESS,
1059
                 &spr_read_generic, &spr_write_generic,
1060
                 0x00000000);
1061
    /* XXX : not implemented */
1062
    spr_register(env, SPR_LT, "LT",
1063
                 SPR_NOACCESS, SPR_NOACCESS,
1064
                 &spr_read_generic, &spr_write_generic,
1065
                 0x00000000);
1066
    /* Watchdog timer */
1067
    /* XXX : not implemented */
1068
    spr_register(env, SPR_TCR, "TCR",
1069
                 SPR_NOACCESS, SPR_NOACCESS,
1070
                 &spr_read_generic, &spr_write_generic,
1071
                 0x00000000);
1072
    /* Interrupt base */
1073
    spr_register(env, SPR_IBR, "IBR",
1074
                 SPR_NOACCESS, SPR_NOACCESS,
1075
                 &spr_read_generic, &spr_write_generic,
1076
                 0x00000000);
1077
    /* XXX : not implemented */
1078
    spr_register(env, SPR_IABR, "IABR",
1079
                 SPR_NOACCESS, SPR_NOACCESS,
1080
                 &spr_read_generic, &spr_write_generic,
1081
                 0x00000000);
1082
}
1083

    
1084
/* SPR specific to PowerPC 601 implementation */
1085
static void gen_spr_601 (CPUPPCState *env)
1086
{
1087
    /* Multiplication/division register */
1088
    /* MQ */
1089
    spr_register(env, SPR_MQ, "MQ",
1090
                 &spr_read_generic, &spr_write_generic,
1091
                 &spr_read_generic, &spr_write_generic,
1092
                 0x00000000);
1093
    /* RTC registers */
1094
    spr_register(env, SPR_601_RTCU, "RTCU",
1095
                 SPR_NOACCESS, SPR_NOACCESS,
1096
                 SPR_NOACCESS, &spr_write_601_rtcu,
1097
                 0x00000000);
1098
    spr_register(env, SPR_601_VRTCU, "RTCU",
1099
                 &spr_read_601_rtcu, SPR_NOACCESS,
1100
                 &spr_read_601_rtcu, SPR_NOACCESS,
1101
                 0x00000000);
1102
    spr_register(env, SPR_601_RTCL, "RTCL",
1103
                 SPR_NOACCESS, SPR_NOACCESS,
1104
                 SPR_NOACCESS, &spr_write_601_rtcl,
1105
                 0x00000000);
1106
    spr_register(env, SPR_601_VRTCL, "RTCL",
1107
                 &spr_read_601_rtcl, SPR_NOACCESS,
1108
                 &spr_read_601_rtcl, SPR_NOACCESS,
1109
                 0x00000000);
1110
    /* Timer */
1111
#if 0 /* ? */
1112
    spr_register(env, SPR_601_UDECR, "UDECR",
1113
                 &spr_read_decr, SPR_NOACCESS,
1114
                 &spr_read_decr, SPR_NOACCESS,
1115
                 0x00000000);
1116
#endif
1117
    /* External access control */
1118
    /* XXX : not implemented */
1119
    spr_register(env, SPR_EAR, "EAR",
1120
                 SPR_NOACCESS, SPR_NOACCESS,
1121
                 &spr_read_generic, &spr_write_generic,
1122
                 0x00000000);
1123
    /* Memory management */
1124
#if !defined(CONFIG_USER_ONLY)
1125
    spr_register(env, SPR_IBAT0U, "IBAT0U",
1126
                 SPR_NOACCESS, SPR_NOACCESS,
1127
                 &spr_read_601_ubat, &spr_write_601_ubatu,
1128
                 0x00000000);
1129
    spr_register(env, SPR_IBAT0L, "IBAT0L",
1130
                 SPR_NOACCESS, SPR_NOACCESS,
1131
                 &spr_read_601_ubat, &spr_write_601_ubatl,
1132
                 0x00000000);
1133
    spr_register(env, SPR_IBAT1U, "IBAT1U",
1134
                 SPR_NOACCESS, SPR_NOACCESS,
1135
                 &spr_read_601_ubat, &spr_write_601_ubatu,
1136
                 0x00000000);
1137
    spr_register(env, SPR_IBAT1L, "IBAT1L",
1138
                 SPR_NOACCESS, SPR_NOACCESS,
1139
                 &spr_read_601_ubat, &spr_write_601_ubatl,
1140
                 0x00000000);
1141
    spr_register(env, SPR_IBAT2U, "IBAT2U",
1142
                 SPR_NOACCESS, SPR_NOACCESS,
1143
                 &spr_read_601_ubat, &spr_write_601_ubatu,
1144
                 0x00000000);
1145
    spr_register(env, SPR_IBAT2L, "IBAT2L",
1146
                 SPR_NOACCESS, SPR_NOACCESS,
1147
                 &spr_read_601_ubat, &spr_write_601_ubatl,
1148
                 0x00000000);
1149
    spr_register(env, SPR_IBAT3U, "IBAT3U",
1150
                 SPR_NOACCESS, SPR_NOACCESS,
1151
                 &spr_read_601_ubat, &spr_write_601_ubatu,
1152
                 0x00000000);
1153
    spr_register(env, SPR_IBAT3L, "IBAT3L",
1154
                 SPR_NOACCESS, SPR_NOACCESS,
1155
                 &spr_read_601_ubat, &spr_write_601_ubatl,
1156
                 0x00000000);
1157
    env->nb_BATs = 4;
1158
#endif
1159
}
1160

    
1161
static void gen_spr_74xx (CPUPPCState *env)
1162
{
1163
    /* Processor identification */
1164
    spr_register(env, SPR_PIR, "PIR",
1165
                 SPR_NOACCESS, SPR_NOACCESS,
1166
                 &spr_read_generic, &spr_write_pir,
1167
                 0x00000000);
1168
    /* XXX : not implemented */
1169
    spr_register(env, SPR_MMCR2, "MMCR2",
1170
                 SPR_NOACCESS, SPR_NOACCESS,
1171
                 &spr_read_generic, &spr_write_generic,
1172
                 0x00000000);
1173
    /* XXX : not implemented */
1174
    spr_register(env, SPR_UMMCR2, "UMMCR2",
1175
                 &spr_read_ureg, SPR_NOACCESS,
1176
                 &spr_read_ureg, SPR_NOACCESS,
1177
                 0x00000000);
1178
    /* XXX: not implemented */
1179
    spr_register(env, SPR_BAMR, "BAMR",
1180
                 SPR_NOACCESS, SPR_NOACCESS,
1181
                 &spr_read_generic, &spr_write_generic,
1182
                 0x00000000);
1183
    /* XXX : not implemented */
1184
    spr_register(env, SPR_UBAMR, "UBAMR",
1185
                 &spr_read_ureg, SPR_NOACCESS,
1186
                 &spr_read_ureg, SPR_NOACCESS,
1187
                 0x00000000);
1188
    /* XXX : not implemented */
1189
    spr_register(env, SPR_MSSCR0, "MSSCR0",
1190
                 SPR_NOACCESS, SPR_NOACCESS,
1191
                 &spr_read_generic, &spr_write_generic,
1192
                 0x00000000);
1193
    /* Hardware implementation registers */
1194
    /* XXX : not implemented */
1195
    spr_register(env, SPR_HID0, "HID0",
1196
                 SPR_NOACCESS, SPR_NOACCESS,
1197
                 &spr_read_generic, &spr_write_generic,
1198
                 0x00000000);
1199
    /* XXX : not implemented */
1200
    spr_register(env, SPR_HID1, "HID1",
1201
                 SPR_NOACCESS, SPR_NOACCESS,
1202
                 &spr_read_generic, &spr_write_generic,
1203
                 0x00000000);
1204
    /* Altivec */
1205
    spr_register(env, SPR_VRSAVE, "VRSAVE",
1206
                 &spr_read_generic, &spr_write_generic,
1207
                 &spr_read_generic, &spr_write_generic,
1208
                 0x00000000);
1209
}
1210

    
1211
static void gen_l3_ctrl (CPUPPCState *env)
1212
{
1213
    /* L3CR */
1214
    /* XXX : not implemented */
1215
    spr_register(env, SPR_L3CR, "L3CR",
1216
                 SPR_NOACCESS, SPR_NOACCESS,
1217
                 &spr_read_generic, &spr_write_generic,
1218
                 0x00000000);
1219
    /* L3ITCR0 */
1220
    /* XXX : not implemented */
1221
    spr_register(env, SPR_L3ITCR0, "L3ITCR0",
1222
                 SPR_NOACCESS, SPR_NOACCESS,
1223
                 &spr_read_generic, &spr_write_generic,
1224
                 0x00000000);
1225
    /* L3ITCR1 */
1226
    /* XXX : not implemented */
1227
    spr_register(env, SPR_L3ITCR1, "L3ITCR1",
1228
                 SPR_NOACCESS, SPR_NOACCESS,
1229
                 &spr_read_generic, &spr_write_generic,
1230
                 0x00000000);
1231
    /* L3ITCR2 */
1232
    /* XXX : not implemented */
1233
    spr_register(env, SPR_L3ITCR2, "L3ITCR2",
1234
                 SPR_NOACCESS, SPR_NOACCESS,
1235
                 &spr_read_generic, &spr_write_generic,
1236
                 0x00000000);
1237
    /* L3ITCR3 */
1238
    /* XXX : not implemented */
1239
    spr_register(env, SPR_L3ITCR3, "L3ITCR3",
1240
                 SPR_NOACCESS, SPR_NOACCESS,
1241
                 &spr_read_generic, &spr_write_generic,
1242
                 0x00000000);
1243
    /* L3OHCR */
1244
    /* XXX : not implemented */
1245
    spr_register(env, SPR_L3OHCR, "L3OHCR",
1246
                 SPR_NOACCESS, SPR_NOACCESS,
1247
                 &spr_read_generic, &spr_write_generic,
1248
                 0x00000000);
1249
    /* L3PM */
1250
    /* XXX : not implemented */
1251
    spr_register(env, SPR_L3PM, "L3PM",
1252
                 SPR_NOACCESS, SPR_NOACCESS,
1253
                 &spr_read_generic, &spr_write_generic,
1254
                 0x00000000);
1255
}
1256

    
1257
static void gen_74xx_soft_tlb (CPUPPCState *env, int nb_tlbs, int nb_ways)
1258
{
1259
#if !defined(CONFIG_USER_ONLY)
1260
    env->nb_tlb = nb_tlbs;
1261
    env->nb_ways = nb_ways;
1262
    env->id_tlbs = 1;
1263
    /* XXX : not implemented */
1264
    spr_register(env, SPR_PTEHI, "PTEHI",
1265
                 SPR_NOACCESS, SPR_NOACCESS,
1266
                 &spr_read_generic, &spr_write_generic,
1267
                 0x00000000);
1268
    /* XXX : not implemented */
1269
    spr_register(env, SPR_PTELO, "PTELO",
1270
                 SPR_NOACCESS, SPR_NOACCESS,
1271
                 &spr_read_generic, &spr_write_generic,
1272
                 0x00000000);
1273
    /* XXX : not implemented */
1274
    spr_register(env, SPR_TLBMISS, "TLBMISS",
1275
                 SPR_NOACCESS, SPR_NOACCESS,
1276
                 &spr_read_generic, &spr_write_generic,
1277
                 0x00000000);
1278
#endif
1279
}
1280

    
1281
/* PowerPC BookE SPR */
1282
static void gen_spr_BookE (CPUPPCState *env)
1283
{
1284
    /* Processor identification */
1285
    spr_register(env, SPR_BOOKE_PIR, "PIR",
1286
                 SPR_NOACCESS, SPR_NOACCESS,
1287
                 &spr_read_generic, &spr_write_pir,
1288
                 0x00000000);
1289
    /* Interrupt processing */
1290
    spr_register(env, SPR_BOOKE_CSRR0, "CSRR0",
1291
                 SPR_NOACCESS, SPR_NOACCESS,
1292
                 &spr_read_generic, &spr_write_generic,
1293
                 0x00000000);
1294
    spr_register(env, SPR_BOOKE_CSRR1, "CSRR1",
1295
                 SPR_NOACCESS, SPR_NOACCESS,
1296
                 &spr_read_generic, &spr_write_generic,
1297
                 0x00000000);
1298
#if 0
1299
    spr_register(env, SPR_BOOKE_DSRR0, "DSRR0",
1300
                 SPR_NOACCESS, SPR_NOACCESS,
1301
                 &spr_read_generic, &spr_write_generic,
1302
                 0x00000000);
1303
    spr_register(env, SPR_BOOKE_DSRR1, "DSRR1",
1304
                 SPR_NOACCESS, SPR_NOACCESS,
1305
                 &spr_read_generic, &spr_write_generic,
1306
                 0x00000000);
1307
#endif
1308
    /* Debug */
1309
    /* XXX : not implemented */
1310
    spr_register(env, SPR_BOOKE_IAC1, "IAC1",
1311
                 SPR_NOACCESS, SPR_NOACCESS,
1312
                 &spr_read_generic, &spr_write_generic,
1313
                 0x00000000);
1314
    /* XXX : not implemented */
1315
    spr_register(env, SPR_BOOKE_IAC2, "IAC2",
1316
                 SPR_NOACCESS, SPR_NOACCESS,
1317
                 &spr_read_generic, &spr_write_generic,
1318
                 0x00000000);
1319
    /* XXX : not implemented */
1320
    spr_register(env, SPR_BOOKE_IAC3, "IAC3",
1321
                 SPR_NOACCESS, SPR_NOACCESS,
1322
                 &spr_read_generic, &spr_write_generic,
1323
                 0x00000000);
1324
    /* XXX : not implemented */
1325
    spr_register(env, SPR_BOOKE_IAC4, "IAC4",
1326
                 SPR_NOACCESS, SPR_NOACCESS,
1327
                 &spr_read_generic, &spr_write_generic,
1328
                 0x00000000);
1329
    /* XXX : not implemented */
1330
    spr_register(env, SPR_BOOKE_DAC1, "DAC1",
1331
                 SPR_NOACCESS, SPR_NOACCESS,
1332
                 &spr_read_generic, &spr_write_generic,
1333
                 0x00000000);
1334
    /* XXX : not implemented */
1335
    spr_register(env, SPR_BOOKE_DAC2, "DAC2",
1336
                 SPR_NOACCESS, SPR_NOACCESS,
1337
                 &spr_read_generic, &spr_write_generic,
1338
                 0x00000000);
1339
    /* XXX : not implemented */
1340
    spr_register(env, SPR_BOOKE_DVC1, "DVC1",
1341
                 SPR_NOACCESS, SPR_NOACCESS,
1342
                 &spr_read_generic, &spr_write_generic,
1343
                 0x00000000);
1344
    /* XXX : not implemented */
1345
    spr_register(env, SPR_BOOKE_DVC2, "DVC2",
1346
                 SPR_NOACCESS, SPR_NOACCESS,
1347
                 &spr_read_generic, &spr_write_generic,
1348
                 0x00000000);
1349
    /* XXX : not implemented */
1350
    spr_register(env, SPR_BOOKE_DBCR0, "DBCR0",
1351
                 SPR_NOACCESS, SPR_NOACCESS,
1352
                 &spr_read_generic, &spr_write_generic,
1353
                 0x00000000);
1354
    /* XXX : not implemented */
1355
    spr_register(env, SPR_BOOKE_DBCR1, "DBCR1",
1356
                 SPR_NOACCESS, SPR_NOACCESS,
1357
                 &spr_read_generic, &spr_write_generic,
1358
                 0x00000000);
1359
    /* XXX : not implemented */
1360
    spr_register(env, SPR_BOOKE_DBCR2, "DBCR2",
1361
                 SPR_NOACCESS, SPR_NOACCESS,
1362
                 &spr_read_generic, &spr_write_generic,
1363
                 0x00000000);
1364
    /* XXX : not implemented */
1365
    spr_register(env, SPR_BOOKE_DBSR, "DBSR",
1366
                 SPR_NOACCESS, SPR_NOACCESS,
1367
                 &spr_read_generic, &spr_write_clear,
1368
                 0x00000000);
1369
    spr_register(env, SPR_BOOKE_DEAR, "DEAR",
1370
                 SPR_NOACCESS, SPR_NOACCESS,
1371
                 &spr_read_generic, &spr_write_generic,
1372
                 0x00000000);
1373
    spr_register(env, SPR_BOOKE_ESR, "ESR",
1374
                 SPR_NOACCESS, SPR_NOACCESS,
1375
                 &spr_read_generic, &spr_write_generic,
1376
                 0x00000000);
1377
    spr_register(env, SPR_BOOKE_IVPR, "IVPR",
1378
                 SPR_NOACCESS, SPR_NOACCESS,
1379
                 &spr_read_generic, &spr_write_excp_prefix,
1380
                 0x00000000);
1381
    /* Exception vectors */
1382
    spr_register(env, SPR_BOOKE_IVOR0, "IVOR0",
1383
                 SPR_NOACCESS, SPR_NOACCESS,
1384
                 &spr_read_generic, &spr_write_excp_vector,
1385
                 0x00000000);
1386
    spr_register(env, SPR_BOOKE_IVOR1, "IVOR1",
1387
                 SPR_NOACCESS, SPR_NOACCESS,
1388
                 &spr_read_generic, &spr_write_excp_vector,
1389
                 0x00000000);
1390
    spr_register(env, SPR_BOOKE_IVOR2, "IVOR2",
1391
                 SPR_NOACCESS, SPR_NOACCESS,
1392
                 &spr_read_generic, &spr_write_excp_vector,
1393
                 0x00000000);
1394
    spr_register(env, SPR_BOOKE_IVOR3, "IVOR3",
1395
                 SPR_NOACCESS, SPR_NOACCESS,
1396
                 &spr_read_generic, &spr_write_excp_vector,
1397
                 0x00000000);
1398
    spr_register(env, SPR_BOOKE_IVOR4, "IVOR4",
1399
                 SPR_NOACCESS, SPR_NOACCESS,
1400
                 &spr_read_generic, &spr_write_excp_vector,
1401
                 0x00000000);
1402
    spr_register(env, SPR_BOOKE_IVOR5, "IVOR5",
1403
                 SPR_NOACCESS, SPR_NOACCESS,
1404
                 &spr_read_generic, &spr_write_excp_vector,
1405
                 0x00000000);
1406
    spr_register(env, SPR_BOOKE_IVOR6, "IVOR6",
1407
                 SPR_NOACCESS, SPR_NOACCESS,
1408
                 &spr_read_generic, &spr_write_excp_vector,
1409
                 0x00000000);
1410
    spr_register(env, SPR_BOOKE_IVOR7, "IVOR7",
1411
                 SPR_NOACCESS, SPR_NOACCESS,
1412
                 &spr_read_generic, &spr_write_excp_vector,
1413
                 0x00000000);
1414
    spr_register(env, SPR_BOOKE_IVOR8, "IVOR8",
1415
                 SPR_NOACCESS, SPR_NOACCESS,
1416
                 &spr_read_generic, &spr_write_excp_vector,
1417
                 0x00000000);
1418
    spr_register(env, SPR_BOOKE_IVOR9, "IVOR9",
1419
                 SPR_NOACCESS, SPR_NOACCESS,
1420
                 &spr_read_generic, &spr_write_excp_vector,
1421
                 0x00000000);
1422
    spr_register(env, SPR_BOOKE_IVOR10, "IVOR10",
1423
                 SPR_NOACCESS, SPR_NOACCESS,
1424
                 &spr_read_generic, &spr_write_excp_vector,
1425
                 0x00000000);
1426
    spr_register(env, SPR_BOOKE_IVOR11, "IVOR11",
1427
                 SPR_NOACCESS, SPR_NOACCESS,
1428
                 &spr_read_generic, &spr_write_excp_vector,
1429
                 0x00000000);
1430
    spr_register(env, SPR_BOOKE_IVOR12, "IVOR12",
1431
                 SPR_NOACCESS, SPR_NOACCESS,
1432
                 &spr_read_generic, &spr_write_excp_vector,
1433
                 0x00000000);
1434
    spr_register(env, SPR_BOOKE_IVOR13, "IVOR13",
1435
                 SPR_NOACCESS, SPR_NOACCESS,
1436
                 &spr_read_generic, &spr_write_excp_vector,
1437
                 0x00000000);
1438
    spr_register(env, SPR_BOOKE_IVOR14, "IVOR14",
1439
                 SPR_NOACCESS, SPR_NOACCESS,
1440
                 &spr_read_generic, &spr_write_excp_vector,
1441
                 0x00000000);
1442
    spr_register(env, SPR_BOOKE_IVOR15, "IVOR15",
1443
                 SPR_NOACCESS, SPR_NOACCESS,
1444
                 &spr_read_generic, &spr_write_excp_vector,
1445
                 0x00000000);
1446
#if 0
1447
    spr_register(env, SPR_BOOKE_IVOR32, "IVOR32",
1448
                 SPR_NOACCESS, SPR_NOACCESS,
1449
                 &spr_read_generic, &spr_write_excp_vector,
1450
                 0x00000000);
1451
    spr_register(env, SPR_BOOKE_IVOR33, "IVOR33",
1452
                 SPR_NOACCESS, SPR_NOACCESS,
1453
                 &spr_read_generic, &spr_write_excp_vector,
1454
                 0x00000000);
1455
    spr_register(env, SPR_BOOKE_IVOR34, "IVOR34",
1456
                 SPR_NOACCESS, SPR_NOACCESS,
1457
                 &spr_read_generic, &spr_write_excp_vector,
1458
                 0x00000000);
1459
    spr_register(env, SPR_BOOKE_IVOR35, "IVOR35",
1460
                 SPR_NOACCESS, SPR_NOACCESS,
1461
                 &spr_read_generic, &spr_write_excp_vector,
1462
                 0x00000000);
1463
    spr_register(env, SPR_BOOKE_IVOR36, "IVOR36",
1464
                 SPR_NOACCESS, SPR_NOACCESS,
1465
                 &spr_read_generic, &spr_write_excp_vector,
1466
                 0x00000000);
1467
    spr_register(env, SPR_BOOKE_IVOR37, "IVOR37",
1468
                 SPR_NOACCESS, SPR_NOACCESS,
1469
                 &spr_read_generic, &spr_write_excp_vector,
1470
                 0x00000000);
1471
#endif
1472
    spr_register(env, SPR_BOOKE_PID, "PID",
1473
                 SPR_NOACCESS, SPR_NOACCESS,
1474
                 &spr_read_generic, &spr_write_generic,
1475
                 0x00000000);
1476
    spr_register(env, SPR_BOOKE_TCR, "TCR",
1477
                 SPR_NOACCESS, SPR_NOACCESS,
1478
                 &spr_read_generic, &spr_write_booke_tcr,
1479
                 0x00000000);
1480
    spr_register(env, SPR_BOOKE_TSR, "TSR",
1481
                 SPR_NOACCESS, SPR_NOACCESS,
1482
                 &spr_read_generic, &spr_write_booke_tsr,
1483
                 0x00000000);
1484
    /* Timer */
1485
    spr_register(env, SPR_DECR, "DECR",
1486
                 SPR_NOACCESS, SPR_NOACCESS,
1487
                 &spr_read_decr, &spr_write_decr,
1488
                 0x00000000);
1489
    spr_register(env, SPR_BOOKE_DECAR, "DECAR",
1490
                 SPR_NOACCESS, SPR_NOACCESS,
1491
                 SPR_NOACCESS, &spr_write_generic,
1492
                 0x00000000);
1493
    /* SPRGs */
1494
    spr_register(env, SPR_USPRG0, "USPRG0",
1495
                 &spr_read_generic, &spr_write_generic,
1496
                 &spr_read_generic, &spr_write_generic,
1497
                 0x00000000);
1498
    spr_register(env, SPR_SPRG4, "SPRG4",
1499
                 SPR_NOACCESS, SPR_NOACCESS,
1500
                 &spr_read_generic, &spr_write_generic,
1501
                 0x00000000);
1502
    spr_register(env, SPR_USPRG4, "USPRG4",
1503
                 &spr_read_ureg, SPR_NOACCESS,
1504
                 &spr_read_ureg, SPR_NOACCESS,
1505
                 0x00000000);
1506
    spr_register(env, SPR_SPRG5, "SPRG5",
1507
                 SPR_NOACCESS, SPR_NOACCESS,
1508
                 &spr_read_generic, &spr_write_generic,
1509
                 0x00000000);
1510
    spr_register(env, SPR_USPRG5, "USPRG5",
1511
                 &spr_read_ureg, SPR_NOACCESS,
1512
                 &spr_read_ureg, SPR_NOACCESS,
1513
                 0x00000000);
1514
    spr_register(env, SPR_SPRG6, "SPRG6",
1515
                 SPR_NOACCESS, SPR_NOACCESS,
1516
                 &spr_read_generic, &spr_write_generic,
1517
                 0x00000000);
1518
    spr_register(env, SPR_USPRG6, "USPRG6",
1519
                 &spr_read_ureg, SPR_NOACCESS,
1520
                 &spr_read_ureg, SPR_NOACCESS,
1521
                 0x00000000);
1522
    spr_register(env, SPR_SPRG7, "SPRG7",
1523
                 SPR_NOACCESS, SPR_NOACCESS,
1524
                 &spr_read_generic, &spr_write_generic,
1525
                 0x00000000);
1526
    spr_register(env, SPR_USPRG7, "USPRG7",
1527
                 &spr_read_ureg, SPR_NOACCESS,
1528
                 &spr_read_ureg, SPR_NOACCESS,
1529
                 0x00000000);
1530
}
1531

    
1532
/* FSL storage control registers */
1533
static void gen_spr_BookE_FSL (CPUPPCState *env)
1534
{
1535
#if !defined(CONFIG_USER_ONLY)
1536
    /* TLB assist registers */
1537
    /* XXX : not implemented */
1538
    spr_register(env, SPR_BOOKE_MAS0, "MAS0",
1539
                 SPR_NOACCESS, SPR_NOACCESS,
1540
                 &spr_read_generic, &spr_write_generic,
1541
                 0x00000000);
1542
    /* XXX : not implemented */
1543
    spr_register(env, SPR_BOOKE_MAS1, "MAS2",
1544
                 SPR_NOACCESS, SPR_NOACCESS,
1545
                 &spr_read_generic, &spr_write_generic,
1546
                 0x00000000);
1547
    /* XXX : not implemented */
1548
    spr_register(env, SPR_BOOKE_MAS2, "MAS3",
1549
                 SPR_NOACCESS, SPR_NOACCESS,
1550
                 &spr_read_generic, &spr_write_generic,
1551
                 0x00000000);
1552
    /* XXX : not implemented */
1553
    spr_register(env, SPR_BOOKE_MAS3, "MAS4",
1554
                 SPR_NOACCESS, SPR_NOACCESS,
1555
                 &spr_read_generic, &spr_write_generic,
1556
                 0x00000000);
1557
    /* XXX : not implemented */
1558
    spr_register(env, SPR_BOOKE_MAS4, "MAS5",
1559
                 SPR_NOACCESS, SPR_NOACCESS,
1560
                 &spr_read_generic, &spr_write_generic,
1561
                 0x00000000);
1562
    /* XXX : not implemented */
1563
    spr_register(env, SPR_BOOKE_MAS6, "MAS6",
1564
                 SPR_NOACCESS, SPR_NOACCESS,
1565
                 &spr_read_generic, &spr_write_generic,
1566
                 0x00000000);
1567
    /* XXX : not implemented */
1568
    spr_register(env, SPR_BOOKE_MAS7, "MAS7",
1569
                 SPR_NOACCESS, SPR_NOACCESS,
1570
                 &spr_read_generic, &spr_write_generic,
1571
                 0x00000000);
1572
    if (env->nb_pids > 1) {
1573
        /* XXX : not implemented */
1574
        spr_register(env, SPR_BOOKE_PID1, "PID1",
1575
                     SPR_NOACCESS, SPR_NOACCESS,
1576
                     &spr_read_generic, &spr_write_generic,
1577
                     0x00000000);
1578
    }
1579
    if (env->nb_pids > 2) {
1580
        /* XXX : not implemented */
1581
        spr_register(env, SPR_BOOKE_PID2, "PID2",
1582
                     SPR_NOACCESS, SPR_NOACCESS,
1583
                     &spr_read_generic, &spr_write_generic,
1584
                     0x00000000);
1585
    }
1586
    /* XXX : not implemented */
1587
    spr_register(env, SPR_MMUCFG, "MMUCFG",
1588
                 SPR_NOACCESS, SPR_NOACCESS,
1589
                 &spr_read_generic, SPR_NOACCESS,
1590
                 0x00000000); /* TOFIX */
1591
    /* XXX : not implemented */
1592
    spr_register(env, SPR_MMUCSR0, "MMUCSR0",
1593
                 SPR_NOACCESS, SPR_NOACCESS,
1594
                 &spr_read_generic, &spr_write_generic,
1595
                 0x00000000); /* TOFIX */
1596
    switch (env->nb_ways) {
1597
    case 4:
1598
        /* XXX : not implemented */
1599
        spr_register(env, SPR_BOOKE_TLB3CFG, "TLB3CFG",
1600
                     SPR_NOACCESS, SPR_NOACCESS,
1601
                     &spr_read_generic, SPR_NOACCESS,
1602
                     0x00000000); /* TOFIX */
1603
        /* Fallthru */
1604
    case 3:
1605
        /* XXX : not implemented */
1606
        spr_register(env, SPR_BOOKE_TLB2CFG, "TLB2CFG",
1607
                     SPR_NOACCESS, SPR_NOACCESS,
1608
                     &spr_read_generic, SPR_NOACCESS,
1609
                     0x00000000); /* TOFIX */
1610
        /* Fallthru */
1611
    case 2:
1612
        /* XXX : not implemented */
1613
        spr_register(env, SPR_BOOKE_TLB1CFG, "TLB1CFG",
1614
                     SPR_NOACCESS, SPR_NOACCESS,
1615
                     &spr_read_generic, SPR_NOACCESS,
1616
                     0x00000000); /* TOFIX */
1617
        /* Fallthru */
1618
    case 1:
1619
        /* XXX : not implemented */
1620
        spr_register(env, SPR_BOOKE_TLB0CFG, "TLB0CFG",
1621
                     SPR_NOACCESS, SPR_NOACCESS,
1622
                     &spr_read_generic, SPR_NOACCESS,
1623
                     0x00000000); /* TOFIX */
1624
        /* Fallthru */
1625
    case 0:
1626
    default:
1627
        break;
1628
    }
1629
#endif
1630
}
1631

    
1632
/* SPR specific to PowerPC 440 implementation */
1633
static void gen_spr_440 (CPUPPCState *env)
1634
{
1635
    /* Cache control */
1636
    /* XXX : not implemented */
1637
    spr_register(env, SPR_440_DNV0, "DNV0",
1638
                 SPR_NOACCESS, SPR_NOACCESS,
1639
                 &spr_read_generic, &spr_write_generic,
1640
                 0x00000000);
1641
    /* XXX : not implemented */
1642
    spr_register(env, SPR_440_DNV1, "DNV1",
1643
                 SPR_NOACCESS, SPR_NOACCESS,
1644
                 &spr_read_generic, &spr_write_generic,
1645
                 0x00000000);
1646
    /* XXX : not implemented */
1647
    spr_register(env, SPR_440_DNV2, "DNV2",
1648
                 SPR_NOACCESS, SPR_NOACCESS,
1649
                 &spr_read_generic, &spr_write_generic,
1650
                 0x00000000);
1651
    /* XXX : not implemented */
1652
    spr_register(env, SPR_440_DNV3, "DNV3",
1653
                 SPR_NOACCESS, SPR_NOACCESS,
1654
                 &spr_read_generic, &spr_write_generic,
1655
                 0x00000000);
1656
    /* XXX : not implemented */
1657
    spr_register(env, SPR_440_DTV0, "DTV0",
1658
                 SPR_NOACCESS, SPR_NOACCESS,
1659
                 &spr_read_generic, &spr_write_generic,
1660
                 0x00000000);
1661
    /* XXX : not implemented */
1662
    spr_register(env, SPR_440_DTV1, "DTV1",
1663
                 SPR_NOACCESS, SPR_NOACCESS,
1664
                 &spr_read_generic, &spr_write_generic,
1665
                 0x00000000);
1666
    /* XXX : not implemented */
1667
    spr_register(env, SPR_440_DTV2, "DTV2",
1668
                 SPR_NOACCESS, SPR_NOACCESS,
1669
                 &spr_read_generic, &spr_write_generic,
1670
                 0x00000000);
1671
    /* XXX : not implemented */
1672
    spr_register(env, SPR_440_DTV3, "DTV3",
1673
                 SPR_NOACCESS, SPR_NOACCESS,
1674
                 &spr_read_generic, &spr_write_generic,
1675
                 0x00000000);
1676
    /* XXX : not implemented */
1677
    spr_register(env, SPR_440_DVLIM, "DVLIM",
1678
                 SPR_NOACCESS, SPR_NOACCESS,
1679
                 &spr_read_generic, &spr_write_generic,
1680
                 0x00000000);
1681
    /* XXX : not implemented */
1682
    spr_register(env, SPR_440_INV0, "INV0",
1683
                 SPR_NOACCESS, SPR_NOACCESS,
1684
                 &spr_read_generic, &spr_write_generic,
1685
                 0x00000000);
1686
    /* XXX : not implemented */
1687
    spr_register(env, SPR_440_INV1, "INV1",
1688
                 SPR_NOACCESS, SPR_NOACCESS,
1689
                 &spr_read_generic, &spr_write_generic,
1690
                 0x00000000);
1691
    /* XXX : not implemented */
1692
    spr_register(env, SPR_440_INV2, "INV2",
1693
                 SPR_NOACCESS, SPR_NOACCESS,
1694
                 &spr_read_generic, &spr_write_generic,
1695
                 0x00000000);
1696
    /* XXX : not implemented */
1697
    spr_register(env, SPR_440_INV3, "INV3",
1698
                 SPR_NOACCESS, SPR_NOACCESS,
1699
                 &spr_read_generic, &spr_write_generic,
1700
                 0x00000000);
1701
    /* XXX : not implemented */
1702
    spr_register(env, SPR_440_ITV0, "ITV0",
1703
                 SPR_NOACCESS, SPR_NOACCESS,
1704
                 &spr_read_generic, &spr_write_generic,
1705
                 0x00000000);
1706
    /* XXX : not implemented */
1707
    spr_register(env, SPR_440_ITV1, "ITV1",
1708
                 SPR_NOACCESS, SPR_NOACCESS,
1709
                 &spr_read_generic, &spr_write_generic,
1710
                 0x00000000);
1711
    /* XXX : not implemented */
1712
    spr_register(env, SPR_440_ITV2, "ITV2",
1713
                 SPR_NOACCESS, SPR_NOACCESS,
1714
                 &spr_read_generic, &spr_write_generic,
1715
                 0x00000000);
1716
    /* XXX : not implemented */
1717
    spr_register(env, SPR_440_ITV3, "ITV3",
1718
                 SPR_NOACCESS, SPR_NOACCESS,
1719
                 &spr_read_generic, &spr_write_generic,
1720
                 0x00000000);
1721
    /* XXX : not implemented */
1722
    spr_register(env, SPR_440_IVLIM, "IVLIM",
1723
                 SPR_NOACCESS, SPR_NOACCESS,
1724
                 &spr_read_generic, &spr_write_generic,
1725
                 0x00000000);
1726
    /* Cache debug */
1727
    /* XXX : not implemented */
1728
    spr_register(env, SPR_BOOKE_DCDBTRH, "DCDBTRH",
1729
                 SPR_NOACCESS, SPR_NOACCESS,
1730
                 &spr_read_generic, SPR_NOACCESS,
1731
                 0x00000000);
1732
    /* XXX : not implemented */
1733
    spr_register(env, SPR_BOOKE_DCDBTRL, "DCDBTRL",
1734
                 SPR_NOACCESS, SPR_NOACCESS,
1735
                 &spr_read_generic, SPR_NOACCESS,
1736
                 0x00000000);
1737
    /* XXX : not implemented */
1738
    spr_register(env, SPR_BOOKE_ICDBDR, "ICDBDR",
1739
                 SPR_NOACCESS, SPR_NOACCESS,
1740
                 &spr_read_generic, SPR_NOACCESS,
1741
                 0x00000000);
1742
    /* XXX : not implemented */
1743
    spr_register(env, SPR_BOOKE_ICDBTRH, "ICDBTRH",
1744
                 SPR_NOACCESS, SPR_NOACCESS,
1745
                 &spr_read_generic, SPR_NOACCESS,
1746
                 0x00000000);
1747
    /* XXX : not implemented */
1748
    spr_register(env, SPR_BOOKE_ICDBTRL, "ICDBTRL",
1749
                 SPR_NOACCESS, SPR_NOACCESS,
1750
                 &spr_read_generic, SPR_NOACCESS,
1751
                 0x00000000);
1752
    /* XXX : not implemented */
1753
    spr_register(env, SPR_440_DBDR, "DBDR",
1754
                 SPR_NOACCESS, SPR_NOACCESS,
1755
                 &spr_read_generic, &spr_write_generic,
1756
                 0x00000000);
1757
    /* Processor control */
1758
    spr_register(env, SPR_4xx_CCR0, "CCR0",
1759
                 SPR_NOACCESS, SPR_NOACCESS,
1760
                 &spr_read_generic, &spr_write_generic,
1761
                 0x00000000);
1762
    spr_register(env, SPR_440_RSTCFG, "RSTCFG",
1763
                 SPR_NOACCESS, SPR_NOACCESS,
1764
                 &spr_read_generic, SPR_NOACCESS,
1765
                 0x00000000);
1766
    /* Storage control */
1767
    spr_register(env, SPR_440_MMUCR, "MMUCR",
1768
                 SPR_NOACCESS, SPR_NOACCESS,
1769
                 &spr_read_generic, &spr_write_generic,
1770
                 0x00000000);
1771
}
1772

    
1773
/* SPR shared between PowerPC 40x implementations */
1774
static void gen_spr_40x (CPUPPCState *env)
1775
{
1776
    /* Cache */
1777
    /* not emulated, as Qemu do not emulate caches */
1778
    spr_register(env, SPR_40x_DCCR, "DCCR",
1779
                 SPR_NOACCESS, SPR_NOACCESS,
1780
                 &spr_read_generic, &spr_write_generic,
1781
                 0x00000000);
1782
    /* not emulated, as Qemu do not emulate caches */
1783
    spr_register(env, SPR_40x_ICCR, "ICCR",
1784
                 SPR_NOACCESS, SPR_NOACCESS,
1785
                 &spr_read_generic, &spr_write_generic,
1786
                 0x00000000);
1787
    /* not emulated, as Qemu do not emulate caches */
1788
    spr_register(env, SPR_BOOKE_ICDBDR, "ICDBDR",
1789
                 SPR_NOACCESS, SPR_NOACCESS,
1790
                 &spr_read_generic, SPR_NOACCESS,
1791
                 0x00000000);
1792
    /* Exception */
1793
    spr_register(env, SPR_40x_DEAR, "DEAR",
1794
                 SPR_NOACCESS, SPR_NOACCESS,
1795
                 &spr_read_generic, &spr_write_generic,
1796
                 0x00000000);
1797
    spr_register(env, SPR_40x_ESR, "ESR",
1798
                 SPR_NOACCESS, SPR_NOACCESS,
1799
                 &spr_read_generic, &spr_write_generic,
1800
                 0x00000000);
1801
    spr_register(env, SPR_40x_EVPR, "EVPR",
1802
                 SPR_NOACCESS, SPR_NOACCESS,
1803
                 &spr_read_generic, &spr_write_excp_prefix,
1804
                 0x00000000);
1805
    spr_register(env, SPR_40x_SRR2, "SRR2",
1806
                 &spr_read_generic, &spr_write_generic,
1807
                 &spr_read_generic, &spr_write_generic,
1808
                 0x00000000);
1809
    spr_register(env, SPR_40x_SRR3, "SRR3",
1810
                 &spr_read_generic, &spr_write_generic,
1811
                 &spr_read_generic, &spr_write_generic,
1812
                 0x00000000);
1813
    /* Timers */
1814
    spr_register(env, SPR_40x_PIT, "PIT",
1815
                 SPR_NOACCESS, SPR_NOACCESS,
1816
                 &spr_read_40x_pit, &spr_write_40x_pit,
1817
                 0x00000000);
1818
    spr_register(env, SPR_40x_TCR, "TCR",
1819
                 SPR_NOACCESS, SPR_NOACCESS,
1820
                 &spr_read_generic, &spr_write_booke_tcr,
1821
                 0x00000000);
1822
    spr_register(env, SPR_40x_TSR, "TSR",
1823
                 SPR_NOACCESS, SPR_NOACCESS,
1824
                 &spr_read_generic, &spr_write_booke_tsr,
1825
                 0x00000000);
1826
}
1827

    
1828
/* SPR specific to PowerPC 405 implementation */
1829
static void gen_spr_405 (CPUPPCState *env)
1830
{
1831
    /* MMU */
1832
    spr_register(env, SPR_40x_PID, "PID",
1833
                 SPR_NOACCESS, SPR_NOACCESS,
1834
                 &spr_read_generic, &spr_write_generic,
1835
                 0x00000000);
1836
    spr_register(env, SPR_4xx_CCR0, "CCR0",
1837
                 SPR_NOACCESS, SPR_NOACCESS,
1838
                 &spr_read_generic, &spr_write_generic,
1839
                 0x00700000);
1840
    /* Debug interface */
1841
    /* XXX : not implemented */
1842
    spr_register(env, SPR_40x_DBCR0, "DBCR0",
1843
                 SPR_NOACCESS, SPR_NOACCESS,
1844
                 &spr_read_generic, &spr_write_40x_dbcr0,
1845
                 0x00000000);
1846
    /* XXX : not implemented */
1847
    spr_register(env, SPR_405_DBCR1, "DBCR1",
1848
                 SPR_NOACCESS, SPR_NOACCESS,
1849
                 &spr_read_generic, &spr_write_generic,
1850
                 0x00000000);
1851
    /* XXX : not implemented */
1852
    spr_register(env, SPR_40x_DBSR, "DBSR",
1853
                 SPR_NOACCESS, SPR_NOACCESS,
1854
                 &spr_read_generic, &spr_write_clear,
1855
                 /* Last reset was system reset */
1856
                 0x00000300);
1857
    /* XXX : not implemented */
1858
    spr_register(env, SPR_40x_DAC1, "DAC1",
1859
                 SPR_NOACCESS, SPR_NOACCESS,
1860
                 &spr_read_generic, &spr_write_generic,
1861
                 0x00000000);
1862
    spr_register(env, SPR_40x_DAC2, "DAC2",
1863
                 SPR_NOACCESS, SPR_NOACCESS,
1864
                 &spr_read_generic, &spr_write_generic,
1865
                 0x00000000);
1866
    /* XXX : not implemented */
1867
    spr_register(env, SPR_405_DVC1, "DVC1",
1868
                 SPR_NOACCESS, SPR_NOACCESS,
1869
                 &spr_read_generic, &spr_write_generic,
1870
                 0x00000000);
1871
    /* XXX : not implemented */
1872
    spr_register(env, SPR_405_DVC2, "DVC2",
1873
                 SPR_NOACCESS, SPR_NOACCESS,
1874
                 &spr_read_generic, &spr_write_generic,
1875
                 0x00000000);
1876
    /* XXX : not implemented */
1877
    spr_register(env, SPR_40x_IAC1, "IAC1",
1878
                 SPR_NOACCESS, SPR_NOACCESS,
1879
                 &spr_read_generic, &spr_write_generic,
1880
                 0x00000000);
1881
    spr_register(env, SPR_40x_IAC2, "IAC2",
1882
                 SPR_NOACCESS, SPR_NOACCESS,
1883
                 &spr_read_generic, &spr_write_generic,
1884
                 0x00000000);
1885
    /* XXX : not implemented */
1886
    spr_register(env, SPR_405_IAC3, "IAC3",
1887
                 SPR_NOACCESS, SPR_NOACCESS,
1888
                 &spr_read_generic, &spr_write_generic,
1889
                 0x00000000);
1890
    /* XXX : not implemented */
1891
    spr_register(env, SPR_405_IAC4, "IAC4",
1892
                 SPR_NOACCESS, SPR_NOACCESS,
1893
                 &spr_read_generic, &spr_write_generic,
1894
                 0x00000000);
1895
    /* Storage control */
1896
    /* XXX: TODO: not implemented */
1897
    spr_register(env, SPR_405_SLER, "SLER",
1898
                 SPR_NOACCESS, SPR_NOACCESS,
1899
                 &spr_read_generic, &spr_write_40x_sler,
1900
                 0x00000000);
1901
    spr_register(env, SPR_40x_ZPR, "ZPR",
1902
                 SPR_NOACCESS, SPR_NOACCESS,
1903
                 &spr_read_generic, &spr_write_generic,
1904
                 0x00000000);
1905
    /* XXX : not implemented */
1906
    spr_register(env, SPR_405_SU0R, "SU0R",
1907
                 SPR_NOACCESS, SPR_NOACCESS,
1908
                 &spr_read_generic, &spr_write_generic,
1909
                 0x00000000);
1910
    /* SPRG */
1911
    spr_register(env, SPR_USPRG0, "USPRG0",
1912
                 &spr_read_ureg, SPR_NOACCESS,
1913
                 &spr_read_ureg, SPR_NOACCESS,
1914
                 0x00000000);
1915
    spr_register(env, SPR_SPRG4, "SPRG4",
1916
                 SPR_NOACCESS, SPR_NOACCESS,
1917
                 &spr_read_generic, &spr_write_generic,
1918
                 0x00000000);
1919
    spr_register(env, SPR_USPRG4, "USPRG4",
1920
                 &spr_read_ureg, SPR_NOACCESS,
1921
                 &spr_read_ureg, SPR_NOACCESS,
1922
                 0x00000000);
1923
    spr_register(env, SPR_SPRG5, "SPRG5",
1924
                 SPR_NOACCESS, SPR_NOACCESS,
1925
                 spr_read_generic, &spr_write_generic,
1926
                 0x00000000);
1927
    spr_register(env, SPR_USPRG5, "USPRG5",
1928
                 &spr_read_ureg, SPR_NOACCESS,
1929
                 &spr_read_ureg, SPR_NOACCESS,
1930
                 0x00000000);
1931
    spr_register(env, SPR_SPRG6, "SPRG6",
1932
                 SPR_NOACCESS, SPR_NOACCESS,
1933
                 spr_read_generic, &spr_write_generic,
1934
                 0x00000000);
1935
    spr_register(env, SPR_USPRG6, "USPRG6",
1936
                 &spr_read_ureg, SPR_NOACCESS,
1937
                 &spr_read_ureg, SPR_NOACCESS,
1938
                 0x00000000);
1939
    spr_register(env, SPR_SPRG7, "SPRG7",
1940
                 SPR_NOACCESS, SPR_NOACCESS,
1941
                 spr_read_generic, &spr_write_generic,
1942
                 0x00000000);
1943
    spr_register(env, SPR_USPRG7, "USPRG7",
1944
                 &spr_read_ureg, SPR_NOACCESS,
1945
                 &spr_read_ureg, SPR_NOACCESS,
1946
                 0x00000000);
1947
}
1948

    
1949
/* SPR shared between PowerPC 401 & 403 implementations */
1950
static void gen_spr_401_403 (CPUPPCState *env)
1951
{
1952
    /* Time base */
1953
    spr_register(env, SPR_403_VTBL,  "TBL",
1954
                 &spr_read_tbl, SPR_NOACCESS,
1955
                 &spr_read_tbl, SPR_NOACCESS,
1956
                 0x00000000);
1957
    spr_register(env, SPR_403_TBL,   "TBL",
1958
                 SPR_NOACCESS, SPR_NOACCESS,
1959
                 SPR_NOACCESS, &spr_write_tbl,
1960
                 0x00000000);
1961
    spr_register(env, SPR_403_VTBU,  "TBU",
1962
                 &spr_read_tbu, SPR_NOACCESS,
1963
                 &spr_read_tbu, SPR_NOACCESS,
1964
                 0x00000000);
1965
    spr_register(env, SPR_403_TBU,   "TBU",
1966
                 SPR_NOACCESS, SPR_NOACCESS,
1967
                 SPR_NOACCESS, &spr_write_tbu,
1968
                 0x00000000);
1969
    /* Debug */
1970
    /* not emulated, as Qemu do not emulate caches */
1971
    spr_register(env, SPR_403_CDBCR, "CDBCR",
1972
                 SPR_NOACCESS, SPR_NOACCESS,
1973
                 &spr_read_generic, &spr_write_generic,
1974
                 0x00000000);
1975
}
1976

    
1977
/* SPR specific to PowerPC 401 implementation */
1978
static void gen_spr_401 (CPUPPCState *env)
1979
{
1980
    /* Debug interface */
1981
    /* XXX : not implemented */
1982
    spr_register(env, SPR_40x_DBCR0, "DBCR",
1983
                 SPR_NOACCESS, SPR_NOACCESS,
1984
                 &spr_read_generic, &spr_write_40x_dbcr0,
1985
                 0x00000000);
1986
    /* XXX : not implemented */
1987
    spr_register(env, SPR_40x_DBSR, "DBSR",
1988
                 SPR_NOACCESS, SPR_NOACCESS,
1989
                 &spr_read_generic, &spr_write_clear,
1990
                 /* Last reset was system reset */
1991
                 0x00000300);
1992
    /* XXX : not implemented */
1993
    spr_register(env, SPR_40x_DAC1, "DAC",
1994
                 SPR_NOACCESS, SPR_NOACCESS,
1995
                 &spr_read_generic, &spr_write_generic,
1996
                 0x00000000);
1997
    /* XXX : not implemented */
1998
    spr_register(env, SPR_40x_IAC1, "IAC",
1999
                 SPR_NOACCESS, SPR_NOACCESS,
2000
                 &spr_read_generic, &spr_write_generic,
2001
                 0x00000000);
2002
    /* Storage control */
2003
    /* XXX: TODO: not implemented */
2004
    spr_register(env, SPR_405_SLER, "SLER",
2005
                 SPR_NOACCESS, SPR_NOACCESS,
2006
                 &spr_read_generic, &spr_write_40x_sler,
2007
                 0x00000000);
2008
    /* not emulated, as Qemu never does speculative access */
2009
    spr_register(env, SPR_40x_SGR, "SGR",
2010
                 SPR_NOACCESS, SPR_NOACCESS,
2011
                 &spr_read_generic, &spr_write_generic,
2012
                 0xFFFFFFFF);
2013
    /* not emulated, as Qemu do not emulate caches */
2014
    spr_register(env, SPR_40x_DCWR, "DCWR",
2015
                 SPR_NOACCESS, SPR_NOACCESS,
2016
                 &spr_read_generic, &spr_write_generic,
2017
                 0x00000000);
2018
}
2019

    
2020
static void gen_spr_401x2 (CPUPPCState *env)
2021
{
2022
    gen_spr_401(env);
2023
    spr_register(env, SPR_40x_PID, "PID",
2024
                 SPR_NOACCESS, SPR_NOACCESS,
2025
                 &spr_read_generic, &spr_write_generic,
2026
                 0x00000000);
2027
    spr_register(env, SPR_40x_ZPR, "ZPR",
2028
                 SPR_NOACCESS, SPR_NOACCESS,
2029
                 &spr_read_generic, &spr_write_generic,
2030
                 0x00000000);
2031
}
2032

    
2033
/* SPR specific to PowerPC 403 implementation */
2034
static void gen_spr_403 (CPUPPCState *env)
2035
{
2036
    /* Debug interface */
2037
    /* XXX : not implemented */
2038
    spr_register(env, SPR_40x_DBCR0, "DBCR0",
2039
                 SPR_NOACCESS, SPR_NOACCESS,
2040
                 &spr_read_generic, &spr_write_40x_dbcr0,
2041
                 0x00000000);
2042
    /* XXX : not implemented */
2043
    spr_register(env, SPR_40x_DBSR, "DBSR",
2044
                 SPR_NOACCESS, SPR_NOACCESS,
2045
                 &spr_read_generic, &spr_write_clear,
2046
                 /* Last reset was system reset */
2047
                 0x00000300);
2048
    /* XXX : not implemented */
2049
    spr_register(env, SPR_40x_DAC1, "DAC1",
2050
                 SPR_NOACCESS, SPR_NOACCESS,
2051
                 &spr_read_generic, &spr_write_generic,
2052
                 0x00000000);
2053
    /* XXX : not implemented */
2054
    spr_register(env, SPR_40x_DAC2, "DAC2",
2055
                 SPR_NOACCESS, SPR_NOACCESS,
2056
                 &spr_read_generic, &spr_write_generic,
2057
                 0x00000000);
2058
    /* XXX : not implemented */
2059
    spr_register(env, SPR_40x_IAC1, "IAC1",
2060
                 SPR_NOACCESS, SPR_NOACCESS,
2061
                 &spr_read_generic, &spr_write_generic,
2062
                 0x00000000);
2063
    /* XXX : not implemented */
2064
    spr_register(env, SPR_40x_IAC2, "IAC2",
2065
                 SPR_NOACCESS, SPR_NOACCESS,
2066
                 &spr_read_generic, &spr_write_generic,
2067
                 0x00000000);
2068
}
2069

    
2070
static void gen_spr_403_real (CPUPPCState *env)
2071
{
2072
    spr_register(env, SPR_403_PBL1,  "PBL1",
2073
                 SPR_NOACCESS, SPR_NOACCESS,
2074
                 &spr_read_403_pbr, &spr_write_403_pbr,
2075
                 0x00000000);
2076
    spr_register(env, SPR_403_PBU1,  "PBU1",
2077
                 SPR_NOACCESS, SPR_NOACCESS,
2078
                 &spr_read_403_pbr, &spr_write_403_pbr,
2079
                 0x00000000);
2080
    spr_register(env, SPR_403_PBL2,  "PBL2",
2081
                 SPR_NOACCESS, SPR_NOACCESS,
2082
                 &spr_read_403_pbr, &spr_write_403_pbr,
2083
                 0x00000000);
2084
    spr_register(env, SPR_403_PBU2,  "PBU2",
2085
                 SPR_NOACCESS, SPR_NOACCESS,
2086
                 &spr_read_403_pbr, &spr_write_403_pbr,
2087
                 0x00000000);
2088
}
2089

    
2090
static void gen_spr_403_mmu (CPUPPCState *env)
2091
{
2092
    /* MMU */
2093
    spr_register(env, SPR_40x_PID, "PID",
2094
                 SPR_NOACCESS, SPR_NOACCESS,
2095
                 &spr_read_generic, &spr_write_generic,
2096
                 0x00000000);
2097
    spr_register(env, SPR_40x_ZPR, "ZPR",
2098
                 SPR_NOACCESS, SPR_NOACCESS,
2099
                 &spr_read_generic, &spr_write_generic,
2100
                 0x00000000);
2101
}
2102

    
2103
/* SPR specific to PowerPC compression coprocessor extension */
2104
static void gen_spr_compress (CPUPPCState *env)
2105
{
2106
    /* XXX : not implemented */
2107
    spr_register(env, SPR_401_SKR, "SKR",
2108
                 SPR_NOACCESS, SPR_NOACCESS,
2109
                 &spr_read_generic, &spr_write_generic,
2110
                 0x00000000);
2111
}
2112

    
2113
#if defined (TARGET_PPC64)
2114
/* SPR specific to PowerPC 620 */
2115
static void gen_spr_620 (CPUPPCState *env)
2116
{
2117
    /* XXX : not implemented */
2118
    spr_register(env, SPR_620_PMR0, "PMR0",
2119
                 SPR_NOACCESS, SPR_NOACCESS,
2120
                 &spr_read_generic, &spr_write_generic,
2121
                 0x00000000);
2122
    /* XXX : not implemented */
2123
    spr_register(env, SPR_620_PMR1, "PMR1",
2124
                 SPR_NOACCESS, SPR_NOACCESS,
2125
                 &spr_read_generic, &spr_write_generic,
2126
                 0x00000000);
2127
    /* XXX : not implemented */
2128
    spr_register(env, SPR_620_PMR2, "PMR2",
2129
                 SPR_NOACCESS, SPR_NOACCESS,
2130
                 &spr_read_generic, &spr_write_generic,
2131
                 0x00000000);
2132
    /* XXX : not implemented */
2133
    spr_register(env, SPR_620_PMR3, "PMR3",
2134
                 SPR_NOACCESS, SPR_NOACCESS,
2135
                 &spr_read_generic, &spr_write_generic,
2136
                 0x00000000);
2137
    /* XXX : not implemented */
2138
    spr_register(env, SPR_620_PMR4, "PMR4",
2139
                 SPR_NOACCESS, SPR_NOACCESS,
2140
                 &spr_read_generic, &spr_write_generic,
2141
                 0x00000000);
2142
    /* XXX : not implemented */
2143
    spr_register(env, SPR_620_PMR5, "PMR5",
2144
                 SPR_NOACCESS, SPR_NOACCESS,
2145
                 &spr_read_generic, &spr_write_generic,
2146
                 0x00000000);
2147
    /* XXX : not implemented */
2148
    spr_register(env, SPR_620_PMR6, "PMR6",
2149
                 SPR_NOACCESS, SPR_NOACCESS,
2150
                 &spr_read_generic, &spr_write_generic,
2151
                 0x00000000);
2152
    /* XXX : not implemented */
2153
    spr_register(env, SPR_620_PMR7, "PMR7",
2154
                 SPR_NOACCESS, SPR_NOACCESS,
2155
                 &spr_read_generic, &spr_write_generic,
2156
                 0x00000000);
2157
    /* XXX : not implemented */
2158
    spr_register(env, SPR_620_PMR8, "PMR8",
2159
                 SPR_NOACCESS, SPR_NOACCESS,
2160
                 &spr_read_generic, &spr_write_generic,
2161
                 0x00000000);
2162
    /* XXX : not implemented */
2163
    spr_register(env, SPR_620_PMR9, "PMR9",
2164
                 SPR_NOACCESS, SPR_NOACCESS,
2165
                 &spr_read_generic, &spr_write_generic,
2166
                 0x00000000);
2167
    /* XXX : not implemented */
2168
    spr_register(env, SPR_620_PMRA, "PMR10",
2169
                 SPR_NOACCESS, SPR_NOACCESS,
2170
                 &spr_read_generic, &spr_write_generic,
2171
                 0x00000000);
2172
    /* XXX : not implemented */
2173
    spr_register(env, SPR_620_PMRB, "PMR11",
2174
                 SPR_NOACCESS, SPR_NOACCESS,
2175
                 &spr_read_generic, &spr_write_generic,
2176
                 0x00000000);
2177
    /* XXX : not implemented */
2178
    spr_register(env, SPR_620_PMRC, "PMR12",
2179
                 SPR_NOACCESS, SPR_NOACCESS,
2180
                 &spr_read_generic, &spr_write_generic,
2181
                 0x00000000);
2182
    /* XXX : not implemented */
2183
    spr_register(env, SPR_620_PMRD, "PMR13",
2184
                 SPR_NOACCESS, SPR_NOACCESS,
2185
                 &spr_read_generic, &spr_write_generic,
2186
                 0x00000000);
2187
    /* XXX : not implemented */
2188
    spr_register(env, SPR_620_PMRE, "PMR14",
2189
                 SPR_NOACCESS, SPR_NOACCESS,
2190
                 &spr_read_generic, &spr_write_generic,
2191
                 0x00000000);
2192
    /* XXX : not implemented */
2193
    spr_register(env, SPR_620_PMRF, "PMR15",
2194
                 SPR_NOACCESS, SPR_NOACCESS,
2195
                 &spr_read_generic, &spr_write_generic,
2196
                 0x00000000);
2197
    /* XXX : not implemented */
2198
    spr_register(env, SPR_620_HID8, "HID8",
2199
                 SPR_NOACCESS, SPR_NOACCESS,
2200
                 &spr_read_generic, &spr_write_generic,
2201
                 0x00000000);
2202
    /* XXX : not implemented */
2203
    spr_register(env, SPR_620_HID9, "HID9",
2204
                 SPR_NOACCESS, SPR_NOACCESS,
2205
                 &spr_read_generic, &spr_write_generic,
2206
                 0x00000000);
2207
}
2208
#endif /* defined (TARGET_PPC64) */
2209

    
2210
// XXX: TODO
2211
/*
2212
 * AMR     => SPR 29 (Power 2.04)
2213
 * CTRL    => SPR 136 (Power 2.04)
2214
 * CTRL    => SPR 152 (Power 2.04)
2215
 * SCOMC   => SPR 276 (64 bits ?)
2216
 * SCOMD   => SPR 277 (64 bits ?)
2217
 * TBU40   => SPR 286 (Power 2.04 hypv)
2218
 * HSPRG0  => SPR 304 (Power 2.04 hypv)
2219
 * HSPRG1  => SPR 305 (Power 2.04 hypv)
2220
 * HDSISR  => SPR 306 (Power 2.04 hypv)
2221
 * HDAR    => SPR 307 (Power 2.04 hypv)
2222
 * PURR    => SPR 309 (Power 2.04 hypv)
2223
 * HDEC    => SPR 310 (Power 2.04 hypv)
2224
 * HIOR    => SPR 311 (hypv)
2225
 * RMOR    => SPR 312 (970)
2226
 * HRMOR   => SPR 313 (Power 2.04 hypv)
2227
 * HSRR0   => SPR 314 (Power 2.04 hypv)
2228
 * HSRR1   => SPR 315 (Power 2.04 hypv)
2229
 * LPCR    => SPR 316 (970)
2230
 * LPIDR   => SPR 317 (970)
2231
 * SPEFSCR => SPR 512 (Power 2.04 emb)
2232
 * EPR     => SPR 702 (Power 2.04 emb)
2233
 * perf    => 768-783 (Power 2.04)
2234
 * perf    => 784-799 (Power 2.04)
2235
 * PPR     => SPR 896 (Power 2.04)
2236
 * EPLC    => SPR 947 (Power 2.04 emb)
2237
 * EPSC    => SPR 948 (Power 2.04 emb)
2238
 * DABRX   => 1015    (Power 2.04 hypv)
2239
 * FPECR   => SPR 1022 (?)
2240
 * ... and more (thermal management, performance counters, ...)
2241
 */
2242

    
2243
/*****************************************************************************/
2244
/* Exception vectors models                                                  */
2245
static void init_excp_4xx_real (CPUPPCState *env)
2246
{
2247
#if !defined(CONFIG_USER_ONLY)
2248
    env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000100;
2249
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2250
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2251
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2252
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2253
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2254
    env->excp_vectors[POWERPC_EXCP_PIT]      = 0x00001000;
2255
    env->excp_vectors[POWERPC_EXCP_FIT]      = 0x00001010;
2256
    env->excp_vectors[POWERPC_EXCP_WDT]      = 0x00001020;
2257
    env->excp_vectors[POWERPC_EXCP_DEBUG]    = 0x00002000;
2258
    env->excp_prefix = 0x00000000UL;
2259
    env->ivor_mask = 0x0000FFF0UL;
2260
    env->ivpr_mask = 0xFFFF0000UL;
2261
    /* Hardware reset vector */
2262
    env->hreset_vector = 0xFFFFFFFCUL;
2263
#endif
2264
}
2265

    
2266
static void init_excp_4xx_softmmu (CPUPPCState *env)
2267
{
2268
#if !defined(CONFIG_USER_ONLY)
2269
    env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000100;
2270
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2271
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2272
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2273
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2274
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2275
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2276
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2277
    env->excp_vectors[POWERPC_EXCP_PIT]      = 0x00001000;
2278
    env->excp_vectors[POWERPC_EXCP_FIT]      = 0x00001010;
2279
    env->excp_vectors[POWERPC_EXCP_WDT]      = 0x00001020;
2280
    env->excp_vectors[POWERPC_EXCP_DTLB]     = 0x00001100;
2281
    env->excp_vectors[POWERPC_EXCP_ITLB]     = 0x00001200;
2282
    env->excp_vectors[POWERPC_EXCP_DEBUG]    = 0x00002000;
2283
    env->excp_prefix = 0x00000000UL;
2284
    env->ivor_mask = 0x0000FFF0UL;
2285
    env->ivpr_mask = 0xFFFF0000UL;
2286
    /* Hardware reset vector */
2287
    env->hreset_vector = 0xFFFFFFFCUL;
2288
#endif
2289
}
2290

    
2291
static void init_excp_BookE (CPUPPCState *env)
2292
{
2293
#if !defined(CONFIG_USER_ONLY)
2294
    env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000000;
2295
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000000;
2296
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000000;
2297
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000000;
2298
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000000;
2299
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000000;
2300
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000000;
2301
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000000;
2302
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000000;
2303
    env->excp_vectors[POWERPC_EXCP_APU]      = 0x00000000;
2304
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000000;
2305
    env->excp_vectors[POWERPC_EXCP_FIT]      = 0x00000000;
2306
    env->excp_vectors[POWERPC_EXCP_WDT]      = 0x00000000;
2307
    env->excp_vectors[POWERPC_EXCP_DTLB]     = 0x00000000;
2308
    env->excp_vectors[POWERPC_EXCP_ITLB]     = 0x00000000;
2309
    env->excp_vectors[POWERPC_EXCP_DEBUG]    = 0x00000000;
2310
    env->excp_prefix = 0x00000000UL;
2311
    env->ivor_mask = 0x0000FFE0UL;
2312
    env->ivpr_mask = 0xFFFF0000UL;
2313
    /* Hardware reset vector */
2314
    env->hreset_vector = 0xFFFFFFFCUL;
2315
#endif
2316
}
2317

    
2318
static void init_excp_601 (CPUPPCState *env)
2319
{
2320
#if !defined(CONFIG_USER_ONLY)
2321
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2322
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2323
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2324
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2325
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2326
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2327
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2328
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2329
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2330
    env->excp_vectors[POWERPC_EXCP_IO]       = 0x00000A00;
2331
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2332
    env->excp_vectors[POWERPC_EXCP_RUNM]     = 0x00002000;
2333
    env->excp_prefix = 0xFFF00000UL;
2334
    /* Hardware reset vector */
2335
    env->hreset_vector = 0x00000100UL;
2336
#endif
2337
}
2338

    
2339
static void init_excp_602 (CPUPPCState *env)
2340
{
2341
#if !defined(CONFIG_USER_ONLY)
2342
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2343
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2344
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2345
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2346
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2347
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2348
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2349
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2350
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2351
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2352
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2353
    env->excp_vectors[POWERPC_EXCP_FPA]      = 0x00000E00;
2354
    env->excp_vectors[POWERPC_EXCP_IFTLB]    = 0x00001000;
2355
    env->excp_vectors[POWERPC_EXCP_DLTLB]    = 0x00001100;
2356
    env->excp_vectors[POWERPC_EXCP_DSTLB]    = 0x00001200;
2357
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2358
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2359
    env->excp_vectors[POWERPC_EXCP_WDT]      = 0x00001500;
2360
    env->excp_vectors[POWERPC_EXCP_EMUL]     = 0x00001600;
2361
    env->excp_prefix = 0xFFF00000UL;
2362
    /* Hardware reset vector */
2363
    env->hreset_vector = 0xFFFFFFFCUL;
2364
#endif
2365
}
2366

    
2367
static void init_excp_603 (CPUPPCState *env)
2368
{
2369
#if !defined(CONFIG_USER_ONLY)
2370
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2371
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2372
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2373
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2374
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2375
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2376
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2377
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2378
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2379
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2380
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2381
    env->excp_vectors[POWERPC_EXCP_IFTLB]    = 0x00001000;
2382
    env->excp_vectors[POWERPC_EXCP_DLTLB]    = 0x00001100;
2383
    env->excp_vectors[POWERPC_EXCP_DSTLB]    = 0x00001200;
2384
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2385
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2386
    env->excp_prefix = 0x00000000UL;
2387
    /* Hardware reset vector */
2388
    env->hreset_vector = 0xFFFFFFFCUL;
2389
#endif
2390
}
2391

    
2392
static void init_excp_G2 (CPUPPCState *env)
2393
{
2394
#if !defined(CONFIG_USER_ONLY)
2395
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2396
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2397
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2398
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2399
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2400
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2401
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2402
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2403
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2404
    env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000A00;
2405
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2406
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2407
    env->excp_vectors[POWERPC_EXCP_IFTLB]    = 0x00001000;
2408
    env->excp_vectors[POWERPC_EXCP_DLTLB]    = 0x00001100;
2409
    env->excp_vectors[POWERPC_EXCP_DSTLB]    = 0x00001200;
2410
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2411
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2412
    env->excp_prefix = 0x00000000UL;
2413
    /* Hardware reset vector */
2414
    env->hreset_vector = 0xFFFFFFFCUL;
2415
#endif
2416
}
2417

    
2418
static void init_excp_604 (CPUPPCState *env)
2419
{
2420
#if !defined(CONFIG_USER_ONLY)
2421
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2422
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2423
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2424
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2425
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2426
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2427
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2428
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2429
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2430
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2431
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2432
    env->excp_vectors[POWERPC_EXCP_PERFM]    = 0x00000F00;
2433
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2434
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2435
    env->excp_prefix = 0x00000000UL;
2436
    /* Hardware reset vector */
2437
    env->hreset_vector = 0xFFFFFFFCUL;
2438
#endif
2439
}
2440

    
2441
#if defined(TARGET_PPC64)
2442
static void init_excp_620 (CPUPPCState *env)
2443
{
2444
#if !defined(CONFIG_USER_ONLY)
2445
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2446
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2447
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2448
    env->excp_vectors[POWERPC_EXCP_DSEG]     = 0x00000380;
2449
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2450
    env->excp_vectors[POWERPC_EXCP_ISEG]     = 0x00000480;
2451
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2452
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2453
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2454
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2455
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2456
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2457
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2458
    env->excp_vectors[POWERPC_EXCP_FPA]      = 0x00000E00;
2459
    env->excp_vectors[POWERPC_EXCP_PERFM]    = 0x00000F00;
2460
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2461
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2462
    env->excp_prefix = 0xFFF00000UL;
2463
    /* Hardware reset vector */
2464
    env->hreset_vector = 0x0000000000000100ULL;
2465
#endif
2466
}
2467
#endif /* defined(TARGET_PPC64) */
2468

    
2469
static void init_excp_7x0 (CPUPPCState *env)
2470
{
2471
#if !defined(CONFIG_USER_ONLY)
2472
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2473
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2474
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2475
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2476
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2477
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2478
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2479
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2480
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2481
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2482
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2483
    env->excp_vectors[POWERPC_EXCP_PERFM]    = 0x00000F00;
2484
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2485
    env->excp_vectors[POWERPC_EXCP_THERM]    = 0x00001700;
2486
    env->excp_prefix = 0x00000000UL;
2487
    /* Hardware reset vector */
2488
    env->hreset_vector = 0xFFFFFFFCUL;
2489
#endif
2490
}
2491

    
2492
static void init_excp_750FX (CPUPPCState *env)
2493
{
2494
#if !defined(CONFIG_USER_ONLY)
2495
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2496
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2497
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2498
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2499
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2500
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2501
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2502
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2503
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2504
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2505
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2506
    env->excp_vectors[POWERPC_EXCP_PERFM]    = 0x00000F00;
2507
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2508
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2509
    env->excp_vectors[POWERPC_EXCP_THERM]    = 0x00001700;
2510
    env->excp_prefix = 0x00000000UL;
2511
    /* Hardware reset vector */
2512
    env->hreset_vector = 0xFFFFFFFCUL;
2513
#endif
2514
}
2515

    
2516
/* XXX: Check if this is correct */
2517
static void init_excp_7x5 (CPUPPCState *env)
2518
{
2519
#if !defined(CONFIG_USER_ONLY)
2520
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2521
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2522
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2523
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2524
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2525
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2526
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2527
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2528
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2529
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2530
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2531
    env->excp_vectors[POWERPC_EXCP_IFTLB]    = 0x00001000;
2532
    env->excp_vectors[POWERPC_EXCP_DLTLB]    = 0x00001100;
2533
    env->excp_vectors[POWERPC_EXCP_DSTLB]    = 0x00001200;
2534
    env->excp_vectors[POWERPC_EXCP_PERFM]    = 0x00000F00;
2535
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2536
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2537
    env->excp_prefix = 0x00000000UL;
2538
    /* Hardware reset vector */
2539
    env->hreset_vector = 0xFFFFFFFCUL;
2540
#endif
2541
}
2542

    
2543
static void init_excp_7400 (CPUPPCState *env)
2544
{
2545
#if !defined(CONFIG_USER_ONLY)
2546
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2547
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2548
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2549
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2550
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2551
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2552
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2553
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2554
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2555
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2556
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2557
    env->excp_vectors[POWERPC_EXCP_PERFM]    = 0x00000F00;
2558
    env->excp_vectors[POWERPC_EXCP_VPU]      = 0x00000F20;
2559
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2560
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2561
    env->excp_vectors[POWERPC_EXCP_VPUA]     = 0x00001600;
2562
    env->excp_vectors[POWERPC_EXCP_THERM]    = 0x00001700;
2563
    env->excp_prefix = 0x00000000UL;
2564
    /* Hardware reset vector */
2565
    env->hreset_vector = 0xFFFFFFFCUL;
2566
#endif
2567
}
2568

    
2569
static void init_excp_7450 (CPUPPCState *env)
2570
{
2571
#if !defined(CONFIG_USER_ONLY)
2572
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2573
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2574
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2575
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2576
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2577
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2578
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2579
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2580
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2581
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2582
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2583
    env->excp_vectors[POWERPC_EXCP_PERFM]    = 0x00000F00;
2584
    env->excp_vectors[POWERPC_EXCP_VPU]      = 0x00000F20;
2585
    env->excp_vectors[POWERPC_EXCP_IFTLB]    = 0x00001000;
2586
    env->excp_vectors[POWERPC_EXCP_DLTLB]    = 0x00001100;
2587
    env->excp_vectors[POWERPC_EXCP_DSTLB]    = 0x00001200;
2588
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2589
    env->excp_vectors[POWERPC_EXCP_SMI]      = 0x00001400;
2590
    env->excp_vectors[POWERPC_EXCP_VPUA]     = 0x00001600;
2591
    env->excp_prefix = 0x00000000UL;
2592
    /* Hardware reset vector */
2593
    env->hreset_vector = 0xFFFFFFFCUL;
2594
#endif
2595
}
2596

    
2597
#if defined (TARGET_PPC64)
2598
static void init_excp_970 (CPUPPCState *env)
2599
{
2600
#if !defined(CONFIG_USER_ONLY)
2601
    env->excp_vectors[POWERPC_EXCP_RESET]    = 0x00000100;
2602
    env->excp_vectors[POWERPC_EXCP_MCHECK]   = 0x00000200;
2603
    env->excp_vectors[POWERPC_EXCP_DSI]      = 0x00000300;
2604
    env->excp_vectors[POWERPC_EXCP_DSEG]     = 0x00000380;
2605
    env->excp_vectors[POWERPC_EXCP_ISI]      = 0x00000400;
2606
    env->excp_vectors[POWERPC_EXCP_ISEG]     = 0x00000480;
2607
    env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
2608
    env->excp_vectors[POWERPC_EXCP_ALIGN]    = 0x00000600;
2609
    env->excp_vectors[POWERPC_EXCP_PROGRAM]  = 0x00000700;
2610
    env->excp_vectors[POWERPC_EXCP_FPU]      = 0x00000800;
2611
    env->excp_vectors[POWERPC_EXCP_DECR]     = 0x00000900;
2612
#if defined(TARGET_PPC64H) /* PowerPC 64 with hypervisor mode support */
2613
    env->excp_vectors[POWERPC_EXCP_HDECR]    = 0x00000980;
2614
#endif
2615
    env->excp_vectors[POWERPC_EXCP_SYSCALL]  = 0x00000C00;
2616
    env->excp_vectors[POWERPC_EXCP_TRACE]    = 0x00000D00;
2617
    env->excp_vectors[POWERPC_EXCP_PERFM]    = 0x00000F00;
2618
    env->excp_vectors[POWERPC_EXCP_VPU]      = 0x00000F20;
2619
    env->excp_vectors[POWERPC_EXCP_IABR]     = 0x00001300;
2620
    env->excp_vectors[POWERPC_EXCP_MAINT]    = 0x00001600;
2621
    env->excp_vectors[POWERPC_EXCP_VPUA]     = 0x00001700;
2622
    env->excp_vectors[POWERPC_EXCP_THERM]    = 0x00001800;
2623
    env->excp_prefix   = 0x00000000FFF00000ULL;
2624
    /* Hardware reset vector */
2625
    env->hreset_vector = 0x0000000000000100ULL;
2626
#endif
2627
}
2628
#endif
2629

    
2630
/*****************************************************************************/
2631
/* Power management enable checks                                            */
2632
static int check_pow_none (CPUPPCState *env)
2633
{
2634
    return 0;
2635
}
2636

    
2637
static int check_pow_nocheck (CPUPPCState *env)
2638
{
2639
    return 1;
2640
}
2641

    
2642
static int check_pow_hid0 (CPUPPCState *env)
2643
{
2644
    if (env->spr[SPR_HID0] & 0x00E00000)
2645
        return 1;
2646

    
2647
    return 0;
2648
}
2649

    
2650
/*****************************************************************************/
2651
/* PowerPC implementations definitions                                       */
2652

    
2653
/* PowerPC 40x instruction set                                               */
2654
#define POWERPC_INSNS_EMB    (PPC_INSNS_BASE | PPC_CACHE_DCBZ | PPC_EMB_COMMON)
2655

    
2656
/* PowerPC 401                                                               */
2657
#define POWERPC_INSNS_401    (POWERPC_INSNS_EMB |                             \
2658
                              PPC_MEM_SYNC | PPC_MEM_EIEIO |                  \
2659
                              PPC_4xx_COMMON | PPC_40x_EXCP | PPC_40x_ICBT)
2660
#define POWERPC_MSRM_401     (0x00000000000FD201ULL)
2661
#define POWERPC_MMU_401      (POWERPC_MMU_REAL_4xx)
2662
#define POWERPC_EXCP_401     (POWERPC_EXCP_40x)
2663
#define POWERPC_INPUT_401    (PPC_FLAGS_INPUT_401)
2664
#define POWERPC_BFDM_401     (bfd_mach_ppc_403)
2665
#define POWERPC_FLAG_401     (POWERPC_FLAG_CE | POWERPC_FLAG_DE)
2666
#define check_pow_401        check_pow_nocheck
2667

    
2668
static void init_proc_401 (CPUPPCState *env)
2669
{
2670
    gen_spr_40x(env);
2671
    gen_spr_401_403(env);
2672
    gen_spr_401(env);
2673
    init_excp_4xx_real(env);
2674
    env->dcache_line_size = 32;
2675
    env->icache_line_size = 32;
2676
    /* Allocate hardware IRQ controller */
2677
    ppc40x_irq_init(env);
2678
}
2679

    
2680
/* PowerPC 401x2                                                             */
2681
#define POWERPC_INSNS_401x2  (POWERPC_INSNS_EMB |                             \
2682
                              PPC_MEM_SYNC | PPC_MEM_EIEIO |                  \
2683
                              PPC_40x_TLB | PPC_MEM_TLBIA | PPC_MEM_TLBSYNC | \
2684
                              PPC_CACHE_DCBA | PPC_MFTB |                     \
2685
                              PPC_4xx_COMMON | PPC_40x_EXCP | PPC_40x_ICBT)
2686
#define POWERPC_MSRM_401x2   (0x00000000001FD231ULL)
2687
#define POWERPC_MMU_401x2    (POWERPC_MMU_SOFT_4xx_Z)
2688
#define POWERPC_EXCP_401x2   (POWERPC_EXCP_40x)
2689
#define POWERPC_INPUT_401x2  (PPC_FLAGS_INPUT_401)
2690
#define POWERPC_BFDM_401x2   (bfd_mach_ppc_403)
2691
#define POWERPC_FLAG_401x2   (POWERPC_FLAG_CE | POWERPC_FLAG_DE)
2692
#define check_pow_401x2      check_pow_nocheck
2693

    
2694
static void init_proc_401x2 (CPUPPCState *env)
2695
{
2696
    gen_spr_40x(env);
2697
    gen_spr_401_403(env);
2698
    gen_spr_401x2(env);
2699
    gen_spr_compress(env);
2700
    /* Memory management */
2701
#if !defined(CONFIG_USER_ONLY)
2702
    env->nb_tlb = 64;
2703
    env->nb_ways = 1;
2704
    env->id_tlbs = 0;
2705
#endif
2706
    init_excp_4xx_softmmu(env);
2707
    env->dcache_line_size = 32;
2708
    env->icache_line_size = 32;
2709
    /* Allocate hardware IRQ controller */
2710
    ppc40x_irq_init(env);
2711
}
2712

    
2713
/* PowerPC 401x3                                                             */
2714
#define POWERPC_INSNS_401x3  (POWERPC_INSNS_EMB |                             \
2715
                              PPC_MEM_SYNC | PPC_MEM_EIEIO |                  \
2716
                              PPC_40x_TLB | PPC_MEM_TLBIA | PPC_MEM_TLBSYNC | \
2717
                              PPC_CACHE_DCBA | PPC_MFTB |                     \
2718
                              PPC_4xx_COMMON | PPC_40x_EXCP | PPC_40x_ICBT)
2719
#define POWERPC_MSRM_401x3   (0x00000000001FD631ULL)
2720
#define POWERPC_MMU_401x3    (POWERPC_MMU_SOFT_4xx_Z)
2721
#define POWERPC_EXCP_401x3   (POWERPC_EXCP_40x)
2722
#define POWERPC_INPUT_401x3  (PPC_FLAGS_INPUT_401)
2723
#define POWERPC_BFDM_401x3   (bfd_mach_ppc_403)
2724
#define POWERPC_FLAG_401x3   (POWERPC_FLAG_CE | POWERPC_FLAG_DE)
2725
#define check_pow_401x3      check_pow_nocheck
2726

    
2727
__attribute__ (( unused ))
2728
static void init_proc_401x3 (CPUPPCState *env)
2729
{
2730
    gen_spr_40x(env);
2731
    gen_spr_401_403(env);
2732
    gen_spr_401(env);
2733
    gen_spr_401x2(env);
2734
    gen_spr_compress(env);
2735
    init_excp_4xx_softmmu(env);
2736
    env->dcache_line_size = 32;
2737
    env->icache_line_size = 32;
2738
    /* Allocate hardware IRQ controller */
2739
    ppc40x_irq_init(env);
2740
}
2741

    
2742
/* IOP480                                                                    */
2743
#define POWERPC_INSNS_IOP480 (POWERPC_INSNS_EMB |                             \
2744
                              PPC_MEM_SYNC | PPC_MEM_EIEIO |                  \
2745
                              PPC_40x_TLB | PPC_MEM_TLBIA | PPC_MEM_TLBSYNC | \
2746
                              PPC_CACHE_DCBA |                                \
2747
                              PPC_4xx_COMMON | PPC_40x_EXCP |  PPC_40x_ICBT)
2748
#define POWERPC_MSRM_IOP480  (0x00000000001FD231ULL)
2749
#define POWERPC_MMU_IOP480   (POWERPC_MMU_SOFT_4xx_Z)
2750
#define POWERPC_EXCP_IOP480  (POWERPC_EXCP_40x)
2751
#define POWERPC_INPUT_IOP480 (PPC_FLAGS_INPUT_401)
2752
#define POWERPC_BFDM_IOP480  (bfd_mach_ppc_403)
2753
#define POWERPC_FLAG_IOP480  (POWERPC_FLAG_CE | POWERPC_FLAG_DE)
2754
#define check_pow_IOP480     check_pow_nocheck
2755

    
2756
static void init_proc_IOP480 (CPUPPCState *env)
2757
{
2758
    gen_spr_40x(env);
2759
    gen_spr_401_403(env);
2760
    gen_spr_401x2(env);
2761
    gen_spr_compress(env);
2762
    /* Memory management */
2763
#if !defined(CONFIG_USER_ONLY)
2764
    env->nb_tlb = 64;
2765
    env->nb_ways = 1;
2766
    env->id_tlbs = 0;
2767
#endif
2768
    init_excp_4xx_softmmu(env);
2769
    env->dcache_line_size = 32;
2770
    env->icache_line_size = 32;
2771
    /* Allocate hardware IRQ controller */
2772
    ppc40x_irq_init(env);
2773
}
2774

    
2775
/* PowerPC 403                                                               */
2776
#define POWERPC_INSNS_403    (POWERPC_INSNS_EMB |                             \
2777
                              PPC_MEM_SYNC | PPC_MEM_EIEIO |                  \
2778
                              PPC_4xx_COMMON | PPC_40x_EXCP | PPC_40x_ICBT)
2779
#define POWERPC_MSRM_403     (0x000000000007D00DULL)
2780
#define POWERPC_MMU_403      (POWERPC_MMU_REAL_4xx)
2781
#define POWERPC_EXCP_403     (POWERPC_EXCP_40x)
2782
#define POWERPC_INPUT_403    (PPC_FLAGS_INPUT_401)
2783
#define POWERPC_BFDM_403     (bfd_mach_ppc_403)
2784
#define POWERPC_FLAG_403     (POWERPC_FLAG_CE | POWERPC_FLAG_PX)
2785
#define check_pow_403        check_pow_nocheck
2786

    
2787
static void init_proc_403 (CPUPPCState *env)
2788
{
2789
    gen_spr_40x(env);
2790
    gen_spr_401_403(env);
2791
    gen_spr_403(env);
2792
    gen_spr_403_real(env);
2793
    init_excp_4xx_real(env);
2794
    env->dcache_line_size = 32;
2795
    env->icache_line_size = 32;
2796
    /* Allocate hardware IRQ controller */
2797
    ppc40x_irq_init(env);
2798
#if !defined(CONFIG_USER_ONLY)
2799
    /* Hardware reset vector */
2800
    env->hreset_vector = 0xFFFFFFFCUL;
2801
#endif
2802
}
2803

    
2804
/* PowerPC 403 GCX                                                           */
2805
#define POWERPC_INSNS_403GCX (POWERPC_INSNS_EMB |                             \
2806
                              PPC_MEM_SYNC | PPC_MEM_EIEIO |                  \
2807
                              PPC_40x_TLB | PPC_MEM_TLBIA | PPC_MEM_TLBSYNC | \
2808
                              PPC_4xx_COMMON | PPC_40x_EXCP | PPC_40x_ICBT)
2809
#define POWERPC_MSRM_403GCX  (0x000000000007D00DULL)
2810
#define POWERPC_MMU_403GCX   (POWERPC_MMU_SOFT_4xx_Z)
2811
#define POWERPC_EXCP_403GCX  (POWERPC_EXCP_40x)
2812
#define POWERPC_INPUT_403GCX (PPC_FLAGS_INPUT_401)
2813
#define POWERPC_BFDM_403GCX  (bfd_mach_ppc_403)
2814
#define POWERPC_FLAG_403GCX  (POWERPC_FLAG_CE | POWERPC_FLAG_PX)
2815
#define check_pow_403GCX     check_pow_nocheck
2816

    
2817
static void init_proc_403GCX (CPUPPCState *env)
2818
{
2819
    gen_spr_40x(env);
2820
    gen_spr_401_403(env);
2821
    gen_spr_403(env);
2822
    gen_spr_403_real(env);
2823
    gen_spr_403_mmu(env);
2824
    /* Bus access control */
2825
    /* not emulated, as Qemu never does speculative access */
2826
    spr_register(env, SPR_40x_SGR, "SGR",
2827
                 SPR_NOACCESS, SPR_NOACCESS,
2828
                 &spr_read_generic, &spr_write_generic,
2829
                 0xFFFFFFFF);
2830
    /* not emulated, as Qemu do not emulate caches */
2831
    spr_register(env, SPR_40x_DCWR, "DCWR",
2832
                 SPR_NOACCESS, SPR_NOACCESS,
2833
                 &spr_read_generic, &spr_write_generic,
2834
                 0x00000000);
2835
    /* Memory management */
2836
#if !defined(CONFIG_USER_ONLY)
2837
    env->nb_tlb = 64;
2838
    env->nb_ways = 1;
2839
    env->id_tlbs = 0;
2840
#endif
2841
    init_excp_4xx_softmmu(env);
2842
    env->dcache_line_size = 32;
2843
    env->icache_line_size = 32;
2844
    /* Allocate hardware IRQ controller */
2845
    ppc40x_irq_init(env);
2846
}
2847

    
2848
/* PowerPC 405                                                               */
2849
#define POWERPC_INSNS_405    (POWERPC_INSNS_EMB | PPC_MFTB |                  \
2850
                              PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_CACHE_DCBA | \
2851
                              PPC_40x_TLB | PPC_MEM_TLBIA | PPC_MEM_TLBSYNC | \
2852
                              PPC_4xx_COMMON | PPC_40x_EXCP | PPC_40x_ICBT |  \
2853
                              PPC_405_MAC)
2854
#define POWERPC_MSRM_405     (0x000000000006E630ULL)
2855
#define POWERPC_MMU_405      (POWERPC_MMU_SOFT_4xx)
2856
#define POWERPC_EXCP_405     (POWERPC_EXCP_40x)
2857
#define POWERPC_INPUT_405    (PPC_FLAGS_INPUT_405)
2858
#define POWERPC_BFDM_405     (bfd_mach_ppc_403)
2859
#define POWERPC_FLAG_405     (POWERPC_FLAG_CE | POWERPC_FLAG_DWE |            \
2860
                              POWERPC_FLAG_DE)
2861
#define check_pow_405        check_pow_nocheck
2862

    
2863
static void init_proc_405 (CPUPPCState *env)
2864
{
2865
    /* Time base */
2866
    gen_tbl(env);
2867
    gen_spr_40x(env);
2868
    gen_spr_405(env);
2869
    /* Bus access control */
2870
    /* not emulated, as Qemu never does speculative access */
2871
    spr_register(env, SPR_40x_SGR, "SGR",
2872
                 SPR_NOACCESS, SPR_NOACCESS,
2873
                 &spr_read_generic, &spr_write_generic,
2874
                 0xFFFFFFFF);
2875
    /* not emulated, as Qemu do not emulate caches */
2876
    spr_register(env, SPR_40x_DCWR, "DCWR",
2877
                 SPR_NOACCESS, SPR_NOACCESS,
2878
                 &spr_read_generic, &spr_write_generic,
2879
                 0x00000000);
2880
    /* Memory management */
2881
#if !defined(CONFIG_USER_ONLY)
2882
    env->nb_tlb = 64;
2883
    env->nb_ways = 1;
2884
    env->id_tlbs = 0;
2885
#endif
2886
    init_excp_4xx_softmmu(env);
2887
    env->dcache_line_size = 32;
2888
    env->icache_line_size = 32;
2889
    /* Allocate hardware IRQ controller */
2890
    ppc40x_irq_init(env);
2891
}
2892

    
2893
/* PowerPC 440 EP                                                            */
2894
#define POWERPC_INSNS_440EP  (POWERPC_INSNS_EMB |                             \
2895
                              PPC_CACHE_DCBA | PPC_MEM_TLBSYNC |              \
2896
                              PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC |      \
2897
                              PPC_440_SPEC | PPC_RFMCI)
2898
#define POWERPC_MSRM_440EP   (0x000000000006D630ULL)
2899
#define POWERPC_MMU_440EP    (POWERPC_MMU_BOOKE)
2900
#define POWERPC_EXCP_440EP   (POWERPC_EXCP_BOOKE)
2901
#define POWERPC_INPUT_440EP  (PPC_FLAGS_INPUT_BookE)
2902
#define POWERPC_BFDM_440EP   (bfd_mach_ppc_403)
2903
#define POWERPC_FLAG_440EP   (POWERPC_FLAG_CE | POWERPC_FLAG_DWE |            \
2904
                              POWERPC_FLAG_DE)
2905
#define check_pow_440EP      check_pow_nocheck
2906

    
2907
static void init_proc_440EP (CPUPPCState *env)
2908
{
2909
    /* Time base */
2910
    gen_tbl(env);
2911
    gen_spr_BookE(env);
2912
    gen_spr_440(env);
2913
    /* XXX : not implemented */
2914
    spr_register(env, SPR_BOOKE_MCSR, "MCSR",
2915
                 SPR_NOACCESS, SPR_NOACCESS,
2916
                 &spr_read_generic, &spr_write_generic,
2917
                 0x00000000);
2918
    spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0",
2919
                 SPR_NOACCESS, SPR_NOACCESS,
2920
                 &spr_read_generic, &spr_write_generic,
2921
                 0x00000000);
2922
    spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1",
2923
                 SPR_NOACCESS, SPR_NOACCESS,
2924
                 &spr_read_generic, &spr_write_generic,
2925
                 0x00000000);
2926
    /* XXX : not implemented */
2927
    spr_register(env, SPR_440_CCR1, "CCR1",
2928
                 SPR_NOACCESS, SPR_NOACCESS,
2929
                 &spr_read_generic, &spr_write_generic,
2930
                 0x00000000);
2931
    /* Memory management */
2932
#if !defined(CONFIG_USER_ONLY)
2933
    env->nb_tlb = 64;
2934
    env->nb_ways = 1;
2935
    env->id_tlbs = 0;
2936
#endif
2937
    init_excp_BookE(env);
2938
    env->dcache_line_size = 32;
2939
    env->icache_line_size = 32;
2940
    /* XXX: TODO: allocate internal IRQ controller */
2941
}
2942

    
2943
/* PowerPC 440 GP                                                            */
2944
#define POWERPC_INSNS_440GP  (POWERPC_INSNS_EMB |                             \
2945
                              PPC_CACHE_DCBA | PPC_MEM_TLBSYNC |              \
2946
                              PPC_BOOKE | PPC_BOOKE_EXT | PPC_4xx_COMMON |    \
2947
                              PPC_405_MAC | PPC_440_SPEC)
2948
#define POWERPC_MSRM_440GP   (0x000000000006FF30ULL)
2949
#define POWERPC_MMU_440GP    (POWERPC_MMU_BOOKE)
2950
#define POWERPC_EXCP_440GP   (POWERPC_EXCP_BOOKE)
2951
#define POWERPC_INPUT_440GP  (PPC_FLAGS_INPUT_BookE)
2952
#define POWERPC_BFDM_440GP   (bfd_mach_ppc_403)
2953
#define POWERPC_FLAG_440GP   (POWERPC_FLAG_CE | POWERPC_FLAG_DWE |            \
2954
                              POWERPC_FLAG_DE)
2955
#define check_pow_440GP      check_pow_nocheck
2956

    
2957
static void init_proc_440GP (CPUPPCState *env)
2958
{
2959
    /* Time base */
2960
    gen_tbl(env);
2961
    gen_spr_BookE(env);
2962
    gen_spr_440(env);
2963
    /* Memory management */
2964
#if !defined(CONFIG_USER_ONLY)
2965
    env->nb_tlb = 64;
2966
    env->nb_ways = 1;
2967
    env->id_tlbs = 0;
2968
#endif
2969
    init_excp_BookE(env);
2970
    env->dcache_line_size = 32;
2971
    env->icache_line_size = 32;
2972
    /* XXX: TODO: allocate internal IRQ controller */
2973
}
2974

    
2975
/* PowerPC 440x4                                                             */
2976
#define POWERPC_INSNS_440x4  (POWERPC_INSNS_EMB |                             \
2977
                              PPC_CACHE_DCBA | PPC_MEM_TLBSYNC |              \
2978
                              PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC |      \
2979
                              PPC_440_SPEC)
2980
#define POWERPC_MSRM_440x4   (0x000000000006FF30ULL)
2981
#define POWERPC_MMU_440x4    (POWERPC_MMU_BOOKE)
2982
#define POWERPC_EXCP_440x4   (POWERPC_EXCP_BOOKE)
2983
#define POWERPC_INPUT_440x4  (PPC_FLAGS_INPUT_BookE)
2984
#define POWERPC_BFDM_440x4   (bfd_mach_ppc_403)
2985
#define POWERPC_FLAG_440x4   (POWERPC_FLAG_CE | POWERPC_FLAG_DWE |            \
2986
                              POWERPC_FLAG_DE)
2987
#define check_pow_440x4      check_pow_nocheck
2988

    
2989
__attribute__ (( unused ))
2990
static void init_proc_440x4 (CPUPPCState *env)
2991
{
2992
    /* Time base */
2993
    gen_tbl(env);
2994
    gen_spr_BookE(env);
2995
    gen_spr_440(env);
2996
    /* Memory management */
2997
#if !defined(CONFIG_USER_ONLY)
2998
    env->nb_tlb = 64;
2999
    env->nb_ways = 1;
3000
    env->id_tlbs = 0;
3001
#endif
3002
    init_excp_BookE(env);
3003
    env->dcache_line_size = 32;
3004
    env->icache_line_size = 32;
3005
    /* XXX: TODO: allocate internal IRQ controller */
3006
}
3007

    
3008
/* PowerPC 440x5                                                             */
3009
#define POWERPC_INSNS_440x5  (POWERPC_INSNS_EMB |                             \
3010
                              PPC_CACHE_DCBA | PPC_MEM_TLBSYNC |              \
3011
                              PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC |      \
3012
                              PPC_440_SPEC | PPC_RFMCI)
3013
#define POWERPC_MSRM_440x5   (0x000000000006FF30ULL)
3014
#define POWERPC_MMU_440x5    (POWERPC_MMU_BOOKE)
3015
#define POWERPC_EXCP_440x5   (POWERPC_EXCP_BOOKE)
3016
#define POWERPC_INPUT_440x5  (PPC_FLAGS_INPUT_BookE)
3017
#define POWERPC_BFDM_440x5   (bfd_mach_ppc_403)
3018
#define POWERPC_FLAG_440x5   (POWERPC_FLAG_CE | POWERPC_FLAG_DWE |           \
3019
                              POWERPC_FLAG_DE)
3020
#define check_pow_440x5      check_pow_nocheck
3021

    
3022
static void init_proc_440x5 (CPUPPCState *env)
3023
{
3024
    /* Time base */
3025
    gen_tbl(env);
3026
    gen_spr_BookE(env);
3027
    gen_spr_440(env);
3028
    /* XXX : not implemented */
3029
    spr_register(env, SPR_BOOKE_MCSR, "MCSR",
3030
                 SPR_NOACCESS, SPR_NOACCESS,
3031
                 &spr_read_generic, &spr_write_generic,
3032
                 0x00000000);
3033
    spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0",
3034
                 SPR_NOACCESS, SPR_NOACCESS,
3035
                 &spr_read_generic, &spr_write_generic,
3036
                 0x00000000);
3037
    spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1",
3038
                 SPR_NOACCESS, SPR_NOACCESS,
3039
                 &spr_read_generic, &spr_write_generic,
3040
                 0x00000000);
3041
    /* XXX : not implemented */
3042
    spr_register(env, SPR_440_CCR1, "CCR1",
3043
                 SPR_NOACCESS, SPR_NOACCESS,
3044
                 &spr_read_generic, &spr_write_generic,
3045
                 0x00000000);
3046
    /* Memory management */
3047
#if !defined(CONFIG_USER_ONLY)
3048
    env->nb_tlb = 64;
3049
    env->nb_ways = 1;
3050
    env->id_tlbs = 0;
3051
#endif
3052
    init_excp_BookE(env);
3053
    env->dcache_line_size = 32;
3054
    env->icache_line_size = 32;
3055
    /* XXX: TODO: allocate internal IRQ controller */
3056
}
3057

    
3058
/* PowerPC 460 (guessed)                                                     */
3059
#define POWERPC_INSNS_460    (POWERPC_INSNS_EMB |                             \
3060
                              PPC_CACHE_DCBA | PPC_MEM_TLBSYNC |              \
3061
                              PPC_BOOKE | PPC_BOOKE_EXT | PPC_4xx_COMMON |    \
3062
                              PPC_405_MAC | PPC_440_SPEC | PPC_DCRUX)
3063
#define POWERPC_MSRM_460     (0x000000000006FF30ULL)
3064
#define POWERPC_MMU_460      (POWERPC_MMU_BOOKE)
3065
#define POWERPC_EXCP_460     (POWERPC_EXCP_BOOKE)
3066
#define POWERPC_INPUT_460    (PPC_FLAGS_INPUT_BookE)
3067
#define POWERPC_BFDM_460     (bfd_mach_ppc_403)
3068
#define POWERPC_FLAG_460     (POWERPC_FLAG_CE | POWERPC_FLAG_DWE |            \
3069
                              POWERPC_FLAG_DE)
3070
#define check_pow_460        check_pow_nocheck
3071

    
3072
__attribute__ (( unused ))
3073
static void init_proc_460 (CPUPPCState *env)
3074
{
3075
    /* Time base */
3076
    gen_tbl(env);
3077
    gen_spr_BookE(env);
3078
    gen_spr_440(env);
3079
    /* XXX : not implemented */
3080
    spr_register(env, SPR_BOOKE_MCSR, "MCSR",
3081
                 SPR_NOACCESS, SPR_NOACCESS,
3082
                 &spr_read_generic, &spr_write_generic,
3083
                 0x00000000);
3084
    spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0",
3085
                 SPR_NOACCESS, SPR_NOACCESS,
3086
                 &spr_read_generic, &spr_write_generic,
3087
                 0x00000000);
3088
    spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1",
3089
                 SPR_NOACCESS, SPR_NOACCESS,
3090
                 &spr_read_generic, &spr_write_generic,
3091
                 0x00000000);
3092
    /* XXX : not implemented */
3093
    spr_register(env, SPR_440_CCR1, "CCR1",
3094
                 SPR_NOACCESS, SPR_NOACCESS,
3095
                 &spr_read_generic, &spr_write_generic,
3096
                 0x00000000);
3097
    /* XXX : not implemented */
3098
    spr_register(env, SPR_DCRIPR, "SPR_DCRIPR",
3099
                 &spr_read_generic, &spr_write_generic,
3100
                 &spr_read_generic, &spr_write_generic,
3101
                 0x00000000);
3102
    /* Memory management */
3103
#if !defined(CONFIG_USER_ONLY)
3104
    env->nb_tlb = 64;
3105
    env->nb_ways = 1;
3106
    env->id_tlbs = 0;
3107
#endif
3108
    init_excp_BookE(env);
3109
    env->dcache_line_size = 32;
3110
    env->icache_line_size = 32;
3111
    /* XXX: TODO: allocate internal IRQ controller */
3112
}
3113

    
3114
/* PowerPC 460F (guessed)                                                    */
3115
#define POWERPC_INSNS_460F   (POWERPC_INSNS_EMB |                             \
3116
                              PPC_CACHE_DCBA | PPC_MEM_TLBSYNC |              \
3117
                              PPC_FLOAT | PPC_FLOAT_FSQRT | PPC_FLOAT_FRES |  \
3118
                              PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL |            \
3119
                              PPC_FLOAT_STFIWX |                              \
3120
                              PPC_BOOKE | PPC_BOOKE_EXT | PPC_4xx_COMMON |    \
3121
                              PPC_405_MAC | PPC_440_SPEC | PPC_DCRUX)
3122
#define POWERPC_MSRM_460     (0x000000000006FF30ULL)
3123
#define POWERPC_MMU_460F     (POWERPC_MMU_BOOKE)
3124
#define POWERPC_EXCP_460F    (POWERPC_EXCP_BOOKE)
3125
#define POWERPC_INPUT_460F   (PPC_FLAGS_INPUT_BookE)
3126
#define POWERPC_BFDM_460F    (bfd_mach_ppc_403)
3127
#define POWERPC_FLAG_460F    (POWERPC_FLAG_CE | POWERPC_FLAG_DWE |            \
3128
                              POWERPC_FLAG_DE)
3129
#define check_pow_460F       check_pow_nocheck
3130

    
3131
__attribute__ (( unused ))
3132
static void init_proc_460F (CPUPPCState *env)
3133
{
3134
    /* Time base */
3135
    gen_tbl(env);
3136
    gen_spr_BookE(env);
3137
    gen_spr_440(env);
3138
    /* XXX : not implemented */
3139
    spr_register(env, SPR_BOOKE_MCSR, "MCSR",
3140
                 SPR_NOACCESS, SPR_NOACCESS,
3141
                 &spr_read_generic, &spr_write_generic,
3142
                 0x00000000);
3143
    spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0",
3144
                 SPR_NOACCESS, SPR_NOACCESS,
3145
                 &spr_read_generic, &spr_write_generic,
3146
                 0x00000000);
3147
    spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1",
3148
                 SPR_NOACCESS, SPR_NOACCESS,
3149
                 &spr_read_generic, &spr_write_generic,
3150
                 0x00000000);
3151
    /* XXX : not implemented */
3152
    spr_register(env, SPR_440_CCR1, "CCR1",
3153
                 SPR_NOACCESS, SPR_NOACCESS,
3154
                 &spr_read_generic, &spr_write_generic,
3155
                 0x00000000);
3156
    /* XXX : not implemented */
3157
    spr_register(env, SPR_DCRIPR, "SPR_DCRIPR",
3158
                 &spr_read_generic, &spr_write_generic,
3159
                 &spr_read_generic, &spr_write_generic,
3160
                 0x00000000);
3161
    /* Memory management */
3162
#if !defined(CONFIG_USER_ONLY)
3163
    env->nb_tlb = 64;
3164
    env->nb_ways = 1;
3165
    env->id_tlbs = 0;
3166
#endif
3167
    init_excp_BookE(env);
3168
    env->dcache_line_size = 32;
3169
    env->icache_line_size = 32;
3170
    /* XXX: TODO: allocate internal IRQ controller */
3171
}
3172

    
3173
/* Generic BookE PowerPC                                                     */
3174
#define POWERPC_INSNS_BookE  (POWERPC_INSNS_EMB |                             \
3175
                              PPC_MEM_EIEIO | PPC_MEM_TLBSYNC |               \
3176
                              PPC_CACHE_DCBA |                                \
3177
                              PPC_FLOAT | PPC_FLOAT_FSQRT |                   \
3178
                              PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE |            \
3179
                              PPC_FLOAT_FSEL | PPC_FLOAT_STFIW |              \
3180
                              PPC_BOOKE)
3181
#define POWERPC_MSRM_BookE   (0x000000000006D630ULL)
3182
#define POWERPC_MMU_BookE    (POWERPC_MMU_BOOKE)
3183
#define POWERPC_EXCP_BookE   (POWERPC_EXCP_BOOKE)
3184
#define POWERPC_INPUT_BookE  (PPC_FLAGS_INPUT_BookE)
3185
#define POWERPC_BFDM_BookE   (bfd_mach_ppc_403)
3186
#define POWERPC_FLAG_BookE   (POWERPC_FLAG_NONE)
3187
#define check_pow_BookE      check_pow_nocheck
3188

    
3189
__attribute__ (( unused ))
3190
static void init_proc_BookE (CPUPPCState *env)
3191
{
3192
    init_excp_BookE(env);
3193
    env->dcache_line_size = 32;
3194
    env->icache_line_size = 32;
3195
}
3196

    
3197
/* e200 core                                                                 */
3198

    
3199
/* e300 core                                                                 */
3200

    
3201
/* e500 core                                                                 */
3202
#define POWERPC_INSNS_e500   (POWERPC_INSNS_EMB |                             \
3203
                              PPC_MEM_EIEIO | PPC_MEM_TLBSYNC |               \
3204
                              PPC_CACHE_DCBA |                                \
3205
                              PPC_BOOKE | PPC_E500_VECTOR)
3206
#define POWERPC_MMU_e500     (POWERPC_MMU_SOFT_4xx)
3207
#define POWERPC_EXCP_e500    (POWERPC_EXCP_40x)
3208
#define POWERPC_INPUT_e500   (PPC_FLAGS_INPUT_BookE)
3209
#define POWERPC_BFDM_e500    (bfd_mach_ppc_403)
3210
#define POWERPC_FLAG_e500    (POWERPC_FLAG_SPE)
3211
#define check_pow_e500       check_pow_hid0
3212

    
3213
__attribute__ (( unused ))
3214
static void init_proc_e500 (CPUPPCState *env)
3215
{
3216
    /* Time base */
3217
    gen_tbl(env);
3218
    gen_spr_BookE(env);
3219
    /* Memory management */
3220
    gen_spr_BookE_FSL(env);
3221
#if !defined(CONFIG_USER_ONLY)
3222
    env->nb_tlb = 64;
3223
    env->nb_ways = 1;
3224
    env->id_tlbs = 0;
3225
#endif
3226
    init_excp_BookE(env);
3227
    env->dcache_line_size = 32;
3228
    env->icache_line_size = 32;
3229
    /* XXX: TODO: allocate internal IRQ controller */
3230
}
3231

    
3232
/* e600 core                                                                 */
3233

    
3234
/* Non-embedded PowerPC                                                      */
3235
/* Base instructions set for all 6xx/7xx/74xx/970 PowerPC                    */
3236
#define POWERPC_INSNS_6xx    (PPC_INSNS_BASE | PPC_FLOAT | PPC_MEM_SYNC |     \
3237
                              PPC_MEM_EIEIO | PPC_MEM_TLBIE)
3238
/* Instructions common to all 6xx/7xx/74xx/970 PowerPC except 601 & 602      */
3239
#define POWERPC_INSNS_WORKS  (POWERPC_INSNS_6xx | PPC_FLOAT_FSQRT |           \
3240
                              PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE |            \
3241
                              PPC_FLOAT_FSEL | PPC_FLOAT_STFIWX |             \
3242
                              PPC_MEM_TLBSYNC | PPC_CACHE_DCBZ | PPC_MFTB |   \
3243
                              PPC_SEGMENT)
3244

    
3245
/* POWER : same as 601, without mfmsr, mfsr                                  */
3246
#if defined(TODO)
3247
#define POWERPC_INSNS_POWER  (XXX_TODO)
3248
/* POWER RSC (from RAD6000) */
3249
#define POWERPC_MSRM_POWER   (0x00000000FEF0ULL)
3250
#endif /* TODO */
3251

    
3252
/* PowerPC 601                                                               */
3253
#define POWERPC_INSNS_601    (POWERPC_INSNS_6xx | PPC_CACHE_DCBZ |            \
3254
                              PPC_SEGMENT | PPC_EXTERN | PPC_POWER_BR)
3255
#define POWERPC_MSRM_601     (0x000000000000FD70ULL)
3256
//#define POWERPC_MMU_601      (POWERPC_MMU_601)
3257
//#define POWERPC_EXCP_601     (POWERPC_EXCP_601)
3258
#define POWERPC_INPUT_601    (PPC_FLAGS_INPUT_6xx)
3259
#define POWERPC_BFDM_601     (bfd_mach_ppc_601)
3260
#define POWERPC_FLAG_601     (POWERPC_FLAG_SE)
3261
#define check_pow_601        check_pow_none
3262

    
3263
static void init_proc_601 (CPUPPCState *env)
3264
{
3265
    gen_spr_ne_601(env);
3266
    gen_spr_601(env);
3267
    /* Hardware implementation registers */
3268
    /* XXX : not implemented */
3269
    spr_register(env, SPR_HID0, "HID0",
3270
                 SPR_NOACCESS, SPR_NOACCESS,
3271
                 &spr_read_generic, &spr_write_hid0_601,
3272
                 0x80010080);
3273
    /* XXX : not implemented */
3274
    spr_register(env, SPR_HID1, "HID1",
3275
                 SPR_NOACCESS, SPR_NOACCESS,
3276
                 &spr_read_generic, &spr_write_generic,
3277
                 0x00000000);
3278
    /* XXX : not implemented */
3279
    spr_register(env, SPR_601_HID2, "HID2",
3280
                 SPR_NOACCESS, SPR_NOACCESS,
3281
                 &spr_read_generic, &spr_write_generic,
3282
                 0x00000000);
3283
    /* XXX : not implemented */
3284
    spr_register(env, SPR_601_HID5, "HID5",
3285
                 SPR_NOACCESS, SPR_NOACCESS,
3286
                 &spr_read_generic, &spr_write_generic,
3287
                 0x00000000);
3288
    /* XXX : not implemented */
3289
    spr_register(env, SPR_601_HID15, "HID15",
3290
                 SPR_NOACCESS, SPR_NOACCESS,
3291
                 &spr_read_generic, &spr_write_generic,
3292
                 0x00000000);
3293
    /* Memory management */
3294
#if !defined(CONFIG_USER_ONLY)
3295
    env->nb_tlb = 64;
3296
    env->nb_ways = 2;
3297
    env->id_tlbs = 0;
3298
#endif
3299
    init_excp_601(env);
3300
    env->dcache_line_size = 64;
3301
    env->icache_line_size = 64;
3302
    /* Allocate hardware IRQ controller */
3303
    ppc6xx_irq_init(env);
3304
}
3305

    
3306
/* PowerPC 602                                                               */
3307
#define POWERPC_INSNS_602    (POWERPC_INSNS_6xx | PPC_MFTB |                  \
3308
                              PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE |            \
3309
                              PPC_FLOAT_FSEL | PPC_FLOAT_STFIWX |             \
3310
                              PPC_6xx_TLB | PPC_MEM_TLBSYNC | PPC_CACHE_DCBZ |\
3311
                              PPC_SEGMENT | PPC_602_SPEC)
3312
#define POWERPC_MSRM_602     (0x000000000033FF73ULL)
3313
#define POWERPC_MMU_602      (POWERPC_MMU_SOFT_6xx)
3314
//#define POWERPC_EXCP_602     (POWERPC_EXCP_602)
3315
#define POWERPC_INPUT_602    (PPC_FLAGS_INPUT_6xx)
3316
#define POWERPC_BFDM_602     (bfd_mach_ppc_602)
3317
#define POWERPC_FLAG_602     (POWERPC_FLAG_TGPR | POWERPC_FLAG_SE |           \
3318
                              POWERPC_FLAG_BE)
3319
#define check_pow_602        check_pow_hid0
3320

    
3321
static void init_proc_602 (CPUPPCState *env)
3322
{
3323
    gen_spr_ne_601(env);
3324
    gen_spr_602(env);
3325
    /* Time base */
3326
    gen_tbl(env);
3327
    /* hardware implementation registers */
3328
    /* XXX : not implemented */
3329
    spr_register(env, SPR_HID0, "HID0",
3330
                 SPR_NOACCESS, SPR_NOACCESS,
3331
                 &spr_read_generic, &spr_write_generic,
3332
                 0x00000000);
3333
    /* XXX : not implemented */
3334
    spr_register(env, SPR_HID1, "HID1",
3335
                 SPR_NOACCESS, SPR_NOACCESS,
3336
                 &spr_read_generic, &spr_write_generic,
3337
                 0x00000000);
3338
    /* Memory management */
3339
    gen_low_BATs(env);
3340
    gen_6xx_7xx_soft_tlb(env, 64, 2);
3341
    init_excp_602(env);
3342
    env->dcache_line_size = 32;
3343
    env->icache_line_size = 32;
3344
    /* Allocate hardware IRQ controller */
3345
    ppc6xx_irq_init(env);
3346
}
3347

    
3348
/* PowerPC 603                                                               */
3349
#define POWERPC_INSNS_603    (POWERPC_INSNS_WORKS | PPC_6xx_TLB | PPC_EXTERN)
3350
#define POWERPC_MSRM_603     (0x000000000007FF73ULL)
3351
#define POWERPC_MMU_603      (POWERPC_MMU_SOFT_6xx)
3352
//#define POWERPC_EXCP_603     (POWERPC_EXCP_603)
3353
#define POWERPC_INPUT_603    (PPC_FLAGS_INPUT_6xx)
3354
#define POWERPC_BFDM_603     (bfd_mach_ppc_603)
3355
#define POWERPC_FLAG_603     (POWERPC_FLAG_TGPR | POWERPC_FLAG_SE |           \
3356
                              POWERPC_FLAG_BE)
3357
#define check_pow_603        check_pow_hid0
3358

    
3359
static void init_proc_603 (CPUPPCState *env)
3360
{
3361
    gen_spr_ne_601(env);
3362
    gen_spr_603(env);
3363
    /* Time base */
3364
    gen_tbl(env);
3365
    /* hardware implementation registers */
3366
    /* XXX : not implemented */
3367
    spr_register(env, SPR_HID0, "HID0",
3368
                 SPR_NOACCESS, SPR_NOACCESS,
3369
                 &spr_read_generic, &spr_write_generic,
3370
                 0x00000000);
3371
    /* XXX : not implemented */
3372
    spr_register(env, SPR_HID1, "HID1",
3373
                 SPR_NOACCESS, SPR_NOACCESS,
3374
                 &spr_read_generic, &spr_write_generic,
3375
                 0x00000000);
3376
    /* Memory management */
3377
    gen_low_BATs(env);
3378
    gen_6xx_7xx_soft_tlb(env, 64, 2);
3379
    init_excp_603(env);
3380
    env->dcache_line_size = 32;
3381
    env->icache_line_size = 32;
3382
    /* Allocate hardware IRQ controller */
3383
    ppc6xx_irq_init(env);
3384
}
3385

    
3386
/* PowerPC 603e                                                              */
3387
#define POWERPC_INSNS_603E   (POWERPC_INSNS_WORKS | PPC_6xx_TLB | PPC_EXTERN)
3388
#define POWERPC_MSRM_603E    (0x000000000007FF73ULL)
3389
#define POWERPC_MMU_603E     (POWERPC_MMU_SOFT_6xx)
3390
//#define POWERPC_EXCP_603E    (POWERPC_EXCP_603E)
3391
#define POWERPC_INPUT_603E   (PPC_FLAGS_INPUT_6xx)
3392
#define POWERPC_BFDM_603E    (bfd_mach_ppc_ec603e)
3393
#define POWERPC_FLAG_603E    (POWERPC_FLAG_TGPR | POWERPC_FLAG_SE |           \
3394
                              POWERPC_FLAG_BE)
3395
#define check_pow_603E       check_pow_hid0
3396

    
3397
static void init_proc_603E (CPUPPCState *env)
3398
{
3399
    gen_spr_ne_601(env);
3400
    gen_spr_603(env);
3401
    /* Time base */
3402
    gen_tbl(env);
3403
    /* hardware implementation registers */
3404
    /* XXX : not implemented */
3405
    spr_register(env, SPR_HID0, "HID0",
3406
                 SPR_NOACCESS, SPR_NOACCESS,
3407
                 &spr_read_generic, &spr_write_generic,
3408
                 0x00000000);
3409
    /* XXX : not implemented */
3410
    spr_register(env, SPR_HID1, "HID1",
3411
                 SPR_NOACCESS, SPR_NOACCESS,
3412
                 &spr_read_generic, &spr_write_generic,
3413
                 0x00000000);
3414
    /* XXX : not implemented */
3415
    spr_register(env, SPR_IABR, "IABR",
3416
                 SPR_NOACCESS, SPR_NOACCESS,
3417
                 &spr_read_generic, &spr_write_generic,
3418
                 0x00000000);
3419
    /* Memory management */
3420
    gen_low_BATs(env);
3421
    gen_6xx_7xx_soft_tlb(env, 64, 2);
3422
    init_excp_603(env);
3423
    env->dcache_line_size = 32;
3424
    env->icache_line_size = 32;
3425
    /* Allocate hardware IRQ controller */
3426
    ppc6xx_irq_init(env);
3427
}
3428

    
3429
/* PowerPC G2                                                                */
3430
#define POWERPC_INSNS_G2     (POWERPC_INSNS_WORKS | PPC_6xx_TLB | PPC_EXTERN)
3431
#define POWERPC_MSRM_G2      (0x000000000006FFF2ULL)
3432
#define POWERPC_MMU_G2       (POWERPC_MMU_SOFT_6xx)
3433
//#define POWERPC_EXCP_G2      (POWERPC_EXCP_G2)
3434
#define POWERPC_INPUT_G2     (PPC_FLAGS_INPUT_6xx)
3435
#define POWERPC_BFDM_G2      (bfd_mach_ppc_ec603e)
3436
#define POWERPC_FLAG_G2      (POWERPC_FLAG_TGPR | POWERPC_FLAG_SE |           \
3437
                              POWERPC_FLAG_BE)
3438
#define check_pow_G2         check_pow_hid0
3439

    
3440
static void init_proc_G2 (CPUPPCState *env)
3441
{
3442
    gen_spr_ne_601(env);
3443
    gen_spr_G2_755(env);
3444
    gen_spr_G2(env);
3445
    /* Time base */
3446
    gen_tbl(env);
3447
    /* Hardware implementation register */
3448
    /* XXX : not implemented */
3449
    spr_register(env, SPR_HID0, "HID0",
3450
                 SPR_NOACCESS, SPR_NOACCESS,
3451
                 &spr_read_generic, &spr_write_generic,
3452
                 0x00000000);
3453
    /* XXX : not implemented */
3454
    spr_register(env, SPR_HID1, "HID1",
3455
                 SPR_NOACCESS, SPR_NOACCESS,
3456
                 &spr_read_generic, &spr_write_generic,
3457
                 0x00000000);
3458
    /* XXX : not implemented */
3459
    spr_register(env, SPR_HID2, "HID2",
3460
                 SPR_NOACCESS, SPR_NOACCESS,
3461
                 &spr_read_generic, &spr_write_generic,
3462
                 0x00000000);
3463
    /* Memory management */
3464
    gen_low_BATs(env);
3465
    gen_high_BATs(env);
3466
    gen_6xx_7xx_soft_tlb(env, 64, 2);
3467
    init_excp_G2(env);
3468
    env->dcache_line_size = 32;
3469
    env->icache_line_size = 32;
3470
    /* Allocate hardware IRQ controller */
3471
    ppc6xx_irq_init(env);
3472
}
3473

    
3474
/* PowerPC G2LE                                                              */
3475
#define POWERPC_INSNS_G2LE   (POWERPC_INSNS_WORKS | PPC_6xx_TLB | PPC_EXTERN)
3476
#define POWERPC_MSRM_G2LE    (0x000000000007FFF3ULL)
3477
#define POWERPC_MMU_G2LE     (POWERPC_MMU_SOFT_6xx)
3478
#define POWERPC_EXCP_G2LE    (POWERPC_EXCP_G2)
3479
#define POWERPC_INPUT_G2LE   (PPC_FLAGS_INPUT_6xx)
3480
#define POWERPC_BFDM_G2LE    (bfd_mach_ppc_ec603e)
3481
#define POWERPC_FLAG_G2LE    (POWERPC_FLAG_TGPR | POWERPC_FLAG_SE |           \
3482
                              POWERPC_FLAG_BE)
3483
#define check_pow_G2LE       check_pow_hid0
3484

    
3485
static void init_proc_G2LE (CPUPPCState *env)
3486
{
3487
    gen_spr_ne_601(env);
3488
    gen_spr_G2_755(env);
3489
    gen_spr_G2(env);
3490
    /* Time base */
3491
    gen_tbl(env);
3492
    /* Hardware implementation register */
3493
    /* XXX : not implemented */
3494
    spr_register(env, SPR_HID0, "HID0",
3495
                 SPR_NOACCESS, SPR_NOACCESS,
3496
                 &spr_read_generic, &spr_write_generic,
3497
                 0x00000000);
3498
    /* XXX : not implemented */
3499
    spr_register(env, SPR_HID1, "HID1",
3500
                 SPR_NOACCESS, SPR_NOACCESS,
3501
                 &spr_read_generic, &spr_write_generic,
3502
                 0x00000000);
3503
    /* XXX : not implemented */
3504
    spr_register(env, SPR_HID2, "HID2",
3505
                 SPR_NOACCESS, SPR_NOACCESS,
3506
                 &spr_read_generic, &spr_write_generic,
3507
                 0x00000000);
3508
    /* Memory management */
3509
    gen_low_BATs(env);
3510
    gen_high_BATs(env);
3511
    gen_6xx_7xx_soft_tlb(env, 64, 2);
3512
    init_excp_G2(env);
3513
    env->dcache_line_size = 32;
3514
    env->icache_line_size = 32;
3515
    /* Allocate hardware IRQ controller */
3516
    ppc6xx_irq_init(env);
3517
}
3518

    
3519
/* PowerPC 604                                                               */
3520
#define POWERPC_INSNS_604    (POWERPC_INSNS_WORKS | PPC_EXTERN)
3521
#define POWERPC_MSRM_604     (0x000000000005FF77ULL)
3522
#define POWERPC_MMU_604      (POWERPC_MMU_32B)
3523
//#define POWERPC_EXCP_604     (POWERPC_EXCP_604)
3524
#define POWERPC_INPUT_604    (PPC_FLAGS_INPUT_6xx)
3525
#define POWERPC_BFDM_604     (bfd_mach_ppc_604)
3526
#define POWERPC_FLAG_604     (POWERPC_FLAG_SE | POWERPC_FLAG_BE |             \
3527
                              POWERPC_FLAG_PMM)
3528
#define check_pow_604        check_pow_nocheck
3529

    
3530
static void init_proc_604 (CPUPPCState *env)
3531
{
3532
    gen_spr_ne_601(env);
3533
    gen_spr_604(env);
3534
    /* Time base */
3535
    gen_tbl(env);
3536
    /* Hardware implementation registers */
3537
    /* XXX : not implemented */
3538
    spr_register(env, SPR_HID0, "HID0",
3539
                 SPR_NOACCESS, SPR_NOACCESS,
3540
                 &spr_read_generic, &spr_write_generic,
3541
                 0x00000000);
3542
    /* XXX : not implemented */
3543
    spr_register(env, SPR_HID1, "HID1",
3544
                 SPR_NOACCESS, SPR_NOACCESS,
3545
                 &spr_read_generic, &spr_write_generic,
3546
                 0x00000000);
3547
    /* Memory management */
3548
    gen_low_BATs(env);
3549
    init_excp_604(env);
3550
    env->dcache_line_size = 32;
3551
    env->icache_line_size = 32;
3552
    /* Allocate hardware IRQ controller */
3553
    ppc6xx_irq_init(env);
3554
}
3555

    
3556
/* PowerPC 740/750 (aka G3)                                                  */
3557
#define POWERPC_INSNS_7x0    (POWERPC_INSNS_WORKS | PPC_EXTERN)
3558
#define POWERPC_MSRM_7x0     (0x000000000005FF77ULL)
3559
#define POWERPC_MMU_7x0      (POWERPC_MMU_32B)
3560
//#define POWERPC_EXCP_7x0     (POWERPC_EXCP_7x0)
3561
#define POWERPC_INPUT_7x0    (PPC_FLAGS_INPUT_6xx)
3562
#define POWERPC_BFDM_7x0     (bfd_mach_ppc_750)
3563
#define POWERPC_FLAG_7x0     (POWERPC_FLAG_SE | POWERPC_FLAG_BE |             \
3564
                              POWERPC_FLAG_PMM)
3565
#define check_pow_7x0        check_pow_hid0
3566

    
3567
static void init_proc_7x0 (CPUPPCState *env)
3568
{
3569
    gen_spr_ne_601(env);
3570
    gen_spr_7xx(env);
3571
    /* Time base */
3572
    gen_tbl(env);
3573
    /* Thermal management */
3574
    gen_spr_thrm(env);
3575
    /* Hardware implementation registers */
3576
    /* XXX : not implemented */
3577
    spr_register(env, SPR_HID0, "HID0",
3578
                 SPR_NOACCESS, SPR_NOACCESS,
3579
                 &spr_read_generic, &spr_write_generic,
3580
                 0x00000000);
3581
    /* XXX : not implemented */
3582
    spr_register(env, SPR_HID1, "HID1",
3583
                 SPR_NOACCESS, SPR_NOACCESS,
3584
                 &spr_read_generic, &spr_write_generic,
3585
                 0x00000000);
3586
    /* Memory management */
3587
    gen_low_BATs(env);
3588
    init_excp_7x0(env);
3589
    env->dcache_line_size = 32;
3590
    env->icache_line_size = 32;
3591
    /* Allocate hardware IRQ controller */
3592
    ppc6xx_irq_init(env);
3593
}
3594

    
3595
/* PowerPC 750FX/GX                                                          */
3596
#define POWERPC_INSNS_750fx  (POWERPC_INSNS_WORKS | PPC_EXTERN)
3597
#define POWERPC_MSRM_750fx   (0x000000000005FF77ULL)
3598
#define POWERPC_MMU_750fx    (POWERPC_MMU_32B)
3599
#define POWERPC_EXCP_750fx   (POWERPC_EXCP_7x0)
3600
#define POWERPC_INPUT_750fx  (PPC_FLAGS_INPUT_6xx)
3601
#define POWERPC_BFDM_750fx   (bfd_mach_ppc_750)
3602
#define POWERPC_FLAG_750fx   (POWERPC_FLAG_SE | POWERPC_FLAG_BE |             \
3603
                              POWERPC_FLAG_PMM)
3604
#define check_pow_750fx      check_pow_hid0
3605

    
3606
static void init_proc_750fx (CPUPPCState *env)
3607
{
3608
    gen_spr_ne_601(env);
3609
    gen_spr_7xx(env);
3610
    /* Time base */
3611
    gen_tbl(env);
3612
    /* Thermal management */
3613
    gen_spr_thrm(env);
3614
    /* Hardware implementation registers */
3615
    /* XXX : not implemented */
3616
    spr_register(env, SPR_HID0, "HID0",
3617
                 SPR_NOACCESS, SPR_NOACCESS,
3618
                 &spr_read_generic, &spr_write_generic,
3619
                 0x00000000);
3620
    /* XXX : not implemented */
3621
    spr_register(env, SPR_HID1, "HID1",
3622
                 SPR_NOACCESS, SPR_NOACCESS,
3623
                 &spr_read_generic, &spr_write_generic,
3624
                 0x00000000);
3625
    /* XXX : not implemented */
3626
    spr_register(env, SPR_750_HID2, "HID2",
3627
                 SPR_NOACCESS, SPR_NOACCESS,
3628
                 &spr_read_generic, &spr_write_generic,
3629
                 0x00000000);
3630
    /* Memory management */
3631
    gen_low_BATs(env);
3632
    /* PowerPC 750fx & 750gx has 8 DBATs and 8 IBATs */
3633
    gen_high_BATs(env);
3634
    init_excp_750FX(env);
3635
    env->dcache_line_size = 32;
3636
    env->icache_line_size = 32;
3637
    /* Allocate hardware IRQ controller */
3638
    ppc6xx_irq_init(env);
3639
}
3640

    
3641
/* PowerPC 745/755                                                           */
3642
#define POWERPC_INSNS_7x5    (POWERPC_INSNS_WORKS | PPC_EXTERN | PPC_6xx_TLB)
3643
#define POWERPC_MSRM_7x5     (0x000000000005FF77ULL)
3644
#define POWERPC_MMU_7x5      (POWERPC_MMU_SOFT_6xx)
3645
//#define POWERPC_EXCP_7x5     (POWERPC_EXCP_7x5)
3646
#define POWERPC_INPUT_7x5    (PPC_FLAGS_INPUT_6xx)
3647
#define POWERPC_BFDM_7x5     (bfd_mach_ppc_750)
3648
#define POWERPC_FLAG_7x5     (POWERPC_FLAG_SE | POWERPC_FLAG_BE |             \
3649
                              POWERPC_FLAG_PMM)
3650
#define check_pow_7x5        check_pow_hid0
3651

    
3652
static void init_proc_7x5 (CPUPPCState *env)
3653
{
3654
    gen_spr_ne_601(env);
3655
    gen_spr_G2_755(env);
3656
    /* Time base */
3657
    gen_tbl(env);
3658
    /* L2 cache control */
3659
    /* XXX : not implemented */
3660
    spr_register(env, SPR_ICTC, "ICTC",
3661
                 SPR_NOACCESS, SPR_NOACCESS,
3662
                 &spr_read_generic, &spr_write_generic,
3663
                 0x00000000);
3664
    /* XXX : not implemented */
3665
    spr_register(env, SPR_L2PMCR, "L2PMCR",
3666
                 SPR_NOACCESS, SPR_NOACCESS,
3667
                 &spr_read_generic, &spr_write_generic,
3668
                 0x00000000);
3669
    /* Hardware implementation registers */
3670
    /* XXX : not implemented */
3671
    spr_register(env, SPR_HID0, "HID0",
3672
                 SPR_NOACCESS, SPR_NOACCESS,
3673
                 &spr_read_generic, &spr_write_generic,
3674
                 0x00000000);
3675
    /* XXX : not implemented */
3676
    spr_register(env, SPR_HID1, "HID1",
3677
                 SPR_NOACCESS, SPR_NOACCESS,
3678
                 &spr_read_generic, &spr_write_generic,
3679
                 0x00000000);
3680
    /* XXX : not implemented */
3681
    spr_register(env, SPR_HID2, "HID2",
3682
                 SPR_NOACCESS, SPR_NOACCESS,
3683
                 &spr_read_generic, &spr_write_generic,
3684
                 0x00000000);
3685
    /* Memory management */
3686
    gen_low_BATs(env);
3687
    gen_high_BATs(env);
3688
    gen_6xx_7xx_soft_tlb(env, 64, 2);
3689
    init_excp_7x5(env);
3690
    env->dcache_line_size = 32;
3691
    env->icache_line_size = 32;
3692
    /* Allocate hardware IRQ controller */
3693
    ppc6xx_irq_init(env);
3694
#if !defined(CONFIG_USER_ONLY)
3695
    /* Hardware reset vector */
3696
    env->hreset_vector = 0xFFFFFFFCUL;
3697
#endif
3698
}
3699

    
3700
/* PowerPC 7400 (aka G4)                                                     */
3701
#define POWERPC_INSNS_7400   (POWERPC_INSNS_WORKS | PPC_CACHE_DCBA |          \
3702
                              PPC_EXTERN | PPC_MEM_TLBIA |                    \
3703
                              PPC_ALTIVEC)
3704
#define POWERPC_MSRM_7400    (0x000000000205FF77ULL)
3705
#define POWERPC_MMU_7400     (POWERPC_MMU_32B)
3706
#define POWERPC_EXCP_7400    (POWERPC_EXCP_74xx)
3707
#define POWERPC_INPUT_7400   (PPC_FLAGS_INPUT_6xx)
3708
#define POWERPC_BFDM_7400    (bfd_mach_ppc_7400)
3709
#define POWERPC_FLAG_7400    (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
3710
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
3711
#define check_pow_7400       check_pow_hid0
3712

    
3713
static void init_proc_7400 (CPUPPCState *env)
3714
{
3715
    gen_spr_ne_601(env);
3716
    gen_spr_7xx(env);
3717
    /* Time base */
3718
    gen_tbl(env);
3719
    /* 74xx specific SPR */
3720
    gen_spr_74xx(env);
3721
    /* Thermal management */
3722
    gen_spr_thrm(env);
3723
    /* Memory management */
3724
    gen_low_BATs(env);
3725
    init_excp_7400(env);
3726
    env->dcache_line_size = 32;
3727
    env->icache_line_size = 32;
3728
    /* Allocate hardware IRQ controller */
3729
    ppc6xx_irq_init(env);
3730
}
3731

    
3732
/* PowerPC 7410 (aka G4)                                                     */
3733
#define POWERPC_INSNS_7410   (POWERPC_INSNS_WORKS | PPC_CACHE_DCBA |          \
3734
                              PPC_EXTERN | PPC_MEM_TLBIA |                    \
3735
                              PPC_ALTIVEC)
3736
#define POWERPC_MSRM_7410    (0x000000000205FF77ULL)
3737
#define POWERPC_MMU_7410     (POWERPC_MMU_32B)
3738
#define POWERPC_EXCP_7410    (POWERPC_EXCP_74xx)
3739
#define POWERPC_INPUT_7410   (PPC_FLAGS_INPUT_6xx)
3740
#define POWERPC_BFDM_7410    (bfd_mach_ppc_7400)
3741
#define POWERPC_FLAG_7410    (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
3742
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
3743
#define check_pow_7410       check_pow_hid0
3744

    
3745
static void init_proc_7410 (CPUPPCState *env)
3746
{
3747
    gen_spr_ne_601(env);
3748
    gen_spr_7xx(env);
3749
    /* Time base */
3750
    gen_tbl(env);
3751
    /* 74xx specific SPR */
3752
    gen_spr_74xx(env);
3753
    /* Thermal management */
3754
    gen_spr_thrm(env);
3755
    /* L2PMCR */
3756
    /* XXX : not implemented */
3757
    spr_register(env, SPR_L2PMCR, "L2PMCR",
3758
                 SPR_NOACCESS, SPR_NOACCESS,
3759
                 &spr_read_generic, &spr_write_generic,
3760
                 0x00000000);
3761
    /* LDSTDB */
3762
    /* XXX : not implemented */
3763
    spr_register(env, SPR_LDSTDB, "LDSTDB",
3764
                 SPR_NOACCESS, SPR_NOACCESS,
3765
                 &spr_read_generic, &spr_write_generic,
3766
                 0x00000000);
3767
    /* Memory management */
3768
    gen_low_BATs(env);
3769
    init_excp_7400(env);
3770
    env->dcache_line_size = 32;
3771
    env->icache_line_size = 32;
3772
    /* Allocate hardware IRQ controller */
3773
    ppc6xx_irq_init(env);
3774
}
3775

    
3776
/* PowerPC 7440 (aka G4)                                                     */
3777
#define POWERPC_INSNS_7440   (POWERPC_INSNS_WORKS | PPC_CACHE_DCBA |          \
3778
                              PPC_EXTERN | PPC_74xx_TLB | PPC_MEM_TLBIA |     \
3779
                              PPC_ALTIVEC)
3780
#define POWERPC_MSRM_7440    (0x000000000205FF77ULL)
3781
#define POWERPC_MMU_7440     (POWERPC_MMU_SOFT_74xx)
3782
#define POWERPC_EXCP_7440    (POWERPC_EXCP_74xx)
3783
#define POWERPC_INPUT_7440   (PPC_FLAGS_INPUT_6xx)
3784
#define POWERPC_BFDM_7440    (bfd_mach_ppc_7400)
3785
#define POWERPC_FLAG_7440    (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
3786
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
3787
#define check_pow_7440       check_pow_hid0
3788

    
3789
__attribute__ (( unused ))
3790
static void init_proc_7440 (CPUPPCState *env)
3791
{
3792
    gen_spr_ne_601(env);
3793
    gen_spr_7xx(env);
3794
    /* Time base */
3795
    gen_tbl(env);
3796
    /* 74xx specific SPR */
3797
    gen_spr_74xx(env);
3798
    /* LDSTCR */
3799
    /* XXX : not implemented */
3800
    spr_register(env, SPR_LDSTCR, "LDSTCR",
3801
                 SPR_NOACCESS, SPR_NOACCESS,
3802
                 &spr_read_generic, &spr_write_generic,
3803
                 0x00000000);
3804
    /* ICTRL */
3805
    /* XXX : not implemented */
3806
    spr_register(env, SPR_ICTRL, "ICTRL",
3807
                 SPR_NOACCESS, SPR_NOACCESS,
3808
                 &spr_read_generic, &spr_write_generic,
3809
                 0x00000000);
3810
    /* MSSSR0 */
3811
    /* XXX : not implemented */
3812
    spr_register(env, SPR_MSSSR0, "MSSSR0",
3813
                 SPR_NOACCESS, SPR_NOACCESS,
3814
                 &spr_read_generic, &spr_write_generic,
3815
                 0x00000000);
3816
    /* PMC */
3817
    /* XXX : not implemented */
3818
    spr_register(env, SPR_PMC5, "PMC5",
3819
                 SPR_NOACCESS, SPR_NOACCESS,
3820
                 &spr_read_generic, &spr_write_generic,
3821
                 0x00000000);
3822
    /* XXX : not implemented */
3823
    spr_register(env, SPR_UPMC5, "UPMC5",
3824
                 &spr_read_ureg, SPR_NOACCESS,
3825
                 &spr_read_ureg, SPR_NOACCESS,
3826
                 0x00000000);
3827
    /* XXX : not implemented */
3828
    spr_register(env, SPR_PMC6, "PMC6",
3829
                 SPR_NOACCESS, SPR_NOACCESS,
3830
                 &spr_read_generic, &spr_write_generic,
3831
                 0x00000000);
3832
    /* XXX : not implemented */
3833
    spr_register(env, SPR_UPMC6, "UPMC6",
3834
                 &spr_read_ureg, SPR_NOACCESS,
3835
                 &spr_read_ureg, SPR_NOACCESS,
3836
                 0x00000000);
3837
    /* Memory management */
3838
    gen_low_BATs(env);
3839
    gen_74xx_soft_tlb(env, 128, 2);
3840
    init_excp_7450(env);
3841
    env->dcache_line_size = 32;
3842
    env->icache_line_size = 32;
3843
    /* Allocate hardware IRQ controller */
3844
    ppc6xx_irq_init(env);
3845
}
3846

    
3847
/* PowerPC 7450 (aka G4)                                                     */
3848
#define POWERPC_INSNS_7450   (POWERPC_INSNS_WORKS | PPC_CACHE_DCBA |          \
3849
                              PPC_EXTERN | PPC_74xx_TLB | PPC_MEM_TLBIA |     \
3850
                              PPC_ALTIVEC)
3851
#define POWERPC_MSRM_7450    (0x000000000205FF77ULL)
3852
#define POWERPC_MMU_7450     (POWERPC_MMU_SOFT_74xx)
3853
#define POWERPC_EXCP_7450    (POWERPC_EXCP_74xx)
3854
#define POWERPC_INPUT_7450   (PPC_FLAGS_INPUT_6xx)
3855
#define POWERPC_BFDM_7450    (bfd_mach_ppc_7400)
3856
#define POWERPC_FLAG_7450    (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
3857
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
3858
#define check_pow_7450       check_pow_hid0
3859

    
3860
__attribute__ (( unused ))
3861
static void init_proc_7450 (CPUPPCState *env)
3862
{
3863
    gen_spr_ne_601(env);
3864
    gen_spr_7xx(env);
3865
    /* Time base */
3866
    gen_tbl(env);
3867
    /* 74xx specific SPR */
3868
    gen_spr_74xx(env);
3869
    /* Level 3 cache control */
3870
    gen_l3_ctrl(env);
3871
    /* LDSTCR */
3872
    /* XXX : not implemented */
3873
    spr_register(env, SPR_LDSTCR, "LDSTCR",
3874
                 SPR_NOACCESS, SPR_NOACCESS,
3875
                 &spr_read_generic, &spr_write_generic,
3876
                 0x00000000);
3877
    /* ICTRL */
3878
    /* XXX : not implemented */
3879
    spr_register(env, SPR_ICTRL, "ICTRL",
3880
                 SPR_NOACCESS, SPR_NOACCESS,
3881
                 &spr_read_generic, &spr_write_generic,
3882
                 0x00000000);
3883
    /* MSSSR0 */
3884
    /* XXX : not implemented */
3885
    spr_register(env, SPR_MSSSR0, "MSSSR0",
3886
                 SPR_NOACCESS, SPR_NOACCESS,
3887
                 &spr_read_generic, &spr_write_generic,
3888
                 0x00000000);
3889
    /* PMC */
3890
    /* XXX : not implemented */
3891
    spr_register(env, SPR_PMC5, "PMC5",
3892
                 SPR_NOACCESS, SPR_NOACCESS,
3893
                 &spr_read_generic, &spr_write_generic,
3894
                 0x00000000);
3895
    /* XXX : not implemented */
3896
    spr_register(env, SPR_UPMC5, "UPMC5",
3897
                 &spr_read_ureg, SPR_NOACCESS,
3898
                 &spr_read_ureg, SPR_NOACCESS,
3899
                 0x00000000);
3900
    /* XXX : not implemented */
3901
    spr_register(env, SPR_PMC6, "PMC6",
3902
                 SPR_NOACCESS, SPR_NOACCESS,
3903
                 &spr_read_generic, &spr_write_generic,
3904
                 0x00000000);
3905
    /* XXX : not implemented */
3906
    spr_register(env, SPR_UPMC6, "UPMC6",
3907
                 &spr_read_ureg, SPR_NOACCESS,
3908
                 &spr_read_ureg, SPR_NOACCESS,
3909
                 0x00000000);
3910
    /* Memory management */
3911
    gen_low_BATs(env);
3912
    gen_74xx_soft_tlb(env, 128, 2);
3913
    init_excp_7450(env);
3914
    env->dcache_line_size = 32;
3915
    env->icache_line_size = 32;
3916
    /* Allocate hardware IRQ controller */
3917
    ppc6xx_irq_init(env);
3918
}
3919

    
3920
/* PowerPC 7445 (aka G4)                                                     */
3921
#define POWERPC_INSNS_7445   (POWERPC_INSNS_WORKS | PPC_CACHE_DCBA |          \
3922
                              PPC_EXTERN | PPC_74xx_TLB | PPC_MEM_TLBIA |     \
3923
                              PPC_ALTIVEC)
3924
#define POWERPC_MSRM_7445    (0x000000000205FF77ULL)
3925
#define POWERPC_MMU_7445     (POWERPC_MMU_SOFT_74xx)
3926
#define POWERPC_EXCP_7445    (POWERPC_EXCP_74xx)
3927
#define POWERPC_INPUT_7445   (PPC_FLAGS_INPUT_6xx)
3928
#define POWERPC_BFDM_7445    (bfd_mach_ppc_7400)
3929
#define POWERPC_FLAG_7445    (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
3930
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
3931
#define check_pow_7445       check_pow_hid0
3932

    
3933
__attribute__ (( unused ))
3934
static void init_proc_7445 (CPUPPCState *env)
3935
{
3936
    gen_spr_ne_601(env);
3937
    gen_spr_7xx(env);
3938
    /* Time base */
3939
    gen_tbl(env);
3940
    /* 74xx specific SPR */
3941
    gen_spr_74xx(env);
3942
    /* LDSTCR */
3943
    /* XXX : not implemented */
3944
    spr_register(env, SPR_LDSTCR, "LDSTCR",
3945
                 SPR_NOACCESS, SPR_NOACCESS,
3946
                 &spr_read_generic, &spr_write_generic,
3947
                 0x00000000);
3948
    /* ICTRL */
3949
    /* XXX : not implemented */
3950
    spr_register(env, SPR_ICTRL, "ICTRL",
3951
                 SPR_NOACCESS, SPR_NOACCESS,
3952
                 &spr_read_generic, &spr_write_generic,
3953
                 0x00000000);
3954
    /* MSSSR0 */
3955
    /* XXX : not implemented */
3956
    spr_register(env, SPR_MSSSR0, "MSSSR0",
3957
                 SPR_NOACCESS, SPR_NOACCESS,
3958
                 &spr_read_generic, &spr_write_generic,
3959
                 0x00000000);
3960
    /* PMC */
3961
    /* XXX : not implemented */
3962
    spr_register(env, SPR_PMC5, "PMC5",
3963
                 SPR_NOACCESS, SPR_NOACCESS,
3964
                 &spr_read_generic, &spr_write_generic,
3965
                 0x00000000);
3966
    /* XXX : not implemented */
3967
    spr_register(env, SPR_UPMC5, "UPMC5",
3968
                 &spr_read_ureg, SPR_NOACCESS,
3969
                 &spr_read_ureg, SPR_NOACCESS,
3970
                 0x00000000);
3971
    /* XXX : not implemented */
3972
    spr_register(env, SPR_PMC6, "PMC6",
3973
                 SPR_NOACCESS, SPR_NOACCESS,
3974
                 &spr_read_generic, &spr_write_generic,
3975
                 0x00000000);
3976
    /* XXX : not implemented */
3977
    spr_register(env, SPR_UPMC6, "UPMC6",
3978
                 &spr_read_ureg, SPR_NOACCESS,
3979
                 &spr_read_ureg, SPR_NOACCESS,
3980
                 0x00000000);
3981
    /* SPRGs */
3982
    spr_register(env, SPR_SPRG4, "SPRG4",
3983
                 SPR_NOACCESS, SPR_NOACCESS,
3984
                 &spr_read_generic, &spr_write_generic,
3985
                 0x00000000);
3986
    spr_register(env, SPR_USPRG4, "USPRG4",
3987
                 &spr_read_ureg, SPR_NOACCESS,
3988
                 &spr_read_ureg, SPR_NOACCESS,
3989
                 0x00000000);
3990
    spr_register(env, SPR_SPRG5, "SPRG5",
3991
                 SPR_NOACCESS, SPR_NOACCESS,
3992
                 &spr_read_generic, &spr_write_generic,
3993
                 0x00000000);
3994
    spr_register(env, SPR_USPRG5, "USPRG5",
3995
                 &spr_read_ureg, SPR_NOACCESS,
3996
                 &spr_read_ureg, SPR_NOACCESS,
3997
                 0x00000000);
3998
    spr_register(env, SPR_SPRG6, "SPRG6",
3999
                 SPR_NOACCESS, SPR_NOACCESS,
4000
                 &spr_read_generic, &spr_write_generic,
4001
                 0x00000000);
4002
    spr_register(env, SPR_USPRG6, "USPRG6",
4003
                 &spr_read_ureg, SPR_NOACCESS,
4004
                 &spr_read_ureg, SPR_NOACCESS,
4005
                 0x00000000);
4006
    spr_register(env, SPR_SPRG7, "SPRG7",
4007
                 SPR_NOACCESS, SPR_NOACCESS,
4008
                 &spr_read_generic, &spr_write_generic,
4009
                 0x00000000);
4010
    spr_register(env, SPR_USPRG7, "USPRG7",
4011
                 &spr_read_ureg, SPR_NOACCESS,
4012
                 &spr_read_ureg, SPR_NOACCESS,
4013
                 0x00000000);
4014
    /* Memory management */
4015
    gen_low_BATs(env);
4016
    gen_high_BATs(env);
4017
    gen_74xx_soft_tlb(env, 128, 2);
4018
    init_excp_7450(env);
4019
    env->dcache_line_size = 32;
4020
    env->icache_line_size = 32;
4021
    /* Allocate hardware IRQ controller */
4022
    ppc6xx_irq_init(env);
4023
}
4024

    
4025
/* PowerPC 7455 (aka G4)                                                     */
4026
#define POWERPC_INSNS_7455   (POWERPC_INSNS_WORKS | PPC_CACHE_DCBA |          \
4027
                              PPC_EXTERN | PPC_74xx_TLB | PPC_MEM_TLBIA |     \
4028
                              PPC_ALTIVEC)
4029
#define POWERPC_MSRM_7455    (0x000000000205FF77ULL)
4030
#define POWERPC_MMU_7455     (POWERPC_MMU_SOFT_74xx)
4031
#define POWERPC_EXCP_7455    (POWERPC_EXCP_74xx)
4032
#define POWERPC_INPUT_7455   (PPC_FLAGS_INPUT_6xx)
4033
#define POWERPC_BFDM_7455    (bfd_mach_ppc_7400)
4034
#define POWERPC_FLAG_7455    (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
4035
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
4036
#define check_pow_7455       check_pow_hid0
4037

    
4038
__attribute__ (( unused ))
4039
static void init_proc_7455 (CPUPPCState *env)
4040
{
4041
    gen_spr_ne_601(env);
4042
    gen_spr_7xx(env);
4043
    /* Time base */
4044
    gen_tbl(env);
4045
    /* 74xx specific SPR */
4046
    gen_spr_74xx(env);
4047
    /* Level 3 cache control */
4048
    gen_l3_ctrl(env);
4049
    /* LDSTCR */
4050
    /* XXX : not implemented */
4051
    spr_register(env, SPR_LDSTCR, "LDSTCR",
4052
                 SPR_NOACCESS, SPR_NOACCESS,
4053
                 &spr_read_generic, &spr_write_generic,
4054
                 0x00000000);
4055
    /* ICTRL */
4056
    /* XXX : not implemented */
4057
    spr_register(env, SPR_ICTRL, "ICTRL",
4058
                 SPR_NOACCESS, SPR_NOACCESS,
4059
                 &spr_read_generic, &spr_write_generic,
4060
                 0x00000000);
4061
    /* MSSSR0 */
4062
    /* XXX : not implemented */
4063
    spr_register(env, SPR_MSSSR0, "MSSSR0",
4064
                 SPR_NOACCESS, SPR_NOACCESS,
4065
                 &spr_read_generic, &spr_write_generic,
4066
                 0x00000000);
4067
    /* PMC */
4068
    /* XXX : not implemented */
4069
    spr_register(env, SPR_PMC5, "PMC5",
4070
                 SPR_NOACCESS, SPR_NOACCESS,
4071
                 &spr_read_generic, &spr_write_generic,
4072
                 0x00000000);
4073
    /* XXX : not implemented */
4074
    spr_register(env, SPR_UPMC5, "UPMC5",
4075
                 &spr_read_ureg, SPR_NOACCESS,
4076
                 &spr_read_ureg, SPR_NOACCESS,
4077
                 0x00000000);
4078
    /* XXX : not implemented */
4079
    spr_register(env, SPR_PMC6, "PMC6",
4080
                 SPR_NOACCESS, SPR_NOACCESS,
4081
                 &spr_read_generic, &spr_write_generic,
4082
                 0x00000000);
4083
    /* XXX : not implemented */
4084
    spr_register(env, SPR_UPMC6, "UPMC6",
4085
                 &spr_read_ureg, SPR_NOACCESS,
4086
                 &spr_read_ureg, SPR_NOACCESS,
4087
                 0x00000000);
4088
    /* SPRGs */
4089
    spr_register(env, SPR_SPRG4, "SPRG4",
4090
                 SPR_NOACCESS, SPR_NOACCESS,
4091
                 &spr_read_generic, &spr_write_generic,
4092
                 0x00000000);
4093
    spr_register(env, SPR_USPRG4, "USPRG4",
4094
                 &spr_read_ureg, SPR_NOACCESS,
4095
                 &spr_read_ureg, SPR_NOACCESS,
4096
                 0x00000000);
4097
    spr_register(env, SPR_SPRG5, "SPRG5",
4098
                 SPR_NOACCESS, SPR_NOACCESS,
4099
                 &spr_read_generic, &spr_write_generic,
4100
                 0x00000000);
4101
    spr_register(env, SPR_USPRG5, "USPRG5",
4102
                 &spr_read_ureg, SPR_NOACCESS,
4103
                 &spr_read_ureg, SPR_NOACCESS,
4104
                 0x00000000);
4105
    spr_register(env, SPR_SPRG6, "SPRG6",
4106
                 SPR_NOACCESS, SPR_NOACCESS,
4107
                 &spr_read_generic, &spr_write_generic,
4108
                 0x00000000);
4109
    spr_register(env, SPR_USPRG6, "USPRG6",
4110
                 &spr_read_ureg, SPR_NOACCESS,
4111
                 &spr_read_ureg, SPR_NOACCESS,
4112
                 0x00000000);
4113
    spr_register(env, SPR_SPRG7, "SPRG7",
4114
                 SPR_NOACCESS, SPR_NOACCESS,
4115
                 &spr_read_generic, &spr_write_generic,
4116
                 0x00000000);
4117
    spr_register(env, SPR_USPRG7, "USPRG7",
4118
                 &spr_read_ureg, SPR_NOACCESS,
4119
                 &spr_read_ureg, SPR_NOACCESS,
4120
                 0x00000000);
4121
    /* Memory management */
4122
    gen_low_BATs(env);
4123
    gen_high_BATs(env);
4124
    gen_74xx_soft_tlb(env, 128, 2);
4125
    init_excp_7450(env);
4126
    env->dcache_line_size = 32;
4127
    env->icache_line_size = 32;
4128
    /* Allocate hardware IRQ controller */
4129
    ppc6xx_irq_init(env);
4130
}
4131

    
4132
#if defined (TARGET_PPC64)
4133
#define POWERPC_INSNS_WORK64  (POWERPC_INSNS_6xx | PPC_FLOAT_FSQRT |          \
4134
                               PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE |           \
4135
                               PPC_FLOAT_FSEL | PPC_FLOAT_STFIWX |            \
4136
                               PPC_MEM_TLBSYNC | PPC_CACHE_DCBZT | PPC_MFTB)
4137
/* PowerPC 970                                                               */
4138
#define POWERPC_INSNS_970    (POWERPC_INSNS_WORK64 | PPC_FLOAT_FSQRT |        \
4139
                              PPC_64B | PPC_ALTIVEC |                         \
4140
                              PPC_SEGMENT_64B | PPC_SLBI)
4141
#define POWERPC_MSRM_970     (0x900000000204FF36ULL)
4142
#define POWERPC_MMU_970      (POWERPC_MMU_64B)
4143
//#define POWERPC_EXCP_970     (POWERPC_EXCP_970)
4144
#define POWERPC_INPUT_970    (PPC_FLAGS_INPUT_970)
4145
#define POWERPC_BFDM_970     (bfd_mach_ppc64)
4146
#define POWERPC_FLAG_970     (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
4147
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
4148

    
4149
#if defined(CONFIG_USER_ONLY)
4150
#define POWERPC970_HID5_INIT 0x00000080
4151
#else
4152
#define POWERPC970_HID5_INIT 0x00000000
4153
#endif
4154

    
4155
static int check_pow_970 (CPUPPCState *env)
4156
{
4157
    if (env->spr[SPR_HID0] & 0x00600000)
4158
        return 1;
4159

    
4160
    return 0;
4161
}
4162

    
4163
static void init_proc_970 (CPUPPCState *env)
4164
{
4165
    gen_spr_ne_601(env);
4166
    gen_spr_7xx(env);
4167
    /* Time base */
4168
    gen_tbl(env);
4169
    /* Hardware implementation registers */
4170
    /* XXX : not implemented */
4171
    spr_register(env, SPR_HID0, "HID0",
4172
                 SPR_NOACCESS, SPR_NOACCESS,
4173
                 &spr_read_generic, &spr_write_clear,
4174
                 0x60000000);
4175
    /* XXX : not implemented */
4176
    spr_register(env, SPR_HID1, "HID1",
4177
                 SPR_NOACCESS, SPR_NOACCESS,
4178
                 &spr_read_generic, &spr_write_generic,
4179
                 0x00000000);
4180
    /* XXX : not implemented */
4181
    spr_register(env, SPR_750_HID2, "HID2",
4182
                 SPR_NOACCESS, SPR_NOACCESS,
4183
                 &spr_read_generic, &spr_write_generic,
4184
                 0x00000000);
4185
    /* XXX : not implemented */
4186
    spr_register(env, SPR_970_HID5, "HID5",
4187
                 SPR_NOACCESS, SPR_NOACCESS,
4188
                 &spr_read_generic, &spr_write_generic,
4189
                 POWERPC970_HID5_INIT);
4190
    /* Memory management */
4191
    /* XXX: not correct */
4192
    gen_low_BATs(env);
4193
    /* XXX : not implemented */
4194
    spr_register(env, SPR_MMUCFG, "MMUCFG",
4195
                 SPR_NOACCESS, SPR_NOACCESS,
4196
                 &spr_read_generic, SPR_NOACCESS,
4197
                 0x00000000); /* TOFIX */
4198
    /* XXX : not implemented */
4199
    spr_register(env, SPR_MMUCSR0, "MMUCSR0",
4200
                 SPR_NOACCESS, SPR_NOACCESS,
4201
                 &spr_read_generic, &spr_write_generic,
4202
                 0x00000000); /* TOFIX */
4203
    spr_register(env, SPR_HIOR, "SPR_HIOR",
4204
                 SPR_NOACCESS, SPR_NOACCESS,
4205
                 &spr_read_generic, &spr_write_generic,
4206
                 0xFFF00000); /* XXX: This is a hack */
4207
#if !defined(CONFIG_USER_ONLY)
4208
    env->slb_nr = 32;
4209
#endif
4210
    init_excp_970(env);
4211
    env->dcache_line_size = 128;
4212
    env->icache_line_size = 128;
4213
    /* Allocate hardware IRQ controller */
4214
    ppc970_irq_init(env);
4215
}
4216

    
4217
/* PowerPC 970FX (aka G5)                                                    */
4218
#define POWERPC_INSNS_970FX  (POWERPC_INSNS_WORK64 | PPC_FLOAT_FSQRT |        \
4219
                              PPC_64B | PPC_ALTIVEC |                         \
4220
                              PPC_SEGMENT_64B | PPC_SLBI)
4221
#define POWERPC_MSRM_970FX   (0x800000000204FF36ULL)
4222
#define POWERPC_MMU_970FX    (POWERPC_MMU_64B)
4223
#define POWERPC_EXCP_970FX   (POWERPC_EXCP_970)
4224
#define POWERPC_INPUT_970FX  (PPC_FLAGS_INPUT_970)
4225
#define POWERPC_BFDM_970FX   (bfd_mach_ppc64)
4226
#define POWERPC_FLAG_970FX   (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
4227
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
4228

    
4229
static int check_pow_970FX (CPUPPCState *env)
4230
{
4231
    if (env->spr[SPR_HID0] & 0x00600000)
4232
        return 1;
4233

    
4234
    return 0;
4235
}
4236

    
4237
static void init_proc_970FX (CPUPPCState *env)
4238
{
4239
    gen_spr_ne_601(env);
4240
    gen_spr_7xx(env);
4241
    /* Time base */
4242
    gen_tbl(env);
4243
    /* Hardware implementation registers */
4244
    /* XXX : not implemented */
4245
    spr_register(env, SPR_HID0, "HID0",
4246
                 SPR_NOACCESS, SPR_NOACCESS,
4247
                 &spr_read_generic, &spr_write_clear,
4248
                 0x60000000);
4249
    /* XXX : not implemented */
4250
    spr_register(env, SPR_HID1, "HID1",
4251
                 SPR_NOACCESS, SPR_NOACCESS,
4252
                 &spr_read_generic, &spr_write_generic,
4253
                 0x00000000);
4254
    /* XXX : not implemented */
4255
    spr_register(env, SPR_750_HID2, "HID2",
4256
                 SPR_NOACCESS, SPR_NOACCESS,
4257
                 &spr_read_generic, &spr_write_generic,
4258
                 0x00000000);
4259
    /* XXX : not implemented */
4260
    spr_register(env, SPR_970_HID5, "HID5",
4261
                 SPR_NOACCESS, SPR_NOACCESS,
4262
                 &spr_read_generic, &spr_write_generic,
4263
                 POWERPC970_HID5_INIT);
4264
    /* Memory management */
4265
    /* XXX: not correct */
4266
    gen_low_BATs(env);
4267
    /* XXX : not implemented */
4268
    spr_register(env, SPR_MMUCFG, "MMUCFG",
4269
                 SPR_NOACCESS, SPR_NOACCESS,
4270
                 &spr_read_generic, SPR_NOACCESS,
4271
                 0x00000000); /* TOFIX */
4272
    /* XXX : not implemented */
4273
    spr_register(env, SPR_MMUCSR0, "MMUCSR0",
4274
                 SPR_NOACCESS, SPR_NOACCESS,
4275
                 &spr_read_generic, &spr_write_generic,
4276
                 0x00000000); /* TOFIX */
4277
    spr_register(env, SPR_HIOR, "SPR_HIOR",
4278
                 SPR_NOACCESS, SPR_NOACCESS,
4279
                 &spr_read_generic, &spr_write_generic,
4280
                 0xFFF00000); /* XXX: This is a hack */
4281
#if !defined(CONFIG_USER_ONLY)
4282
    env->slb_nr = 32;
4283
#endif
4284
    init_excp_970(env);
4285
    env->dcache_line_size = 128;
4286
    env->icache_line_size = 128;
4287
    /* Allocate hardware IRQ controller */
4288
    ppc970_irq_init(env);
4289
}
4290

    
4291
/* PowerPC 970 GX                                                            */
4292
#define POWERPC_INSNS_970GX  (POWERPC_INSNS_WORK64 | PPC_FLOAT_FSQRT |        \
4293
                              PPC_64B | PPC_ALTIVEC |                         \
4294
                              PPC_SEGMENT_64B | PPC_SLBI)
4295
#define POWERPC_MSRM_970GX   (0x800000000204FF36ULL)
4296
#define POWERPC_MMU_970GX    (POWERPC_MMU_64B)
4297
#define POWERPC_EXCP_970GX   (POWERPC_EXCP_970)
4298
#define POWERPC_INPUT_970GX  (PPC_FLAGS_INPUT_970)
4299
#define POWERPC_BFDM_970GX   (bfd_mach_ppc64)
4300
#define POWERPC_FLAG_970GX   (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
4301
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
4302

    
4303
static int check_pow_970GX (CPUPPCState *env)
4304
{
4305
    if (env->spr[SPR_HID0] & 0x00600000)
4306
        return 1;
4307

    
4308
    return 0;
4309
}
4310

    
4311
static void init_proc_970GX (CPUPPCState *env)
4312
{
4313
    gen_spr_ne_601(env);
4314
    gen_spr_7xx(env);
4315
    /* Time base */
4316
    gen_tbl(env);
4317
    /* Hardware implementation registers */
4318
    /* XXX : not implemented */
4319
    spr_register(env, SPR_HID0, "HID0",
4320
                 SPR_NOACCESS, SPR_NOACCESS,
4321
                 &spr_read_generic, &spr_write_clear,
4322
                 0x60000000);
4323
    /* XXX : not implemented */
4324
    spr_register(env, SPR_HID1, "HID1",
4325
                 SPR_NOACCESS, SPR_NOACCESS,
4326
                 &spr_read_generic, &spr_write_generic,
4327
                 0x00000000);
4328
    /* XXX : not implemented */
4329
    spr_register(env, SPR_750_HID2, "HID2",
4330
                 SPR_NOACCESS, SPR_NOACCESS,
4331
                 &spr_read_generic, &spr_write_generic,
4332
                 0x00000000);
4333
    /* XXX : not implemented */
4334
    spr_register(env, SPR_970_HID5, "HID5",
4335
                 SPR_NOACCESS, SPR_NOACCESS,
4336
                 &spr_read_generic, &spr_write_generic,
4337
                 POWERPC970_HID5_INIT);
4338
    /* Memory management */
4339
    /* XXX: not correct */
4340
    gen_low_BATs(env);
4341
    /* XXX : not implemented */
4342
    spr_register(env, SPR_MMUCFG, "MMUCFG",
4343
                 SPR_NOACCESS, SPR_NOACCESS,
4344
                 &spr_read_generic, SPR_NOACCESS,
4345
                 0x00000000); /* TOFIX */
4346
    /* XXX : not implemented */
4347
    spr_register(env, SPR_MMUCSR0, "MMUCSR0",
4348
                 SPR_NOACCESS, SPR_NOACCESS,
4349
                 &spr_read_generic, &spr_write_generic,
4350
                 0x00000000); /* TOFIX */
4351
    spr_register(env, SPR_HIOR, "SPR_HIOR",
4352
                 SPR_NOACCESS, SPR_NOACCESS,
4353
                 &spr_read_generic, &spr_write_generic,
4354
                 0xFFF00000); /* XXX: This is a hack */
4355
#if !defined(CONFIG_USER_ONLY)
4356
    env->slb_nr = 32;
4357
#endif
4358
    init_excp_970(env);
4359
    env->dcache_line_size = 128;
4360
    env->icache_line_size = 128;
4361
    /* Allocate hardware IRQ controller */
4362
    ppc970_irq_init(env);
4363
}
4364

    
4365
/* PowerPC 970 MP                                                            */
4366
#define POWERPC_INSNS_970MP  (POWERPC_INSNS_WORK64 | PPC_FLOAT_FSQRT |        \
4367
                              PPC_64B | PPC_ALTIVEC |                         \
4368
                              PPC_SEGMENT_64B | PPC_SLBI)
4369
#define POWERPC_MSRM_970MP   (0x900000000204FF36ULL)
4370
#define POWERPC_MMU_970MP    (POWERPC_MMU_64B)
4371
#define POWERPC_EXCP_970MP   (POWERPC_EXCP_970)
4372
#define POWERPC_INPUT_970MP  (PPC_FLAGS_INPUT_970)
4373
#define POWERPC_BFDM_970MP   (bfd_mach_ppc64)
4374
#define POWERPC_FLAG_970MP   (POWERPC_FLAG_VRE | POWERPC_FLAG_SE |            \
4375
                              POWERPC_FLAG_BE | POWERPC_FLAG_PMM)
4376

    
4377
static int check_pow_970MP (CPUPPCState *env)
4378
{
4379
    if (env->spr[SPR_HID0] & 0x01C00000)
4380
        return 1;
4381

    
4382
    return 0;
4383
}
4384

    
4385
static void init_proc_970MP (CPUPPCState *env)
4386
{
4387
    gen_spr_ne_601(env);
4388
    gen_spr_7xx(env);
4389
    /* Time base */
4390
    gen_tbl(env);
4391
    /* Hardware implementation registers */
4392
    /* XXX : not implemented */
4393
    spr_register(env, SPR_HID0, "HID0",
4394
                 SPR_NOACCESS, SPR_NOACCESS,
4395
                 &spr_read_generic, &spr_write_clear,
4396
                 0x60000000);
4397
    /* XXX : not implemented */
4398
    spr_register(env, SPR_HID1, "HID1",
4399
                 SPR_NOACCESS, SPR_NOACCESS,
4400
                 &spr_read_generic, &spr_write_generic,
4401
                 0x00000000);
4402
    /* XXX : not implemented */
4403
    spr_register(env, SPR_750_HID2, "HID2",
4404
                 SPR_NOACCESS, SPR_NOACCESS,
4405
                 &spr_read_generic, &spr_write_generic,
4406
                 0x00000000);
4407
    /* XXX : not implemented */
4408
    spr_register(env, SPR_970_HID5, "HID5",
4409
                 SPR_NOACCESS, SPR_NOACCESS,
4410
                 &spr_read_generic, &spr_write_generic,
4411
                 POWERPC970_HID5_INIT);
4412
    /* Memory management */
4413
    /* XXX: not correct */
4414
    gen_low_BATs(env);
4415
    /* XXX : not implemented */
4416
    spr_register(env, SPR_MMUCFG, "MMUCFG",
4417
                 SPR_NOACCESS, SPR_NOACCESS,
4418
                 &spr_read_generic, SPR_NOACCESS,
4419
                 0x00000000); /* TOFIX */
4420
    /* XXX : not implemented */
4421
    spr_register(env, SPR_MMUCSR0, "MMUCSR0",
4422
                 SPR_NOACCESS, SPR_NOACCESS,
4423
                 &spr_read_generic, &spr_write_generic,
4424
                 0x00000000); /* TOFIX */
4425
    spr_register(env, SPR_HIOR, "SPR_HIOR",
4426
                 SPR_NOACCESS, SPR_NOACCESS,
4427
                 &spr_read_generic, &spr_write_generic,
4428
                 0xFFF00000); /* XXX: This is a hack */
4429
#if !defined(CONFIG_USER_ONLY)
4430
    env->slb_nr = 32;
4431
#endif
4432
    init_excp_970(env);
4433
    env->dcache_line_size = 128;
4434
    env->icache_line_size = 128;
4435
    /* Allocate hardware IRQ controller */
4436
    ppc970_irq_init(env);
4437
}
4438

    
4439
/* PowerPC 620                                                               */
4440
#define POWERPC_INSNS_620    (POWERPC_INSNS_WORKS | PPC_FLOAT_FSQRT |         \
4441
                              PPC_64B | PPC_SLBI)
4442
#define POWERPC_MSRM_620     (0x800000000005FF73ULL)
4443
#define POWERPC_MMU_620      (POWERPC_MMU_64B)
4444
#define POWERPC_EXCP_620     (POWERPC_EXCP_970)
4445
#define POWERPC_INPUT_620    (PPC_FLAGS_INPUT_6xx)
4446
#define POWERPC_BFDM_620     (bfd_mach_ppc64)
4447
#define POWERPC_FLAG_620     (POWERPC_FLAG_SE | POWERPC_FLAG_BE)
4448
#define check_pow_620        check_pow_nocheck /* Check this */
4449

    
4450
__attribute__ (( unused ))
4451
static void init_proc_620 (CPUPPCState *env)
4452
{
4453
    gen_spr_ne_601(env);
4454
    gen_spr_620(env);
4455
    /* Time base */
4456
    gen_tbl(env);
4457
    /* Hardware implementation registers */
4458
    /* XXX : not implemented */
4459
    spr_register(env, SPR_HID0, "HID0",
4460
                 SPR_NOACCESS, SPR_NOACCESS,
4461
                 &spr_read_generic, &spr_write_generic,
4462
                 0x00000000);
4463
    /* Memory management */
4464
    gen_low_BATs(env);
4465
    gen_high_BATs(env);
4466
    init_excp_620(env);
4467
    env->dcache_line_size = 64;
4468
    env->icache_line_size = 64;
4469
    /* Allocate hardware IRQ controller */
4470
    ppc6xx_irq_init(env);
4471
}
4472
#endif /* defined (TARGET_PPC64) */
4473

    
4474
/* Default 32 bits PowerPC target will be 604 */
4475
#define CPU_POWERPC_PPC32     CPU_POWERPC_604
4476
#define POWERPC_INSNS_PPC32   POWERPC_INSNS_604
4477
#define POWERPC_MSRM_PPC32    POWERPC_MSRM_604
4478
#define POWERPC_MMU_PPC32     POWERPC_MMU_604
4479
#define POWERPC_EXCP_PPC32    POWERPC_EXCP_604
4480
#define POWERPC_INPUT_PPC32   POWERPC_INPUT_604
4481
#define POWERPC_BFDM_PPC32    POWERPC_BFDM_604
4482
#define POWERPC_FLAG_PPC32    POWERPC_FLAG_604
4483
#define check_pow_PPC32       check_pow_604
4484
#define init_proc_PPC32       init_proc_604
4485

    
4486
/* Default 64 bits PowerPC target will be 970 FX */
4487
#define CPU_POWERPC_PPC64     CPU_POWERPC_970FX
4488
#define POWERPC_INSNS_PPC64   POWERPC_INSNS_970FX
4489
#define POWERPC_MSRM_PPC64    POWERPC_MSRM_970FX
4490
#define POWERPC_MMU_PPC64     POWERPC_MMU_970FX
4491
#define POWERPC_EXCP_PPC64    POWERPC_EXCP_970FX
4492
#define POWERPC_INPUT_PPC64   POWERPC_INPUT_970FX
4493
#define POWERPC_BFDM_PPC64    POWERPC_BFDM_970FX
4494
#define POWERPC_FLAG_PPC64    POWERPC_FLAG_970FX
4495
#define check_pow_PPC64       check_pow_970FX
4496
#define init_proc_PPC64       init_proc_970FX
4497

    
4498
/* Default PowerPC target will be PowerPC 32 */
4499
#if defined (TARGET_PPC64) && 0 // XXX: TODO
4500
#define CPU_POWERPC_DEFAULT   CPU_POWERPC_PPC64
4501
#define POWERPC_INSNS_DEFAULT POWERPC_INSNS_PPC64
4502
#define POWERPC_MSRM_DEFAULT  POWERPC_MSRM_PPC64
4503
#define POWERPC_MMU_DEFAULT   POWERPC_MMU_PPC64
4504
#define POWERPC_EXCP_DEFAULT  POWERPC_EXCP_PPC64
4505
#define POWERPC_INPUT_DEFAULT POWERPC_INPUT_PPC64
4506
#define POWERPC_BFDM_DEFAULT  POWERPC_BFDM_PPC64
4507
#define POWERPC_FLAG_DEFAULT  POWERPC_FLAG_PPC64
4508
#define check_pow_DEFAULT     check_pow_PPC64
4509
#define init_proc_DEFAULT     init_proc_PPC64
4510
#else
4511
#define CPU_POWERPC_DEFAULT   CPU_POWERPC_PPC32
4512
#define POWERPC_INSNS_DEFAULT POWERPC_INSNS_PPC32
4513
#define POWERPC_MSRM_DEFAULT  POWERPC_MSRM_PPC32
4514
#define POWERPC_MMU_DEFAULT   POWERPC_MMU_PPC32
4515
#define POWERPC_EXCP_DEFAULT  POWERPC_EXCP_PPC32
4516
#define POWERPC_INPUT_DEFAULT POWERPC_INPUT_PPC32
4517
#define POWERPC_BFDM_DEFAULT  POWERPC_BFDM_PPC32
4518
#define POWERPC_FLAG_DEFAULT  POWERPC_FLAG_PPC32
4519
#define check_pow_DEFAULT     check_pow_PPC32
4520
#define init_proc_DEFAULT     init_proc_PPC32
4521
#endif
4522

    
4523
/*****************************************************************************/
4524
/* PVR definitions for most known PowerPC                                    */
4525
enum {
4526
    /* PowerPC 401 family */
4527
    /* Generic PowerPC 401 */
4528
#define CPU_POWERPC_401       CPU_POWERPC_401G2
4529
    /* PowerPC 401 cores */
4530
    CPU_POWERPC_401A1       = 0x00210000,
4531
    CPU_POWERPC_401B2       = 0x00220000,
4532
#if 0
4533
    CPU_POWERPC_401B3       = xxx,
4534
#endif
4535
    CPU_POWERPC_401C2       = 0x00230000,
4536
    CPU_POWERPC_401D2       = 0x00240000,
4537
    CPU_POWERPC_401E2       = 0x00250000,
4538
    CPU_POWERPC_401F2       = 0x00260000,
4539
    CPU_POWERPC_401G2       = 0x00270000,
4540
    /* PowerPC 401 microcontrolers */
4541
#if 0
4542
    CPU_POWERPC_401GF       = xxx,
4543
#endif
4544
#define CPU_POWERPC_IOP480    CPU_POWERPC_401B2
4545
    /* IBM Processor for Network Resources */
4546
    CPU_POWERPC_COBRA       = 0x10100000, /* XXX: 405 ? */
4547
#if 0
4548
    CPU_POWERPC_XIPCHIP     = xxx,
4549
#endif
4550
    /* PowerPC 403 family */
4551
    /* Generic PowerPC 403 */
4552
#define CPU_POWERPC_403       CPU_POWERPC_403GC
4553
    /* PowerPC 403 microcontrollers */
4554
    CPU_POWERPC_403GA       = 0x00200011,
4555
    CPU_POWERPC_403GB       = 0x00200100,
4556
    CPU_POWERPC_403GC       = 0x00200200,
4557
    CPU_POWERPC_403GCX      = 0x00201400,
4558
#if 0
4559
    CPU_POWERPC_403GP       = xxx,
4560
#endif
4561
    /* PowerPC 405 family */
4562
    /* Generic PowerPC 405 */
4563
#define CPU_POWERPC_405       CPU_POWERPC_405D4
4564
    /* PowerPC 405 cores */
4565
#if 0
4566
    CPU_POWERPC_405A3       = xxx,
4567
#endif
4568
#if 0
4569
    CPU_POWERPC_405A4       = xxx,
4570
#endif
4571
#if 0
4572
    CPU_POWERPC_405B3       = xxx,
4573
#endif
4574
#if 0
4575
    CPU_POWERPC_405B4       = xxx,
4576
#endif
4577
#if 0
4578
    CPU_POWERPC_405C3       = xxx,
4579
#endif
4580
#if 0
4581
    CPU_POWERPC_405C4       = xxx,
4582
#endif
4583
    CPU_POWERPC_405D2       = 0x20010000,
4584
#if 0
4585
    CPU_POWERPC_405D3       = xxx,
4586
#endif
4587
    CPU_POWERPC_405D4       = 0x41810000,
4588
#if 0
4589
    CPU_POWERPC_405D5       = xxx,
4590
#endif
4591
#if 0
4592
    CPU_POWERPC_405E4       = xxx,
4593
#endif
4594
#if 0
4595
    CPU_POWERPC_405F4       = xxx,
4596
#endif
4597
#if 0
4598
    CPU_POWERPC_405F5       = xxx,
4599
#endif
4600
#if 0
4601
    CPU_POWERPC_405F6       = xxx,
4602
#endif
4603
    /* PowerPC 405 microcontrolers */
4604
    /* XXX: missing 0x200108a0 */
4605
#define CPU_POWERPC_405CR     CPU_POWERPC_405CRc
4606
    CPU_POWERPC_405CRa      = 0x40110041,
4607
    CPU_POWERPC_405CRb      = 0x401100C5,
4608
    CPU_POWERPC_405CRc      = 0x40110145,
4609
    CPU_POWERPC_405EP       = 0x51210950,
4610
#if 0
4611
    CPU_POWERPC_405EXr      = xxx,
4612
#endif
4613
    CPU_POWERPC_405EZ       = 0x41511460, /* 0x51210950 ? */
4614
#if 0
4615
    CPU_POWERPC_405FX       = xxx,
4616
#endif
4617
#define CPU_POWERPC_405GP     CPU_POWERPC_405GPd
4618
    CPU_POWERPC_405GPa      = 0x40110000,
4619
    CPU_POWERPC_405GPb      = 0x40110040,
4620
    CPU_POWERPC_405GPc      = 0x40110082,
4621
    CPU_POWERPC_405GPd      = 0x401100C4,
4622
#define CPU_POWERPC_405GPe    CPU_POWERPC_405CRc
4623
    CPU_POWERPC_405GPR      = 0x50910951,
4624
#if 0
4625
    CPU_POWERPC_405H        = xxx,
4626
#endif
4627
#if 0
4628
    CPU_POWERPC_405L        = xxx,
4629
#endif
4630
    CPU_POWERPC_405LP       = 0x41F10000,
4631
#if 0
4632
    CPU_POWERPC_405PM       = xxx,
4633
#endif
4634
#if 0
4635
    CPU_POWERPC_405PS       = xxx,
4636
#endif
4637
#if 0
4638
    CPU_POWERPC_405S        = xxx,
4639
#endif
4640
    /* IBM network processors */
4641
    CPU_POWERPC_NPE405H     = 0x414100C0,
4642
    CPU_POWERPC_NPE405H2    = 0x41410140,
4643
    CPU_POWERPC_NPE405L     = 0x416100C0,
4644
    CPU_POWERPC_NPE4GS3     = 0x40B10000,
4645
#if 0
4646
    CPU_POWERPC_NPCxx1      = xxx,
4647
#endif
4648
#if 0
4649
    CPU_POWERPC_NPR161      = xxx,
4650
#endif
4651
#if 0
4652
    CPU_POWERPC_LC77700     = xxx,
4653
#endif
4654
    /* IBM STBxxx (PowerPC 401/403/405 core based microcontrollers) */
4655
#if 0
4656
    CPU_POWERPC_STB01000    = xxx,
4657
#endif
4658
#if 0
4659
    CPU_POWERPC_STB01010    = xxx,
4660
#endif
4661
#if 0
4662
    CPU_POWERPC_STB0210     = xxx, /* 401B3 */
4663
#endif
4664
    CPU_POWERPC_STB03       = 0x40310000, /* 0x40130000 ? */
4665
#if 0
4666
    CPU_POWERPC_STB043      = xxx,
4667
#endif
4668
#if 0
4669
    CPU_POWERPC_STB045      = xxx,
4670
#endif
4671
    CPU_POWERPC_STB04       = 0x41810000,
4672
    CPU_POWERPC_STB25       = 0x51510950,
4673
#if 0
4674
    CPU_POWERPC_STB130      = xxx,
4675
#endif
4676
    /* Xilinx cores */
4677
    CPU_POWERPC_X2VP4       = 0x20010820,
4678
#define CPU_POWERPC_X2VP7     CPU_POWERPC_X2VP4
4679
    CPU_POWERPC_X2VP20      = 0x20010860,
4680
#define CPU_POWERPC_X2VP50    CPU_POWERPC_X2VP20
4681
#if 0
4682
    CPU_POWERPC_ZL10310     = xxx,
4683
#endif
4684
#if 0
4685
    CPU_POWERPC_ZL10311     = xxx,
4686
#endif
4687
#if 0
4688
    CPU_POWERPC_ZL10320     = xxx,
4689
#endif
4690
#if 0
4691
    CPU_POWERPC_ZL10321     = xxx,
4692
#endif
4693
    /* PowerPC 440 family */
4694
    /* Generic PowerPC 440 */
4695
#define CPU_POWERPC_440       CPU_POWERPC_440GXf
4696
    /* PowerPC 440 cores */
4697
#if 0
4698
    CPU_POWERPC_440A4       = xxx,
4699
#endif
4700
#if 0
4701
    CPU_POWERPC_440A5       = xxx,
4702
#endif
4703
#if 0
4704
    CPU_POWERPC_440B4       = xxx,
4705
#endif
4706
#if 0
4707
    CPU_POWERPC_440F5       = xxx,
4708
#endif
4709
#if 0
4710
    CPU_POWERPC_440G5       = xxx,
4711
#endif
4712
#if 0
4713
    CPU_POWERPC_440H4       = xxx,
4714
#endif
4715
#if 0
4716
    CPU_POWERPC_440H6       = xxx,
4717
#endif
4718
    /* PowerPC 440 microcontrolers */
4719
#define CPU_POWERPC_440EP     CPU_POWERPC_440EPb
4720
    CPU_POWERPC_440EPa      = 0x42221850,
4721
    CPU_POWERPC_440EPb      = 0x422218D3,
4722
#define CPU_POWERPC_440GP     CPU_POWERPC_440GPc
4723
    CPU_POWERPC_440GPb      = 0x40120440,
4724
    CPU_POWERPC_440GPc      = 0x40120481,
4725
#define CPU_POWERPC_440GR     CPU_POWERPC_440GRa
4726
#define CPU_POWERPC_440GRa    CPU_POWERPC_440EPb
4727
    CPU_POWERPC_440GRX      = 0x200008D0,
4728
#define CPU_POWERPC_440EPX    CPU_POWERPC_440GRX
4729
#define CPU_POWERPC_440GX     CPU_POWERPC_440GXf
4730
    CPU_POWERPC_440GXa      = 0x51B21850,
4731
    CPU_POWERPC_440GXb      = 0