From 4bc670563f2ded392f19387b589596e8fe0918fc Mon Sep 17 00:00:00 2001 From: hadaq Date: Mon, 12 Apr 2010 01:06:14 +0000 Subject: [PATCH] added TRB_DEBUGGER variable, removed lazy option --- libtrbnet/Makefile | 2 +- libtrbnet/trbcmd.c | 12 ++---- libtrbnet/trbnet.c | 101 ++++++++++++++++++++++++++------------------- libtrbnet/trbnet.h | 1 - 4 files changed, 63 insertions(+), 53 deletions(-) diff --git a/libtrbnet/Makefile b/libtrbnet/Makefile index 8f02f83..696e97f 100644 --- a/libtrbnet/Makefile +++ b/libtrbnet/Makefile @@ -4,7 +4,7 @@ AXIS_USABLE_LIBS = UCLIBC GLIBC include $(AXIS_TOP_DIR)/tools/build/Rules.axis INCDIR = -I. -CPPFLAGS = #-DHEXMODE +CPPFLAGS = #-DTRB_DEBUGGER #-DHEXMODE CFLAGS = -pipe -g -Wall -Winline -O3 -fPIC -finline-functions -finline-limit=600000 diff --git a/libtrbnet/trbcmd.c b/libtrbnet/trbcmd.c index 4ea0483..306131a 100644 --- a/libtrbnet/trbcmd.c +++ b/libtrbnet/trbcmd.c @@ -35,7 +35,7 @@ static int hexMode = HEXMODE; -static const char trbcmd_version[] = "$Revision: 2.45 $"; +static const char trbcmd_version[] = "$Revision: 2.46 $"; #define BACKLOG 10 static uint16_t tcp_port = 55555; @@ -66,8 +66,6 @@ void usage(const char *progName) fprintf(STDOUT, " level 1: TRB_Package debugging\n"); fprintf(STDOUT, " level 2: +FIFO debugging\n"); fprintf(STDOUT, " -D FIFO DMA-Mode\n"); - fprintf(STDOUT, - " -l lazy-mode: skip most consistency-checks of packages\n"); fprintf(STDOUT, " -H hex-mode: all arguments will be interpreted " "as hexadecimal-numbers\n"); @@ -152,11 +150,10 @@ int start(int argc, char **argv) USER_BUFFER_SIZE = 786432; /* 0xc000 * 4 Byte */ trb_debug = 0; - trb_lazy = 0; /* Parse Arguments */ optind = 1; - while ((opt = getopt(argc, argv, "+hf:n:d:DlHMV")) != -1) { + while ((opt = getopt(argc, argv, "+hf:n:d:DHMV")) != -1) { switch (opt) { case '?': usage(basename(argv[0])); @@ -176,9 +173,6 @@ int start(int argc, char **argv) case 'D': trb_dma = 1; break; - case 'l': - trb_lazy = 1; - break; case 'H': hexMode = 1; break; @@ -385,7 +379,7 @@ int start(int argc, char **argv) } } free(data); - + } else if (strncmp(cmd[0], "rm", CMD_SIZE) == 0) { /*******************************************/ diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index e864178..66ffcce 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -1,4 +1,4 @@ -const char trbnet_version[] = "$Revision: 2.59 $"; +const char trbnet_version[] = "$Revision: 2.60 $"; #include #include @@ -142,7 +142,6 @@ static int semid = -1; static const key_t sem_key = 0x545242; unsigned int trb_debug = 0; -unsigned int trb_lazy = 0; unsigned int trb_dma = 0; FILE* trb_stderr = NULL; @@ -551,9 +550,8 @@ static int trb_fifo_read(uint8_t channel, fifoDebugCtr, *tmp); } - if ((trb_lazy == 0) && - (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) != - (counter - 1) % 2)) { + if (((*tmp & MASK_FIFO_TYPE) >> SHIFT_FIFO_TYPE) != + (counter - 1) % 2) { /* Error: invalid sequence (not 0, 1, .), flush FIFO-BUFFER and exit */ fifo_flush(channel); trb_errno = TRB_FIFO_SEQUENZ; @@ -592,19 +590,18 @@ static int trb_fifo_read(uint8_t channel, /* DEBUG INFO */ if (trb_debug > 0) { TRB_Package_dump(&package); - fprintf(trb_stderr, "-------------------------------------------------\n"); + fprintf(trb_stderr, + "-------------------------------------------------\n"); } - if (trb_lazy == 0) { - /* First package: headerType must be HDR or TRM */ - if (packageCtr == 0) { - if (!((headerType == HEADER_HDR) || (headerType == HEADER_TRM))) { - fifo_flush(channel); - trb_errno = TRB_FIFO_INVALID_HEADER; - return -1; - } + /* First package: headerType must be HDR or TRM */ + if (packageCtr == 0) { + if (!((headerType == HEADER_HDR) || (headerType == HEADER_TRM))) { + fifo_flush(channel); + trb_errno = TRB_FIFO_INVALID_HEADER; + return -1; } - + /* Check Header H0 */ if (((package.H0 & MASK_HEADER_REPLY) >> SHIFT_HEADER_REPLY != 0x01) || @@ -645,6 +642,9 @@ static int trb_fifo_read(uint8_t channel, } if (dataCtr < dsize) { data[dataCtr++] = (uint32_t)package.F0; +#ifdef TRB_DEBUGGER + fprintf(trb_stderr, "D: 0x%04x ", data[dataCtr - 1]); +#endif } else { fifo_flush(channel); trb_errno = TRB_USER_BUFFER_OVF; @@ -661,6 +661,9 @@ static int trb_fifo_read(uint8_t channel, if (dataCtr < dsize) { data[dataCtr++] = (((uint32_t)package.F1 << 16) | ((uint32_t)package.F2)); +#ifdef TRB_DEBUGGER + fprintf(trb_stderr, "0x%08x\n", data[dataCtr - 1]); +#endif endPointCtr++; } else { fifo_flush(channel); @@ -694,6 +697,9 @@ static int trb_fifo_read(uint8_t channel, memLen = 0; lastHeader = &data[dataCtr]; data[dataCtr++] = (uint32_t)package.F0; +#ifdef TRB_DEBUGGER + fprintf(trb_stderr, "D: H: 0x%04x\n", data[dataCtr - 1]); +#endif } else { fifo_flush(channel); trb_errno = TRB_USER_BUFFER_OVF; @@ -706,6 +712,10 @@ static int trb_fifo_read(uint8_t channel, if (package.F0 == 0x0000) break; /* it a hack, ask Jan */ data[dataCtr++] = (((uint32_t)package.F1 << 16) | ((uint32_t)package.F2)); +#ifdef TRB_DEBUGGER + fprintf(trb_stderr, + "D: 0x%04x 0x%08x\n", memLen, data[dataCtr - 1]); +#endif memLen++; } else { fifo_flush(channel); @@ -765,6 +775,9 @@ static int trb_fifo_read(uint8_t channel, ((uint32_t)package.F1)) : (((uint32_t)package.F2 << 16) | ((uint32_t)package.F3)); +#ifdef TRB_DEBUGGER + fprintf(trb_stderr, "D: 0x%08x\n", data[dataCtr - 1]); +#endif } else { fifo_flush(channel); trb_errno = TRB_USER_BUFFER_OVF; @@ -814,6 +827,12 @@ static int trb_fifo_read(uint8_t channel, data[dataCtr++] = (uint32_t)package.F0; data[dataCtr++] = (uint32_t)sourceAddress; endPointCtr++; +#ifdef TRB_DEBUGGER + fprintf(trb_stderr, "D: 0x%04x 0x%08x%08x 0x%02x\n", + (uint32_t)sourceAddress, + uidLow, uidHigh, + (uint32_t)package.F0); +#endif } else { fifo_flush(channel); trb_errno = TRB_USER_BUFFER_OVF; @@ -884,36 +903,34 @@ static int trb_fifo_read(uint8_t channel, trb_term.sequence = package.F3; trb_term.channel = channel; - if (trb_lazy == 0) { - /* Check whether last package is complete */ - if ((packageCtr >= 0) && (counter != 5)) { - trb_errno = TRB_FIFO_INCOMPLETE_PACKAGE; - return -1; - } - - /* Check whether last package is a TERMINATION Package */ - if (headerType != HEADER_TRM) { - trb_errno = TRB_FIFO_MISSING_TERM_HEADER; - return -1; - } - - /* Check StatusBits of TerminationPackage */ - if ((trb_term.status_common == 0) && (trb_term.status_channel == 0)) { - trb_errno = TRB_ENDPOINT_NOT_REACHED; - return -1; - } - - if ((trb_term.status_common & 0x007e) != 0) { - trb_errno = TRB_STATUS_ERROR; - return -1; - } + /* Check whether last package is complete */ + if ((packageCtr >= 0) && (counter != 5)) { + trb_errno = TRB_FIFO_INCOMPLETE_PACKAGE; + return -1; + } - if ((channel == 3) && ((trb_term.status_channel & 0x0002) != 0)) { - trb_errno = TRB_STATUS_ERROR; - return -1; - } + /* Check whether last package is a TERMINATION Package */ + if (headerType != HEADER_TRM) { + trb_errno = TRB_FIFO_MISSING_TERM_HEADER; + return -1; + } + + /* Check StatusBits of TerminationPackage */ + if ((trb_term.status_common == 0) && (trb_term.status_channel == 0)) { + trb_errno = TRB_ENDPOINT_NOT_REACHED; + return -1; + } + + if ((trb_term.status_common & 0x007e) != 0) { + trb_errno = TRB_STATUS_ERROR; + return -1; } + if ((channel == 3) && ((trb_term.status_channel & 0x0002) != 0)) { + trb_errno = TRB_STATUS_ERROR; + return -1; + } + return dataCtr; } diff --git a/libtrbnet/trbnet.h b/libtrbnet/trbnet.h index a514654..82062aa 100644 --- a/libtrbnet/trbnet.h +++ b/libtrbnet/trbnet.h @@ -7,7 +7,6 @@ extern const char trbnet_version[]; #include extern unsigned int trb_debug; -extern unsigned int trb_lazy; extern unsigned int trb_dma; extern FILE* trb_stderr; -- 2.43.0