Bluez Upgrade: Add Bluez 5.43 open source code.
[platform/upstream/bluez.git] / monitor / intel.c
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2011-2014  Intel Corporation
6  *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
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.
13  *
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.
18  *
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
22  *
23  */
24
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
28
29 #include <stdio.h>
30 #include <inttypes.h>
31
32 #include "lib/bluetooth.h"
33 #include "lib/hci.h"
34
35 #include "src/shared/util.h"
36 #include "display.h"
37 #include "packet.h"
38 #include "lmp.h"
39 #include "ll.h"
40 #include "vendor.h"
41 #include "intel.h"
42
43 #define COLOR_UNKNOWN_EVENT_MASK        COLOR_WHITE_BG
44 #define COLOR_UNKNOWN_SCAN_STATUS       COLOR_WHITE_BG
45
46 static void print_status(uint8_t status)
47 {
48         packet_print_error("Status", status);
49 }
50
51 static void print_module(uint8_t module)
52 {
53         const char *str;
54
55         switch (module) {
56         case 0x01:
57                 str = "BC";
58                 break;
59         case 0x02:
60                 str = "HCI";
61                 break;
62         case 0x03:
63                 str = "LLC";
64                 break;
65         case 0x04:
66                 str = "OS";
67                 break;
68         case 0x05:
69                 str = "LM";
70                 break;
71         case 0x06:
72                 str = "SC";
73                 break;
74         case 0x07:
75                 str = "SP";
76                 break;
77         case 0x08:
78                 str = "OSAL";
79                 break;
80         case 0x09:
81                 str = "LC";
82                 break;
83         case 0x0a:
84                 str = "APP";
85                 break;
86         case 0x0b:
87                 str = "TLD";
88                 break;
89         case 0xf0:
90                 str = "Debug";
91                 break;
92         default:
93                 str = "Reserved";
94                 break;
95         }
96
97         print_field("Module: %s (0x%2.2x)", str, module);
98 }
99
100 static void null_cmd(const void *data, uint8_t size)
101 {
102 }
103
104 static void status_rsp(const void *data, uint8_t size)
105 {
106         uint8_t status = get_u8(data);
107
108         print_status(status);
109 }
110
111 static void reset_cmd(const void *data, uint8_t size)
112 {
113         uint8_t reset_type = get_u8(data);
114         uint8_t patch_enable = get_u8(data + 1);
115         uint8_t ddc_reload = get_u8(data + 2);
116         uint8_t boot_option = get_u8(data + 3);
117         uint32_t boot_addr = get_le32(data + 4);
118         const char *str;
119
120         switch (reset_type) {
121         case 0x00:
122                 str = "Soft software reset";
123                 break;
124         case 0x01:
125                 str = "Hard software reset";
126                 break;
127         default:
128                 str = "Reserved";
129                 break;
130         }
131
132         print_field("Reset type: %s (0x%2.2x)", str, reset_type);
133
134         switch (patch_enable) {
135         case 0x00:
136                 str = "Do not enable";
137                 break;
138         case 0x01:
139                 str = "Enable";
140                 break;
141         default:
142                 str = "Reserved";
143                 break;
144         }
145
146         print_field("Patch vectors: %s (0x%2.2x)", str, patch_enable);
147
148         switch (ddc_reload) {
149         case 0x00:
150                 str = "Do not reload";
151                 break;
152         case 0x01:
153                 str = "Reload from OTP";
154                 break;
155         default:
156                 str = "Reserved";
157                 break;
158         }
159
160         print_field("DDC parameters: %s (0x%2.2x)", str, ddc_reload);
161
162         switch (boot_option) {
163         case 0x00:
164                 str = "Current image";
165                 break;
166         case 0x01:
167                 str = "Specified address";
168                 break;
169         default:
170                 str = "Reserved";
171                 break;
172         }
173
174         print_field("Boot option: %s (0x%2.2x)", str, boot_option);
175         print_field("Boot address: 0x%8.8x", boot_addr);
176 }
177
178 static void read_version_rsp(const void *data, uint8_t size)
179 {
180         uint8_t status = get_u8(data);
181         uint8_t hw_platform = get_u8(data + 1);
182         uint8_t hw_variant = get_u8(data + 2);
183         uint8_t hw_revision = get_u8(data + 3);
184         uint8_t fw_variant = get_u8(data + 4);
185         uint8_t fw_revision = get_u8(data + 5);
186         uint8_t fw_build_nn = get_u8(data + 6);
187         uint8_t fw_build_cw = get_u8(data + 7);
188         uint8_t fw_build_yy = get_u8(data + 8);
189         uint8_t fw_patch = get_u8(data + 9);
190
191         print_status(status);
192         print_field("Hardware platform: 0x%2.2x", hw_platform);
193         print_field("Hardware variant: 0x%2.2x", hw_variant);
194         print_field("Hardware revision: %u.%u", hw_revision >> 4,
195                                                 hw_revision & 0x0f);
196         print_field("Firmware variant: 0x%2.2x", fw_variant);
197         print_field("Firmware revision: %u.%u", fw_revision >> 4,
198                                                 fw_revision & 0x0f);
199
200         print_field("Firmware build: %u-%u.%u", fw_build_nn,
201                                         fw_build_cw, 2000 + fw_build_yy);
202         print_field("Firmware patch: %u", fw_patch);
203 }
204
205 static void secure_send_cmd(const void *data, uint8_t size)
206 {
207         uint8_t type = get_u8(data);
208         const char *str;
209
210         switch (type) {
211         case 0x00:
212                 str = "Init";
213                 break;
214         case 0x01:
215                 str = "Data";
216                 break;
217         case 0x02:
218                 str = "Sign";
219                 break;
220         case 0x03:
221                 str = "PKey";
222                 break;
223         default:
224                 str = "Reserved";
225                 break;
226         }
227
228         print_field("Type: %s fragment (0x%2.2x)", str, type);
229
230         packet_hexdump(data + 1, size - 1);
231 }
232
233 static void manufacturer_mode_cmd(const void *data, uint8_t size)
234 {
235         uint8_t mode = get_u8(data);
236         uint8_t reset = get_u8(data + 1);
237         const char *str;
238
239         switch (mode) {
240         case 0x00:
241                 str = "Disabled";
242                 break;
243         case 0x01:
244                 str = "Enabled";
245                 break;
246         default:
247                 str = "Reserved";
248                 break;
249         }
250
251         print_field("Mode switch: %s (0x%2.2x)", str, mode);
252
253         switch (reset) {
254         case 0x00:
255                 str = "No reset";
256                 break;
257         case 0x01:
258                 str = "Reset and deactivate patches";
259                 break;
260         case 0x02:
261                 str = "Reset and activate patches";
262                 break;
263         default:
264                 str = "Reserved";
265                 break;
266         }
267
268         print_field("Reset behavior: %s (0x%2.2x)", str, reset);
269 }
270
271 static void write_bd_data_cmd(const void *data, uint8_t size)
272 {
273         uint8_t features[8];
274
275         packet_print_addr("Address", data, false);
276         packet_hexdump(data + 6, 6);
277
278         memcpy(features, data + 12, 8);
279         packet_print_features_lmp(features, 0);
280
281         memcpy(features, data + 20, 1);
282         memset(features + 1, 0, 7);
283         packet_print_features_ll(features);
284
285         packet_hexdump(data + 21, size - 21);
286 }
287
288 static void read_bd_data_rsp(const void *data, uint8_t size)
289 {
290         uint8_t status = get_u8(data);
291
292         print_status(status);
293         packet_print_addr("Address", data + 1, false);
294         packet_hexdump(data + 7, size - 7);
295 }
296
297 static void write_bd_address_cmd(const void *data, uint8_t size)
298 {
299         packet_print_addr("Address", data, false);
300 }
301
302 static void act_deact_traces_cmd(const void *data, uint8_t size)
303 {
304         uint8_t tx = get_u8(data);
305         uint8_t tx_arq = get_u8(data + 1);
306         uint8_t rx = get_u8(data + 2);
307
308         print_field("Transmit traces: 0x%2.2x", tx);
309         print_field("Transmit ARQ: 0x%2.2x", tx_arq);
310         print_field("Receive traces: 0x%2.2x", rx);
311 }
312
313 static void stimulate_exception_cmd(const void *data, uint8_t size)
314 {
315         uint8_t type = get_u8(data);
316         const char *str;
317
318         switch (type) {
319         case 0x00:
320                 str = "Fatal Exception";
321                 break;
322         case 0x01:
323                 str = "Debug Exception";
324                 break;
325         default:
326                 str = "Reserved";
327                 break;
328         }
329
330         print_field("Type: %s (0x%2.2x)", str, type);
331 }
332
333 static const struct {
334         uint8_t bit;
335         const char *str;
336 } events_table[] = {
337         {  0, "Bootup"                  },
338         {  1, "SCO Rejected via LMP"    },
339         {  2, "PTT Switch Notification" },
340         {  7, "Scan Status"             },
341         {  9, "Debug Exception"         },
342         { 10, "Fatal Exception"         },
343         { 11, "System Exception"        },
344         { 13, "LE Link Established"     },
345         { 14, "FW Trace String"         },
346         { }
347 };
348
349 static void set_event_mask_cmd(const void *data, uint8_t size)
350 {
351         const uint8_t *events_array = data;
352         uint64_t mask, events = 0;
353         int i;
354
355         for (i = 0; i < 8; i++)
356                 events |= ((uint64_t) events_array[i]) << (i * 8);
357
358         print_field("Mask: 0x%16.16" PRIx64, events);
359
360         mask = events;
361
362         for (i = 0; events_table[i].str; i++) {
363                 if (events & (((uint64_t) 1) << events_table[i].bit)) {
364                         print_field("  %s", events_table[i].str);
365                         mask &= ~(((uint64_t) 1) << events_table[i].bit);
366                 }
367         }
368
369         if (mask)
370                 print_text(COLOR_UNKNOWN_EVENT_MASK, "  Unknown mask "
371                                                 "(0x%16.16" PRIx64 ")", mask);
372 }
373
374 static void ddc_config_write_cmd(const void *data, uint8_t size)
375 {
376         while (size > 0) {
377                 uint8_t param_len = get_u8(data);
378                 uint16_t param_id = get_le16(data + 1);
379
380                 print_field("Identifier: 0x%4.4x", param_id);
381                 packet_hexdump(data + 2, param_len - 2);
382
383                 data += param_len + 1;
384                 size -= param_len + 1;
385         }
386 }
387
388 static void ddc_config_write_rsp(const void *data, uint8_t size)
389 {
390         uint8_t status = get_u8(data);
391         uint16_t param_id = get_le16(data + 1);
392
393         print_status(status);
394         print_field("Identifier: 0x%4.4x", param_id);
395 }
396
397 static void memory_write_cmd(const void *data, uint8_t size)
398 {
399         uint32_t addr = get_le32(data);
400         uint8_t mode = get_u8(data + 4);
401         uint8_t length = get_u8(data + 5);
402         const char *str;
403
404         print_field("Address: 0x%8.8x", addr);
405
406         switch (mode) {
407         case 0x00:
408                 str = "Byte access";
409                 break;
410         case 0x01:
411                 str = "Half word access";
412                 break;
413         case 0x02:
414                 str = "Word access";
415                 break;
416         default:
417                 str = "Reserved";
418                 break;
419         }
420
421         print_field("Mode: %s (0x%2.2x)", str, mode);
422         print_field("Length: %u", length);
423
424         packet_hexdump(data + 6, size - 6);
425 }
426
427 static const struct vendor_ocf vendor_ocf_table[] = {
428         { 0x001, "Reset",
429                         reset_cmd, 8, true,
430                         status_rsp, 1, true },
431         { 0x002, "No Operation" },
432         { 0x005, "Read Version",
433                         null_cmd, 0, true,
434                         read_version_rsp, 10, true },
435         { 0x006, "Set UART Baudrate" },
436         { 0x007, "Enable LPM" },
437         { 0x008, "PCM Write Configuration" },
438         { 0x009, "Secure Send",
439                         secure_send_cmd, 1, false,
440                         status_rsp, 1, true },
441         { 0x00d, "Read Secure Boot Params",
442                         null_cmd, 0, true },
443         { 0x00e, "Write Secure Boot Params" },
444         { 0x00f, "Unlock" },
445         { 0x010, "Change UART Baudrate" },
446         { 0x011, "Manufacturer Mode",
447                         manufacturer_mode_cmd, 2, true,
448                         status_rsp, 1, true },
449         { 0x012, "Read Link RSSI" },
450         { 0x022, "Get Exception Info" },
451         { 0x024, "Clear Exception Info" },
452         { 0x02f, "Write BD Data",
453                         write_bd_data_cmd, 6, false },
454         { 0x030, "Read BD Data",
455                         null_cmd, 0, true,
456                         read_bd_data_rsp, 7, false },
457         { 0x031, "Write BD Address",
458                         write_bd_address_cmd, 6, true,
459                         status_rsp, 1, true },
460         { 0x032, "Flow Specification" },
461         { 0x034, "Read Secure ID" },
462         { 0x038, "Set Synchronous USB Interface Type" },
463         { 0x039, "Config Synchronous Interface" },
464         { 0x03f, "SW RF Kill",
465                         null_cmd, 0, true,
466                         status_rsp, 1, true },
467         { 0x043, "Activate Deactivate Traces",
468                         act_deact_traces_cmd, 3, true },
469         { 0x04d, "Stimulate Exception",
470                         stimulate_exception_cmd, 1, true,
471                         status_rsp, 1, true },
472         { 0x050, "Read HW Version" },
473         { 0x052, "Set Event Mask",
474                         set_event_mask_cmd, 8, true,
475                         status_rsp, 1, true },
476         { 0x053, "Config_Link_Controller" },
477         { 0x089, "DDC Write" },
478         { 0x08a, "DDC Read" },
479         { 0x08b, "DDC Config Write",
480                         ddc_config_write_cmd, 3, false,
481                         ddc_config_write_rsp, 3, true },
482         { 0x08c, "DDC Config Read" },
483         { 0x08d, "Memory Read" },
484         { 0x08e, "Memory Write",
485                         memory_write_cmd, 6, false,
486                         status_rsp, 1, true },
487         { }
488 };
489
490 const struct vendor_ocf *intel_vendor_ocf(uint16_t ocf)
491 {
492         int i;
493
494         for (i = 0; vendor_ocf_table[i].str; i++) {
495                 if (vendor_ocf_table[i].ocf == ocf)
496                         return &vendor_ocf_table[i];
497         }
498
499         return NULL;
500 }
501
502 static void startup_evt(const void *data, uint8_t size)
503 {
504 }
505
506 static void fatal_exception_evt(const void *data, uint8_t size)
507 {
508         uint16_t line = get_le16(data);
509         uint8_t module = get_u8(data + 2);
510         uint8_t reason = get_u8(data + 3);
511
512         print_field("Line: %u", line);
513         print_module(module);
514         print_field("Reason: 0x%2.2x", reason);
515 }
516
517 static void bootup_evt(const void *data, uint8_t size)
518 {
519         uint8_t zero = get_u8(data);
520         uint8_t num_packets = get_u8(data + 1);
521         uint8_t source = get_u8(data + 2);
522         uint8_t reset_type = get_u8(data + 3);
523         uint8_t reset_reason = get_u8(data + 4);
524         uint8_t ddc_status = get_u8(data + 5);
525         const char *str;
526
527         print_field("Zero: 0x%2.2x", zero);
528         print_field("Number of packets: %d", num_packets);
529
530         switch (source) {
531         case 0x00:
532                 str = "Bootloader";
533                 break;
534         case 0x01:
535                 str = "Operational firmware";
536                 break;
537         case 0x02:
538                 str = "Self test firmware";
539                 break;
540         default:
541                 str = "Reserved";
542                 break;
543         }
544
545         print_field("Source: %s (0x%2.2x)", str, source);
546
547         switch (reset_type) {
548         case 0x00:
549                 str = "Hardware reset";
550                 break;
551         case 0x01:
552                 str = "Soft watchdog reset";
553                 break;
554         case 0x02:
555                 str = "Soft software reset";
556                 break;
557         case 0x03:
558                 str = "Hard watchdog reset";
559                 break;
560         case 0x04:
561                 str = "Hard software reset";
562                 break;
563         default:
564                 str = "Reserved";
565                 break;
566         }
567
568         print_field("Reset type: %s (0x%2.2x)", str, reset_type);
569
570         switch (reset_reason) {
571         case 0x00:
572                 str = "Power on";
573                 break;
574         case 0x01:
575                 str = "Reset command";
576                 break;
577         case 0x02:
578                 str = "Intel reset command";
579                 break;
580         case 0x03:
581                 str = "Watchdog";
582                 break;
583         case 0x04:
584                 str = "Fatal exception";
585                 break;
586         case 0x05:
587                 str = "System exception";
588                 break;
589         case 0xff:
590                 str = "Unknown";
591                 break;
592         default:
593                 str = "Reserved";
594                 break;
595         }
596
597         print_field("Reset reason: %s (0x%2.2x)", str, reset_reason);
598
599         switch (ddc_status) {
600         case 0x00:
601                 str = "Firmware default";
602                 break;
603         case 0x01:
604                 str = "Firmware default plus OTP";
605                 break;
606         case 0x02:
607                 str = "Persistent RAM";
608                 break;
609         case 0x03:
610                 str = "Not used";
611                 break;
612         default:
613                 str = "Reserved";
614                 break;
615         }
616
617         print_field("DDC status: %s (0x%2.2x)", str, ddc_status);
618 }
619
620 static void default_bd_data_evt(const void *data, uint8_t size)
621 {
622         uint8_t mem_status = get_u8(data);
623         const char *str;
624
625         switch (mem_status) {
626         case 0x02:
627                 str = "Invalid manufacturing data";
628                 break;
629         default:
630                 str = "Reserved";
631                 break;
632         }
633
634         print_field("Memory status: %s (0x%2.2x)", str, mem_status);
635 }
636
637 static void secure_send_commands_result_evt(const void *data, uint8_t size)
638 {
639         uint8_t result = get_u8(data);
640         uint16_t opcode = get_le16(data + 1);
641         uint16_t ogf = cmd_opcode_ogf(opcode);
642         uint16_t ocf = cmd_opcode_ocf(opcode);
643         uint8_t status = get_u8(data + 3);
644         const char *str;
645
646         switch (result) {
647         case 0x00:
648                 str = "Success";
649                 break;
650         case 0x01:
651                 str = "General failure";
652                 break;
653         case 0x02:
654                 str = "Hardware failure";
655                 break;
656         case 0x03:
657                 str = "Signature verification failed";
658                 break;
659         case 0x04:
660                 str = "Parsing error of command buffer";
661                 break;
662         case 0x05:
663                 str = "Command execution failure";
664                 break;
665         case 0x06:
666                 str = "Command parameters error";
667                 break;
668         case 0x07:
669                 str = "Command missing";
670                 break;
671         default:
672                 str = "Reserved";
673                 break;
674         }
675
676         print_field("Result: %s (0x%2.2x)", str, result);
677         print_field("Opcode: 0x%4.4x (0x%2.2x|0x%4.4x)", opcode, ogf, ocf);
678         print_status(status);
679 }
680
681 static void debug_exception_evt(const void *data, uint8_t size)
682 {
683         uint16_t line = get_le16(data);
684         uint8_t module = get_u8(data + 2);
685         uint8_t reason = get_u8(data + 3);
686
687         print_field("Line: %u", line);
688         print_module(module);
689         print_field("Reason: 0x%2.2x", reason);
690 }
691
692 static void le_link_established_evt(const void *data, uint8_t size)
693 {
694         uint16_t handle = get_le16(data);
695         uint32_t access_addr = get_le32(data + 10);
696
697         print_field("Handle: %u", handle);
698
699         packet_hexdump(data + 2, 8);
700
701         print_field("Access address: 0x%8.8x", access_addr);
702
703         packet_hexdump(data + 14, size - 14);
704 }
705
706 static void scan_status_evt(const void *data, uint8_t size)
707 {
708         uint8_t enable = get_u8(data);
709
710         print_field("Inquiry scan: %s",
711                                 (enable & 0x01) ? "Enabled" : "Disabled");
712         print_field("Page scan: %s",
713                                 (enable & 0x02) ? "Enabled" : "Disabled");
714
715         if (enable & 0xfc)
716                 print_text(COLOR_UNKNOWN_SCAN_STATUS,
717                                 "  Unknown status (0x%2.2x)", enable & 0xfc);
718
719 }
720
721 static void act_deact_traces_complete_evt(const void *data, uint8_t size)
722 {
723         uint8_t status = get_u8(data);
724
725         print_status(status);
726 }
727
728 static void lmp_pdu_trace_evt(const void *data, uint8_t size)
729 {
730         uint8_t type, len, id;
731         uint16_t handle, count;
732         uint32_t clock;
733         const char *str;
734
735         type = get_u8(data);
736         handle = get_le16(data + 1);
737
738         switch (type) {
739         case 0x00:
740                 str = "RX LMP";
741                 break;
742         case 0x01:
743                 str = "TX LMP";
744                 break;
745         case 0x02:
746                 str = "ACK LMP";
747                 break;
748         case 0x03:
749                 str = "RX LL";
750                 break;
751         case 0x04:
752                 str = "TX LL";
753                 break;
754         case 0x05:
755                 str = "ACK LL";
756                 break;
757         default:
758                 str = "Unknown";
759                 break;
760         }
761
762         print_field("Type: %s (0x%2.2x)", str, type);
763         print_field("Handle: %u", handle);
764
765         switch (type) {
766         case 0x00:
767                 len = size - 8;
768                 clock = get_le32(data + 4 + len);
769
770                 packet_hexdump(data + 3, 1);
771                 lmp_packet(data + 4, len, false);
772                 print_field("Clock: 0x%8.8x", clock);
773                 break;
774         case 0x01:
775                 len = size - 9;
776                 clock = get_le32(data + 4 + len);
777                 id = get_u8(data + 4 + len + 4);
778
779                 packet_hexdump(data + 3, 1);
780                 lmp_packet(data + 4, len, false);
781                 print_field("Clock: 0x%8.8x", clock);
782                 print_field("ID: 0x%2.2x", id);
783                 break;
784         case 0x02:
785                 clock = get_le32(data + 3);
786                 id = get_u8(data + 3 + 4);
787
788                 print_field("Clock: 0x%8.8x", clock);
789                 print_field("ID: 0x%2.2x", id);
790                 break;
791         case 0x03:
792                 len = size - 8;
793                 count = get_le16(data + 3);
794
795                 print_field("Count: 0x%4.4x", count);
796                 packet_hexdump(data + 3 + 2 + 1, 2);
797                 llcp_packet(data + 8, len, false);
798                 break;
799         case 0x04:
800                 len = size - 8;
801                 count = get_le16(data + 3);
802                 id = get_u8(data + 3 + 2);
803
804                 print_field("Count: 0x%4.4x", count);
805                 print_field("ID: 0x%2.2x", id);
806                 packet_hexdump(data + 3 + 2 + 1, 2);
807                 llcp_packet(data + 8, len, false);
808                 break;
809         case 0x05:
810                 count = get_le16(data + 3);
811                 id = get_u8(data + 3 + 2);
812
813                 print_field("Count: 0x%4.4x", count);
814                 print_field("ID: 0x%2.2x", id);
815                 break;
816         default:
817                 packet_hexdump(data + 3, size - 3);
818                 break;
819         }
820 }
821
822 static void write_bd_data_complete_evt(const void *data, uint8_t size)
823 {
824         uint8_t status = get_u8(data);
825
826         print_status(status);
827 }
828
829 static void sco_rejected_via_lmp_evt(const void *data, uint8_t size)
830 {
831         uint8_t reason = get_u8(data + 6);
832
833         packet_print_addr("Address", data, false);
834         packet_print_error("Reason", reason);
835 }
836
837 static void ptt_switch_notification_evt(const void *data, uint8_t size)
838 {
839         uint16_t handle = get_le16(data);
840         uint8_t table = get_u8(data + 2);
841         const char *str;
842
843         print_field("Handle: %u", handle);
844
845         switch (table) {
846         case 0x00:
847                 str = "Basic rate";
848                 break;
849         case 0x01:
850                 str = "Enhanced data rate";
851                 break;
852         default:
853                 str = "Reserved";
854                 break;
855         }
856
857         print_field("Packet type table: %s (0x%2.2x)", str, table);
858 }
859
860 static void system_exception_evt(const void *data, uint8_t size)
861 {
862         uint8_t type = get_u8(data);
863         const char *str;
864
865         switch (type) {
866         case 0x00:
867                 str = "No Exception";
868                 break;
869         case 0x01:
870                 str = "Undefined Instruction";
871                 break;
872         case 0x02:
873                 str = "Prefetch abort";
874                 break;
875         case 0x03:
876                 str = "Data abort";
877                 break;
878         default:
879                 str = "Reserved";
880                 break;
881         }
882
883         print_field("Type: %s (0x%2.2x)", str, type);
884
885         packet_hexdump(data + 1, size - 1);
886 }
887
888 static const struct vendor_evt vendor_evt_table[] = {
889         { 0x00, "Startup",
890                         startup_evt, 0, true },
891         { 0x01, "Fatal Exception",
892                         fatal_exception_evt, 4, true },
893         { 0x02, "Bootup",
894                         bootup_evt, 6, true },
895         { 0x05, "Default BD Data",
896                         default_bd_data_evt, 1, true },
897         { 0x06, "Secure Send Commands Result",
898                         secure_send_commands_result_evt, 4, true },
899         { 0x08, "Debug Exception",
900                         debug_exception_evt, 4, true },
901         { 0x0f, "LE Link Established",
902                         le_link_established_evt, 26, true },
903         { 0x11, "Scan Status",
904                         scan_status_evt, 1, true },
905         { 0x16, "Activate Deactivate Traces Complete",
906                         act_deact_traces_complete_evt, 1, true },
907         { 0x17, "LMP PDU Trace",
908                         lmp_pdu_trace_evt, 3, false },
909         { 0x19, "Write BD Data Complete",
910                         write_bd_data_complete_evt, 1, true },
911         { 0x25, "SCO Rejected via LMP",
912                         sco_rejected_via_lmp_evt, 7, true },
913         { 0x26, "PTT Switch Notification",
914                         ptt_switch_notification_evt, 3, true },
915         { 0x29, "System Exception",
916                         system_exception_evt, 133, true },
917         { 0x2c, "FW Trace String" },
918         { 0x2e, "FW Trace Binary" },
919         { }
920 };
921
922 const struct vendor_evt *intel_vendor_evt(uint8_t evt)
923 {
924         int i;
925
926         for (i = 0; vendor_evt_table[i].str; i++) {
927                 if (vendor_evt_table[i].evt == evt)
928                         return &vendor_evt_table[i];
929         }
930
931         return NULL;
932 }