freemyipod r732 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r731‎ | r732 | r733 >
Date:00:02, 12 July 2011
Author:theseven
Status:new
Tags:
Comment:
emCORE: Add MMU support for iPod Nano 4G
Modified paths:
  • /emcore/trunk/target/ipodnano4g/crt0.S (modified) (history)
  • /emcore/trunk/target/ipodnano4g/mmu.c (modified) (history)

Diff [purge]

Index: emcore/trunk/target/ipodnano4g/mmu.c
@@ -28,6 +28,9 @@
2929 void clean_dcache()
3030 {
3131 asm volatile(
 32+ "MOV R0, #0 \n\t"
 33+ "MCR p15, 0, R0,c7,c10,0 \n\t"
 34+ "MCR p15, 0, R0,c7,c10,4 \n\t"
3235 "MOV PC, LR \n\t"
3336 );
3437 }
@@ -35,6 +38,9 @@
3639 void invalidate_dcache()
3740 {
3841 asm volatile(
 42+ "MOV R0, #0 \n\t"
 43+ "MCR p15, 0, R0,c7,c14,0 \n\t"
 44+ "MCR p15, 0, R0,c7,c10,4 \n\t"
3945 "MOV PC, LR \n\t"
4046 );
4147 }
@@ -42,6 +48,9 @@
4349 void invalidate_icache()
4450 {
4551 asm volatile(
 52+ "MOV R0, #0 \n\t"
 53+ "MCR p15, 0, R0,c7,c5,0 \n\t"
 54+ "MCR p15, 0, R0,c7,c5,4 \n\t"
4655 "MOV PC, LR \n\t"
4756 );
4857 }
Index: emcore/trunk/target/ipodnano4g/crt0.S
@@ -41,8 +41,51 @@
4242 .section .initcode,"ax",%progbits
4343 .global _start
4444 _start:
45 - ldr r0, =0x00450878
46 - mcr p15, 0, r0,c1,c0,0
 45+ mrc p15, 0, r0,c1,c0
 46+ bic r0, r0, #0x200
 47+ orr r0, r0, #0x100
 48+ mcr p15, 0, r0,c1,c0
 49+ mov r0, #0x7fffffff
 50+ mcr p15, 0, r0,c3,c0
 51+ mov r0, #0x22000000
 52+ orr r1, r0, #0x00000100
 53+ orr r0, r0, #0x0003c000
 54+ orr r1, r1, #0x000000fe
 55+ add r2, r0, #0x200
 56+ mov r3, #0
 57+ str r1, [r0], #4
 58+.mmuloop1:
 59+ str r3, [r0], #4
 60+ cmp r0, r2
 61+ bne .mmuloop1
 62+ add r0, r0, #0x080
 63+ add r2, r0, #0x580
 64+.mmuloop2:
 65+ str r3, [r0], #4
 66+ cmp r0, r2
 67+ bne .mmuloop2
 68+ add r0, r0, #0x4
 69+ add r2, r0, #0x7c
 70+.mmuloop3:
 71+ str r3, [r0], #4
 72+ cmp r0, r2
 73+ bne .mmuloop3
 74+ add r0, r0, #0x4
 75+ add r2, r0, #0x500
 76+ add r2, r2, #0x7c
 77+.mmuloop4:
 78+ str r3, [r0], #4
 79+ cmp r0, r2
 80+ bne .mmuloop4
 81+ add r0, r0, #0x200
 82+ add r2, r0, #0x3000
 83+.mmuloop5:
 84+ str r3, [r0], #4
 85+ cmp r0, r2
 86+ bne .mmuloop5
 87+ mrc p15, 0, r0,c1,c0
 88+ orr r0, r0, #5
 89+ mcr p15, 0, r0,c1,c0
4790 ldr r0, =_sramsource
4891 ldr r1, =_sramstart
4992 ldr r2, =_sramend
@@ -72,17 +115,15 @@
73116 cmp r1, r0
74117 strhi r2, [r0], #4
75118 bhi .clearbss
76 - ldr r1, =0x38200000
77 - ldr r0, [r1]
78 - orr r0, r0, #1
79 - bic r0, r0, #0x10000
80 - str r0, [r1]
81119 mov r0, #0
82 - mcr p15, 0, r0,c7,c5,0
83 - add r1, r1, #0x00c00000
 120+ mcr p15, 0, r0,c7,c10,0 @ clean data cache
 121+ mcr p15, 0, r0,c7,c10,4 @ drain write buffer
 122+ mcr p15, 0, r0,c7,c5,0 @ invalidate instruction cache
 123+ mcr p15, 0, r0,c7,c5,4 @ flush prefetch buffer
 124+ ldr r1, =0x38e00000
84125 add r2, r1, #0x00001000
85126 add r3, r1, #0x00002000
86 - sub r4, r0, #1
 127+ mov r4, #-1
87128 str r4, [r1,#0x14]
88129 str r4, [r2,#0x14]
89130 str r4, [r1,#0xf00]
@@ -89,12 +130,6 @@
90131 str r4, [r2,#0xf00]
91132 str r4, [r3,#0x08]
92133 str r4, [r3,#0x0c]
93 - str r0, [r1,#0x14]
94 - str r0, [r2,#0x14]
95 - mov r0, #0
96 - ldr r1, =0x3c500000
97 - str r0, [r1,#0x48]
98 - str r0, [r1,#0x4c]
99134 msr cpsr_c, #0xd2
100135 ldr sp, =_irqstackend
101136 msr cpsr_c, #0xd7
@@ -127,6 +162,7 @@
128163 str r0, [r1]
129164 hang:
130165 msr cpsr_c, #0xd3
 166+ mov r0, #0
131167 mcr p15, 0, r0,c7,c0,4
132168 b hang
133169 .size reset, .-reset
@@ -192,7 +228,7 @@
193229 sub sp, sp, #0x44
194230 mov r0, #0
195231 adr r1, prefetch_abort_text
196 - mrc p15, 0, r3,c5,c0,1
 232+ mrc p15, 0, r3,c5,c0
197233 mov r4, r3,lsr#4
198234 and r4, r4, #0xf
199235 and r5, r3, #0xf
@@ -292,12 +328,7 @@
293329 .type read_usec_timer, %function
294330 read_usec_timer:
295331 ldr r0, val_3c700000
296 - ldr r1, [r0,#0x80]
297 - ldr r0, [r0,#0x84]
298 - mov r0, r0,lsr#5
299 - orr r0, r0, r1,lsl#27
300 - add r0, r0, r0,asr#2
301 - add r0, r0, r0,asr#6
 332+ ldr r0, [r0,#0xb4]
302333 bx lr
303334 .size read_usec_timer, .-read_usec_timer
304335