xref: /btstack/src/btstack_memory.h (revision b8c00949e59d3e3d5ea4008e93c597bf7f602800)
1a3b02b71Smatthias.ringwald /*
2a0c35809S[email protected]  * Copyright (C) 2014 BlueKitchen GmbH
3a3b02b71Smatthias.ringwald  *
4a3b02b71Smatthias.ringwald  * Redistribution and use in source and binary forms, with or without
5a3b02b71Smatthias.ringwald  * modification, are permitted provided that the following conditions
6a3b02b71Smatthias.ringwald  * are met:
7a3b02b71Smatthias.ringwald  *
8a3b02b71Smatthias.ringwald  * 1. Redistributions of source code must retain the above copyright
9a3b02b71Smatthias.ringwald  *    notice, this list of conditions and the following disclaimer.
10a3b02b71Smatthias.ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11a3b02b71Smatthias.ringwald  *    notice, this list of conditions and the following disclaimer in the
12a3b02b71Smatthias.ringwald  *    documentation and/or other materials provided with the distribution.
13a3b02b71Smatthias.ringwald  * 3. Neither the name of the copyright holders nor the names of
14a3b02b71Smatthias.ringwald  *    contributors may be used to endorse or promote products derived
15a3b02b71Smatthias.ringwald  *    from this software without specific prior written permission.
166b64433eSmatthias.ringwald  * 4. Any redistribution, use, or modification is done solely for
176b64433eSmatthias.ringwald  *    personal benefit and not for any commercial purpose or for
186b64433eSmatthias.ringwald  *    monetary gain.
19a3b02b71Smatthias.ringwald  *
202e97c149S[email protected]  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21a3b02b71Smatthias.ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22a3b02b71Smatthias.ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
232fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25a3b02b71Smatthias.ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26a3b02b71Smatthias.ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27a3b02b71Smatthias.ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28a3b02b71Smatthias.ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29a3b02b71Smatthias.ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30a3b02b71Smatthias.ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31a3b02b71Smatthias.ringwald  * SUCH DAMAGE.
32a3b02b71Smatthias.ringwald  *
332e97c149S[email protected]  * Please inquire about commercial licensing options at
342e97c149S[email protected]  * [email protected]
356b64433eSmatthias.ringwald  *
36a3b02b71Smatthias.ringwald  */
37a3b02b71Smatthias.ringwald 
38b45b7749SMilanka Ringwald 
39b45b7749SMilanka Ringwald 
40b45b7749SMilanka Ringwald /*
41b45b7749SMilanka Ringwald  * btstack_memory.h
42a3b02b71Smatthias.ringwald  *
43b45b7749SMilanka Ringwald  * @brief BTstack memory management using configurable memory pools
44a3b02b71Smatthias.ringwald  *
45a3b02b71Smatthias.ringwald  */
46a3b02b71Smatthias.ringwald 
4780e33422SMatthias Ringwald #ifndef BTSTACK_MEMORY_H
4880e33422SMatthias Ringwald #define BTSTACK_MEMORY_H
49a3b02b71Smatthias.ringwald 
50bc64ca62S[email protected] #if defined __cplusplus
51bc64ca62S[email protected] extern "C" {
52bc64ca62S[email protected] #endif
53bc64ca62S[email protected] 
547907f069SMatthias Ringwald #include "btstack_config.h"
55d0fdae3cS[email protected] 
563edc84c5SMatthias Ringwald // Core
576527a633S[email protected] #include "hci.h"
586527a633S[email protected] #include "l2cap.h"
596527a633S[email protected] 
603edc84c5SMatthias Ringwald // Classic
61ef83f5c4SMatthias Ringwald #ifdef ENABLE_CLASSIC
628ef7100fSMilanka Ringwald #include "classic/avdtp_sink.h"
638ef7100fSMilanka Ringwald #include "classic/avdtp_source.h"
64be32e7f1SMilanka Ringwald #include "classic/avrcp.h"
65f399f7fbSMilanka Ringwald #include "classic/bnep.h"
66f399f7fbSMilanka Ringwald #include "classic/btstack_link_key_db.h"
67f399f7fbSMilanka Ringwald #include "classic/btstack_link_key_db_memory.h"
68*b8c00949SMatthias Ringwald #include "classic/goep_server.h"
69f399f7fbSMilanka Ringwald #include "classic/hfp.h"
70f399f7fbSMilanka Ringwald #include "classic/hid_host.h"
71f399f7fbSMilanka Ringwald #include "classic/rfcomm.h"
72f399f7fbSMilanka Ringwald #include "classic/sdp_server.h"
73ef83f5c4SMatthias Ringwald #endif
743edc84c5SMatthias Ringwald 
753edc84c5SMatthias Ringwald // BLE
76a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE
776bdecec7SMatthias Ringwald #include "ble/gatt-service/battery_service_client.h"
78cf26c8fbSMilanka Ringwald #include "ble/gatt-service/hids_client.h"
7978ae886bSMilanka Ringwald #include "ble/gatt-service/scan_parameters_service_client.h"
80cf26c8fbSMilanka Ringwald #include "ble/gatt_client.h"
81cf26c8fbSMilanka Ringwald #include "ble/sm.h"
8244c5d856SMatthias Ringwald #endif
8344c5d856SMatthias Ringwald 
8444c5d856SMatthias Ringwald #ifdef ENABLE_MESH
8577ba3d3fSMatthias Ringwald #include "mesh/mesh_network.h"
86a5a7b6daSMatthias Ringwald #include "mesh/mesh_keys.h"
87a5a7b6daSMatthias Ringwald #include "mesh/mesh_virtual_addresses.h"
88d0fdae3cS[email protected] #endif
89d0fdae3cS[email protected] 
90f8088037SMilanka Ringwald /* API_START */
91f8088037SMilanka Ringwald 
92f8088037SMilanka Ringwald /**
93f8088037SMilanka Ringwald  * @brief Initializes BTstack memory pools.
94f8088037SMilanka Ringwald  */
95a3b02b71Smatthias.ringwald void btstack_memory_init(void);
96a3b02b71Smatthias.ringwald 
97b6269742SMatthias Ringwald /**
98b6269742SMatthias Ringwald  * @brief Deinitialize BTstack memory pools
99b6269742SMatthias Ringwald  * @note if HAVE_MALLOC is defined, all previously allocated buffers are free'd
100b6269742SMatthias Ringwald  */
101b6269742SMatthias Ringwald void btstack_memory_deinit(void);
102b6269742SMatthias Ringwald 
103f8088037SMilanka Ringwald /* API_END */
104f8088037SMilanka Ringwald 
1052e97c149S[email protected] // hci_connection
1066527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void);
1076527a633S[email protected] void   btstack_memory_hci_connection_free(hci_connection_t *hci_connection);
108fdb398c2S[email protected] 
1092e97c149S[email protected] // l2cap_service, l2cap_channel
1106527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void);
1116527a633S[email protected] void   btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service);
1126527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void);
1136527a633S[email protected] void   btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel);
114fdb398c2S[email protected] 
11544c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC
1162e97c149S[email protected] // rfcomm_multiplexer, rfcomm_service, rfcomm_channel
1176527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void);
1186527a633S[email protected] void   btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer);
1196527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void);
1206527a633S[email protected] void   btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service);
1216527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void);
1226527a633S[email protected] void   btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel);
123fdb398c2S[email protected] 
1242c455dadSMatthias Ringwald // btstack_link_key_db_memory_entry
1252c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void);
1262c455dadSMatthias Ringwald void   btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry);
127bc64ca62S[email protected] 
1282e97c149S[email protected] // bnep_service, bnep_channel
1292e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void);
1302e97c149S[email protected] void   btstack_memory_bnep_service_free(bnep_service_t *bnep_service);
1312e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void);
1322e97c149S[email protected] void   btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel);
1332e97c149S[email protected] 
134*b8c00949SMatthias Ringwald // goep_server_service, goep_server_connection
135*b8c00949SMatthias Ringwald goep_server_service_t * btstack_memory_goep_server_service_get(void);
136*b8c00949SMatthias Ringwald void   btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service);
137*b8c00949SMatthias Ringwald goep_server_connection_t * btstack_memory_goep_server_connection_get(void);
138*b8c00949SMatthias Ringwald void   btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection);
139*b8c00949SMatthias Ringwald 
140ea5029c9SMilanka Ringwald // hfp_connection
141ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void);
142ea5029c9SMilanka Ringwald void   btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection);
143ea5029c9SMilanka Ringwald 
144f399f7fbSMilanka Ringwald // hid_host_connection
145f399f7fbSMilanka Ringwald hid_host_connection_t * btstack_memory_hid_host_connection_get(void);
146f399f7fbSMilanka Ringwald void   btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection);
147f399f7fbSMilanka Ringwald 
1480e826a17SMilanka Ringwald // avdtp_stream_endpoint
1490e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void);
1500e826a17SMilanka Ringwald void   btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint);
15127faf85aSMilanka Ringwald 
15212e7f38cSMilanka Ringwald // avdtp_connection
15312e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void);
15412e7f38cSMilanka Ringwald void   btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection);
15512e7f38cSMilanka Ringwald 
15691451a2bSMilanka Ringwald // avrcp_connection
15791451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void);
15891451a2bSMilanka Ringwald void   btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection);
15991451a2bSMilanka Ringwald 
160f12a3722SMilanka Ringwald // avrcp_browsing_connection
161f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void);
162f12a3722SMilanka Ringwald void   btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection);
163f12a3722SMilanka Ringwald 
164*b8c00949SMatthias Ringwald // service_record_item
165*b8c00949SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void);
166*b8c00949SMatthias Ringwald void   btstack_memory_service_record_item_free(service_record_item_t *service_record_item);
167*b8c00949SMatthias Ringwald 
16844c5d856SMatthias Ringwald #endif
169a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE
170dbca66ffSMatthias Ringwald // battery_service_client, gatt_client, hids_client, scan_parameters_service_client, sm_lookup_entry, whitelist_entry, periodic_advertiser_list_entry
171174a0c1cSMilanka Ringwald battery_service_client_t * btstack_memory_battery_service_client_get(void);
172174a0c1cSMilanka Ringwald void   btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client);
173d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void);
174d0fdae3cS[email protected] void   btstack_memory_gatt_client_free(gatt_client_t *gatt_client);
175cf26c8fbSMilanka Ringwald hids_client_t * btstack_memory_hids_client_get(void);
176cf26c8fbSMilanka Ringwald void   btstack_memory_hids_client_free(hids_client_t *hids_client);
177cf26c8fbSMilanka Ringwald scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void);
178cf26c8fbSMilanka Ringwald void   btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client);
179cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void);
180cf49570bSMatthias Ringwald void   btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry);
181174a0c1cSMilanka Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void);
182174a0c1cSMilanka Ringwald void   btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry);
183dbca66ffSMatthias Ringwald periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void);
184dbca66ffSMatthias Ringwald void   btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t *periodic_advertiser_list_entry);
18544c5d856SMatthias Ringwald #endif
18644c5d856SMatthias Ringwald #ifdef ENABLE_MESH
187039cbf1dSMatthias Ringwald // mesh_network_pdu, mesh_segmented_pdu, mesh_upper_transport_pdu, mesh_network_key, mesh_transport_key, mesh_virtual_address, mesh_subnet
188ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void);
189ebb73e1fSMatthias Ringwald void   btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu);
190a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void);
191a4bbc09dSMatthias Ringwald void   btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu);
192491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void);
193491f99b3SMatthias Ringwald void   btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu);
194c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void);
195c0a711d9SMatthias Ringwald void   btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key);
19601e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void);
19701e2bf94SMatthias Ringwald void   btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key);
1981f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void);
1991f45d603SMatthias Ringwald void   btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address);
20001122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void);
20101122b73SMatthias Ringwald void   btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet);
202d0fdae3cS[email protected] #endif
203d0fdae3cS[email protected] 
204bc64ca62S[email protected] #if defined __cplusplus
205bc64ca62S[email protected] }
206bc64ca62S[email protected] #endif
207f471afd8S[email protected] 
20880e33422SMatthias Ringwald #endif // BTSTACK_MEMORY_H
2092e97c149S[email protected] 
210