bluetooth: Eliminate the need for kernel headers in userland.
This commit is contained in:
@@ -5,12 +5,49 @@
|
|||||||
#ifndef _BTHCI_TRANSPORT_H_
|
#ifndef _BTHCI_TRANSPORT_H_
|
||||||
#define _BTHCI_TRANSPORT_H_
|
#define _BTHCI_TRANSPORT_H_
|
||||||
|
|
||||||
|
|
||||||
#include <bluetooth/HCI/btHCI.h>
|
#include <bluetooth/HCI/btHCI.h>
|
||||||
|
|
||||||
|
#include <Drivers.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <util/DoublyLinkedList.h>
|
#include <util/DoublyLinkedList.h>
|
||||||
|
|
||||||
|
#ifdef _KERNEL_MODE
|
||||||
#include <net_buffer.h>
|
#include <net_buffer.h>
|
||||||
#include <Drivers.h>
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Here the transport driver have some flags that
|
||||||
|
* can be used to inform the upper layer about some
|
||||||
|
* special behaouvior to perform */
|
||||||
|
|
||||||
|
#define BT_IGNORE_THIS_DEVICE (1 << 0)
|
||||||
|
#define BT_SCO_NOT_WORKING (1 << 1)
|
||||||
|
#define BT_WILL_NEED_A_RESET (1 << 2)
|
||||||
|
#define BT_DIGIANSWER (1 << 4)
|
||||||
|
|
||||||
|
// Mandatory IOCTLS
|
||||||
|
#define BT_IOCTLS_OFFSET 3000
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, // 12999
|
||||||
|
GET_STATS,
|
||||||
|
GET_NOTIFICATION_PORT,
|
||||||
|
GET_HCI_ID,
|
||||||
|
BT_UP
|
||||||
|
};
|
||||||
|
|
||||||
|
// To deprecate ...
|
||||||
|
#define PACK_PORTCODE(type,hid,data) ((type & 0xFF) << 24 | (hid & 0xFF) << 16 | (data & 0xFFFF))
|
||||||
|
#define GET_PORTCODE_TYPE(code) ((code & 0xFF000000) >> 24)
|
||||||
|
#define GET_PORTCODE_HID(code) ((code & 0x00FF0000) >> 16)
|
||||||
|
#define GET_PORTCODE_DATA(code) ((code & 0x0000FFFF))
|
||||||
|
|
||||||
|
/* Port drivers can use to send information (1 for all for
|
||||||
|
at moment refer to ioctl GET_NOTIFICATION_PORT)*/
|
||||||
|
#define BT_USERLAND_PORT_NAME "BT Kernel-User Event"
|
||||||
|
#define BT_RX_PORT_NAME "BT Kernel RX assembly"
|
||||||
|
#define BLUETOOTH_CONNECTION_PORT "bluetooth connection port"
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -54,12 +91,12 @@ typedef struct bt_hci_device {
|
|||||||
} bt_hci_device;
|
} bt_hci_device;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_KERNEL_MODE)
|
||||||
/* Hooks which drivers will have to provide.
|
/* Hooks which drivers will have to provide.
|
||||||
* The structure is meant to be allocated in driver side and
|
* The structure is meant to be allocated in driver side and
|
||||||
* provided to the HCI where it will fill the remaining fields
|
* provided to the HCI where it will fill the remaining fields
|
||||||
*/
|
*/
|
||||||
typedef struct bt_hci_transport_hooks {
|
typedef struct bt_hci_transport_hooks {
|
||||||
|
|
||||||
// to be filled by driver
|
// to be filled by driver
|
||||||
status_t (*SendCommand)(hci_id hciId, void* command);
|
status_t (*SendCommand)(hci_id hciId, void* command);
|
||||||
status_t (*SendACL)(hci_id hciId, net_buffer* nbuf);
|
status_t (*SendACL)(hci_id hciId, net_buffer* nbuf);
|
||||||
@@ -69,21 +106,17 @@ typedef struct bt_hci_transport_hooks {
|
|||||||
status_t (*DeliverStatistics)(hci_id hciId, bt_hci_statistics* statistics);
|
status_t (*DeliverStatistics)(hci_id hciId, bt_hci_statistics* statistics);
|
||||||
|
|
||||||
transport_type kind;
|
transport_type kind;
|
||||||
|
|
||||||
} bt_hci_transport_hooks;
|
} bt_hci_transport_hooks;
|
||||||
|
|
||||||
typedef struct bt_hci_device_information {
|
typedef struct bt_hci_device_information {
|
||||||
|
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
uint16 vendorId;
|
uint16 vendorId;
|
||||||
uint16 deviceId;
|
uint16 deviceId;
|
||||||
char name[B_OS_NAME_LENGTH];
|
char name[B_OS_NAME_LENGTH];
|
||||||
|
|
||||||
} bt_hci_device_information;
|
} bt_hci_device_information;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
|
|
||||||
struct bluetooth_device : DoublyLinkedListLinkImpl<bluetooth_device> {
|
struct bluetooth_device : DoublyLinkedListLinkImpl<bluetooth_device> {
|
||||||
|
|
||||||
net_buffer* fBuffersRx[HCI_NUM_PACKET_TYPES];
|
net_buffer* fBuffersRx[HCI_NUM_PACKET_TYPES];
|
||||||
@@ -99,11 +132,8 @@ struct bluetooth_device : DoublyLinkedListLinkImpl<bluetooth_device> {
|
|||||||
uint16 mtu;
|
uint16 mtu;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
struct bluetooth_device;
|
struct bluetooth_device;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -129,37 +159,7 @@ typedef struct bt_hci_module_info {
|
|||||||
|
|
||||||
} bt_hci_module_info ;
|
} bt_hci_module_info ;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Here the transport driver have some flags that
|
|
||||||
* can be used to inform the upper layer about some
|
|
||||||
* special behaouvior to perform */
|
|
||||||
|
|
||||||
#define BT_IGNORE_THIS_DEVICE (1 << 0)
|
|
||||||
#define BT_SCO_NOT_WORKING (1 << 1)
|
|
||||||
#define BT_WILL_NEED_A_RESET (1 << 2)
|
|
||||||
#define BT_DIGIANSWER (1 << 4)
|
|
||||||
|
|
||||||
// Mandatory IOCTLS
|
|
||||||
#define BT_IOCTLS_OFFSET 3000
|
|
||||||
|
|
||||||
enum {
|
|
||||||
ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, // 12999
|
|
||||||
GET_STATS,
|
|
||||||
GET_NOTIFICATION_PORT,
|
|
||||||
GET_HCI_ID,
|
|
||||||
BT_UP
|
|
||||||
};
|
|
||||||
|
|
||||||
// To deprecate ...
|
|
||||||
#define PACK_PORTCODE(type,hid,data) ((type & 0xFF) << 24 | (hid & 0xFF) << 16 | (data & 0xFFFF))
|
|
||||||
#define GET_PORTCODE_TYPE(code) ((code & 0xFF000000) >> 24)
|
|
||||||
#define GET_PORTCODE_HID(code) ((code & 0x00FF0000) >> 16)
|
|
||||||
#define GET_PORTCODE_DATA(code) ((code & 0x0000FFFF))
|
|
||||||
|
|
||||||
/* Port drivers can use to send information (1 for all for
|
|
||||||
at moment refer to ioctl GET_NOTIFICATION_PORT)*/
|
|
||||||
#define BT_USERLAND_PORT_NAME "BT Kernel-User Event"
|
|
||||||
#define BT_RX_PORT_NAME "BT Kernel RX assembly"
|
|
||||||
#define BLUETOOTH_CONNECTION_PORT "bluetooth connection port"
|
|
||||||
|
|
||||||
#endif // _BTHCI_TRANSPORT_H_
|
#endif // _BTHCI_TRANSPORT_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user