##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 EVALUATION    07/Feb/2009  14:43:57 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  interwork                                            #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  D:\pasha\elf\_MY_PROJECT_\naticq_mod2\conf_loader.c  #
#    Command line    =  D:\pasha\elf\_MY_PROJECT_\naticq_mod2\conf_loader.c  #
#                       -D NEWSGOLD -D ELKA -D kluchnik -D BCFG -D ICONBAR   #
#                       --preprocess D:\pasha\elf\_MY_PROJECT_\naticq_mod2\k #
#                       luchnik_iconbar\List\ -lC                            #
#                       D:\pasha\elf\_MY_PROJECT_\naticq_mod2\kluchnik_iconb #
#                       ar\List\ -o D:\pasha\elf\_MY_PROJECT_\naticq_mod2\kl #
#                       uchnik_iconbar\Obj\ -s9 --cpu_mode arm --endian      #
#                       little --cpu ARM926EJ-S --stack_align 4 --interwork  #
#                       -e --fpu None --dlib_config "D:\Embedded Workbench   #
#                       4.0 Evaluation2\ARM\LIB\dl5tpainl8n.h" -I            #
#                       "D:\Embedded Workbench 4.0 Evaluation2\ARM\INC\"     #
#                       --inline_threshold=2                                 #
#    List file       =  D:\pasha\elf\_MY_PROJECT_\naticq_mod2\kluchnik_iconb #
#                       ar\List\conf_loader.lst                              #
#    Object file     =  D:\pasha\elf\_MY_PROJECT_\naticq_mod2\kluchnik_iconb #
#                       ar\Obj\conf_loader.r79                               #
#                                                                            #
#                                                                            #
##############################################################################

D:\pasha\elf\_MY_PROJECT_\naticq_mod2\conf_loader.c
      1          #include "..\inc\swilib.h"
      2          #include "..\inc\cfg_items.h"
      3          #include "conf_loader.h"
      4          
      5          #pragma segment="CONFIG_C"

   \                                 In segment CODE, align 4, keep-with-next
      6          int SaveConfigData(const char *fname)
      7          {
      8            int f;
      9            unsigned int ul;
     10            int result=-1;
     11            unsigned int wlen;
     12            unsigned int len=(char *)__segment_end("CONFIG_C")-(char *)__segment_begin("CONFIG_C");
   \                     SaveConfigData:
   \   00000000   60109FE5           LDR      R1,??SaveConfigData_0  ;; SFE(CONFIG_C)
   \   00000004   F0402DE9           PUSH     {R4-R7,LR}
   \   00000008   5C509FE5           LDR      R5,??SaveConfigData_0+0x4  ;; SFB(CONFIG_C)
   \   0000000C   04D04DE2           SUB      SP,SP,#+4
   \   00000010   0040E0E3           MVN      R4,#+0
   \   00000014   056041E0           SUB      R6,R1,R5
     13          
     14            if ((f=fopen(fname,A_WriteOnly+A_BIN+A_Create+A_Truncate,P_WRITE,&ul))!=-1)
   \   00000018   0D30A0E1           MOV      R3,SP
   \   0000001C   402FA0E3           MOV      R2,#+256
   \   00000020   0110A0E3           MOV      R1,#+1
   \   00000024   831C81E3           ORR      R1,R1,#0x8300
   \   00000028   0A0000EF           SWI      +10
   \   0000002C   0070A0E1           MOV      R7,R0
   \   00000030   010077E3           CMN      R7,#+1
   \   00000034   0900000A           BEQ      ??SaveConfigData_1
     15            {
     16              wlen=fwrite(f,__segment_begin("CONFIG_C"),len,&ul);
   \   00000038   0D30A0E1           MOV      R3,SP
   \   0000003C   0620A0E1           MOV      R2,R6
   \   00000040   0510A0E1           MOV      R1,R5
   \   00000044   0C0000EF           SWI      +12
   \   00000048   0050A0E1           MOV      R5,R0
     17              fclose(f,&ul);
   \   0000004C   0D10A0E1           MOV      R1,SP
   \   00000050   0700A0E1           MOV      R0,R7
   \   00000054   0D0000EF           SWI      +13
     18              if (wlen==len) result=0;
   \   00000058   060055E1           CMP      R5,R6
   \   0000005C   0040A003           MOVEQ    R4,#+0
     19            }
     20            return(result);
   \                     ??SaveConfigData_1:
   \   00000060   0400A0E1           MOV      R0,R4
   \   00000064   F280BDE8           POP      {R1,R4-R7,PC}    ;; return
   \                     ??SaveConfigData_0:
   \   00000068   ........           DC32     SFE(CONFIG_C)
   \   0000006C   ........           DC32     SFB(CONFIG_C)
     21          }
     22          

   \                                 In segment CODE, align 4, keep-with-next
     23          int LoadConfigData(const char *fname, void* cfg,unsigned int len)
     24          {
   \                     LoadConfigData:
   \   00000000   F0402DE9           PUSH     {R4-R7,LR}
   \   00000004   04D04DE2           SUB      SP,SP,#+4
   \   00000008   0140A0E1           MOV      R4,R1
   \   0000000C   0250A0E1           MOV      R5,R2
     25            int f;
     26            unsigned int ul;
     27            int result=-1;
   \   00000010   0060E0E3           MVN      R6,#+0
     28            if ((f=fopen(fname,A_ReadOnly+A_BIN,P_READ,&ul))!=-1)
   \   00000014   0D30A0E1           MOV      R3,SP
   \   00000018   8020A0E3           MOV      R2,#+128
   \   0000001C   801CA0E3           MOV      R1,#+32768
   \   00000020   0A0000EF           SWI      +10
   \   00000024   0070A0E1           MOV      R7,R0
   \   00000028   010077E3           CMN      R7,#+1
   \   0000002C   0C00000A           BEQ      ??LoadConfigData_0
     29            {
     30              if (fread(f,cfg,len,&ul)==len)
   \   00000030   0D30A0E1           MOV      R3,SP
   \   00000034   0520A0E1           MOV      R2,R5
   \   00000038   0410A0E1           MOV      R1,R4
   \   0000003C   0B0000EF           SWI      +11
   \   00000040   050050E1           CMP      R0,R5
   \   00000044   0D10A0E1           MOV      R1,SP
   \   00000048   0700A0E1           MOV      R0,R7
   \   0000004C   0300001A           BNE      ??LoadConfigData_1
     31              {
     32                fclose(f,&ul);
   \   00000050   0D0000EF           SWI      +13
     33                result = 0;
   \   00000054   0060A0E3           MOV      R6,#+0
   \   00000058   0600A0E1           MOV      R0,R6
   \   0000005C   F280BDE8           POP      {R1,R4-R7,PC}
     34              }
     35              else
     36              {
     37                fclose(f,&ul);
   \                     ??LoadConfigData_1:
   \   00000060   0D0000EF           SWI      +13
     38              }
     39            }
     40            return(result);
   \                     ??LoadConfigData_0:
   \   00000064   0600A0E1           MOV      R0,R6
   \   00000068   F280BDE8           POP      {R1,R4-R7,PC}    ;; return
     41          }
     42          
     43          

   \                                 In segment DATA_I, align 4, align-sorted
     44          char *config_path=":\\zbin\\etc";
   \                     config_path:
   \   00000000                      DS8 4
   \   00000004                      REQUIRE `?<Initializer for config_path>`

   \                                 In segment CODE, align 4, keep-with-next
     45          int InitConfig(void* cfgstruct, int len, char *name,int disk)
     46          {
   \                     InitConfig:
   \   00000000   30402DE9           PUSH     {R4,R5,LR}
   \   00000004   80D04DE2           SUB      SP,SP,#+128
     47            int result;
     48            char config_name[128];
     49            sprintf(config_name, "%d%s\\%s.bcfg", disk, config_path,name);
   \   00000008   04002DE9           PUSH     {R2}
   \   0000000C   0150A0E1           MOV      R5,R1
   \   00000010   30109FE5           LDR      R1,??InitConfig_0  ;; config_path
   \   00000014   0040A0E1           MOV      R4,R0
   \   00000018   0300A0E1           MOV      R0,R3
   \   0000001C   003091E5           LDR      R3,[R1, #+0]
   \   00000020   24109FE5           LDR      R1,??InitConfig_0+0x4  ;; `?<Constant "%d%s\\\\%s.bcfg">`
   \   00000024   0020A0E1           MOV      R2,R0
   \   00000028   04008DE2           ADD      R0,SP,#+4
   \   0000002C   160000EF           SWI      +22
     50            result = LoadConfigData(config_name,  cfgstruct, len);
     51            return result;
   \   00000030   0520A0E1           MOV      R2,R5
   \   00000034   0410A0E1           MOV      R1,R4
   \   00000038   04008DE2           ADD      R0,SP,#+4
   \   0000003C   ........           BL       LoadConfigData
   \   00000040   84D08DE2           ADD      SP,SP,#+132
   \   00000044   3080BDE8           POP      {R4,R5,PC}       ;; return
   \                     ??InitConfig_0:
   \   00000048   ........           DC32     config_path
   \   0000004C   ........           DC32     `?<Constant "%d%s\\\\%s.bcfg">`
     52          }
     53          

   \                                 In segment DATA_I, align 4, align-sorted
     54          const char *suc_config_name_mod="";
   \                     suc_config_name_mod:
   \   00000000                      DS8 4
   \   00000004                      REQUIRE `?<Initializer for suc_config_name_mod>`
     55          
     56          #pragma segment="CONFIG_C"

   \                                 In segment CODE, align 4, keep-with-next
     57          int LoadConfigData2(const char *fname)
     58          {
   \                     LoadConfigData2:
   \   00000000   F14F2DE9           PUSH     {R0,R4-R11,LR}
     59            int f;
     60            unsigned int ul;
     61            char *buf;
     62            int result=0;
     63            void *cfg;
     64            unsigned int rlen, end;
     65          
     66            extern const CFG_HDR cfghdr0; //first var in CONFIG
     67            cfg=(void*)&cfghdr0;
     68          
     69            unsigned int len=(int)__segment_end("CONFIG_C")-(int)__segment_begin("CONFIG_C");
   \   00000004   14519FE5           LDR      R5,??LoadConfigData2_0  ;; SFE(CONFIG_C) - SFB(CONFIG_C)
   \   00000008   04D04DE2           SUB      SP,SP,#+4
   \   0000000C   0040A0E3           MOV      R4,#+0
     70          
     71            if (!(buf=malloc(len))) return -1;
   \   00000010   0500A0E1           MOV      R0,R5
   \   00000014   140000EF           SWI      +20
   \   00000018   0060B0E1           MOVS     R6,R0
   \   0000001C   0400E001           MVNEQ    R0,R4
   \   00000020   F68FBD08           POPEQ    {R1,R2,R4-R11,PC}
     72            if ((f=fopen(fname,A_ReadOnly+A_BIN,P_READ,&ul))!=-1)
   \   00000024   04009DE5           LDR      R0,[SP, #+4]
   \   00000028   F4709FE5           LDR      R7,??LoadConfigData2_0+0x4  ;; cfghdr0
   \   0000002C   0D30A0E1           MOV      R3,SP
   \   00000030   8020A0E3           MOV      R2,#+128
   \   00000034   801CA0E3           MOV      R1,#+32768
   \   00000038   0A0000EF           SWI      +10
   \   0000003C   00A0A0E1           MOV      R10,R0
   \   00000040   0480E0E1           MVN      R8,R4
   \   00000044   08005AE1           CMP      R10,R8
   \   00000048   1800000A           BEQ      ??LoadConfigData2_1
     73            {
     74              rlen=fread(f,buf,len,&ul);
   \   0000004C   0D30A0E1           MOV      R3,SP
   \   00000050   0520A0E1           MOV      R2,R5
   \   00000054   0610A0E1           MOV      R1,R6
   \   00000058   0B0000EF           SWI      +11
   \   0000005C   0090A0E1           MOV      R9,R0
     75              end=lseek(f,0,S_END,&ul,&ul);
   \   00000060   0D00A0E1           MOV      R0,SP
   \   00000064   01002DE9           PUSH     {R0}
   \   00000068   04308DE2           ADD      R3,SP,#+4
   \   0000006C   0220A0E3           MOV      R2,#+2
   \   00000070   0010A0E3           MOV      R1,#+0
   \   00000074   0A00A0E1           MOV      R0,R10
   \   00000078   0F0000EF           SWI      +15
   \   0000007C   00B0A0E1           MOV      R11,R0
     76              fclose(f,&ul);
   \   00000080   04108DE2           ADD      R1,SP,#+4
   \   00000084   0A00A0E1           MOV      R0,R10
   \   00000088   0D0000EF           SWI      +13
     77              if (rlen!=end || rlen!=len)  goto L_SAVENEWCFG;
   \   0000008C   0B0059E1           CMP      R9,R11
   \   00000090   04D08DE2           ADD      SP,SP,#+4
   \   00000094   05005901           CMPEQ    R9,R5
   \   00000098   0400001A           BNE      ??LoadConfigData2_1
     78              memcpy(cfg,buf,len);
   \   0000009C   0520A0E1           MOV      R2,R5
   \   000000A0   0610A0E1           MOV      R1,R6
   \   000000A4   0700A0E1           MOV      R0,R7
   \   000000A8   1E0100EF           SWI      +286
   \   000000AC   130000EA           B        ??LoadConfigData2_2
     79            }
     80            else
     81            {
     82            L_SAVENEWCFG:
     83              if ((f=fopen(fname,A_ReadWrite+A_Create+A_Truncate,P_READ+P_WRITE,&ul))!=-1)
   \                     ??LoadConfigData2_1:
   \   000000B0   04009DE5           LDR      R0,[SP, #+4]
   \   000000B4   0D30A0E1           MOV      R3,SP
   \   000000B8   602FA0E3           MOV      R2,#+384
   \   000000BC   0210A0E3           MOV      R1,#+2
   \   000000C0   C01F81E3           ORR      R1,R1,#0x300
   \   000000C4   0A0000EF           SWI      +10
   \   000000C8   00A0A0E1           MOV      R10,R0
   \   000000CC   08005AE1           CMP      R10,R8
   \   000000D0   0900000A           BEQ      ??LoadConfigData2_3
     84              {
     85                if (fwrite(f,cfg,len,&ul)!=len) result=-1;
   \   000000D4   0D30A0E1           MOV      R3,SP
   \   000000D8   0520A0E1           MOV      R2,R5
   \   000000DC   0710A0E1           MOV      R1,R7
   \   000000E0   0C0000EF           SWI      +12
   \   000000E4   050050E1           CMP      R0,R5
   \   000000E8   0840A011           MOVNE    R4,R8
     86                fclose(f,&ul);
   \   000000EC   0D10A0E1           MOV      R1,SP
   \   000000F0   0A00A0E1           MOV      R0,R10
   \   000000F4   0D0000EF           SWI      +13
   \   000000F8   000000EA           B        ??LoadConfigData2_2
     87              }
     88              else
     89                result=-1;
   \                     ??LoadConfigData2_3:
   \   000000FC   0840A0E1           MOV      R4,R8
     90            }
     91            mfree(buf);
   \                     ??LoadConfigData2_2:
   \   00000100   0600A0E1           MOV      R0,R6
   \   00000104   150000EF           SWI      +21
     92            if (result>=0) suc_config_name_mod=fname;
   \   00000108   000054E3           CMP      R4,#+0
   \   0000010C   14009F55           LDRPL    R0,??LoadConfigData2_0+0x8  ;; suc_config_name_mod
   \   00000110   04109D55           LDRPL    R1,[SP, #+4]
   \   00000114   00108055           STRPL    R1,[R0, #+0]
     93            return(result);
   \   00000118   0400A0E1           MOV      R0,R4
   \   0000011C   F68FBDE8           POP      {R1,R2,R4-R11,PC}  ;; return
   \                     ??LoadConfigData2_0:
   \   00000120   ........           DC32     SFE(CONFIG_C) - SFB(CONFIG_C)
   \   00000124   ........           DC32     cfghdr0
   \   00000128   ........           DC32     suc_config_name_mod
     94          }
     95          

   \                                 In segment CODE, align 4, keep-with-next
     96          void InitConfig2()
     97          {
   \                     InitConfig2:
   \   00000000   10402DE9           PUSH     {R4,LR}
     98            if (LoadConfigData2("4:\\ZBin\\etc\\NATICQMod.bcfg")<0)
   \   00000004   18409FE5           LDR      R4,??InitConfig2_0  ;; `?<Constant "0:\\\\ZBin\\\\etc\\\\NATICQMod...">`
   \   00000008   1C0084E2           ADD      R0,R4,#+28
   \   0000000C   ........           BL       LoadConfigData2
   \   00000010   000050E3           CMP      R0,#+0
   \   00000014   1080BD58           POPPL    {R4,PC}
     99            {
    100              LoadConfigData2("0:\\ZBin\\etc\\NATICQMod.bcfg");
   \   00000018   0400A0E1           MOV      R0,R4
   \   0000001C   ........           BL       LoadConfigData2
    101            }
    102          }
   \   00000020   1080BDE8           POP      {R4,PC}          ;; return
   \                     ??InitConfig2_0:
   \   00000024   ........           DC32     `?<Constant "0:\\\\ZBin\\\\etc\\\\NATICQMod...">`

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

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

   \                                 In segment CONFIG_C, align 1

   \                                 In segment DATA_C, align 4, align-sorted
   \                     `?<Constant ":\\\\zbin\\\\etc">`:
   \   00000000   3A5C7A62696E       DC8 ":\\zbin\\etc"
   \              5C65746300  
   \   0000000B   00                 DC8 0

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

   \                                 In segment DATA_C, align 4, align-sorted
   \                     `?<Constant "%d%s\\\\%s.bcfg">`:
   \   00000000   256425735C25       DC8 "%d%s\\%s.bcfg"
   \              732E62636667
   \              00          
   \   0000000D   000000             DC8 0, 0, 0

   \                                 In segment DATA_C, align 4, align-sorted
   \                     `?<Constant "0:\\\\ZBin\\\\etc\\\\NATICQMod...">`:
   \   00000000   303A5C5A4269       DC8 "0:\\ZBin\\etc\\NATICQMod.bcfg"
   \              6E5C6574635C
   \              4E4154494351
   \              4D6F642E6263
   \              666700      
   \   0000001B   00                 DC8 0
   \   0000001C   343A5C5A4269       DC8 "4:\\ZBin\\etc\\NATICQMod.bcfg"
   \              6E5C6574635C
   \              4E4154494351
   \              4D6F642E6263
   \              666700      
   \   00000037   00                 DC8 0

   Maximum stack usage in bytes:

     Function        CSTACK
     --------        ------
     InitConfig        144
     InitConfig2         8
     LoadConfigData     24
     LoadConfigData2    48
     SaveConfigData     24


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     SaveConfigData                  112
     LoadConfigData                  108
     config_path                       4
     InitConfig                       80
     suc_config_name_mod               4
     LoadConfigData2                 300
     InitConfig2                      40
     ?<Initializer for config_path>    4
     ?<Initializer for suc_config_name_mod>
                                       4
     ?<Constant ":\\zbin\\etc">       12
     ?<Constant "">                    1
     ?<Constant "%d%s\\%s.bcfg">      16
     ?<Constant "0:\\ZBin\\etc\\NATICQMod...">
                                      56
      Others                          32

 
 660 bytes in segment CODE
  85 bytes in segment DATA_C
   8 bytes in segment DATA_I
   8 bytes in segment DATA_ID
  12 bytes in segment INITTAB
 
 640 bytes of CODE  memory (+ 32 bytes shared)
  93 bytes of CONST memory
   8 bytes of DATA  memory

Errors: none
Warnings: none
