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

4.104.114.95
Last change on this file since 574fb67 was 3c6fe2e, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/14/08 at 08:46:06

added haleakala BSP contributed by Michael Hamel

  • Property mode set to 100644
File size: 4.0 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_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_e200z6:            return "e200z6";
55    default:
56      printk("Unknown CPU value of 0x%x. Please add it to "
57             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", cpu );
58  }
59  return "UNKNOWN";
60}
61
62ppc_cpu_id_t get_ppc_cpu_type()
63{
64  unsigned int pvr;
65
66  if ( PPC_UNKNOWN != current_ppc_cpu )
67        return current_ppc_cpu;
68
69  pvr = (_read_PVR() >> 16);
70  current_ppc_cpu = (ppc_cpu_id_t) pvr;
71
72  switch (pvr) {
73    case PPC_405:
74        case PPC_405GP:
75        case PPC_405EX:
76    case PPC_601:
77    case PPC_5XX:
78    case PPC_603:
79    case PPC_603ev:
80    case PPC_603le:
81    case PPC_604:
82    case PPC_604r:
83    case PPC_750:
84    case PPC_7400:
85    case PPC_7455:
86    case PPC_7457:
87    case PPC_604e:
88    case PPC_620:
89    case PPC_860:
90    case PPC_8260:
91    case PPC_8245:
92    case PPC_PSIM:
93    case PPC_8540:
94    case PPC_e200z6:
95    case PPC_e300c1:
96    case PPC_e300c2:
97    case PPC_e300c3:
98      break;
99    default:
100      printk("Unknown PVR value of 0x%x. Please add it to "
101             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", pvr );
102    return PPC_UNKNOWN;
103  }
104
105  /* determine features */
106
107  /* FIXME: This is incomplete; I couldn't go through all the
108   * manuals (yet).
109   */
110  switch ( current_ppc_cpu ) {
111    case PPC_7455:
112    case PPC_7457:
113                current_ppc_features.has_8_bats                 = 1;
114    case PPC_7400:
115                current_ppc_features.has_altivec                = 1;
116        case PPC_604:
117        case PPC_604e:
118        case PPC_604r:
119        case PPC_750:
120                current_ppc_features.has_hw_ptbl_lkup   = 1;
121        case PPC_8260:
122        case PPC_8245:
123        case PPC_601:
124        case PPC_603:
125        case PPC_603e:
126        case PPC_603ev:
127        case PPC_603le:
128                current_ppc_features.is_60x                             = 1;
129        default:
130        break;
131  }
132
133  switch ( current_ppc_cpu ) {
134        case PPC_405:
135        case PPC_405GP:
136        case PPC_405EX:
137                current_ppc_features.is_bookE                   = PPC_BOOKE_405;
138        break;
139        case PPC_8540:
140        case PPC_e200z6:
141                current_ppc_features.is_bookE                   = PPC_BOOKE_E500;
142        default:
143        break;
144  }
145
146  switch ( current_ppc_cpu ) {
147        case PPC_860:
148                current_ppc_features.has_16byte_clne    = 1;
149        default:
150        break;
151  }
152
153  switch ( current_ppc_cpu ) {
154    case PPC_603e:
155    case PPC_603ev:
156    case PPC_603le:
157    case PPC_e300c1:
158    case PPC_e300c2:
159    case PPC_e300c3:
160    case PPC_8240:
161                current_ppc_features.has_shadowed_gprs  = 1;
162        default:
163        break;
164  }
165
166        switch (current_ppc_cpu) {
167                case PPC_e200z6:
168                        current_ppc_features.has_ivpr_and_ivor = 1;
169                        break;
170                default:
171                        break;
172        }
173
174  return current_ppc_cpu;
175}
176
177ppc_cpu_revision_t get_ppc_cpu_revision()
178{
179  ppc_cpu_revision_t rev = (ppc_cpu_revision_t) (_read_PVR() & 0xffff);
180  current_ppc_revision = rev;
181  return rev;
182}
Note: See TracBrowser for help on using the repository browser.