e32boot.cpp revision 1.3.2.2 1 1.3.2.2 tls /* $NetBSD: e32boot.cpp,v 1.3.2.2 2013/06/23 06:20:03 tls Exp $ */
2 1.3.2.2 tls /*
3 1.3.2.2 tls * Copyright (c) 2012, 2013 KIYOHARA Takashi
4 1.3.2.2 tls * All rights reserved.
5 1.3.2.2 tls *
6 1.3.2.2 tls * Redistribution and use in source and binary forms, with or without
7 1.3.2.2 tls * modification, are permitted provided that the following conditions
8 1.3.2.2 tls * are met:
9 1.3.2.2 tls * 1. Redistributions of source code must retain the above copyright
10 1.3.2.2 tls * notice, this list of conditions and the following disclaimer.
11 1.3.2.2 tls * 2. Redistributions in binary form must reproduce the above copyright
12 1.3.2.2 tls * notice, this list of conditions and the following disclaimer in the
13 1.3.2.2 tls * documentation and/or other materials provided with the distribution.
14 1.3.2.2 tls *
15 1.3.2.2 tls * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 1.3.2.2 tls * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 1.3.2.2 tls * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 1.3.2.2 tls * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 1.3.2.2 tls * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 1.3.2.2 tls * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 1.3.2.2 tls * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.3.2.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 1.3.2.2 tls * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 1.3.2.2 tls * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.3.2.2 tls * POSSIBILITY OF SUCH DAMAGE.
26 1.3.2.2 tls */
27 1.3.2.2 tls
28 1.3.2.2 tls #include <e32base.h>
29 1.3.2.2 tls #include <e32cons.h>
30 1.3.2.2 tls #include <e32def.h>
31 1.3.2.2 tls #include <e32hal.h>
32 1.3.2.2 tls #include <e32svr.h> /* XXXXX */
33 1.3.2.2 tls #include <w32std.h>
34 1.3.2.2 tls
35 1.3.2.2 tls #include "e32boot.h"
36 1.3.2.2 tls #include "netbsd.h"
37 1.3.2.2 tls #include "../../../include/bootinfo.h"
38 1.3.2.2 tls
39 1.3.2.2 tls CConsoleBase *console;
40 1.3.2.2 tls LOCAL_C NetBSD *LoadNetBSDL(void);
41 1.3.2.2 tls LOCAL_C struct btinfo_common *CreateBootInfo(TAny *);
42 1.3.2.2 tls LOCAL_C struct btinfo_common *FindBootInfoL(struct btinfo_common *, int);
43 1.3.2.2 tls TUint SummaryBootInfoMemory(struct btinfo_common *);
44 1.3.2.2 tls LOCAL_C void E32BootL(void);
45 1.3.2.2 tls
46 1.3.2.2 tls struct memmap {
47 1.3.2.2 tls TUint address;
48 1.3.2.2 tls TUint size; /* KB */
49 1.3.2.2 tls };
50 1.3.2.2 tls struct memmap series5_4m[] = {{ 0xc0000000, 512 }, { 0xc0100000, 512 },
51 1.3.2.2 tls { 0xc0400000, 512 }, { 0xc0500000, 512 },
52 1.3.2.2 tls { 0xc1000000, 512 }, { 0xc1100000, 512 },
53 1.3.2.2 tls { 0xc1400000, 512 }, { 0xc1500000, 512 }};
54 1.3.2.2 tls struct memmap series5_8m[] = {{ 0xc0000000, 512 }, { 0xc0100000, 512 },
55 1.3.2.2 tls { 0xc0400000, 512 }, { 0xc0500000, 512 },
56 1.3.2.2 tls { 0xc1000000, 512 }, { 0xc1100000, 512 },
57 1.3.2.2 tls { 0xc1400000, 512 }, { 0xc1500000, 512 },
58 1.3.2.2 tls { 0xd0000000, 512 }, { 0xd0100000, 512 },
59 1.3.2.2 tls { 0xd0400000, 512 }, { 0xd0500000, 512 },
60 1.3.2.2 tls { 0xd1000000, 512 }, { 0xd1100000, 512 },
61 1.3.2.2 tls { 0xd1400000, 512 }, { 0xd1500000, 512 }};
62 1.3.2.2 tls struct memmap revo[] = {{ 0xc0000000, 4096 }, { 0xc0800000, 4096 }};
63 1.3.2.2 tls struct memmap revopuls[] = {{ 0xc0000000, 4096 }, { 0xc0800000, 4096 },
64 1.3.2.2 tls { 0xd0000000, 4096 }, { 0xd0800000, 4096 }};
65 1.3.2.2 tls struct memmap series5mx_16m[] = {{ 0xc0000000, 8192 }, { 0xc1000000, 8192 }};
66 1.3.2.2 tls struct memmap series5mxpro_24m[] = {{ 0xc0000000, 8192 }, { 0xc1000000, 8192 },
67 1.3.2.2 tls { 0xd0000000, 4096 }, { 0xd0800000, 4096 }};
68 1.3.2.2 tls struct memmap series5mxpro_32m[] = {{ 0xc0000000, 8192 }, { 0xc1000000, 8192 },
69 1.3.2.2 tls { 0xd0000000, 8192 }, { 0xd1000000, 8192 }};
70 1.3.2.2 tls struct memmap series7_16m[] = {{ 0xc0000000, 16384 }};
71 1.3.2.2 tls struct memmap series7_32m[] = {{ 0xc0000000, 16384 }, { 0xc8000000, 16384 }};
72 1.3.2.2 tls
73 1.3.2.2 tls struct {
74 1.3.2.2 tls char *model;
75 1.3.2.2 tls TInt width;
76 1.3.2.2 tls TInt height;
77 1.3.2.2 tls TUint memsize;
78 1.3.2.2 tls struct memmap *memmaps;
79 1.3.2.2 tls } memmaps[] = {
80 1.3.2.2 tls { "SERIES5 R1", 640, 240, 4096, series5_4m },
81 1.3.2.2 tls { "SERIES5 R1", 640, 240, 8192, series5_8m },
82 1.3.2.2 tls { "SERIES5 R1", 640, 320, 4096, series5_4m }, /* Geofox One */
83 1.3.2.2 tls { "SERIES5 R1", 640, 320, 8192, series5_8m }, /* Geofox One */
84 1.3.2.2 tls // { "SERIES5 R1", 640, 320, 16384, one_16m },
85 1.3.2.2 tls { "SERIES5 R1", 320, 200, 4096, series5_4m }, /* Osaris */
86 1.3.2.2 tls // { "SERIES5 R1", 320, 200, 16384, osaris_16m },
87 1.3.2.2 tls { "SERIES5mx", 480, 160, 8192, revo },
88 1.3.2.2 tls { "SERIES5mx", 480, 160, 16384, revopuls },
89 1.3.2.2 tls { "SERIES5mx", 640, 240, 16384, series5mx_16m },
90 1.3.2.2 tls { "SERIES5mx", 640, 240, 24576, series5mxpro_24m },
91 1.3.2.2 tls { "SERIES5mx", 640, 240, 32768, series5mxpro_32m },
92 1.3.2.2 tls { "SERIES7", 800, 600, 16384, series7_16m },
93 1.3.2.2 tls { "SERIES7", 800, 600, 32768, series7_32m },
94 1.3.2.2 tls };
95 1.3.2.2 tls
96 1.3.2.2 tls class E32BootLogicalChannel : public RLogicalChannel {
97 1.3.2.2 tls public:
98 1.3.2.2 tls TInt DoCreate(const TDesC *aChan, TInt aUnit, const TDesC *aDriver,
99 1.3.2.2 tls const TDesC8 *anInfo)
100 1.3.2.2 tls {
101 1.3.2.2 tls
102 1.3.2.2 tls return RLogicalChannel::DoCreate(E32BootName, TVersion(0, 0, 0),
103 1.3.2.2 tls aChan, aUnit, aDriver, anInfo);
104 1.3.2.2 tls }
105 1.3.2.2 tls
106 1.3.2.2 tls TInt DoControl(TInt aFunction, TAny *a1)
107 1.3.2.2 tls {
108 1.3.2.2 tls
109 1.3.2.2 tls return RLogicalChannel::DoControl(aFunction, a1);
110 1.3.2.2 tls }
111 1.3.2.2 tls
112 1.3.2.2 tls TInt DoControl(TInt aFunction, TAny *a1, TAny *a2)
113 1.3.2.2 tls {
114 1.3.2.2 tls
115 1.3.2.2 tls return RLogicalChannel::DoControl(aFunction, a1, a2);
116 1.3.2.2 tls }
117 1.3.2.2 tls };
118 1.3.2.2 tls
119 1.3.2.2 tls
120 1.3.2.2 tls LOCAL_C void
121 1.3.2.2 tls E32BootL(void)
122 1.3.2.2 tls {
123 1.3.2.2 tls E32BootLogicalChannel *E32BootChannel = new E32BootLogicalChannel;
124 1.3.2.2 tls NetBSD *netbsd = NULL;
125 1.3.2.2 tls TScreenInfoV01 screenInfo;
126 1.3.2.2 tls TPckg<TScreenInfoV01> sI(screenInfo);
127 1.3.2.2 tls TBuf<32> ldd;
128 1.3.2.2 tls TInt err;
129 1.3.2.2 tls TUint membytes;
130 1.3.2.2 tls TAny *buf, *safeAddress;
131 1.3.2.2 tls struct btinfo_common *bootinfo;
132 1.3.2.2 tls struct btinfo_model *model;
133 1.3.2.2 tls struct btinfo_video *video;
134 1.3.2.2 tls struct btinfo_bootargs *bootargs;
135 1.3.2.2 tls
136 1.3.2.2 tls console =
137 1.3.2.2 tls Console::NewL(E32BootName, TSize(KConsFullScreen, KConsFullScreen));
138 1.3.2.2 tls
139 1.3.2.2 tls buf = User::AllocL(ALIGN_SAFE_PAGE_SIZE); /* bootinfo buffer */
140 1.3.2.2 tls
141 1.3.2.2 tls /* Put banner */
142 1.3.2.2 tls console->Printf(_L("\n"));
143 1.3.2.2 tls console->Printf(_L(">> %s, Revision %s\n"),
144 1.3.2.2 tls bootprog_name, bootprog_rev);
145 1.3.2.2 tls
146 1.3.2.2 tls UserSvr::ScreenInfo(sI);
147 1.3.2.2 tls if (!screenInfo.iScreenAddressValid)
148 1.3.2.2 tls User::Leave(KErrNotSupported);
149 1.3.2.2 tls safeAddress = screenInfo.iScreenAddress;
150 1.3.2.2 tls
151 1.3.2.2 tls bootinfo = CreateBootInfo((TAny *)PAGE_ALIGN(buf));
152 1.3.2.2 tls
153 1.3.2.2 tls model = (struct btinfo_model *)FindBootInfoL(bootinfo, BTINFO_MODEL);
154 1.3.2.2 tls console->Printf(_L(">> Model %s\n"), model->model);
155 1.3.2.2 tls
156 1.3.2.2 tls membytes = SummaryBootInfoMemory(bootinfo);
157 1.3.2.2 tls console->Printf(_L(">> Memory %d k\n"), membytes / 1024);
158 1.3.2.2 tls
159 1.3.2.2 tls video = (struct btinfo_video *)FindBootInfoL(bootinfo, BTINFO_VIDEO);
160 1.3.2.2 tls console->Printf(_L(">> Video %d x %d\n"), video->width, video->height);
161 1.3.2.2 tls
162 1.3.2.2 tls console->Printf(_L("\n"));
163 1.3.2.2 tls
164 1.3.2.2 tls bootargs =
165 1.3.2.2 tls (struct btinfo_bootargs *)FindBootInfoL(bootinfo, BTINFO_BOOTARGS);
166 1.3.2.2 tls TRAP(err, netbsd = LoadNetBSDL());
167 1.3.2.2 tls if (err != KErrNone)
168 1.3.2.2 tls User::Leave(err);
169 1.3.2.2 tls else if (netbsd == NULL)
170 1.3.2.2 tls return;
171 1.3.2.2 tls console->Printf(_L("\nLoaded\n"));
172 1.3.2.2 tls
173 1.3.2.2 tls int n, m;
174 1.3.2.2 tls n = sizeof(bootargs->bootargs);
175 1.3.2.2 tls m = (*netbsd->GetArgs()).Length();
176 1.3.2.2 tls if (m > 0)
177 1.3.2.2 tls Mem::Copy(bootargs->bootargs, &(*netbsd->GetArgs())[0],
178 1.3.2.2 tls n < m ? n : m);
179 1.3.2.2 tls bootargs->bootargs[n < m ? n - 1 : m] = '\0';
180 1.3.2.2 tls
181 1.3.2.2 tls netbsd->ParseHeader();
182 1.3.2.2 tls
183 1.3.2.2 tls /* Load logical device(kernel part of e32boot). */
184 1.3.2.2 tls if (_L(model->model).CompareF(_L("SERIES5 R1")) == 0)
185 1.3.2.2 tls ldd = _L("e32boot-s5.ldd");
186 1.3.2.2 tls else if (_L(model->model).CompareF(_L("SERIES5mx")) == 0)
187 1.3.2.2 tls ldd = _L("e32boot-s5mx.ldd");
188 1.3.2.2 tls // else if (_L(model->model).CompareF(_L("SERIES7")) == 0)
189 1.3.2.2 tls // ldd = _L("e32boot-s7.ldd"); // not yet.
190 1.3.2.2 tls else {
191 1.3.2.2 tls console->Printf(_L("Not Supported machine\n"));
192 1.3.2.2 tls console->Getch();
193 1.3.2.2 tls User::Leave(KErrNotSupported);
194 1.3.2.2 tls }
195 1.3.2.2 tls err = User::LoadLogicalDevice(ldd);
196 1.3.2.2 tls if (err != KErrNone && err != KErrAlreadyExists) {
197 1.3.2.2 tls console->Printf(_L("LoadLogicalDevice failed: %d\n"), err);
198 1.3.2.2 tls console->Getch();
199 1.3.2.2 tls User::Leave(err);
200 1.3.2.2 tls }
201 1.3.2.2 tls /* Create channel to kernel part. */
202 1.3.2.2 tls err = E32BootChannel->DoCreate(NULL, KNullUnit, NULL, NULL);
203 1.3.2.2 tls if (err == KErrNone) {
204 1.3.2.2 tls E32BootChannel->DoControl(KE32BootSetSafeAddress, safeAddress);
205 1.3.2.2 tls E32BootChannel->DoControl(KE32BootBootNetBSD, netbsd, bootinfo);
206 1.3.2.2 tls } else {
207 1.3.2.2 tls console->Printf(_L("DoCreate failed: %d\n"), err);
208 1.3.2.2 tls console->Getch();
209 1.3.2.2 tls }
210 1.3.2.2 tls
211 1.3.2.2 tls User::FreeLogicalDevice(ldd);
212 1.3.2.2 tls if (err != KErrNone)
213 1.3.2.2 tls User::Leave(err);
214 1.3.2.2 tls }
215 1.3.2.2 tls
216 1.3.2.2 tls GLDEF_C TInt E32Main(void) /* main function called by E32 */
217 1.3.2.2 tls {
218 1.3.2.2 tls
219 1.3.2.2 tls __UHEAP_MARK;
220 1.3.2.2 tls CTrapCleanup *cleanup = CTrapCleanup::New();
221 1.3.2.2 tls
222 1.3.2.2 tls TRAPD(error, E32BootL());
223 1.3.2.2 tls __ASSERT_ALWAYS(!error, User::Panic(E32BootName, error));
224 1.3.2.2 tls
225 1.3.2.2 tls delete cleanup;
226 1.3.2.2 tls __UHEAP_MARKEND;
227 1.3.2.2 tls return 0;
228 1.3.2.2 tls }
229 1.3.2.2 tls
230 1.3.2.2 tls LOCAL_C NetBSD *
231 1.3.2.2 tls LoadNetBSDL(void)
232 1.3.2.2 tls {
233 1.3.2.2 tls NetBSD *netbsd = NULL;
234 1.3.2.2 tls TBuf<KMaxCommandLine> input, *args;
235 1.3.2.2 tls TPtrC Default = _L("C:\\netbsd");
236 1.3.2.2 tls TPtrC Prompt = _L("Boot: ");
237 1.3.2.2 tls TInt pos, err;
238 1.3.2.2 tls TBool retry;
239 1.3.2.2 tls
240 1.3.2.2 tls input.Zero();
241 1.3.2.2 tls args = new TBuf<KMaxCommandLine>;
242 1.3.2.2 tls args->Zero();
243 1.3.2.2 tls retry = false;
244 1.3.2.2 tls console->Printf(Prompt);
245 1.3.2.2 tls console->Printf(_L("["));
246 1.3.2.2 tls console->Printf(Default);
247 1.3.2.2 tls console->Printf(_L("]: "));
248 1.3.2.2 tls console->SetPos(Prompt.Length() +
249 1.3.2.2 tls _L("[").Length() +
250 1.3.2.2 tls Default.Length() +
251 1.3.2.2 tls _L("]: ").Length());
252 1.3.2.2 tls pos = 0;
253 1.3.2.2 tls while (1) {
254 1.3.2.2 tls TChar gChar = console->Getch();
255 1.3.2.2 tls switch (gChar) {
256 1.3.2.2 tls case EKeyEscape:
257 1.3.2.2 tls return NULL;
258 1.3.2.2 tls
259 1.3.2.2 tls case EKeyEnter:
260 1.3.2.2 tls break;
261 1.3.2.2 tls
262 1.3.2.2 tls case EKeyBackspace:
263 1.3.2.2 tls if (pos > 0) {
264 1.3.2.2 tls pos--;
265 1.3.2.2 tls input.Delete(pos, 1);
266 1.3.2.2 tls }
267 1.3.2.2 tls break;
268 1.3.2.2 tls
269 1.3.2.2 tls default:
270 1.3.2.2 tls if (gChar.IsPrint()) {
271 1.3.2.2 tls if (input.Length() < KMaxCommandLine) {
272 1.3.2.2 tls TBuf<0x02> b;
273 1.3.2.2 tls b.Append(gChar);
274 1.3.2.2 tls input.Insert(pos++, b);
275 1.3.2.2 tls }
276 1.3.2.2 tls }
277 1.3.2.2 tls break;
278 1.3.2.2 tls }
279 1.3.2.2 tls if (gChar == EKeyEnter) {
280 1.3.2.2 tls input.TrimAll();
281 1.3.2.2 tls if (input[0] == '-')
282 1.3.2.2 tls input.Swap(*args);
283 1.3.2.2 tls for (int i = 0; i < input.Length(); i++)
284 1.3.2.2 tls if (input[i] == ' ') {
285 1.3.2.2 tls args->Copy(input);
286 1.3.2.2 tls input.SetLength(i);
287 1.3.2.2 tls args->Delete(0, i + 1);
288 1.3.2.2 tls break;
289 1.3.2.2 tls }
290 1.3.2.2 tls args->ZeroTerminate();
291 1.3.2.2 tls
292 1.3.2.2 tls if (input.Length() > 0) {
293 1.3.2.2 tls TRAP(err, netbsd = NetBSD::New(input, *args));
294 1.3.2.2 tls } else {
295 1.3.2.2 tls TRAP(err, netbsd = NetBSD::New(Default, *args));
296 1.3.2.2 tls }
297 1.3.2.2 tls if (err == 0 && netbsd != NULL)
298 1.3.2.2 tls break;
299 1.3.2.2 tls console->Printf(_L("\nLoad failed: %d\n"), err);
300 1.3.2.2 tls
301 1.3.2.2 tls input.Zero();
302 1.3.2.2 tls args->Zero();
303 1.3.2.2 tls console->Printf(Prompt);
304 1.3.2.2 tls pos = 0;
305 1.3.2.2 tls retry = true;
306 1.3.2.2 tls }
307 1.3.2.2 tls TInt base = Prompt.Length();
308 1.3.2.2 tls if (!retry)
309 1.3.2.2 tls base += (_L("[").Length() + Default.Length() +
310 1.3.2.2 tls _L("]: ").Length());
311 1.3.2.2 tls console->SetPos(base + pos);
312 1.3.2.2 tls console->ClearToEndOfLine();
313 1.3.2.2 tls console->SetPos(base);
314 1.3.2.2 tls console->Write(input);
315 1.3.2.2 tls console->SetPos(base + pos);
316 1.3.2.2 tls }
317 1.3.2.2 tls
318 1.3.2.2 tls return netbsd;
319 1.3.2.2 tls }
320 1.3.2.2 tls
321 1.3.2.2 tls #define KB * 1024
322 1.3.2.2 tls
323 1.3.2.2 tls LOCAL_C struct btinfo_common *
324 1.3.2.2 tls CreateBootInfo(TAny *buf)
325 1.3.2.2 tls {
326 1.3.2.2 tls TMachineInfoV1Buf MachInfo;
327 1.3.2.2 tls TMemoryInfoV1Buf MemInfo;
328 1.3.2.2 tls struct btinfo_common *bootinfo, *common;
329 1.3.2.2 tls struct btinfo_model *model;
330 1.3.2.2 tls struct btinfo_memory *memory;
331 1.3.2.2 tls struct btinfo_video *video;
332 1.3.2.2 tls struct btinfo_bootargs *bootargs;
333 1.3.2.2 tls struct memmap *memmap;
334 1.3.2.2 tls TUint memsize;
335 1.3.2.2 tls TUint i;
336 1.3.2.2 tls
337 1.3.2.2 tls UserHal::MachineInfo(MachInfo);
338 1.3.2.2 tls UserHal::MemoryInfo(MemInfo);
339 1.3.2.2 tls
340 1.3.2.2 tls common = bootinfo = (struct btinfo_common *)buf;
341 1.3.2.2 tls
342 1.3.2.2 tls /* Set machine name to bootinfo. */
343 1.3.2.2 tls common->len = sizeof(struct btinfo_model);
344 1.3.2.2 tls common->type = BTINFO_MODEL;
345 1.3.2.2 tls model = (struct btinfo_model *)common;
346 1.3.2.2 tls Mem::Copy(model->model, &MachInfo().iMachineName[0],
347 1.3.2.2 tls sizeof(model->model));
348 1.3.2.2 tls common = &(model + 1)->common;
349 1.3.2.2 tls
350 1.3.2.2 tls /* Set video width/height to bootinfo. */
351 1.3.2.2 tls common->len = sizeof(struct btinfo_video);
352 1.3.2.2 tls common->type = BTINFO_VIDEO;
353 1.3.2.2 tls video = (struct btinfo_video *)common;
354 1.3.2.2 tls video->width = MachInfo().iDisplaySizeInPixels.iWidth;
355 1.3.2.2 tls video->height = MachInfo().iDisplaySizeInPixels.iHeight;
356 1.3.2.2 tls common = &(video + 1)->common;
357 1.3.2.2 tls
358 1.3.2.2 tls /* Set memory size to bootinfo. */
359 1.3.2.2 tls memsize = MemInfo().iTotalRamInBytes / 1024;
360 1.3.2.2 tls for (i = 0; i < sizeof(memmaps) / sizeof(memmaps[0]); i++) {
361 1.3.2.2 tls if (_L(memmaps[i].model).CompareF(_L(model->model)) == 0 &&
362 1.3.2.2 tls memmaps[i].width == video->width &&
363 1.3.2.2 tls memmaps[i].height == video->height &&
364 1.3.2.2 tls memmaps[i].memsize == memsize) {
365 1.3.2.2 tls memmap = memmaps[i].memmaps;
366 1.3.2.2 tls while (memsize > 0) {
367 1.3.2.2 tls common->len = sizeof(struct btinfo_memory);
368 1.3.2.2 tls common->type = BTINFO_MEMORY;
369 1.3.2.2 tls memory = (struct btinfo_memory *)common;
370 1.3.2.2 tls memory->address = memmap->address;
371 1.3.2.2 tls memory->size = memmap->size KB;
372 1.3.2.2 tls common = &(memory + 1)->common;
373 1.3.2.2 tls memsize -= memmap->size;
374 1.3.2.2 tls memmap++;
375 1.3.2.2 tls }
376 1.3.2.2 tls break;
377 1.3.2.2 tls }
378 1.3.2.2 tls }
379 1.3.2.2 tls if (i == sizeof(memmaps) / sizeof(memmaps[0])) {
380 1.3.2.2 tls common->len = sizeof(struct btinfo_memory);
381 1.3.2.2 tls common->type = BTINFO_MEMORY;
382 1.3.2.2 tls memory = (struct btinfo_memory *)common;
383 1.3.2.2 tls memory->address = 0xc0000000; /* default is here */
384 1.3.2.2 tls memory->size = 4096 KB; /* XXXXX */
385 1.3.2.2 tls common = &(memory + 1)->common;
386 1.3.2.2 tls }
387 1.3.2.2 tls
388 1.3.2.2 tls common->len = sizeof(struct btinfo_bootargs);
389 1.3.2.2 tls common->type = BTINFO_BOOTARGS;
390 1.3.2.2 tls bootargs = (struct btinfo_bootargs *)common;
391 1.3.2.2 tls bootargs->bootargs[0] = '\0';
392 1.3.2.2 tls common = &(bootargs + 1)->common;
393 1.3.2.2 tls
394 1.3.2.2 tls common->len = 0;
395 1.3.2.2 tls common->type = BTINFO_NONE;
396 1.3.2.2 tls
397 1.3.2.2 tls /* Terminate bootinfo. */
398 1.3.2.2 tls return bootinfo;
399 1.3.2.2 tls }
400 1.3.2.2 tls
401 1.3.2.2 tls #undef KB
402 1.3.2.2 tls
403 1.3.2.2 tls LOCAL_C struct btinfo_common *
404 1.3.2.2 tls FindBootInfoL(struct btinfo_common *bootinfo, int type)
405 1.3.2.2 tls {
406 1.3.2.2 tls struct btinfo_common *entry;
407 1.3.2.2 tls
408 1.3.2.2 tls entry = bootinfo;
409 1.3.2.2 tls while (entry->type != BTINFO_NONE) {
410 1.3.2.2 tls if (entry->type == type)
411 1.3.2.2 tls return entry;
412 1.3.2.2 tls entry = (struct btinfo_common *)((int)entry + entry->len);
413 1.3.2.2 tls }
414 1.3.2.2 tls User::Leave(KErrNotFound);
415 1.3.2.2 tls
416 1.3.2.2 tls /* NOTREACHED */
417 1.3.2.2 tls
418 1.3.2.2 tls return NULL;
419 1.3.2.2 tls }
420 1.3.2.2 tls
421 1.3.2.2 tls TUint
422 1.3.2.2 tls SummaryBootInfoMemory(struct btinfo_common *bootinfo)
423 1.3.2.2 tls {
424 1.3.2.2 tls struct btinfo_common *entry;
425 1.3.2.2 tls struct btinfo_memory *memory;
426 1.3.2.2 tls TUint memsize = 0;
427 1.3.2.2 tls
428 1.3.2.2 tls entry = bootinfo;
429 1.3.2.2 tls while (entry->type != BTINFO_NONE) {
430 1.3.2.2 tls if (entry->type == BTINFO_MEMORY) {
431 1.3.2.2 tls memory = (struct btinfo_memory *)entry;
432 1.3.2.2 tls memsize += memory->size;
433 1.3.2.2 tls }
434 1.3.2.2 tls entry = (struct btinfo_common *)((int)entry + entry->len);
435 1.3.2.2 tls }
436 1.3.2.2 tls return memsize;
437 1.3.2.2 tls }
438