/*******************************************************************************
* Copyright (C) ST-Ericsson SA 2011
* License terms: 3-clause BSD license
******************************************************************************/
#ifndef _LCDRIVER_H_
#define _LCDRIVER_H_
#if defined(_WIN32)
#ifdef LCDRIVER_EXPORTS
#define LCDRIVER_API __declspec(dllexport)
#else
#define LCDRIVER_API __declspec(dllimport)
#endif //LCDRIVER_EXPORTS
#ifndef __int64
#define __int64 long long
#endif
typedef unsigned __int64 uint64;
typedef unsigned long uint32;
#elif (defined(__linux__) || defined(__APPLE__))
#ifdef LCDRIVER_EXPORTS
#define LCDRIVER_API __attribute__((visibility("default")))
#else
#define LCDRIVER_API
#endif
typedef unsigned long long uint64;
typedef unsigned int uint32;
#define __cdecl
#else
#error "Unknown platform"
#endif
typedef struct CLCDriverInterface *LCDContext;
///
/// Command information.
///
/// Command group number.
/// Command number.
/// Permition level.
typedef struct {
int iGroup;
int iCommand;
int iPermitted;
} TSupportedCmd;
///
/// Description of ME device.
///
/// Absolute device path pointing at the described device.
/// Size of pchPath.
/// Type of device.
/// Size of pchType.
/// Size of the smallest addressable unit in the device [Byte].
/// Offset [Byte] of the start of the device relative its parent's
/// offset 0 with granularity of its parent's block size.
/// Length of the device [Byte].
typedef struct {
const char *pchPath;
int iPathSize;
const char *pchType;
int iTypeSize;
uint64 uiBlockSize;
uint64 uiStart;
uint64 uiLength;
} TDevices;
///
/// Description of filesystem file or directory in ME.
///
/// Name of file or directory.
/// Size of pchName.
/// Size of file or directory.
/// Indicator of file or directory.
/// Time of last modification.
typedef struct {
const char *pchName;
int iNameSize;
uint64 uiSize;
int iMode;
int iTime;
} TEntries;
///
/// 12 SIM lock/unlock keys.
///
/// NLCKLock key.
/// NSLCKLock key.
/// SPLCKLock key.
/// CLCKLock key.
/// PCKLock key.
/// ESLCKLock key.
/// NLCKUnLock key.
/// NSLCKUnLock key.
/// SPLCKUnLock key.
/// CLCKUnLock key.
/// PCKUnLock key.
/// ESLCKUnLock key.
typedef struct {
char *pchNLCKLock;
char *pchNSLCKLock;
char *pchSPLCKLock;
char *pchCLCKLock;
char *pchPCKLock;
char *pchESLCKLock;
char *pchNLCKUnLock;
char *pchNSLCKUnLock;
char *pchSPLCKUnLock;
char *pchCLCKUnLock;
char *pchPCKUnLock;
char *pchESLCKUnLock;
} TSIMLockKeys;
///
/// LCDriver time out.
///
/// Startup TimeOut.
/// Response TimeOut.
typedef struct {
uint32 uiSTO;
uint32 uiRTO;
} TLCDriverTimeouts;
///
/// R15 protocol time out.
///
/// Time for command packet acknowledge.
/// Time for bulk command packet to be recieved.
/// Time for bulk session end. NOTE: Starting from version R1J this timeout is not
///used in LCM but it stays in LCDriver interface to avoid interface changes.
/// Time for bulk data packet to be received.
typedef struct {
uint32 TCACK;
uint32 TBCR;
uint32 TBES;
uint32 TBDR;
} TR15Timeouts;
///
/// Protocol family.
///
typedef enum {
/// R15 protocol family.
R15_PROTOCOL_FAMILY = 0,
/// A2 protocol family.
A2_PROTOCOL_FAMILY = 1,
/// PROTROM protocol family.
PROTROM_PROTOCOL_FAMILY = 3,
/// Z protocol family.
Z_PROTOCOL_FAMILY = 4
} TFamily;
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
///
/// Initializes new instance of the LCD context.
///
/// Deprecated.
/// Instead of this function please use: SetLCMLibPath, CreateContext, SwitchProtocolFamily, ConfigureCommunicationDevice,
/// SetMessageCallback, SetProgressCallback and StartContext. These new functions give separation between creation,
/// configuration and startup of the context.
///
/// A pointer to a LCDContext where to store the newly created context or to put
/// the previously created context if the context with the specified interface id already exists.
/// A zero terminated string containing the interface unique ID.
/// A pointer to a communication device read function.
/// A pointer to a communication device write function.
/// A pointer to a communication device cancel function.
/// A pointer to a pointer where to store the adress of the loader communication module instance.
/// A pointer to a message logging function.
/// A zero terminated string containing the path to the LCM library.
/// A pointer to function which receives the progress updates.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl Initialize(LCDContext *pContext, const char *InterfaceId, void *Read_fn, void *Write_fn, void *Cancel_fn, void **Instance, void *Message_fn, const char *LCMLibPath, void *ProgressBar_fn);
///
/// Closes the LCD context.
///
/// Deprecated.
/// Instead of this function please use DestroyContext which properly sets the LCD context to NULL to avoid further usage
/// of the destroyed context.
///
/// LCD context on which to execute the operation.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl Close(LCDContext Context);
///
/// Sets the global LCM library path.
///
/// A zero terminated string containing the path to the LCM library.
LCDRIVER_API void __cdecl SetLCMLibPath(const char *LCMLibPath);
///
/// Creates new LCD context with the specified interface ID.
///
/// A pointer to a LCDContext where to store the newly created context or to put
/// the previously created context if the context with the specified interface id already exists.
/// A zero terminated string containing the interface unique ID.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl CreateContext(LCDContext *pContext, const char *InterfaceId);
///
/// Sets the initial family of not started context, or switches the protocol family of started context.
///
/// LCD context on which to execute the operation.
/// New family to be set.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl SwitchProtocolFamily(LCDContext Context, TFamily Family);
///
/// Configures the communication device to be used for the context.
///
/// LCD context on which to execute the operation.
/// A pointer to a communication device read function.
/// A pointer to a communication device write function.
/// A pointer to a communication device cancel function.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl ConfigureCommunicationDevice(LCDContext Context, void *Read_fn, void *Write_fn, void *Cancel_fn);
///
/// Sets the callback for message logging.
///
/// LCD context on which to execute the operation.
/// A pointer to a message logging function.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl SetMessageCallback(LCDContext Context, void *Callback_fn);
///
/// Sets the callback for progress updates.
///
/// LCD context on which to execute the operation.
/// A pointer to function which receives the progress updates.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl SetProgressCallback(LCDContext Context, void *Callback_fn);
///
/// Starts the context. Should be called after the required parameters are previously configured.
///
/// LCD context on which to execute the operation.
/// A pointer to a pointer where to store the address of the started communication instance.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl StartContext(LCDContext Context, void **Instance);
///
/// Destroys the context. Should be called last after we are finished with the context.
///
/// Pointer to LCDContext on which to execute the operation.
/// LCDContext is set to NULL after this function is called.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl DestroyContext(LCDContext *pContext);
///
/// Sets the LCD and R15 protocol timeouts.
///
/// LCD context on which to execute the operation.
/// Pointer to TR15Timeouts structure.
/// Pointer to TLCDriverTimeouts structure.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl SetTimeouts(LCDContext Context, TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs);
///
/// Gets the LCD and R15 protocol timeouts.
///
/// LCD context on which to execute the operation.
/// Pointer to TR15Timeouts structure.
/// Pointer to TLCDriverTimeouts structure.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl GetTimeouts(LCDContext Context, TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs);
///
/// Cancels the currently executing command.
///
/// LCD context on which to execute the operation.
/// 0 if OK, otherwise non-zero.
LCDRIVER_API int __cdecl CancelCurrentLoaderCommand(LCDContext Context);
///
/// The Loader Start-up Status command is sent by the ME to notify the host that it has started. The Status parameter indicates in what mode the loader started.
///
/// LCD context on which to execute the operation.
/// Loader version identifier.
/// Number of allocated bytes for version string.
/// Protocol version identifier.
/// Number of allocated bytes for protocol string.
/// Status of the command.
LCDRIVER_API int __cdecl System_LoaderStartupStatus(LCDContext Context, char *pchVersion, int *piVersionSize, char *pchProtocol, int *piProtocolSize);
///
/// The ChangeBaudrate command is used to instruct the loader to change the UART baud rate.
/// The ME does not return GeneralResponse to this command. It changes to new BaudRate
/// and expects the further communication over UART to be realized using the new BaudRate.
///
/// LCD context on which to execute the operation.
/// Indicates the new UART baud rate.
/// Status of the command.
LCDRIVER_API int __cdecl System_ChangeBaudrate(LCDContext Context, int iBaudRate);
///
/// The Reboot command is used to instruct the loader to reset the ME. Upon receiving this command,
/// the loader shuts down in a controlled fashion and restarts the ME. The Mode parameter is used to
/// select the mode of reset. The ME does not accept any further communication after a successful
/// response from this command has been returned.
///
/// LCD context on which to execute the operation.
/// Indicates the mode of reset:
/// 0: indicates normal restart.
/// 1: indicates restart in service mode.
/// 2: indicates restart with JTAG debugging enabled.
/// 3: indicates restart in service mode and with JTAG debugging enabled.
///
/// Status of the command.
LCDRIVER_API int __cdecl System_Reboot(LCDContext Context, int iMode);
///
/// The loader shuts down in a controlled fashion and proceeds to shut down the ME itself.
/// The ME does not accept any further communication after a successful response from this
/// command has been returned.
///
/// LCD context on which to execute the operation.
/// Status of the command.
LCDRIVER_API int __cdecl System_Shutdown(LCDContext Context);
///
/// The loader returns a list of implemented commands and whether they are permitted to
/// execute in the current loader state.
///
/// LCD context on which to execute the operation.
/// A list with supported commands.
/// Number of commands in CmdList.
/// Status of the command.
LCDRIVER_API int __cdecl System_SupportedCommands(LCDContext Context, TSupportedCmd *pCmdList, int *piCmdListSize);
///
/// This command is used by the loader to extract debug, measurement or flashing status data.
///
/// LCD context on which to execute the operation.
/// Type of data to be extracted.
/// Size of the collected data buffer.
/// Buffer to hold the collected data.
/// Status of the command.
LCDRIVER_API int __cdecl System_CollectData(LCDContext Context, int iType, int *piSize, char *pData);
///
/// Receive, verify and execute software, which can be a signed loader.
/// After having sent this command, the ME attempts to read the software
/// payload data from the host using the Bulk protocol or from the flash
/// file system depending on the selected path. The current loader does not
/// respond to communication after this command has been successfully executed.
/// If the executed software is another loader, communication can be resumed once the
/// Loader Started command has been received. A response of E_OPERATION_CANCELLED
/// indicates the operation was canceled.
///
/// LCD context on which to execute the operation.
/// Execute mode: 1 = execution from specified address, 2 = first load the software then execute.
/// Target path. If use bulk the path is on PC, else on ME.
/// If value = 1 -> source on PC, else source on ME.
/// Status of the command.
LCDRIVER_API int __cdecl System_ExecuteSoftware(LCDContext Context, const uint32 ExecuteMode, const char *pchDevicePath, int iUseBulk);
///
/// This command is used to escalate the privileges of the operator. Two ways of
/// authentication are available by default; control key authentication and certificate based
/// authentication. The authentication command sets the loader in a specific
/// authentication context when it takes control over the command flow. After
/// receiving the authentication command, the loader sends the appropriate request for information to the PC.
///
/// LCD context on which to execute the operation.
/// Authentication type:0 = control key authentication,1 = certificate authentication.
/// Size of puchData.
/// Data challenge.
/// Status of the command.
LCDRIVER_API int __cdecl System_Authenticate(LCDContext Context, int iType, int *piSize, unsigned char *puchdata);
///
/// This command deauthenticates the ME from prior
/// authentications to prevent unauthorized access.
///
/// Deauthentication type:0 = deauthenticate until next reboot of the ME,1 = permanent deauthentication.
/// Status of the command.
LCDRIVER_API int __cdecl System_Deauthenticate(LCDContext Context, int iType);
///
/// This command is used by the loader to retrieve the SimLock control keys from the host to authenticate a user.
/// The command is used in the authentication context.
///
/// LCD context on which to execute the operation.
/// A struct with all lock/unlock keys.
/// Status of the command.
LCDRIVER_API int __cdecl System_GetControlKeys(LCDContext Context, TSIMLockKeys *pSIMLockKeys);
///
/// This command is used by the loader to retrieve the SimLock control keys data from the host to authenticate a user.
/// The command is used in the authentication context.
///
/// LCD context on which to execute the operation.
/// SIMLockKeyData buffer that contain all SIMLock keys.
/// SIMLockKeyData buffer size.
/// Status of the command.
LCDRIVER_API int __cdecl System_GetControlKeysData(LCDContext Context, int iDataSize, unsigned char *pSIMLockKeysData);
///
/// This command is used by the loader to perform a certificate authentication.
/// The command is only used in the authentication context.
///
/// LCD context on which to execute the operation.
/// Authentication challenge. This challenge must be signed
/// using the correct certificate and returned to the loader.
/// Authentication challenge buffer length.
/// Status of the command.
LCDRIVER_API int __cdecl System_AuthenticationChallenge(LCDContext Context, unsigned char *puchChallengeData, int iDataSize);
///
/// The Set System Time command is used to set the current epoch time for loader
/// to configure the real time clock and use it for file system operations.
///
/// LCD context on which to execute the operation.
/// Number of seconds that have elapsed since January 1, 1970
/// Status of the command.
LCDRIVER_API int __cdecl System_SetSystemTime(LCDContext Context, uint32 uiEpochTime);
///
/// This command is used to instruct the Loader to switch to a new communication device.
///
/// Device ID of the communication device to switch to.
/// Communication device parameters.
/// Status of the command.
LCDRIVER_API int __cdecl System_SwitchCommunicationDevice(LCDContext Context, uint32 uiDevice, uint32 uiDeviceParam);
///
/// The Loader shuts down the global communication and enters in a Relay working mode.
///
/// Communication device number of the relay input (host device).
/// Communication device number of the relay output (target device).
/// Communication device number for the loader commands (control device).
/// Status of the command.
LCDRIVER_API int __cdecl System_StartCommRelay(LCDContext Context, uint32 HostDeviceId, uint32 TargetDeviceId, uint32 ControlDeviceId);
///
/// This command is used to initiate a flashing session. The type argument is
/// used to select the type of file to process and Length parameter
/// defines the total size of the file.
///
/// LCD context on which to execute the operation.
/// Target path. If iUseBulk = 1, path is on PC.
/// Type of the opened file.
/// If to use bulk protocol. If target is on PC iUseBulk shall be 1.
/// Specify if to delete bulk buffers after finish. 1 -> delete buffers. 0 -> don't delete buffers.
/// Status of the command.
LCDRIVER_API int __cdecl Flash_ProcessFile(LCDContext Context, const char *pchPath, const char *pchType, int iUseBulk, int iDeleteBuffers);
///
/// This command is used by the client application program to obtain the device tree.
///
/// LCD context on which to execute the operation.
/// A struct with information about one flash device.
/// Number of flash devices, size of pDevices array.
/// Status of the command.
LCDRIVER_API int __cdecl Flash_ListDevices(LCDContext Context, TDevices *pDevices, int *piDeviceSize);
///
/// This command is used to initiate a dump session.
///
/// LCD context on which to execute the operation.
/// Path to the device to dump.
/// Start of the dump relative to the start of the device indicated by Path [Byte].
/// Length of the dump [Byte]. Actual length is determined by the device block size.
/// File path on PC to store dump data to.
/// 0-> dump with redundant data, 1-> dump without redundant data.
/// 1-> save dump data on PC, 0-> save dump data on ME.
/// Status of the command.
LCDRIVER_API int __cdecl Flash_DumpArea(LCDContext Context, const char *pchPathToDump, uint64 uiStart, uint64 uiLength, const char *pchFilePath, uint32 uiRedundantArea, int iUseBulk);
///
/// This command is used to erase a flash device or part of a flash device.
///
/// LCD context on which to execute the operation.
/// Path to the device to erase.
/// Start of the erase relative to the start of the device
/// indicated by path [Byte]. This must be a multiple of the block size of the device.
/// Length of the dump [Byte]. This must be a multiple of the block size of the device.
/// Status of the command.
LCDRIVER_API int __cdecl Flash_EraseArea(LCDContext Context, const char *pchPath, uint64 uiStart, uint64 uiLength);
///
/// This command is used to initiate a flashing of raw data.
///
/// LCD context on which to execute the operation.
/// Target path. If iUseBulk = 1, path is on PC.
/// Address where flashing should start.
/// Length of data to be flashed.
/// Device ID number.
/// If to use bulk protocol. If target is on PC iUseBulk shall be 1.
/// Specify if to delete bulk buffers after finish. 1 -> delete buffers. 0 -> don't delete buffers.
/// Status of the command.
LCDRIVER_API int __cdecl Flash_FlashRaw(LCDContext Context, const char *pchPath, uint64 uiStart, uint64 uiLength, uint32 uiDevice, int iUseBulk, int iDeleteBuffers);
///
/// This command is used to set enhanced area in eMMC.
///
/// LCD context on which to execute the operation.
/// Path to the device where area should be set.
/// Start of enhanced area [Byte].
/// Length of enhanced area [Byte].
/// Status of the command.
LCDRIVER_API int __cdecl Flash_SetEnhancedArea(LCDContext Context, const char *pchPathToDump, uint64 uiStart, uint64 uiLength);
///
/// This command retrieves the properties of the specified file system volume. It is issued by the PC application.
///
/// LCD context on which to execute the operation.
/// Path of file system volume.
/// File system type.
/// Size of pchFSType array.
/// Total size of the file system [Byte].
/// Available space [Byte].
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_VolumeProperties(LCDContext Context, const char *pchDevicePath, char *pchFSType, int *piFSTypeSize, uint64 *puiSize, uint64 *puiFree);
///
/// Formats unused file system volume specified in device path. This operation fails if the volume is currently in use.
///
/// LCD context on which to execute the operation.
/// Device path of the file system volume.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_FormatVolume(LCDContext Context, const char *pchDevicePath);
///
/// List files and directories residing in specified path.
///
/// LCD context on which to execute the operation.
/// File system path.
/// Struct with file and directory information.
/// Number of files or directories, number of element in pEntries array.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_ListDirectory(LCDContext Context, const char *pchPath, TEntries *pEntries, int *piDeviceSize);
///
/// This command moves a file from the source path to the destination path if the source and destination differ.
/// It also renames a file if the source path and the destination path are the same.
///
/// LCD context on which to execute the operation.
/// File system path in ME to source.
/// File system path in ME to destination.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_MoveFile(LCDContext Context, const char *pchSourcePath, const char *pchDestinationPath);
///
/// Delete the specified file or directory. The loader only deletes empty directories.
///
/// LCD context on which to execute the operation.
/// File system path in ME.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_DeleteFile(LCDContext Context, const char *pchTargetPath);
///
/// This command is used to do the following: Copy a file from the PC to the ME. Copy a file between two directories or file systems on the ME.
/// Copy a file from the ME to the PC.
///
/// LCD context on which to execute the operation.
/// If iSourceUseBulk = 1 -> path on PC, else path on ME.
/// If = 1 -> source on PC, else source on ME.
/// If iDestinationUseBulk = 1 -> path on PC, else path on ME.
/// If = 1 -> destination on PC, else destination on ME.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_CopyFile(LCDContext Context, const char *pchSourcePath, int iSourceUseBulk, const char *pchDestinationPath, int iDestinationUseBulk);
///
/// This command is used to create a directory. It is issued by the PC application.
///
/// LCD context on which to execute the operation.
/// File system path to target.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_CreateDirectory(LCDContext Context, const char *pchTargetPath);
///
/// This command is used to retrieve the properties of a file or directory.
///
/// LCD context on which to execute the operation.
/// File system path to target.
/// File type and access restrictions descriptor.
/// File size [Byte].
/// Last modification timestamp.
/// Last access timestamp.
/// Creation timestamp.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_Properties(LCDContext Context, const char *pchTargetPath, uint32 *puiMode, uint64 *puiSize, int *piMTime, int *piATime, int *piCTime);
///
/// This command is used to change the access permissions of a specified path.
///
/// LCD context on which to execute the operation.
/// File system path to target.
/// New access permissions.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_ChangeAccess(LCDContext Context, const char *pchTargetPath, int iAccess);
///
/// This command is used to read manifests contained in load modules at the specified path and send the data back over bulk protocol.
///
/// LCD context on which to execute the operation.
/// Path on PC to save manifest.
/// Load module(s) file system path.
/// Status of the command.
LCDRIVER_API int __cdecl FileSystem_ReadLoadModuleManifests(LCDContext Context, const char *pchTargetPath, const char *pchSourcePath);
///
/// This command is used to read the specified bits from the OTP.
///
/// LCD context on which to execute the operation.
/// OTP area ID.
/// Starting offset [bit].
/// Length of read [bit].
/// Received OTP data.
/// Size of puchDataBuffer.
/// Lock status for each read bit.
/// Size of puchStatusBuffer.
/// Status of the command.
LCDRIVER_API int __cdecl OTP_ReadBits(LCDContext Context, int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer, int *piDataBufferSize, unsigned char *puchStatusBuffer, int *piStatusBufferSize);
///
/// This command stores the specified bits in the loader internal OTP structures in RAM, it does not write to OTP.
///
/// LCD context on which to execute the operation.
/// OTP area ID.
/// Starting offset [bit].
/// Length of write [bit].
/// OTP data to write.
/// Status of the command.
LCDRIVER_API int __cdecl OTP_SetBits(LCDContext Context, int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer);
///
/// This command writes (burns) all data from loader internal OTP structures in RAM into the OTP fuse box.
///
/// LCD context on which to execute the operation.
/// OTP area ID.
/// If true: write and lock all lockable areas even if not all bits are received in cache.
/// Status of the command.
LCDRIVER_API int __cdecl OTP_WriteAndLock(LCDContext Context, int iOtpId, int iForceWrite);
///
/// Reads a specified unit from the global data storage area/partition specified by the DevicePath parameter.
///
/// LCD context on which to execute the operation.
/// GDFS ID.
/// Unit ID to read.
/// Received global data.
/// Size of puchDataBuffer.
/// Status of the command.
LCDRIVER_API int __cdecl ParameterStorage_ReadGlobalDataUnit(LCDContext Context, const char *pchGdfsId, int iUnit, unsigned char *puchDataBuffer, int *piSize);
///
/// Writes a specified unit to the global data storage area/partition specified by the pchGdfsId parameter.
///
/// LCD context on which to execute the operation.
/// GDFS ID.
/// Unit ID to write.
/// Global data to write.
/// Size of puchDataBuffer.
/// Status of the command.
LCDRIVER_API int __cdecl ParameterStorage_WriteGlobalDataUnit(LCDContext Context, const char *pchGdfsId, int iUnit, unsigned char *puchDataBuffer, int iSize);
///
/// Reads the complete global data storage area/partition specified by the pchGdfsId parameter (reads all units at once).
///
/// LCD context on which to execute the operation.
/// GDFS ID.
/// If iUseBulk=1 -> path on PC to save data set to. Else path on ME.
/// 1-> save global data on PC, 0-> save global data on ME.
/// Status of the command.
LCDRIVER_API int __cdecl ParameterStorage_ReadGlobalDataSet(LCDContext Context, const char *pchGdfsId, const char *pchPath, int iUseBulk);
///
/// Writes the complete global data storage area/partition specified by the pchGdfsId parameter (writes all units at once).
///
/// LCD context on which to execute the operation.
/// GDFS ID.
/// If iUseBulk=1 -> path on PC. Else path on ME
/// 1-> global data source on PC, 0-> global data source on ME.
/// Status of the command.
LCDRIVER_API int __cdecl ParameterStorage_WriteGlobalDataSet(LCDContext Context, const char *pchGdfsId, const char *pchPath, int iUseBulk);
///
/// Erases the complete global data storage area/partition specified by the DevicePath parameter.
///
/// LCD context on which to execute the operation.
/// GDFS ID.
/// Status of the command.
LCDRIVER_API int __cdecl ParameterStorage_EraseGlobalDataSet(LCDContext Context, const char *pchGdfsId);
///
/// This command is used to set the ME domain.
///
/// LCD context on which to execute the operation.
/// Target domain.
/// Status of the command.
LCDRIVER_API int __cdecl Security_SetDomain(LCDContext Context, int iDomain);
///
/// This command is used to get the ME domain.
///
/// LCD context on which to execute the operation.
/// The ME current domain.
/// Status of the command.
LCDRIVER_API int __cdecl Security_GetDomain(LCDContext Context, int *piWrittenDomain);
///
/// This command is used to read a security data unit (such as a secure static or dynamic data unit).
///
/// LCD context on which to execute the operation.
/// Unit ID to read.
/// Size of puchDataBuffer.
/// The unit data.
/// Status of the command.
LCDRIVER_API int __cdecl Security_GetProperties(LCDContext Context, int iUnitId, int *piSize, unsigned char *puchDataBuffer);
///
/// This command is used to write a security data unit (such as a secure static or dynamic data unit).
///
/// LCD context on which to execute the operation.
/// Unit ID to write.
/// Size of puchDataBuffer.
/// The data to write.
/// Status of the command.
LCDRIVER_API int __cdecl Security_SetProperties(LCDContext Context, int iUnitId, int iSize, unsigned char *puchDataBuffer);
///
/// This command associates all security data units with the current ME.
///
/// LCD context on which to execute the operation.
/// Status of the command.
LCDRIVER_API int __cdecl Security_BindProperties(LCDContext Context);
///
/// This command installs a secure object to the Boot record or OTP area.
///
/// LCD context on which to execute the operation.
/// If iUseBulk = 1 -> path on PC, else path on ME.
/// Secure object destination address on ME.
/// Source on PC -> iUseBulk= 1. Source on ME -> iUseBulk= 0.
/// Status of the command.
LCDRIVER_API int __cdecl Security_StoreSecureObject(LCDContext Context, const char *pchSourcePath, int iDestination, int iUseBulk);
///
/// This command is used to initialize a SW version table, intended for checking the ARB functionality.
///
/// LCD context on which to execute the operation.
/// ARB data type:0 = COPS_ARB_DATA_TYPE_MODELID.
/// Length of puarbData.
/// For arb_data_type = COPS_ARB_DATA_TYPE_MODELID the data is a 16 bit modelid.
/// Status of the command.
LCDRIVER_API int __cdecl Security_InitARBTable(LCDContext Context, int iType, int iLength, unsigned char *puarbdata);
///
/// The A2 loader shuts down in a controlled fashion and proceeds to shut down the ME itself.
/// The ME does not accept any further communication after a successful response from this
/// command has been returned.
///
/// Status of the command.
LCDRIVER_API int __cdecl A2_System_Shutdown(LCDContext Context);
///
/// The PC uses the Loader version command to request version information from the loader
/// The response holds the loader version information coded as ASCII characters in the data field
///
/// Status of the command.
LCDRIVER_API int __cdecl A2_System_LoaderVersion(LCDContext Context, char *pchLoaderVersion, int *piSize, int iTargetCPU);
///
/// The Loader on loader command is used to transfer a new loader to the ME
/// When the header or payload has been sent, the loader responds with a GR using status codes.
///
/// Status of the command.
LCDRIVER_API int __cdecl A2_System_LoaderOnLoader(LCDContext Context, const char *pchPath, int iPLOfset, int iHLOffset, int iTargetCPU);
///
/// The Reset command will reset the phone using the watchdog reset functionality of the ARM processor.
///
/// Status of the command.
LCDRIVER_API int __cdecl A2_System_Reset(LCDContext Context, int iTimeout);
///
/// The Program flash command is sent by the PC to write a block of data into the flash memory.
/// The block data is sent in the data field.
/// When a complete block has been transmitted the loader verifies the data and responds with a GR using status codes
///
/// Status of the command.
LCDRIVER_API int __cdecl A2_Flash_ProgramFlash(LCDContext Context, const char *pchPath, int iUseSpeedFlash);
///
/// The Erase flash command is used to erase the complete flash memory.
/// It checks what type of memory is used in the ME and erases the complete memory including the first memory block.
/// If more than one flash is attached, all of them will be erased
/// The loader responds with a GR using status codes
///
/// Status of the command.
LCDRIVER_API int __cdecl A2_Flash_EraseFlash(LCDContext Context);
///
/// The loader started message is sent from the ME to the PC as soon as the loader has started executing
/// and is ready to receive commands.
///
/// Status of the command.
LCDRIVER_API int __cdecl A2_Control_LoaderStarted(LCDContext Context);
///
/// Set protocol to use.
///
/// LCD context on which to execute the operation.
/// Protocol to use. Valid values: R15_FAMILY, PROTROM_FAMILY, NOPROT
/// Status of the command.
LCDRIVER_API int __cdecl SetProtocolFamily(LCDContext Context, const char *pchFamily);
///
/// Set ME in service mode and receive chip id.
///
/// LCD context on which to execute the operation.
/// Received chip id.
/// Status of the command.
LCDRIVER_API int __cdecl Z_SetInServiceMode(LCDContext Context, unsigned int *puiChipId);
///
/// Set communication baudrate when communicating via UART.
///
/// LCD context on which to execute the operation.
/// Baudrate to use. Valid values: 9600, 19200, 38400, 57600, 115200,
/// 230400, 460800, 921600, 1625000.
/// Status of the command.
LCDRIVER_API int __cdecl Z_SetBaudrate(LCDContext Context, int iBaudrate);
///
/// Exit Z-protocol and start using PROTROM-protocol.
///
/// LCD context on which to execute the operation.
/// Status of the command.
LCDRIVER_API int __cdecl Z_Exit_Z_Protocol(LCDContext Context);
///
/// Download loader using PROTROM-protocol.
///
/// LCD context on which to execute the operation.
/// Path to loader on PC.
/// Offset in header to payload length.
/// Offset in header to header length.
/// 1 -> continue use PROTROM-protocol after download the loader. O -> not use PROTROM-protocol after download the loader.
/// Status of the command.
LCDRIVER_API int __cdecl PROTROM_DownloadLoader(LCDContext Context, const char *pchPath, int iPLOffset, int iHLOffset, int iContinueProtRom);
///
/// Send intrinsic request to read security data using PROTROM-protocol.
///
/// LCD context on which to execute the operation.
/// ID of the security data to be read with the intrinsic request.
/// Buffer where the read data will be stored.
/// IN: Length of DataBuffer; OUT: Read data length.
/// Status of the command.
LCDRIVER_API int __cdecl PROTROM_ReadSecurityData(LCDContext Context, unsigned char uiSecDataId, unsigned char *puchDataBuffer, int *piDataLength);
// Random SIMLock keys generation functions not related to communication
LCDRIVER_API int __cdecl Algorithms_SimGeneratorInit(void *Object, int SecurityLevel);
LCDRIVER_API int __cdecl Algorithms_SimGeneratorExit(void *Object);
LCDRIVER_API int __cdecl Algorithms_SimGeneratorCalculate(void *Object, unsigned char *ByteArray, uint32 ArraySize);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _LCDRIVER_H_