Ignore:
File:
1 edited

Legend:

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

    r9d58539 r7cd15b9  
    5050#define TOP2ADDR(top)  (((void *) PA2KA(BOOT_OFFSET)) + (top))
    5151
     52extern void *bdata_start;
     53extern void *bdata_end;
     54
     55static inline void clean_dcache_poc(void *address, size_t size)
     56{
     57        const uintptr_t addr = (uintptr_t)address;
     58        for (uintptr_t a = addr; a < addr + size; a += 4) {
     59                /* DCCMVAC - clean by address to the point of coherence */
     60                asm volatile ("mcr p15, 0, %[a], c7, c10, 1\n" :: [a]"r"(a) : );
     61        }
     62}
     63
    5264static bootinfo_t bootinfo;
    5365
    5466void bootstrap(void)
    5567{
     68        /* Enable MMU and caches */
    5669        mmu_start();
    5770        version_print();
    5871       
     72        printf("Boot data: %p -> %p\n", &bdata_start, &bdata_end);
    5973        printf("\nMemory statistics\n");
    6074        printf(" %p|%p: bootstrap stack\n", &boot_stack, &boot_stack);
     
    6478            (void *) PA2KA(BOOT_OFFSET), (void *) BOOT_OFFSET);
    6579       
    66         size_t i;
    67         for (i = 0; i < COMPONENTS; i++)
     80        for (size_t i = 0; i < COMPONENTS; i++) {
    6881                printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start,
    6982                    components[i].start, components[i].name, components[i].inflated,
    7083                    components[i].size);
     84        }
    7185       
    7286        void *dest[COMPONENTS];
     
    7488        size_t cnt = 0;
    7589        bootinfo.cnt = 0;
    76         for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
     90        for (size_t i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
    7791                top = ALIGN_UP(top, PAGE_SIZE);
    7892               
     
    94108        printf("\nInflating components ... ");
    95109       
    96         for (i = cnt; i > 0; i--) {
     110        for (size_t i = cnt; i > 0; i--) {
    97111                void *tail = components[i - 1].start + components[i - 1].size;
    98112                if (tail >= dest[i - 1]) {
     
    106120                int err = inflate(components[i - 1].start, components[i - 1].size,
    107121                    dest[i - 1], components[i - 1].inflated);
    108                
    109122                if (err != EOK) {
    110123                        printf("\n%s: Inflating error %d\n", components[i - 1].name, err);
    111124                        halt();
    112125                }
     126                /* Make sure data are in the memory, ICache will need them */
     127                clean_dcache_poc(dest[i - 1], components[i - 1].inflated);
    113128        }
    114129       
    115130        printf(".\n");
     131
     132        /* Flush PT too. We need this if we disable caches later */
     133        clean_dcache_poc(boot_pt, PTL0_ENTRIES * PTL0_ENTRY_SIZE);
    116134       
    117         printf("Booting the kernel... \n");
     135        printf("Booting the kernel...\n");
    118136        jump_to_kernel((void *) PA2KA(BOOT_OFFSET), &bootinfo);
    119137}
Note: See TracChangeset for help on using the changeset viewer.