author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// eka\include\kernel\cache_maintenance.inl |
|
15 |
// |
|
16 |
// Contains Kernel's internal API of cache maintenance |
|
17 |
||
18 |
/** |
|
19 |
@file |
|
20 |
@internalComponent |
|
21 |
*/ |
|
22 |
||
23 |
#ifndef __CACHE_MAINTENANCE_INL__ |
|
24 |
#define __CACHE_MAINTENANCE_INL__ |
|
25 |
||
26 |
#if defined(__CPU_HAS_CACHE) |
|
27 |
||
28 |
#include <e32err.h> |
|
29 |
#include "cache_maintenance.h" |
|
30 |
#include <platform.h> |
|
31 |
#include <nk_cpu.h> |
|
32 |
#include <mmboot.h> |
|
33 |
||
34 |
#if defined(__MEMMODEL_MULTIPLE__) || defined(__MEMMODEL_FLEXIBLE__) |
|
35 |
||
36 |
#if defined(GNUC) && !defined(__MARM_ARM4__) |
|
37 |
#define __VOLATILE__ volatile |
|
38 |
#else |
|
39 |
#define __VOLATILE__ |
|
40 |
#endif |
|
41 |
||
42 |
||
43 |
#if defined(__CPU_ARMV6) |
|
44 |
#define CLEAN_PTE_REGION(aAddr, aSize) InternalCache::Clean_DCache_Region(aAddr, aSize) |
|
45 |
#define PTE_CLEAN_REG "c10" |
|
46 |
#else //(__CPU_ARMV6) |
|
47 |
// On ARMv7 onwards, page tables have to be cleaned to the Point of Unification |
|
48 |
// to be visible to page-table walk. |
|
49 |
#if defined (__FLUSH_PT_INTO_RAM__) |
|
50 |
// However, if page table entries have to be visible in main memory, we have to clean to the |
|
51 |
// Point of Coherency. |
|
52 |
#define CLEAN_PTE_REGION(aAddr, aSize) InternalCache::Clean_DCache_Region(aAddr, aSize) |
|
53 |
#define PTE_CLEAN_REG "c10" |
|
54 |
#else |
|
55 |
// Ordinary ARMv7 case, where page table change is pushed down to the Point of Unification. |
|
56 |
#define CLEAN_PTE_REGION(aAddr, aSize) InternalCache::Clean_PoU_DCache_Region(aAddr, aSize) |
|
57 |
#define PTE_CLEAN_REG "c11" |
|
58 |
#endif // else defined (__FLUSH_PT_INTO_RAM__) |
|
59 |
#endif // else (__CPU_ARMV6) |
|
60 |
||
61 |
FORCE_INLINE void CacheMaintenance::MultiplePtesUpdated(TLinAddr aPte, TUint aSize) |
|
62 |
{ |
|
63 |
#if defined(__CPU_X86) |
|
64 |
//Empty |
|
65 |
#elif defined(__CPU_SUPPORTS_PAGE_TABLE_WALK_TO_L1_CACHE) || !defined(__CPU_PAGE_TABLES_FULLY_CACHED) |
|
66 |
(void)aPte; |
|
67 |
(void)aSize; |
|
68 |
__e32_io_completion_barrier(); |
|
69 |
#else // (__CPU_SUPPORTS_PAGE_TABLE_WALK_TO_L1_CACHE) || !(__CPU_PAGE_TABLES_FULLY_CACHED) |
|
70 |
CLEAN_PTE_REGION((TLinAddr)aPte, aSize); // clean cache lines & drain write buffer |
|
71 |
#endif // else (__CPU_SUPPORTS_PAGE_TABLE_WALK_TO_L1_CACHE) || !(__CPU_PAGE_TABLES_FULLY_CACHED) |
|
72 |
#if defined (__FLUSH_PT_INTO_RAM__) |
|
73 |
//See SinglePteUpdated for details. |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
ExternalCache::Clean(aPte, aSize); |
0 | 75 |
#endif // (__FLUSH_PT_INTO_RAM__) |
76 |
} |
|
77 |
||
78 |
FORCE_INLINE void CacheMaintenance::PdesInitialised(TLinAddr aPde, TUint aSize) |
|
79 |
{ |
|
80 |
CacheMaintenance::MultiplePtesUpdated(aPde, aSize); |
|
81 |
} |
|
82 |
||
83 |
FORCE_INLINE void CacheMaintenance::SinglePteUpdated(TLinAddr aPte) |
|
84 |
{ |
|
85 |
#if defined(__CPU_X86) |
|
86 |
//Empty |
|
87 |
#elif defined(__CPU_SUPPORTS_PAGE_TABLE_WALK_TO_L1_CACHE) || !defined(__CPU_PAGE_TABLES_FULLY_CACHED) |
|
88 |
(void)aPte; |
|
89 |
__e32_io_completion_barrier(); |
|
90 |
#else // (__CPU_SUPPORTS_PAGE_TABLE_WALK_TO_L1_CACHE) || !(__CPU_PAGE_TABLES_FULLY_CACHED) |
|
91 |
#ifdef __GNUC__ |
|
92 |
asm __VOLATILE__ ("mcr p15, 0, %0, c7, " PTE_CLEAN_REG ", 1 " : : "r"(aPte)); // clean cache line |
|
93 |
#elif defined(__ARMCC__) |
|
94 |
asm("mcr p15, 0, aPte, c7, " PTE_CLEAN_REG ", 1 "); // clean cache line |
|
95 |
#elif defined(__GCCXML__) |
|
96 |
// empty |
|
97 |
#else |
|
98 |
#error Unknown compiler |
|
99 |
#endif |
|
100 |
__e32_io_completion_barrier(); |
|
101 |
#endif //else (__CPU_SUPPORTS_PAGE_TABLE_WALK_TO_L1_CACHE) || !(__CPU_PAGE_TABLES_FULLY_CACHED) |
|
102 |
||
103 |
#if defined (__FLUSH_PT_INTO_RAM__) |
|
104 |
// This will ensure that the page tables/dirs are updated in main memory. |
|
105 |
// This is only necessary when another part of the system accesses the page |
|
106 |
// tables separately (e.g. another processor using the same page tables out |
|
107 |
// of main memory), and is not necessary on standard platforms. |
|
108 |
// Either __ARM_L210_CACHE__ or __ARM_L220_CACHE__ must also be defined |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
109 |
ExternalCache::Clean(aPte, 4); |
0 | 110 |
#endif |
111 |
} |
|
112 |
||
113 |
FORCE_INLINE void CacheMaintenance::SinglePdeUpdated(TLinAddr aPde) |
|
114 |
{ |
|
115 |
CacheMaintenance::SinglePteUpdated(aPde); |
|
116 |
} |
|
117 |
||
118 |
#endif //#if defined(__MEMMODEL_MULTIPLE__) || defined(__MEMMODEL_FLEXIBLE__) |
|
119 |
||
120 |
#endif //defined(__CPU_HAS_CACHE) |
|
121 |
||
122 |
#endif //#ifndef __CACHE_MAINTENANCE_INL__ |