Rev 419 | Rev 561 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
@@@ emBIOS Loader for iPod Classic@@ Copyright 2010 TheSeven@@@ This file is part of emBIOS.@@ emBIOS is free software: you can redistribute it and/or@ modify it under the terms of the GNU General Public License as@ published by the Free Software Foundation, either version 2 of the@ License, or (at your option) any later version.@@ emBIOS is distributed in the hope that it will be useful,@ but WITHOUT ANY WARRANTY; without even the implied warranty of@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.@ See the GNU General Public License for more details.@@ You should have received a copy of the GNU General Public License along@ with emBIOS. If not, see <http://www.gnu.org/licenses/>.@@.global _start_start:msr cpsr_c, #0xd3mrc p15, 0, r0,c1,c0bic r0, r0, #1mcr p15, 0, r0,c1,c0mov r0, #0mcr p15, 0, r0,c7,c5mcr p15, 0, r0,c8,c7mcr p15, 0, r0,c13,c0adr lr, cacheflush_doneflushcache:mrc p15, 0, r15,c7,c14,3bne flushcachemov r0, #0mcr p15, 0, r0,c7,c10,4bx lrcacheflush_done:adr sp, values1ldmia sp!, {r10-r12}mcr p15, 0, r11,c2,c0mov r0, #-1mcr p15, 0, r0,c3,c0mmuloop:str r12, [r11], #4add r12, r12, #0x00100000cmp r12, #0x38000000biccs r12, r12, #0xctst r12, #0x40000000beq mmuloopmcr p15, 0, r10,c1,c0ldmia sp!, {r0-r12} @ R0 = SYSCONBASE (temporary)str r1, [r0,#0x48]str r2, [r0,#0x4c]mov r2, #0 @ R2 = 0str r2, [r0]str r2, [r0,#0x4]mov r1, #7str r1, [r0,#0x44]mov r1, #0x30str r1, [r0,#0x44]str r2, [r0,#0x60]str r3, [r0,#0x28]str r4, [r0,#0x38]mov r1, #0x34str r1, [r0,#0x44]orr r1, r1, #0x40000str r1, [r0,#0x44]waitpll:ldr r1, [r0,#0x40]tst r1, #4beq waitpllstr r5, [r0,#0x04]mov r1, #0x3000str r1, [r0]mov r1, #0x8000orr r3, r1, #0x80000000str r3, [r0,#0x8]str r3, [r0,#0xc]str r1, [r0,#0x10]str r1, [r0,#0x14]mov r3, #3str r3, [r6]orr r1, r0, #0x00200000 @ R1 = TIMERBASEmov r4, #0x440str r4, [r1,#0xa0]mov r4, #0xbstr r4, [r1,#0xb0]mvn r4, r2str r4, [r1,#0xa8]str r3, [r1,#0xa4]orr r3, r1, #0x00800000 @ R3 = GPIOBASE (temporary)gpioloop:ldr r4, [sp], #4str r4, [r3], #0xcstr r2, [r3], #0x4str r2, [r3], #0x10tst r3, #0x200beq gpioloopstr r7, [r3]add r7, r7, #0x100str r7, [r3]ldr r7, [r3,#-0x30]bic r7, r7, #0x40str r7, [r3,#-0x30]ldr r7, [r3,#-0x34]orr r7, r7, #0x40str r7, [r3,#-0x34]add r5, r0, #0x00100000 @ R5 = I2CBASEbl i2cwaitrdy @ R3 = I2C address (temporary)mov r7, #0x40 @ R4 = I2C data (temporary)str r7, [r5,#8] @ R6 = I2C scratch register (temporary)bl i2cwaitrdy @ R7 = I2C return address (temporary)str r2, [r5,#0x14] @ R0 = coldboot flag (temporary)bl i2cwaitrdystr r2, [r5,#0x18]bl i2cwaitrdymov r6, #0x80str r6, [r5,#0x4]bl i2cwaitrdystr r2, [r5]bl i2cwaitrdystr r2, [r5,#0x4]bl i2cwaitrdystr r7, [r5,#0xc]bl i2cwaitrdymov r6, #0x184str r6, [r5]bl i2cwaitrdymov r6, #0x10str r6, [r5,#0x4]bl i2cwaitrdymov r3, #0x16mvn r4, r2bl pmutransferand r0, r4, #7mov r3, #0xcmvn r4, r2bl pmutransferand r4, r4, #8orr r0, r0, r4pmuloop:ldrb r3, [sp], #1ldrb r4, [sp], #1cmp r3, #0xffadrne lr, pmuloopbne pmutransfermov r3, #0x19mvn r4, r2bl pmutransfertst r4, #1beq pwrokmov r3, #0x4bmvn r4, r2bl pmutransfertst r4, #4bne pwrokmov r3, #0x12mvn r4, r2bl pmutransfertst r4, #4bne pwrokpoweroff:mov r3, #0xcmov r4, #1bl pmutransferb poweroffvalues1:.word 0x0005107D @ R10 - CP15r1.word 0x2203C000 @ R11 - First level page table.word 0x00000C1E @ R12 - Default segment flags.word 0x3C500000 @ R0 - SYSCON base.word 0x2007CE65 @ R1 - PWRCON(0).word 0x0003EFC9 @ R2 - PWRCON(1).word 0x01002401 @ R3.word 0x00007E90 @ R4.word 0x00404101 @ R5.word 0x38501000 @ R6.word 0x00060400 @ R7.word 0x0000080D @ R8.word 0x0006105D @ R9.word 0x001FB621 @ R10.word 0x0790682B @ R11.word 0x00008040 @ R12.word 0x5322222F @ PCON0.word 0xEEEEEE00 @ PCON1.word 0x2332EEEE @ PCON2.word 0x3333E222 @ PCON3.word 0x33333333 @ PCON4.word 0x33333333 @ PCON5.word 0x3F000E33 @ PCON6.word 0xEEEEEEEE @ PCON7.word 0xEEEEEEEE @ PCON8.word 0xEEEEEEEE @ PCON9.word 0xE0EEEEEE @ PCONA.word 0xEF00EE0E @ PCONB.word 0xEEEE0EEF @ PCONC.word 0xEEEEEEEE @ PCOND.word 0x202222EE @ PCONE.word 0xEEEE0E22 @ PCONF.byte 0x0c, 0 @ PMU init address-data pairs.byte 0x2d, 0x15.byte 0x2e, 1.byte 0x37, 0x15.byte 0x38, 4.byte 0x2f, 0x15.byte 0x30, 1.byte 0x3b, 0.byte 0x3c, 0x8c.byte 0x13, 3.byte 0x14, 0.byte 0x15, 0.byte 0x22, 0x2f.byte 0x23, 1.byte 0x24, 0.byte 0x25, 0x10.byte 0x26, 9.byte 0x27, 1.byte 0x1a, 0x6f.byte 0x1b, 0.byte 0x1c, 0.byte 0x1d, 0x59.byte 0x33, 9.byte 0x34, 1.byte 0x39, 0x18.byte 0x3a, 0.byte 0x18, 0xa.byte 0x19, 4.byte 0x58, 0.byte 0x07, 0xb0.byte 0x08, 3.byte 0x09, 0xfe.byte 0x0a, 0xfc.byte 0x0b, 0xff.byte 0x86, 0xfd.byte 0x0d, 0xdf.byte 0x0e, 0xaa.byte 0x0f, 0x4a.byte 0x10, 5.byte 0x11, 0x27.byte 0x17, 1.byte 0x2a, 5.byte 0xff, 0xff @ PMU init terminatorlcddata_ref:.hword lcddata_0 - lcddata_ref.hword lcddata_1 - lcddata_ref - 2.hword lcddata_2 - lcddata_ref - 4.hword lcddata_3 - lcddata_ref - 6lcddata_0:.hword 0x4011.hword 0xc78f.hword 0x8135.byte 0x00.hword 0x813a.byte 0x06.hword 0x8136.byte 0x00.hword 0x4013.hword 0x4029.hword 0xc000lcddata_1:.hword 0x95b0.byte 0x3a.byte 0x3a.byte 0x80.byte 0x80.byte 0x0a.byte 0x0a.byte 0x0a.byte 0x0a.byte 0x0a.byte 0x0a.byte 0x0a.byte 0x0a.byte 0x3c.byte 0x30.byte 0x0f.byte 0x00.byte 0x01.byte 0x54.byte 0x06.byte 0x66.byte 0x66.hword 0x81b8.byte 0xd8.hword 0x9eb1.byte 0x14.byte 0x59.byte 0x00.byte 0x15.byte 0x57.byte 0x27.byte 0x04.byte 0x85.byte 0x14.byte 0x59.byte 0x00.byte 0x15.byte 0x57.byte 0x27.byte 0x04.byte 0x85.byte 0x14.byte 0x09.byte 0x15.byte 0x57.byte 0x27.byte 0x04.byte 0x05.byte 0x14.byte 0x09.byte 0x15.byte 0x57.byte 0x27.byte 0x04.byte 0x05.hword 0x40d2.hword 0x0101.hword 0x8de0.byte 0x00.byte 0x00.byte 0x00.byte 0x05.byte 0x0b.byte 0x12.byte 0x16.byte 0x1f.byte 0x25.byte 0x22.byte 0x24.byte 0x29.byte 0x1c.hword 0x8de1.byte 0x08.byte 0x01.byte 0x01.byte 0x06.byte 0x0b.byte 0x11.byte 0x15.byte 0x1f.byte 0x27.byte 0x26.byte 0x29.byte 0x2f.byte 0x1e.hword 0x8de2.byte 0x07.byte 0x01.byte 0x01.byte 0x05.byte 0x09.byte 0x0f.byte 0x13.byte 0x1e.byte 0x26.byte 0x25.byte 0x28.byte 0x2e.byte 0x1e.hword 0x8de3.byte 0x0d.byte 0x00.byte 0x00.byte 0x00.byte 0x05.byte 0x0b.byte 0x12.byte 0x16.byte 0x1f.byte 0x25.byte 0x22.byte 0x24.byte 0x29.byte 0x1c.hword 0x8de4.byte 0x08.byte 0x01.byte 0x01.byte 0x06.byte 0x0b.byte 0x11.byte 0x15.byte 0x1f.byte 0x27.byte 0x26.byte 0x29.byte 0x2f.byte 0x1e.hword 0x8de5.byte 0x07.byte 0x01.byte 0x01.byte 0x05.byte 0x09.byte 0x0f.byte 0x13.byte 0x1e.byte 0x26.byte 0x25.byte 0x28.byte 0x2e.byte 0x1e.hword 0x813a.byte 0x06.hword 0x81c2.byte 0x00.hword 0x8135.byte 0x00.hword 0x4011.hword 0xce88.hword 0x4013.hword 0x4029.hword 0xc000lcddata_2:lcddata_3:.hword 0xc010.hword 0x4008.hword 0x0808.hword 0x8110.byte 0x13.hword 0x4011.hword 0x0300.hword 0x4012.hword 0x0101.hword 0x4013.hword 0x0a03.hword 0x4014.hword 0x0a0e.hword 0x4015.hword 0x0a19.hword 0x4016.hword 0x2402.hword 0x8118.byte 0x01.hword 0x8190.byte 0x21.hword 0x4300.hword 0x0307.hword 0x4301.hword 0x0003.hword 0x4302.hword 0x0402.hword 0x4303.hword 0x0303.hword 0x4304.hword 0x0300.hword 0x4305.hword 0x0407.hword 0x4306.hword 0x1c04.hword 0x4307.hword 0x0307.hword 0x4308.hword 0x0003.hword 0x4309.hword 0x0402.hword 0x430a.hword 0x0303.hword 0x430b.hword 0x0300.hword 0x430c.hword 0x0407.hword 0x430d.hword 0x1c04.hword 0x4310.hword 0x0707.hword 0x4311.hword 0x0407.hword 0x4312.hword 0x0306.hword 0x4313.hword 0x0303.hword 0x4314.hword 0x0300.hword 0x4315.hword 0x0407.hword 0x4316.hword 0x1c01.hword 0x4317.hword 0x0707.hword 0x4318.hword 0x0407.hword 0x4319.hword 0x0306.hword 0x431a.hword 0x0303.hword 0x431b.hword 0x0300.hword 0x431c.hword 0x0407.hword 0x431d.hword 0x1c01.hword 0x4320.hword 0x0206.hword 0x4321.hword 0x0102.hword 0x4322.hword 0x0404.hword 0x4323.hword 0x0303.hword 0x4324.hword 0x0300.hword 0x4325.hword 0x0407.hword 0x4326.hword 0x1c1f.hword 0x4327.hword 0x0206.hword 0x4328.hword 0x0102.hword 0x4329.hword 0x0404.hword 0x432a.hword 0x0303.hword 0x432b.hword 0x0300.hword 0x432c.hword 0x0407.hword 0x432d.hword 0x1c1f.hword 0x4400.hword 0x001d.hword 0x4401.hword 0x0001.hword 0x4205.hword 0x0060.hword 0x8107.byte 0x01.hword 0x8131.byte 0x71.hword 0x4110.hword 0x0001.hword 0x4100.hword 0x17b0.hword 0x4101.hword 0x0220.hword 0x4102.hword 0x00bd.hword 0x4103.hword 0x1500.hword 0x4105.hword 0x0103.hword 0x4106.hword 0x0105.hword 0x8107.byte 0x21.hword 0x4102.hword 0x00bd.hword 0x4001.hword 0x0110.hword 0x4003.hword 0x0230.hword 0x4002.hword 0x0500.hword 0x8107.byte 0x31.hword 0x8130.byte 0x07.hword 0xc744.hword 0x4030.hword 0x03ff.hword 0xce88.hword 0x8107.byte 0x72.hword 0xe454.hword 0x4007.hword 0x0173.hword 0xc000.align 2lcdbyteseq:mov r9, r0,lsr#8and r0, r0, #0xffbl sendlcdclcdbyteseqloop:ldrb r0, [sp], #1bl sendlcddsubs r9, r9, #1bne lcdbyteseqloopb lcdloopsendlcdc:ldr r6, [r4,#0x1c]ands r6, r6, #0x10bne sendlcdcstr r0, [r4,#0x04]mov pc, lrsendlcdd:ldr r6, [r4,#0x1c]ands r6, r6, #0x10bne sendlcddstr r0, [r4,#0x40]mov pc, lri2cwaitrdy:ldr r6, [r5,#0x10]cmp r6, #0bne i2cwaitrdymov pc, lri2cwait:ldr r6, [r5]tst r6, #0x10beq i2cwaitmov pc, lrpmutransfer:mov r7, lrmov lr, #0xb7str lr, [r5]mov lr, #0xe6str lr, [r5,#0xc]mov lr, #0xf0str lr, [r5,#0x4]bl i2cwaitstr r3, [r5,#0xc]mov lr, #0xb7str lr, [r5]bl i2cwaitcmn r4, #1beq pmuskipstr r4, [r5,#0xc]mov lr, #0xb7str lr, [r5]bl i2cwaitmov lr, #0xd0b pmudonepmuskip:mov lr, #0xe7str lr, [r5,#0xc]mov lr, #0xb0str lr, [r5,#0x4]mov lr, #0xb7str lr, [r5]bl i2cwaitmov lr, #0x37str lr, [r5]bl i2cwaitldr r3, [r5,#0xc]mov lr, #0x90pmudone:str lr, [r5,#0x4]mov lr, #0xb7str lr, [r5]pmuwait:ldr lr, [r5,#0x4]tst lr, #0x20bne pmuwaitmov pc, r7udelay:ldr r6, [r1,#0xb4]add r0, r0, r6udelayloop:ldr r6, [r1,#0xb4]cmp r6, r0bmi udelayloopmov pc, lrpwrok:sub r7, r5, #0x04500000 @ R7 = MIUBASE (temporary)cmp r0, #0moveq r6, #0x11streq r6, [r7]str r8, [r7]str r2, [r7,#0xf0]str r9, [r7,#0x8]str r10, [r7,#0x10]mov r8, #0x1800orr r6, r8, #0x45str r6, [r7,#0x200]str r6, [r7,#0x204]str r8, [r7,#0x210]str r8, [r7,#0x214]str r6, [r7,#0x220]str r6, [r7,#0x224]add r6, r6, #0x40str r6, [r7,#0x230]str r6, [r7,#0x234]mov r6, #0x19str r6, [r7,#0x14]str r6, [r7,#0x18]str r11, [r7,#0x1c]ldr r6, [r7,#0x314]bic r6, r6, #0x10str r6, [r7,#0x314]add r8, r7, #0x2cmov r9, #0x24sdramloop:ldr r6, [r8]bic r6, r6, #0x01000000str r6, [r8], #4subs r9, r9, #1bne sdramloopmov r6, #0x540str r6, [r7,#0x1cc]ldr r6, [r7,#0x1d4]orr r6, r6, #0x80str r6, [r7,#0x1d4]mov r6, #0x33str r6, [r7,#0x4]str r6, [r7,#0x4]orr r8, r6, #0x200str r8, [r7,#0x4]str r6, [r7,#0x4]str r6, [r7,#0x4]str r6, [r7,#0x4]orr r8, r8, #0x100str r8, [r7,#0x4]str r6, [r7,#0x4]str r6, [r7,#0x4]str r6, [r7,#0x4]str r8, [r7,#0x4]str r6, [r7,#0x4]str r6, [r7,#0x4]str r6, [r7,#0x4]cmp r0, #0strne r6, [r7,#0xc]bicne r8, r8, #0x200strne r8, [r7,#0x4]strne r6, [r7,#0x4]strne r6, [r7,#0x4]strne r6, [r7,#0x4]strne r12, [r7,#0xc]strne r8, [r7,#0x4]strne r6, [r7,#0x4]strne r6, [r7,#0x4]strne r6, [r7,#0x4]ldr r6, [r7,#0x8]orr r6, r6, #0x61000str r6, [r7,#0x8]orr r3, r1, #0x00800000 @ R3 = GPIOBASEsub r4, r1, #0x04400000 @ R4 = LCDBASEldr r0, [r3,#0xc4]and r8, r0, #0x30 @ R8 = LCD type GPIO bits << 4mov r6, #0x80000000add sp, sp, r8,lsr#3tst r8, #0x20ldrh r0, [sp]orrne r6, r6, #0x188add sp, sp, r0orr r6, r6, #0xc20mov r0, #0x33str r6, [r4]str r0, [r4,#0x20]lcdloop:adr lr, lcdloopldrb r6, [sp], #1ldrb r7, [sp], #1orr r6, r6, r7,lsl#8mov r7, r6,lsr#14bics r0, r6, #0xc000add pc, pc, r7,lsl#2val_80100db0:.word 0x80100db0b sendlcddb sendlcdcbne lcdbyteseqmovne r0, r0,lsl#4bne udelayadr r1, _stubend + 4ldr r6, val_80100db0ldr r0, _stubendstr r6, [r4]add r0, r1, r0mov r2, #0x08000000movepayloadloop:cmp r0, r1ldrhi r3, [r1], #4strhi r3, [r2], #4bhi movepayloadloopbl flushcachemcr p15, 0, r0,c7,c5mov pc, #0x08000000_stubend: