From 02d67528b5640a6a954fe6465a76bce5adab3a58 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Fri, 13 Nov 2009 22:03:33 +0000 Subject: [PATCH] Add class to handle all code values to be sent in the ports git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34024 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/bluetooth/CodeHandler.h | 64 +++++++++++++++++++++++++ headers/private/bluetooth/btCoreData.h | 11 ++++- 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 headers/private/bluetooth/CodeHandler.h diff --git a/headers/private/bluetooth/CodeHandler.h b/headers/private/bluetooth/CodeHandler.h new file mode 100644 index 0000000000..fb3f2071ab --- /dev/null +++ b/headers/private/bluetooth/CodeHandler.h @@ -0,0 +1,64 @@ +#ifndef _CODEHANDLER_H_ +#define _CODEHANDLER_H_ + +#include + +namespace Bluetooth +{ + +class CodeHandler { + +public: + /* + * TODO: Handler and protocol could be fit in 16 bits 12 + * for handler and 4 for the protocol + */ + + /* + * Used: + * - From HCI layer to send events to bluetooth server. + * - L2cap lower to dispatch TX packets to HCI Layer informing about connection handle + * - Transport drivers dispatch its data to HCI layer + * + */ + static inline hci_id Device(uint32 code) + { + return ((code & 0xFF) >> 24); + } + + + static inline void SetDevice(uint32* code, hci_id device) + { + *code = *code | ((device & 0xFF) << 24); + } + + + static inline uint16 Handler(uint32 code) + { + return ((code & 0xFFFF) >> 0); + } + + + static void SetHandler(uint32* code, uint16 handler) + { + *code = *code | ((handler & 0xFFFF) << 0); + } + + + static bt_packet_t Protocol(uint32 code) + { + return (bt_packet_t)((code && 0xFF) >> 16); + } + + + static void SetProtocol(uint32* code, bt_packet_t protocol) + { + *code = *code | ((protocol & 0xFF) << 16); + } + + +}; + +} // namespace + +#endif diff --git a/headers/private/bluetooth/btCoreData.h b/headers/private/bluetooth/btCoreData.h index 55a2226f0c..8885807667 100644 --- a/headers/private/bluetooth/btCoreData.h +++ b/headers/private/bluetooth/btCoreData.h @@ -6,6 +6,7 @@ #define _BTCOREDATA_H #include +#include #include #include @@ -30,6 +31,9 @@ typedef enum _connection_status { #ifdef __cplusplus struct HciConnection : DoublyLinkedListLinkImpl { + HciConnection(); + virtual ~HciConnection(); + hci_id Hid; struct net_device* ndevice; net_buffer* currentRxPacket; @@ -44,6 +48,8 @@ struct HciConnection : DoublyLinkedListLinkImpl { DoublyLinkedList ChannelList; DoublyLinkedList ExpectedResponses; DoublyLinkedList OutGoingFrames; + mutex fLock; + mutex fLockExpected; }; #else @@ -84,7 +90,7 @@ struct L2capChannel : DoublyLinkedListLinkImpl { uint16 psm; uint8 ident; uint8 cfgState; - + channel_status state; ChannelConfiguration* configuration; L2capEndpoint* endpoint; @@ -154,9 +160,10 @@ struct bluetooth_core_data_module_info { struct L2capFrame* (*SignalByIdent)(struct HciConnection* conn, uint8 ident); status_t (*TimeoutSignal)(struct L2capFrame* frame, uint32 timeo); status_t (*UnTimeoutSignal)(struct L2capFrame* frame); - struct L2capFrame* (*SpawnFrame)(struct HciConnection* conn, net_buffer* buffer, frame_type frame); + struct L2capFrame* (*SpawnFrame)(struct HciConnection* conn, struct L2capChannel* channel, net_buffer* buffer, frame_type frame); struct L2capFrame* (*SpawnSignal)(struct HciConnection* conn, struct L2capChannel* channel, net_buffer* buffer, uint8 ident, uint8 code); status_t (*AcknowledgeSignal)(struct L2capFrame* frame); + status_t (*QueueSignal)(struct L2capFrame* frame); };