···11-/***************************************************************************
22- * __________ __ ___.
33- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77- * \/ \/ \/ \/ \/
88- * $Id$
99- *
1010- * Copyright (C) 2008 by Jens Arnold
1111- *
1212- * based on arm_nrv2e_d8.S -- ARM decompressor for NRV2E
1313- * Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer
1414- * Copyright (C) 1996-2008 Laszlo Molnar
1515- * Copyright (C) 2000-2008 John F. Reiser
1616- *
1717- * This program is free software; you can redistribute it and/or
1818- * modify it under the terms of the GNU General Public License
1919- * as published by the Free Software Foundation; either version 2
2020- * of the License, or (at your option) any later version.
2121- *
2222- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2323- * KIND, either express or implied.
2424- *
2525- ****************************************************************************/
2626-2727-#define src r4
2828-#define dst r5
2929-#define len r6 /* overlaps 'cnt' */
3030-#define cnt r6 /* overlaps 'len' while reading an offset */
3131-#define tmp r7
3232-3333-#define off r0 /* must be r0 because of indexed addressing */
3434-#define bits r1
3535-#define bitmask r2
3636-#define wrnk r3 /* -0x500 -M2_MAX_OFFSET before "wrinkle" */
3737-3838-3939-#define GETBIT \
4040- tst bits, bitmask; \
4141- bf 1f; \
4242- bsr get1_n2e; \
4343-1: \
4444- shll bits /* using the delay slot on purpose */
4545-4646-#define getnextb(reg) GETBIT; rotcl reg
4747-#define jnextb0 GETBIT; bf
4848-#define jnextb1 GETBIT; bt
4949-5050- .section .icode,"ax",@progbits
5151- .align 2
5252- .global _ucl_nrv2e_decompress_8
5353- .type _ucl_nrv2e_decompress_8,@function
5454-5555-/* src_len = ucl_nrv2e_decompress_8(const unsigned char *src,
5656- * unsigned char *dst,
5757- * unsigned long *dst_len)
5858- */
5959-6060-_ucl_nrv2e_decompress_8:
6161- sts.l pr, @-r15
6262- mov #-1, off ! off = -1 initial condition
6363- mov.l r6, @-r15
6464- mov #-5, wrnk
6565- mov.l r5, @-r15
6666- shll8 wrnk ! nrv2e -M2_MAX_OFFSET
6767- mov.l r4, @-r15
6868- mov #-1, bitmask
6969- shlr bitmask ! 0x7fffffff for testing before shifting
7070- bra top_n2e
7171- not bitmask, bits ! refill next time (MSB must be set)
7272-7373-eof_n2e:
7474- mov.l @r15+, r0 ! r0 = orig_src
7575- mov.l @r15+, r1 ! r1 = orig_dst
7676- sub r0, src
7777- mov.l @r15+, r2 ! r2 = plen_dst
7878- sub r1, dst
7979- mov.l dst, @r2
8080- lds.l @r15+, pr
8181- rts
8282- mov src, r0
8383-8484-lit_n2e:
8585- mov.b @src, tmp
8686- add #1, src ! Need to fill the pipeline latency anyway
8787- mov.b tmp, @dst
8888- add #1, dst
8989-top_n2e:
9090- jnextb1 lit_n2e
9191- bra getoff_n2e
9292- mov #1, cnt
9393-9494-off_n2e:
9595- add #-1, cnt
9696- getnextb(cnt)
9797-getoff_n2e:
9898- getnextb(cnt)
9999- jnextb0 off_n2e
100100-101101- mov #-4, tmp ! T=1 on entry, so this does
102102- addc cnt, tmp ! tmp = cnt - 3, T = (cnt >= 3)
103103- mov #0, len ! cnt and len share a reg!
104104- bf offprev_n2e ! cnt was 2
105105- mov.b @src+, off ! low 7+1 bits
106106- shll8 tmp
107107- extu.b off, off
108108- or tmp, off
109109- not off, off ! off = ~off
110110- tst off, off
111111- bt eof_n2e
112112- shar off
113113- bt lenlast_n2e
114114- bf lenmore_n2e ! always taken if the preceding bt isn't
115115-116116-offprev_n2e:
117117- jnextb1 lenlast_n2e
118118-lenmore_n2e:
119119- mov #1, len
120120- jnextb1 lenlast_n2e
121121-len_n2e:
122122- getnextb(len)
123123- jnextb0 len_n2e
124124- bra gotlen_n2e
125125- mov #6-2, tmp
126126-127127-get1_n2e: ! in: T bit set
128128- mov.b @src+, bits ! SH1 sign-extends on load
129129- rotcl bits ! LSB = T, T = MSB
130130- shll16 bits
131131- rts
132132- shll8 bits
133133-134134-lenlast_n2e:
135135- getnextb(len) ! 0,1,2,3
136136- mov #2, tmp
137137-gotlen_n2e:
138138- cmp/gt off, wrnk ! too far away, so minimum match length is 3
139139- addc tmp, len
140140-copy_n2e:
141141- add #-1, len
142142- mov.b @(off,dst), tmp
143143- tst len, len
144144- mov.b tmp, @dst
145145- add #1, dst
146146- bf copy_n2e
147147- bt top_n2e ! always taken if the preceding bf isn't
148148-149149- .size _ucl_nrv2e_decompress_8, .-_ucl_nrv2e_decompress_8
-59
firmware/decompressor/startup.S
···11-/***************************************************************************
22- * __________ __ ___.
33- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77- * \/ \/ \/ \/ \/
88- * $Id$
99- *
1010- * Copyright (C) 2005 by Jens Arnold
1111- * based on crt0.S by Linus Nielsen Feltzing
1212- *
1313- * This program is free software; you can redistribute it and/or
1414- * modify it under the terms of the GNU General Public License
1515- * as published by the Free Software Foundation; either version 2
1616- * of the License, or (at your option) any later version.
1717- *
1818- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1919- * KIND, either express or implied.
2020- *
2121- ****************************************************************************/
2222- .section .start,"ax",@progbits
2323- .global _start
2424-_start:
2525- /* copy the .iram section */
2626- mov.l .iramcopy_k,r0
2727- mov.l .iram_k,r1
2828- mov.l .iramend_k,r2
2929- /* Note: We cannot put a PC relative load into the delay slot of a 'bra'
3030- instruction (the offset would be wrong), but there is nothing else to
3131- do before the loop, so the delay slot would be 'nop'. The cmp / bf
3232- sequence is the same length, but more efficient. */
3333- cmp/hi r1,r2
3434- bf .noiramcopy
3535-.iramloop:
3636- mov.l @r0+,r3
3737- mov.l r3,@r1
3838- add #4,r1
3939- cmp/hi r1,r2
4040- bt .iramloop
4141-.noiramcopy:
4242-4343- /* call the mainline */
4444- mov.l .main_k,r0
4545- mov.l .stackend_k,r15
4646- jmp @r0
4747- nop
4848-4949- .align 2
5050-.iramcopy_k:
5151- .long _iramcopy
5252-.iram_k:
5353- .long _iramstart
5454-.iramend_k:
5555- .long _iramend
5656-.stackend_k:
5757- .long _stackend
5858-.main_k:
5959- .long _main