~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/bt.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-22 10:13:17 UTC
  • mfrom: (1.2.1 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090322101317-iigjtnu5qil35dtb
Tags: 0.10.1-1
[ Aurelien Jarno ]
* New upstream stable release:
  - patches/80_stable-branch.patch: remove.
* debian/control: 
  - Remove depends on proll.
  - Move depends on device-tree-compiler to build-depends.
  - Bump Standards-Version to 3.8.1 (no changes).
* patches/82_qemu-img_decimal.patch: new patch from upstream to make
  qemu-img accept sizes with decimal values (closes: bug#501400).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Convenience functions for bluetooth.
 
3
 *
 
4
 * Copyright (C) 2008 Andrzej Zaborowski  <balrog@zabor.org>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License as
 
8
 * published by the Free Software Foundation; either version 2 or
 
9
 * (at your option) version 3 of the License.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License along
 
17
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
19
 */
 
20
 
 
21
#include "qemu-common.h"
 
22
#include "net.h"
 
23
#include "bt.h"
 
24
 
 
25
/* Slave implementations can ignore this */
 
26
static void bt_dummy_lmp_mode_change(struct bt_link_s *link)
 
27
{
 
28
}
 
29
 
 
30
/* Slaves should never receive these PDUs */
 
31
static void bt_dummy_lmp_connection_complete(struct bt_link_s *link)
 
32
{
 
33
    if (link->slave->reject_reason)
 
34
        fprintf(stderr, "%s: stray LMP_not_accepted received, fixme\n",
 
35
                        __FUNCTION__);
 
36
    else
 
37
        fprintf(stderr, "%s: stray LMP_accepted received, fixme\n",
 
38
                        __FUNCTION__);
 
39
    exit(-1);
 
40
}
 
41
 
 
42
static void bt_dummy_lmp_disconnect_master(struct bt_link_s *link)
 
43
{
 
44
    fprintf(stderr, "%s: stray LMP_detach received, fixme\n", __FUNCTION__);
 
45
    exit(-1);
 
46
}
 
47
 
 
48
static void bt_dummy_lmp_acl_resp(struct bt_link_s *link,
 
49
                const uint8_t *data, int start, int len)
 
50
{
 
51
    fprintf(stderr, "%s: stray ACL response PDU, fixme\n", __FUNCTION__);
 
52
    exit(-1);
 
53
}
 
54
 
 
55
/* Slaves that don't hold any additional per link state can use these */
 
56
static void bt_dummy_lmp_connection_request(struct bt_link_s *req)
 
57
{
 
58
    struct bt_link_s *link = qemu_mallocz(sizeof(struct bt_link_s));
 
59
 
 
60
    link->slave = req->slave;
 
61
    link->host = req->host;
 
62
 
 
63
    req->host->reject_reason = 0;
 
64
    req->host->lmp_connection_complete(link);
 
65
}
 
66
 
 
67
static void bt_dummy_lmp_disconnect_slave(struct bt_link_s *link)
 
68
{
 
69
    qemu_free(link);
 
70
}
 
71
 
 
72
static void bt_dummy_destroy(struct bt_device_s *device)
 
73
{
 
74
    bt_device_done(device);
 
75
    qemu_free(device);
 
76
}
 
77
 
 
78
static int bt_dev_idx = 0;
 
79
 
 
80
void bt_device_init(struct bt_device_s *dev, struct bt_scatternet_s *net)
 
81
{
 
82
    memset(dev, 0, sizeof(*dev));
 
83
    dev->inquiry_scan = 1;
 
84
    dev->page_scan = 1;
 
85
 
 
86
    dev->bd_addr.b[0] = bt_dev_idx & 0xff;
 
87
    dev->bd_addr.b[1] = bt_dev_idx >> 8;
 
88
    dev->bd_addr.b[2] = 0xd0;
 
89
    dev->bd_addr.b[3] = 0xba;
 
90
    dev->bd_addr.b[4] = 0xbe;
 
91
    dev->bd_addr.b[5] = 0xba;
 
92
    bt_dev_idx ++;
 
93
 
 
94
    /* Simple slave-only devices need to implement only .lmp_acl_data */
 
95
    dev->lmp_connection_complete = bt_dummy_lmp_connection_complete;
 
96
    dev->lmp_disconnect_master = bt_dummy_lmp_disconnect_master;
 
97
    dev->lmp_acl_resp = bt_dummy_lmp_acl_resp;
 
98
    dev->lmp_mode_change = bt_dummy_lmp_mode_change;
 
99
    dev->lmp_connection_request = bt_dummy_lmp_connection_request;
 
100
    dev->lmp_disconnect_slave = bt_dummy_lmp_disconnect_slave;
 
101
 
 
102
    dev->handle_destroy = bt_dummy_destroy;
 
103
 
 
104
    dev->net = net;
 
105
    dev->next = net->slave;
 
106
    net->slave = dev;
 
107
}
 
108
 
 
109
void bt_device_done(struct bt_device_s *dev)
 
110
{
 
111
    struct bt_device_s **p = &dev->net->slave;
 
112
 
 
113
    while (*p && *p != dev)
 
114
        p = &(*p)->next;
 
115
    if (*p != dev) {
 
116
        fprintf(stderr, "%s: bad bt device \"%s\"\n", __FUNCTION__,
 
117
                        dev->lmp_name ?: "(null)");
 
118
        exit(-1);
 
119
    }
 
120
 
 
121
    *p = dev->next;
 
122
}