fp@680: /*******************************************************************************
fp@680: 
fp@680:   Intel PRO/1000 Linux driver
fp@680:   Copyright(c) 1999 - 2006 Intel Corporation.
fp@680: 
fp@680:   This program is free software; you can redistribute it and/or modify it
fp@680:   under the terms and conditions of the GNU General Public License,
fp@680:   version 2, as published by the Free Software Foundation.
fp@680: 
fp@680:   This program is distributed in the hope it will be useful, but WITHOUT
fp@680:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fp@680:   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
fp@680:   more details.
fp@680: 
fp@680:   You should have received a copy of the GNU General Public License along with
fp@680:   this program; if not, write to the Free Software Foundation, Inc.,
fp@680:   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
fp@680: 
fp@680:   The full GNU General Public License is included in this distribution in
fp@680:   the file called "COPYING".
fp@680: 
fp@680:   Contact Information:
fp@680:   Linux NICS <linux.nics@intel.com>
fp@680:   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
fp@680:   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
fp@680: 
fp@680: *******************************************************************************/
fp@680: 
fp@680: 
fp@680: /* glue for the OS independent part of e1000
fp@680:  * includes register access macros
fp@680:  */
fp@680: 
fp@680: #ifndef _E1000_OSDEP_H_
fp@680: #define _E1000_OSDEP_H_
fp@680: 
fp@680: #include <linux/types.h>
fp@680: #include <linux/pci.h>
fp@680: #include <linux/delay.h>
fp@680: #include <asm/io.h>
fp@680: #include <linux/interrupt.h>
fp@680: #include <linux/sched.h>
fp@680: 
fp@680: typedef enum {
fp@680: #undef FALSE
fp@680:     FALSE = 0,
fp@680: #undef TRUE
fp@680:     TRUE = 1
fp@680: } boolean_t;
fp@680: 
fp@680: #define MSGOUT(S, A, B)	printk(KERN_DEBUG S "\n", A, B)
fp@680: 
fp@680: #ifdef DBG
fp@680: #define DEBUGOUT(S)		printk(KERN_DEBUG S "\n")
fp@680: #define DEBUGOUT1(S, A...)	printk(KERN_DEBUG S "\n", A)
fp@680: #else
fp@680: #define DEBUGOUT(S)
fp@680: #define DEBUGOUT1(S, A...)
fp@680: #endif
fp@680: 
fp@680: #define DEBUGFUNC(F) DEBUGOUT(F)
fp@680: #define DEBUGOUT2 DEBUGOUT1
fp@680: #define DEBUGOUT3 DEBUGOUT2
fp@680: #define DEBUGOUT7 DEBUGOUT3
fp@680: 
fp@680: 
fp@680: #define E1000_WRITE_REG(a, reg, value) ( \
fp@680:     writel((value), ((a)->hw_addr + \
fp@680:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg))))
fp@680: 
fp@680: #define E1000_READ_REG(a, reg) ( \
fp@680:     readl((a)->hw_addr + \
fp@680:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg)))
fp@680: 
fp@680: #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
fp@680:     writel((value), ((a)->hw_addr + \
fp@680:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
fp@680:         ((offset) << 2))))
fp@680: 
fp@680: #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
fp@680:     readl((a)->hw_addr + \
fp@680:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
fp@680:         ((offset) << 2)))
fp@680: 
fp@680: #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
fp@680: #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
fp@680: 
fp@680: #define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
fp@680:     writew((value), ((a)->hw_addr + \
fp@680:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
fp@680:         ((offset) << 1))))
fp@680: 
fp@680: #define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
fp@680:     readw((a)->hw_addr + \
fp@680:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
fp@680:         ((offset) << 1)))
fp@680: 
fp@680: #define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
fp@680:     writeb((value), ((a)->hw_addr + \
fp@680:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
fp@680:         (offset))))
fp@680: 
fp@680: #define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
fp@680:     readb((a)->hw_addr + \
fp@680:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
fp@680:         (offset)))
fp@680: 
fp@680: #define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
fp@680: 
fp@680: #define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \
fp@680:     writel((value), ((a)->flash_address + reg)))
fp@680: 
fp@680: #define E1000_READ_ICH_FLASH_REG(a, reg) ( \
fp@680:     readl((a)->flash_address + reg))
fp@680: 
fp@680: #define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \
fp@680:     writew((value), ((a)->flash_address + reg)))
fp@680: 
fp@680: #define E1000_READ_ICH_FLASH_REG16(a, reg) ( \
fp@680:     readw((a)->flash_address + reg))
fp@680: 
fp@680: #endif /* _E1000_OSDEP_H_ */