lpfc_compat.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Enterprise Fibre Channel Host Bus Adapters. *
  4. * Refer to the README file included with this package for *
  5. * driver version and adapter support. *
  6. * Copyright (C) 2004 Emulex Corporation. *
  7. * www.emulex.com *
  8. * *
  9. * This program is free software; you can redistribute it and/or *
  10. * modify it under the terms of the GNU General Public License *
  11. * as published by the Free Software Foundation; either version 2 *
  12. * of the License, or (at your option) any later version. *
  13. * *
  14. * This program is distributed in the hope that it will be useful, *
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  17. * GNU General Public License for more details, a copy of which *
  18. * can be found in the file COPYING included with this package. *
  19. *******************************************************************/
  20. /*
  21. * $Id: lpfc_compat.h 1.32 2005/01/25 17:51:45EST sf_support Exp $
  22. *
  23. * This file provides macros to aid compilation in the Linux 2.4 kernel
  24. * over various platform architectures.
  25. */
  26. /*******************************************************************
  27. Note: HBA's SLI memory contains little-endian LW.
  28. Thus to access it from a little-endian host,
  29. memcpy_toio() and memcpy_fromio() can be used.
  30. However on a big-endian host, copy 4 bytes at a time,
  31. using writel() and readl().
  32. *******************************************************************/
  33. #if __BIG_ENDIAN
  34. static inline void
  35. lpfc_memcpy_to_slim(void __iomem *dest, void *src, unsigned int bytes)
  36. {
  37. uint32_t __iomem *dest32;
  38. uint32_t *src32;
  39. unsigned int four_bytes;
  40. dest32 = (uint32_t __iomem *) dest;
  41. src32 = (uint32_t *) src;
  42. /* write input bytes, 4 bytes at a time */
  43. for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
  44. writel( *src32, dest32);
  45. readl(dest32); /* flush */
  46. dest32++;
  47. src32++;
  48. }
  49. return;
  50. }
  51. static inline void
  52. lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
  53. {
  54. uint32_t *dest32;
  55. uint32_t __iomem *src32;
  56. unsigned int four_bytes;
  57. dest32 = (uint32_t *) dest;
  58. src32 = (uint32_t __iomem *) src;
  59. /* read input bytes, 4 bytes at a time */
  60. for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
  61. *dest32 = readl( src32);
  62. dest32++;
  63. src32++;
  64. }
  65. return;
  66. }
  67. #else
  68. static inline void
  69. lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
  70. {
  71. /* actually returns 1 byte past dest */
  72. memcpy_toio( dest, src, bytes);
  73. }
  74. static inline void
  75. lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
  76. {
  77. /* actually returns 1 byte past dest */
  78. memcpy_fromio( dest, src, bytes);
  79. }
  80. #endif /* __BIG_ENDIAN */