lpfc_compat.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2004-2005 Emulex. All rights reserved. *
  5. * EMULEX and SLI are trademarks of Emulex. *
  6. * www.emulex.com *
  7. * *
  8. * This program is free software; you can redistribute it and/or *
  9. * modify it under the terms of version 2 of the GNU General *
  10. * Public License as published by the Free Software Foundation. *
  11. * This program is distributed in the hope that it will be useful. *
  12. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  13. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  14. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  15. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  16. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  17. * more details, a copy of which can be found in the file COPYING *
  18. * included with this package. *
  19. *******************************************************************/
  20. /*
  21. * This file provides macros to aid compilation in the Linux 2.4 kernel
  22. * over various platform architectures.
  23. */
  24. /*******************************************************************
  25. Note: HBA's SLI memory contains little-endian LW.
  26. Thus to access it from a little-endian host,
  27. memcpy_toio() and memcpy_fromio() can be used.
  28. However on a big-endian host, copy 4 bytes at a time,
  29. using writel() and readl().
  30. *******************************************************************/
  31. #if __BIG_ENDIAN
  32. static inline void
  33. lpfc_memcpy_to_slim(void __iomem *dest, void *src, unsigned int bytes)
  34. {
  35. uint32_t __iomem *dest32;
  36. uint32_t *src32;
  37. unsigned int four_bytes;
  38. dest32 = (uint32_t __iomem *) dest;
  39. src32 = (uint32_t *) src;
  40. /* write input bytes, 4 bytes at a time */
  41. for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
  42. writel( *src32, dest32);
  43. readl(dest32); /* flush */
  44. dest32++;
  45. src32++;
  46. }
  47. return;
  48. }
  49. static inline void
  50. lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
  51. {
  52. uint32_t *dest32;
  53. uint32_t __iomem *src32;
  54. unsigned int four_bytes;
  55. dest32 = (uint32_t *) dest;
  56. src32 = (uint32_t __iomem *) src;
  57. /* read input bytes, 4 bytes at a time */
  58. for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
  59. *dest32 = readl( src32);
  60. dest32++;
  61. src32++;
  62. }
  63. return;
  64. }
  65. #else
  66. static inline void
  67. lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
  68. {
  69. /* actually returns 1 byte past dest */
  70. memcpy_toio( dest, src, bytes);
  71. }
  72. static inline void
  73. lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
  74. {
  75. /* actually returns 1 byte past dest */
  76. memcpy_fromio( dest, src, bytes);
  77. }
  78. #endif /* __BIG_ENDIAN */