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

4.104.114.95
Last change on this file since 3c6fe2e 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
RevLine 
[abd9401]1/*
2 *  cpuIdent.c -- Cpu identification code
3 *
4 *  Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
5 *
[48694da]6 *  Added MPC8260 Andy Dachs <a.dachs@sstl.co.uk>
7 *  Surrey Satellite Technology Limited
8 *
[abd9401]9 *  The license and distribution terms for this file may be
10 *  found in found in the file LICENSE in this distribution or at
[21e1c44]11 *  http://www.rtems.com/license/LICENSE.
[abd9401]12 *
13 * $Id$
14 *
15 */
16
[f054b51]17#include <libcpu/cpuIdent.h>
[abd9401]18#include <libcpu/spr.h>
[5c76213]19#include <rtems/bspIo.h>
[abd9401]20
21/*
22 * Generate inline code to read Processor Version Register
23 */
24SPR_RO(PVR)
25
[e955b06]26ppc_cpu_id_t       current_ppc_cpu      = PPC_UNKNOWN;
[abd9401]27ppc_cpu_revision_t current_ppc_revision = 0xff;
[e955b06]28ppc_feature_t      current_ppc_features = {0};
[abd9401]29
[0d776cd2]30char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu)
31{
32  switch (cpu) {
[73cdeb6]33    case PPC_405:               return "PPC405";
[3c6fe2e]34        case PPC_405GP:         return "PPC405GP";
35        case PPC_405EX:         return "PPC405EX";
[0d776cd2]36    case PPC_601:               return "MPC601";
[9c4a30e2]37    case PPC_5XX:               return "MPC5XX";
[0d776cd2]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";
[408bb71]43    case PPC_7455:              return "MPC7455";
[73cdeb6]44    case PPC_7457:              return "MPC7457";
[56c4cae]45    case PPC_603le:             return "MPC603le";
[0d776cd2]46    case PPC_604e:              return "MPC604e";
[d49389a]47    case PPC_604r:              return "MPC604r";
[0d776cd2]48    case PPC_620:               return "MPC620";
49    case PPC_860:               return "MPC860";
50    case PPC_8260:              return "MPC8260";
[408bb71]51    case PPC_8245:              return "MPC8245";
[25a92bc1]52    case PPC_8540:              return "MPC8540";
53    case PPC_PSIM:              return "PSIM";
54    case PPC_e200z6:            return "e200z6";
[0d776cd2]55    default:
[a84392d]56      printk("Unknown CPU value of 0x%x. Please add it to "
57             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", cpu );
[0d776cd2]58  }
59  return "UNKNOWN";
60}
61
[abd9401]62ppc_cpu_id_t get_ppc_cpu_type()
63{
[e955b06]64  unsigned int pvr;
65
66  if ( PPC_UNKNOWN != current_ppc_cpu )
67        return current_ppc_cpu;
68
69  pvr = (_read_PVR() >> 16);
[abd9401]70  current_ppc_cpu = (ppc_cpu_id_t) pvr;
[e955b06]71
[abd9401]72  switch (pvr) {
[73cdeb6]73    case PPC_405:
[3c6fe2e]74        case PPC_405GP:
75        case PPC_405EX:
[eaedd00]76    case PPC_601:
[9c4a30e2]77    case PPC_5XX:
[eaedd00]78    case PPC_603:
79    case PPC_603ev:
[56c4cae]80    case PPC_603le:
[acddd7d2]81    case PPC_604:
[8ca2e5b]82    case PPC_604r:
[eaedd00]83    case PPC_750:
[0d776cd2]84    case PPC_7400:
[56c4cae]85    case PPC_7455:
[73cdeb6]86    case PPC_7457:
[eaedd00]87    case PPC_604e:
88    case PPC_620:
89    case PPC_860:
[48694da]90    case PPC_8260:
[a84392d]91    case PPC_8245:
[25a92bc1]92    case PPC_PSIM:
93    case PPC_8540:
94    case PPC_e200z6:
95    case PPC_e300c1:
96    case PPC_e300c2:
97    case PPC_e300c3:
[e955b06]98      break;
[eaedd00]99    default:
[a84392d]100      printk("Unknown PVR value of 0x%x. Please add it to "
101             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", pvr );
[abd9401]102    return PPC_UNKNOWN;
103  }
[e955b06]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:
[3c6fe2e]135        case PPC_405GP:
136        case PPC_405EX:
[4be2812f]137                current_ppc_features.is_bookE                   = PPC_BOOKE_405;
138        break;
[e955b06]139        case PPC_8540:
[25a92bc1]140        case PPC_e200z6:
[4be2812f]141                current_ppc_features.is_bookE                   = PPC_BOOKE_E500;
[e955b06]142        default:
143        break;
144  }
145
146  switch ( current_ppc_cpu ) {
147        case PPC_860:
[76a5a3cc]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;
[e955b06]162        default:
163        break;
164  }
[25a92bc1]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
[e955b06]174  return current_ppc_cpu;
[abd9401]175}
[0d776cd2]176
[abd9401]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.