Back to home page

OSCL-LXR

 
 

    


0001 /*******************************************************************
0002  * This file is part of the Emulex Linux Device Driver for         *
0003  * Fibre Channel Host Bus Adapters.                                *
0004  * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
0005  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
0006  * Copyright (C) 2004-2011 Emulex.  All rights reserved.           *
0007  * EMULEX and SLI are trademarks of Emulex.                        *
0008  * www.broadcom.com                                                *
0009  *                                                                 *
0010  * This program is free software; you can redistribute it and/or   *
0011  * modify it under the terms of version 2 of the GNU General       *
0012  * Public License as published by the Free Software Foundation.    *
0013  * This program is distributed in the hope that it will be useful. *
0014  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
0015  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
0016  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
0017  * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
0018  * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
0019  * more details, a copy of which can be found in the file COPYING  *
0020  * included with this package.                                     *
0021  *******************************************************************/
0022 
0023 /*
0024  * This file provides macros to aid compilation in the Linux 2.4 kernel
0025  * over various platform architectures.
0026  */
0027 
0028 /*******************************************************************
0029 Note: HBA's SLI memory contains little-endian LW.
0030 Thus to access it from a little-endian host,
0031 memcpy_toio() and memcpy_fromio() can be used.
0032 However on a big-endian host, copy 4 bytes at a time,
0033 using writel() and readl().
0034  *******************************************************************/
0035 #include <asm/byteorder.h>
0036 
0037 #ifdef __BIG_ENDIAN
0038 
0039 static inline void
0040 lpfc_memcpy_to_slim(void __iomem *dest, void *src, unsigned int bytes)
0041 {
0042     uint32_t __iomem *dest32;
0043     uint32_t *src32;
0044     unsigned int four_bytes;
0045 
0046 
0047     dest32  = (uint32_t __iomem *) dest;
0048     src32  = (uint32_t *) src;
0049 
0050     /* write input bytes, 4 bytes at a time */
0051     for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
0052         writel( *src32, dest32);
0053         readl(dest32); /* flush */
0054         dest32++;
0055         src32++;
0056     }
0057 
0058     return;
0059 }
0060 
0061 static inline void
0062 lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
0063 {
0064     uint32_t *dest32;
0065     uint32_t __iomem *src32;
0066     unsigned int four_bytes;
0067 
0068 
0069     dest32  = (uint32_t *) dest;
0070     src32  = (uint32_t __iomem *) src;
0071 
0072     /* read input bytes, 4 bytes at a time */
0073     for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
0074         *dest32 = readl( src32);
0075         dest32++;
0076         src32++;
0077     }
0078 
0079     return;
0080 }
0081 
0082 #else
0083 
0084 static inline void
0085 lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
0086 {
0087     /* convert bytes in argument list to word count for copy function */
0088     __iowrite32_copy(dest, src, bytes / sizeof(uint32_t));
0089 }
0090 
0091 static inline void
0092 lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
0093 {
0094     /* actually returns 1 byte past dest */
0095     memcpy_fromio( dest, src, bytes);
0096 }
0097 
0098 #endif  /* __BIG_ENDIAN */