Changeset e955b06 in rtems


Ignore:
Timestamp:
Dec 1, 2007, 12:06:00 AM (13 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.10, 4.11, 4.9, master
Children:
d18d7fe0
Parents:
9edf584f
Message:

2007-11-29 Till Straumann <strauman@…>

  • shared/include/cpuIdent.h, shared/include/cpuIdent.c: Added a simple 'feature check' facility. Code should not check for a particular CPU type if possible but check the respective feature bit (e.g., 'has_altivec'). This makes it much less cumbersome to add more CPU types in the future.
Location:
c/src/lib/libcpu/powerpc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/powerpc/ChangeLog

    r9edf584f re955b06  
     12007-11-29      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * shared/include/cpuIdent.h, shared/include/cpuIdent.c:
     4        Added a simple 'feature check' facility. Code should
     5        not check for a particular CPU type if possible but
     6        check the respective feature bit (e.g., 'has_altivec').
     7        This makes it much less cumbersome to add more CPU
     8        types in the future.
     9
    1102007-11-29      Till Straumann <strauman@slac.stanford.edu>
    211
  • c/src/lib/libcpu/powerpc/shared/include/cpuIdent.c

    r9edf584f re955b06  
    2424SPR_RO(PVR)
    2525
    26 ppc_cpu_id_t current_ppc_cpu = PPC_UNKNOWN;
     26ppc_cpu_id_t       current_ppc_cpu      = PPC_UNKNOWN;
    2727ppc_cpu_revision_t current_ppc_revision = 0xff;
     28ppc_feature_t      current_ppc_features = {0};
    2829
    2930char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu)
     
    4748    case PPC_8260:              return "MPC8260";
    4849    case PPC_8245:              return "MPC8245";
     50        case PPC_8540:          return "MPC8540";
    4951        case PPC_PSIM:          return "PSIM";
    5052    default:
     
    5759ppc_cpu_id_t get_ppc_cpu_type()
    5860{
    59   unsigned int pvr = (_read_PVR() >> 16);
     61  unsigned int pvr;
     62
     63  if ( PPC_UNKNOWN != current_ppc_cpu )
     64        return current_ppc_cpu;
     65
     66  pvr = (_read_PVR() >> 16);
    6067  current_ppc_cpu = (ppc_cpu_id_t) pvr;
     68
    6169  switch (pvr) {
    6270    case PPC_405:
     
    7886    case PPC_8245:
    7987        case PPC_PSIM:
    80       return current_ppc_cpu;
     88        case PPC_8540:
     89      break;
    8190    default:
    8291      printk("Unknown PVR value of 0x%x. Please add it to "
     
    8493    return PPC_UNKNOWN;
    8594  }
     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        case PPC_8540:
     127                current_ppc_features.is_bookE                   = 1;
     128        default:
     129        break;
     130  }
     131
     132  switch ( current_ppc_cpu ) {
     133        case PPC_860:
     134                current_ppc_features.has_16byte_clne    =1;
     135        default:
     136        break;
     137  }
     138               
     139  return current_ppc_cpu;
    86140}
    87141
  • c/src/lib/libcpu/powerpc/shared/include/cpuIdent.h

    r9edf584f re955b06  
    4040  PPC_8240 = PPC_8260,
    4141  PPC_8245 = 0x8081,
     42  PPC_8540 = 0x8020,
    4243  PPC_603le = 0x8082, /* 603le core, in MGT5100 and MPC5200 */
    4344  PPC_e300c1  = 0x8083, /* e300c1  core, in MPC83xx*/
     
    4748  PPC_UNKNOWN = 0xffff
    4849} ppc_cpu_id_t;
     50
     51/* Bitfield of for identifying features or groups of cpu flavors.
     52 * DO NOT USE DIRECTLY (as implementation may change)
     53 * only use the 'ppc_is_xxx() / ppc_has_xxx()' macros/inlines
     54 * below.
     55 */
     56
     57typedef struct {
     58        unsigned has_altivec            : 1;
     59        unsigned has_fpu                        : 1;
     60        unsigned has_hw_ptbl_lkup       : 1;
     61        unsigned is_bookE                       : 1;
     62        unsigned has_16byte_clne        : 1;
     63        unsigned is_60x             : 1;
     64        unsigned has_8_bats                     : 1;
     65        unsigned has_epic           : 1;
     66} ppc_feature_t;
     67
     68extern ppc_feature_t   current_ppc_features;
     69
     70/* PUBLIC ACCESS ROUTINES */
     71#define _PPC_FEAT_DECL(x) \
     72static inline ppc_cpu_##x() { if ( PPC_UNKNOWN == current_ppc_cpu ) get_ppc_cpu_type(); return current_ppc_features.x; }
     73
     74_PPC_FEAT_DECL(has_altivec)
     75/* has_fpu not implemented yet */
     76_PPC_FEAT_DECL(has_hw_ptbl_lkup)
     77_PPC_FEAT_DECL(is_bookE)
     78_PPC_FEAT_DECL(is_60x)
     79_PPC_FEAT_DECL(has_8_bats)
     80_PPC_FEAT_DECL(has_epic)
     81
     82#undef _PPC_FEAT_DECL
    4983
    5084typedef unsigned short ppc_cpu_revision_t;
Note: See TracChangeset for help on using the changeset viewer.