IAR EWARM __iar_program_start, __iar_data_init3, __iar_copy_init3, __iar_zero_init3

复制代码
#include <stdint.h>

// The type of a pointer into the init table.
typedef void const * table_ptr_t;

// The type of an initialization routine. It takes a pointer to the start of
// its entry (after the function pointer) in the init table and returns a
// pointer to after its entry.
typedef table_ptr_t init_fun_t( table_ptr_t );

typedef struct
{
  int32_t mOff;
} FAddr;

__no_init uint32_t __iar_SB @ r9;

uint32_t const * __iar_zero_init3( uint32_t const * p )
{
  uint32_t size;
  while ( ( size = *p++ ) != 0 )
  {
    uint32_t d = *p++;
    uint32_t * dest;

    if ( d & 1 )
    {
      d -= 1;
      d += __iar_SB;
    }

    dest = (uint32_t*) d;

    do
    {
      *dest++ = 0;
      size -= 4;
    }while ( size != 0 );
  }
  return p;
}

uint32_t const * __iar_copy_init3( uint32_t const * p )
{
  uint32_t size;
  while ( ( size = *p++ ) != 0 )
  {
    uint32_t const * src;
    uint32_t d;
    uint32_t * dest;

    src = (uint32_t *) ( (char const *) p + *(int32_t *) p );
    p++;

    d = *p++;

    if ( d & 1 )
    {
      d -= 1;
      d += __iar_SB;
    }

    dest = (uint32_t *) d;

    do
    {
      *dest++ = *src++;
      size -= 4;
    }while ( size != 0 );
  }
  return p;
}

#pragma section = "Region$$Table"
void __iar_data_init3( void )
{
  FAddr const * pi = __section_begin("Region$$Table");
  table_ptr_t pe = __section_end ("Region$$Table");
  while ( pi != pe )
  {
    init_fun_t * fun = (init_fun_t *) ( (uint32_t) pi + pi->mOff );
    ++pi;
    pi = fun( pi );
  }
}
复制代码
复制代码
Mode_USR  EQU     0x10
Mode_FIQ  EQU     0x11
Mode_IRQ  EQU     0x12
Mode_SVC  EQU     0x13
Mode_ABT  EQU     0x17
Mode_UND  EQU     0x1B
Mode_SYS  EQU     0x1F ; available on ARM Arch 4 and later

I_Bit     EQU     0x80 ; when I bit is set, IRQ is disabled
F_Bit     EQU     0x40 ; when F bit is set, FIQ is disabled

__iar_program_start
          MSR     CPSR_c, #Mode_SYS|F_Bit|I_Bit
          ldr     sp,=SFE(CSTACK)     ; End of CSTACK(user)
          BL      __iar_data_init3
          BL      main
          B       .
复制代码

 

posted @   IAmAProgrammer  阅读(5104)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
历史上的今天:
2013-06-22 ARM JTAG 20
点击右上角即可分享
微信分享提示