2007-11-29 Till Straumann <strauman@slac.stanford.edu>

* shared/include/cpuIdent.h, shared/include/cpuIdent.c:
	Added a simple 'feature check' facility. Code should
	not check for a particular CPU type if possible but
	check the respective feature bit (e.g., 'has_altivec').
	This makes it much less cumbersome to add more CPU
	types in the future.
This commit is contained in:
Till Straumann
2007-12-01 00:06:00 +00:00
parent 9edf584f3b
commit e955b062fb
3 changed files with 100 additions and 3 deletions

View File

@@ -39,6 +39,7 @@ typedef enum
PPC_8260 = 0x81,
PPC_8240 = PPC_8260,
PPC_8245 = 0x8081,
PPC_8540 = 0x8020,
PPC_603le = 0x8082, /* 603le core, in MGT5100 and MPC5200 */
PPC_e300c1 = 0x8083, /* e300c1 core, in MPC83xx*/
PPC_e300c2 = 0x8084, /* e300c2 core */
@@ -47,6 +48,39 @@ typedef enum
PPC_UNKNOWN = 0xffff
} ppc_cpu_id_t;
/* Bitfield of for identifying features or groups of cpu flavors.
* DO NOT USE DIRECTLY (as implementation may change)
* only use the 'ppc_is_xxx() / ppc_has_xxx()' macros/inlines
* below.
*/
typedef struct {
unsigned has_altivec : 1;
unsigned has_fpu : 1;
unsigned has_hw_ptbl_lkup : 1;
unsigned is_bookE : 1;
unsigned has_16byte_clne : 1;
unsigned is_60x : 1;
unsigned has_8_bats : 1;
unsigned has_epic : 1;
} ppc_feature_t;
extern ppc_feature_t current_ppc_features;
/* PUBLIC ACCESS ROUTINES */
#define _PPC_FEAT_DECL(x) \
static inline ppc_cpu_##x() { if ( PPC_UNKNOWN == current_ppc_cpu ) get_ppc_cpu_type(); return current_ppc_features.x; }
_PPC_FEAT_DECL(has_altivec)
/* has_fpu not implemented yet */
_PPC_FEAT_DECL(has_hw_ptbl_lkup)
_PPC_FEAT_DECL(is_bookE)
_PPC_FEAT_DECL(is_60x)
_PPC_FEAT_DECL(has_8_bats)
_PPC_FEAT_DECL(has_epic)
#undef _PPC_FEAT_DECL
typedef unsigned short ppc_cpu_revision_t;
extern ppc_cpu_id_t get_ppc_cpu_type ();