1 /* 2 * CDDL HEADER START 3 * 4 * Copyright(c) 2007-2008 Intel Corporation. All rights reserved. 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at: 10 * http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When using or redistributing this file, you may do so under the 15 * License only. No other modification of this header is permitted. 16 * 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 */ 23 24 /* 25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms of the CDDL. 27 */ 28 29 #ifndef _IGB_OSDEP_H 30 #define _IGB_OSDEP_H 31 32 #pragma ident "%Z%%M% %I% %E% SMI" 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #include <sys/types.h> 39 #include <sys/conf.h> 40 #include <sys/debug.h> 41 #include <sys/stropts.h> 42 #include <sys/stream.h> 43 #include <sys/strlog.h> 44 #include <sys/kmem.h> 45 #include <sys/stat.h> 46 #include <sys/kstat.h> 47 #include <sys/modctl.h> 48 #include <sys/errno.h> 49 #include <sys/ddi.h> 50 #include <sys/dditypes.h> 51 #include <sys/sunddi.h> 52 #include <sys/pci.h> 53 #include <sys/atomic.h> 54 #include <sys/note.h> 55 #include "igb_debug.h" 56 57 #define usec_delay(x) drv_usecwait(x) 58 #define msec_delay(x) drv_usecwait(x * 1000) 59 60 #ifdef IGB_DEBUG 61 #define DEBUGOUT(S) IGB_DEBUGLOG_0(NULL, S) 62 #define DEBUGOUT1(S, A) IGB_DEBUGLOG_1(NULL, S, A) 63 #define DEBUGOUT2(S, A, B) IGB_DEBUGLOG_2(NULL, S, A, B) 64 #define DEBUGOUT3(S, A, B, C) IGB_DEBUGLOG_3(NULL, S, A, B, C) 65 #define DEBUGFUNC(F) 66 #else 67 #define DEBUGOUT(S) 68 #define DEBUGOUT1(S, A) 69 #define DEBUGOUT2(S, A, B) 70 #define DEBUGOUT3(S, A, B, C) 71 #define DEBUGFUNC(F) 72 #endif 73 74 #define OS_DEP(hw) ((struct igb_osdep *)((hw)->back)) 75 76 #define FALSE 0 77 #define TRUE 1 78 79 #define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */ 80 #define PCI_COMMAND_REGISTER 0x04 81 #define PCI_EX_CONF_CAP 0xE0 82 83 84 /* 85 * Constants used in setting flow control thresholds 86 */ 87 #define E1000_PBA_MASK 0xffff 88 #define E1000_PBA_SHIFT 10 89 #define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */ 90 #define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */ 91 #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */ 92 93 /* PHY Extended Status Register */ 94 #define IEEE_ESR_1000T_HD_CAPS 0x1000 /* 1000T HD capable */ 95 #define IEEE_ESR_1000T_FD_CAPS 0x2000 /* 1000T FD capable */ 96 #define IEEE_ESR_1000X_HD_CAPS 0x4000 /* 1000X HD capable */ 97 #define IEEE_ESR_1000X_FD_CAPS 0x8000 /* 1000X FD capable */ 98 99 #define E1000_WRITE_FLUSH(a) (void) E1000_READ_REG(a, E1000_STATUS) 100 101 #define E1000_WRITE_REG(hw, reg, value) \ 102 ddi_put32((OS_DEP(hw))->reg_handle, \ 103 (uint32_t *)((uintptr_t)(hw)->hw_addr + reg), (value)) 104 105 #define E1000_READ_REG(hw, reg) \ 106 ddi_get32((OS_DEP(hw))->reg_handle, \ 107 (uint32_t *)((uintptr_t)(hw)->hw_addr + reg)) 108 109 #define E1000_WRITE_REG_ARRAY(hw, reg, offset, value) \ 110 ddi_put32((OS_DEP(hw))->reg_handle, \ 111 (uint32_t *)((uintptr_t)(hw)->hw_addr + reg + ((offset) << 2)), \ 112 (value)) 113 114 #define E1000_READ_REG_ARRAY(hw, reg, offset) \ 115 ddi_get32((OS_DEP(hw))->reg_handle, \ 116 (uint32_t *)((uintptr_t)(hw)->hw_addr + reg + ((offset) << 2))) 117 118 #define E1000_WRITE_REG_ARRAY_DWORD(a, reg, offset, value) \ 119 E1000_WRITE_REG_ARRAY(a, reg, offset, value) 120 #define E1000_READ_REG_ARRAY_DWORD(a, reg, offset) \ 121 E1000_READ_REG_ARRAY(a, reg, offset) 122 123 #define msec_delay_irq msec_delay 124 125 #define UNREFERENCED_PARAMETER(x) _NOTE(ARGUNUSED(x)) 126 127 typedef int8_t s8; 128 typedef int16_t s16; 129 typedef int32_t s32; 130 typedef int64_t s64; 131 typedef uint8_t u8; 132 typedef uint16_t u16; 133 typedef uint32_t u32; 134 typedef uint64_t u64; 135 typedef boolean_t bool; 136 137 struct igb_osdep { 138 ddi_acc_handle_t reg_handle; 139 ddi_acc_handle_t cfg_handle; 140 struct igb *igb; 141 }; 142 143 144 #ifdef __cplusplus 145 } 146 #endif 147 148 #endif /* _IGB_OSDEP_H */ 149