]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/scsi/lpfc/lpfc_compat.h
275ba34b3c9d5c2d80376248a249d921a6e93377
[linux-2.6-omap-h63xx.git] / drivers / scsi / lpfc / lpfc_compat.h
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 /*
22  * This file provides macros to aid compilation in the Linux 2.4 kernel
23  * over various platform architectures.
24  */
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
34 #if __BIG_ENDIAN
35
36 static inline void
37 lpfc_memcpy_to_slim(void __iomem *dest, void *src, unsigned int bytes)
38 {
39         uint32_t __iomem *dest32;
40         uint32_t *src32;
41         unsigned int four_bytes;
42
43
44         dest32  = (uint32_t __iomem *) dest;
45         src32  = (uint32_t *) src;
46
47         /* write input bytes, 4 bytes at a time */
48         for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
49                 writel( *src32, dest32);
50                 readl(dest32); /* flush */
51                 dest32++;
52                 src32++;
53         }
54
55         return;
56 }
57
58 static inline void
59 lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
60 {
61         uint32_t *dest32;
62         uint32_t __iomem *src32;
63         unsigned int four_bytes;
64
65
66         dest32  = (uint32_t *) dest;
67         src32  = (uint32_t __iomem *) src;
68
69         /* read input bytes, 4 bytes at a time */
70         for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
71                 *dest32 = readl( src32);
72                 dest32++;
73                 src32++;
74         }
75
76         return;
77 }
78
79 #else
80
81 static inline void
82 lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
83 {
84         /* actually returns 1 byte past dest */
85         memcpy_toio( dest, src, bytes);
86 }
87
88 static inline void
89 lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
90 {
91         /* actually returns 1 byte past dest */
92         memcpy_fromio( dest, src, bytes);
93 }
94
95 #endif  /* __BIG_ENDIAN */