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

4.104.114.95
Last change on this file since a86f3aac was 4be2812f, checked in by Till Straumann <strauman@…>, on 12/08/07 at 22:46:59

2007-12-08 Till Straumann <strauman@…>

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