Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/cpu/cpu.c

    r8316547f r9d58539  
    4444/** Implementators (vendor) names */
    4545static const char *imp_data[] = {
    46         "?",                                     /* IMP_DATA_START_OFFSET */
    47         "ARM Limited",                           /* 0x41 */
    48         "", "",                                  /* 0x42 - 0x43 */
    49         "Digital Equipment Corporation",         /* 0x44 */
    50         "", "", "", "", "", "", "", "",          /* 0x45 - 0x4c */
    51         "Motorola, Freescale Semicondutor Inc.", /* 0x4d */
    52         "", "", "",                              /* 0x4e - 0x50 */
    53         "Qualcomm Inc.",                         /* 0x51 */
    54         "", "", "", "",                          /* 0x52 - 0x55 */
    55         "Marvell Semiconductor",                 /* 0x56 */
    56         "", "", "", "", "", "", "", "", "", "",  /* 0x57 - 0x60 */
    57         "", "", "", "", "", "", "", "",          /* 0x61 - 0x68 */
    58         "Intel Corporation"                      /* 0x69 */
     46        "?",                                    /* IMP_DATA_START_OFFSET */
     47        "ARM Ltd",                              /* 0x41 */
     48        "",                                     /* 0x42 */
     49        "",                                     /* 0x43 */
     50        "Digital Equipment Corporation",        /* 0x44 */
     51        "", "", "", "", "", "", "", "", "", "", /* 0x45 - 0x4e */
     52        "", "", "", "", "", "", "", "", "", "", /* 0x4f - 0x58 */
     53        "", "", "", "", "", "", "", "", "", "", /* 0x59 - 0x62 */
     54        "", "", "", "", "", "",                 /* 0x63 - 0x68 */
     55        "Intel Corporation"                     /* 0x69 */
    5956};
    6057
     
    9794}
    9895
    99 /** Enables unaligned access and caching for armv6+ */
     96/** Does nothing on ARM. */
    10097void cpu_arch_init(void)
    10198{
    102 #if defined(PROCESSOR_armv7_a) | defined(PROCESSOR_armv6)
    103         uint32_t control_reg = 0;
    104         asm volatile (
    105                 "mrc p15, 0, %[control_reg], c1, c0"
    106                 : [control_reg] "=r" (control_reg)
    107         );
    108        
    109         /* Turn off tex remap, RAZ ignores writes prior to armv7 */
    110         control_reg &= ~CP15_R1_TEX_REMAP_EN;
    111         /* Turn off accessed flag, RAZ ignores writes prior to armv7 */
    112         control_reg &= ~(CP15_R1_ACCESS_FLAG_EN | CP15_R1_HW_ACCESS_FLAG_EN);
    113         /* Enable unaligned access, RAZ ignores writes prior to armv6
    114          * switchable on armv6, RAO ignores writes on armv7,
    115          * see ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition
    116          * L.3.1 (p. 2456) */
    117         control_reg |= CP15_R1_UNALIGNED_EN;
    118         /* Disable alignment checks, this turns unaligned access to undefined,
    119          * unless U bit is set. */
    120         control_reg &= ~CP15_R1_ALIGN_CHECK_EN;
    121         /* Enable caching, On arm prior to armv7 there is only one level
    122          * of caches. Data cache is coherent.
    123          * "This means that the behavior of accesses from the same observer to
    124          * different VAs, that are translated to the same PA
    125          * with the same memory attributes, is fully coherent."
    126          *    ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition
    127          *    B3.11.1 (p. 1383)
    128          * ICache coherency is elaborate on in barrier.h.
    129          * We are safe to turn these on.
    130          */
    131         control_reg |= CP15_R1_CACHE_EN | CP15_R1_INST_CACHE_EN;
    132        
    133         asm volatile (
    134                 "mcr p15, 0, %[control_reg], c1, c0"
    135                 :: [control_reg] "r" (control_reg)
    136         );
    137 #endif
    13899}
    139100
    140101/** Retrieves processor identification and stores it to #CPU.arch */
    141 void cpu_identify(void)
     102void cpu_identify(void) 
    142103{
    143104        arch_cpu_identify(&CPU->arch);
     
    151112        cpu_arch_t * cpu_arch = &m->arch;
    152113
    153         const unsigned imp_offset = cpu_arch->imp_num - IMP_DATA_START_OFFSET;
    154 
    155         if (imp_offset < imp_data_length) {
     114        if ((cpu_arch->imp_num) > 0 &&
     115            (cpu_arch->imp_num < (imp_data_length + IMP_DATA_START_OFFSET))) {
    156116                vendor = imp_data[cpu_arch->imp_num - IMP_DATA_START_OFFSET];
    157117        }
    158118
    159         // TODO CPUs with arch_num == 0xf use CPUID scheme for identification
    160         if (cpu_arch->arch_num < arch_data_length) {
     119        if ((cpu_arch->arch_num) > 0 &&
     120            (cpu_arch->arch_num < arch_data_length)) {
    161121                architecture = arch_data[cpu_arch->arch_num];
    162122        }
Note: See TracChangeset for help on using the changeset viewer.