1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Jens Arnold
12 * based on arm_nrv2e_d8.S -- ARM decompressor for NRV2E
13 * Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer
14 * Copyright (C) 1996-2008 Laszlo Molnar
15 * Copyright (C) 2000-2008 John F. Reiser
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
22 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
23 * KIND, either express or implied.
25 ****************************************************************************/
29 #define len r6 /* overlaps 'cnt' */
30 #define cnt r6 /* overlaps 'len' while reading an offset */
33 #define off r0 /* must be r0 because of indexed addressing */
36 #define wrnk r3 /* -0x500 -M2_MAX_OFFSET before "wrinkle" */
44 shll bits /* using the delay slot on purpose */
46 #define getnextb(reg) GETBIT; rotcl reg
47 #define jnextb0 GETBIT; bf
48 #define jnextb1 GETBIT; bt
50 .section .icode,"ax",@progbits
52 .global _ucl_nrv2e_decompress_8
53 .type _ucl_nrv2e_decompress_8,@function
55 /* src_len = ucl_nrv2e_decompress_8(const unsigned char *src,
57 * unsigned long *dst_len)
60 _ucl_nrv2e_decompress_8:
62 mov #-1, off ! off = -1 initial condition
66 shll8 wrnk ! nrv2e -M2_MAX_OFFSET
69 shlr bitmask ! 0x7fffffff for testing before shifting
71 not bitmask, bits ! refill next time (MSB must be set)
74 mov.l @r15+, r0 ! r0 = orig_src
75 mov.l @r15+, r1 ! r1 = orig_dst
77 mov.l @r15+, r2 ! r2 = plen_dst
86 add #1, src ! Need to fill the pipeline latency anyway
101 mov #-4, tmp ! T=1 on entry, so this does
102 addc cnt, tmp ! tmp = cnt - 3, T = (cnt >= 3)
103 mov #0, len ! cnt and len share a reg!
104 bf offprev_n2e ! cnt was 2
105 mov.b @src+, off ! low 7+1 bits
109 not off, off ! off = ~off
114 bf lenmore_n2e ! always taken if the preceding bt isn't
127 get1_n2e: ! in: T bit set
128 mov.b @src+, bits ! SH1 sign-extends on load
129 rotcl bits ! LSB = T, T = MSB
135 getnextb(len) ! 0,1,2,3
138 cmp/gt off, wrnk ! too far away, so minimum match length is 3
142 mov.b @(off,dst), tmp
147 bt top_n2e ! always taken if the preceding bf isn't
149 .size ucl_nrv2e_decompress_8, .-ucl_nrv2e_decompress_8