diff options
Diffstat (limited to 'firmware/target/sh/archos/descramble.S')
-rw-r--r-- | firmware/target/sh/archos/descramble.S | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/firmware/target/sh/archos/descramble.S b/firmware/target/sh/archos/descramble.S deleted file mode 100644 index 0ab5e93dce..0000000000 --- a/firmware/target/sh/archos/descramble.S +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2004 by Jens Arnold | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | .section .icode,"ax",@progbits | ||
23 | |||
24 | .align 2 /* this aligns to 2^2=4 byte bounday */ | ||
25 | .global _descramble | ||
26 | .type _descramble,@function | ||
27 | |||
28 | /* Descramble a block of byte data, from source to dest, processing len | ||
29 | * bytes. Size only limited by the len argument. Note that len must | ||
30 | * be an even multiple of 4 (something rolo_load() already assumes. | ||
31 | * (Does the Archos firmware loader also require that?). | ||
32 | * | ||
33 | * Returns the 16-bit "sum" checksum of the descrambled data. | ||
34 | * | ||
35 | * Arguments: | ||
36 | * r4 - source (unsigned char*) | ||
37 | * r5 - dest (unsigned char*) | ||
38 | * r6 - len (unsigned int) | ||
39 | * | ||
40 | * Register usage: | ||
41 | * r0 - data | ||
42 | * r1 - temp | ||
43 | * r2 - checksum | ||
44 | * r3 - current src address | ||
45 | * r4 - source | ||
46 | * r5 - dest | ||
47 | * r6 - len -> source_end | ||
48 | * r7 - dest_end | ||
49 | * r8 - len / 4 | ||
50 | */ | ||
51 | |||
52 | _descramble: | ||
53 | mov.l r8,@-r15 | ||
54 | mov r6,r8 | ||
55 | shlr2 r8 /* r8 = len / 4 */ | ||
56 | mov r5,r7 | ||
57 | add r6,r7 /* dest_end = dest + len */ | ||
58 | add r4,r6 /* source_end = source + len */ | ||
59 | mov r4,r3 /* addr = source */ | ||
60 | mov #0,r2 /* checksum = 0 */ | ||
61 | |||
62 | .loop: | ||
63 | mov.b @r3,r0 /* data = *addr */ | ||
64 | add r8,r3 /* addr += len / 4 */ | ||
65 | extu.b r0,r0 /* zero extend data byte */ | ||
66 | swap.b r0,r1 /* byte swap low word to temp */ | ||
67 | or r1,r0 /* r0's two lower bytes now identical */ | ||
68 | shlr r0 /* -> this equals "rotr.b r0" now */ | ||
69 | not r0,r0 /* negate */ | ||
70 | extu.b r0,r0 /* zero extend low byte (only needed for sum) */ | ||
71 | mov.b r0,@r5 /* *dest = data */ | ||
72 | add r0,r2 /* checksum += data */ | ||
73 | add #1,r5 /* dest++ */ | ||
74 | cmp/hi r3,r6 /* addr < source_end ? */ | ||
75 | bt .loop | ||
76 | |||
77 | add #1,r4 /* source++ */ | ||
78 | mov r4,r3 /* addr = source */ | ||
79 | cmp/hi r5,r7 /* dest < dest_end */ | ||
80 | bt .loop | ||
81 | |||
82 | /* 15 clock cycles if no reset of source address, 19 if reset, | ||
83 | * avg. 16 cycles per byte. Magnus' Version needed 17-22 cycles per byte | ||
84 | */ | ||
85 | |||
86 | mov.l @r15+,r8 | ||
87 | rts | ||
88 | extu.w r2,r0 | ||
89 | |||
90 | |||
91 | /* Move len bytes from source to dest (which must be suitably aligned for | ||
92 | * long moves) and jump to dest + 0x200. | ||
93 | * | ||
94 | * Arguments: | ||
95 | * r4 - source | ||
96 | * r5 - dest | ||
97 | * r6 - len | ||
98 | */ | ||
99 | |||
100 | .align 2 | ||
101 | .global _rolo_restart | ||
102 | .type _rolo_restart,@function | ||
103 | |||
104 | _rolo_restart: | ||
105 | mov r5,r0 | ||
106 | sub r4,r0 /* r0 = dest - source */ | ||
107 | add #-4,r0 /* adjust for early increment */ | ||
108 | add r4,r6 /* r6 = source + len */ | ||
109 | |||
110 | .copy: /* loop takes 6 cycles per longword */ | ||
111 | mov.l @r4+,r1 | ||
112 | cmp/hi r4,r6 | ||
113 | mov.l r1,@(r0,r4) | ||
114 | bt .copy | ||
115 | |||
116 | mov.l @r5+,r0 /* start address from image */ | ||
117 | jmp @r0 | ||
118 | mov.l @r5+,r15 /* stack pointer from image */ | ||
119 | |||
120 | .end: | ||
121 | .size _descramble,.end-_descramble | ||