source: rtems/c/src/lib/libcpu/powerpc/shared/include/cpuIdent.h @ e08dbc5

4.104.115
Last change on this file since e08dbc5 was e08dbc5, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 11/03/09 at 18:45:04

various PowerPC code maintenance

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (C) 1999  Eric Valette (valette@crf.canon.fr)
3 *                     Canon Centre Recherche France.
4 *
5 *  Added MPC8260 Andy Dachs <a.dachs@sstl.co.uk>
6 *  Surrey Satellite Technology Limited
7 *
8 *
9 *  The license and distribution terms for this file may be
10 *  found in found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#ifndef _LIBCPU_CPUIDENT_H
17#define _LIBCPU_CPUIDENT_H
18
19#include <stdbool.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#ifndef ASM
26typedef enum
27{
28  PPC_601 = 0x1,
29  PPC_5XX = 0x2,
30  PPC_603 = 0x3,
31  PPC_604 = 0x4,
32  PPC_603e = 0x6,
33  PPC_603ev = 0x7,
34  PPC_750 = 0x8,
35  PPC_604e = 0x9,
36  PPC_604r = 0xA,
37  PPC_7400 = 0xC,
38  PPC_405  = 0x2001,
39  PPC_405EX = 0x1291,   /* + 405EXr */
40  PPC_405GP = 0x4011,   /* + 405CR */
41  PPC_405GPr = 0x5091,
42  PPC_405EZ = 0x4151,
43  PPC_405EP = 0x5121,
44  PPC_7455 = 0x8001, /* Kate Feng */
45  PPC_7457 = 0x8002,
46  PPC_620 = 0x16,
47  PPC_860 = 0x50,
48  PPC_821 = PPC_860,
49  PPC_823 = PPC_860,
50  PPC_8260 = 0x81,
51  PPC_8240 = PPC_8260,
52  PPC_8245 = 0x8081,
53  PPC_8540 = 0x8020,
54  PPC_603le = 0x8082, /* 603le core, in MGT5100 and MPC5200 */
55  PPC_e300c1  = 0x8083, /* e300c1  core, in MPC83xx*/
56  PPC_e300c2  = 0x8084, /* e300c2  core */
57  PPC_e300c3  = 0x8085, /* e300c3  core */
58  PPC_e200z6 = 0x8115,
59  PPC_PSIM = 0xfffe,  /* GDB PowerPC simulator -- fake version */
60  PPC_UNKNOWN = 0xffff
61} ppc_cpu_id_t;
62
63/* Bitfield of for identifying features or groups of cpu flavors.
64 * DO NOT USE DIRECTLY (as implementation may change)
65 * only use the 'ppc_is_xxx() / ppc_has_xxx()' macros/inlines
66 * below.
67 */
68
69typedef struct {
70        unsigned has_altivec            : 1;
71        unsigned has_fpu                        : 1;
72        unsigned has_hw_ptbl_lkup       : 1;
73#define PPC_BOOKE_405   1       /* almost like booke but with some significant differences */
74#define PPC_BOOKE_STD   2
75#define PPC_BOOKE_E500  3       /* bookE with extensions */
76        unsigned is_bookE                       : 2;
77        unsigned has_16byte_clne        : 1;
78        unsigned is_60x             : 1;
79        unsigned has_8_bats                     : 1;
80        unsigned has_epic           : 1;
81        unsigned has_shadowed_gprs  : 1;
82        unsigned has_ivpr_and_ivor  : 1;
83} ppc_feature_t;
84
85extern ppc_feature_t   current_ppc_features;
86extern ppc_cpu_id_t current_ppc_cpu;
87
88typedef unsigned short ppc_cpu_revision_t;
89
90extern ppc_cpu_id_t get_ppc_cpu_type ();
91extern char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu);
92extern ppc_cpu_revision_t get_ppc_cpu_revision ();
93extern ppc_cpu_revision_t current_ppc_revision;
94
95/* PUBLIC ACCESS ROUTINES */
96#define _PPC_FEAT_DECL(x) \
97static inline unsigned ppc_cpu_##x() { \
98  if ( PPC_UNKNOWN == current_ppc_cpu ) \
99    get_ppc_cpu_type(); \
100  return current_ppc_features.x; \
101}
102
103_PPC_FEAT_DECL(has_altivec)
104/* has_fpu not implemented yet */
105_PPC_FEAT_DECL(has_hw_ptbl_lkup)
106_PPC_FEAT_DECL(is_bookE)
107_PPC_FEAT_DECL(is_60x)
108_PPC_FEAT_DECL(has_8_bats)
109_PPC_FEAT_DECL(has_epic)
110_PPC_FEAT_DECL(has_shadowed_gprs)
111_PPC_FEAT_DECL(has_ivpr_and_ivor)
112
113#undef _PPC_FEAT_DECL
114
115static inline ppc_cpu_id_t ppc_cpu_current(void)
116{
117        return current_ppc_cpu;
118}
119
120static inline bool ppc_cpu_is_e300()
121{
122        if (ppc_cpu_current() == PPC_UNKNOWN) {
123                get_ppc_cpu_type();
124        }
125        return ppc_cpu_current() == PPC_e300c1
126                || ppc_cpu_current() == PPC_e300c2
127                || ppc_cpu_current() == PPC_e300c3;
128}
129
130static inline bool ppc_cpu_is(ppc_cpu_id_t cpu)
131{
132        return ppc_cpu_current() == cpu;
133}
134
135#endif /* ASM */
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif
Note: See TracBrowser for help on using the repository browser.