1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 /* |
2 // All rights reserved. |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 // This component and the accompanying materials are made available |
3 * All rights reserved. |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 * This component and the accompanying materials are made available |
5 // which accompanies this distribution, and is available |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 * which accompanies this distribution, and is available |
7 // |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 // Initial Contributors: |
8 * |
9 // Nokia Corporation - initial contribution. |
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 */ |
10 // |
12 // |
11 // Contributors: |
13 // Contributors: |
12 // |
14 // |
13 // Description: |
15 // Description: |
14 // This file is part of the NE1_TB Variant Base Port |
16 // This file is part of the NE1_TB Variant Base Port |
21 |
23 |
22 #include "hcr_debug.h" |
24 #include "hcr_debug.h" |
23 |
25 |
24 #include "hcr_hai.h" |
26 #include "hcr_hai.h" |
25 |
27 |
|
28 #include "hcr_uids.h" |
|
29 |
|
30 #include <plat_priv.h> |
|
31 #include <kernel/kernboot.h> |
|
32 |
|
33 |
|
34 #ifdef __WINS__ |
|
35 // On WINS the EMapAttrSupRo and EMapAttrCachedMax doesn't exists |
|
36 #define EMapAttrSupRo 0x01 |
|
37 #define EMapAttrCachedMax 0xF000 |
|
38 #endif |
26 |
39 |
27 |
40 |
28 // -- GLOBALS ----------------------------------------------------------------- |
41 // -- GLOBALS ----------------------------------------------------------------- |
29 |
42 |
30 #define GLOBAL_REPOSITORY GLREF_C HCR::SRepositoryCompiled |
43 |
31 |
44 GLREF_C HCR::SRepositoryCompiled gRepository; |
32 //GLREF_C HCR::SRepositoryCompiled gRepository; |
45 #define BUFFER_OFFSET_ZERO 0 |
33 GLOBAL_REPOSITORY gRepository; |
|
34 |
46 |
35 // -- CLASSES- ---------------------------------------------------------------- |
47 // -- CLASSES- ---------------------------------------------------------------- |
36 |
48 |
37 |
49 |
38 class HCRVariant : public HCR::MVariant |
50 class HCRVariant : public HCR::MVariant |
49 |
61 |
50 TBool IgnoreCoreImgRepository(); |
62 TBool IgnoreCoreImgRepository(); |
51 TInt GetCompiledRepositoryAddress( TAny* & aAddr); |
63 TInt GetCompiledRepositoryAddress( TAny* & aAddr); |
52 TInt GetOverrideRepositoryAddress( TAny* & aAddr); |
64 TInt GetOverrideRepositoryAddress( TAny* & aAddr); |
53 |
65 |
|
66 private: |
|
67 DChunk * iChunk; |
54 }; |
68 }; |
55 |
69 |
56 |
70 |
57 |
71 |
58 |
72 |
59 // -- METHODS ----------------------------------------------------------------- |
73 // -- METHODS ----------------------------------------------------------------- |
60 |
74 |
61 |
75 |
62 HCRVariant::HCRVariant() |
76 HCRVariant::HCRVariant() |
|
77 : iChunk(0) |
63 { |
78 { |
64 HCR_FUNC("HCRVariant"); |
79 HCR_FUNC("HCRVariant"); |
65 } |
80 } |
66 |
81 |
67 |
82 |
68 HCRVariant::~HCRVariant() |
83 HCRVariant::~HCRVariant() |
69 { |
84 { |
70 HCR_FUNC("~HCRVariant"); |
85 HCR_FUNC("~HCRVariant"); |
|
86 if (iChunk != 0) |
|
87 { |
|
88 NKern::ThreadEnterCS(); |
|
89 TInt r = Kern::ChunkClose(iChunk); |
|
90 __NK_ASSERT_ALWAYS(r!=0); |
|
91 NKern::ThreadLeaveCS(); |
|
92 } |
71 } |
93 } |
72 |
94 |
73 |
95 |
74 TInt HCRVariant::Initialise() |
96 TInt HCRVariant::Initialise() |
75 { |
97 { |
84 HCR_FUNC("HCRVariant::GetCompiledRepositoryAddress"); |
106 HCR_FUNC("HCRVariant::GetCompiledRepositoryAddress"); |
85 |
107 |
86 aAddr = static_cast<TAny*>(&gRepository); |
108 aAddr = static_cast<TAny*>(&gRepository); |
87 HCR_TRACE_RETURN(KErrNone); |
109 HCR_TRACE_RETURN(KErrNone); |
88 } |
110 } |
89 |
111 |
90 |
|
91 TBool HCRVariant::IgnoreCoreImgRepository() |
112 TBool HCRVariant::IgnoreCoreImgRepository() |
92 { |
113 { |
93 HCR_FUNC("HCRVariant::IgnoreCoreImgRepository"); |
114 HCR_FUNC("HCRVariant::IgnoreCoreImgRepository"); |
94 |
115 |
95 HCR_TRACE_RETURN(EFalse); |
116 HCR_TRACE_RETURN(EFalse); |
96 } |
117 } |
97 |
118 |
98 TInt HCRVariant::GetOverrideRepositoryAddress( TAny* & aAddr) |
119 TInt HCRVariant::GetOverrideRepositoryAddress( TAny* & aAddr) |
99 { |
120 { |
100 HCR_FUNC("HCRVariant::GetRAMRepositoryAddress"); |
121 HCR_FUNC("HCRVariant::GetRAMRepositoryAddress"); |
101 aAddr = NULL; |
122 aAddr = 0; |
|
123 |
|
124 // Note: the SMR feature by which we obtain the address of the override |
|
125 // repository is only supported in the ARM bootstrap, not X86 or WINS so |
|
126 // this test code needs conditional compilation. |
|
127 #if !defined(__WINS__) && !defined(__X86__) |
|
128 |
|
129 // Note to future implementor: |
|
130 // #include <kernel\kernboot.h> |
|
131 // First check to see if SMRIB was created during boot time. |
|
132 // If SSuperPageBase::iSmrData == KSuperPageAddressFieldUndefined (i.e. -1) |
|
133 // it does not exist, return KErrNotSupported, SMR not support by base port |
|
134 // or it is not available due to boot scenario, i.e. boot from MMC |
|
135 // |
|
136 // If it does exist (i.e. boot from NAND) then read and process the |
|
137 // SMR entries listed in the SMRIB looking for KHCRUID_SMRPayloadUID. |
|
138 // Next using the internal sizes from the HCR dat file within the SMR image |
|
139 // determine if the RAM holding the SMR image can be shrunk to return |
|
140 // unused RAM pages at the end of the image. |
|
141 // |
|
142 // Finally allocate the reserved RAM identified in the SMR entry to a |
|
143 // DChunk and return the virtual address of the HCR data file payload |
|
144 // within the SMR image, i.e. iBase+(sizeof(SSmrRomHeader)>>2). |
|
145 // Locate SMRIB |
|
146 const TSuperPage& superpage = Kern::SuperPage(); |
|
147 TUint32* smrIB; |
|
148 smrIB = (TUint32 *) superpage.iSmrData; |
|
149 |
|
150 HCR_TRACE2("--- Superpage: 0x%08x, SMRIB: 0x%08x", &superpage, smrIB); |
|
151 |
|
152 if( (smrIB == NULL) || (smrIB == (TUint32*)KSuperPageAddressFieldUndefined)) |
|
153 { |
|
154 HCR_TRACE_RETURN(KErrNotSupported); |
|
155 } |
|
156 |
|
157 HCR_HEX_DUMP_ABS((TUint8 *)smrIB, 8*sizeof(SSmrBank) ); |
|
158 SSmrBank * smrBank = (SSmrBank *) smrIB; |
|
159 |
|
160 // T_HCRUT designed to work ith the second HCR SMR image as the first |
|
161 // is used by the t_hcr test suite. |
|
162 int smrInst = 2; |
|
163 |
|
164 while( smrBank->iBase != 0 ) |
|
165 { |
|
166 HCR_TRACE2("--- smrBank: 0x%08x, smrBank->iPayloadUID: 0x%08x", smrBank, smrBank->iPayloadUID); |
|
167 |
|
168 if (smrBank->iPayloadUID == KHCRUID_SMRPayloadUID) |
|
169 { |
|
170 smrInst--; |
|
171 if (smrInst == 0) // PSL to use only the 2nd HCR SMR image |
|
172 { |
|
173 |
|
174 HCR_TRACE2("--- smrPhysAddr: 0x%08x, size:0x%08x", smrBank->iBase, smrBank->iSize); |
|
175 NKern::ThreadEnterCS(); |
|
176 |
|
177 TChunkCreateInfo info; |
|
178 info.iType = TChunkCreateInfo::ESharedKernelSingle; |
|
179 info.iMaxSize = smrBank->iSize; |
|
180 |
|
181 // Enable to give supervisor read only access and maximum caching at both L1 and L2. |
|
182 info.iMapAttr = EMapAttrSupRo|EMapAttrCachedMax; |
|
183 |
|
184 info.iOwnsMemory = EFalse; |
|
185 info.iDestroyedDfc = NULL; |
|
186 TUint32 mapAttr; |
|
187 TLinAddr chunkKernAddr; |
|
188 TInt r = Kern::ChunkCreate(info, iChunk, chunkKernAddr, mapAttr); |
|
189 if( r != KErrNone ) |
|
190 { |
|
191 HCR_TRACE1("--- Kern::ChunkCreate failed: 0x%08x", r); |
|
192 NKern::ThreadLeaveCS(); |
|
193 HCR_TRACE_RETURN(r); |
|
194 } |
|
195 |
|
196 r = Kern::ChunkCommitPhysical(iChunk, BUFFER_OFFSET_ZERO, smrBank->iSize, smrBank->iBase); |
|
197 if( r != KErrNone) |
|
198 { |
|
199 HCR_TRACE1("--- Kern::ChunkCommitPhysical failed: 0x%08x", r); |
|
200 TInt r2 = Kern::ChunkClose(iChunk); |
|
201 __NK_ASSERT_ALWAYS(r2!=0); |
|
202 NKern::ThreadLeaveCS(); |
|
203 HCR_TRACE_RETURN(r); |
|
204 } |
|
205 NKern::ThreadLeaveCS(); |
|
206 |
|
207 HCR_TRACE1("--- iChunkKernAddr: 0x%08x", chunkKernAddr); |
|
208 // It should contains SMR and HCR image headers and some settings |
|
209 HCR_HEX_DUMP_ABS((TUint8 *)chunkKernAddr, 1024 ); |
|
210 |
|
211 // Skip the SMR header, so we return the address of the first byte in the Repository |
|
212 aAddr = (TAny *) (chunkKernAddr + sizeof(SSmrRomHeader)); |
|
213 |
|
214 HCR_TRACE_RETURN(KErrNone); |
|
215 } |
|
216 } |
|
217 |
|
218 ++smrBank; |
|
219 } |
|
220 #endif // !__WINS__ && !__X86__ |
|
221 |
102 HCR_TRACE_RETURN(KErrNotSupported); |
222 HCR_TRACE_RETURN(KErrNotSupported); |
103 |
|
104 } |
223 } |
105 |
224 |
106 |
225 |
107 // -- ENTRY POINTS ------------------------------------------------------------ |
226 // -- ENTRY POINTS ------------------------------------------------------------ |
108 |
227 |