Changeset b1011dae in mainline for boot/arch/arm32/src
- Timestamp:
- 2013-01-24T21:18:18Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 077b9172
- Parents:
- 5e761f3 (diff), c124dce3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- boot/arch/arm32/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/arm32/src/asm.S
r5e761f3 rb1011dae 61 61 # 62 62 63 #if defined(MACHINE_gta02) 63 # 64 # r0 is kernel entry point 65 # r1 is pointer to the bootinfo structure 64 66 65 67 #define CP15_C1_IC 12 68 #define CP15_C1_BP 11 66 69 #define CP15_C1_DC 2 67 #define CP15_C7_SEG_SHIFT 568 #define CP15_C7_SEG_SIZE 369 #define CP15_C7_IDX_SHIFT 2670 71 70 # Disable I-cache and D-cache before the kernel is started. 72 71 mrc p15, 0, r4, c1, c0, 0 73 72 bic r4, r4, #(1 << CP15_C1_DC) 74 73 bic r4, r4, #(1 << CP15_C1_IC) 74 bic r4, r4, #(1 << CP15_C1_BP) 75 75 mcr p15, 0, r4, c1, c0, 0 76 77 78 #Wait for the operations to complete 79 #ifdef PROCESSOR_ARCH_armv7_a 80 dsb 81 #else 82 #cp15 dsb, r4 is ignored (should be zero) 83 mcr p15, 0, r4, c7, c10, 4 84 #endif 85 86 # Clean ICache and BPredictors, r4 ignored (SBZ) 87 mcr p15, 0, r4, c7, c5, 0 88 nop 89 90 #Wait for the operations to complete 91 #ifdef PROCESSOR_ARCH_armv7_a 92 isb 93 nop 94 #else 95 # cp15 isb 96 mcr p15, 0, r4, c7, c5, 4 97 nop 98 #endif 99 100 #TODO:This should not be necessary 101 102 #if defined(MACHINE_gta02) 103 104 #define CP15_C7_SEG_SHIFT 5 105 #define CP15_C7_SEG_SIZE 3 106 #define CP15_C7_IDX_SHIFT 26 76 107 77 108 # Now clean D-cache to guarantee coherency between I-cache and D-cache. -
boot/arch/arm32/src/main.c
r5e761f3 rb1011dae 50 50 #define TOP2ADDR(top) (((void *) PA2KA(BOOT_OFFSET)) + (top)) 51 51 52 extern void *bdata_start; 53 extern void *bdata_end; 54 55 56 static 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 62 static 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 71 static inline void clean_dcache_poc(void *address, size_t size) 72 { 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) : ); 77 } 78 } 79 52 80 static bootinfo_t bootinfo; 53 81 54 82 void bootstrap(void) 55 83 { 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 91 /* Enable MMU and caches */ 56 92 mmu_start(); 57 93 version_print(); 58 94 95 printf("Boot data: %p -> %p\n", &bdata_start, &bdata_end); 59 96 printf("\nMemory statistics\n"); 60 97 printf(" %p|%p: bootstrap stack\n", &boot_stack, &boot_stack); … … 64 101 (void *) PA2KA(BOOT_OFFSET), (void *) BOOT_OFFSET); 65 102 66 size_t i; 67 for (i = 0; i < COMPONENTS; i++) 103 for (size_t i = 0; i < COMPONENTS; i++) { 68 104 printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start, 69 105 components[i].start, components[i].name, components[i].inflated, 70 106 components[i].size); 107 invalidate_dcache(components[i].start, components[i].size); 108 } 71 109 72 110 void *dest[COMPONENTS]; … … 74 112 size_t cnt = 0; 75 113 bootinfo.cnt = 0; 76 for ( i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {114 for (size_t i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) { 77 115 top = ALIGN_UP(top, PAGE_SIZE); 78 116 … … 94 132 printf("\nInflating components ... "); 95 133 96 for ( i = cnt; i > 0; i--) {134 for (size_t i = cnt; i > 0; i--) { 97 135 void *tail = components[i - 1].start + components[i - 1].size; 98 136 if (tail >= dest[i - 1]) { … … 106 144 int err = inflate(components[i - 1].start, components[i - 1].size, 107 145 dest[i - 1], components[i - 1].inflated); 108 109 146 if (err != EOK) { 110 147 printf("\n%s: Inflating error %d\n", components[i - 1].name, err); 111 148 halt(); 112 149 } 150 clean_dcache_poc(dest[i - 1], components[i - 1].inflated); 113 151 } 114 152 115 153 printf(".\n"); 116 154 117 printf("Booting the kernel... \n"); 155 void *kernel_end = (void *) PA2KA(BOOT_OFFSET + components[0].inflated); 156 printf("Booting the kernel...\n"); 118 157 jump_to_kernel((void *) PA2KA(BOOT_OFFSET), &bootinfo); 119 158 } -
boot/arch/arm32/src/mm.c
r5e761f3 rb1011dae 66 66 else 67 67 return 1; 68 #else 68 #elif defined MACHINE_beagleboardxm 69 const unsigned long address = section << PTE_SECTION_SHIFT; 70 if (address >= BBXM_RAM_START && address < BBXM_RAM_END) 71 return 1; 72 #endif 69 73 return 0; 70 #endif71 74 } 72 75 … … 129 132 "mrc p15, 0, r0, c1, c0, 0\n" 130 133 131 #ifdef PROCESSOR_armv7_a 132 /* Mask to enable paging, caching */ 133 "ldr r1, =0x00000005\n" 134 #else 135 #ifdef MACHINE_gta02 136 /* Mask to enable paging (bit 0), 137 D-cache (bit 2), I-cache (bit 12) */ 138 "ldr r1, =0x00001005\n" 139 #else 140 /* Mask to enable paging */ 141 "ldr r1, =0x00000001\n" 142 #endif 143 #endif 134 /* Enable ICache, DCache, BPredictors and MMU, 135 * we disable caches before jumping to kernel 136 * so this is safe for all archs. 137 */ 138 "ldr r1, =0x00001805\n" 139 144 140 "orr r0, r0, r1\n" 145 141
Note:
See TracChangeset
for help on using the changeset viewer.