Home | History | Annotate | Line # | Download | only in exe
      1  1.3  kiyohara /*	$NetBSD: e32boot.cpp,v 1.3 2013/06/20 15:30:00 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.3  kiyohara 	if (m > 0)
    177  1.3  kiyohara 		Mem::Copy(bootargs->bootargs, &(*netbsd->GetArgs())[0],
    178  1.3  kiyohara 		    n < m ? n : m);
    179  1.2  kiyohara 	bootargs->bootargs[n < m ? n - 1 : m] = '\0';
    180  1.2  kiyohara 
    181  1.1  kiyohara 	netbsd->ParseHeader();
    182  1.1  kiyohara 
    183  1.1  kiyohara 	/* Load logical device(kernel part of e32boot). */
    184  1.1  kiyohara 	if (_L(model->model).CompareF(_L("SERIES5 R1")) == 0)
    185  1.1  kiyohara 		ldd = _L("e32boot-s5.ldd");
    186  1.1  kiyohara 	else if (_L(model->model).CompareF(_L("SERIES5mx")) == 0)
    187  1.1  kiyohara 		ldd = _L("e32boot-s5mx.ldd");
    188  1.1  kiyohara //	else if (_L(model->model).CompareF(_L("SERIES7")) == 0)
    189  1.1  kiyohara //		ldd = _L("e32boot-s7.ldd");	// not yet.
    190  1.1  kiyohara 	else {
    191  1.1  kiyohara 		console->Printf(_L("Not Supported machine\n"));
    192  1.1  kiyohara 		console->Getch();
    193  1.1  kiyohara 		User::Leave(KErrNotSupported);
    194  1.1  kiyohara 	}
    195  1.1  kiyohara 	err = User::LoadLogicalDevice(ldd);
    196  1.1  kiyohara 	if (err != KErrNone && err != KErrAlreadyExists) {
    197  1.1  kiyohara 		console->Printf(_L("LoadLogicalDevice failed: %d\n"), err);
    198  1.1  kiyohara 		console->Getch();
    199  1.1  kiyohara 		User::Leave(err);
    200  1.1  kiyohara 	}
    201  1.1  kiyohara 	/* Create channel to kernel part. */
    202  1.1  kiyohara 	err = E32BootChannel->DoCreate(NULL, KNullUnit, NULL, NULL);
    203  1.1  kiyohara 	if (err == KErrNone) {
    204  1.1  kiyohara 		E32BootChannel->DoControl(KE32BootSetSafeAddress, safeAddress);
    205  1.1  kiyohara 		E32BootChannel->DoControl(KE32BootBootNetBSD, netbsd, bootinfo);
    206  1.1  kiyohara 	} else {
    207  1.1  kiyohara 		console->Printf(_L("DoCreate failed: %d\n"), err);
    208  1.1  kiyohara 		console->Getch();
    209  1.1  kiyohara 	}
    210  1.1  kiyohara 
    211  1.1  kiyohara 	User::FreeLogicalDevice(ldd);
    212  1.1  kiyohara 	if (err != KErrNone)
    213  1.1  kiyohara 		User::Leave(err);
    214  1.1  kiyohara }
    215  1.1  kiyohara 
    216  1.1  kiyohara GLDEF_C TInt E32Main(void)	/* main function called by E32 */
    217  1.1  kiyohara {
    218  1.1  kiyohara 
    219  1.1  kiyohara 	__UHEAP_MARK;
    220  1.1  kiyohara 	CTrapCleanup *cleanup = CTrapCleanup::New();
    221  1.1  kiyohara 
    222  1.1  kiyohara 	TRAPD(error, E32BootL());
    223  1.1  kiyohara 	__ASSERT_ALWAYS(!error, User::Panic(E32BootName, error));
    224  1.1  kiyohara 
    225  1.1  kiyohara 	delete cleanup;
    226  1.1  kiyohara 	__UHEAP_MARKEND;
    227  1.1  kiyohara 	return 0;
    228  1.1  kiyohara }
    229  1.1  kiyohara 
    230  1.1  kiyohara LOCAL_C NetBSD *
    231  1.1  kiyohara LoadNetBSDL(void)
    232  1.1  kiyohara {
    233  1.1  kiyohara 	NetBSD *netbsd = NULL;
    234  1.2  kiyohara 	TBuf<KMaxCommandLine> input, *args;
    235  1.1  kiyohara 	TPtrC Default = _L("C:\\netbsd");
    236  1.1  kiyohara 	TPtrC Prompt = _L("Boot: ");
    237  1.1  kiyohara 	TInt pos, err;
    238  1.1  kiyohara 	TBool retry;
    239  1.1  kiyohara 
    240  1.1  kiyohara 	input.Zero();
    241  1.2  kiyohara 	args = new TBuf<KMaxCommandLine>;
    242  1.2  kiyohara 	args->Zero();
    243  1.1  kiyohara 	retry = false;
    244  1.1  kiyohara 	console->Printf(Prompt);
    245  1.1  kiyohara 	console->Printf(_L("["));
    246  1.1  kiyohara 	console->Printf(Default);
    247  1.1  kiyohara 	console->Printf(_L("]: "));
    248  1.1  kiyohara 	console->SetPos(Prompt.Length() +
    249  1.1  kiyohara 			_L("[").Length() +
    250  1.1  kiyohara 			Default.Length() +
    251  1.1  kiyohara 			_L("]: ").Length());
    252  1.1  kiyohara 	pos = 0;
    253  1.1  kiyohara 	while (1) {
    254  1.1  kiyohara 		TChar gChar = console->Getch();
    255  1.1  kiyohara 		switch (gChar) {
    256  1.1  kiyohara 		case EKeyEscape:
    257  1.1  kiyohara 			return NULL;
    258  1.1  kiyohara 
    259  1.1  kiyohara 		case EKeyEnter:
    260  1.1  kiyohara 			break;
    261  1.1  kiyohara 
    262  1.1  kiyohara 		case EKeyBackspace:
    263  1.1  kiyohara 			if (pos > 0) {
    264  1.1  kiyohara 				pos--;
    265  1.1  kiyohara 				input.Delete(pos, 1);
    266  1.1  kiyohara 			}
    267  1.1  kiyohara 			break;
    268  1.1  kiyohara 
    269  1.1  kiyohara 		default:
    270  1.1  kiyohara 			if (gChar.IsPrint()) {
    271  1.1  kiyohara 				if (input.Length() < KMaxCommandLine) {
    272  1.1  kiyohara 					TBuf<0x02> b;
    273  1.1  kiyohara 					b.Append(gChar);
    274  1.1  kiyohara 					input.Insert(pos++, b);
    275  1.1  kiyohara 				}
    276  1.1  kiyohara 			}
    277  1.1  kiyohara 			break;
    278  1.1  kiyohara 		}
    279  1.1  kiyohara 		if (gChar == EKeyEnter) {
    280  1.2  kiyohara 			input.TrimAll();
    281  1.2  kiyohara 			if (input[0] == '-')
    282  1.2  kiyohara 				input.Swap(*args);
    283  1.2  kiyohara 			for (int i = 0; i < input.Length(); i++)
    284  1.2  kiyohara 				if (input[i] == ' ') {
    285  1.2  kiyohara 					args->Copy(input);
    286  1.2  kiyohara 					input.SetLength(i);
    287  1.2  kiyohara 					args->Delete(0, i + 1);
    288  1.2  kiyohara 					break;
    289  1.2  kiyohara 				}
    290  1.2  kiyohara 			args->ZeroTerminate();
    291  1.2  kiyohara 
    292  1.1  kiyohara 			if (input.Length() > 0) {
    293  1.2  kiyohara 				TRAP(err, netbsd = NetBSD::New(input, *args));
    294  1.1  kiyohara 			} else {
    295  1.2  kiyohara 				TRAP(err, netbsd = NetBSD::New(Default, *args));
    296  1.1  kiyohara 			}
    297  1.1  kiyohara 			if (err == 0 && netbsd != NULL)
    298  1.1  kiyohara 				break;
    299  1.1  kiyohara 			console->Printf(_L("\nLoad failed: %d\n"), err);
    300  1.1  kiyohara 
    301  1.1  kiyohara 			input.Zero();
    302  1.2  kiyohara 			args->Zero();
    303  1.1  kiyohara 			console->Printf(Prompt);
    304  1.1  kiyohara 			pos = 0;
    305  1.1  kiyohara 			retry = true;
    306  1.1  kiyohara 		}
    307  1.1  kiyohara 		TInt base = Prompt.Length();
    308  1.1  kiyohara 		if (!retry)
    309  1.1  kiyohara 			base += (_L("[").Length() + Default.Length() +
    310  1.1  kiyohara 							_L("]: ").Length());
    311  1.1  kiyohara 		console->SetPos(base + pos);
    312  1.1  kiyohara 		console->ClearToEndOfLine();
    313  1.1  kiyohara 		console->SetPos(base);
    314  1.1  kiyohara 		console->Write(input);
    315  1.1  kiyohara 		console->SetPos(base + pos);
    316  1.1  kiyohara 	}
    317  1.1  kiyohara 
    318  1.1  kiyohara 	return netbsd;
    319  1.1  kiyohara }
    320  1.1  kiyohara 
    321  1.1  kiyohara #define KB	* 1024
    322  1.1  kiyohara 
    323  1.1  kiyohara LOCAL_C struct btinfo_common *
    324  1.1  kiyohara CreateBootInfo(TAny *buf)
    325  1.1  kiyohara {
    326  1.1  kiyohara 	TMachineInfoV1Buf MachInfo;
    327  1.1  kiyohara 	TMemoryInfoV1Buf MemInfo;
    328  1.1  kiyohara 	struct btinfo_common *bootinfo, *common;
    329  1.1  kiyohara 	struct btinfo_model *model;
    330  1.1  kiyohara 	struct btinfo_memory *memory;
    331  1.1  kiyohara 	struct btinfo_video *video;
    332  1.2  kiyohara 	struct btinfo_bootargs *bootargs;
    333  1.1  kiyohara 	struct memmap *memmap;
    334  1.1  kiyohara 	TUint memsize;
    335  1.1  kiyohara 	TUint i;
    336  1.1  kiyohara 
    337  1.1  kiyohara 	UserHal::MachineInfo(MachInfo);
    338  1.1  kiyohara 	UserHal::MemoryInfo(MemInfo);
    339  1.1  kiyohara 
    340  1.1  kiyohara 	common = bootinfo = (struct btinfo_common *)buf;
    341  1.1  kiyohara 
    342  1.1  kiyohara 	/* Set machine name to bootinfo. */
    343  1.1  kiyohara 	common->len = sizeof(struct btinfo_model);
    344  1.1  kiyohara 	common->type = BTINFO_MODEL;
    345  1.1  kiyohara 	model = (struct btinfo_model *)common;
    346  1.1  kiyohara 	Mem::Copy(model->model, &MachInfo().iMachineName[0],
    347  1.1  kiyohara 	    sizeof(model->model));
    348  1.1  kiyohara 	common = &(model + 1)->common;
    349  1.1  kiyohara 
    350  1.1  kiyohara 	/* Set video width/height to bootinfo. */
    351  1.1  kiyohara 	common->len = sizeof(struct btinfo_video);
    352  1.1  kiyohara 	common->type = BTINFO_VIDEO;
    353  1.1  kiyohara 	video = (struct btinfo_video *)common;
    354  1.1  kiyohara 	video->width = MachInfo().iDisplaySizeInPixels.iWidth;
    355  1.1  kiyohara 	video->height = MachInfo().iDisplaySizeInPixels.iHeight;
    356  1.1  kiyohara 	common = &(video + 1)->common;
    357  1.1  kiyohara 
    358  1.1  kiyohara 	/* Set memory size to bootinfo. */
    359  1.1  kiyohara 	memsize = MemInfo().iTotalRamInBytes / 1024;
    360  1.1  kiyohara 	for (i = 0; i < sizeof(memmaps) / sizeof(memmaps[0]); i++) {
    361  1.1  kiyohara 		if (_L(memmaps[i].model).CompareF(_L(model->model)) == 0 &&
    362  1.1  kiyohara 		    memmaps[i].width == video->width &&
    363  1.1  kiyohara 		    memmaps[i].height == video->height &&
    364  1.1  kiyohara 		    memmaps[i].memsize == memsize) {
    365  1.1  kiyohara 			memmap = memmaps[i].memmaps;
    366  1.1  kiyohara 			while (memsize > 0) {
    367  1.1  kiyohara 				common->len = sizeof(struct btinfo_memory);
    368  1.1  kiyohara 				common->type = BTINFO_MEMORY;
    369  1.1  kiyohara 				memory = (struct btinfo_memory *)common;
    370  1.1  kiyohara 				memory->address = memmap->address;
    371  1.1  kiyohara 				memory->size = memmap->size KB;
    372  1.1  kiyohara 				common = &(memory + 1)->common;
    373  1.1  kiyohara 				memsize -= memmap->size;
    374  1.1  kiyohara 				memmap++;
    375  1.1  kiyohara 			}
    376  1.1  kiyohara 			break;
    377  1.1  kiyohara 		}
    378  1.1  kiyohara 	}
    379  1.1  kiyohara 	if (i == sizeof(memmaps) / sizeof(memmaps[0])) {
    380  1.1  kiyohara 		common->len = sizeof(struct btinfo_memory);
    381  1.1  kiyohara 		common->type = BTINFO_MEMORY;
    382  1.1  kiyohara 		memory = (struct btinfo_memory *)common;
    383  1.1  kiyohara 		memory->address = 0xc0000000;		/* default is here */
    384  1.1  kiyohara 		memory->size = 4096 KB;			/* XXXXX */
    385  1.1  kiyohara 		common = &(memory + 1)->common;
    386  1.1  kiyohara 	}
    387  1.1  kiyohara 
    388  1.2  kiyohara 	common->len = sizeof(struct btinfo_bootargs);
    389  1.2  kiyohara 	common->type = BTINFO_BOOTARGS;
    390  1.2  kiyohara 	bootargs = (struct btinfo_bootargs *)common;
    391  1.2  kiyohara 	bootargs->bootargs[0] = '\0';
    392  1.2  kiyohara 	common = &(bootargs + 1)->common;
    393  1.2  kiyohara 
    394  1.1  kiyohara 	common->len = 0;
    395  1.1  kiyohara 	common->type = BTINFO_NONE;
    396  1.1  kiyohara 
    397  1.1  kiyohara 	/* Terminate bootinfo. */
    398  1.1  kiyohara 	return bootinfo;
    399  1.1  kiyohara }
    400  1.1  kiyohara 
    401  1.1  kiyohara #undef KB
    402  1.1  kiyohara 
    403  1.1  kiyohara LOCAL_C struct btinfo_common *
    404  1.1  kiyohara FindBootInfoL(struct btinfo_common *bootinfo, int type)
    405  1.1  kiyohara {
    406  1.1  kiyohara 	struct btinfo_common *entry;
    407  1.1  kiyohara 
    408  1.1  kiyohara 	entry = bootinfo;
    409  1.1  kiyohara 	while (entry->type != BTINFO_NONE) {
    410  1.1  kiyohara 		if (entry->type == type)
    411  1.1  kiyohara 			return entry;
    412  1.1  kiyohara 		entry = (struct btinfo_common *)((int)entry + entry->len);
    413  1.1  kiyohara 	}
    414  1.1  kiyohara 	User::Leave(KErrNotFound);
    415  1.1  kiyohara 
    416  1.1  kiyohara 	/* NOTREACHED */
    417  1.1  kiyohara 
    418  1.1  kiyohara 	return NULL;
    419  1.1  kiyohara }
    420  1.1  kiyohara 
    421  1.1  kiyohara TUint
    422  1.1  kiyohara SummaryBootInfoMemory(struct btinfo_common *bootinfo)
    423  1.1  kiyohara {
    424  1.1  kiyohara 	struct btinfo_common *entry;
    425  1.1  kiyohara 	struct btinfo_memory *memory;
    426  1.1  kiyohara 	TUint memsize = 0;
    427  1.1  kiyohara 
    428  1.1  kiyohara 	entry = bootinfo;
    429  1.1  kiyohara 	while (entry->type != BTINFO_NONE) {
    430  1.1  kiyohara 		if (entry->type == BTINFO_MEMORY) {
    431  1.1  kiyohara 			memory = (struct btinfo_memory *)entry;
    432  1.1  kiyohara 			memsize += memory->size;
    433  1.1  kiyohara 		}
    434  1.1  kiyohara 		entry = (struct btinfo_common *)((int)entry + entry->len);
    435  1.1  kiyohara 	}
    436  1.1  kiyohara 	return memsize;
    437  1.1  kiyohara }
    438