__iar_data_init2 Procedures

__iar_data_init2在bootloader的main之前被调用

#if __VER__ < 5020000 ;Pre-5.20 table format, fully replaced
    bl      segment_init                        ; intialize the C environment - in bsp.c
#else ;5.20+ table format, can only be reasonbly replaced on table function's level
      ;See ARM\crc\lib\init\data_init2.c and ARM\crc\lib\arm\cmain.s for details
    bl __iar_data_init2 ; this will call init functions

 

Diagram

Region$$Table

__iar_data_init2通过Region$$Table对全局变量区域进行初始化

 

The usage of the fields in Region$$Table 

 

Sequences (pseudo-code)

push {R4, LR}  // Push LR, R4 onto stack 

R1 = 0x20  // Region$$Table$$Base 

R4 = 0x44  // Region$$Table$$Limit 

[R1-R4](0x20-0x44) 是Region$$Table范围

 

R0 = R1 + 4  // Use R0 to walk through Region$$Table

R1 = [R0] + R1 = 0x1b7ef + 0x20 = 0x1b80f = 0x1b80e (aligned)

R0 += 4

(0x1b80e) __iar_zero_init2

清空为初始化Global Variables区域

Clear memory region [0x40001148, 0x40001148+0x1b24-4] 

for (r3 = [R0++] = 0x1b24; r3 != 0; r3 -= 4)

{

  Start address = R2= [R0] = 0x40001148

  [R2] = 0

  R2 += 4

}

 

R1 = [R0] + R1 = 0x1b807 + 0x30 = 0x1b837 = 0x1b836 (aligned)

(0x1b836) __iar_copy_init2

R2 = 0x1b4bc; R2 + R1 = R2 + 0x38 = 0x1b4f4

R3 = 0x40000960

复制已初始化Global Variables区域 

Copy R2 to R3. Memory Region [0x1b4f4, 0x1b4f4+0x318-4] to [0x40000960, 0x40000960+0x318-4]

for (r1 = 0x318; r1 != 0; r1 -= 4)

{

  [R3] = [R2]

  R3 += 4; R2 += 4

}

 

Region$$Table$$Base End. R0 = R4 = 0x44

 

Memory locations in .map

.iar.init_table const 0x00000020 0x24 - Linker created -
.rodata const 0x00000044 0x8 ad_l.o [1]

posted on 2012-04-18 17:56  Feilian  阅读(726)  评论(0编辑  收藏  举报

导航