diff options
author | adrian <adrian@FreeBSD.org> | 2011-04-05 15:11:09 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2011-04-05 15:11:09 +0000 |
commit | 45d22c55074e1afec867c885d27bc871a6a105ec (patch) | |
tree | 9fe2009fc6c2c29388242660ed981555b9146f66 | |
parent | 4fde1ce654bbaabe7c045d8f2cc469c73b079816 (diff) | |
download | FreeBSD-src-45d22c55074e1afec867c885d27bc871a6a105ec.zip FreeBSD-src-45d22c55074e1afec867c885d27bc871a6a105ec.tar.gz |
Flesh out a simple tool to print the ALQ dump generated by the HAL.
-rw-r--r-- | tools/tools/ath/Makefile | 3 | ||||
-rw-r--r-- | tools/tools/ath/arcode/Makefile | 8 | ||||
-rw-r--r-- | tools/tools/ath/arcode/arcode.c | 116 |
3 files changed, 126 insertions, 1 deletions
diff --git a/tools/tools/ath/Makefile b/tools/tools/ath/Makefile index ef368ce..e5b9d3c 100644 --- a/tools/tools/ath/Makefile +++ b/tools/tools/ath/Makefile @@ -1,5 +1,6 @@ # $FreeBSD$ -SUBDIR= athdebug athdecode athkey athpoke athprom athrd athregs athstats ath_ee_v14_print ath_prom_read ath_ee_v4k_print +SUBDIR= arcode athdebug athdecode athkey athpoke athprom athrd athregs +SUBDIR+= athstats ath_ee_v14_print ath_prom_read ath_ee_v4k_print .include <bsd.subdir.mk> diff --git a/tools/tools/ath/arcode/Makefile b/tools/tools/ath/arcode/Makefile new file mode 100644 index 0000000..9611a6f --- /dev/null +++ b/tools/tools/ath/arcode/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +PROG= arcode +NOMAN= yes + +.include <../Makefile.inc> + +.include <bsd.prog.mk> diff --git a/tools/tools/ath/arcode/arcode.c b/tools/tools/ath/arcode/arcode.c new file mode 100644 index 0000000..deed16d --- /dev/null +++ b/tools/tools/ath/arcode/arcode.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD$ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> + +#include <sys/types.h> +#include <sys/alq.h> + +#include "ah_decode.h" + +#define MAX_MARKERS 9 + +const char *markers[] = { + "AH_MARK_RESET", /* ar*Reset entry, bChannelChange */ + "AH_MARK_RESET_LINE", /* ar*_reset.c, line %d */ + "AH_MARK_RESET_DONE", /* ar*Reset exit, error code */ + "AH_MARK_CHIPRESET", /* ar*ChipReset, channel num */ + "AH_MARK_PERCAL", /* ar*PerCalibration, channel num */ + "AH_MARK_SETCHANNEL", /* ar*SetChannel, channel num */ + "AH_MARK_ANI_RESET", /* ar*AniReset, opmode */ + "AH_MARK_ANI_POLL", /* ar*AniReset, listen time */ + "AH_MARK_ANI_CONTROL", /* ar*AniReset, cmd */ +}; + +static void +op_read(struct athregrec *a) +{ + printf("read\t%.8x = %.8x\n", a->reg, a->val); +} + +static void +op_write(struct athregrec *a) +{ + printf("write\t%.8x = %.8x\n", a->reg, a->val); +} + +static void +op_device(struct athregrec *a) +{ + printf("device\t0x%x/0x%x\n", a->reg, a->val); +} + +static void +op_mark(struct athregrec *a) +{ + const char *s = "UNKNOWN"; +#if 0 + if (a->reg <= MAX_MARKERS) + s = markers[a->reg]; +#endif + + printf("mark\t%d (%d): %d\n", s, a->reg, a->val); +} + +int +main(int argc, const char *argv[]) +{ + const char *file = argv[1]; + int fd; + struct athregrec a; + int r; + + if (argc < 1) { + printf("usage: %s <ahq log>\n", argv[0]); + exit(127); + } + + fd = open(file, O_RDONLY); + if (fd < 0) { + perror("open"); + exit(127); + } + + while (1) { + r = read(fd, &a, sizeof(a)); + if (r != sizeof(a)) + break; + switch (a.op) { + case OP_READ: + op_read(&a); + break; + case OP_WRITE: + op_write(&a); + break; + case OP_DEVICE: + op_device(&a); + break; + case OP_MARK: + op_mark(&a); + break; + default: + printf("op: %s; reg: %x; val: %x\n", + a.op, a.reg, a.val); + } + } + close(fd); +} |