Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/arm32/src/main.c

    r15fbe6a r0e63d34  
    4747#include <errno.h>
    4848#include <inflate.h>
    49 #include <arch/cp15.h>
    5049
    5150#define TOP2ADDR(top)  (((void *) PA2KA(BOOT_OFFSET)) + (top))
     
    5453extern void *bdata_end;
    5554
     55
     56static inline void invalidate_icache(void)
     57{
     58        /* ICIALLU Invalidate entire ICache */
     59        asm volatile ("mov r0, #0\n" "mcr p15, 0, r0, c7, c5, 0\n" ::: "r0" );
     60}
     61
     62static inline void invalidate_dcache(void *address, size_t size)
     63{
     64        const uintptr_t addr = (uintptr_t)address;
     65        /* DCIMVAC - invalidate by address to the point of coherence */
     66        for (uintptr_t a = addr; a < addr + size; a += 4) {
     67                asm volatile ("mcr p15, 0, %[a], c7, c6, 1\n" :: [a]"r"(a) : );
     68        }
     69}
     70
    5671static inline void clean_dcache_poc(void *address, size_t size)
    5772{
    58         const uintptr_t addr = (uintptr_t) address;
    59 
    60 #if !defined(PROCESSOR_ARCH_armv7_a)
    61         bool sep;
    62         if (MIDR_read() != CTR_read()) {
    63                 sep = (CTR_read() & CTR_SEP_FLAG) == CTR_SEP_FLAG;
    64         } else {
    65                 printf("Unknown cache type.\n");
    66                 halt();
    67         }
    68 #endif
    69 
    70         for (uintptr_t a = ALIGN_DOWN(addr, CP15_C7_MVA_ALIGN); a < addr + size;
    71             a += CP15_C7_MVA_ALIGN) {
    72 #if defined(PROCESSOR_ARCH_armv7_a)
    73                 DCCMVAC_write(a);
    74 #else
    75                 if (sep)
    76                         DCCMVA_write(a);
    77                 else
    78                         CCMVA_write(a);
    79 #endif
     73        const uintptr_t addr = (uintptr_t)address;
     74        /* DCCMVAC - clean by address to the point of coherence */
     75        for (uintptr_t a = addr; a < addr + size; a += 4) {
     76                asm volatile ("mcr p15, 0, %[a], c7, c10, 1\n" :: [a]"r"(a) : );
    8077        }
    8178}
     
    8582void bootstrap(void)
    8683{
     84        /* Make sure  we run in memory code when caches are enabled,
     85         * make sure we read memory data too. This part is ARMv7 specific as
     86         * ARMv7 no longer invalidates caches on restart.
     87         * See chapter B2.2.2 of ARM Architecture Reference Manual p. B2-1263*/
     88        invalidate_icache();
     89        invalidate_dcache(&bdata_start, &bdata_end - &bdata_start);
     90
    8791        /* Enable MMU and caches */
    8892        mmu_start();
     
    101105                    components[i].start, components[i].name, components[i].inflated,
    102106                    components[i].size);
     107                invalidate_dcache(components[i].start, components[i].size);
    103108        }
    104109       
     
    143148                        halt();
    144149                }
    145                 /* Make sure data are in the memory, ICache will need them */
    146150                clean_dcache_poc(dest[i - 1], components[i - 1].inflated);
    147151        }
    148152       
    149153        printf(".\n");
    150 
    151         /* Flush PT too. We need this if we disable caches later */
    152         clean_dcache_poc(boot_pt, PTL0_ENTRIES * PTL0_ENTRY_SIZE);
    153154       
    154155        printf("Booting the kernel...\n");
Note: See TracChangeset for help on using the changeset viewer.