0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// invoke the USB mass storage application
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include <e32const.h>
|
|
23 |
#include <e32const_private.h>
|
|
24 |
#include <e32std.h>
|
|
25 |
#include <e32std_private.h>
|
|
26 |
#include <e32svr.h>
|
|
27 |
#include <e32cons.h>
|
|
28 |
#include <f32file.h>
|
|
29 |
#include <hal.h>
|
|
30 |
#include <u32hal.h>
|
|
31 |
#include "bootloader_variantconfig.h"
|
|
32 |
#include <nkern/nk_trace.h>
|
|
33 |
#include <e32twin.h>
|
|
34 |
|
|
35 |
#define FILE_ID 0x594D555D
|
|
36 |
#include "bootldr.h"
|
|
37 |
|
|
38 |
GLDEF_C TBool StartUSBMS()
|
|
39 |
{
|
|
40 |
RFs fs;
|
|
41 |
TInt r = fs.Connect();
|
|
42 |
if (r != KErrNone)
|
|
43 |
{
|
|
44 |
// BOOTFAULT
|
|
45 |
RDebug::Print(_L("FAULT: Connecting RFs returned %d\r\n"), r);
|
|
46 |
BOOT_FAULT();
|
|
47 |
}
|
|
48 |
|
|
49 |
TInt drive;
|
|
50 |
RFs::CharToDrive('D', drive); // XXX variant constant drivepath
|
|
51 |
|
|
52 |
TDriveInfo info;
|
|
53 |
r = fs.Drive(info, drive);
|
|
54 |
if (r != KErrNone)
|
|
55 |
{
|
|
56 |
// BOOTFAULT
|
|
57 |
RDebug::Print(_L("FAULT: Calling Drive() on RFs returned %d\r\n"), r);
|
|
58 |
BOOT_FAULT();
|
|
59 |
}
|
|
60 |
|
|
61 |
if (info.iType == EMediaNotPresent)
|
|
62 |
{
|
|
63 |
return EFalse;
|
|
64 |
}
|
|
65 |
|
|
66 |
LoadDevice = ELoadUSBMS;
|
|
67 |
WriteConfig();
|
|
68 |
|
|
69 |
RProcess proc;
|
|
70 |
TName command = _L("D");
|
|
71 |
r = proc.Create(_L("z:\\sys\\bin\\usbboot.exe"), command);
|
|
72 |
if (r != KErrNone)
|
|
73 |
{
|
|
74 |
// BOOTFAULT
|
|
75 |
RDebug::Print(_L("FAULT: error starting usbboot %d\r\n"), r);
|
|
76 |
BOOT_FAULT();
|
|
77 |
}
|
|
78 |
proc.Resume();
|
|
79 |
return ETrue;
|
|
80 |
}
|
|
81 |
|
|
82 |
GLDEF_C void TryUSBMS()
|
|
83 |
{
|
|
84 |
// Check first whether this boot is intended to load and boot an image from
|
|
85 |
// the media.
|
|
86 |
if (LoadDevice == EBootUSBMS)
|
|
87 |
{
|
|
88 |
PrintToScreen(_L("USB-MS boot scanning drives\r\n"));
|
|
89 |
// search drives for file - returns true if an image has been found
|
|
90 |
if (SearchDrives())
|
|
91 |
DoDownload();
|
|
92 |
}
|
|
93 |
|
|
94 |
PrintToScreen(_L("Starting USB Mass Storage\r\n"));
|
|
95 |
DisableMenu();
|
|
96 |
if(StartUSBMS())
|
|
97 |
{
|
|
98 |
// USB Mass Storage boot has started - don't continue with the
|
|
99 |
// bootloader, sleep here.
|
|
100 |
while(1)
|
|
101 |
User::After(10000000);
|
|
102 |
}
|
|
103 |
else
|
|
104 |
{
|
|
105 |
EnableMenu();
|
|
106 |
// Not started (probably no card in drive) revert to normal bootloader
|
|
107 |
// mode and notify the variant to rewrite it's configuration.
|
|
108 |
PrintToScreen(_L("NO VALID MEDIA\r\n"));
|
|
109 |
PrintToScreen(_L("Leaving USB Mass Storage mode\r\n"));
|
|
110 |
LoadDevice = ELoadDrive;
|
|
111 |
WriteConfig();
|
|
112 |
}
|
|
113 |
|
|
114 |
return;
|
|
115 |
}
|