Changeset 12325


Ignore:
Timestamp:
06/20/09 18:58:53 (4 years ago)
Author:
BrainSlayer
Message:

increase lzma decoder speed by 2

Location:
ar5315_microredboot/microredboot
Files:
71 edited

Legend:

Unmodified
Added
Removed
  • ar5315_microredboot/microredboot/CHANGELOG

    r12324 r12325  
    1120.6.09 
    22    * AR5312/AR2313: fix nvram erase for nor flash devices (tested) 
     3    * make LzmaDecoder 2-3 times faster. this increases size, but we are still in 64 kb limit 
    34    note: 
    45    - finally the bootloader works now for ap51,ap65 and ap48 with all current planned features 
  • ar5315_microredboot/microredboot/boot/src/Makefile

    r12321 r12325  
    4949HEAD             = head.o 
    5050OBJS             = misc_lzma.o lib/lib.o lib/print.o lib/printf.o 
    51 MEMCPY           = memcpy.o memset.o 
     51MEMCPY           = memset.o 
    5252# CFLAGS         = $(CPPFLAGS) -O2 -DSTDC_HEADERS $(CFLAGS_BOOT) 
    5353ZLDFLAGS         = -G 0 -static -X -T ld.script 
  • ar5315_microredboot/microredboot/boot/src/lib/LzmaDecode.c

    r12320 r12325  
    4141        int Result; 
    4242#endif 
    43         int ExtraBytes; 
    4443} CRangeDecoder; 
    4544 
    46 static Byte RangeDecoderReadByte(CRangeDecoder * rd) 
     45static inline Byte RangeDecoderReadByte(CRangeDecoder * rd) 
    4746{ 
    4847        if (rd->Buffer == rd->BufferLim) { 
     
    5150                rd->Result = read_byte(&rd->Buffer, &size); 
    5251                rd->BufferLim = rd->Buffer + size; 
    53                 if (size == 0) 
    54 #endif 
    55                 { 
    56                         rd->ExtraBytes = 1; 
    57                         return 0xFF; 
    58                 } 
     52#endif 
    5953        } 
    6054        return (*rd->Buffer++); 
     
    7367        rd->BufferLim = stream + bufferSize; 
    7468#endif 
    75         rd->ExtraBytes = 0; 
    7669        rd->Code = 0; 
    7770        rd->Range = (0xFFFFFFFF); 
     
    8477#define RC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | ReadByte; } 
    8578 
    86 static UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder * rd, int numTotalBits) 
     79static inline UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder * rd, 
     80                                                  int numTotalBits) 
    8781{ 
    8882        RC_INIT_VAR UInt32 result = 0; 
     
    107101} 
    108102 
    109 static int RangeDecoderBitDecode(CProb * prob, CRangeDecoder * rd) 
     103static inline int RangeDecoderBitDecode(CProb * prob, CRangeDecoder * rd) 
    110104{ 
    111105        UInt32 bound = (rd->Range >> kNumBitModelTotalBits) * *prob; 
     
    140134#define RC_GET_BIT(prob, mi) RC_GET_BIT2(prob, mi, ; , ;) 
    141135 
    142 static int RangeDecoderBitTreeDecode(CProb * probs, int numLevels, 
    143                                      CRangeDecoder * rd) 
     136static int inline RangeDecoderBitTreeDecode(CProb * probs, int numLevels, 
     137                                            CRangeDecoder * rd) 
    144138{ 
    145139        int mi = 1; 
     
    162156} 
    163157 
    164 static int RangeDecoderReverseBitTreeDecode(CProb * probs, int numLevels, 
    165                                             CRangeDecoder * rd) 
     158static int inline RangeDecoderReverseBitTreeDecode(CProb * probs, int numLevels, 
     159                                                   CRangeDecoder * rd) 
    166160{ 
    167161        int mi = 1; 
     
    187181} 
    188182 
    189 static Byte LzmaLiteralDecode(CProb * probs, CRangeDecoder * rd) 
     183static Byte inline LzmaLiteralDecode(CProb * probs, CRangeDecoder * rd) 
    190184{ 
    191185        int symbol = 1; 
     
    210204} 
    211205 
    212 static Byte LzmaLiteralDecodeMatch(CProb * probs, CRangeDecoder * rd, 
    213                                    Byte matchByte) 
     206static inline Byte LzmaLiteralDecodeMatch(CProb * probs, CRangeDecoder * rd, 
     207                                          Byte matchByte) 
    214208{ 
    215209        int symbol = 1; 
     
    272266#define kNumLenProbs (LenHigh + kLenNumHighSymbols) 
    273267 
    274 static int LzmaLenDecode(CProb * p, CRangeDecoder * rd, int posState) 
     268static inline int LzmaLenDecode(CProb * p, CRangeDecoder * rd, int posState) 
    275269{ 
    276270        if (RangeDecoderBitDecode(p + LenChoice, rd) == 0) 
     
    364358} 
    365359 
    366 static int LzmaDecode(unsigned char *buffer, 
    367                       unsigned char *outStream, UInt32 outSize, 
    368                       UInt32 * outSizeProcessed) 
     360int LzmaDecode(unsigned char *buffer, 
     361               unsigned char *outStream, UInt32 outSize, 
     362               UInt32 * outSizeProcessed) 
    369363{ 
    370364        LzmaVarState *vs = (LzmaVarState *) buffer; 
     
    443437                        return rd.Result; 
    444438#endif 
    445                 if (rd.ExtraBytes != 0) 
    446                         return LZMA_RESULT_DATA_ERROR; 
    447439                if (RangeDecoderBitDecode 
    448440                    (p + IsMatch + (state << kNumPosBitsMax) + posState, 
  • ar5315_microredboot/microredboot/boot/src/misc_lzma.c

    r12323 r12325  
    4343static unsigned outcnt;         /* bytes in output buffer */ 
    4444 
    45 #define get_byte()  (inptr < insize ? inbuf[inptr++] : fill_inbuf()) 
    46  
    47 static int fill_inbuf(void); 
     45static void fill_inbuf(void); 
     46 
     47static inline unsigned char get_byte(void) 
     48{ 
     49        static unsigned int vall; 
     50 
     51        if (((unsigned int)inptr % 4) == 0) { 
     52                vall = *(unsigned int *)inbuf; 
     53                inbuf += 4; 
     54        } 
     55        return *(((unsigned char *)&vall) + (inptr++ & 3)); 
     56} 
     57 
     58//#define get_byte()  (inptr < insize ? inbuf[inptr++] : fill_inbuf()) 
     59 
    4860static void flush_window(void); 
    4961static void error(char *m); 
     
    6375 
    6476#include "lib/LzmaDecode.h" 
    65 static int read_byte(unsigned char **buffer, UInt32 * bufferSize); 
     77static unsigned int icnt = 0; 
     78static inline int read_byte(unsigned char **buffer, UInt32 * bufferSize) 
     79{ 
     80        static unsigned char val; 
     81        *bufferSize = 1; 
     82        val = get_byte(); 
     83        *buffer = &val; 
     84        if (icnt++ % (1024 * 10) == 0) 
     85                putc('.'); 
     86        return LZMA_RESULT_OK; 
     87} 
     88 
    6689#include "lib/LzmaDecode.c" 
    6790 
     
    80103        unsigned char *workspace; 
    81104        unsigned int lc, lp, pb; 
     105        if (inptr >= insize) 
     106                fill_inbuf(); 
    82107 
    83108        // lzma args 
     
    153178*/ 
    154179 
    155 static unsigned int icnt = 0; 
    156 static int read_byte(unsigned char **buffer, UInt32 * bufferSize) 
    157 { 
    158         static unsigned char val; 
    159         *bufferSize = 1; 
    160         val = get_byte(); 
    161         *buffer = &val; 
    162         if (icnt++ % (1024 * 10) == 0) 
    163                 putc('.'); 
    164         return LZMA_RESULT_OK; 
    165 } 
    166  
    167180struct fis_image_desc { 
    168181        unsigned char name[16]; // Null terminated name 
     
    206219                        bootoffset = fis->entry_point; 
    207220                        output_data = (uch *) fis->mem_base; 
    208 #ifdef AR5312 
     221//#ifdef AR5312 
    209222                        return fis->flash_base; 
    210 #else 
    211                         memcpy((unsigned char *)ZCACHEADDR, 
    212                                (unsigned char *)fis->flash_base, 
    213                                1 * 1024 * 1024); 
    214                         return ZCACHEADDR; 
    215 #endif 
     223//#else 
     224//                      memcpy((unsigned char *)ZCACHEADDR, 
     225//                             (unsigned char *)fis->flash_base, 
     226//                             1 * 1024 * 1024); 
     227//                      return ZCACHEADDR; 
     228//#endif 
    216229                } 
    217230                p += 256; 
     
    231244static int resettrigger = 0; 
    232245 
    233 static int fill_inbuf(void) 
     246static void fill_inbuf(void) 
    234247{ 
    235248        if (insize != 0) 
     
    238251                inbuf = (uch *) linuxaddr; 
    239252                insize = 0x400000; 
    240                 inptr = 1; 
     253                inptr = 0; 
    241254        } else { 
    242255                inbuf = input_data; 
    243256                insize = &input_data_end[0] - &input_data[0]; 
    244                 inptr = 1; 
    245         } 
    246         return inbuf[0]; 
     257                inptr = 0; 
     258        } 
     259        return; 
    247260} 
    248261 
     
    943956                             header->len, header); 
    944957                        nvramdetect = (unsigned int)header; 
    945                         memcpy(nvram_buf, header, NVRAM_SPACE); 
     958                        unsigned int *src = header; 
     959                        unsigned int *dst = nvram_buf; 
     960                        for (i = 0; i < NVRAM_SPACE / 4; i++) 
     961                                dst[i] = src[i]; 
    946962                        return; 
    947963                } 
Note: See TracChangeset for help on using the changeset viewer.