1185743Ssam#ifndef _DUMPREGS_ 2185743Ssam#define _DUMPREGS_ 3185743Ssam/*- 4185743Ssam * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 5185743Ssam * All rights reserved. 6185743Ssam * 7185743Ssam * Redistribution and use in source and binary forms, with or without 8185743Ssam * modification, are permitted provided that the following conditions 9185743Ssam * are met: 10185743Ssam * 1. Redistributions of source code must retain the above copyright 11185743Ssam * notice, this list of conditions and the following disclaimer, 12185743Ssam * without modification. 13185743Ssam * 2. Redistributions in binary form must reproduce at minimum a disclaimer 14185743Ssam * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 15185743Ssam * redistribution must be conditioned upon including a substantially 16185743Ssam * similar Disclaimer requirement for further binary redistribution. 17185743Ssam * 18185743Ssam * NO WARRANTY 19185743Ssam * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20185743Ssam * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21185743Ssam * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 22185743Ssam * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23185743Ssam * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 24185743Ssam * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25185743Ssam * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26185743Ssam * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 27185743Ssam * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28185743Ssam * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29185743Ssam * THE POSSIBILITY OF SUCH DAMAGES. 30185743Ssam * 31185743Ssam * $FreeBSD$ 32185743Ssam */ 33185743Ssam 34185743Ssam#define __constructor __attribute__((constructor)) 35185743Ssam 36185743Ssamstruct dumpreg { 37185743Ssam uint32_t addr; 38185743Ssam const char *name; 39189701Ssam const char *bits; 40185743Ssam int type; 41185743Ssam u_int srevMin, srevMax; 42185743Ssam u_int phyMin, phyMax; 43185743Ssam}; 44185743Ssam#define SREV(v,r) (((v) << 16) | (r)) 45185743Ssam#define MAC_MATCH(dr, mv, mr) \ 46185743Ssam ((dr)->srevMin <= SREV(mv,mr) && SREV(mv,mr) < (dr)->srevMax) 47185743Ssam 48185743Ssam#define PHY_MATCH(dr, pr) \ 49185743Ssam ((dr)->phyMin <= (pr) && (pr) < (dr)->phyMax) 50185743Ssam#define PHYANY 0,0xffff 51185743Ssam 52185743Ssamenum { 53185743Ssam DUMP_BASIC = 0x0001, /* basic/default registers */ 54185743Ssam DUMP_KEYCACHE = 0x0002, /* key cache */ 55185743Ssam DUMP_BASEBAND = 0x0004, /* baseband */ 56185743Ssam DUMP_INTERRUPT = 0x0008, /* interrupt state */ 57185743Ssam DUMP_XR = 0x0010, /* XR state */ 58185743Ssam DUMP_QCU = 0x0020, /* QCU state */ 59185743Ssam DUMP_DCU = 0x0040, /* DCU state */ 60185743Ssam 61185743Ssam DUMP_PUBLIC = 0x0061, /* public = BASIC+QCU+DCU */ 62185743Ssam DUMP_ALL = 0xffff 63185743Ssam}; 64185743Ssam 65189701Ssam#define _DEFREG(_addr, _name, _type) \ 66189701Ssam { .addr = _addr, .name = _name, .type = _type } 67189701Ssam#define _DEFREGx(_addr, _name, _type, _srevmin, _srevmax) \ 68189701Ssam { .addr = _addr, .name = _name, .type = _type, \ 69189701Ssam .srevMin = _srevmin, .srevMax = _srevmax } 70189701Ssam#define _DEFREGfmt(_addr, _name, _type, _fmt) \ 71189701Ssam { .addr = _addr, .name = _name, .type = _type, .bits = _fmt } 72189701Ssam#define DEFVOID(_addr, _name) _DEFREG(_addr, _name, 0) 73189701Ssam#define DEFVOIDx(_addr, _name, _smin, _smax) \ 74189701Ssam __DEFREGx(_addr, _name, _smin, _smax, 0) 75189701Ssam#define DEFVOIDfmt(_addr, _name, _fmt) \ 76189701Ssam _DEFREGfmt(_addr, _name, 0, _fmt) 77189701Ssam#define DEFBASIC(_addr, _name) _DEFREG(_addr, _name, DUMP_BASIC) 78189701Ssam#define DEFBASICfmt(_addr, _name, _fmt) \ 79189701Ssam _DEFREGfmt(_addr, _name, DUMP_BASIC, _fmt) 80189701Ssam#define DEFBASICx(_addr, _name, _smin, _smax) \ 81189701Ssam _DEFREGx(_addr, _name, DUMP_BASIC, _smin, _smax) 82189701Ssam#define DEFBB(_addr, _name) _DEFREG(_addr, _name, DUMP_BASEBAND) 83189701Ssam#define DEFINT(_addr, _name) _DEFREG(_addr, _name, DUMP_INTERRUPT) 84189701Ssam#define DEFINTfmt(_addr, _name, _fmt) \ 85189701Ssam _DEFREGfmt(_addr, _name, DUMP_INTERRUPT, _fmt) 86189701Ssam#define DEFQCU(_addr, _name) _DEFREG(_addr, _name, DUMP_QCU) 87189701Ssam#define DEFDCU(_addr, _name) _DEFREG(_addr, _name, DUMP_DCU) 88189701Ssam 89185743Ssamvoid register_regs(struct dumpreg *_regs, u_int _nregs, 90185743Ssam int def_srev_min, int def_srev_max, 91185743Ssam int def_phy_min, int def_phy_max); 92185743Ssamvoid register_keycache(u_int nslots, 93185743Ssam int def_srev_min, int def_srev_max, 94185743Ssam int def_phy_min, int def_phy_max); 95185743Ssamvoid register_range(u_int brange, u_int erange, int what, 96185743Ssam int def_srev_min, int def_srev_max, 97185743Ssam int def_phy_min, int def_phy_max); 98185743Ssam#endif /* _DUMPREGS_ */ 99