Commit graph

472 commits

Author SHA1 Message Date
Johan Hedberg 9bea2c3cfc Bluetooth: Move HCI driver API to dedicated header file
This makes it clearer that this is a specialized API not intended for
general app usage (unlike most other things in bluetooth.h).

Change-Id: I0ce1d5903610a9b3a99cf0be9f0e1462b04bf45a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 939544b75d Bluetooth: Move logging helpers to a dedicated header file
To make it clearer that these helpers are intended only for
Bluetooth-subsystem internal code, move them to a separate file.

Change-Id: Iea64780f5c61c1c96e12c9df378676bc49498fe4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 68773aa74e Bluetooth: Fix CONFIG_BLUETOOTH_DEBUG_UART dependency
The BLUETOOTH_DEBUG_UART config option should depend on BLUETOOTH_UART
and also be sorted after it in the hierarchy.

Change-Id: I3e049e52c2e353cd0c6f1a99ca8934a289e0cce8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:17 -05:00
Andrei Emeltchenko 1c65da5ed7 Bluetooth: Check returned buffer is not NULL
Buffers returned by bt_uart_evt_recv() and bt_uart_acl_recv() may be
NULL in theory. This makes code consistent by checking return value.

Change-Id: Id39def39c8b1c4c6eefc7b2bf01702c54b3e565c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:17 -05:00
Anas Nashif bbe84f8ae5 Use ccflags-y and asflags-y instead of EXTRA_CFLAGS
According to section 3.7 of Documentation/kbuild/makefiles.txt, using
EXTRA_CFLAGS in Makefiles is "still supported but their usage is
deprecated." However, using make EXTRA_CFLAGS="-DSOMETHING" results in
EXTRA_CFLAGS from Makefiles being overwritten, obviously breaking the
build.  This patch converts to them to the newer ccflags-y which also
fixes the problem.

Change-Id: I6309439599d4c9cc184f9ecd941bde841982ef07
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:14 -05:00
Dan Kalowsky c02dd34277 Renaming include/nanokernel to include/arch
Renaming the directory include/nanokernel to be include/arch, which
better reflects the real nature of the directory and the contents
inside.

Change-Id: I2bc33ebc6715e2f0403227a558279fdf52398ade
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:14:12 -05:00
Anas Nashif f4f5cc138c Kbuild: include files dynamically based on BSP_DIR
Change-Id: If36a03acb633c772d599ae1492ebabf04c432306
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:10 -05:00
Juan Manuel Cruz d15251fec5 Kbuild: Kconfig license headers.
This commit add license headers to Kconfig files.

Change-Id: I79e60263b8c7b696463ecc84b8ad411af5415117
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
2016-02-05 20:14:10 -05:00
Anas Nashif c4b860cff1 Kbuild: Rename menu for bluetooth uart driver
Change-Id: Ibfc45a91d39fa78406115e209d71d820b028af45
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:09 -05:00
Anas Nashif d2ca03270e Kbuild: Fix sanity checks for quark
Change-Id: Id142f337f715590fa63d9f7b957f51c203743566
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:08 -05:00
Juan Manuel Cruz b7fcfd53e5 Kconfig: Organization of Ksymbols for bluetooth.
This commit organizes the bluetooth Ksymbols in:
 - Driver symbols at drivers/bluetooth/Kconfig
 - Stack symbols at net/bluetooth/Kconfig

Change-Id: I8ebadeb8ac7f8a769d7620e4e44077a05915dc86
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
2016-02-05 20:14:08 -05:00
Juan Manuel Cruz 638fb2c181 Kbuild: Bluetooth driver support.
This commit adds the Makefile and Kconfig files
to support the bluetooth driver in the Kbuild system.

Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
Change-Id: I1f72b13aca8fb098eece04c4f0e1b680639b520f
2016-02-05 20:14:08 -05:00
Tomasz Bursztyka ea4c3d1c0f bluetooth: UART based driver no longer needs to set regs and irq
Now that UART drivers are configured internally when it comes to
hardware specific information such as IRQ and registers (or mmaped
registers), bluetooth UART driver no longer needs to do it by itself. It
only requires to select the port it wants to use.

Change-Id: I5a30500f4b6f4155292609d0ed4a758f91930817
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:14:01 -05:00
Johan Hedberg a0bb20f4d1 Bluetooth: coding-style: fix one-line branch braces usage
The coding guidelines make an exception to the Linux kernel style
where all branches, even one-liners, should use braces.

Change-Id: I368930af3033eac15f0152a6671909e401d332e6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:56 -05:00
Andrei Emeltchenko ea1f5f3785 Bluetooth: Add Bluetooth UART driver specific debug support
Configuration option BLUETOOTH_DEBUG_UART enables debug support for
Bluetooth UART driver.

Change-Id: I192f380be492df1a52ad212239447b6ee4b50aac
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg caf5141de5 Bluetooth: Remove unnecessary error checks for bt_uart_read() calls
When the 'len' and 'min' parameters passed to bt_uart_read() are equal
the function is guaranteed to always return 'len' (it will keep
looping until that). This patch removes bt_uart_read() error checks
which would never occur in practice.

Change-Id: Icd879f1e15c6d33acc549155aabd24490098ffc5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 099ecbfa7c Bluetooth: Add minimum required length parameter to bt_uart_read()
There are some places where it's forgivable if bt_uart_read() wasn't
able to read as many bytes as requested. In other places it's not
acceptable (e.g. when reading ACL or event header). To avoid failing
in situations where we can handle receiving less data than requested
this patch adds a new parameter to bt_uart_read() to specify the
minimum required data amount.

Change-Id: I372e3af7aaa6bfabe14896eb10cc71c3deff94f2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 935198e715 Bluetooth: Fix UART driver robustness when out of buffers
If we're out of buffers the UART driver would previously loose sync of
where the packet boundaries go, because it was using the buffer itself
to store and parse the HCI packet headers. This patch modifies the
UART driver to use stack variable for initial header parsing, thereby
being able to always determine how many remaining bytes there are and
cleanly discard the bytes until the beginning of the next packet.

Change-Id: I278f3fc0c983e6a2a6904356ef1af1d25c9f06e4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg c96f8e484c Bluetooth: Fix potential NULL-pointer access in UART driver
If we get an invalid packet type here the buf pointer will be NULL.
Going to the cleanup section at the end of the function would trigger
a bt_but_put() call which would cause a NULL pointer access. Directly
returning from the function is the right thing to do instead.

Change-Id: I0c18646e0820cf829ef8aa3f77835ba0a14375b5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg d829fe9755 Bluetooth: Consolidate bt_buf_get* functions
We may soon want to have a _wait() variant of bt_buf_get, so to avoid
the number of 'get' function growing too large consolidate the
existing get() and get_reserve() functions into a single one. The new
consolidated function also takes the type as input parameter so that
we know this from the very start and thereby plan for the split into
multiple buffer pools.

Change-Id: Ia09448565349def2be9bc08d9510fedd029480b4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 4e65d0aac2 Bluetooth: Split ACL buffers into two distinct types
We'll soon want to have dedicated pools for outgoing and incoming ACL
data. To know from which pool to get and put the buffers each buffer
should contain enough information to distinguish the two types. This
patch splits the old BT_ACL type into two new BT_ACL_IN & BT_ACL_OUT
types.

Change-Id: I7d3c05c26d2a70f80fb1229e245aa21673ec378b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 2581ad9313 Bluetooth: Add HCI UART (H4) driver
This patch adds a simple HCI UART (H4) driver that currently maps to
the second UART in the system. The main intention is to use this
together with qemu for accessing the Bluetooth controller available on
the host OS side.

The H4 HCI transport protocol is perhaps the simplest of the standard
HCI transports. It consists of a single byte in the beginning of each
packet which indicates the type of the packet: HCI event, HCI command,
ACL data, or SCO data (which we don't use at the moment).

Change-Id: I225a2a2361fbd7cd4ba82ea1f81ddc1271e9e7c2
Co-authored-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:44 -05:00