Bluetooth: Add convenience macros for defining stacks

To not have to always do the __noinit, debug log correction and 4-byte
alignement declaration create some helper macros for defining the
stacks.

Change-Id: I2de5068d7044af3f348ed01281498a777d04c97d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-05-26 13:20:54 +03:00 committed by Anas Nashif
commit 8eabf208d7
4 changed files with 12 additions and 11 deletions

View file

@ -268,7 +268,7 @@ struct bt_conn *bt_conn_add(struct bt_dev *dev, uint16_t handle)
nano_fifo_init(&conn->tx_queue);
fiber_start(conn->tx_stack, BT_CONN_TX_STACK_SIZE, conn_tx_fiber,
fiber_start(conn->tx_stack, sizeof(conn->tx_stack), conn_tx_fiber,
(int)bt_conn_get(conn), 0, 7, 0);
bt_l2cap_update_conn_param(conn);

View file

@ -30,8 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#define BT_CONN_TX_STACK_SIZE (256 + BT_STACK_DEBUG_EXTRA)
enum {
BT_CONN_DISCONNECTED,
BT_CONN_CONNECTED,
@ -68,7 +66,8 @@ struct bt_conn {
uint8_t state;
char __stack tx_stack[BT_CONN_TX_STACK_SIZE];
/* TX fiber stack */
BT_STACK(tx_stack, 256);
};
/* Process incoming data for a connection */

View file

@ -57,13 +57,9 @@
#define ACL_OUT_MAX 7
/* Stacks for the fibers */
#define RX_STACK_SIZE (1024 + BT_STACK_DEBUG_EXTRA)
#define CMD_RX_STACK_SIZE (256 + BT_STACK_DEBUG_EXTRA)
#define CMD_TX_STACK_SIZE (256 + BT_STACK_DEBUG_EXTRA)
static char __noinit __stack rx_fiber_stack[RX_STACK_SIZE];
static char __noinit __stack cmd_rx_fiber_stack[CMD_RX_STACK_SIZE];
static char __noinit __stack cmd_tx_fiber_stack[CMD_TX_STACK_SIZE];
static BT_STACK_NOINIT(rx_fiber_stack, 1024);
static BT_STACK_NOINIT(cmd_rx_fiber_stack, 256);
static BT_STACK_NOINIT(cmd_tx_fiber_stack, 256);
#if defined(CONFIG_BLUETOOTH_DEBUG)
static nano_context_id_t cmd_rx_fiber_id;

View file

@ -31,6 +31,7 @@
*/
#include <stdbool.h>
#include <arch/cpu.h>
/* Enabling debug increases stack size requirement considerably */
#if defined(CONFIG_BLUETOOTH_DEBUG)
@ -39,6 +40,11 @@
#define BT_STACK_DEBUG_EXTRA 0
#endif
#define BT_STACK(name, size) \
char __stack name[(size) + BT_STACK_DEBUG_EXTRA]
#define BT_STACK_NOINIT(name, size) \
char __noinit __stack name[(size) + BT_STACK_DEBUG_EXTRA]
/* LMP feature helpers */
#define lmp_bredr_capable(dev) (!((dev).features[4] & BT_LMP_NO_BREDR))
#define lmp_le_capable(dev) ((dev).features[4] & BT_LMP_LE)