##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.41A/W32 EVALUATION    23/Jan/2008  00:02:36 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  interwork                                            #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  D:\Pasha\elf\idater\conf_loader.c                    #
#    Command line    =  D:\Pasha\elf\idater\conf_loader.c -lC                #
#                       D:\Pasha\elf\idater\Release_SGOLD\List\ -o           #
#                       D:\Pasha\elf\idater\Release_SGOLD\Obj\ -s9           #
#                       --cpu_mode arm --endian little --cpu ARM926EJ-S      #
#                       --stack_align 4 --interwork -e --fpu None            #
#                       --dlib_config "D:\Pasha\ARM_Embedded_Workbench\Embed #
#                       ded Workbench 4.0 Evaluation\ARM\LIB\dl5tpainl8n.h"  #
#                       -I "D:\Pasha\ARM_Embedded_Workbench\Embedded         #
#                       Workbench 4.0 Evaluation\ARM\INC\"                   #
#                       --inline_threshold=2                                 #
#    List file       =  D:\Pasha\elf\idater\Release_SGOLD\List\conf_loader.l #
#                       st                                                   #
#    Object file     =  D:\Pasha\elf\idater\Release_SGOLD\Obj\conf_loader.r7 #
#                       9                                                    #
#                                                                            #
#                                                                            #
##############################################################################

D:\Pasha\elf\idater\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   F14F2DE9           PUSH     {R0,R4-R11,LR}
     10            int f;
     11            unsigned int ul;
     12            char *buf;
     13            int result=0;
     14            void *cfg;
     15            unsigned int rlen, end;
     16          
     17            extern const CFG_HDR cfghdr0; //first var in CONFIG
     18            cfg=(void*)&cfghdr0;
     19          
     20            unsigned int len=(int)__segment_end("CONFIG_C")-(int)__segment_begin("CONFIG_C");
   \   00000004   14519FE5           LDR      R5,??LoadConfigData_0  ;; SFE(CONFIG_C) - SFB(CONFIG_C)
   \   00000008   04D04DE2           SUB      SP,SP,#+4
   \   0000000C   0040A0E3           MOV      R4,#+0
     21          
     22            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}
     23            if ((f=fopen(fname,A_ReadOnly+A_BIN,P_READ,&ul))!=-1)
   \   00000024   04009DE5           LDR      R0,[SP, #+4]
   \   00000028   F4709FE5           LDR      R7,??LoadConfigData_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      ??LoadConfigData_1
     24            {
     25              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
     26              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
     27              fclose(f,&ul);
   \   00000080   04108DE2           ADD      R1,SP,#+4
   \   00000084   0A00A0E1           MOV      R0,R10
   \   00000088   0D0000EF           SWI      +13
     28              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      ??LoadConfigData_1
     29              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        ??LoadConfigData_2
     30            }
     31            else
     32            {
     33            L_SAVENEWCFG:
     34              if ((f=fopen(fname,A_ReadWrite+A_Create+A_Truncate,P_READ+P_WRITE,&ul))!=-1)
   \                     ??LoadConfigData_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      ??LoadConfigData_3
     35              {
     36                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
     37                fclose(f,&ul);
   \   000000EC   0D10A0E1           MOV      R1,SP
   \   000000F0   0A00A0E1           MOV      R0,R10
   \   000000F4   0D0000EF           SWI      +13
   \   000000F8   000000EA           B        ??LoadConfigData_2
     38              }
     39              else
     40                result=-1;
   \                     ??LoadConfigData_3:
   \   000000FC   0840A0E1           MOV      R4,R8
     41            }
     42            mfree(buf);
   \                     ??LoadConfigData_2:
   \   00000100   0600A0E1           MOV      R0,R6
   \   00000104   150000EF           SWI      +21
     43            if (result>=0) successed_config_filename=fname;
   \   00000108   000054E3           CMP      R4,#+0
   \   0000010C   14009F55           LDRPL    R0,??LoadConfigData_0+0x8  ;; successed_config_filename
   \   00000110   04109D55           LDRPL    R1,[SP, #+4]
   \   00000114   00108055           STRPL    R1,[R0, #+0]
     44            return(result);
   \   00000118   0400A0E1           MOV      R0,R4
   \   0000011C   F68FBDE8           POP      {R1,R2,R4-R11,PC}  ;; return
   \                     ??LoadConfigData_0:
   \   00000120   ........           DC32     SFE(CONFIG_C) - SFB(CONFIG_C)
   \   00000124   ........           DC32     cfghdr0
   \   00000128   ........           DC32     successed_config_filename
     45          }
     46          

   \                                 In segment CODE, align 4, keep-with-next
     47          void InitConfig()
     48          {
   \                     InitConfig:
   \   00000000   10402DE9           PUSH     {R4,LR}
     49            if (LoadConfigData("4:\\ZBin\\etc\\iDater.bcfg")<0)
   \   00000004   18409FE5           LDR      R4,??InitConfig_0  ;; `?<Constant "0:\\\\ZBin\\\\etc\\\\iDater.bcfg">`
   \   00000008   180084E2           ADD      R0,R4,#+24
   \   0000000C   ........           BL       LoadConfigData
   \   00000010   000050E3           CMP      R0,#+0
   \   00000014   1080BD58           POPPL    {R4,PC}
     50            {
     51              LoadConfigData("0:\\ZBin\\etc\\iDater.bcfg");
   \   00000018   0400A0E1           MOV      R0,R4
   \   0000001C   ........           BL       LoadConfigData
     52            }
     53          }
   \   00000020   1080BDE8           POP      {R4,PC}          ;; return
   \                     ??InitConfig_0:
   \   00000024   ........           DC32     `?<Constant "0:\\\\ZBin\\\\etc\\\\iDater.bcfg">`

   \                                 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\\\\iDater.bcfg">`:
   \   00000000   303A5C5A4269       DC8 "0:\\ZBin\\etc\\iDater.bcfg"
   \              6E5C6574635C
   \              694461746572
   \              2E6263666700
   \   00000018   343A5C5A4269       DC8 "4:\\ZBin\\etc\\iDater.bcfg"
   \              6E5C6574635C
   \              694461746572
   \              2E6263666700

   Maximum stack usage in bytes:

     Function       CSTACK
     --------       ------
     InitConfig         8
     LoadConfigData    48


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     successed_config_filename         4
     LoadConfigData                  300
     InitConfig                       40
     ?<Initializer for successed_config_filename>
                                       4
     ?<Constant "">                    1
     ?<Constant "0:\\ZBin\\etc\\iDater.bcfg">
                                      48
      Others                          20

 
 348 bytes in segment CODE
  49 bytes in segment DATA_C
   4 bytes in segment DATA_I
   4 bytes in segment DATA_ID
  12 bytes in segment INITTAB
 
 340 bytes of CODE  memory (+ 20 bytes shared)
  53 bytes of CONST memory
   4 bytes of DATA  memory

Errors: none
Warnings: none
