File indexing completed on 2025-05-11 08:23:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _LIBCPU_CPUIDENT_H
0015 #define _LIBCPU_CPUIDENT_H
0016
0017 #include <stdbool.h>
0018
0019 #ifdef __cplusplus
0020 extern "C" {
0021 #endif
0022
0023 #ifndef ASM
0024 typedef enum
0025 {
0026 PPC_601 = 0x1,
0027 PPC_5XX = 0x2,
0028 PPC_603 = 0x3,
0029 PPC_604 = 0x4,
0030 PPC_603e = 0x6,
0031 PPC_603ev = 0x7,
0032 PPC_750 = 0x8,
0033 PPC_750_IBM = 0x7000,
0034 PPC_604e = 0x9,
0035 PPC_604r = 0xA,
0036 PPC_7400 = 0xC,
0037 PPC_405 = 0x2001,
0038 PPC_405EX = 0x1291,
0039 PPC_405GP = 0x4011,
0040 PPC_405GPr = 0x5091,
0041 PPC_405EZ = 0x4151,
0042 PPC_405EP = 0x5121,
0043 PPC_440 = 0x7ff2,
0044 PPC_7455 = 0x8001,
0045 PPC_7457 = 0x8002,
0046 PPC_620 = 0x16,
0047 PPC_860 = 0x50,
0048 PPC_821 = PPC_860,
0049 PPC_823 = PPC_860,
0050 PPC_8260 = 0x81,
0051 PPC_8240 = PPC_8260,
0052 PPC_8245 = 0x8081,
0053 PPC_8540 = 0x8020,
0054 PPC_e500v2 = 0x8021,
0055 PPC_e6500 = 0x8040,
0056 PPC_603le = 0x8082,
0057 PPC_e300c1 = 0x8083,
0058 PPC_e300c2 = 0x8084,
0059 PPC_e300c3 = 0x8085,
0060 PPC_e200z0 = 0x8170,
0061 PPC_e200z1 = 0x8140,
0062 PPC_e200z4 = 0x8150,
0063 PPC_e200z6 = 0x8110,
0064 PPC_e200z7 = 0x8160,
0065 PPC_PSIM = 0xfffe,
0066 PPC_UNKNOWN = 0xffff
0067 } ppc_cpu_id_t;
0068
0069
0070
0071
0072
0073
0074
0075 typedef struct {
0076 unsigned has_altivec : 1;
0077 unsigned has_fpu : 1;
0078 unsigned has_hw_ptbl_lkup : 1;
0079 #define PPC_BOOKE_405 1
0080 #define PPC_BOOKE_STD 2
0081 #define PPC_BOOKE_E500 3
0082 unsigned is_bookE : 2;
0083 unsigned has_16byte_clne : 1;
0084 unsigned is_60x : 1;
0085 unsigned has_8_bats : 1;
0086 unsigned has_epic : 1;
0087 unsigned has_shadowed_gprs : 1;
0088 } ppc_feature_t;
0089
0090 extern ppc_feature_t current_ppc_features;
0091 extern ppc_cpu_id_t current_ppc_cpu;
0092
0093 typedef unsigned short ppc_cpu_revision_t;
0094
0095 extern ppc_cpu_id_t get_ppc_cpu_type (void);
0096 extern const char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu);
0097 extern ppc_cpu_revision_t get_ppc_cpu_revision (void);
0098 extern ppc_cpu_revision_t current_ppc_revision;
0099
0100
0101 #define _PPC_FEAT_DECL(x) \
0102 static inline unsigned ppc_cpu_##x(void) { \
0103 if ( PPC_UNKNOWN == current_ppc_cpu ) \
0104 get_ppc_cpu_type(); \
0105 return current_ppc_features.x; \
0106 }
0107
0108 _PPC_FEAT_DECL(has_altivec)
0109
0110 _PPC_FEAT_DECL(has_hw_ptbl_lkup)
0111 _PPC_FEAT_DECL(is_bookE)
0112 _PPC_FEAT_DECL(is_60x)
0113 _PPC_FEAT_DECL(has_8_bats)
0114 _PPC_FEAT_DECL(has_epic)
0115 _PPC_FEAT_DECL(has_shadowed_gprs)
0116
0117 #undef _PPC_FEAT_DECL
0118
0119 static inline ppc_cpu_id_t ppc_cpu_current(void)
0120 {
0121 return current_ppc_cpu;
0122 }
0123
0124 static inline bool ppc_cpu_is_e200(void)
0125 {
0126 return (ppc_cpu_current() & 0xff80) == 0x8100;
0127 }
0128
0129 static inline bool ppc_cpu_is_specific_e200(ppc_cpu_id_t id)
0130 {
0131 return (ppc_cpu_current() & 0xfff0) == id;
0132 }
0133
0134 static inline bool ppc_cpu_is_e300(void)
0135 {
0136 return ppc_cpu_current() == PPC_e300c1
0137 || ppc_cpu_current() == PPC_e300c2
0138 || ppc_cpu_current() == PPC_e300c3;
0139 }
0140
0141 static inline bool ppc_cpu_is_e500(void)
0142 {
0143 return ppc_cpu_current() == PPC_8540
0144 || ppc_cpu_current() == PPC_e500v2;
0145 }
0146
0147 static inline bool ppc_cpu_is(ppc_cpu_id_t cpu)
0148 {
0149 return ppc_cpu_current() == cpu;
0150 }
0151
0152 #endif
0153
0154 #ifdef __cplusplus
0155 }
0156 #endif
0157
0158 #endif