3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2011-2014 Intel Corporation
6 * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "src/shared/util.h"
39 static void print_status(uint8_t status)
41 packet_print_error("Status", status);
44 static void null_cmd(const void *data, uint8_t size)
48 static void status_rsp(const void *data, uint8_t size)
50 uint8_t status = get_u8(data);
55 static void write_bd_addr_cmd(const void *data, uint8_t size)
57 packet_print_addr("Address", data, false);
60 static void enable_usb_hid_emulation_cmd(const void *data, uint8_t size)
62 uint8_t enable = get_u8(data);
67 str = "Bluetooth mode";
77 print_field("Enable: %s (0x%2.2x)", str, enable);
80 static void write_ram_cmd(const void *data, uint8_t size)
82 uint32_t addr = get_le32(data);
84 print_field("Address: 0x%8.8x", addr);
86 packet_hexdump(data + 4, size - 4);
89 static void launch_ram_cmd(const void *data, uint8_t size)
91 uint32_t addr = get_le32(data);
93 print_field("Address: 0x%8.8x", addr);
96 static void read_vid_pid_rsp(const void *data, uint8_t size)
98 uint8_t status = get_u8(data);
99 uint16_t vid = get_le16(data + 1);
100 uint16_t pid = get_le16(data + 3);
102 print_status(status);
103 print_field("Product: %4.4x:%4.4x", vid, pid);
106 static void read_verbose_version_info_rsp(const void *data, uint8_t size)
108 uint8_t status = get_u8(data);
109 uint8_t chip_id = get_u8(data + 1);
110 uint8_t target_id = get_u8(data + 2);
111 uint16_t build_base = get_le16(data + 3);
112 uint16_t build_num = get_le16(data + 5);
115 print_status(status);
116 print_field("Chip ID: %u (0x%2.2x)", chip_id, chip_id);
130 print_field("Build target: %s (%u)", str, target_id);
131 print_field("Build baseline: %u (0x%4.4x)", build_base, build_base);
132 print_field("Build number: %u (0x%4.4x)", build_num, build_num);
135 static const struct vendor_ocf vendor_ocf_table[] = {
136 { 0x001, "Write BD ADDR",
137 write_bd_addr_cmd, 6, true,
138 status_rsp, 1, true },
139 { 0x018, "Update UART Baud Rate" },
140 { 0x027, "Set Sleepmode Param" },
141 { 0x02e, "Download Minidriver",
143 status_rsp, 1, true },
144 { 0x03b, "Enable USB HID Emulation",
145 enable_usb_hid_emulation_cmd, 1, true,
146 status_rsp, 1, true },
147 { 0x045, "Write UART Clock Setting" },
148 { 0x04c, "Write RAM",
149 write_ram_cmd, 4, false,
150 status_rsp, 1, true },
151 { 0x04e, "Launch RAM",
152 launch_ram_cmd, 4, true,
153 status_rsp, 1, true },
154 { 0x05a, "Read VID PID",
156 read_vid_pid_rsp, 5, true },
157 { 0x079, "Read Verbose Config Version Info",
159 read_verbose_version_info_rsp, 7, true },
163 const struct vendor_ocf *broadcom_vendor_ocf(uint16_t ocf)
167 for (i = 0; vendor_ocf_table[i].str; i++) {
168 if (vendor_ocf_table[i].ocf == ocf)
169 return &vendor_ocf_table[i];
175 void broadcom_lm_diag(const void *data, uint8_t size)
183 packet_hexdump(data, size);
187 type = *((uint8_t *) data);
188 clock = get_be32(data + 1);
208 print_field("Type: %s (%u)", str, type);
209 print_field("Clock: 0x%8.8x", clock);
214 print_field("Address: --:--:%2.2X:%2.2X:%2.2X:%2.2X",
215 addr[0], addr[1], addr[2], addr[3]);
216 packet_hexdump(data + 9, 1);
217 lmp_packet(data + 10, size - 10, true);
221 print_field("Address: --:--:%2.2X:%2.2X:%2.2X:%2.2X",
222 addr[0], addr[1], addr[2], addr[3]);
223 packet_hexdump(data + 9, 4);
224 lmp_packet(data + 13, size - 13, true);
228 packet_hexdump(data + 5, 7);
229 llcp_packet(data + 12, size - 12, true);
232 packet_hexdump(data + 9, size - 9);
237 static const struct vendor_evt vendor_evt_table[] = {
241 const struct vendor_evt *broadcom_vendor_evt(uint8_t evt)
245 for (i = 0; vendor_evt_table[i].str; i++) {
246 if (vendor_evt_table[i].evt == evt)
247 return &vendor_evt_table[i];