xref: /btstack/src/btstack_memory.h (revision a8d51f092f1b660d0f6921369ad2bc3f9368296c)
1 /*
2  * Copyright (C) 2014 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 
39 
40 /*
41  *  btstack_memory.h
42  *
43  *  @brief BTstack memory management via configurable memory pools
44  *
45  */
46 
47 #ifndef BTSTACK_MEMORY_H
48 #define BTSTACK_MEMORY_H
49 
50 #if defined __cplusplus
51 extern "C" {
52 #endif
53 
54 #include "btstack_config.h"
55 
56 // Core
57 #include "hci.h"
58 #include "l2cap.h"
59 
60 // Classic
61 #include "classic/bnep.h"
62 #include "classic/hfp.h"
63 #include "classic/btstack_link_key_db.h"
64 #include "classic/btstack_link_key_db_memory.h"
65 #include "classic/rfcomm.h"
66 #include "classic/sdp_server.h"
67 #include "classic/avdtp_sink.h"
68 #include "classic/avdtp_source.h"
69 #include "classic/avrcp.h"
70 
71 // BLE
72 #ifdef ENABLE_BLE
73 #include "ble/gatt_client.h"
74 #include "ble/sm.h"
75 #endif
76 
77 #ifdef ENABLE_MESH
78 #include "mesh/mesh_network.h"
79 #include "mesh/mesh_keys.h"
80 #include "mesh/mesh_virtual_addresses.h"
81 #endif
82 
83 /* API_START */
84 
85 /**
86  * @brief Initializes BTstack memory pools.
87  */
88 void btstack_memory_init(void);
89 
90 /* API_END */
91 
92 // hci_connection
93 hci_connection_t * btstack_memory_hci_connection_get(void);
94 void   btstack_memory_hci_connection_free(hci_connection_t *hci_connection);
95 
96 // l2cap_service, l2cap_channel
97 l2cap_service_t * btstack_memory_l2cap_service_get(void);
98 void   btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service);
99 l2cap_channel_t * btstack_memory_l2cap_channel_get(void);
100 void   btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel);
101 
102 #ifdef ENABLE_CLASSIC
103 // rfcomm_multiplexer, rfcomm_service, rfcomm_channel
104 rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void);
105 void   btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer);
106 rfcomm_service_t * btstack_memory_rfcomm_service_get(void);
107 void   btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service);
108 rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void);
109 void   btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel);
110 
111 // btstack_link_key_db_memory_entry
112 btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void);
113 void   btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry);
114 
115 // bnep_service, bnep_channel
116 bnep_service_t * btstack_memory_bnep_service_get(void);
117 void   btstack_memory_bnep_service_free(bnep_service_t *bnep_service);
118 bnep_channel_t * btstack_memory_bnep_channel_get(void);
119 void   btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel);
120 
121 // hfp_connection
122 hfp_connection_t * btstack_memory_hfp_connection_get(void);
123 void   btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection);
124 
125 // service_record_item
126 service_record_item_t * btstack_memory_service_record_item_get(void);
127 void   btstack_memory_service_record_item_free(service_record_item_t *service_record_item);
128 
129 // avdtp_stream_endpoint
130 avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void);
131 void   btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint);
132 
133 // avdtp_connection
134 avdtp_connection_t * btstack_memory_avdtp_connection_get(void);
135 void   btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection);
136 
137 // avrcp_connection
138 avrcp_connection_t * btstack_memory_avrcp_connection_get(void);
139 void   btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection);
140 
141 // avrcp_browsing_connection
142 avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void);
143 void   btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection);
144 
145 #endif
146 #ifdef ENABLE_BLE
147 // gatt_client, whitelist_entry, sm_lookup_entry
148 gatt_client_t * btstack_memory_gatt_client_get(void);
149 void   btstack_memory_gatt_client_free(gatt_client_t *gatt_client);
150 whitelist_entry_t * btstack_memory_whitelist_entry_get(void);
151 void   btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry);
152 sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void);
153 void   btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry);
154 #endif
155 #ifdef ENABLE_MESH
156 // mesh_network_pdu, mesh_segmented_pdu, mesh_upper_transport_pdu, mesh_network_key, mesh_transport_key, mesh_virtual_address, mesh_subnet
157 mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void);
158 void   btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu);
159 mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void);
160 void   btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu);
161 mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void);
162 void   btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu);
163 mesh_network_key_t * btstack_memory_mesh_network_key_get(void);
164 void   btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key);
165 mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void);
166 void   btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key);
167 mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void);
168 void   btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address);
169 mesh_subnet_t * btstack_memory_mesh_subnet_get(void);
170 void   btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet);
171 #endif
172 
173 #if defined __cplusplus
174 }
175 #endif
176 
177 #endif // BTSTACK_MEMORY_H
178 
179