[BACK]Return to if_em_osdep.h CVS log [TXT][DIR] Up to [local] / sys / dev / pci

Annotation of sys/dev/pci/if_em_osdep.h, Revision 1.1.1.1

1.1       nbrk        1: /**************************************************************************
                      2:
                      3: Copyright (c) 2001-2006, 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_em_osdep.h,v 1.10 2006/11/06 03:52:37 brad Exp $ */
                     35: /* $FreeBSD: if_em_osdep.h,v 1.11 2003/05/02 21:17:08 pdeuskar Exp $ */
                     36:
                     37: #ifndef _EM_OPENBSD_OS_H_
                     38: #define _EM_OPENBSD_OS_H_
                     39:
                     40: /* The happy-fun DELAY macro is defined in /usr/src/sys/i386/include/clock.h */
                     41: #define usec_delay(x)          DELAY(x)
                     42: #define msec_delay(x)          DELAY(1000*(x))
                     43: /* TODO: Should we be paranoid about delaying in interrupt context? */
                     44: #define msec_delay_irq(x)      DELAY(1000*(x))
                     45:
                     46: #define MSGOUT(S, A, B)                printf(S "\n", A, B)
                     47: #define DEBUGFUNC(F)           DEBUGOUT(F);
                     48: #ifdef DBG
                     49:        #define DEBUGOUT(S)                     printf(S "\n")
                     50:        #define DEBUGOUT1(S,A)                  printf(S "\n",A)
                     51:        #define DEBUGOUT2(S,A,B)                printf(S "\n",A,B)
                     52:        #define DEBUGOUT3(S,A,B,C)              printf(S "\n",A,B,C)
                     53:        #define DEBUGOUT7(S,A,B,C,D,E,F,G)      printf(S "\n",A,B,C,D,E,F,G)
                     54: #else
                     55:        #define DEBUGOUT(S)
                     56:        #define DEBUGOUT1(S,A)
                     57:        #define DEBUGOUT2(S,A,B)
                     58:        #define DEBUGOUT3(S,A,B,C)
                     59:        #define DEBUGOUT7(S,A,B,C,D,E,F,G)
                     60: #endif
                     61:
                     62: #define CMD_MEM_WRT_INVALIDATE         0x0010  /* BIT_4 */
                     63:
                     64: struct em_osdep
                     65: {
                     66:        bus_space_tag_t         mem_bus_space_tag;
                     67:        bus_space_handle_t      mem_bus_space_handle;
                     68:        bus_space_tag_t         io_bus_space_tag;
                     69:        bus_space_handle_t      io_bus_space_handle;
                     70:        bus_space_tag_t         flash_bus_space_tag;
                     71:        bus_space_handle_t      flash_bus_space_handle;
                     72:        struct device           *dev;
                     73:
                     74:        struct pci_attach_args  em_pa;
                     75:
                     76:        bus_size_t              em_memsize;
                     77:        bus_addr_t              em_membase;
                     78:        bus_size_t              em_iosize;
                     79:        bus_addr_t              em_iobase;
                     80:        bus_size_t              em_flashsize;
                     81:        bus_addr_t              em_flashbase;
                     82: };
                     83:
                     84: #define E1000_WRITE_FLUSH(hw)  E1000_READ_REG(hw, STATUS)
                     85:
                     86: /* Read from an absolute offset in the adapter's memory space */
                     87: #define E1000_READ_OFFSET(hw, offset) \
                     88:        bus_space_read_4(((struct em_osdep *)(hw)->back)->mem_bus_space_tag, \
                     89:                         ((struct em_osdep *)(hw)->back)->mem_bus_space_handle, \
                     90:                          offset)
                     91:
                     92: /* Write to an absolute offset in the adapter's memory space */
                     93: #define E1000_WRITE_OFFSET(hw, offset, value) \
                     94:        bus_space_write_4(((struct em_osdep *)(hw)->back)->mem_bus_space_tag, \
                     95:                          ((struct em_osdep *)(hw)->back)->mem_bus_space_handle, \
                     96:                           offset, value)
                     97:
                     98: /* Convert a register name to its offset in the adapter's memory space */
                     99: #define E1000_REG_OFFSET(hw, reg) \
                    100:        ((hw)->mac_type >= em_82543 ? E1000_##reg : E1000_82542_##reg)
                    101:
                    102: /* Register READ/WRITE macros */
                    103:
                    104: #define E1000_READ_REG(hw, reg) \
                    105:        bus_space_read_4(((struct em_osdep *)(hw)->back)->mem_bus_space_tag, \
                    106:                         ((struct em_osdep *)(hw)->back)->mem_bus_space_handle, \
                    107:                          ((hw)->mac_type >= em_82543 ? E1000_##reg : E1000_82542_##reg))
                    108:
                    109: #define E1000_WRITE_REG(hw, reg, value) \
                    110:        bus_space_write_4(((struct em_osdep *)(hw)->back)->mem_bus_space_tag, \
                    111:                          ((struct em_osdep *)(hw)->back)->mem_bus_space_handle, \
                    112:                           ((hw)->mac_type >= em_82543 ? E1000_##reg : E1000_82542_##reg), \
                    113:                           value)
                    114:
                    115: #define E1000_READ_REG_ARRAY(hw, reg, index) \
                    116:        bus_space_read_4(((struct em_osdep *)(hw)->back)->mem_bus_space_tag, \
                    117:                         ((struct em_osdep *)(hw)->back)->mem_bus_space_handle, \
                    118:                          ((hw)->mac_type >= em_82543 ? E1000_##reg : E1000_82542_##reg) \
                    119:                          + ((index) << 2))
                    120:
                    121: #define E1000_WRITE_REG_ARRAY(hw, reg, index, value) \
                    122:        bus_space_write_4(((struct em_osdep *)(hw)->back)->mem_bus_space_tag, \
                    123:                          ((struct em_osdep *)(hw)->back)->mem_bus_space_handle, \
                    124:                           ((hw)->mac_type >= em_82543 ? E1000_##reg : E1000_82542_##reg) \
                    125:                           + ((index) << 2), value)
                    126:
                    127: #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
                    128: #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
                    129:
                    130: #define E1000_WRITE_REG_ARRAY_BYTE(hw, reg, index, value) \
                    131:        bus_space_write_1(((struct em_osdep *)(hw)->back)->mem_bus_space_tag, \
                    132:                          ((struct em_osdep *)(hw)->back)->mem_bus_space_handle, \
                    133:                           ((hw)->mac_type >= em_82543 ? E1000_##reg : E1000_82542_##reg \
                    134:                           + index), value)
                    135:
                    136: #define E1000_WRITE_REG_ARRAY_WORD(hw, reg, index, value) \
                    137:        bus_space_write_2(((struct em_osdep *)(hw)->back)->mem_bus_space_tag, \
                    138:                          ((struct em_osdep *)(hw)->back)->mem_bus_space_handle, \
                    139:                           ((hw)->mac_type >= em_82543 ? E1000_##reg : E1000_82542_##reg \
                    140:                           + (index << 1)), value)
                    141:
                    142: #define E1000_READ_ICH_FLASH_REG(hw, reg) \
                    143:        bus_space_read_4(((struct em_osdep *)(hw)->back)->flash_bus_space_tag, \
                    144:                         ((struct em_osdep *)(hw)->back)->flash_bus_space_handle, reg)
                    145:
                    146: #define E1000_READ_ICH_FLASH_REG16(hw, reg) \
                    147:        bus_space_read_2(((struct em_osdep *)(hw)->back)->flash_bus_space_tag, \
                    148:                         ((struct em_osdep *)(hw)->back)->flash_bus_space_handle, reg)
                    149:
                    150: #define E1000_WRITE_ICH_FLASH_REG(hw, reg, value) \
                    151:        bus_space_write_4(((struct em_osdep *)(hw)->back)->flash_bus_space_tag, \
                    152:                          ((struct em_osdep *)(hw)->back)->flash_bus_space_handle, \
                    153:                           reg, value)
                    154:
                    155: #define E1000_WRITE_ICH_FLASH_REG16(hw, reg, value) \
                    156:        bus_space_write_2(((struct em_osdep *)(hw)->back)->flash_bus_space_tag, \
                    157:                          ((struct em_osdep *)(hw)->back)->flash_bus_space_handle, \
                    158:                           reg, value)
                    159:
                    160: #define em_io_read(hw, port) \
                    161:        bus_space_read_4(((struct em_osdep *)(hw)->back)->io_bus_space_tag, \
                    162:                         ((struct em_osdep *)(hw)->back)->io_bus_space_handle, (port))
                    163:
                    164: #define em_io_write(hw, port, value) \
                    165:        bus_space_write_4(((struct em_osdep *)(hw)->back)->io_bus_space_tag, \
                    166:                          ((struct em_osdep *)(hw)->back)->io_bus_space_handle, \
                    167:                           (port), (value))
                    168:
                    169: #ifdef DEBUG
                    170: #define EM_KASSERT(exp,msg)    do { if (!(exp)) panic msg; } while (0)
                    171: #else
                    172: #define EM_KASSERT(exp,msg)
                    173: #endif
                    174:
                    175: #endif  /* _EM_OPENBSD_OS_H_ */

CVSweb