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