brdbootldr/ubootldr/inc/bootldr.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1996-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 // bootldr\inc\bootldr.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef FILE_ID
       
    19 #error File ID not specified
       
    20 #endif
       
    21 
       
    22 #include "bootloader_variantconfig.h"
       
    23 
       
    24 #define BOOTLDR_VERSION_MAJOR 1
       
    25 #define BOOTLDR_VERSION_MINOR 11
       
    26 
       
    27 #ifndef PLATFORM_BUILD
       
    28 #define PLATFORM_BUILD 0
       
    29 #endif
       
    30 
       
    31 #include <e32std.h>
       
    32 #include <e32svr.h>
       
    33 #include <e32cons.h>
       
    34 #include <f32file.h>
       
    35 #include <d32comm.h>
       
    36 
       
    37 GLREF_C void BootFault(TUint aId, TInt aLine, char aFileName[]);
       
    38 #define BOOT_FAULT()	BootFault(FILE_ID,__LINE__, __FILE__ )
       
    39 #define TEST(c)		((void)((c)||(BOOT_FAULT(),0)))
       
    40 #define CHECK(c)	((void)(((c)==0)||(RDebug::Print(_L("Error %d at line %d\n"),(c),__LINE__),BOOT_FAULT(),0)))
       
    41 
       
    42 //#define _DEBUG_CORELDR_  1
       
    43 
       
    44 #ifdef _DEBUG_CORELDR_        
       
    45     #define DEBUG_PRINT(m) PrintToScreen m;	\
       
    46                            RDebug::Print m;
       
    47 #else
       
    48     #define DEBUG_PRINT(m)
       
    49 #endif    
       
    50 
       
    51 #define TROM_LOADER_HEADER_SIZE 0x100
       
    52 
       
    53 GLREF_D TInt LoadDrive;
       
    54 GLREF_D TInt LoadFile;
       
    55 GLREF_D TInt LoadSize;
       
    56 GLREF_D TInt ImageSize;
       
    57 GLREF_D TInt ImageReadProgress;
       
    58 GLREF_D TBool ImageHeaderPresent;
       
    59 GLREF_D TBool ImageZip;
       
    60 GLREF_D TBool LoadToFlash;
       
    61 GLREF_D TBool FlashBootLoader;
       
    62 GLREF_D TBuf<256> FileName;
       
    63 GLREF_D TUint32 RamBootPhys;
       
    64 GLREF_D TUint32 * ActualDestinationAddress;
       
    65 GLREF_D TInt SerialDownloadPort;
       
    66 GLREF_D TBps SerialBaud;
       
    67 GLREF_D RFile bootFile;
       
    68 GLREF_D TInt FileSize;
       
    69 GLREF_D TBool ImageDeflated;
       
    70 GLREF_D TBool RomLoaderHeaderExists;
       
    71 GLREF_D TBusLocalDrive LocDrv;
       
    72 GLREF_D TBool LocDrvChg;
       
    73 GLREF_D TInt64 LocDrvPos;
       
    74 
       
    75 enum TLoadDevice
       
    76 	{
       
    77 	ELoadDrive,
       
    78 	ELoadSerial,
       
    79 	ELoadUSBMS,
       
    80 	EBootUSBMS,
       
    81 	EBootEMMC
       
    82 	};
       
    83 
       
    84 GLREF_D TLoadDevice LoadDevice;
       
    85 
       
    86 typedef TInt (*TInputFunc)(TUint8* aDest, TInt& aLength);
       
    87 GLREF_D TInputFunc InputFunction;
       
    88 
       
    89 typedef void (*TCloseInputFunc)();
       
    90 GLREF_D TCloseInputFunc CloseInputFunction;
       
    91 
       
    92 inline TInt ReadInputData(TUint8* aDest, TInt& aLength)
       
    93 	{ return (*InputFunction)(aDest,aLength); }
       
    94 inline void CloseInput()
       
    95 	{ (*CloseInputFunction)(); }
       
    96 
       
    97 
       
    98 GLREF_C TInt LoadDriver(const TDesC& aName, TBool aPdd);
       
    99 
       
   100 // Graphical screen methods
       
   101 GLREF_C void PrintToScreen(TRefByValue<const TDesC> aFmt,...);
       
   102 GLREF_C void InitDisplay();
       
   103 GLREF_C void ClearScreen();
       
   104 GLREF_C void PutChar(TUint aChar);
       
   105 GLREF_C void PutString(const TDesC& aBuf);
       
   106 GLREF_C void InitProgressBar(TInt aId, TUint aLimit, const TDesC& aTitle);
       
   107 GLREF_C void UpdateProgressBar(TInt aId, TUint aProgress);
       
   108 
       
   109 // Menu
       
   110 GLREF_C void StartMenu();
       
   111 GLREF_C void EnableMenu();
       
   112 GLREF_C void DisableMenu();
       
   113 
       
   114 // Fundamental download methods
       
   115 GLREF_C void DoDownload();
       
   116 GLREF_C TInt DoZipDownload(RFile &aBootFile);
       
   117 GLREF_C TInt DoDeflateDownload();
       
   118 GLREF_C void Restart(TInt aCode);
       
   119 
       
   120 // Media download
       
   121 GLREF_C TBool SearchDrives();
       
   122 GLREF_C TInt ReadFromFile(TUint8* aDest, TInt& aLength);
       
   123 GLREF_C void CloseFile();
       
   124 GLREF_C TInt GetInnerCompression(TBool &aImageDeflated, TBool &aRomLoaderHeaderExists);
       
   125 
       
   126 // Local Drive Raw Access
       
   127 GLREF_C TBool SearchDrivesRaw();
       
   128 GLREF_C TInt ReadFromLocalDrive(TUint8* aDest, TInt& aLength);
       
   129 GLREF_C void CloseLocalDrive();
       
   130 
       
   131 // Serial download
       
   132 GLREF_C TInt InitSerialDownload(TInt aPort);
       
   133 
       
   134 // NOR FLASH methods
       
   135 GLREF_C TInt InitFlashWrite();
       
   136 GLREF_C void NotifyDataAvailable(TInt aTotalAmount);
       
   137 GLREF_C void NotifyDownloadComplete();
       
   138 
       
   139 // USB Mass Storage download
       
   140 GLREF_C void TryUSBMS();
       
   141 GLREF_C TBool StartUSBMS();
       
   142 
       
   143 // Variant supplied methods
       
   144 GLREF_C void VariantInit();
       
   145 GLREF_C void ReadConfig();
       
   146 GLREF_C void WriteConfig();
       
   147 
       
   148 inline TLinAddr DestinationAddress()
       
   149 	{ return (TLinAddr)ActualDestinationAddress; }
       
   150