if_ixgb_osdep.h revision 129794
1129794Stackerman/************************************************************************** 2129794Stackerman 3129794StackermanCopyright (c) 2001-2004, Intel Corporation 4129794StackermanAll rights reserved. 5129794Stackerman 6129794StackermanRedistribution and use in source and binary forms, with or without 7129794Stackermanmodification, are permitted provided that the following conditions are met: 8129794Stackerman 9129794Stackerman 1. Redistributions of source code must retain the above copyright notice, 10129794Stackerman this list of conditions and the following disclaimer. 11129794Stackerman 12129794Stackerman 2. Redistributions in binary form must reproduce the above copyright 13129794Stackerman notice, this list of conditions and the following disclaimer in the 14129794Stackerman documentation and/or other materials provided with the distribution. 15129794Stackerman 16129794Stackerman 3. Neither the name of the Intel Corporation nor the names of its 17129794Stackerman contributors may be used to endorse or promote products derived from 18129794Stackerman this software without specific prior written permission. 19129794Stackerman 20129794StackermanTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21129794StackermanAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22129794StackermanIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23129794StackermanARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24129794StackermanLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25129794StackermanCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26129794StackermanSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27129794StackermanINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28129794StackermanCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29129794StackermanARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30129794StackermanPOSSIBILITY OF SUCH DAMAGE. 31129794Stackerman 32129794Stackerman***************************************************************************/ 33129794Stackerman 34129794Stackerman/*$FreeBSD: head/sys/dev/ixgb/if_ixgb_osdep.h 129794 2004-05-28 00:23:00Z tackerman $*/ 35129794Stackerman 36129794Stackerman#ifndef _FREEBSD_OS_H_ 37129794Stackerman#define _FREEBSD_OS_H_ 38129794Stackerman 39129794Stackerman#include <sys/types.h> 40129794Stackerman#include <sys/param.h> 41129794Stackerman#include <sys/systm.h> 42129794Stackerman#include <sys/mbuf.h> 43129794Stackerman#include <sys/protosw.h> 44129794Stackerman#include <sys/socket.h> 45129794Stackerman#include <sys/malloc.h> 46129794Stackerman#include <sys/kernel.h> 47129794Stackerman#include <sys/bus.h> 48129794Stackerman#include <machine/bus.h> 49129794Stackerman#include <sys/rman.h> 50129794Stackerman#include <machine/resource.h> 51129794Stackerman#include <vm/vm.h> 52129794Stackerman#include <vm/pmap.h> 53129794Stackerman#include <machine/clock.h> 54129794Stackerman#if __FreeBSD_version >= 502000 55129794Stackerman #include <dev/pci/pcivar.h> 56129794Stackerman #include <dev/pci/pcireg.h> 57129794Stackerman#else 58129794Stackerman #include <pci/pcivar.h> 59129794Stackerman #include <pci/pcireg.h> 60129794Stackerman#endif 61129794Stackerman 62129794Stackerman#define ASSERT(x) if(!(x)) panic("IXGB: x") 63129794Stackerman 64129794Stackerman/* The happy-fun DELAY macro is defined in /usr/src/sys/i386/include/clock.h */ 65129794Stackerman#define usec_delay(x) DELAY(x) 66129794Stackerman#define msec_delay(x) DELAY(1000*(x)) 67129794Stackerman 68129794Stackerman#define DBG 0 69129794Stackerman#define MSGOUT(S, A, B) printf(S "\n", A, B) 70129794Stackerman#define DEBUGFUNC(F) DEBUGOUT(F); 71129794Stackerman#if DBG 72129794Stackerman #define DEBUGOUT(S) printf(S "\n") 73129794Stackerman #define DEBUGOUT1(S,A) printf(S "\n",A) 74129794Stackerman #define DEBUGOUT2(S,A,B) printf(S "\n",A,B) 75129794Stackerman #define DEBUGOUT3(S,A,B,C) printf(S "\n",A,B,C) 76129794Stackerman #define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S "\n",A,B,C,D,E,F,G) 77129794Stackerman#else 78129794Stackerman #define DEBUGOUT(S) 79129794Stackerman #define DEBUGOUT1(S,A) 80129794Stackerman #define DEBUGOUT2(S,A,B) 81129794Stackerman #define DEBUGOUT3(S,A,B,C) 82129794Stackerman #define DEBUGOUT7(S,A,B,C,D,E,F,G) 83129794Stackerman#endif 84129794Stackerman 85129794Stackerman#define FALSE 0 86129794Stackerman#define TRUE 1 87129794Stackerman#define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */ 88129794Stackerman#define PCI_COMMAND_REGISTER PCIR_COMMAND 89129794Stackerman 90129794Stackerman#define le16_to_cpu 91129794Stackerman 92129794Stackermanstruct ixgb_osdep 93129794Stackerman{ 94129794Stackerman bus_space_tag_t mem_bus_space_tag; 95129794Stackerman bus_space_handle_t mem_bus_space_handle; 96129794Stackerman struct device *dev; 97129794Stackerman}; 98129794Stackerman 99129794Stackerman#define IXGB_WRITE_FLUSH(a) IXGB_READ_REG(a, STATUS) 100129794Stackerman 101129794Stackerman#define IXGB_READ_REG(a, reg) (\ 102129794Stackerman bus_space_read_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \ 103129794Stackerman ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \ 104129794Stackerman IXGB_##reg)) 105129794Stackerman 106129794Stackerman#define IXGB_WRITE_REG(a, reg, value) (\ 107129794Stackerman bus_space_write_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \ 108129794Stackerman ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \ 109129794Stackerman IXGB_##reg, value)) 110129794Stackerman 111129794Stackerman 112129794Stackerman#define IXGB_READ_REG_ARRAY(a, reg, offset) (\ 113129794Stackerman bus_space_read_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \ 114129794Stackerman ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \ 115129794Stackerman (IXGB_##reg + ((offset) << 2)))) 116129794Stackerman 117129794Stackerman#define IXGB_WRITE_REG_ARRAY(a, reg, offset, value) (\ 118129794Stackerman bus_space_write_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \ 119129794Stackerman ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \ 120129794Stackerman (IXGB_##reg + ((offset) << 2)), value)) 121129794Stackerman 122129794Stackerman#endif /* _FREEBSD_OS_H_ */ 123129794Stackerman 124