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. #include <asm/byteorder.h>
  32. #ifdef __BIG_ENDIAN
  33. static inline void
  34. lpfc_memcpy_to_slim(void __iomem *dest, void *src, unsigned int bytes)
  35. {
  36. uint32_t __iomem *dest32;
  37. uint32_t *src32;
  38. unsigned int four_bytes;
  39. dest32 = (uint32_t __iomem *) dest;
  40. src32 = (uint32_t *) src;
  41. /* write input bytes, 4 bytes at a time */
  42. for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
  43. writel( *src32, dest32);
  44. readl(dest32); /* flush */
  45. dest32++;
  46. src32++;
  47. }
  48. return;
  49. }
  50. static inline void
  51. lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
  52. {
  53. uint32_t *dest32;
  54. uint32_t __iomem *src32;
  55. unsigned int four_bytes;
  56. dest32 = (uint32_t *) dest;
  57. src32 = (uint32_t __iomem *) src;
  58. /* read input bytes, 4 bytes at a time */
  59. for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
  60. *dest32 = readl( src32);
  61. dest32++;
  62. src32++;
  63. }
  64. return;
  65. }
  66. #else
  67. static inline void
  68. lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
  69. {
  70. __iowrite32_copy(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 */