mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
tools/firewire: nosy-dump: change to kernel coding style
This changes only - whitespace - C99 initializers - comment style - order of #includes - if { } else { } bracing Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
parent
a8461c0f3b
commit
92c16f7e9c
@ -6,58 +6,34 @@
|
||||
#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 {
|
||||
@ -67,8 +43,8 @@ struct avc_enum {
|
||||
|
||||
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 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;
|
||||
};
|
||||
@ -86,16 +62,13 @@ struct avc_enum power_field_names[] = {
|
||||
|
||||
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", {
|
||||
/* TA Document 1999026 */
|
||||
/* AV/C Digital Interface Command Set General Specification 4.0 */
|
||||
[0xb2] = { "power", {
|
||||
{ "state", 0, 8, power_field_names }
|
||||
}
|
||||
},
|
||||
[0x30] =
|
||||
{ "unit info", {
|
||||
[0x30] = { "unit info", {
|
||||
{ "foo", 0, 8 },
|
||||
{ "unit_type", 8, 5 },
|
||||
{ "unit", 13, 3 },
|
||||
@ -106,7 +79,6 @@ static const struct avc_opcode_info opcode_info[256] = {
|
||||
[0x01] = { "reserve" },
|
||||
[0xb0] = { "version" },
|
||||
[0x00] = { "vendor dependent" },
|
||||
|
||||
[0x02] = { "plug info" },
|
||||
[0x12] = { "channel usage" },
|
||||
[0x24] = { "connect" },
|
||||
@ -120,8 +92,8 @@ static const struct avc_opcode_info opcode_info[256] = {
|
||||
[0x18] = { "output plug signal format" },
|
||||
[0x1f] = { "general bus setup" },
|
||||
|
||||
/* TA Document 1999025
|
||||
* AV/C Descriptor Mechanism Specification Version 1.0 */
|
||||
/* TA Document 1999025 */
|
||||
/* AV/C Descriptor Mechanism Specification Version 1.0 */
|
||||
[0x0c] = { "create descriptor" },
|
||||
[0x08] = { "open descriptor" },
|
||||
[0x09] = { "read descriptor" },
|
||||
@ -132,8 +104,8 @@ static const struct avc_opcode_info opcode_info[256] = {
|
||||
[0x0b] = { "search descriptor" },
|
||||
[0x0d] = { "object number select" },
|
||||
|
||||
/* TA Document 1999015
|
||||
* AV/C Command Set for Rate Control of Isochronous Data Flow 1.0 */
|
||||
/* TA Document 1999015 */
|
||||
/* AV/C Command Set for Rate Control of Isochronous Data Flow 1.0 */
|
||||
[0xb3] = { "rate", {
|
||||
{ "subfunction", 0, 8 },
|
||||
{ "result", 8, 8 },
|
||||
@ -142,12 +114,12 @@ static const struct avc_opcode_info opcode_info[256] = {
|
||||
}
|
||||
},
|
||||
|
||||
/* TA Document 1999008
|
||||
* AV/C Audio Subunit Specification 1.0 */
|
||||
/* TA Document 1999008 */
|
||||
/* AV/C Audio Subunit Specification 1.0 */
|
||||
[0xb8] = { "function block" },
|
||||
|
||||
/* TA Document 2001001
|
||||
* AV/C Panel Subunit Specification 1.1 */
|
||||
/* TA Document 2001001 */
|
||||
/* AV/C Panel Subunit Specification 1.1 */
|
||||
[0x7d] = { "gui update" },
|
||||
[0x7e] = { "push gui data" },
|
||||
[0x7f] = { "user action" },
|
||||
@ -169,7 +141,8 @@ struct avc_frame {
|
||||
static void
|
||||
decode_avc(struct link_transaction *t)
|
||||
{
|
||||
struct avc_frame *frame = (struct avc_frame *) t->request->packet.write_block.data;
|
||||
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];
|
||||
@ -177,7 +150,8 @@ decode_avc(struct link_transaction *t)
|
||||
|
||||
info = &opcode_info[frame->opcode];
|
||||
if (info->name == NULL) {
|
||||
snprintf(buffer, sizeof buffer, "(unknown opcode 0x%02x)", frame->opcode);
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"(unknown opcode 0x%02x)", frame->opcode);
|
||||
name = buffer;
|
||||
} else {
|
||||
name = info->name;
|
||||
@ -187,21 +161,19 @@ decode_avc(struct link_transaction *t)
|
||||
ctype_names[frame->ctype], subunit_type_names[frame->subunit_type],
|
||||
frame->subunit_id, name);
|
||||
|
||||
for (i = 0; info->fields[i].name != NULL; i++) {
|
||||
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) |
|
||||
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)
|
||||
|
@ -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,45 +17,41 @@
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.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 <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_TRANSACTION = 0x04,
|
||||
};
|
||||
|
||||
static void
|
||||
print_packet(uint32_t *data, size_t length);
|
||||
static void
|
||||
decode_link_packet(struct link_packet *packet, size_t length,
|
||||
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 char *option_output;
|
||||
static char *option_input;
|
||||
static int option_hex;
|
||||
static int option_iso;
|
||||
static int option_cycle_start;
|
||||
@ -67,85 +61,83 @@ static int option_verbose;
|
||||
enum {
|
||||
VIEW_TRANSACTION,
|
||||
VIEW_PACKET,
|
||||
VIEW_STATS
|
||||
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 = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "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.",
|
||||
.longName = "version",
|
||||
.argInfo = POPT_ARG_NONE,
|
||||
.arg = &option_version,
|
||||
.descrip = "Specify print version info.",
|
||||
},
|
||||
POPT_AUTOHELP
|
||||
POPT_TABLEEND
|
||||
};
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@ -170,8 +162,9 @@ subaction_destroy(struct subaction *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)
|
||||
@ -200,18 +193,18 @@ link_transaction_lookup(int request_node, int response_node, int tlabel)
|
||||
void
|
||||
link_transaction_destroy(struct link_transaction *t)
|
||||
{
|
||||
struct subaction *sa;
|
||||
|
||||
while (!list_empty(&t->request_list)) {
|
||||
struct subaction *sa = list_head(&t->request_list, struct subaction, link);
|
||||
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);
|
||||
sa = list_head(&t->response_list, struct subaction, link);
|
||||
list_remove(&sa->link);
|
||||
subaction_destroy(sa);
|
||||
}
|
||||
|
||||
free(t);
|
||||
}
|
||||
|
||||
@ -267,7 +260,8 @@ 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);
|
||||
t = list_head(&pending_transaction_list,
|
||||
struct link_transaction, link);
|
||||
list_remove(&t->link);
|
||||
link_transaction_destroy(t);
|
||||
/* print unfinished transactions */
|
||||
@ -275,55 +269,37 @@ clear_pending_transaction_list(void)
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -343,8 +319,8 @@ struct packet_info {
|
||||
|
||||
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 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;
|
||||
@ -371,14 +347,14 @@ struct packet_field {
|
||||
struct packet_field read_quadlet_request_fields[] = {
|
||||
COMMON_REQUEST_FIELDS,
|
||||
{ "crc", 96, 32, PACKET_FIELD_DETAIL },
|
||||
{ "ack", 156, 4, 0, ack_names }
|
||||
{ "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 }
|
||||
{ "ack", 188, 4, 0, ack_names },
|
||||
};
|
||||
|
||||
struct packet_field read_block_request_fields[] = {
|
||||
@ -396,13 +372,13 @@ struct packet_field block_response_fields[] = {
|
||||
{ "crc", 128, 32, PACKET_FIELD_DETAIL },
|
||||
{ "data", 160, 0, PACKET_FIELD_TRANSACTION },
|
||||
{ "crc", -64, 32, PACKET_FIELD_DETAIL },
|
||||
{ "ack", -4, 4, 0, ack_names }
|
||||
{ "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 }
|
||||
{ "ack", -4, 4, 0, ack_names },
|
||||
};
|
||||
|
||||
struct packet_field block_request_fields[] = {
|
||||
@ -412,13 +388,13 @@ struct packet_field block_request_fields[] = {
|
||||
{ "crc", 128, 32, PACKET_FIELD_DETAIL },
|
||||
{ "data", 160, 0, PACKET_FIELD_TRANSACTION },
|
||||
{ "crc", -64, 32, PACKET_FIELD_DETAIL },
|
||||
{ "ack", -4, 4, 0, ack_names }
|
||||
{ "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 }
|
||||
{ "ack", -4, 4, 0, ack_names },
|
||||
};
|
||||
|
||||
struct packet_field iso_data_fields[] = {
|
||||
@ -430,7 +406,7 @@ struct packet_field iso_data_fields[] = {
|
||||
{ "crc", 32, 32, PACKET_FIELD_DETAIL },
|
||||
{ "data", 64, 0 },
|
||||
{ "crc", -64, 32, PACKET_FIELD_DETAIL },
|
||||
{ "ack", -4, 4, 0, ack_names }
|
||||
{ "ack", -4, 4, 0, ack_names },
|
||||
};
|
||||
|
||||
static struct packet_info packet_info[] = {
|
||||
@ -507,7 +483,7 @@ static struct packet_info packet_info[] = {
|
||||
.type = PACKET_RESPONSE,
|
||||
.fields = block_response_fields,
|
||||
.field_count = array_length(block_response_fields)
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
int
|
||||
@ -516,8 +492,7 @@ handle_packet(uint32_t *data, size_t length)
|
||||
if (length == 0) {
|
||||
printf("bus reset\r\n");
|
||||
clear_pending_transaction_list();
|
||||
}
|
||||
else if (length > sizeof(struct phy_packet)) {
|
||||
} else if (length > sizeof(struct phy_packet)) {
|
||||
struct link_packet *p = (struct link_packet *) data;
|
||||
struct subaction *sa, *prev;
|
||||
struct link_transaction *t;
|
||||
@ -530,19 +505,23 @@ handle_packet(uint32_t *data, size_t length)
|
||||
t->request = sa;
|
||||
|
||||
if (!list_empty(&t->request_list)) {
|
||||
prev = list_tail(&t->request_list, struct subaction, link);
|
||||
prev = list_tail(&t->request_list,
|
||||
struct subaction, link);
|
||||
|
||||
if (!ACK_BUSY(prev->ack)) {
|
||||
/* error, we should only see ack_busy_* before the
|
||||
/*
|
||||
* error, we should only see ack_busy_* before the
|
||||
* ack_pending/ack_complete -- this is an ack_pending
|
||||
* instead (ack_complete would have finished the
|
||||
* transaction). */
|
||||
* transaction).
|
||||
*/
|
||||
}
|
||||
|
||||
if (prev->packet.common.tcode != sa->packet.common.tcode ||
|
||||
prev->packet.common.tlabel != sa->packet.common.tlabel)
|
||||
prev->packet.common.tlabel != sa->packet.common.tlabel) {
|
||||
/* memcmp() ? */
|
||||
/* error, these should match for retries. */;
|
||||
/* error, these should match for retries. */
|
||||
}
|
||||
}
|
||||
|
||||
list_append(&t->request_list, &sa->link);
|
||||
@ -589,20 +568,25 @@ handle_packet(uint32_t *data, size_t length)
|
||||
if (!list_empty(&t->response_list)) {
|
||||
prev = list_tail(&t->response_list, struct subaction, link);
|
||||
|
||||
if (!ACK_BUSY(prev->ack))
|
||||
/* error, we should only see ack_busy_* before the
|
||||
* ack_pending/ack_complete */;
|
||||
if (!ACK_BUSY(prev->ack)) {
|
||||
/*
|
||||
* error, we should only see ack_busy_* before the
|
||||
* ack_pending/ack_complete
|
||||
*/
|
||||
}
|
||||
|
||||
if (prev->packet.common.tcode != sa->packet.common.tcode ||
|
||||
prev->packet.common.tlabel != sa->packet.common.tlabel)
|
||||
prev->packet.common.tlabel != sa->packet.common.tlabel) {
|
||||
/* use memcmp() instead? */
|
||||
/* error, these should match for retries. */;
|
||||
/* error, these should match for retries. */
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
prev = list_tail(&t->request_list, struct subaction, link);
|
||||
if (prev->ack != ACK_PENDING) {
|
||||
/* error, should not get response unless last request got
|
||||
* ack_pending. */
|
||||
/*
|
||||
* error, should not get response unless last request got
|
||||
* ack_pending.
|
||||
*/
|
||||
}
|
||||
|
||||
if (packet_info[prev->packet.common.tcode].response_tcode !=
|
||||
@ -712,13 +696,11 @@ decode_link_packet(struct link_packet *packet, size_t length,
|
||||
|
||||
bits = get_bits(packet, offset, f->width);
|
||||
printf("%s", f->value_names[bits]);
|
||||
}
|
||||
else if (f->width == 0) {
|
||||
} else if (f->width == 0) {
|
||||
printf("%s=[", f->name);
|
||||
dump_data((unsigned char *) packet + (offset / 8 + 4), data_length);
|
||||
printf("]");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unsigned long long bits;
|
||||
int high_width, low_width;
|
||||
|
||||
@ -730,9 +712,9 @@ decode_link_packet(struct link_packet *packet, size_t length,
|
||||
bits = get_bits(packet, offset, high_width);
|
||||
bits = (bits << low_width) |
|
||||
get_bits(packet, offset + high_width, low_width);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
bits = get_bits(packet, offset, f->width);
|
||||
}
|
||||
|
||||
printf("%s=0x%0*llx", f->name, (f->width + 3) / 4, bits);
|
||||
|
||||
@ -752,16 +734,15 @@ print_packet(uint32_t *data, size_t length)
|
||||
|
||||
printf("%6u ", data[0]);
|
||||
|
||||
if (length == 4)
|
||||
if (length == 4) {
|
||||
printf("bus reset");
|
||||
else if (length < sizeof(struct phy_packet)) {
|
||||
} else if (length < sizeof(struct phy_packet)) {
|
||||
printf("short packet: ");
|
||||
for (i = 1; i < length / 4; i++)
|
||||
printf("%s%08x", i == 0 ? "[" : " ", data[i]);
|
||||
printf("]");
|
||||
|
||||
}
|
||||
else if (length == sizeof(struct phy_packet) && data[1] == ~data[2]) {
|
||||
} else if (length == sizeof(struct phy_packet) && data[1] == ~data[2]) {
|
||||
struct phy_packet *pp = (struct phy_packet *) data;
|
||||
|
||||
/* phy packet are 3 quadlets: the 1 quadlet payload,
|
||||
@ -772,8 +753,7 @@ print_packet(uint32_t *data, size_t length)
|
||||
case PHY_PACKET_CONFIGURATION:
|
||||
if (!pp->phy_config.set_root && !pp->phy_config.set_gap_count) {
|
||||
printf("ext phy config: phy_id=%02x", pp->phy_config.root_id);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("phy config:");
|
||||
if (pp->phy_config.set_root)
|
||||
printf(" set_root_id=%02x", pp->phy_config.root_id);
|
||||
@ -790,8 +770,7 @@ print_packet(uint32_t *data, size_t length)
|
||||
if (pp->self_id.extended) {
|
||||
printf("extended self id: phy_id=%02x, seq=%d",
|
||||
pp->ext_self_id.phy_id, pp->ext_self_id.sequence);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
static const char * const speed_names[] = {
|
||||
"S100", "S200", "S400", "BETA"
|
||||
};
|
||||
@ -802,7 +781,6 @@ print_packet(uint32_t *data, size_t length)
|
||||
speed_names[pp->self_id.phy_speed],
|
||||
(pp->self_id.contender ? ", irm contender" : ""),
|
||||
(pp->self_id.initiated_reset ? ", initiator" : ""));
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -812,8 +790,7 @@ print_packet(uint32_t *data, size_t length)
|
||||
printf("]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
struct link_packet *packet = (struct link_packet *) data;
|
||||
|
||||
decode_link_packet(packet, length, 0,
|
||||
@ -936,8 +913,7 @@ int main(int argc, const char *argv[])
|
||||
fprintf(stderr, "Could not open %s, %m\n", option_input);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fd = open(option_nosy_device, O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Could not open %s, %m\n", option_nosy_device);
|
||||
@ -990,8 +966,7 @@ int main(int argc, const char *argv[])
|
||||
if (fread(&length, sizeof length, 1, input) != 1)
|
||||
return 0;
|
||||
fread(buf, 1, length, input);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
poll(pollfds, 2, -1);
|
||||
if (pollfds[1].revents) {
|
||||
read(STDIN_FILENO, &c, sizeof c);
|
||||
@ -1026,9 +1001,9 @@ int main(int argc, const char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
poptPrintUsage(con, stdout, 0);
|
||||
}
|
||||
|
||||
if (output != NULL)
|
||||
fclose(output);
|
||||
|
Loading…
Reference in New Issue
Block a user