]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/device-ti-proprietary-open.git/blob - jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.h
a66e927369745d511e4cd81a67c0c38655aad306
[android-sdk/device-ti-proprietary-open.git] / jacinto6 / sgx_src / eurasia_km / services4 / srvkm / env / linux / mutils.h
1 /*************************************************************************/ /*!
2 @Title          Memory management support utils
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description    Declares various memory management support functions
5                 for Linux.
6 @License        Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43 #ifndef __IMG_LINUX_MUTILS_H__
44 #define __IMG_LINUX_MUTILS_H__
46 #include <linux/version.h>
48 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
49 #ifndef AUTOCONF_INCLUDED
50 #include <linux/config.h>
51 #endif
52 #endif
54 #if !(defined(__i386__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)))
55 #if defined(SUPPORT_LINUX_X86_PAT)
56 #undef SUPPORT_LINUX_X86_PAT
57 #endif
58 #endif
60 #if defined(SUPPORT_LINUX_X86_PAT)
61         pgprot_t pvr_pgprot_writecombine(pgprot_t prot);
62         #define PGPROT_WC(pv)   pvr_pgprot_writecombine(pv)
63 #else
64         #if defined(__arm__) || defined(__sh__)
65                 #define PGPROT_WC(pv)   pgprot_writecombine(pv)
66         #elif defined(__mips__)
67                 #define PGPROT_WC(pv)   pgprot_writecombine(pv)
68         #elif defined(__i386__) || defined(__x86_64)
69                 /* PAT support supersedes this */
70                 #define PGPROT_WC(pv)   pgprot_noncached(pv)
71         #else
72                 #define PGPROT_WC(pv)   pgprot_noncached(pv)
73                 #error  Unsupported architecture!
74         #endif
75 #endif
77 #define PGPROT_UC(pv)   pgprot_noncached(pv)
79 #if defined(__i386__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
80         #define IOREMAP(pa, bytes)      ioremap_cache(pa, bytes)
81 #else   
82         #if defined(__arm__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
83                 #define IOREMAP(pa, bytes)      ioremap_cached(pa, bytes)
84         #else
85                 #define IOREMAP(pa, bytes)      ioremap(pa, bytes)
86         #endif
87 #endif
89 #if defined(SUPPORT_LINUX_X86_PAT)
90         #if defined(SUPPORT_LINUX_X86_WRITECOMBINE)
91                 #define IOREMAP_WC(pa, bytes) ioremap_wc(pa, bytes)
92         #else
93                 #define IOREMAP_WC(pa, bytes) ioremap_nocache(pa, bytes)
94         #endif
95 #else
96         #if defined(__arm__)
97                 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
98                         #define IOREMAP_WC(pa, bytes) ioremap_wc(pa, bytes)
99                 #else
100                         #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
101                                 #define IOREMAP_WC(pa, bytes)   ioremap_nocache(pa, bytes)
102                         #else
103                                 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17))
104                                         #define IOREMAP_WC(pa, bytes)   __ioremap(pa, bytes, L_PTE_BUFFERABLE)
105                                 #else
106                                         #define IOREMAP_WC(pa, bytes)   __ioremap(pa, bytes, , L_PTE_BUFFERABLE, 1)
107                                 #endif
108                         #endif
109                 #endif
110         #else
111                 #define IOREMAP_WC(pa, bytes)   ioremap_nocache(pa, bytes)
112         #endif
113 #endif
115 #define IOREMAP_UC(pa, bytes)   ioremap_nocache(pa, bytes)
117 IMG_VOID PVRLinuxMUtilsInit(IMG_VOID);
119 #endif /* __IMG_LINUX_MUTILS_H__ */