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