1 /************************************************************************** 2 3 Copyright (c) 2001-2005, Intel Corporation 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 3. Neither the name of the Intel Corporation nor the names of its 17 contributors may be used to endorse or promote products derived from 18 this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32 ***************************************************************************/ 33 34 /* $OpenBSD: if_ixgb_osdep.h,v 1.5 2024/10/22 21:50:02 jsg Exp $ */ 35 36 #ifndef _IXGB_OPENBSD_OS_H_ 37 #define _IXGB_OPENBSD_OS_H_ 38 39 #define ASSERT(x) if(!(x)) panic("IXGB: x") 40 41 #define usec_delay(x) DELAY(x) 42 #define msec_delay(x) DELAY(1000*(x)) 43 44 #define DBG 0 45 #define MSGOUT(S, A, B) printf(S "\n", A, B) 46 #define DEBUGFUNC(F) DEBUGOUT(F); 47 #if DBG 48 #define DEBUGOUT(S) printf(S "\n") 49 #define DEBUGOUT1(S,A) printf(S "\n",A) 50 #define DEBUGOUT2(S,A,B) printf(S "\n",A,B) 51 #define DEBUGOUT3(S,A,B,C) printf(S "\n",A,B,C) 52 #define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S "\n",A,B,C,D,E,F,G) 53 #else 54 #define DEBUGOUT(S) 55 #define DEBUGOUT1(S,A) 56 #define DEBUGOUT2(S,A,B) 57 #define DEBUGOUT3(S,A,B,C) 58 #define DEBUGOUT7(S,A,B,C,D,E,F,G) 59 #endif 60 61 #define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */ 62 63 #define le16_to_cpu letoh16 64 65 struct ixgb_osdep { 66 bus_space_tag_t mem_bus_space_tag; 67 bus_space_handle_t mem_bus_space_handle; 68 struct device *dev; 69 70 struct pci_attach_args ixgb_pa; 71 72 bus_size_t ixgb_memsize; 73 bus_addr_t ixgb_membase; 74 }; 75 76 #define IXGB_WRITE_FLUSH(a) IXGB_READ_REG(a, STATUS) 77 78 #define IXGB_READ_REG(a, reg) \ 79 bus_space_read_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \ 80 ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \ 81 IXGB_##reg) 82 83 #define IXGB_WRITE_REG(a, reg, value) \ 84 bus_space_write_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \ 85 ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \ 86 IXGB_##reg, value) 87 88 #define IXGB_READ_REG_ARRAY(a, reg, offset) \ 89 bus_space_read_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \ 90 ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \ 91 (IXGB_##reg + ((offset) << 2))) 92 93 #define IXGB_WRITE_REG_ARRAY(a, reg, offset, value) \ 94 bus_space_write_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \ 95 ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \ 96 (IXGB_##reg + ((offset) << 2)), value) 97 98 #ifdef DEBUG 99 #define IXGB_KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0) 100 #else 101 #define IXGB_KASSERT(exp,msg) 102 #endif 103 104 #endif /* _IXGB_OPENBSD_OS_H_ */ 105