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

4.115
Last change on this file since a762dc2 was a762dc2, checked in by Sebastian Huber <sebastian.huber@…>, on 01/23/12 at 10:19:22

Support for MPC5643L.

Rework of the start sequence to reduce the amount assembler code and to
support configuration tables which may be provided by the application.

  • Property mode set to 100644
File size: 5.3 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 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(PPC_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;
29
30const char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu)
31{
32  switch (cpu) {
33    case PPC_405:               return "PPC405";
34        case PPC_405GP:         return "PPC405GP";
35        case PPC_405EX:         return "PPC405EX";
36    case PPC_601:               return "MPC601";
37    case PPC_5XX:               return "MPC5XX";
38    case PPC_603:               return "MPC603";
39    case PPC_603ev:             return "MPC603ev";
40    case PPC_604:               return "MPC604";
41    case PPC_750:               return "MPC750";
42    case PPC_7400:              return "MPC7400";
43    case PPC_7455:              return "MPC7455";
44    case PPC_7457:              return "MPC7457";
45    case PPC_603le:             return "MPC603le";
46    case PPC_604e:              return "MPC604e";
47    case PPC_604r:              return "MPC604r";
48    case PPC_620:               return "MPC620";
49    case PPC_860:               return "MPC860";
50    case PPC_8260:              return "MPC8260";
51    case PPC_8245:              return "MPC8245";
52    case PPC_8540:              return "MPC8540";
53    case PPC_PSIM:              return "PSIM";
54    case PPC_e200z0:            return "e200z0";
55    case PPC_e200z1:            return "e200z1";
56    case PPC_e200z4:            return "e200z4";
57    case PPC_e200z6:            return "e200z6";
58    case PPC_e200z7:            return "e200z7";
59    case PPC_e500v2:            return "e500v2";
60    default:
61      printk("Unknown CPU value of 0x%x. Please add it to "
62             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", cpu );
63  }
64  return "UNKNOWN";
65}
66
67ppc_cpu_id_t get_ppc_cpu_type(void)
68{
69  /*
70   * cpu types listed here have the lowermost nibble as a version identifier
71   * we will tweak them to the standard version
72   */
73  const uint32_t ppc_cpu_id_version_nibble[] = {
74    PPC_e200z0,
75    PPC_e200z1,
76    PPC_e200z4,
77    PPC_e200z6,
78    PPC_e200z7
79  };
80
81  unsigned int pvr;
82  int i;
83
84  if ( PPC_UNKNOWN != current_ppc_cpu )
85        return current_ppc_cpu;
86
87  pvr = (_read_PPC_PVR() >> 16);
88  /*
89   * apply tweaks to ignore version
90   */
91  for (i = 0;
92       i < (sizeof(ppc_cpu_id_version_nibble)
93            /sizeof(ppc_cpu_id_version_nibble[0]));
94       i++) {
95    if ((pvr & 0xfff0) == (ppc_cpu_id_version_nibble[i] & 0xfff0)) {
96      pvr = ppc_cpu_id_version_nibble[i];
97      break;
98    }
99  }
100
101  current_ppc_cpu = (ppc_cpu_id_t) pvr;
102
103  switch (pvr) {
104    case PPC_405:
105    case PPC_405GP:
106    case PPC_405EX:
107    case PPC_601:
108    case PPC_5XX:
109    case PPC_603:
110    case PPC_603ev:
111    case PPC_603le:
112    case PPC_604:
113    case PPC_604r:
114    case PPC_750:
115    case PPC_7400:
116    case PPC_7455:
117    case PPC_7457:
118    case PPC_604e:
119    case PPC_620:
120    case PPC_860:
121    case PPC_8260:
122    case PPC_8245:
123    case PPC_PSIM:
124    case PPC_8540:
125    case PPC_e200z0:
126    case PPC_e200z1:
127    case PPC_e200z4:
128    case PPC_e200z6:
129    case PPC_e200z7:
130    case PPC_e300c1:
131    case PPC_e300c2:
132    case PPC_e300c3:
133    case PPC_e500v2:
134      break;
135    default:
136      printk("Unknown PVR value of 0x%x. Please add it to "
137             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", pvr );
138    return PPC_UNKNOWN;
139  }
140
141  /* determine features */
142
143  /* FIXME: This is incomplete; I couldn't go through all the
144   * manuals (yet).
145   */
146  switch ( current_ppc_cpu ) {
147    case PPC_7455:
148    case PPC_7457:
149                current_ppc_features.has_8_bats                 = 1;
150    case PPC_7400:
151        /* NOTE: PSIM PVR doesn't tell us anything (its
152     *       contents are not set based on what model
153         *       the uses chooses but has to be programmed via
154         *       the device file with the special value 0xfffe
155         *       telling us that we have a 'psim cpu').
156         *
157         *       I'm not sure pagetables work if the user chooses
158         *       e.g., the 603 model...
159         */
160        case PPC_PSIM:
161                current_ppc_features.has_altivec                = 1;
162        case PPC_604:
163        case PPC_604e:
164        case PPC_604r:
165        case PPC_750:
166                current_ppc_features.has_hw_ptbl_lkup   = 1;
167        case PPC_8260:
168        case PPC_8245:
169        case PPC_601:
170        case PPC_603:
171        case PPC_603e:
172        case PPC_603ev:
173        case PPC_603le:
174                current_ppc_features.is_60x                             = 1;
175        default:
176        break;
177  }
178
179  switch ( current_ppc_cpu ) {
180        case PPC_405:
181        case PPC_405GP:
182        case PPC_405EX:
183                current_ppc_features.is_bookE                   = PPC_BOOKE_405;
184        break;
185        case PPC_8540:
186        case PPC_e200z0:
187        case PPC_e200z1:
188        case PPC_e200z4:
189        case PPC_e200z6:
190        case PPC_e200z7:
191        case PPC_e500v2:
192                current_ppc_features.is_bookE                   = PPC_BOOKE_E500;
193        default:
194        break;
195  }
196
197  switch ( current_ppc_cpu ) {
198        case PPC_860:
199                current_ppc_features.has_16byte_clne    = 1;
200        default:
201        break;
202  }
203
204  switch ( current_ppc_cpu ) {
205    case PPC_603e:
206    case PPC_603ev:
207    case PPC_603le:
208    case PPC_e300c1:
209    case PPC_e300c2:
210    case PPC_e300c3:
211    case PPC_8240:
212                current_ppc_features.has_shadowed_gprs  = 1;
213        default:
214        break;
215  }
216
217  return current_ppc_cpu;
218}
219
220ppc_cpu_revision_t get_ppc_cpu_revision(void)
221{
222  ppc_cpu_revision_t rev = (ppc_cpu_revision_t) (_read_PPC_PVR() & 0xffff);
223  current_ppc_revision = rev;
224  return rev;
225}
Note: See TracBrowser for help on using the repository browser.