##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 EVALUATION    08/Jun/2010  15:34:24 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  interwork                                            #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  F:\SVN\cn\KeyExten\conf_loader.c                     #
#    Command line    =  F:\SVN\cn\KeyExten\conf_loader.c -D NEWSGOLD -lC     #
#                       F:\SVN\cn\KeyExten\NSG\List\ -o                      #
#                       F:\SVN\cn\KeyExten\NSG\Obj\ -s9 --no_unroll          #
#                       --no_clustering --cpu_mode arm --endian little       #
#                       --cpu ARM926EJ-S --stack_align 4 --interwork -e      #
#                       --fpu None --dlib_config "F:\software\Embedded       #
#                       Workbench 4.0 Evaluation\ARM\LIB\dl5tpainl8n.h" -I   #
#                       "F:\software\Embedded Workbench 4.0                  #
#                       Evaluation\ARM\INC\" --inline_threshold=2            #
#    List file       =  F:\SVN\cn\KeyExten\NSG\List\conf_loader.lst          #
#    Object file     =  F:\SVN\cn\KeyExten\NSG\Obj\conf_loader.r79           #
#                                                                            #
#                                                                            #
##############################################################################

F:\SVN\cn\KeyExten\conf_loader.c
      1          #include "..\inc\swilib.h"
      2          #include "..\inc\cfg_items.h"
      3          #include "conf_loader.h"
      4          

   \                                 In segment DATA_I, align 4, align-sorted
      5          const char *successed_config_filename="";
   \                     successed_config_filename:
   \   00000000                      DS8 4
   \   00000004                      REQUIRE `?<Initializer for successed_config_filename>`
      6          
      7          #pragma segment="CONFIG_C"

   \                                 In segment CODE, align 4, keep-with-next
      8          int LoadConfigData(const char *fname)
      9          {
   \                     LoadConfigData:
   \   00000000   F0472DE9           PUSH     {R4-R10,LR}
     10            int f;
     11            unsigned int ul;
     12            char *buf;
     13            int result=0;
     14            void *cfg;
     15          
     16            extern const CFG_HDR cfghdr0; //first var in CONFIG
     17            cfg=(void*)&cfghdr0;
     18          
     19            unsigned int len=(int)__segment_end("CONFIG_C")-(int)__segment_begin("CONFIG_C");
   \   00000004   EC609FE5           LDR      R6,??LoadConfigData_0  ;; SFE(CONFIG_C) - SFB(CONFIG_C)
   \   00000008   04D04DE2           SUB      SP,SP,#+4
   \   0000000C   0040A0E1           MOV      R4,R0
   \   00000010   0050A0E3           MOV      R5,#+0
     20          
     21            if (!(buf=malloc(len))) return -1;
   \   00000014   0600A0E1           MOV      R0,R6
   \   00000018   140000EF           SWI      +20
   \   0000001C   0070B0E1           MOVS     R7,R0
   \   00000020   0500E001           MVNEQ    R0,R5
   \   00000024   F287BD08           POPEQ    {R1,R4-R10,PC}
     22            if ((f=fopen(fname,A_ReadOnly+A_BIN,P_READ,&ul))!=-1)
   \   00000028   CC909FE5           LDR      R9,??LoadConfigData_0+0x4  ;; cfghdr0
   \   0000002C   0D30A0E1           MOV      R3,SP
   \   00000030   8020A0E3           MOV      R2,#+128
   \   00000034   801CA0E3           MOV      R1,#+32768
   \   00000038   0400A0E1           MOV      R0,R4
   \   0000003C   0A0000EF           SWI      +10
   \   00000040   0080A0E1           MOV      R8,R0
   \   00000044   05A0E0E1           MVN      R10,R5
   \   00000048   0A0058E1           CMP      R8,R10
   \   0000004C   1000000A           BEQ      ??LoadConfigData_1
     23            {
     24              if (fread(f,buf,len,&ul)==len)
   \   00000050   0D30A0E1           MOV      R3,SP
   \   00000054   0620A0E1           MOV      R2,R6
   \   00000058   0710A0E1           MOV      R1,R7
   \   0000005C   0B0000EF           SWI      +11
   \   00000060   060050E1           CMP      R0,R6
   \   00000064   0700001A           BNE      ??LoadConfigData_2
     25              {
     26                memcpy(cfg,buf,len);
   \   00000068   0620A0E1           MOV      R2,R6
   \   0000006C   0710A0E1           MOV      R1,R7
   \   00000070   0900A0E1           MOV      R0,R9
   \   00000074   1E0100EF           SWI      +286
     27                fclose(f,&ul);
   \                     ??LoadConfigData_3:
   \   00000078   0D10A0E1           MOV      R1,SP
   \   0000007C   0800A0E1           MOV      R0,R8
   \   00000080   0D0000EF           SWI      +13
   \   00000084   140000EA           B        ??LoadConfigData_4
     28              }
     29              else
     30              {
     31                fclose(f,&ul);
   \                     ??LoadConfigData_2:
   \   00000088   0D10A0E1           MOV      R1,SP
   \   0000008C   0800A0E1           MOV      R0,R8
   \   00000090   0D0000EF           SWI      +13
     32                goto L_SAVENEWCFG;
     33              }
     34            }
     35            else
     36            {
     37            L_SAVENEWCFG:
     38              if ((f=fopen(fname,A_ReadWrite+A_Create+A_Truncate,P_READ+P_WRITE,&ul))!=-1)
   \                     ??LoadConfigData_1:
   \   00000094   0D30A0E1           MOV      R3,SP
   \   00000098   602FA0E3           MOV      R2,#+384
   \   0000009C   0210A0E3           MOV      R1,#+2
   \   000000A0   C01F81E3           ORR      R1,R1,#0x300
   \   000000A4   0400A0E1           MOV      R0,R4
   \   000000A8   0A0000EF           SWI      +10
   \   000000AC   0080A0E1           MOV      R8,R0
   \   000000B0   0A0058E1           CMP      R8,R10
   \   000000B4   0700000A           BEQ      ??LoadConfigData_5
     39              {
     40                if (fwrite(f,cfg,len,&ul)!=len) result=-1;
   \   000000B8   0D30A0E1           MOV      R3,SP
   \   000000BC   0620A0E1           MOV      R2,R6
   \   000000C0   0910A0E1           MOV      R1,R9
   \   000000C4   0C0000EF           SWI      +12
   \   000000C8   060050E1           CMP      R0,R6
   \   000000CC   E9FFFF0A           BEQ      ??LoadConfigData_3
   \   000000D0   0A50A0E1           MOV      R5,R10
     41                fclose(f,&ul);
   \   000000D4   E7FFFFEA           B        ??LoadConfigData_3
     42              }
     43              else
     44                result=-1;
   \                     ??LoadConfigData_5:
   \   000000D8   0A50A0E1           MOV      R5,R10
     45            }
     46            mfree(buf);
   \                     ??LoadConfigData_4:
   \   000000DC   0700A0E1           MOV      R0,R7
   \   000000E0   150000EF           SWI      +21
     47            if (result>=0) successed_config_filename=fname;
   \   000000E4   000055E3           CMP      R5,#+0
   \   000000E8   10009F55           LDRPL    R0,??LoadConfigData_0+0x8  ;; successed_config_filename
   \   000000EC   00408055           STRPL    R4,[R0, #+0]
     48            return(result);
   \   000000F0   0500A0E1           MOV      R0,R5
   \   000000F4   F287BDE8           POP      {R1,R4-R10,PC}   ;; return
   \                     ??LoadConfigData_0:
   \   000000F8   ........           DC32     SFE(CONFIG_C) - SFB(CONFIG_C)
   \   000000FC   ........           DC32     cfghdr0
   \   00000100   ........           DC32     successed_config_filename
     49          }
     50          

   \                                 In segment CODE, align 4, keep-with-next
     51          void InitConfig()
     52          {
     53            if (LoadConfigData("4:\\ZBin\\etc\\KeyExten.bcfg")<0)
   \                     InitConfig:
   \   00000000   18009FE5           LDR      R0,??InitConfig_0  ;; `?<Constant "4:\\\\ZBin\\\\etc\\\\KeyExten....">`
   \   00000004   00402DE9           PUSH     {LR}
   \   00000008   ........           BL       LoadConfigData
   \   0000000C   000050E3           CMP      R0,#+0
   \   00000010   0080BD58           POPPL    {PC}
     54            {
     55              LoadConfigData("0:\\ZBin\\etc\\KeyExten.bcfg");
   \   00000014   08009FE5           LDR      R0,??InitConfig_0+0x4  ;; `?<Constant "0:\\\\ZBin\\\\etc\\\\KeyExten....">`
   \   00000018   ........           BL       LoadConfigData
     56            }
     57          }
   \   0000001C   0080BDE8           POP      {PC}             ;; return
   \                     ??InitConfig_0:
   \   00000020   ........           DC32     `?<Constant "4:\\\\ZBin\\\\etc\\\\KeyExten....">`
   \   00000024   ........           DC32     `?<Constant "0:\\\\ZBin\\\\etc\\\\KeyExten....">`

   \                                 In segment DATA_ID, align 4, align-sorted
   \                     `?<Initializer for successed_config_filename>`:
   \   00000000   ........           DC32 `?<Constant "">`

   \                                 In segment CONFIG_C, align 1

   \                                 In segment DATA_C, align 1, align-sorted
   \                     `?<Constant "">`:
   \   00000000   00                 DC8 ""

   \                                 In segment DATA_C, align 4, align-sorted
   \                     `?<Constant "0:\\\\ZBin\\\\etc\\\\KeyExten....">`:
   \   00000000   303A5C5A4269       DC8 "0:\\ZBin\\etc\\KeyExten.bcfg"
   \              6E5C6574635C
   \              4B6579457874
   \              656E2E626366
   \              6700        
   \   0000001A   0000               DC8 0, 0

   \                                 In segment DATA_C, align 4, align-sorted
   \                     `?<Constant "4:\\\\ZBin\\\\etc\\\\KeyExten....">`:
   \   00000000   343A5C5A4269       DC8 "4:\\ZBin\\etc\\KeyExten.bcfg"
   \              6E5C6574635C
   \              4B6579457874
   \              656E2E626366
   \              6700        
   \   0000001A   0000               DC8 0, 0

   Maximum stack usage in bytes:

     Function       CSTACK
     --------       ------
     InitConfig         4
     LoadConfigData    36


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     successed_config_filename         4
     LoadConfigData                  260
     InitConfig                       40
     ?<Initializer for successed_config_filename>
                                       4
     ?<Constant "">                    1
     ?<Constant "0:\\ZBin\\etc\\KeyExten....">
                                      28
     ?<Constant "4:\\ZBin\\etc\\KeyExten....">
                                      28
      Others                          20

 
 308 bytes in segment CODE
  57 bytes in segment DATA_C
   4 bytes in segment DATA_I
   4 bytes in segment DATA_ID
  12 bytes in segment INITTAB
 
 300 bytes of CODE  memory (+ 20 bytes shared)
  61 bytes of CONST memory
   4 bytes of DATA  memory

Errors: none
Warnings: none
