diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-10-18 21:45:39 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-10-18 21:59:53 +0200 |
commit | a11313666371fb395d64c093efc63525323b706e (patch) | |
tree | 9b64ae6a7a6f17489288b0add9dec5f1261d9f94 /monitor/broadcom.c | |
parent | 37491f88394d4d7e26ed9a2f718fdd4f7710f186 (diff) | |
download | bluez-a11313666371fb395d64c093efc63525323b706e.tar.gz |
monitor: Update handling for vendor commands and events
Diffstat (limited to 'monitor/broadcom.c')
-rw-r--r-- | monitor/broadcom.c | 146 |
1 files changed, 136 insertions, 10 deletions
diff --git a/monitor/broadcom.c b/monitor/broadcom.c index 7c76b97a9..a3c344398 100644 --- a/monitor/broadcom.c +++ b/monitor/broadcom.c @@ -36,17 +36,127 @@ #include "vendor.h" #include "broadcom.h" +static void print_status(uint8_t status) +{ + packet_print_error("Status", status); +} + +static void null_cmd(const void *data, uint8_t size) +{ +} + +static void status_rsp(const void *data, uint8_t size) +{ + uint8_t status = get_u8(data); + + print_status(status); +} + +static void write_bd_addr_cmd(const void *data, uint8_t size) +{ + packet_print_addr("Address", data, false); +} + +static void enable_usb_hid_emulation_cmd(const void *data, uint8_t size) +{ + uint8_t enable = get_u8(data); + const char *str; + + switch (enable) { + case 0x00: + str = "Bluetooth mode"; + break; + case 0x01: + str = "HID Mode"; + break; + default: + str = "Reserved"; + break; + } + + print_field("Enable: %s (0x%2.2x)", str, enable); +} + +static void write_ram_cmd(const void *data, uint8_t size) +{ + uint32_t addr = get_le32(data); + + print_field("Address: 0x%8.8x", addr); + + packet_hexdump(data + 4, size - 4); +} + +static void launch_ram_cmd(const void *data, uint8_t size) +{ + uint32_t addr = get_le32(data); + + print_field("Address: 0x%8.8x", addr); +} + +static void read_vid_pid_rsp(const void *data, uint8_t size) +{ + uint8_t status = get_u8(data); + uint16_t vid = get_le16(data + 1); + uint16_t pid = get_le16(data + 3); + + print_status(status); + print_field("Product: %4.4x:%4.4x", vid, pid); +} + +static void read_verbose_version_info_rsp(const void *data, uint8_t size) +{ + uint8_t status = get_u8(data); + uint8_t chip_id = get_u8(data + 1); + uint8_t target_id = get_u8(data + 2); + uint16_t build_base = get_le16(data + 3); + uint16_t build_num = get_le16(data + 5); + const char *str; + + print_status(status); + print_field("Chip ID: %u (0x%2.2x)", chip_id, chip_id); + + switch (target_id) { + case 254: + str = "Invalid"; + break; + case 255: + str = "Undefined"; + break; + default: + str = "Reserved"; + break; + } + + print_field("Build target: %s (%u)", str, target_id); + print_field("Build baseline: %u (0x%4.4x)", build_base, build_base); + print_field("Build number: %u (0x%4.4x)", build_num, build_num); +} + static const struct vendor_ocf vendor_ocf_table[] = { - { 0x001, "Write BD ADDR" }, - { 0x018, "Update UART Baud Rate" }, - { 0x027, "Set Sleepmode Param" }, - { 0x02e, "Download Minidriver" }, - { 0x03b, "Enable USB HID Emulation" }, - { 0x045, "Write UART Clock Setting" }, - { 0x04c, "Write RAM" }, - { 0x04e, "Launch RAM" }, - { 0x05a, "Read VID PID" }, - { 0x079, "Read Verbose Config Version Info" }, + { 0x001, "Write BD ADDR", + write_bd_addr_cmd, 6, true, + status_rsp, 1, true }, + { 0x018, "Update UART Baud Rate" }, + { 0x027, "Set Sleepmode Param" }, + { 0x02e, "Download Minidriver", + null_cmd, 0, true, + status_rsp, 1, true }, + { 0x03b, "Enable USB HID Emulation", + enable_usb_hid_emulation_cmd, 1, true, + status_rsp, 1, true }, + { 0x045, "Write UART Clock Setting" }, + { 0x04c, "Write RAM", + write_ram_cmd, 4, false, + status_rsp, 1, true }, + { 0x04e, "Launch RAM", + launch_ram_cmd, 4, true, + status_rsp, 1, true }, + { 0x05a, "Read VID PID", + null_cmd, 0, true, + read_vid_pid_rsp, 5, true }, + { 0x079, "Read Verbose Config Version Info", + null_cmd, 0, true, + read_verbose_version_info_rsp, 7, true }, { } }; @@ -123,3 +233,19 @@ void broadcom_lm_diag(const void *data, uint8_t size) break; } } + +static const struct vendor_evt vendor_evt_table[] = { + { } +}; + +const struct vendor_evt *broadcom_vendor_evt(uint8_t evt) +{ + int i; + + for (i = 0; vendor_evt_table[i].str; i++) { + if (vendor_evt_table[i].evt == evt) + return &vendor_evt_table[i]; + } + + return NULL; +} |