xref: /dragonfly/tools/tools/ath/common/dumpregs.h (revision 7d3e9a5b)
1 #ifndef _DUMPREGS_
2 #define	_DUMPREGS_
3 /*-
4  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer,
12  *    without modification.
13  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
15  *    redistribution must be conditioned upon including a substantially
16  *    similar Disclaimer requirement for further binary redistribution.
17  *
18  * NO WARRANTY
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY
22  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
24  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29  * THE POSSIBILITY OF SUCH DAMAGES.
30  *
31  * $FreeBSD: src/tools/tools/ath/common/dumpregs.h,v 1.1 2009/03/11 17:46:01 sam Exp $
32  */
33 
34 #define	__constructor	__attribute__((constructor))
35 
36 struct dumpreg {
37 	uint32_t	addr;
38 	const char	*name;
39 	const char	*bits;
40 	int		type;
41 	u_int		srevMin, srevMax;
42 	u_int		phyMin, phyMax;
43 };
44 #define	SREV(v,r)	(((v) << 16) | (r))
45 #define	MAC_MATCH(dr, mv, mr) \
46 	((dr)->srevMin <= SREV(mv,mr) && SREV(mv,mr) < (dr)->srevMax)
47 
48 #define	PHY_MATCH(dr, pr) \
49 	((dr)->phyMin <= (pr) && (pr) < (dr)->phyMax)
50 #define	PHYANY	0,0xffff
51 
52 enum {
53 	DUMP_BASIC	= 0x0001,	/* basic/default registers */
54 	DUMP_KEYCACHE	= 0x0002,	/* key cache */
55 	DUMP_BASEBAND	= 0x0004,	/* baseband */
56 	DUMP_INTERRUPT	= 0x0008,	/* interrupt state */
57 	DUMP_XR		= 0x0010,	/* XR state */
58 	DUMP_QCU	= 0x0020,	/* QCU state */
59 	DUMP_DCU	= 0x0040,	/* DCU state */
60 
61 	DUMP_PUBLIC	= 0x0061,	/* public = BASIC+QCU+DCU */
62 	DUMP_ALL	= 0xffff
63 };
64 
65 #define	_DEFREG(_addr, _name, _type) \
66     { .addr = _addr, .name = _name, .type = _type }
67 #define	_DEFREGx(_addr, _name, _type, _srevmin, _srevmax) \
68     { .addr = _addr, .name = _name, .type = _type, \
69      .srevMin = _srevmin, .srevMax = _srevmax }
70 #define	_DEFREGfmt(_addr, _name, _type, _fmt) \
71     { .addr = _addr, .name = _name, .type = _type, .bits = _fmt }
72 #define	DEFVOID(_addr, _name)	_DEFREG(_addr, _name, 0)
73 #define	DEFVOIDx(_addr, _name, _smin, _smax) \
74 	__DEFREGx(_addr, _name, _smin, _smax, 0)
75 #define	DEFVOIDfmt(_addr, _name, _fmt) \
76 	_DEFREGfmt(_addr, _name, 0, _fmt)
77 #define	DEFBASIC(_addr, _name)	_DEFREG(_addr, _name, DUMP_BASIC)
78 #define	DEFBASICfmt(_addr, _name, _fmt) \
79 	_DEFREGfmt(_addr, _name, DUMP_BASIC, _fmt)
80 #define	DEFBASICx(_addr, _name, _smin, _smax) \
81 	_DEFREGx(_addr, _name, DUMP_BASIC, _smin, _smax)
82 #define	DEFBB(_addr, _name)	_DEFREG(_addr, _name, DUMP_BASEBAND)
83 #define	DEFINT(_addr, _name)	_DEFREG(_addr, _name, DUMP_INTERRUPT)
84 #define	DEFINTfmt(_addr, _name, _fmt) \
85 	_DEFREGfmt(_addr, _name, DUMP_INTERRUPT, _fmt)
86 #define	DEFQCU(_addr, _name)	_DEFREG(_addr, _name, DUMP_QCU)
87 #define	DEFDCU(_addr, _name)	_DEFREG(_addr, _name, DUMP_DCU)
88 
89 void	register_regs(struct dumpreg *_regs, u_int _nregs,
90 	    int def_srev_min, int def_srev_max,
91 	    int def_phy_min, int def_phy_max);
92 void	register_keycache(u_int nslots,
93 	    int def_srev_min, int def_srev_max,
94 	    int def_phy_min, int def_phy_max);
95 void	register_range(u_int brange, u_int erange, int what,
96 	    int def_srev_min, int def_srev_max,
97 	    int def_phy_min, int def_phy_max);
98 #endif /* _DUMPREGS_ */
99