e1000_osdep.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*******************************************************************************
  2. Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that 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., 59
  13. Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. The full GNU General Public License is included in this distribution in the
  15. file called LICENSE.
  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. #define MSGOUT(S, A, B) printk(KERN_DEBUG S "\n", A, B)
  39. #ifdef DBG
  40. #define DEBUGOUT(S) printk(KERN_DEBUG S "\n")
  41. #define DEBUGOUT1(S, A...) printk(KERN_DEBUG S "\n", A)
  42. #else
  43. #define DEBUGOUT(S)
  44. #define DEBUGOUT1(S, A...)
  45. #endif
  46. #define DEBUGFUNC(F) DEBUGOUT(F)
  47. #define DEBUGOUT2 DEBUGOUT1
  48. #define DEBUGOUT3 DEBUGOUT2
  49. #define DEBUGOUT7 DEBUGOUT3
  50. #define E1000_WRITE_REG(a, reg, value) ( \
  51. writel((value), ((a)->hw_addr + \
  52. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg))))
  53. #define E1000_READ_REG(a, reg) ( \
  54. readl((a)->hw_addr + \
  55. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg)))
  56. #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
  57. writel((value), ((a)->hw_addr + \
  58. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  59. ((offset) << 2))))
  60. #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
  61. readl((a)->hw_addr + \
  62. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  63. ((offset) << 2)))
  64. #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
  65. #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
  66. #define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
  67. writew((value), ((a)->hw_addr + \
  68. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  69. ((offset) << 1))))
  70. #define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
  71. readw((a)->hw_addr + \
  72. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  73. ((offset) << 1)))
  74. #define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
  75. writeb((value), ((a)->hw_addr + \
  76. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  77. (offset))))
  78. #define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
  79. readb((a)->hw_addr + \
  80. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  81. (offset)))
  82. #define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
  83. #define E1000_WRITE_ICH8_REG(a, reg, value) ( \
  84. writel((value), ((a)->flash_address + reg)))
  85. #define E1000_READ_ICH8_REG(a, reg) ( \
  86. readl((a)->flash_address + reg))
  87. #define E1000_WRITE_ICH8_REG16(a, reg, value) ( \
  88. writew((value), ((a)->flash_address + reg)))
  89. #define E1000_READ_ICH8_REG16(a, reg) ( \
  90. readw((a)->flash_address + reg))
  91. #endif /* _E1000_OSDEP_H_ */