summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'omap5/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c')
-rw-r--r--omap5/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c166
1 files changed, 0 insertions, 166 deletions
diff --git a/omap5/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c b/omap5/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c
deleted file mode 100644
index 8e57476..0000000
--- a/omap5/sgx_src/eurasia_km/services4/srvkm/env/linux/mutils.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/*************************************************************************/ /*!
2@Title Linux memory interface support functions
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@License Dual MIT/GPLv2
5
6The contents of this file are subject to the MIT license as set out below.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18Alternatively, the contents of this file may be used under the terms of
19the GNU General Public License Version 2 ("GPL") in which case the provisions
20of GPL are applicable instead of those above.
21
22If you wish to allow use of your version of this file only under the terms of
23GPL, and not to allow others to use your version of this file under the terms
24of the MIT license, indicate your decision by deleting the provisions above
25and replace them with the notice and other provisions required by GPL as set
26out in the file called "GPL-COPYING" included in this distribution. If you do
27not delete the provisions above, a recipient may use your version of this file
28under the terms of either the MIT license or GPL.
29
30This License is also included in this distribution in the file called
31"MIT-COPYING".
32
33EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40*/ /**************************************************************************/
41
42#include <linux/version.h>
43
44#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
45#ifndef AUTOCONF_INCLUDED
46#include <linux/config.h>
47#endif
48#endif
49
50#include <linux/spinlock.h>
51#include <linux/mm.h>
52#include <asm/page.h>
53#include <asm/pgtable.h>
54
55#include "img_defs.h"
56#include "pvr_debug.h"
57#include "mutils.h"
58
59#if defined(SUPPORT_LINUX_X86_PAT)
60#define PAT_LINUX_X86_WC 1
61
62#define PAT_X86_ENTRY_BITS 8
63
64#define PAT_X86_BIT_PWT 1U
65#define PAT_X86_BIT_PCD 2U
66#define PAT_X86_BIT_PAT 4U
67#define PAT_X86_BIT_MASK (PAT_X86_BIT_PAT | PAT_X86_BIT_PCD | PAT_X86_BIT_PWT)
68
69static IMG_BOOL g_write_combining_available = IMG_FALSE;
70
71#define PROT_TO_PAT_INDEX(v, B) ((v & _PAGE_ ## B) ? PAT_X86_BIT_ ## B : 0)
72
73static inline IMG_UINT
74pvr_pat_index(pgprotval_t prot_val)
75{
76 IMG_UINT ret = 0;
77 pgprotval_t val = prot_val & _PAGE_CACHE_MASK;
78
79 ret |= PROT_TO_PAT_INDEX(val, PAT);
80 ret |= PROT_TO_PAT_INDEX(val, PCD);
81 ret |= PROT_TO_PAT_INDEX(val, PWT);
82
83 return ret;
84}
85
86static inline IMG_UINT
87pvr_pat_entry(u64 pat, IMG_UINT index)
88{
89 return (IMG_UINT)(pat >> (index * PAT_X86_ENTRY_BITS)) & PAT_X86_BIT_MASK;
90}
91
92static IMG_VOID
93PVRLinuxX86PATProbe(IMG_VOID)
94{
95 /*
96 * cpu_has_pat indicates whether PAT support is available on the CPU,
97 * but doesn't indicate if it has been enabled.
98 */
99 if (cpu_has_pat) /* PRQA S 3335 */ /* ignore 'no function declared' */
100 {
101 u64 pat;
102 IMG_UINT pat_index;
103 IMG_UINT pat_entry;
104
105 PVR_TRACE(("%s: PAT available", __FUNCTION__));
106 /*
107 * There is no Linux API for finding out if write combining
108 * is avaialable through the PAT, so we take the direct
109 * approach, and see if the PAT MSR contains a write combining
110 * entry.
111 */
112 rdmsrl(MSR_IA32_CR_PAT, pat);
113 PVR_TRACE(("%s: Top 32 bits of PAT: 0x%.8x", __FUNCTION__, (IMG_UINT)(pat >> 32)));
114 PVR_TRACE(("%s: Bottom 32 bits of PAT: 0x%.8x", __FUNCTION__, (IMG_UINT)(pat)));
115
116 pat_index = pvr_pat_index(_PAGE_CACHE_WC);
117 PVR_TRACE(("%s: PAT index for write combining: %u", __FUNCTION__, pat_index));
118
119 pat_entry = pvr_pat_entry(pat, pat_index);
120 PVR_TRACE(("%s: PAT entry for write combining: 0x%.2x (should be 0x%.2x)", __FUNCTION__, pat_entry, PAT_LINUX_X86_WC));
121
122#if defined(SUPPORT_LINUX_X86_WRITECOMBINE)
123 g_write_combining_available = (IMG_BOOL)(pat_entry == PAT_LINUX_X86_WC);
124#endif
125 }
126#if defined(DEBUG)
127#if defined(SUPPORT_LINUX_X86_WRITECOMBINE)
128 if (g_write_combining_available)
129 {
130 PVR_TRACE(("%s: Write combining available via PAT", __FUNCTION__));
131 }
132 else
133 {
134 PVR_TRACE(("%s: Write combining not available", __FUNCTION__));
135 }
136#else /* defined(SUPPORT_LINUX_X86_WRITECOMBINE) */
137 PVR_TRACE(("%s: Write combining disabled in driver build", __FUNCTION__));
138#endif /* defined(SUPPORT_LINUX_X86_WRITECOMBINE) */
139#endif /* DEBUG */
140}
141
142pgprot_t
143pvr_pgprot_writecombine(pgprot_t prot)
144{
145 /*
146 * It would be worth checking from time to time to see if a
147 * pgprot_writecombine function (or similar) is introduced on Linux for
148 * x86 processors. If so, this function, and PVRLinuxX86PATProbe can be
149 * removed, and a macro used to select between pgprot_writecombine and
150 * pgprot_noncached, dpending on the value for of
151 * SUPPORT_LINUX_X86_WRITECOMBINE.
152 */
153 /* PRQA S 0481,0482 2 */ /* scalar expressions */
154 return (g_write_combining_available) ?
155 __pgprot((pgprot_val(prot) & ~_PAGE_CACHE_MASK) | _PAGE_CACHE_WC) : pgprot_noncached(prot);
156}
157#endif /* defined(SUPPORT_LINUX_X86_PAT) */
158
159IMG_VOID
160PVRLinuxMUtilsInit(IMG_VOID)
161{
162#if defined(SUPPORT_LINUX_X86_PAT)
163 PVRLinuxX86PATProbe();
164#endif
165}
166