diff options
author | Herve Codina <Herve.CODINA@celad.com> | 2015-07-06 09:36:43 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-07-13 08:28:19 +0200 |
commit | a2136e6cbd732e627f9f33d9211ba0a67be52889 (patch) | |
tree | c1aff563dc89e01ed4a801ec7045b19e00041de5 /include/init.h | |
parent | d46b6785c4bcd3ceb7d90895e9f44a7bf7d6757d (diff) | |
download | barebox-a2136e6cbd732e627f9f33d9211ba0a67be52889.tar.gz barebox-a2136e6cbd732e627f9f33d9211ba0a67be52889.tar.xz |
exitcall: Add exitcall infrastructure
exitcall infrastructure is based on initcall infrastructure.
It allows to have and use exit call hooks on barebox shutdown.
Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/init.h')
-rw-r--r-- | include/init.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/init.h b/include/init.h index f619c951d3..527d49afec 100644 --- a/include/init.h +++ b/include/init.h @@ -7,17 +7,24 @@ #define __init #define __initdata #define __initconst +#define __exit +#define __exitdata /* For assembly routines */ #define __BARE_INIT .section ".text_bare_init.text","ax" #ifndef __ASSEMBLY__ typedef int (*initcall_t)(void); +typedef void (*exitcall_t)(void); #define __define_initcall(level,fn,id) \ static initcall_t __initcall_##fn##id __attribute__((__used__)) \ __attribute__((__section__(".initcall." level))) = fn +#define __define_exitcall(level,fn,id) \ + static exitcall_t __exitcall_##fn##id __attribute__((__used__)) \ + __attribute__((__section__(".exitcall." level))) = fn + /* * A "pure" initcall has no dependencies on anything else, and purely @@ -42,6 +49,14 @@ typedef int (*initcall_t)(void); #define environment_initcall(fn) __define_initcall("13",fn,13) #define postenvironment_initcall(fn) __define_initcall("14",fn,14) +#define early_exitcall(fn) __define_exitcall("0",fn,0) +#define predevshutdown_exitcall(fn) __define_exitcall("1",fn,1) +#define devshutdown_exitcall(fn) __define_exitcall("2",fn,2) +#define postdevshutdown_exitcall(fn) __define_exitcall("3",fn,3) +#define prearchshutdown_exitcall(fn) __define_exitcall("4",fn,4) +#define archshutdown_exitcall(fn) __define_exitcall("5",fn,5) +#define postarchshutdown_exitcall(fn) __define_exitcall("6",fn,6) + /* section for code used very early when * - we're not running from where we linked at * - bss not cleared |