e32boot.cpp revision 1.1 1 1.1 kiyohara /* $NetBSD: e32boot.cpp,v 1.1 2013/04/28 12:11:26 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.1 kiyohara
135 1.1 kiyohara console =
136 1.1 kiyohara Console::NewL(E32BootName, TSize(KConsFullScreen, KConsFullScreen));
137 1.1 kiyohara
138 1.1 kiyohara buf = User::AllocL(ALIGN_SAFE_PAGE_SIZE); /* bootinfo buffer */
139 1.1 kiyohara
140 1.1 kiyohara /* Put banner */
141 1.1 kiyohara console->Printf(_L("\n"));
142 1.1 kiyohara console->Printf(_L(">> %s, Revision %s\n"),
143 1.1 kiyohara bootprog_name, bootprog_rev);
144 1.1 kiyohara
145 1.1 kiyohara UserSvr::ScreenInfo(sI);
146 1.1 kiyohara if (!screenInfo.iScreenAddressValid)
147 1.1 kiyohara User::Leave(KErrNotSupported);
148 1.1 kiyohara safeAddress = screenInfo.iScreenAddress;
149 1.1 kiyohara
150 1.1 kiyohara bootinfo = CreateBootInfo((TAny *)PAGE_ALIGN(buf));
151 1.1 kiyohara
152 1.1 kiyohara model = (struct btinfo_model *)FindBootInfoL(bootinfo, BTINFO_MODEL);
153 1.1 kiyohara console->Printf(_L(">> Model %s\n"), model->model);
154 1.1 kiyohara
155 1.1 kiyohara membytes = SummaryBootInfoMemory(bootinfo);
156 1.1 kiyohara console->Printf(_L(">> Memory %d k\n"), membytes / 1024);
157 1.1 kiyohara
158 1.1 kiyohara video = (struct btinfo_video *)FindBootInfoL(bootinfo, BTINFO_VIDEO);
159 1.1 kiyohara console->Printf(_L(">> Video %d x %d\n"), video->width, video->height);
160 1.1 kiyohara
161 1.1 kiyohara console->Printf(_L("\n"));
162 1.1 kiyohara
163 1.1 kiyohara TRAP(err, netbsd = LoadNetBSDL());
164 1.1 kiyohara if (err != KErrNone)
165 1.1 kiyohara User::Leave(err);
166 1.1 kiyohara else if (netbsd == NULL)
167 1.1 kiyohara return;
168 1.1 kiyohara console->Printf(_L("\nLoaded\n"));
169 1.1 kiyohara
170 1.1 kiyohara netbsd->ParseHeader();
171 1.1 kiyohara
172 1.1 kiyohara /* Load logical device(kernel part of e32boot). */
173 1.1 kiyohara if (_L(model->model).CompareF(_L("SERIES5 R1")) == 0)
174 1.1 kiyohara ldd = _L("e32boot-s5.ldd");
175 1.1 kiyohara else if (_L(model->model).CompareF(_L("SERIES5mx")) == 0)
176 1.1 kiyohara ldd = _L("e32boot-s5mx.ldd");
177 1.1 kiyohara // else if (_L(model->model).CompareF(_L("SERIES7")) == 0)
178 1.1 kiyohara // ldd = _L("e32boot-s7.ldd"); // not yet.
179 1.1 kiyohara else {
180 1.1 kiyohara console->Printf(_L("Not Supported machine\n"));
181 1.1 kiyohara console->Getch();
182 1.1 kiyohara User::Leave(KErrNotSupported);
183 1.1 kiyohara }
184 1.1 kiyohara err = User::LoadLogicalDevice(ldd);
185 1.1 kiyohara if (err != KErrNone && err != KErrAlreadyExists) {
186 1.1 kiyohara console->Printf(_L("LoadLogicalDevice failed: %d\n"), err);
187 1.1 kiyohara console->Getch();
188 1.1 kiyohara User::Leave(err);
189 1.1 kiyohara }
190 1.1 kiyohara /* Create channel to kernel part. */
191 1.1 kiyohara err = E32BootChannel->DoCreate(NULL, KNullUnit, NULL, NULL);
192 1.1 kiyohara if (err == KErrNone) {
193 1.1 kiyohara E32BootChannel->DoControl(KE32BootSetSafeAddress, safeAddress);
194 1.1 kiyohara E32BootChannel->DoControl(KE32BootBootNetBSD, netbsd, bootinfo);
195 1.1 kiyohara } else {
196 1.1 kiyohara console->Printf(_L("DoCreate failed: %d\n"), err);
197 1.1 kiyohara console->Getch();
198 1.1 kiyohara }
199 1.1 kiyohara
200 1.1 kiyohara User::FreeLogicalDevice(ldd);
201 1.1 kiyohara if (err != KErrNone)
202 1.1 kiyohara User::Leave(err);
203 1.1 kiyohara }
204 1.1 kiyohara
205 1.1 kiyohara GLDEF_C TInt E32Main(void) /* main function called by E32 */
206 1.1 kiyohara {
207 1.1 kiyohara
208 1.1 kiyohara __UHEAP_MARK;
209 1.1 kiyohara CTrapCleanup *cleanup = CTrapCleanup::New();
210 1.1 kiyohara
211 1.1 kiyohara TRAPD(error, E32BootL());
212 1.1 kiyohara __ASSERT_ALWAYS(!error, User::Panic(E32BootName, error));
213 1.1 kiyohara
214 1.1 kiyohara delete cleanup;
215 1.1 kiyohara __UHEAP_MARKEND;
216 1.1 kiyohara return 0;
217 1.1 kiyohara }
218 1.1 kiyohara
219 1.1 kiyohara LOCAL_C NetBSD *
220 1.1 kiyohara LoadNetBSDL(void)
221 1.1 kiyohara {
222 1.1 kiyohara NetBSD *netbsd = NULL;
223 1.1 kiyohara TBuf<KMaxCommandLine> input;
224 1.1 kiyohara TPtrC Default = _L("C:\\netbsd");
225 1.1 kiyohara TPtrC Prompt = _L("Boot: ");
226 1.1 kiyohara TInt pos, err;
227 1.1 kiyohara TBool retry;
228 1.1 kiyohara
229 1.1 kiyohara input.Zero();
230 1.1 kiyohara retry = false;
231 1.1 kiyohara console->Printf(Prompt);
232 1.1 kiyohara console->Printf(_L("["));
233 1.1 kiyohara console->Printf(Default);
234 1.1 kiyohara console->Printf(_L("]: "));
235 1.1 kiyohara console->SetPos(Prompt.Length() +
236 1.1 kiyohara _L("[").Length() +
237 1.1 kiyohara Default.Length() +
238 1.1 kiyohara _L("]: ").Length());
239 1.1 kiyohara pos = 0;
240 1.1 kiyohara while (1) {
241 1.1 kiyohara TChar gChar = console->Getch();
242 1.1 kiyohara switch (gChar) {
243 1.1 kiyohara case EKeyEscape:
244 1.1 kiyohara return NULL;
245 1.1 kiyohara
246 1.1 kiyohara case EKeyEnter:
247 1.1 kiyohara break;
248 1.1 kiyohara
249 1.1 kiyohara case EKeyBackspace:
250 1.1 kiyohara if (pos > 0) {
251 1.1 kiyohara pos--;
252 1.1 kiyohara input.Delete(pos, 1);
253 1.1 kiyohara }
254 1.1 kiyohara break;
255 1.1 kiyohara
256 1.1 kiyohara default:
257 1.1 kiyohara if (gChar.IsPrint()) {
258 1.1 kiyohara if (input.Length() < KMaxCommandLine) {
259 1.1 kiyohara TBuf<0x02> b;
260 1.1 kiyohara b.Append(gChar);
261 1.1 kiyohara input.Insert(pos++, b);
262 1.1 kiyohara }
263 1.1 kiyohara }
264 1.1 kiyohara break;
265 1.1 kiyohara }
266 1.1 kiyohara if (gChar == EKeyEnter) {
267 1.1 kiyohara if (input.Length() > 0) {
268 1.1 kiyohara TBufC<KMaxCommandLine> kernel =
269 1.1 kiyohara TBufC<KMaxCommandLine>(input);
270 1.1 kiyohara
271 1.1 kiyohara TRAP(err, netbsd = NetBSD::New(kernel));
272 1.1 kiyohara } else {
273 1.1 kiyohara TRAP(err, netbsd = NetBSD::New(Default));
274 1.1 kiyohara }
275 1.1 kiyohara if (err == 0 && netbsd != NULL)
276 1.1 kiyohara break;
277 1.1 kiyohara console->Printf(_L("\nLoad failed: %d\n"), err);
278 1.1 kiyohara
279 1.1 kiyohara input.Zero();
280 1.1 kiyohara console->Printf(Prompt);
281 1.1 kiyohara pos = 0;
282 1.1 kiyohara retry = true;
283 1.1 kiyohara }
284 1.1 kiyohara TInt base = Prompt.Length();
285 1.1 kiyohara if (!retry)
286 1.1 kiyohara base += (_L("[").Length() + Default.Length() +
287 1.1 kiyohara _L("]: ").Length());
288 1.1 kiyohara console->SetPos(base + pos);
289 1.1 kiyohara console->ClearToEndOfLine();
290 1.1 kiyohara console->SetPos(base);
291 1.1 kiyohara console->Write(input);
292 1.1 kiyohara console->SetPos(base + pos);
293 1.1 kiyohara }
294 1.1 kiyohara
295 1.1 kiyohara return netbsd;
296 1.1 kiyohara }
297 1.1 kiyohara
298 1.1 kiyohara #define KB * 1024
299 1.1 kiyohara
300 1.1 kiyohara LOCAL_C struct btinfo_common *
301 1.1 kiyohara CreateBootInfo(TAny *buf)
302 1.1 kiyohara {
303 1.1 kiyohara TMachineInfoV1Buf MachInfo;
304 1.1 kiyohara TMemoryInfoV1Buf MemInfo;
305 1.1 kiyohara struct btinfo_common *bootinfo, *common;
306 1.1 kiyohara struct btinfo_model *model;
307 1.1 kiyohara struct btinfo_memory *memory;
308 1.1 kiyohara struct btinfo_video *video;
309 1.1 kiyohara struct memmap *memmap;
310 1.1 kiyohara TUint memsize;
311 1.1 kiyohara TUint i;
312 1.1 kiyohara
313 1.1 kiyohara UserHal::MachineInfo(MachInfo);
314 1.1 kiyohara UserHal::MemoryInfo(MemInfo);
315 1.1 kiyohara
316 1.1 kiyohara common = bootinfo = (struct btinfo_common *)buf;
317 1.1 kiyohara
318 1.1 kiyohara /* Set machine name to bootinfo. */
319 1.1 kiyohara common->len = sizeof(struct btinfo_model);
320 1.1 kiyohara common->type = BTINFO_MODEL;
321 1.1 kiyohara model = (struct btinfo_model *)common;
322 1.1 kiyohara Mem::Copy(model->model, &MachInfo().iMachineName[0],
323 1.1 kiyohara sizeof(model->model));
324 1.1 kiyohara common = &(model + 1)->common;
325 1.1 kiyohara
326 1.1 kiyohara /* Set video width/height to bootinfo. */
327 1.1 kiyohara common->len = sizeof(struct btinfo_video);
328 1.1 kiyohara common->type = BTINFO_VIDEO;
329 1.1 kiyohara video = (struct btinfo_video *)common;
330 1.1 kiyohara video->width = MachInfo().iDisplaySizeInPixels.iWidth;
331 1.1 kiyohara video->height = MachInfo().iDisplaySizeInPixels.iHeight;
332 1.1 kiyohara common = &(video + 1)->common;
333 1.1 kiyohara
334 1.1 kiyohara /* Set memory size to bootinfo. */
335 1.1 kiyohara memsize = MemInfo().iTotalRamInBytes / 1024;
336 1.1 kiyohara for (i = 0; i < sizeof(memmaps) / sizeof(memmaps[0]); i++) {
337 1.1 kiyohara if (_L(memmaps[i].model).CompareF(_L(model->model)) == 0 &&
338 1.1 kiyohara memmaps[i].width == video->width &&
339 1.1 kiyohara memmaps[i].height == video->height &&
340 1.1 kiyohara memmaps[i].memsize == memsize) {
341 1.1 kiyohara memmap = memmaps[i].memmaps;
342 1.1 kiyohara while (memsize > 0) {
343 1.1 kiyohara common->len = sizeof(struct btinfo_memory);
344 1.1 kiyohara common->type = BTINFO_MEMORY;
345 1.1 kiyohara memory = (struct btinfo_memory *)common;
346 1.1 kiyohara memory->address = memmap->address;
347 1.1 kiyohara memory->size = memmap->size KB;
348 1.1 kiyohara common = &(memory + 1)->common;
349 1.1 kiyohara memsize -= memmap->size;
350 1.1 kiyohara memmap++;
351 1.1 kiyohara }
352 1.1 kiyohara break;
353 1.1 kiyohara }
354 1.1 kiyohara }
355 1.1 kiyohara if (i == sizeof(memmaps) / sizeof(memmaps[0])) {
356 1.1 kiyohara common->len = sizeof(struct btinfo_memory);
357 1.1 kiyohara common->type = BTINFO_MEMORY;
358 1.1 kiyohara memory = (struct btinfo_memory *)common;
359 1.1 kiyohara memory->address = 0xc0000000; /* default is here */
360 1.1 kiyohara memory->size = 4096 KB; /* XXXXX */
361 1.1 kiyohara common = &(memory + 1)->common;
362 1.1 kiyohara }
363 1.1 kiyohara
364 1.1 kiyohara common->len = 0;
365 1.1 kiyohara common->type = BTINFO_NONE;
366 1.1 kiyohara
367 1.1 kiyohara /* Terminate bootinfo. */
368 1.1 kiyohara return bootinfo;
369 1.1 kiyohara }
370 1.1 kiyohara
371 1.1 kiyohara #undef KB
372 1.1 kiyohara
373 1.1 kiyohara LOCAL_C struct btinfo_common *
374 1.1 kiyohara FindBootInfoL(struct btinfo_common *bootinfo, int type)
375 1.1 kiyohara {
376 1.1 kiyohara struct btinfo_common *entry;
377 1.1 kiyohara
378 1.1 kiyohara entry = bootinfo;
379 1.1 kiyohara while (entry->type != BTINFO_NONE) {
380 1.1 kiyohara if (entry->type == type)
381 1.1 kiyohara return entry;
382 1.1 kiyohara entry = (struct btinfo_common *)((int)entry + entry->len);
383 1.1 kiyohara }
384 1.1 kiyohara User::Leave(KErrNotFound);
385 1.1 kiyohara
386 1.1 kiyohara /* NOTREACHED */
387 1.1 kiyohara
388 1.1 kiyohara return NULL;
389 1.1 kiyohara }
390 1.1 kiyohara
391 1.1 kiyohara TUint
392 1.1 kiyohara SummaryBootInfoMemory(struct btinfo_common *bootinfo)
393 1.1 kiyohara {
394 1.1 kiyohara struct btinfo_common *entry;
395 1.1 kiyohara struct btinfo_memory *memory;
396 1.1 kiyohara TUint memsize = 0;
397 1.1 kiyohara
398 1.1 kiyohara entry = bootinfo;
399 1.1 kiyohara while (entry->type != BTINFO_NONE) {
400 1.1 kiyohara if (entry->type == BTINFO_MEMORY) {
401 1.1 kiyohara memory = (struct btinfo_memory *)entry;
402 1.1 kiyohara memsize += memory->size;
403 1.1 kiyohara }
404 1.1 kiyohara entry = (struct btinfo_common *)((int)entry + entry->len);
405 1.1 kiyohara }
406 1.1 kiyohara return memsize;
407 1.1 kiyohara }
408