Changeset 12295


Ignore:
Timestamp:
06/16/09 04:12:29 (4 years ago)
Author:
BrainSlayer
Message:

make it about 2 kb smaller

Location:
ar5315_microredboot/microredboot/boot/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ar5315_microredboot/microredboot/boot/src/Makefile

    r12281 r12295  
    4747HEAD             = head.o 
    4848OBJS             = misc_lzma.o 
    49 MEMCPY           = memcpy.o memset.o 
     49MEMCPY           = memset.o 
    5050# CFLAGS         = $(CPPFLAGS) -O2 -DSTDC_HEADERS $(CFLAGS_BOOT) 
    5151ZLDFLAGS         = -G 0 -static -X -T ld.script 
  • ar5315_microredboot/microredboot/boot/src/lib/LzmaDecode.c

    r12281 r12295  
    4545} CRangeDecoder; 
    4646 
    47 Byte RangeDecoderReadByte(CRangeDecoder *rd) 
     47static Byte RangeDecoderReadByte(CRangeDecoder *rd) 
    4848{ 
    4949  if (rd->Buffer == rd->BufferLim) 
     
    6666#define ReadByte (RangeDecoderReadByte(rd)) 
    6767 
    68 void RangeDecoderInit(CRangeDecoder *rd) 
     68static void RangeDecoderInit(CRangeDecoder *rd) 
    6969{ 
    7070  int i; 
     
    8686#define RC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | ReadByte; } 
    8787 
    88 UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits) 
     88static UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits) 
    8989{ 
    9090  RC_INIT_VAR 
     
    114114} 
    115115 
    116 int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd) 
     116static int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd) 
    117117{ 
    118118  UInt32 bound = (rd->Range >> kNumBitModelTotalBits) * *prob; 
     
    152152#define RC_GET_BIT(prob, mi) RC_GET_BIT2(prob, mi, ; , ;)                
    153153 
    154 int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd) 
     154static int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd) 
    155155{ 
    156156  int mi = 1; 
     
    174174} 
    175175 
    176 int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd) 
     176static int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd) 
    177177{ 
    178178  int mi = 1; 
     
    199199} 
    200200 
    201 Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd) 
     201static Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd) 
    202202{  
    203203  int symbol = 1; 
     
    221221} 
    222222 
    223 Byte LzmaLiteralDecodeMatch(CProb *probs, CRangeDecoder *rd, Byte matchByte) 
     223static Byte LzmaLiteralDecodeMatch(CProb *probs, CRangeDecoder *rd, Byte matchByte) 
    224224{  
    225225  int symbol = 1; 
     
    279279#define kNumLenProbs (LenHigh + kLenNumHighSymbols)  
    280280 
    281 int LzmaLenDecode(CProb *p, CRangeDecoder *rd, int posState) 
     281static int LzmaLenDecode(CProb *p, CRangeDecoder *rd, int posState) 
    282282{ 
    283283  if(RangeDecoderBitDecode(p + LenChoice, rd) == 0) 
     
    340340} LzmaVarState; 
    341341 
    342 int LzmaDecoderInit( 
     342static int LzmaDecoderInit( 
    343343    unsigned char *buffer, UInt32 bufferSize, 
    344344    int lc, int lp, int pb, 
     
    371371} 
    372372 
    373 int LzmaDecode(unsigned char *buffer,  
     373static int LzmaDecode(unsigned char *buffer,  
    374374    unsigned char *outStream, UInt32 outSize, 
    375375    UInt32 *outSizeProcessed) 
     
    415415#else 
    416416 
    417 int LzmaDecode( 
     417static int LzmaDecode( 
    418418    Byte *buffer, UInt32 bufferSize, 
    419419    int lc, int lp, int pb, 
  • ar5315_microredboot/microredboot/boot/src/lib/LzmaDecode.h

    r12281 r12295  
    6666 
    6767#ifdef _LZMA_OUT_READ 
    68 int LzmaDecoderInit( 
     68static int LzmaDecoderInit( 
    6969    unsigned char *buffer, UInt32 bufferSize, 
    7070    int lc, int lp, int pb, 
     
    7373#endif 
    7474 
    75 int LzmaDecode( 
     75static int LzmaDecode( 
    7676    unsigned char *buffer,  
    7777  #ifndef _LZMA_OUT_READ 
  • ar5315_microredboot/microredboot/boot/src/misc_lzma.c

    r12294 r12295  
    189189 * searches for a directory entry named linux* vmlinux* or kernel and returns its flash address (it also initializes entrypoint and load address) 
    190190 */ 
    191 unsigned int getLinux(void) 
     191static unsigned int getLinux(void) 
    192192{ 
    193193        int count; 
     
    215215        puts("no bootable image found, try default location 0xbfc10000\r\n"); 
    216216        bootoffset = 0x80041000; 
    217         output_data = (uch *)0x80041000; 
     217        output_data = (uch *) 0x80041000; 
    218218        return 0xbfc10000; 
    219219} 
     
    225225static int resettrigger = 0; 
    226226 
    227 int fill_inbuf(void) 
     227static int fill_inbuf(void) 
    228228{ 
    229229        if (insize != 0) 
    230230                error("ran out of input data"); 
    231231        if (resettrigger) { 
    232                 inbuf = (uch *)linuxaddr; 
     232                inbuf = (uch *) linuxaddr; 
    233233                insize = 0x400000; 
    234234                inptr = 1; 
     
    491491        __u32 sector_size; 
    492492        __u32 cs_addrmask; 
    493 } flashconfig_tbl[MAX_FLASH] = { 
    494         { 
    495         0, 0, 0, 0}, { 
    496         STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT, STM_1MB_SECTOR_SIZE, 0x0}, 
    497         { 
    498         STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT, STM_2MB_SECTOR_SIZE, 0x0}, 
    499         { 
    500         STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT, STM_4MB_SECTOR_SIZE, 0x0}, 
    501         { 
    502         STM_8MB_BYTE_COUNT, STM_8MB_SECTOR_COUNT, STM_8MB_SECTOR_SIZE, 0x0}, 
    503         { 
    504         STM_16MB_BYTE_COUNT, STM_16MB_SECTOR_COUNT, 
    505                     STM_16MB_SECTOR_SIZE, 0x0} 
     493} static flashconfig_tbl[MAX_FLASH] = { 
     494        { 
     495         0, 0, 0, 0}, { 
     496                       STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT, 
     497                       STM_1MB_SECTOR_SIZE, 0x0}, 
     498        { 
     499         STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT, STM_2MB_SECTOR_SIZE, 0x0}, 
     500        { 
     501         STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT, STM_4MB_SECTOR_SIZE, 0x0}, 
     502        { 
     503         STM_8MB_BYTE_COUNT, STM_8MB_SECTOR_COUNT, STM_8MB_SECTOR_SIZE, 0x0}, 
     504        { 
     505         STM_16MB_BYTE_COUNT, STM_16MB_SECTOR_COUNT, 
     506         STM_16MB_SECTOR_SIZE, 0x0} 
    506507}; 
    507508 
     
    510511        __s8 tx_cnt; 
    511512        __s8 rx_cnt; 
    512 } stm_opcodes[] = { 
    513         { 
    514         STM_OP_WR_ENABLE, 1, 0}, { 
    515         STM_OP_WR_DISABLE, 1, 0}, { 
    516         STM_OP_RD_STATUS, 1, 1}, { 
    517         STM_OP_WR_STATUS, 1, 0}, { 
    518         STM_OP_RD_DATA, 4, 4}, { 
    519         STM_OP_FAST_RD_DATA, 5, 0}, { 
    520         STM_OP_PAGE_PGRM, 8, 0}, { 
    521         STM_OP_SECTOR_ERASE, 4, 0}, { 
    522         STM_OP_BULK_ERASE, 1, 0}, { 
    523         STM_OP_DEEP_PWRDOWN, 1, 0}, { 
    524 STM_OP_RD_SIG, 4, 1},}; 
     513} static stm_opcodes[] = { 
     514        { 
     515         STM_OP_WR_ENABLE, 1, 0}, { 
     516                                   STM_OP_WR_DISABLE, 1, 0}, { 
     517                                                              STM_OP_RD_STATUS, 
     518                                                              1, 1}, { 
     519                                                                      STM_OP_WR_STATUS, 
     520                                                                      1, 0}, { 
     521                                                                              STM_OP_RD_DATA, 
     522                                                                              4, 
     523                                                                              4}, 
     524        { 
     525         STM_OP_FAST_RD_DATA, 5, 0}, { 
     526                                      STM_OP_PAGE_PGRM, 8, 0}, { 
     527                                                                STM_OP_SECTOR_ERASE, 
     528                                                                4, 0}, { 
     529                                                                        STM_OP_BULK_ERASE, 
     530                                                                        1, 0}, { 
     531                                                                                STM_OP_DEEP_PWRDOWN, 
     532                                                                                1, 
     533                                                                                0}, 
     534        { 
     535         STM_OP_RD_SIG, 4, 1}, 
     536}; 
    525537 
    526538static __u32 spiflash_regread32(int reg) 
     
    538550        return; 
    539551} 
    540  
    541552 
    542553#define busy_wait(condition, wait) \ 
     
    634645        puts("\r\n"); 
    635646 
    636  
    637647        ptr_opcode = &stm_opcodes[SPI_SECTOR_ERASE]; 
    638648 
    639649        temp = ((__u32)offset << 8) | (__u32)(ptr_opcode->code); 
    640         spiflash_sendcmd(SPI_WRITE_ENABLE,0); 
     650        spiflash_sendcmd(SPI_WRITE_ENABLE, 0); 
    641651        busy_wait((reg = spiflash_regread32(SPI_FLASH_CTL)) & SPI_CTL_BUSY, 0); 
    642652 
    643653        spiflash_regwrite32(SPI_FLASH_OPCODE, temp); 
    644654 
    645         reg = (reg & ~SPI_CTL_TX_RX_CNT_MASK) | ptr_opcode->tx_cnt | SPI_CTL_START; 
     655        reg = 
     656            (reg & ~SPI_CTL_TX_RX_CNT_MASK) | ptr_opcode->tx_cnt | 
     657            SPI_CTL_START; 
    646658        spiflash_regwrite32(SPI_FLASH_CTL, reg); 
    647659 
    648660        busy_wait(spiflash_sendcmd(SPI_RD_STATUS, 0) & SPI_STATUS_WIP, 20); 
    649  
    650661 
    651662        puts("done\r\n"); 
     
    656667decompress_kernel(ulg output_start, ulg free_mem_ptr_p, ulg free_mem_ptr_end_p) 
    657668{ 
    658         output_data = (uch *) output_start;     /* Points to kernel start */ 
     669        output_data = (uch *) output_start; 
    659670        free_mem_ptr = free_mem_ptr_p; 
    660671        free_mem_ptr_end = free_mem_ptr_end_p; 
     
    669680                int count = 5; 
    670681                while (count--) { 
    671                         if (!resetTouched()) // check if reset button is unpressed again 
     682                        if (!resetTouched())    // check if reset button is unpressed again 
    672683                                break; 
    673684                        udelay(1000000); 
     
    685696                                sectorsize = flashconfig_tbl[index].sector_size; 
    686697                                puts("\r\n"); 
    687                                 flash_erase_nvram(flashconfig_tbl[index]. 
    688                                                   byte_cnt, 
    689                                                   flashconfig_tbl[index]. 
    690                                                   sector_size); 
     698                                flash_erase_nvram(flashconfig_tbl 
     699                                                  [index].byte_cnt, 
     700                                                  flashconfig_tbl 
     701                                                  [index].sector_size); 
    691702                        } 
    692703 
     
    702713                unsigned int mask = RESET_ENET0 | RESET_EPHY0; 
    703714                unsigned int regtmp; 
    704                  
     715 
    705716                /* important, enable ethernet bus, if the following lines are not initialized linux will not be able to use the ethernet mac, taken from redboot source */ 
    706717                regtmp = sysRegRead(AR2316_AHB_ARB_CTL); 
Note: See TracChangeset for help on using the changeset viewer.