1 /*
2  * Copyright (c) 2022 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef H_MCUMGR_MGMT_HANDLERS_
8 #define H_MCUMGR_MGMT_HANDLERS_
9 
10 #include <zephyr/kernel.h>
11 #include <zephyr/sys/util_macro.h>
12 #include <zephyr/sys/iterable_sections.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif /* __cplusplus */
17 
18 /**
19  * @brief MCUmgr handler registration API
20  * @defgroup mcumgr_handler_api MCUmgr handler API
21  * @ingroup mcumgr
22  * @{
23  */
24 
25 /** Type definition for a MCUmgr handler initialisation function */
26 typedef void (*mcumgr_handler_init_t)(void);
27 
28 /** @cond INTERNAL_HIDDEN */
29 struct mcumgr_handler {
30 	/** Initialisation function to be called */
31 	const mcumgr_handler_init_t init;
32 };
33 /** @endcond  */
34 
35 /**
36  * @brief Define a MCUmgr handler to register.
37  *
38  * This adds a new entry to the iterable section linker list of MCUmgr handers.
39  *
40  * @param name	Name of the MCUmgr handler to registger.
41  * @param _init	Init function to be called (mcumgr_handler_init_t).
42  */
43 #define MCUMGR_HANDLER_DEFINE(name, _init)			\
44 	STRUCT_SECTION_ITERABLE(mcumgr_handler, name) = {	\
45 		.init = _init,					\
46 	}
47 
48 #ifdef __cplusplus
49 }
50 #endif /* __cplusplus */
51 
52 /**
53  * @}
54  */
55 
56 #endif /* H_MCUMGR_MGMT_HANDLERS_ */
57