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

4.104.115
Last change on this file since 29313369 was 29313369, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 04/07/10 at 06:45:59

changes to support GW_LCFM

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