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 /* This is the size of the Clip's RAM, but there is nothing to be gained
25 (at the moment) by making use of the larger RAM of other targets */
27 .set DRAM_SIZE, 0x50000
29 .set GPIOA, 0xC80B0000
30 .set GPIOB, 0xC80C0000
31 .set GPIOC, 0xC80D0000
32 .set GPIOD, 0xC80E0000
33 .set CGU_PERI, 0xC80F0014
46 /* These values are filled in by mkamsboot - don't move them from offset 0x20 */
47 uclunpack_end: .word 0 /* End of the ucl_unpack function */
48 uclunpack_size: .word 0 /* Size in bytes of the ucl_unpack function */
50 ucl_of_end: .word 0 /* End of the ucl-compressed OF image */
51 ucl_of_size: .word 0 /* Size in bytes of the compressed OF image */
53 ucl_rb_end: .word 0 /* End of the ucl-compressed RB image */
54 ucl_rb_size: .word 0 /* Size in bytes of the compressed RB image */
58 /* First copy the UCL unpack function to the end of RAM */
59 ldr r0, uclunpack_end /* Source */
60 ldr r1, uclunpack_size /* Source length */
61 sub r2, r0, r1 /* Source start - 1*/
63 ldr r3, =(DRAM_SIZE-1) /* Destination end */
71 add r5, r3, #2 /* r5 is entry point of copy of uclunpack */
72 /* function, plus one (for thumb mode */
74 /* enable gpio clock */
81 #ifndef SANSA_M200V4 /* this doesnt work for m200 */
82 /* we check A3 unconditionally of the model because it seems to be */
83 /* either hold, either usb on every model */
84 /* TODO: make it USB on all AMS Sansas for consistency, USB is safer too */
90 ldr r1, [r0, #0x8] /* USB is A1 on C200 */
91 #elif defined(SANSA_CLIP)
92 ldr r1, [r0, #0x100] /* USB is A6 on Clip */
94 ldr r1, [r0, #0x20] /* read pin A3 */
100 /* here are model specific tests, for dual boot without a computer */
104 .set row, (1<<6) /* enable output on C6 */
108 str r1, [r0, #(4*row)]
110 .set col, (1<<2) /* read keyscan column B2 */
114 ldr r1, [r0, #(4*col)]
118 #elif defined(SANSA_E200V2) || defined(SANSA_FUZE)
123 ldr r1, [r0, #0x20] /* read pin C3 */
125 cmp r1, #0 /* C3 = #0 means button pressed */
127 #elif defined(SANSA_C200V2)
128 /* check for RIGHT on C6, should maybe changed to LEFT as soon as it
129 * known in which pin that is in order for consistency */
132 str r1, [r0, #0x400] /* set pin to output */
134 ldr r1, [r0, #256] /* 1<<(6+2) */
135 cmp r1, #0 /* C6 low means button pressed */
137 #elif defined(SANSA_M200V4)
139 .set row, (1<<5) /* enable output on A5 */
143 str r1, [r0, #(4*row)]
145 .set col, (1<<0) /* read keyscan column A0 */
146 ldr r2, [r0, #(4*col)]
148 /* check value read (1 means button pressed) */
152 #error No target-specific key check defined!
155 /* No button was held, so we boot rockbox */
156 ldr r0, ucl_rb_end /* Address of compressed image */
157 ldr r1, ucl_rb_size /* Compressed size */
161 ldr r0, ucl_of_end /* Address of compressed image */
162 ldr r1, ucl_of_size /* Compressed size */
167 /* r5 = entry point (plus one for thumb) of uclunpack function */
168 /* r3 = destination_end for copy of UCL image */
169 /* r0 = source_end for UCL image to copy */
170 /* r1 = size of UCL image to copy */
172 sub r4, r3, r1 /* r4 := destination_start - 1 */
177 cmp r3, r4 /* Stop when we reached dest_start-1 */
180 /* Call the ucl decompress function, which will branch to 0x0 */
182 add r0, r3, #1 /* r0 := Start of compressed image */
183 /* r1 already contains compressed size */
184 mov r2, #0 /* r2 := Destination for unpacking */
185 bx r5 /* Branch to uclunpack, switching to thumb */