e1000_osdep.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2006 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. *******************************************************************************/
  21. /* glue for the OS independent part of e1000
  22. * includes register access macros
  23. */
  24. #ifndef _E1000_OSDEP_H_
  25. #define _E1000_OSDEP_H_
  26. #include <linux/types.h>
  27. #include <linux/pci.h>
  28. #include <linux/delay.h>
  29. #include <asm/io.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/sched.h>
  32. typedef enum {
  33. #undef FALSE
  34. FALSE = 0,
  35. #undef TRUE
  36. TRUE = 1
  37. } boolean_t;
  38. #ifdef DBG
  39. #define DEBUGOUT(S) printk(KERN_DEBUG S "\n")
  40. #define DEBUGOUT1(S, A...) printk(KERN_DEBUG S "\n", A)
  41. #else
  42. #define DEBUGOUT(S)
  43. #define DEBUGOUT1(S, A...)
  44. #endif
  45. #define DEBUGFUNC(F) DEBUGOUT(F "\n")
  46. #define DEBUGOUT2 DEBUGOUT1
  47. #define DEBUGOUT3 DEBUGOUT2
  48. #define DEBUGOUT7 DEBUGOUT3
  49. #define E1000_WRITE_REG(a, reg, value) ( \
  50. writel((value), ((a)->hw_addr + \
  51. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg))))
  52. #define E1000_READ_REG(a, reg) ( \
  53. readl((a)->hw_addr + \
  54. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg)))
  55. #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
  56. writel((value), ((a)->hw_addr + \
  57. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  58. ((offset) << 2))))
  59. #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
  60. readl((a)->hw_addr + \
  61. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  62. ((offset) << 2)))
  63. #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
  64. #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
  65. #define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
  66. writew((value), ((a)->hw_addr + \
  67. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  68. ((offset) << 1))))
  69. #define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
  70. readw((a)->hw_addr + \
  71. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  72. ((offset) << 1)))
  73. #define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
  74. writeb((value), ((a)->hw_addr + \
  75. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  76. (offset))))
  77. #define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
  78. readb((a)->hw_addr + \
  79. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  80. (offset)))
  81. #define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
  82. #define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \
  83. writel((value), ((a)->flash_address + reg)))
  84. #define E1000_READ_ICH_FLASH_REG(a, reg) ( \
  85. readl((a)->flash_address + reg))
  86. #define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \
  87. writew((value), ((a)->flash_address + reg)))
  88. #define E1000_READ_ICH_FLASH_REG16(a, reg) ( \
  89. readw((a)->flash_address + reg))
  90. #endif /* _E1000_OSDEP_H_ */