Make the local devices register in some module of the Kernel land... for the moment as bridge for l2cap
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26613 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
25ae4a6a68
commit
e54b6bb39a
@ -22,11 +22,9 @@
|
|||||||
#include <bluetooth/HCI/btHCI_module.h>
|
#include <bluetooth/HCI/btHCI_module.h>
|
||||||
|
|
||||||
#define BT_DEBUG_THIS_MODULE
|
#define BT_DEBUG_THIS_MODULE
|
||||||
|
|
||||||
#define MODULE_NAME "BT"
|
#define MODULE_NAME "BT"
|
||||||
#define SUBMODULE_NAME BLUETOOTH_DEVICE_DEVFS_NAME
|
#define SUBMODULE_NAME BLUETOOTH_DEVICE_DEVFS_NAME
|
||||||
#define SUBMODULE_COLOR 31
|
#define SUBMODULE_COLOR 31
|
||||||
|
|
||||||
#include <btDebug.h>
|
#include <btDebug.h>
|
||||||
|
|
||||||
#include "h2generic.h"
|
#include "h2generic.h"
|
||||||
@ -41,8 +39,13 @@ int32 api_version = B_CUR_DRIVER_API_VERSION;
|
|||||||
static char* usb_name = B_USB_MODULE_NAME;
|
static char* usb_name = B_USB_MODULE_NAME;
|
||||||
static char* hci_name = BT_HCI_MODULE_NAME;
|
static char* hci_name = BT_HCI_MODULE_NAME;
|
||||||
|
|
||||||
|
#define NET_BLUETOOTH_DEVICE_NAME "network/devices/bluetooth/v1" //move out!!
|
||||||
|
static char* btDevices_name = NET_BLUETOOTH_DEVICE_NAME;
|
||||||
|
|
||||||
|
|
||||||
usb_module_info *usb = NULL;
|
usb_module_info *usb = NULL;
|
||||||
bt_hci_module_info *hci = NULL;
|
bt_hci_module_info *hci = NULL;
|
||||||
|
struct net_device_module_info* btDevices;
|
||||||
struct net_buffer_module_info *nb = NULL;
|
struct net_buffer_module_info *nb = NULL;
|
||||||
|
|
||||||
/* Driver Global data */
|
/* Driver Global data */
|
||||||
@ -457,19 +460,21 @@ device_open(const char *name, uint32 flags, void **cookie)
|
|||||||
list_init(&bdev->snetBufferRecycleTrash);
|
list_init(&bdev->snetBufferRecycleTrash);
|
||||||
|
|
||||||
// Allocate set and register the HCI device
|
// Allocate set and register the HCI device
|
||||||
if (hci != NULL) {
|
if (btDevices != NULL) {
|
||||||
|
struct net_device* ndev;
|
||||||
// TODO: Fill the transport descriptor
|
// TODO: Fill the transport descriptor
|
||||||
hci->RegisterDriver(&bt_usb_hooks, &hdev, (void*)bdev);
|
err = btDevices->init_device(bdev->name, &ndev);
|
||||||
|
|
||||||
if ( err != B_OK )
|
if ( err == B_OK ) {
|
||||||
{
|
hdev = ndev->index;
|
||||||
flowf("Impossible to register a hci device.\n");
|
bdev->ndev = ndev;
|
||||||
hdev = bdev->num; /* XXX: Lets try to go on*/
|
} else
|
||||||
}
|
hdev = bdev->num; /* XXX: Lets try to go on*/
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hdev = bdev->num;
|
hdev = bdev->num; /* XXX: Lets try to go on*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bdev->hdev = hdev;
|
bdev->hdev = hdev;
|
||||||
|
|
||||||
|
|
||||||
@ -521,8 +526,8 @@ device_close(void *cookie)
|
|||||||
purge_room(&bdev->aclRoom);
|
purge_room(&bdev->aclRoom);
|
||||||
|
|
||||||
/* Device no longer in our Stack*/
|
/* Device no longer in our Stack*/
|
||||||
if (hci != NULL)
|
if (btDevices != NULL)
|
||||||
hci->UnregisterDriver(bdev->hdev);
|
btDevices->uninit_device(bdev->ndev);
|
||||||
|
|
||||||
// unSet RUNNING
|
// unSet RUNNING
|
||||||
if (TEST_AND_CLEAR(&bdev->state, RUNNING)) {
|
if (TEST_AND_CLEAR(&bdev->state, RUNNING)) {
|
||||||
@ -687,31 +692,42 @@ init_driver(void)
|
|||||||
int j;
|
int j;
|
||||||
flowf("init_driver()\n");
|
flowf("init_driver()\n");
|
||||||
|
|
||||||
|
|
||||||
|
// BT devices MODULE INITS
|
||||||
|
if (get_module(btDevices_name,(module_info**)&btDevices) != B_OK) {
|
||||||
|
debugf("cannot get module \"%s\"\n", btDevices_name);
|
||||||
|
return B_ERROR;
|
||||||
|
} else
|
||||||
|
debugf("btDevices module at %p\n", btDevices);
|
||||||
|
|
||||||
|
|
||||||
// HCI MODULE INITS
|
// HCI MODULE INITS
|
||||||
if (get_module(hci_name,(module_info**)&hci) != B_OK) {
|
if (get_module(hci_name,(module_info**)&hci) != B_OK) {
|
||||||
debugf("cannot get module \"%s\"\n", hci_name);
|
debugf("cannot get module \"%s\"\n", hci_name);
|
||||||
#ifndef BT_SURVIVE_WITHOUT_HCI
|
#ifndef BT_SURVIVE_WITHOUT_HCI
|
||||||
return B_ERROR;
|
return err_release2;
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
debugf("hci module at %p\n", hci);
|
||||||
}
|
}
|
||||||
debugf("hci module at %p\n", hci);
|
|
||||||
|
|
||||||
// USB MODULE INITS
|
// USB MODULE INITS
|
||||||
if (get_module(usb_name,(module_info**)&usb) != B_OK) {
|
if (get_module(usb_name,(module_info**)&usb) != B_OK) {
|
||||||
debugf("cannot get module \"%s\"\n", usb_name);
|
debugf("cannot get module \"%s\"\n", usb_name);
|
||||||
goto err_release;
|
goto err_release1;
|
||||||
|
} else {
|
||||||
|
debugf("usb module at %p\n", usb);
|
||||||
}
|
}
|
||||||
debugf("usb module at %p\n", usb);
|
|
||||||
|
|
||||||
|
|
||||||
if (get_module(NET_BUFFER_MODULE_NAME,(module_info**)&nb) != B_OK) {
|
if (get_module(NET_BUFFER_MODULE_NAME,(module_info**)&nb) != B_OK) {
|
||||||
debugf("cannot get module \"%s\"\n", NET_BUFFER_MODULE_NAME);
|
debugf("cannot get module \"%s\"\n", NET_BUFFER_MODULE_NAME);
|
||||||
#ifndef BT_SURVIVE_WITHOUT_NET_BUFFERS
|
#ifndef BT_SURVIVE_WITHOUT_NET_BUFFERS
|
||||||
goto err_release;
|
goto err_release;
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
debugf("nb module at %p\n", nb);
|
||||||
}
|
}
|
||||||
debugf("nb module at %p\n", nb);
|
|
||||||
|
|
||||||
// GENERAL INITS
|
// GENERAL INITS
|
||||||
dev_table_sem = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "dev_table_lock");
|
dev_table_sem = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "dev_table_lock");
|
||||||
if (dev_table_sem < 0) {
|
if (dev_table_sem < 0) {
|
||||||
@ -729,9 +745,13 @@ init_driver(void)
|
|||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
err: // Releasing
|
err: // Releasing
|
||||||
|
put_module(NET_BUFFER_MODULE_NAME);
|
||||||
|
err_release:
|
||||||
put_module(usb_name);
|
put_module(usb_name);
|
||||||
err_release:
|
err_release1:
|
||||||
|
put_module(hci_name);
|
||||||
|
err_release2:
|
||||||
put_module(hci_name);
|
put_module(hci_name);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
#ifndef _H2GENERIC_H_
|
#ifndef _H2GENERIC_H_
|
||||||
#define _H2GENERIC_H_
|
#define _H2GENERIC_H_
|
||||||
|
|
||||||
|
#include <net_buffer.h>
|
||||||
|
#include <net_device.h>
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <USB.h>
|
#include <USB.h>
|
||||||
|
|
||||||
@ -15,8 +18,6 @@
|
|||||||
#include <bluetooth/HCI/btHCI.h>
|
#include <bluetooth/HCI/btHCI.h>
|
||||||
#include <bluetooth/HCI/btHCI_module.h>
|
#include <bluetooth/HCI/btHCI_module.h>
|
||||||
|
|
||||||
#include <net_buffer.h>
|
|
||||||
|
|
||||||
#include "snet_buffer.h"
|
#include "snet_buffer.h"
|
||||||
|
|
||||||
/* USB definitions for the generic device*/
|
/* USB definitions for the generic device*/
|
||||||
@ -28,8 +29,6 @@
|
|||||||
#define BLUETOOTH_DEVICE_NAME "generic"
|
#define BLUETOOTH_DEVICE_NAME "generic"
|
||||||
#include "h2cfg.h"
|
#include "h2cfg.h"
|
||||||
|
|
||||||
//#define ID DEVICE_NAME ": " /* prefix for debug messages */
|
|
||||||
|
|
||||||
#define USB_TYPE_CLASS (0x01 << 5) /// Check if it is in some other header
|
#define USB_TYPE_CLASS (0x01 << 5) /// Check if it is in some other header
|
||||||
#define USB_TYPE_VENDOR (0x02 << 5)
|
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||||
|
|
||||||
@ -39,6 +38,7 @@
|
|||||||
|
|
||||||
extern usb_module_info* usb;
|
extern usb_module_info* usb;
|
||||||
extern bt_hci_module_info* hci;
|
extern bt_hci_module_info* hci;
|
||||||
|
extern struct net_device_module_info* btDevices;
|
||||||
extern struct net_buffer_module_info* nb;
|
extern struct net_buffer_module_info* nb;
|
||||||
|
|
||||||
#define MAX_COMMAND_WINDOW 1
|
#define MAX_COMMAND_WINDOW 1
|
||||||
@ -53,6 +53,7 @@ typedef struct bt_usb_dev bt_usb_dev;
|
|||||||
struct bt_usb_dev {
|
struct bt_usb_dev {
|
||||||
const usb_device* dev; /* opaque handle */
|
const usb_device* dev; /* opaque handle */
|
||||||
hci_id hdev; /* HCI device id*/
|
hci_id hdev; /* HCI device id*/
|
||||||
|
struct net_device* ndev;
|
||||||
|
|
||||||
char name[B_OS_NAME_LENGTH];
|
char name[B_OS_NAME_LENGTH];
|
||||||
bool connected; /* is the device plugged into the USB? */
|
bool connected; /* is the device plugged into the USB? */
|
||||||
|
@ -2,3 +2,4 @@ SubDir HAIKU_TOP src add-ons kernel network devices ;
|
|||||||
|
|
||||||
SubInclude HAIKU_TOP src add-ons kernel network devices ethernet ;
|
SubInclude HAIKU_TOP src add-ons kernel network devices ethernet ;
|
||||||
SubInclude HAIKU_TOP src add-ons kernel network devices loopback ;
|
SubInclude HAIKU_TOP src add-ons kernel network devices loopback ;
|
||||||
|
SubInclude HAIKU_TOP src add-ons kernel network devices bluetooth ;
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define BT_DEBUG_THIS_MODULE
|
#define BT_DEBUG_THIS_MODULE
|
||||||
|
#define SUBMODULE_NAME "bluetooth_device"
|
||||||
|
#define SUBMODULE_COLOR 34
|
||||||
#include <btDebug.h>
|
#include <btDebug.h>
|
||||||
|
|
||||||
|
|
||||||
@ -49,10 +51,10 @@ static sem_id sLinkChangeSemaphore;
|
|||||||
status_t
|
status_t
|
||||||
bluetooth_init(const char *name, net_device **_device)
|
bluetooth_init(const char *name, net_device **_device)
|
||||||
{
|
{
|
||||||
debugf("Inidializing bluetooth device %s\n",name);
|
debugf("Initializing bluetooth device %s\n",name);
|
||||||
|
|
||||||
// make sure this is a device in /dev/bluetooth
|
// TODO: make sure this is a device in /dev/bluetooth
|
||||||
if (strncmp(name, "/dev/bluetooth/", 15))
|
if (strncmp(name, "bluetooth/h", 11))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (gBufferModule == NULL) { // lazy allocation
|
if (gBufferModule == NULL) { // lazy allocation
|
||||||
@ -73,12 +75,17 @@ bluetooth_init(const char *name, net_device **_device)
|
|||||||
strcpy(device->name, name);
|
strcpy(device->name, name);
|
||||||
|
|
||||||
MutexLocker _(&sListLock);
|
MutexLocker _(&sListLock);
|
||||||
|
|
||||||
device->index = (sDeviceList.Tail())->index + 1; // TODO: index will be assigned by netstack
|
if (sDeviceList.IsEmpty())
|
||||||
|
device->index = 0x0000007C; // REVIEW: dev index
|
||||||
|
else
|
||||||
|
device->index = (sDeviceList.Tail())->index + 1; // TODO: index will be assigned by netstack
|
||||||
|
|
||||||
// TODO: add to list whould be done in up hook
|
// TODO: add to list whould be done in up hook
|
||||||
sDeviceList.Add(device);
|
sDeviceList.Add(device);
|
||||||
|
|
||||||
|
debugf("Device %s %x\n", device->name, device->index );
|
||||||
|
|
||||||
*_device = device;
|
*_device = device;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -89,7 +96,7 @@ bluetooth_uninit(net_device *_device)
|
|||||||
{
|
{
|
||||||
bluetooth_device *device = (bluetooth_device *)_device;
|
bluetooth_device *device = (bluetooth_device *)_device;
|
||||||
|
|
||||||
debugf("index %ld\n",device->index);
|
debugf("index %x\n",device->index);
|
||||||
|
|
||||||
// if the device is still part of the list, remove it
|
// if the device is still part of the list, remove it
|
||||||
if (device->GetDoublyLinkedListLink()->next != NULL
|
if (device->GetDoublyLinkedListLink()->next != NULL
|
||||||
@ -241,6 +248,23 @@ bluetooth_remove_multicast(struct net_device *_device, const sockaddr *_address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
dump_bluetooth_devices(int argc, char** argv)
|
||||||
|
{
|
||||||
|
bluetooth_device* device;
|
||||||
|
|
||||||
|
DoublyLinkedList<bluetooth_device>::Iterator iterator = sDeviceList.GetIterator();
|
||||||
|
while (iterator.HasNext()) {
|
||||||
|
|
||||||
|
device = iterator.Next();
|
||||||
|
kprintf("\tname=%s index=%#x\n",device->name, device->index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
bluetooth_std_ops(int32 op, ...)
|
bluetooth_std_ops(int32 op, ...)
|
||||||
{
|
{
|
||||||
@ -266,6 +290,8 @@ bluetooth_std_ops(int32 op, ...)
|
|||||||
|
|
||||||
mutex_init(&sListLock, "bluetooth devices");
|
mutex_init(&sListLock, "bluetooth devices");
|
||||||
|
|
||||||
|
add_debugger_command("btLocalDevices", &dump_bluetooth_devices, "Lists Bluetooth LocalDevices registered in the Stack");
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +301,9 @@ bluetooth_std_ops(int32 op, ...)
|
|||||||
|
|
||||||
mutex_destroy(&sListLock);
|
mutex_destroy(&sListLock);
|
||||||
put_module(NET_STACK_MODULE_NAME);
|
put_module(NET_STACK_MODULE_NAME);
|
||||||
|
|
||||||
|
remove_debugger_command("btLocalDevices", &dump_bluetooth_devices);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user