diff options
Diffstat (limited to 'tools/firewire')
-rw-r--r-- | tools/firewire/decode-fcp.c | 364 | ||||
-rw-r--r-- | tools/firewire/list.h | 24 | ||||
-rw-r--r-- | tools/firewire/nosy-dump.c | 1663 | ||||
-rw-r--r-- | tools/firewire/nosy-dump.h | 280 |
4 files changed, 1139 insertions, 1192 deletions
diff --git a/tools/firewire/decode-fcp.c b/tools/firewire/decode-fcp.c index b6b37253761..9cd1550db24 100644 --- a/tools/firewire/decode-fcp.c +++ b/tools/firewire/decode-fcp.c @@ -6,234 +6,206 @@ #define CSR_FCP_COMMAND 0xfffff0000b00ull #define CSR_FCP_RESPONSE 0xfffff0000d00ull -static const char * const ctype_names[16] = { - "control", - "status", - "specific inquiry", - "notify", - "general inquiry", - "(reserved 0x05)", - "(reserved 0x06)", - "(reserved 0x07)", - "not implemented", - "accepted", - "rejected", - "in transition", - "stable", - "changed", - "(reserved 0x0e)", - "interim" +static const char * const ctype_names[] = { + [0x0] = "control", [0x8] = "not implemented", + [0x1] = "status", [0x9] = "accepted", + [0x2] = "specific inquiry", [0xa] = "rejected", + [0x3] = "notify", [0xb] = "in transition", + [0x4] = "general inquiry", [0xc] = "stable", + [0x5] = "(reserved 0x05)", [0xd] = "changed", + [0x6] = "(reserved 0x06)", [0xe] = "(reserved 0x0e)", + [0x7] = "(reserved 0x07)", [0xf] = "interim", }; -static const char * const subunit_type_names[32] = { - "monitor", - "audio", - "printer", - "disc", - "tape recorder/player", - "tuner", - "ca", - "camera", - "(reserved 0x08)", - "panel", - "bulletin board", - "camera storage", - "(reserved 0x0c)", - "(reserved 0x0d)", - "(reserved 0x0e)", - "(reserved 0x0f)", - "(reserved 0x10)", - "(reserved 0x11)", - "(reserved 0x12)", - "(reserved 0x13)", - "(reserved 0x14)", - "(reserved 0x15)", - "(reserved 0x16)", - "(reserved 0x17)", - "(reserved 0x18)", - "(reserved 0x19)", - "(reserved 0x1a)", - "(reserved 0x1b)", - "vendor unique", - "all subunit types", - "subunit_type extended to next byte", - "unit" +static const char * const subunit_type_names[] = { + [0x00] = "monitor", [0x10] = "(reserved 0x10)", + [0x01] = "audio", [0x11] = "(reserved 0x11)", + [0x02] = "printer", [0x12] = "(reserved 0x12)", + [0x03] = "disc", [0x13] = "(reserved 0x13)", + [0x04] = "tape recorder/player",[0x14] = "(reserved 0x14)", + [0x05] = "tuner", [0x15] = "(reserved 0x15)", + [0x06] = "ca", [0x16] = "(reserved 0x16)", + [0x07] = "camera", [0x17] = "(reserved 0x17)", + [0x08] = "(reserved 0x08)", [0x18] = "(reserved 0x18)", + [0x09] = "panel", [0x19] = "(reserved 0x19)", + [0x0a] = "bulletin board", [0x1a] = "(reserved 0x1a)", + [0x0b] = "camera storage", [0x1b] = "(reserved 0x1b)", + [0x0c] = "(reserved 0x0c)", [0x1c] = "vendor unique", + [0x0d] = "(reserved 0x0d)", [0x1d] = "all subunit types", + [0x0e] = "(reserved 0x0e)", [0x1e] = "subunit_type extended to next byte", + [0x0f] = "(reserved 0x0f)", [0x1f] = "unit", }; struct avc_enum { - int value; - const char *name; + int value; + const char *name; }; struct avc_field { - const char *name; /* Short name for field. */ - int offset; /* Location of field, specified in bits. - * Negative means from end of packet */ - int width; /* Width of field, 0 means use data_length. */ - struct avc_enum *names; + const char *name; /* Short name for field. */ + int offset; /* Location of field, specified in bits; */ + /* negative means from end of packet. */ + int width; /* Width of field, 0 means use data_length. */ + struct avc_enum *names; }; struct avc_opcode_info { - const char *name; - struct avc_field fields[8]; + const char *name; + struct avc_field fields[8]; }; struct avc_enum power_field_names[] = { - { 0x70, "on" }, - { 0x60, "off" }, - { } + { 0x70, "on" }, + { 0x60, "off" }, + { } }; static const struct avc_opcode_info opcode_info[256] = { - /* TA Document 1999026 - * AV/C Digital Interface Command Set General Specification - * Version 4.0 */ - [0xb2] = - { "power", { - { "state", 0, 8, power_field_names } - } - }, - [0x30] = - { "unit info", { - { "foo", 0, 8 }, - { "unit_type", 8, 5 }, - { "unit", 13, 3 }, - { "company id", 16, 24 }, - } - }, - [0x31] = { "subunit info" }, - [0x01] = { "reserve" }, - [0xb0] = { "version" }, - [0x00] = { "vendor dependent" }, - - [0x02] = { "plug info" }, - [0x12] = { "channel usage" }, - [0x24] = { "connect" }, - [0x20] = { "connect av" }, - [0x22] = { "connections" }, - [0x11] = { "digital input" }, - [0x10] = { "digital output" }, - [0x25] = { "disconnect" }, - [0x21] = { "disconnect av" }, - [0x19] = { "input plug signal format" }, - [0x18] = { "output plug signal format" }, - [0x1f] = { "general bus setup" }, - - /* TA Document 1999025 - * AV/C Descriptor Mechanism Specification Version 1.0 */ - [0x0c] = { "create descriptor" }, - [0x08] = { "open descriptor" }, - [0x09] = { "read descriptor" }, - [0x0a] = { "write descriptor" }, - [0x05] = { "open info block" }, - [0x06] = { "read info block" }, - [0x07] = { "write info block" }, - [0x0b] = { "search descriptor" }, - [0x0d] = { "object number select" }, - - /* TA Document 1999015 - * AV/C Command Set for Rate Control of Isochronous Data Flow 1.0 */ - [0xb3] = { "rate", { - { "subfunction", 0, 8 }, - { "result", 8, 8 }, - { "plug_type", 16, 8 }, - { "plug_id", 16, 8 }, - } - }, - - /* TA Document 1999008 - * AV/C Audio Subunit Specification 1.0 */ - [0xb8] = { "function block" }, - - /* TA Document 2001001 - * AV/C Panel Subunit Specification 1.1 */ - [0x7d] = { "gui update" }, - [0x7e] = { "push gui data" }, - [0x7f] = { "user action" }, - [0x7c] = { "pass through" }, - - /* */ - [0x26] = { "asynchronous connection" }, + /* TA Document 1999026 */ + /* AV/C Digital Interface Command Set General Specification 4.0 */ + [0xb2] = { "power", { + { "state", 0, 8, power_field_names } + } + }, + [0x30] = { "unit info", { + { "foo", 0, 8 }, + { "unit_type", 8, 5 }, + { "unit", 13, 3 }, + { "company id", 16, 24 }, + } + }, + [0x31] = { "subunit info" }, + [0x01] = { "reserve" }, + [0xb0] = { "version" }, + [0x00] = { "vendor dependent" }, + [0x02] = { "plug info" }, + [0x12] = { "channel usage" }, + [0x24] = { "connect" }, + [0x20] = { "connect av" }, + [0x22] = { "connections" }, + [0x11] = { "digital input" }, + [0x10] = { "digital output" }, + [0x25] = { "disconnect" }, + [0x21] = { "disconnect av" }, + [0x19] = { "input plug signal format" }, + [0x18] = { "output plug signal format" }, + [0x1f] = { "general bus setup" }, + + /* TA Document 1999025 */ + /* AV/C Descriptor Mechanism Specification Version 1.0 */ + [0x0c] = { "create descriptor" }, + [0x08] = { "open descriptor" }, + [0x09] = { "read descriptor" }, + [0x0a] = { "write descriptor" }, + [0x05] = { "open info block" }, + [0x06] = { "read info block" }, + [0x07] = { "write info block" }, + [0x0b] = { "search descriptor" }, + [0x0d] = { "object number select" }, + + /* TA Document 1999015 */ + /* AV/C Command Set for Rate Control of Isochronous Data Flow 1.0 */ + [0xb3] = { "rate", { + { "subfunction", 0, 8 }, + { "result", 8, 8 }, + { "plug_type", 16, 8 }, + { "plug_id", 16, 8 }, + } + }, + + /* TA Document 1999008 */ + /* AV/C Audio Subunit Specification 1.0 */ + [0xb8] = { "function block" }, + + /* TA Document 2001001 */ + /* AV/C Panel Subunit Specification 1.1 */ + [0x7d] = { "gui update" }, + [0x7e] = { "push gui data" }, + [0x7f] = { "user action" }, + [0x7c] = { "pass through" }, + + /* */ + [0x26] = { "asynchronous connection" }, }; struct avc_frame { - uint32_t operand0:8; - uint32_t opcode:8; - uint32_t subunit_id:3; - uint32_t subunit_type:5; - uint32_t ctype:4; - uint32_t cts:4; + uint32_t operand0:8; + uint32_t opcode:8; + uint32_t subunit_id:3; + uint32_t subunit_type:5; + uint32_t ctype:4; + uint32_t cts:4; }; static void decode_avc(struct link_transaction *t) { - struct avc_frame *frame = (struct avc_frame *) t->request->packet.write_block.data; - const struct avc_opcode_info *info; - const char *name; - char buffer[32]; - int i; - - info = &opcode_info[frame->opcode]; - if (info->name == NULL) { - snprintf(buffer, sizeof buffer, "(unknown opcode 0x%02x)", frame->opcode); - name = buffer; - } else { - name = info->name; - } - - printf("av/c %s, subunit_type=%s, subunit_id=%d, opcode=%s", - ctype_names[frame->ctype], subunit_type_names[frame->subunit_type], - frame->subunit_id, name); - - for (i = 0; info->fields[i].name != NULL; i++) { - printf(", %s", info->fields[i].name); - } - - printf("\n"); -} + struct avc_frame *frame = + (struct avc_frame *) t->request->packet.write_block.data; + const struct avc_opcode_info *info; + const char *name; + char buffer[32]; + int i; + + info = &opcode_info[frame->opcode]; + if (info->name == NULL) { + snprintf(buffer, sizeof(buffer), + "(unknown opcode 0x%02x)", frame->opcode); + name = buffer; + } else { + name = info->name; + } + printf("av/c %s, subunit_type=%s, subunit_id=%d, opcode=%s", + ctype_names[frame->ctype], subunit_type_names[frame->subunit_type], + frame->subunit_id, name); + + for (i = 0; info->fields[i].name != NULL; i++) + printf(", %s", info->fields[i].name); + + printf("\n"); +} int decode_fcp(struct link_transaction *t) { - struct avc_frame *frame = (struct avc_frame *) t->request->packet.write_block.data; - unsigned long long offset; - - offset = ((unsigned long long) t->request->packet.common.offset_high << 32) | - t->request->packet.common.offset_low; - - if (t->request->packet.common.tcode != TCODE_WRITE_BLOCK) - return 0; - - if (offset == CSR_FCP_COMMAND || offset == CSR_FCP_RESPONSE) { - switch (frame->cts) { - case 0x00: - decode_avc(t); - break; - case 0x01: - printf("cal fcp frame (cts=0x01)\n"); - break; - case 0x02: - printf("ehs fcp frame (cts=0x02)\n"); - break; - case 0x03: - printf("havi fcp frame (cts=0x03)\n"); - break; - case 0x0e: - printf("vendor specific fcp frame (cts=0x0e)\n"); - break; - case 0x0f: - printf("extended cts\n"); - break; - default: - printf("reserved fcp frame (ctx=0x%02x)\n", frame->cts); - break; + struct avc_frame *frame = + (struct avc_frame *) t->request->packet.write_block.data; + unsigned long long offset = + ((unsigned long long) t->request->packet.common.offset_high << 32) | + t->request->packet.common.offset_low; + + if (t->request->packet.common.tcode != TCODE_WRITE_BLOCK) + return 0; + + if (offset == CSR_FCP_COMMAND || offset == CSR_FCP_RESPONSE) { + switch (frame->cts) { + case 0x00: + decode_avc(t); + break; + case 0x01: + printf("cal fcp frame (cts=0x01)\n"); + break; + case 0x02: + printf("ehs fcp frame (cts=0x02)\n"); + break; + case 0x03: + printf("havi fcp frame (cts=0x03)\n"); + break; + case 0x0e: + printf("vendor specific fcp frame (cts=0x0e)\n"); + break; + case 0x0f: + printf("extended cts\n"); + break; + default: + printf("reserved fcp frame (ctx=0x%02x)\n", frame->cts); + break; + } + return 1; } - return 1; - } - return 0; + return 0; } diff --git a/tools/firewire/list.h b/tools/firewire/list.h index fa119dd371f..41f4bdadf63 100644 --- a/tools/firewire/list.h +++ b/tools/firewire/list.h @@ -1,46 +1,46 @@ struct list { - struct list *next, *prev; + struct list *next, *prev; }; static inline void list_init(struct list *list) { - list->next = list; - list->prev = list; + list->next = list; + list->prev = list; } static inline int list_empty(struct list *list) { - return list->next == list; + return list->next == list; } static inline void list_insert(struct list *link, struct list *new_link) { - new_link->prev = link->prev; - new_link->next = link; - new_link->prev->next = new_link; - new_link->next->prev = new_link; + new_link->prev = link->prev; + new_link->next = link; + new_link->prev->next = new_link; + new_link->next->prev = new_link; } static inline void list_append(struct list *list, struct list *new_link) { - list_insert((struct list *)list, new_link); + list_insert((struct list *)list, new_link); } static inline void list_prepend(struct list *list, struct list *new_link) { - list_insert(list->next, new_link); + list_insert(list->next, new_link); } static inline void list_remove(struct list *link) { - link->prev->next = link->next; - link->next->prev = link->prev; + link->prev->next = link->next; + link->next->prev = link->prev; } #define list_entry(link, type, member) \ diff --git a/tools/firewire/nosy-dump.c b/tools/firewire/nosy-dump.c index 1d4dd5439d4..3d7e1a6dfe9 100644 --- a/tools/firewire/nosy-dump.c +++ b/tools/firewire/nosy-dump.c @@ -1,5 +1,3 @@ -/* -*- mode: c; c-basic-offset: 2 -*- */ - /* * nosy-dump - Interface to snoop mode driver for TI PCILynx 1394 controllers * Copyright (C) 2002-2006 Kristian Høgsberg @@ -19,642 +17,628 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <stdlib.h> +#include <byteswap.h> +#include <endian.h> +#include <fcntl.h> +#include <poll.h> +#include <popt.h> +#include <signal.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <unistd.h> -#include <fcntl.h> #include <sys/ioctl.h> #include <sys/time.h> -#include <endian.h> -#include <popt.h> -#include <poll.h> -#include <byteswap.h> #include <termios.h> - -#include <signal.h> +#include <unistd.h> #include "list.h" -#include "nosy-user.h" #include "nosy-dump.h" +#include "nosy-user.h" enum { - PACKET_FIELD_DETAIL = 0x01, - PACKET_FIELD_DATA_LENGTH = 0x02, - /* Marks the fields we print in transaction view. */ - PACKET_FIELD_TRANSACTION = 0x04 + PACKET_FIELD_DETAIL = 0x01, + PACKET_FIELD_DATA_LENGTH = 0x02, + /* Marks the fields we print in transaction view. */ + PACKET_FIELD_TRANSACTION = 0x04, }; -static void -print_packet(uint32_t *data, size_t length); -static void -decode_link_packet(struct link_packet *packet, size_t length, - int include_flags, int exclude_flags); - -static int run = 1; +static void print_packet(uint32_t *data, size_t length); +static void decode_link_packet(struct link_packet *packet, size_t length, + int include_flags, int exclude_flags); +static int run = 1; sig_t sys_sigint_handler; static char *option_nosy_device = "/dev/nosy"; static char *option_view = "packet"; -static char *option_output = NULL; -static char *option_input = NULL; -static int option_hex; -static int option_iso; -static int option_cycle_start; -static int option_version; -static int option_verbose; +static char *option_output; +static char *option_input; +static int option_hex; +static int option_iso; +static int option_cycle_start; +static int option_version; +static int option_verbose; enum { - VIEW_TRANSACTION, - VIEW_PACKET, - VIEW_STATS + VIEW_TRANSACTION, + VIEW_PACKET, + VIEW_STATS, }; static const struct poptOption options[] = { - { - longName: "device", - shortName: 'd', - argInfo: POPT_ARG_STRING, - arg: &option_nosy_device, - descrip: "Path to nosy device.", - argDescrip: "DEVICE" - }, - { - longName: "view", - argInfo: POPT_ARG_STRING, - arg: &option_view, - descrip: "Specify view of bus traffic: packet, transaction or stats.", - argDescrip: "VIEW" - }, - { - longName: "hex", - shortName: 'x', - argInfo: POPT_ARG_NONE, - arg: &option_hex, - descrip: "Print each packet in hex.", - }, - { - longName: "iso", - argInfo: POPT_ARG_NONE, - arg: &option_iso, - descrip: "Print iso packets.", - }, - { - longName: "cycle-start", - argInfo: POPT_ARG_NONE, - arg: &option_cycle_start, - descrip: "Print cycle start packets.", - }, - { - longName: "verbose", - shortName: 'v', - argInfo: POPT_ARG_NONE, - arg: &option_verbose, - descrip: "Verbose packet view.", - }, - { - longName: "output", - shortName: 'o', - argInfo: POPT_ARG_STRING, - arg: &option_output, - descrip: "Log to output file.", - argDescrip: "FILENAME" - }, - { - longName: "input", - shortName: 'i', - argInfo: POPT_ARG_STRING, - arg: &option_input, - descrip: "Decode log from file.", - argDescrip: "FILENAME" - }, - { - longName: "version", - argInfo: POPT_ARG_NONE, - arg: &option_version, - descrip: "Specify print version info.", - }, - POPT_AUTOHELP - POPT_TABLEEND + { + .longName = "device", + .shortName = 'd', + .argInfo = POPT_ARG_STRING, + .arg = &option_nosy_device, + .descrip = "Path to nosy device.", + .argDescrip = "DEVICE" + }, + { + .longName = "view", + .argInfo = POPT_ARG_STRING, + .arg = &option_view, + .descrip = "Specify view of bus traffic: packet, transaction or stats.", + .argDescrip = "VIEW" + }, + { + .longName = "hex", + .shortName = 'x', + .argInfo = POPT_ARG_NONE, + .arg = &option_hex, + .descrip = "Print each packet in hex.", + }, + { + .longName = "iso", + .argInfo = POPT_ARG_NONE, + .arg = &option_iso, + .descrip = "Print iso packets.", + }, + { + .longName = "cycle-start", + .argInfo = POPT_ARG_NONE, + .arg = &option_cycle_start, + .descrip = "Print cycle start packets.", + }, + { + .longName = "verbose", + .shortName = 'v', + .argInfo = POPT_ARG_NONE, + .arg = &option_verbose, + .descrip = "Verbose packet view.", + }, + { + .longName = "output", + .shortName = 'o', + .argInfo = POPT_ARG_STRING, + .arg = &option_output, + .descrip = "Log to output file.", + .argDescrip = "FILENAME" + }, + { + .longName = "input", + .shortName = 'i', + .argInfo = POPT_ARG_STRING, + .arg = &option_input, + .descrip = "Decode log from file.", + .argDescrip = "FILENAME" + }, + { + .longName = "version", + .argInfo = POPT_ARG_NONE, + .arg = &option_version, + .descrip = "Specify print version info.", + }, + POPT_AUTOHELP + POPT_TABLEEND }; -void +/* Allow all ^C except the first to interrupt the program in the usual way. */ +void sigint_handler(int signal_num) { - if (run == 1) { - run = 0; - /* Allow all Ctrl-C's except the first to interrupt the program in - * the usual way. - */ - signal(SIGINT, SIG_DFL); - } + if (run == 1) { + run = 0; + signal(SIGINT, SIG_DFL); + } } struct subaction * subaction_create(uint32_t *data, size_t length) { - struct subaction *sa; + struct subaction *sa; - /* we put the ack in the subaction struct for easy access. */ - sa = malloc(sizeof *sa - sizeof sa->packet + length); - sa->ack = data[length / 4 - 1]; - sa->length = length; - memcpy (&sa->packet, data, length); + /* we put the ack in the subaction struct for easy access. */ + sa = malloc(sizeof *sa - sizeof sa->packet + length); + sa->ack = data[length / 4 - 1]; + sa->length = length; + memcpy(&sa->packet, data, length); - return sa; + return sa; } void subaction_destroy(struct subaction *sa) { - free(sa); + free(sa); } -struct list pending_transaction_list = - { &pending_transaction_list, &pending_transaction_list }; +struct list pending_transaction_list = { + &pending_transaction_list, &pending_transaction_list +}; struct link_transaction * link_transaction_lookup(int request_node, int response_node, int tlabel) { - struct link_transaction *t; - - list_for_each_entry(t, &pending_transaction_list, link) { - if (t->request_node == request_node && - t->response_node == response_node && - t->tlabel == tlabel) - return t; - } - - t = malloc(sizeof *t); - t->request_node = request_node; - t->response_node = response_node; - t->tlabel = tlabel; - list_init(&t->request_list); - list_init(&t->response_list); - - list_append(&pending_transaction_list, &t->link); - - return t; + struct link_transaction *t; + + list_for_each_entry(t, &pending_transaction_list, link) { + if (t->request_node == request_node && + t->response_node == response_node && + t->tlabel == tlabel) + return t; + } + + t = malloc(sizeof *t); + t->request_node = request_node; + t->response_node = response_node; + t->tlabel = tlabel; + list_init(&t->request_list); + list_init(&t->response_list); + + list_append(&pending_transaction_list, &t->link); + + return t; } void link_transaction_destroy(struct link_transaction *t) { - while (!list_empty(&t->request_list)) { - struct subaction *sa = list_head(&t->request_list, struct subaction, link); - list_remove(&sa->link); - subaction_destroy(sa); - } - - while (!list_empty(&t->response_list)) { - struct subaction *sa = list_head(&t->response_list, struct subaction, link); - list_remove(&sa->link); - subaction_destroy(sa); - } - - free(t); + struct subaction *sa; + + while (!list_empty(&t->request_list)) { + sa = list_head(&t->request_list, struct subaction, link); + list_remove(&sa->link); + subaction_destroy(sa); + } + while (!list_empty(&t->response_list)) { + sa = list_head(&t->response_list, struct subaction, link); + list_remove(&sa->link); + subaction_destroy(sa); + } + free(t); } struct protocol_decoder { - const char *name; - int (*decode)(struct link_transaction *t); + const char *name; + int (*decode)(struct link_transaction *t); }; static struct protocol_decoder protocol_decoders[] = { - { "FCP", decode_fcp } + { "FCP", decode_fcp } }; void handle_transaction(struct link_transaction *t) { - struct subaction *sa; - int i; - - if (!t->request) { - printf("BUG in handle_transaction\n"); - return; - } - - for (i = 0; i < array_length(protocol_decoders); i++) - if (protocol_decoders[i].decode(t)) - break; - - /* HACK: decode only fcp right now. */ - return; - - decode_link_packet(&t->request->packet, t->request->length, - PACKET_FIELD_TRANSACTION, 0); - if (t->response) - decode_link_packet(&t->response->packet, t->request->length, - PACKET_FIELD_TRANSACTION, 0); - else - printf("[no response]"); - - if (option_verbose) { - list_for_each_entry(sa, &t->request_list, link) - print_packet((uint32_t *) &sa->packet, sa->length); - list_for_each_entry(sa, &t->response_list, link) - print_packet((uint32_t *) &sa->packet, sa->length); - } - printf("\r\n"); - - link_transaction_destroy(t); + struct subaction *sa; + int i; + + if (!t->request) { + printf("BUG in handle_transaction\n"); + return; + } + + for (i = 0; i < array_length(protocol_decoders); i++) + if (protocol_decoders[i].decode(t)) + break; + + /* HACK: decode only fcp right now. */ + return; + + decode_link_packet(&t->request->packet, t->request->length, + PACKET_FIELD_TRANSACTION, 0); + if (t->response) + decode_link_packet(&t->response->packet, t->request->length, + PACKET_FIELD_TRANSACTION, 0); + else + printf("[no response]"); + + if (option_verbose) { + list_for_each_entry(sa, &t->request_list, link) + print_packet((uint32_t *) &sa->packet, sa->length); + list_for_each_entry(sa, &t->response_list, link) + print_packet((uint32_t *) &sa->packet, sa->length); + } + printf("\r\n"); + + link_transaction_destroy(t); } void clear_pending_transaction_list(void) { - struct link_transaction *t; - - while (!list_empty(&pending_transaction_list)) { - t = list_head(&pending_transaction_list, struct link_transaction, link); - list_remove(&t->link); - link_transaction_destroy(t); - /* print unfinished transactions */ - } + struct link_transaction *t; + + while (!list_empty(&pending_transaction_list)) { + t = list_head(&pending_transaction_list, + struct link_transaction, link); + list_remove(&t->link); + link_transaction_destroy(t); + /* print unfinished transactions */ + } } static const char * const tcode_names[] = { - "write_quadlet_request", - "write_block_request", - "write_response", - "reserved", - "read_quadlet_request", - "read_block_request", - "read_quadlet_response", - "read_block_response", - "cycle_start", - "lock_request", - "iso_data", - "lock_response" + [0x0] = "write_quadlet_request", [0x6] = "read_quadlet_response", + [0x1] = "write_block_request", [0x7] = "read_block_response", + [0x2] = "write_response", [0x8] = "cycle_start", + [0x3] = "reserved", [0x9] = "lock_request", + [0x4] = "read_quadlet_request", [0xa] = "iso_data", + [0x5] = "read_block_request", [0xb] = "lock_response", }; static const char * const ack_names[] = { - "no ack", - "ack_complete", - "ack_pending", - "reserved (0x03)", - "ack_busy_x", - "ack_busy_a", - "ack_busy_b", - "reserved (0x07)", - "reserved (0x08)", - "reserved (0x09)", - "reserved (0x0a)", - "reserved (0x0b)", - "reserved (0x0c)", - "ack_data_error", - "ack_type_error", - "reserved (0x0f)", + [0x0] = "no ack", [0x8] = "reserved (0x08)", + [0x1] = "ack_complete", [0x9] = "reserved (0x09)", + [0x2] = "ack_pending", [0xa] = "reserved (0x0a)", + [0x3] = "reserved (0x03)", [0xb] = "reserved (0x0b)", + [0x4] = "ack_busy_x", [0xc] = "reserved (0x0c)", + [0x5] = "ack_busy_a", [0xd] = "ack_data_error", + [0x6] = "ack_busy_b", [0xe] = "ack_type_error", + [0x7] = "reserved (0x07)", [0xf] = "reserved (0x0f)", }; static const char * const rcode_names[] = { - "complete", - "reserved (0x01)", - "reserved (0x02)", - "reserved (0x03)", - "conflict_error", - "data_error", - "type_error", - "address_error", + [0x0] = "complete", [0x4] = "conflict_error", + [0x1] = "reserved (0x01)", [0x5] = "data_error", + [0x2] = "reserved (0x02)", [0x6] = "type_error", + [0x3] = "reserved (0x03)", [0x7] = "address_error", }; static const char * const retry_names[] = { - "retry_1", - "retry_x", - "retry_a", - "retry_b", + [0x0] = "retry_1", + [0x1] = "retry_x", + [0x2] = "retry_a", + [0x3] = "retry_b", }; enum { - PACKET_RESERVED, - PACKET_REQUEST, - PACKET_RESPONSE, - PACKET_OTHER, + PACKET_RESERVED, + PACKET_REQUEST, + PACKET_RESPONSE, + PACKET_OTHER, }; struct packet_info { - const char *name; - int type; - int response_tcode; - struct packet_field *fields; - int field_count; + const char *name; + int type; + int response_tcode; + struct packet_field *fields; + int field_count; }; struct packet_field { - const char *name; /* Short name for field. */ - int offset; /* Location of field, specified in bits. - * Negative means from end of packet */ - int width; /* Width of field, 0 means use data_length. */ - int flags; /* Show options. */ - const char * const *value_names; + const char *name; /* Short name for field. */ + int offset; /* Location of field, specified in bits; */ + /* negative means from end of packet. */ + int width; /* Width of field, 0 means use data_length. */ + int flags; /* Show options. */ + const char * const *value_names; }; -#define COMMON_REQUEST_FIELDS \ - { "dest", 0, 16, PACKET_FIELD_TRANSACTION }, \ - { "tl", 16, 6 }, \ - { "rt", 22, 2, PACKET_FIELD_DETAIL, retry_names }, \ - { "tcode", 24, 4, PACKET_FIELD_TRANSACTION, tcode_names }, \ - { "pri", 28, 4, PACKET_FIELD_DETAIL }, \ - { "src", 32, 16, PACKET_FIELD_TRANSACTION }, \ - { "offs", 48, 48, PACKET_FIELD_TRANSACTION } - -#define COMMON_RESPONSE_FIELDS \ - { "dest", 0, 16 }, \ - { "tl", 16, 6 }, \ - { "rt", 22, 2, PACKET_FIELD_DETAIL, retry_names }, \ - { "tcode", 24, 4, 0, tcode_names }, \ - { "pri", 28, 4, PACKET_FIELD_DETAIL }, \ - { "src", 32, 16 }, \ - { "rcode", 48, 4, PACKET_FIELD_TRANSACTION, rcode_names } +#define COMMON_REQUEST_FIELDS \ + { "dest", 0, 16, PACKET_FIELD_TRANSACTION }, \ + { "tl", 16, 6 }, \ + { "rt", 22, 2, PACKET_FIELD_DETAIL, retry_names }, \ + { "tcode", 24, 4, PACKET_FIELD_TRANSACTION, tcode_names }, \ + { "pri", 28, 4, PACKET_FIELD_DETAIL }, \ + { "src", 32, 16, PACKET_FIELD_TRANSACTION }, \ + { "offs", 48, 48, PACKET_FIELD_TRANSACTION } + +#define COMMON_RESPONSE_FIELDS \ + { "dest", 0, 16 }, \ + { "tl", 16, 6 }, \ + { "rt", 22, 2, PACKET_FIELD_DETAIL, retry_names }, \ + { "tcode", 24, 4, 0, tcode_names }, \ + { "pri", 28, 4, PACKET_FIELD_DETAIL }, \ + { "src", 32, 16 }, \ + { "rcode", 48, 4, PACKET_FIELD_TRANSACTION, rcode_names } struct packet_field read_quadlet_request_fields[] = { - COMMON_REQUEST_FIELDS, - { "crc", 96, 32, PACKET_FIELD_DETAIL }, - { "ack", 156, 4, 0, ack_names } + COMMON_REQUEST_FIELDS, + { "crc", 96, 32, PACKET_FIELD_DETAIL }, + { "ack", 156, 4, 0, ack_names }, }; struct packet_field read_quadlet_response_fields[] = { - COMMON_RESPONSE_FIELDS, - { "data", 96, 32, PACKET_FIELD_TRANSACTION }, - { "crc", 128, 32, PACKET_FIELD_DETAIL }, - { "ack", 188, 4, 0, ack_names } + COMMON_RESPONSE_FIELDS, + { "data", 96, 32, PACKET_FIELD_TRANSACTION }, + { "crc", 128, 32, PACKET_FIELD_DETAIL }, + { "ack", 188, 4, 0, ack_names }, }; struct packet_field read_block_request_fields[] = { - COMMON_REQUEST_FIELDS, - { "data_length", 96, 16, PACKET_FIELD_TRANSACTION }, - { "extended_tcode", 112, 16 }, - { "crc", 128, 32, PACKET_FIELD_DETAIL }, - { "ack", 188, 4, 0, ack_names }, + COMMON_REQUEST_FIELDS, + { "data_length", 96, 16, PACKET_FIELD_TRANSACTION }, + { "extended_tcode", 112, 16 }, + { "crc", 128, 32, PACKET_FIELD_DETAIL }, + { "ack", 188, 4, 0, ack_names }, }; struct packet_field block_response_fields[] = { - COMMON_RESPONSE_FIELDS, - { "data_length", 96, 16, PACKET_FIELD_DATA_LENGTH }, - { "extended_tcode", 112, 16 }, - { "crc", 128, 32, PACKET_FIELD_DETAIL }, - { "data", 160, 0, PACKET_FIELD_TRANSACTION }, - { "crc", -64, 32, PACKET_FIELD_DETAIL }, - { "ack", -4, 4, 0, ack_names } + COMMON_RESPONSE_FIELDS, + { "data_length", 96, 16, PACKET_FIELD_DATA_LENGTH }, + { "extended_tcode", 112, 16 }, + { "crc", 128, 32, PACKET_FIELD_DETAIL }, + { "data", 160, 0, PACKET_FIELD_TRANSACTION }, + { "crc", -64, 32, PACKET_FIELD_DETAIL }, + { "ack", -4, 4, 0, ack_names }, }; struct packet_field write_quadlet_request_fields[] = { - COMMON_REQUEST_FIELDS, - { "data", 96, 32, PACKET_FIELD_TRANSACTION }, - { "ack", -4, 4, 0, ack_names } + COMMON_REQUEST_FIELDS, + { "data", 96, 32, PACKET_FIELD_TRANSACTION }, + { "ack", -4, 4, 0, ack_names }, }; struct packet_field block_request_fields[] = { - COMMON_REQUEST_FIELDS, - { "data_length", 96, 16, PACKET_FIELD_DATA_LENGTH | PACKET_FIELD_TRANSACTION }, - { "extended_tcode", 112, 16, PACKET_FIELD_TRANSACTION }, - { "crc", 128, 32, PACKET_FIELD_DETAIL }, - { "data", 160, 0, PACKET_FIELD_TRANSACTION }, - { "crc", -64, 32, PACKET_FIELD_DETAIL }, - { "ack", -4, 4, 0, ack_names } + COMMON_REQUEST_FIELDS, + { "data_length", 96, 16, PACKET_FIELD_DATA_LENGTH | PACKET_FIELD_TRANSACTION }, + { "extended_tcode", 112, 16, PACKET_FIELD_TRANSACTION }, + { "crc", 128, 32, PACKET_FIELD_DETAIL }, + { "data", 160, 0, PACKET_FIELD_TRANSACTION }, + { "crc", -64, 32, PACKET_FIELD_DETAIL }, + { "ack", -4, 4, 0, ack_names }, }; struct packet_field write_response_fields[] = { - COMMON_RESPONSE_FIELDS, - { "reserved", 64, 32, PACKET_FIELD_DETAIL }, - { "ack", -4, 4, 0, ack_names } + COMMON_RESPONSE_FIELDS, + { "reserved", 64, 32, PACKET_FIELD_DETAIL }, + { "ack", -4, 4, 0, ack_names }, }; struct packet_field iso_data_fields[] = { - { "data_length", 0, 16, PACKET_FIELD_DATA_LENGTH }, - { "tag", 16, 2 }, - { "channel", 18, 6 }, - { "tcode", 24, 4, 0, tcode_names }, - { "sy", 28, 4 }, - { "crc", 32, 32, PACKET_FIELD_DETAIL }, - { "data", 64, 0 }, - { "crc", -64, 32, PACKET_FIELD_DETAIL }, - { "ack", -4, 4, 0, ack_names } + { "data_length", 0, 16, PACKET_FIELD_DATA_LENGTH }, + { "tag", 16, 2 }, + { "channel", 18, 6 }, + { "tcode", 24, 4, 0, tcode_names }, + { "sy", 28, 4 }, + { "crc", 32, 32, PACKET_FIELD_DETAIL }, + { "data", 64, 0 }, + { "crc", -64, 32, PACKET_FIELD_DETAIL }, + { "ack", -4, 4, 0, ack_names }, }; static struct packet_info packet_info[] = { - { |