source: rtems/c/src/lib/libcpu/powerpc/shared/include/cpuIdent.c @ 9ec91233

4.104.114.95
Last change on this file since 9ec91233 was 25a92bc1, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/11/08 at 10:02:12

adapted powerpc exception code

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 *  cpuIdent.c -- Cpu identification code
3 *
4 *  Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
5 *
6 *  Added MPC8260 Andy Dachs <a.dachs@sstl.co.uk>
7 *  Surrey Satellite Technology Limited
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
17#include <libcpu/cpuIdent.h>
18#include <libcpu/spr.h>
19#include <rtems/bspIo.h>
20
21/*
22 * Generate inline code to read Processor Version Register
23 */
24SPR_RO(PVR)
25
26ppc_cpu_id_t       current_ppc_cpu      = PPC_UNKNOWN;
27ppc_cpu_revision_t current_ppc_revision = 0xff;
28ppc_feature_t      current_ppc_features = {0};
29
30char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu)
31{
32  switch (cpu) {
33    case PPC_405:               return "PPC405";
34    case PPC_601:               return "MPC601";
35    case PPC_5XX:               return "MPC5XX";
36    case PPC_603:               return "MPC603";
37    case PPC_603ev:             return "MPC603ev";
38    case PPC_604:               return "MPC604";
39    case PPC_750:               return "MPC750";
40    case PPC_7400:              return "MPC7400";
41    case PPC_7455:              return "MPC7455";
42    case PPC_7457:              return "MPC7457";
43    case PPC_603le:             return "MPC603le";
44    case PPC_604e:              return "MPC604e";
45    case PPC_604r:              return "MPC604r";
46    case PPC_620:               return "MPC620";
47    case PPC_860:               return "MPC860";
48    case PPC_8260:              return "MPC8260";
49    case PPC_8245:              return "MPC8245";
50    case PPC_8540:              return "MPC8540";
51    case PPC_PSIM:              return "PSIM";
52    case PPC_e200z6:            return "e200z6";
53    default:
54      printk("Unknown CPU value of 0x%x. Please add it to "
55             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", cpu );
56  }
57  return "UNKNOWN";
58}
59
60ppc_cpu_id_t get_ppc_cpu_type()
61{
62  unsigned int pvr;
63
64  if ( PPC_UNKNOWN != current_ppc_cpu )
65        return current_ppc_cpu;
66
67  pvr = (_read_PVR() >> 16);
68  current_ppc_cpu = (ppc_cpu_id_t) pvr;
69
70  switch (pvr) {
71    case PPC_405:
72    case PPC_601:
73    case PPC_5XX:
74    case PPC_603:
75    case PPC_603ev:
76    case PPC_603le:
77    case PPC_604:
78    case PPC_604r:
79    case PPC_750:
80    case PPC_7400:
81    case PPC_7455:
82    case PPC_7457:
83    case PPC_604e:
84    case PPC_620:
85    case PPC_860:
86    case PPC_8260:
87    case PPC_8245:
88    case PPC_PSIM:
89    case PPC_8540:
90    case PPC_e200z6:
91    case PPC_e300c1:
92    case PPC_e300c2:
93    case PPC_e300c3:
94      break;
95    default:
96      printk("Unknown PVR value of 0x%x. Please add it to "
97             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", pvr );
98    return PPC_UNKNOWN;
99  }
100
101  /* determine features */
102
103  /* FIXME: This is incomplete; I couldn't go through all the
104   * manuals (yet).
105   */
106  switch ( current_ppc_cpu ) {
107    case PPC_7455:
108    case PPC_7457:
109                current_ppc_features.has_8_bats                 = 1;
110    case PPC_7400:
111                current_ppc_features.has_altivec                = 1;
112        case PPC_604:
113        case PPC_604e:
114        case PPC_604r:
115        case PPC_750:
116                current_ppc_features.has_hw_ptbl_lkup   = 1;
117        case PPC_8260:
118        case PPC_8245:
119        case PPC_601:
120        case PPC_603:
121        case PPC_603e:
122        case PPC_603ev:
123        case PPC_603le:
124                current_ppc_features.is_60x                             = 1;
125        default:
126        break;
127  }
128
129  switch ( current_ppc_cpu ) {
130        case PPC_405:
131                current_ppc_features.is_bookE                   = PPC_BOOKE_405;
132        break;
133        case PPC_8540:
134        case PPC_e200z6:
135                current_ppc_features.is_bookE                   = PPC_BOOKE_E500;
136        default:
137        break;
138  }
139
140  switch ( current_ppc_cpu ) {
141        case PPC_860:
142                current_ppc_features.has_16byte_clne    = 1;
143        default:
144        break;
145  }
146
147  switch ( current_ppc_cpu ) {
148    case PPC_603e:
149    case PPC_603ev:
150    case PPC_603le:
151    case PPC_e300c1:
152    case PPC_e300c2:
153    case PPC_e300c3:
154    case PPC_8240:
155                current_ppc_features.has_shadowed_gprs  = 1;
156        default:
157        break;
158  }
159
160        switch (current_ppc_cpu) {
161                case PPC_e200z6:
162                        current_ppc_features.has_ivpr_and_ivor = 1;
163                        break;
164                default:
165                        break;
166        }
167
168  return current_ppc_cpu;
169}
170
171ppc_cpu_revision_t get_ppc_cpu_revision()
172{
173  ppc_cpu_revision_t rev = (ppc_cpu_revision_t) (_read_PVR() & 0xffff);
174  current_ppc_revision = rev;
175  return rev;
176}
Note: See TracBrowser for help on using the repository browser.