#define DEFINE_SECTION_INIT (a) [a] = {\
. start= (void *) &__start_module_# #a # #_init, \
. stop= (void *) &__stop_module_# #a # #_init \
}
#define DEFINE_SECTION_EXIT (a) [a] = {\
. start= (void *) &__start_module_# #a # #_exit, \
. stop= (void *) &__stop_module_# #a # #_exit \
}
struct tsection
{
void (**start) (void);
void (**stop) (void);
} ;
static struct tsection module_init_sections[] =
{
Define_section_init (0), Define_section_init (1), Define_section_init (2),
Define_section_init (3), Define_section_init (4), Define_section_init (5),
Define_section_init (6), Define_section_init (7), Define_section_init (8),
Define_section_init (9),
};
static struct tsection module_exit_sections[] =
{
Define_section_exit (0), Define_section_exit (1), Define_section_exit (2),
Define_section_exit (3), Define_section_exit (4), Define_section_exit (5),
Define_section_exit (6), Define_section_exit (7), Define_section_exit (8),
Define_section_exit (9),
};
/**
* Initial All modules
*/
void Moduleinitall (void)
{
uint32_t i;
for (i = 0; I<array_size (module_init_sections); i++)
{
void (**iter) (void) =module_init_sections[i].start;
for (; iter<module_init_sections[i].stop;iter++)
{
(* ITER) ();
}
}
}
/**
* uninitialize All modules
*/
void Moduledeinitall (void)
{
int32_t i;
printf ("Exit in progress\n");
for (i = array_size (module_exit_sections)-1; I >= 0; i--)
{
void (**iter) (void) =module_exit_sections[i].start;
for (; iter<module_exit_sections[i].stop;iter++)
{
(* ITER) ();
}
}
printf ("Exit in Progress done\n");
}