2025-05-21 11:31:07 +08:00

56 lines
1.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************
Copyright @2024 - 2044 Shenzhen dcenzix Technology Ltd.
******************************************************************************
@file cola_init.h
@brief 各个需要自动初始化的函数放到指定的段中,形成一张初始化函数表
@author xiexiongwu
@version V1.0
@date 2024年5月25日
******************************************************************************/
#ifndef __COLA_INIT_H__
#define __COLA_INIT_H__
/*----------------------------------------------*
* 宏定义 *
*----------------------------------------------*/
/* 修改后的宏定义适配GCC */
#define __used __attribute__((used)) // 简化属性语法
typedef void (*initcall_t)(void);
/* 重新定义段命名规则 */
#define __define_initcall(fn, level) \
static const initcall_t __initcall_##fn##level __used \
__attribute__((__section__(".initcall" #level ".init"))) = fn;
#define sysclk_initcall(fn) __define_initcall(fn, 0)
#define register_initcall(fn) __define_initcall(fn, 1)
#define bsp_initcall(fn) __define_initcall(fn, 2)
#define device_initcall(fn) __define_initcall(fn, 3)
#define app_initcall(fn) __define_initcall(fn, 4)
/*----------------------------------------------*
* 函数原型说明 *
*----------------------------------------------*/
#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */
extern void do_init_call(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* __COLA_INIT_H__ */