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. *
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. *
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 *******************************************************************/
22 * $Id: lpfc_compat.h 1.28 2004/11/09 14:49:24EST sf_support Exp $
24 * This file provides macros to aid compilation in the Linux 2.4 kernel
25 * over various platform architectures.
28 #ifndef _H_LPFC_COMPAT
29 #define _H_LPFC_COMPAT
32 /*******************************************************************
33 Note: HBA's SLI memory contains little-endian LW.
34 Thus to access it from a little-endian host,
35 memcpy_toio() and memcpy_fromio() can be used.
36 However on a big-endian host, copy 4 bytes at a time,
37 using writel() and readl().
38 *******************************************************************/
43 lpfc_memcpy_to_slim( void *dest, void *src, unsigned int bytes)
47 unsigned int four_bytes;
50 dest32 = (uint32_t *) dest;
51 src32 = (uint32_t *) src;
53 /* write input bytes, 4 bytes at a time */
54 for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
55 writel( *src32, dest32);
56 readl(dest32); /* flush */
65 lpfc_memcpy_from_slim( void *dest, void *src, unsigned int bytes)
69 unsigned int four_bytes;
72 dest32 = (uint32_t *) dest;
73 src32 = (uint32_t *) src;
75 /* read input bytes, 4 bytes at a time */
76 for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
77 *dest32 = readl( src32);
88 lpfc_memcpy_to_slim( void *dest, void *src, unsigned int bytes)
90 /* actually returns 1 byte past dest */
91 memcpy_toio( dest, src, bytes);
95 lpfc_memcpy_from_slim( void *dest, void *src, unsigned int bytes)
97 /* actually returns 1 byte past dest */
98 memcpy_fromio( dest, src, bytes);
101 #endif /* __BIG_ENDIAN */
103 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)
104 #define msleep(x) do { \
105 set_current_state(TASK_UNINTERRUPTIBLE); \
106 schedule_timeout((x)); \
108 /* Provide local msecs_to_jiffies call for earlier kernels */
109 static inline unsigned long msecs_to_jiffies(const unsigned int m)
111 #if HZ <= 1000 && !(1000 % HZ)
112 return (m + (1000 / HZ) - 1) / (1000 / HZ);
113 #elif HZ > 1000 && !(HZ % 1000)
114 return m * (HZ / 1000);
116 return (m * HZ + 999) / 1000;
120 #endif /* _H_LPFC_COMPAT */