summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-03-19 22:04:17 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-03-19 22:04:17 +0000
commite1dd10ddfb49bfdd05fa8997bc097df93a9c9466 (patch)
tree0c530ecb1ab68eb335edf595829bf7786e6a683e /firmware
parentfbf52ae8fe04f27368392b71a3572dc2bb00788f (diff)
downloadrockbox-e1dd10ddfb49bfdd05fa8997bc097df93a9c9466.tar.gz
rockbox-e1dd10ddfb49bfdd05fa8997bc097df93a9c9466.zip
SWCODEC: Get rid of extra swap buffer and get back 512K of RAM or 100K if the players RAM is <= 1MB. Make any needed changes to things to stabilize and facilitate this including removing flattening out initialization. Comment some things heavily. Fix a few logfs I didn't want to see the compiler complaining about.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12843 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES4
-rw-r--r--firmware/common/memswap128.c44
-rw-r--r--firmware/include/memory.h11
-rw-r--r--firmware/target/arm/memswap128-arm.S44
-rw-r--r--firmware/target/coldfire/memswap128-coldfire.S50
5 files changed, 153 insertions, 0 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 549e4af286..974326570a 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -248,6 +248,8 @@ target/coldfire/crt0.S
248target/coldfire/memcpy-coldfire.S 248target/coldfire/memcpy-coldfire.S
249target/coldfire/memmove-coldfire.S 249target/coldfire/memmove-coldfire.S
250target/coldfire/memset-coldfire.S 250target/coldfire/memset-coldfire.S
251target/coldfire/memswap128-coldfire.S
252common/memswap128.c
251#if defined(HAVE_LCD_COLOR) \ 253#if defined(HAVE_LCD_COLOR) \
252 || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) 254 || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED)
253target/coldfire/memset16-coldfire.S 255target/coldfire/memset16-coldfire.S
@@ -269,6 +271,7 @@ common/strlen.c
269#ifndef SIMULATOR 271#ifndef SIMULATOR
270target/arm/memset-arm.S 272target/arm/memset-arm.S
271target/arm/memset16-arm.S 273target/arm/memset16-arm.S
274target/arm/memswap128-arm.S
272#if CONFIG_I2C == I2C_PP5020 || CONFIG_I2C == I2C_PP5002 275#if CONFIG_I2C == I2C_PP5020 || CONFIG_I2C == I2C_PP5002
273target/arm/i2c-pp.c 276target/arm/i2c-pp.c
274#elif CONFIG_I2C == I2C_PNX0101 277#elif CONFIG_I2C == I2C_PNX0101
@@ -295,6 +298,7 @@ common/memcpy.c
295common/memmove.c 298common/memmove.c
296common/memset.c 299common/memset.c
297common/memset16.c 300common/memset16.c
301common/memswap128.c
298common/strlen.c 302common/strlen.c
299#ifndef SIMULATOR 303#ifndef SIMULATOR
300crt0.S 304crt0.S
diff --git a/firmware/common/memswap128.c b/firmware/common/memswap128.c
new file mode 100644
index 0000000000..af1fe157b6
--- /dev/null
+++ b/firmware/common/memswap128.c
@@ -0,0 +1,44 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Michael Sevakis
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include <string.h>
21#include <inttypes.h>
22
23void memswap128(void *a, void *b, size_t len)
24{
25 for (len >>= 4; len > 0; len--, a += 16, b += 16)
26 {
27 int32_t a0 = *((int32_t *)a + 0);
28 int32_t a1 = *((int32_t *)a + 1);
29 int32_t a2 = *((int32_t *)a + 2);
30 int32_t a3 = *((int32_t *)a + 3);
31 int32_t b0 = *((int32_t *)b + 0);
32 int32_t b1 = *((int32_t *)b + 1);
33 int32_t b2 = *((int32_t *)b + 2);
34 int32_t b3 = *((int32_t *)b + 3);
35 *((int32_t *)b + 0) = a0;
36 *((int32_t *)b + 1) = a1;
37 *((int32_t *)b + 2) = a2;
38 *((int32_t *)b + 3) = a3;
39 *((int32_t *)a + 0) = b0;
40 *((int32_t *)a + 1) = b1;
41 *((int32_t *)a + 2) = b2;
42 *((int32_t *)a + 3) = b3;
43 }
44}
diff --git a/firmware/include/memory.h b/firmware/include/memory.h
index 559c6ed96a..75bcb98df7 100644
--- a/firmware/include/memory.h
+++ b/firmware/include/memory.h
@@ -24,4 +24,15 @@
24 24
25void memset16(void *dst, int val, size_t len); 25void memset16(void *dst, int val, size_t len);
26 26
27/**
28 * memswap128
29 *
30 * Exchanges the contents of two buffers.
31 * For maximum efficiency, this function performs no aligning of addresses
32 * and buf1, buf2 and len should be 16 byte (128 bit) aligned. Not being at
33 * least longword aligned will fail on some architechtures. Any len mod 16
34 * at the end is not swapped.
35 */
36void memswap128(void *buf1, void *buf2, size_t len);
37
27#endif /* _MEMORY_H_ */ 38#endif /* _MEMORY_H_ */
diff --git a/firmware/target/arm/memswap128-arm.S b/firmware/target/arm/memswap128-arm.S
new file mode 100644
index 0000000000..f5276ef353
--- /dev/null
+++ b/firmware/target/arm/memswap128-arm.S
@@ -0,0 +1,44 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Michael Sevakis
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/****************************************************************************
21 * void memswap128(void *buf1, void *buf2, size_t len)
22 */
23 .section .icode, "ax", %progbits
24 .align 2
25 .global memswap128
26 .type memswap128, %function
27memswap128:
28 @ r0 = buf1
29 @ r1 = buf2
30 @ r2 = len
31 movs r2, r2, lsr #4 @ bytes => lines, len == 0?
32 moveq pc, lr @ not at least a line? leave
33 stmdb sp!, { r4-r10, lr } @ save registers and return address
34.loop: @
35 ldmia r0, { r3-r6 } @ read four longwords from buf1
36 ldmia r1, { r7-r10 } @ read four longwords from buf2
37 stmia r0!, { r7-r10 } @ write buf2 data to buf1, buf1 += 16
38 stmia r1!, { r3-r6 } @ write buf1 data to buf2, buf2 += 16
39 subs r2, r2, #1 @ len -= 1, len > 0 ?
40 bhi .loop @ yes? keep exchanging
41 ldmia sp!, { r4-r10, pc } @ restore registers and return
42.end:
43 .size memswap128, .end-memswap128
44
diff --git a/firmware/target/coldfire/memswap128-coldfire.S b/firmware/target/coldfire/memswap128-coldfire.S
new file mode 100644
index 0000000000..2509fd0e45
--- /dev/null
+++ b/firmware/target/coldfire/memswap128-coldfire.S
@@ -0,0 +1,50 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Michael Sevakis
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/****************************************************************************
21 * void memswap128(void *buf1, void *buf2, size_t len)
22 */
23 .section .icode, "ax", @progbits
24 .align 2
25 .global memswap128
26 .type memswap128, @function
27memswap128:
28 lea.l -28(%sp), %sp | save registers
29 movem.l %d2-%d7/%a2, (%sp) |
30 movem.l 32(%sp), %a0-%a2 | %a0 = buf1
31 | %a1 = buf2
32 | %a2 = len
33 lea.l -15(%a0, %a2.l), %a2 | %a2 = end address - 15
34 cmp.l %a0, %a2 | end address <= buf1?
35 bls.b .no_lines | not at least a line? leave
36.loop: |
37 movem.l (%a0), %d0-%d3 | read four longwords from buf1
38 movem.l (%a1), %d4-%d7 | read four longwords from buf2
39 movem.l %d4-%d7, (%a0) | write buf2 data to buf1
40 movem.l %d0-%d3, (%a1) | write buf1 data to buf2
41 lea.l 16(%a0), %a0 | buf1 += 16
42 lea.l 16(%a1), %a1 | buf2 += 16
43 cmp.l %a0, %a2 | %a0 < %d0?
44 bhi.b .loop | yes? keep exchanging
45.no_lines: |
46 movem.l (%sp), %d2-%d7/%a2 | restore registers
47 lea.l 28(%sp), %sp |
48 rts |
49.end:
50 .size memswap128, .end-memswap128