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

4.115
Last change on this file since 644448f was 644448f, checked in by Sebastian Huber <sebastian.huber@…>, on 12/29/10 at 09:51:18

2010-12-29 Sebastian Huber <sebastian.huber@…>

  • shared/include/cpuIdent.c, shared/include/cpuIdent.h: Added support for e500v2. Removed IVPR/IVOR/HWIVOR features since they are included in Book E.
  • new-exceptions/bspsupport/vectors.h, new-exceptions/bspsupport/ppc_exc.S, new-exceptions/bspsupport/ppc_exc_address.c, new-exceptions/bspsupport/ppc_exc_categories.c, new-exceptions/bspsupport/ppc_exc_initialize.c, new-exceptions/bspsupport/ppc_exc_prologue.c: Added support for e500v2. Added exception vector defines for Book E types. Removed e200 exception vector defines. Added e500 exception vector defines. Unified IVOR calculation for e200 and e500 (e200z1 has hard wired IVOR values).
  • Property mode set to 100644
File size: 5.1 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
30char *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_e200z6:            return "e200z6";
57    case PPC_e500v2:            return "e500v2";
58    default:
59      printk("Unknown CPU value of 0x%x. Please add it to "
60             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", cpu );
61  }
62  return "UNKNOWN";
63}
64
65ppc_cpu_id_t get_ppc_cpu_type(void)
66{
67  /*
68   * cpu types listed here have the lowermost nibble as a version identifier
69   * we will tweak them to the starndard version
70   */
71  const uint32_t ppc_cpu_id_version_nibble[] = {
72    PPC_e200z6,
73    PPC_e200z0,
74    PPC_e200z1};
75
76  unsigned int pvr;
77  int i;
78
79  if ( PPC_UNKNOWN != current_ppc_cpu )
80        return current_ppc_cpu;
81
82  pvr = (_read_PVR() >> 16);
83  /*
84   * apply tweaks to ignore version
85   */
86  for (i = 0;
87       i < (sizeof(ppc_cpu_id_version_nibble)
88            /sizeof(ppc_cpu_id_version_nibble[0]));
89       i++) {
90    if ((pvr & 0xfff0) == (ppc_cpu_id_version_nibble[i] & 0xfff0)) {
91      pvr = ppc_cpu_id_version_nibble[i];
92      break;
93    }
94  }
95
96  current_ppc_cpu = (ppc_cpu_id_t) pvr;
97
98  switch (pvr) {
99    case PPC_405:
100    case PPC_405GP:
101    case PPC_405EX:
102    case PPC_601:
103    case PPC_5XX:
104    case PPC_603:
105    case PPC_603ev:
106    case PPC_603le:
107    case PPC_604:
108    case PPC_604r:
109    case PPC_750:
110    case PPC_7400:
111    case PPC_7455:
112    case PPC_7457:
113    case PPC_604e:
114    case PPC_620:
115    case PPC_860:
116    case PPC_8260:
117    case PPC_8245:
118    case PPC_PSIM:
119    case PPC_8540:
120    case PPC_e200z0:
121    case PPC_e200z1:
122    case PPC_e200z6:
123    case PPC_e300c1:
124    case PPC_e300c2:
125    case PPC_e300c3:
126    case PPC_e500v2:
127      break;
128    default:
129      printk("Unknown PVR value of 0x%x. Please add it to "
130             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", pvr );
131    return PPC_UNKNOWN;
132  }
133
134  /* determine features */
135
136  /* FIXME: This is incomplete; I couldn't go through all the
137   * manuals (yet).
138   */
139  switch ( current_ppc_cpu ) {
140    case PPC_7455:
141    case PPC_7457:
142                current_ppc_features.has_8_bats                 = 1;
143    case PPC_7400:
144        /* NOTE: PSIM PVR doesn't tell us anything (its
145     *       contents are not set based on what model
146         *       the uses chooses but has to be programmed via
147         *       the device file with the special value 0xfffe
148         *       telling us that we have a 'psim cpu').
149         *
150         *       I'm not sure pagetables work if the user chooses
151         *       e.g., the 603 model...
152         */
153        case PPC_PSIM:
154                current_ppc_features.has_altivec                = 1;
155        case PPC_604:
156        case PPC_604e:
157        case PPC_604r:
158        case PPC_750:
159                current_ppc_features.has_hw_ptbl_lkup   = 1;
160        case PPC_8260:
161        case PPC_8245:
162        case PPC_601:
163        case PPC_603:
164        case PPC_603e:
165        case PPC_603ev:
166        case PPC_603le:
167                current_ppc_features.is_60x                             = 1;
168        default:
169        break;
170  }
171
172  switch ( current_ppc_cpu ) {
173        case PPC_405:
174        case PPC_405GP:
175        case PPC_405EX:
176                current_ppc_features.is_bookE                   = PPC_BOOKE_405;
177        break;
178        case PPC_8540:
179        case PPC_e200z0:
180        case PPC_e200z1:
181        case PPC_e200z6:
182        case PPC_e500v2:
183                current_ppc_features.is_bookE                   = PPC_BOOKE_E500;
184        default:
185        break;
186  }
187
188  switch ( current_ppc_cpu ) {
189        case PPC_860:
190                current_ppc_features.has_16byte_clne    = 1;
191        default:
192        break;
193  }
194
195  switch ( current_ppc_cpu ) {
196    case PPC_603e:
197    case PPC_603ev:
198    case PPC_603le:
199    case PPC_e300c1:
200    case PPC_e300c2:
201    case PPC_e300c3:
202    case PPC_8240:
203                current_ppc_features.has_shadowed_gprs  = 1;
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.