1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 Rafaël Carré
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 .set IRAM_SIZE, 0x50000
26 .set GPIOA, 0xC80B0000
27 .set GPIOB, 0xC80C0000
28 .set GPIOC, 0xC80D0000
29 .set GPIOD, 0xC80E0000
30 .set CGU_PERI, 0xC80F0014
43 /* These values are filled in by mkamsboot - don't move them from offset 0x20 */
44 uclunpack_end: .word 0 /* End of the ucl_unpack function */
45 uclunpack_size: .word 0 /* Size in bytes of the ucl_unpack function */
47 ucl_of_end: .word 0 /* End of the ucl-compressed OF image */
48 ucl_of_size: .word 0 /* Size in bytes of the compressed OF image */
50 ucl_rb_end: .word 0 /* End of the ucl-compressed RB image */
51 ucl_rb_size: .word 0 /* Size in bytes of the compressed RB image */
55 /* First copy the UCL unpack function to the end of RAM */
56 ldr r0, uclunpack_end /* Source */
57 ldr r1, uclunpack_size /* Source length */
58 sub r2, r0, r1 /* Source start - 1*/
60 ldr r3, =(IRAM_SIZE-1) /* Destination end */
68 add r5, r3, #2 /* r5 is entry point of copy of uclunpack */
69 /* function, plus one (for thumb mode */
71 /* enable gpio clock */
78 #ifndef SANSA_M200V4 /* this doesnt work for m200 */
79 /* we check A3 unconditionally of the model because it seems to be */
80 /* either hold, either usb on every model */
81 /* TODO: make it USB on all AMS Sansas for consistency, USB is safer too */
87 ldr r1, [r0, #0x8] /* USB is A1 on C200 */
88 #elif defined(SANSA_CLIP)
89 ldr r1, [r0, #0x100] /* USB is A6 on Clip */
91 ldr r1, [r0, #0x20] /* read pin A3 */
97 /* here are model specific tests, for dual boot without a computer */
101 .set row, (1<<5) /* enable output on C5 */
105 str r1, [r0, #(4*row)]
107 .set col, (1<<0) /* read keyscan column B0 */
111 ldr r1, [r0, #(4*col)]
115 #elif defined(SANSA_E200V2) || defined(SANSA_FUZE)
120 ldr r1, [r0, #0x20] /* read pin C3 */
122 cmp r1, #0 /* C3 = #0 means button pressed */
124 #elif defined(SANSA_C200V2)
125 /* check for RIGHT on C6, should maybe changed to LEFT as soon as it
126 * known in which pin that is in order for consistency */
129 str r1, [r0, #0x400] /* set pin to output */
131 ldr r1, [r0, #256] /* 1<<(6+2) */
132 cmp r1, #0 /* C6 low means button pressed */
134 #elif defined(SANSA_M200V4)
136 .set row, (1<<5) /* enable output on A5 */
140 str r1, [r0, #(4*row)]
142 .set col, (1<<0) /* read keyscan column A0 */
143 ldr r2, [r0, #(4*col)]
145 /* check value read (1 means button pressed) */
149 #error No target-specific key check defined!
152 /* No button was held, so we boot rockbox */
153 ldr r0, ucl_rb_end /* Address of compressed image */
154 ldr r1, ucl_rb_size /* Compressed size */
158 ldr r0, ucl_of_end /* Address of compressed image */
159 ldr r1, ucl_of_size /* Compressed size */
164 /* r5 = entry point (plus one for thumb) of uclunpack function */
165 /* r3 = destination_end for copy of UCL image */
166 /* r0 = source_end for UCL image to copy */
167 /* r1 = size of UCL image to copy */
169 sub r4, r3, r1 /* r4 := destination_start - 1 */
174 cmp r3, r4 /* Stop when we reached dest_start-1 */
177 /* Call the ucl decompress function, which will branch to 0x0 */
179 add r0, r3, #1 /* r0 := Start of compressed image */
180 /* r1 already contains compressed size */
181 mov r2, #0 /* r2 := Destination for unpacking */
182 bx r5 /* Branch to uclunpack, switching to thumb */