~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to target-ppc/cpu.h

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-22 10:13:17 UTC
  • mfrom: (1.2.1 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090322101317-iigjtnu5qil35dtb
Tags: 0.10.1-1
[ Aurelien Jarno ]
* New upstream stable release:
  - patches/80_stable-branch.patch: remove.
* debian/control: 
  - Remove depends on proll.
  - Move depends on device-tree-compiler to build-depends.
  - Bump Standards-Version to 3.8.1 (no changes).
* patches/82_qemu-img_decimal.patch: new patch from upstream to make
  qemu-img accept sizes with decimal values (closes: bug#501400).

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 * You should have received a copy of the GNU Lesser General Public
17
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
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
19
19
 */
20
20
#if !defined (__CPU_PPC_H__)
21
21
#define __CPU_PPC_H__
27
27
 
28
28
#if defined (TARGET_PPC64)
29
29
/* PowerPC 64 definitions */
30
 
typedef uint64_t ppc_gpr_t;
31
30
#define TARGET_LONG_BITS 64
32
31
#define TARGET_PAGE_BITS 12
33
32
 
34
33
#else /* defined (TARGET_PPC64) */
35
34
/* PowerPC 32 definitions */
36
 
#if (HOST_LONG_BITS >= 64)
37
 
/* When using 64 bits temporary registers,
38
 
 * we can use 64 bits GPR with no extra cost
39
 
 * It's even an optimization as this will prevent
40
 
 * the compiler to do unuseful masking in the micro-ops.
41
 
 */
42
 
typedef uint64_t ppc_gpr_t;
43
 
#else /* (HOST_LONG_BITS >= 64) */
44
 
typedef uint32_t ppc_gpr_t;
45
 
#endif /* (HOST_LONG_BITS >= 64) */
46
 
 
47
35
#define TARGET_LONG_BITS 32
48
36
 
49
37
#if defined(TARGET_PPCEMB)
78
66
 
79
67
#define TARGET_HAS_ICE 1
80
68
 
81
 
#if defined (TARGET_PPC64)
 
69
/* Load a 32 bit BIOS also on 64 bit machines */
 
70
#if defined (TARGET_PPC64) && defined(CONFIG_USER_ONLY)
82
71
#define ELF_MACHINE     EM_PPC64
83
72
#else
84
73
#define ELF_MACHINE     EM_PPC
307
296
 
308
297
/* SPR access micro-ops generations callbacks */
309
298
struct ppc_spr_t {
310
 
    void (*uea_read)(void *opaque, int spr_num);
311
 
    void (*uea_write)(void *opaque, int spr_num);
 
299
    void (*uea_read)(void *opaque, int gpr_num, int spr_num);
 
300
    void (*uea_write)(void *opaque, int spr_num, int gpr_num);
312
301
#if !defined(CONFIG_USER_ONLY)
313
 
    void (*oea_read)(void *opaque, int spr_num);
314
 
    void (*oea_write)(void *opaque, int spr_num);
315
 
    void (*hea_read)(void *opaque, int spr_num);
316
 
    void (*hea_write)(void *opaque, int spr_num);
 
302
    void (*oea_read)(void *opaque, int gpr_num, int spr_num);
 
303
    void (*oea_write)(void *opaque, int spr_num, int gpr_num);
 
304
    void (*hea_read)(void *opaque, int gpr_num, int spr_num);
 
305
    void (*hea_write)(void *opaque, int spr_num, int gpr_num);
317
306
#endif
318
 
    const unsigned char *name;
 
307
    const char *name;
319
308
};
320
309
 
321
310
/* Altivec registers (128 bits) */
322
311
union ppc_avr_t {
 
312
    float32 f[4];
323
313
    uint8_t u8[16];
324
314
    uint16_t u16[8];
325
315
    uint32_t u32[4];
 
316
    int8_t s8[16];
 
317
    int16_t s16[8];
 
318
    int32_t s32[4];
326
319
    uint64_t u64[2];
327
320
};
328
321
 
397
390
#define msr_thv  ((env->msr >> MSR_THV)  & 1)
398
391
#define msr_ucle ((env->msr >> MSR_UCLE) & 1)
399
392
#define msr_vr   ((env->msr >> MSR_VR)   & 1)
400
 
#define msr_spe  ((env->msr >> MSR_SE)   & 1)
 
393
#define msr_spe  ((env->msr >> MSR_SPE)  & 1)
401
394
#define msr_ap   ((env->msr >> MSR_AP)   & 1)
402
395
#define msr_sa   ((env->msr >> MSR_SA)   & 1)
403
396
#define msr_key  ((env->msr >> MSR_KEY)  & 1)
534
527
                   0x1F)
535
528
 
536
529
/*****************************************************************************/
 
530
/* Vector status and control register */
 
531
#define VSCR_NJ         16 /* Vector non-java */
 
532
#define VSCR_SAT        0 /* Vector saturation */
 
533
#define vscr_nj         (((env->vscr) >> VSCR_NJ)       & 0x1)
 
534
#define vscr_sat        (((env->vscr) >> VSCR_SAT)      & 0x1)
 
535
 
 
536
/*****************************************************************************/
537
537
/* The whole PowerPC CPU context */
538
538
#define NB_MMU_MODES 3
539
539
 
541
541
    /* First are the most commonly used resources
542
542
     * during translated code execution
543
543
     */
544
 
#if (HOST_LONG_BITS == 32)
545
 
    /* temporary fixed-point registers
546
 
     * used to emulate 64 bits registers on 32 bits hosts
547
 
     */
548
 
    uint64_t t0, t1, t2;
549
 
#endif
550
 
    ppc_avr_t avr0, avr1, avr2;
551
 
 
552
544
    /* general purpose registers */
553
 
    ppc_gpr_t gpr[32];
 
545
    target_ulong gpr[32];
554
546
#if !defined(TARGET_PPC64)
555
547
    /* Storage for GPR MSB, used by the SPE extension */
556
 
    ppc_gpr_t gprh[32];
 
548
    target_ulong gprh[32];
557
549
#endif
558
550
    /* LR */
559
551
    target_ulong lr;
560
552
    /* CTR */
561
553
    target_ulong ctr;
562
554
    /* condition register */
563
 
    uint8_t crf[8];
 
555
    uint32_t crf[8];
564
556
    /* XER */
565
 
    /* XXX: We use only 5 fields, but we want to keep the structure aligned */
566
 
    uint8_t xer[8];
 
557
    target_ulong xer;
567
558
    /* Reservation address */
568
559
    target_ulong reserve;
569
560
 
571
562
    /* machine state register */
572
563
    target_ulong msr;
573
564
    /* temporary general purpose registers */
574
 
    ppc_gpr_t tgpr[4]; /* Used to speed-up TLB assist handlers */
 
565
    target_ulong tgpr[4]; /* Used to speed-up TLB assist handlers */
575
566
 
576
567
    /* Floating point execution context */
577
 
    /* temporary float registers */
578
 
    float64 ft0;
579
 
    float64 ft1;
580
 
    float64 ft2;
581
568
    float_status fp_status;
582
569
    /* floating point registers */
583
570
    float64 fpr[32];
586
573
 
587
574
    CPU_COMMON
588
575
 
589
 
    int halted; /* TRUE if the CPU is in suspend state */
590
 
 
591
576
    int access_type; /* when a memory exception occurs, the access
592
577
                        type is stored here */
593
578
 
601
586
#endif
602
587
    /* segment registers */
603
588
    target_ulong sdr1;
604
 
    target_ulong sr[16];
 
589
    target_ulong sr[32];
605
590
    /* BATs */
606
591
    int nb_BATs;
607
592
    target_ulong DBAT[2][8];
626
611
    ppc_avr_t avr[32];
627
612
    uint32_t vscr;
628
613
    /* SPE registers */
629
 
    ppc_gpr_t spe_acc;
630
 
    float_status spe_status;
 
614
    uint64_t spe_acc;
631
615
    uint32_t spe_fscr;
 
616
    /* SPE and Altivec can share a status since they will never be used
 
617
     * simultaneously */
 
618
    float_status vec_status;
632
619
 
633
620
    /* Internal devices resources */
634
621
    /* Time base and decrementer */
648
635
    int bfd_mach;
649
636
    uint32_t flags;
650
637
 
651
 
    int exception_index;
652
638
    int error_code;
653
 
    int interrupt_request;
654
639
    uint32_t pending_interrupts;
655
640
#if !defined(CONFIG_USER_ONLY)
656
641
    /* This is the IRQ controller, which is implementation dependant
674
659
    opc_handler_t *opcodes[0x40];
675
660
 
676
661
    /* Those resources are used only in Qemu core */
677
 
    jmp_buf jmp_env;
678
 
    int user_mode_only; /* user mode only simulation */
679
662
    target_ulong hflags;      /* hflags is a MSR & HFLAGS_MASK         */
680
663
    target_ulong hflags_nmsr; /* specific hflags, not comming from MSR */
681
664
    int mmu_idx;         /* precomputed MMU index to speed up mem accesses */
701
684
 
702
685
/*****************************************************************************/
703
686
CPUPPCState *cpu_ppc_init (const char *cpu_model);
 
687
void ppc_translate_init(void);
704
688
int cpu_ppc_exec (CPUPPCState *s);
705
689
void cpu_ppc_close (CPUPPCState *s);
706
690
/* you can call this signal handler from your SIGBUS and SIGSEGV
708
692
   is returned if the signal was handled by the virtual CPU.  */
709
693
int cpu_ppc_signal_handler (int host_signum, void *pinfo,
710
694
                            void *puc);
711
 
 
 
695
int cpu_ppc_handle_mmu_fault (CPUPPCState *env, target_ulong address, int rw,
 
696
                              int mmu_idx, int is_softmmu);
 
697
int get_physical_address (CPUPPCState *env, mmu_ctx_t *ctx, target_ulong vaddr,
 
698
                          int rw, int access_type);
712
699
void do_interrupt (CPUPPCState *env);
713
700
void ppc_hw_interrupt (CPUPPCState *env);
714
 
void cpu_loop_exit (void);
715
701
 
716
 
void dump_stack (CPUPPCState *env);
 
702
void cpu_dump_rfi (target_ulong RA, target_ulong msr);
717
703
 
718
704
#if !defined(CONFIG_USER_ONLY)
719
 
target_ulong do_load_ibatu (CPUPPCState *env, int nr);
720
 
target_ulong do_load_ibatl (CPUPPCState *env, int nr);
721
 
void do_store_ibatu (CPUPPCState *env, int nr, target_ulong value);
722
 
void do_store_ibatl (CPUPPCState *env, int nr, target_ulong value);
723
 
target_ulong do_load_dbatu (CPUPPCState *env, int nr);
724
 
target_ulong do_load_dbatl (CPUPPCState *env, int nr);
725
 
void do_store_dbatu (CPUPPCState *env, int nr, target_ulong value);
726
 
void do_store_dbatl (CPUPPCState *env, int nr, target_ulong value);
727
 
void do_store_ibatu_601 (CPUPPCState *env, int nr, target_ulong value);
728
 
void do_store_ibatl_601 (CPUPPCState *env, int nr, target_ulong value);
729
 
target_ulong do_load_sdr1 (CPUPPCState *env);
730
 
void do_store_sdr1 (CPUPPCState *env, target_ulong value);
 
705
void ppc6xx_tlb_store (CPUPPCState *env, target_ulong EPN, int way, int is_code,
 
706
                       target_ulong pte0, target_ulong pte1);
 
707
void ppc_store_ibatu (CPUPPCState *env, int nr, target_ulong value);
 
708
void ppc_store_ibatl (CPUPPCState *env, int nr, target_ulong value);
 
709
void ppc_store_dbatu (CPUPPCState *env, int nr, target_ulong value);
 
710
void ppc_store_dbatl (CPUPPCState *env, int nr, target_ulong value);
 
711
void ppc_store_ibatu_601 (CPUPPCState *env, int nr, target_ulong value);
 
712
void ppc_store_ibatl_601 (CPUPPCState *env, int nr, target_ulong value);
 
713
void ppc_store_sdr1 (CPUPPCState *env, target_ulong value);
731
714
#if defined(TARGET_PPC64)
732
 
target_ulong ppc_load_asr (CPUPPCState *env);
733
715
void ppc_store_asr (CPUPPCState *env, target_ulong value);
734
716
target_ulong ppc_load_slb (CPUPPCState *env, int slb_nr);
735
717
void ppc_store_slb (CPUPPCState *env, int slb_nr, target_ulong rs);
736
718
#endif /* defined(TARGET_PPC64) */
737
 
#if 0 // Unused
738
 
target_ulong do_load_sr (CPUPPCState *env, int srnum);
739
 
#endif
740
 
void do_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 
719
void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
741
720
#endif /* !defined(CONFIG_USER_ONLY) */
742
 
target_ulong ppc_load_xer (CPUPPCState *env);
743
 
void ppc_store_xer (CPUPPCState *env, target_ulong value);
744
721
void ppc_store_msr (CPUPPCState *env, target_ulong value);
745
722
 
746
723
void cpu_ppc_reset (void *opaque);
747
724
 
748
725
void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
749
726
 
750
 
const ppc_def_t *cpu_ppc_find_by_name (const unsigned char *name);
 
727
const ppc_def_t *cpu_ppc_find_by_name (const char *name);
751
728
int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def);
752
729
 
753
730
/* Time-base and decrementer management */
816
793
#define cpu_signal_handler cpu_ppc_signal_handler
817
794
#define cpu_list ppc_cpu_list
818
795
 
 
796
#define CPU_SAVE_VERSION 3
 
797
 
819
798
/* MMU modes definitions */
820
799
#define MMU_MODE0_SUFFIX _user
821
800
#define MMU_MODE1_SUFFIX _kernel
826
805
    return env->mmu_idx;
827
806
}
828
807
 
 
808
#if defined(CONFIG_USER_ONLY)
 
809
static inline void cpu_clone_regs(CPUState *env, target_ulong newsp)
 
810
{
 
811
    int i;
 
812
    if (newsp)
 
813
        env->gpr[1] = newsp;
 
814
    for (i = 7; i < 32; i++)
 
815
        env->gpr[i] = 0;
 
816
}
 
817
#endif
 
818
 
829
819
#include "cpu-all.h"
 
820
#include "exec-all.h"
830
821
 
831
822
/*****************************************************************************/
832
 
/* Registers definitions */
833
 
#define XER_SO 31
834
 
#define XER_OV 30
835
 
#define XER_CA 29
836
 
#define XER_CMP 8
837
 
#define XER_BC  0
838
 
#define xer_so  env->xer[4]
839
 
#define xer_ov  env->xer[6]
840
 
#define xer_ca  env->xer[2]
841
 
#define xer_cmp env->xer[1]
842
 
#define xer_bc  env->xer[0]
 
823
/* CRF definitions */
 
824
#define CRF_LT        3
 
825
#define CRF_GT        2
 
826
#define CRF_EQ        1
 
827
#define CRF_SO        0
 
828
#define CRF_CH        (1 << 4)
 
829
#define CRF_CL        (1 << 3)
 
830
#define CRF_CH_OR_CL  (1 << 2)
 
831
#define CRF_CH_AND_CL (1 << 1)
 
832
 
 
833
/* XER definitions */
 
834
#define XER_SO  31
 
835
#define XER_OV  30
 
836
#define XER_CA  29
 
837
#define XER_CMP  8
 
838
#define XER_BC   0
 
839
#define xer_so  ((env->xer >> XER_SO)  &    1)
 
840
#define xer_ov  ((env->xer >> XER_OV)  &    1)
 
841
#define xer_ca  ((env->xer >> XER_CA)  &    1)
 
842
#define xer_cmp ((env->xer >> XER_CMP) & 0xFF)
 
843
#define xer_bc  ((env->xer >> XER_BC)  & 0x7F)
843
844
 
844
845
/* SPR definitions */
845
846
#define SPR_MQ                (0x000)
1355
1356
};
1356
1357
 
1357
1358
enum {
 
1359
    /* PowerPC E500 input pins */
 
1360
    PPCE500_INPUT_RESET_CORE = 0,
 
1361
    PPCE500_INPUT_MCK        = 1,
 
1362
    PPCE500_INPUT_CINT       = 3,
 
1363
    PPCE500_INPUT_INT        = 4,
 
1364
    PPCE500_INPUT_DEBUG      = 6,
 
1365
    PPCE500_INPUT_NB,
 
1366
};
 
1367
 
 
1368
enum {
1358
1369
    /* PowerPC 40x input pins */
1359
1370
    PPC40x_INPUT_RESET_CORE = 0,
1360
1371
    PPC40x_INPUT_RESET_CHIP = 1,
1420
1431
 
1421
1432
/*****************************************************************************/
1422
1433
 
 
1434
static inline void cpu_pc_from_tb(CPUState *env, TranslationBlock *tb)
 
1435
{
 
1436
    env->nip = tb->pc;
 
1437
}
 
1438
 
 
1439
static inline void cpu_get_tb_cpu_state(CPUState *env, target_ulong *pc,
 
1440
                                        target_ulong *cs_base, int *flags)
 
1441
{
 
1442
    *pc = env->nip;
 
1443
    *cs_base = 0;
 
1444
    *flags = env->hflags;
 
1445
}
 
1446
 
1423
1447
#endif /* !defined (__CPU_PPC_H__) */