xFSTK  0.0.0
Intel SoC Cross Platform Firmware & Software Tool Kit
xfstkdldrapi.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2015 Intel Corporation
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 #ifndef XFSTKDLDRAPI_H
19 #define XFSTKDLDRAPI_H
20 #include "xfstk-dldr-api_global.h"
21 #include <iostream>
22 
28 #define MOORESTOWN 0x1
29 #define MEDFIELD 0x2
30 #define CLOVERVIEW 0x3
31 #define CLOVERVIEWPLUS 0x4
32 #define MERRIFIELD 0x5
33 #define MEDFIELD_EMMC_DUMP 0x6
34 #define HASHVERIFY 0x7
35 #define MOOREFIELD 0x8
36 #define BAYTRAIL 0x9
37 #define CARBONCANYON 0xA
38 #define XFSTK_MAXDEVICE 0xB
39 #define XFSTK_NODEVICE 0x666
40 
45 #define LOG_ACK 0x0001
46 #define LOG_UPDATE 0x0002
47 #define LOG_OPCODE 0x0004
48 #define LOG_FWUPGRADE 0x0008
49 #define LOG_OS 0x0010
50 #define LOG_USB 0x0020
51 #define LOG_SOCKET 0x0040
52 #define LOG_SERIAL 0x0080
53 #define LOG_UTIL 0x0100
54 #define LOG_DOWNLOADER 0x0200
55 #define LOG_ENTRY 0x0400
56 #define LOG_STATUS 0x0800
57 #define LOG_PROGRESS 0x1000
58 #define DEBUG_ERROR 0xfffffff1
59 #define LOG_ALL 0xffffffff
60 #define MAX_ARGS 32
61 
67 struct LastError {
68  unsigned long error_code;
69  char error_message[128];
70 };
71 
72 #define MAX_USBSN_LENGTH 128
73 
81 struct SoCDevice {
82  char usbsn[MAX_USBSN_LENGTH];
83  unsigned long root_hub;
84  unsigned long port[5];
85 
86 };
87 
94 struct SoCDevices {
96  SoCDevice soc_device[32];
97 };
98 
99 #ifdef XFSTK_OS_WIN
100 typedef struct DevicesCallBack
101 {
102  SoCDevices* device;
103  void (*attach)(void* data);
104  void (*detach)(void* data);
105  void * clientdata;
106 }DevicesCallBack;
107 #endif
108 
113 typedef void(*xfstkstatuspfn)(char* status, void *);
124 class XFSTKDLDRAPISHARED_EXPORT xfstkdldrapi {
125 public:
126 
133  xfstkdldrapi();
134 
141  virtual ~xfstkdldrapi();
142 
151  virtual bool idrqresponse(unsigned char *buffer, int maxsize);
152 
159  virtual bool downloadcli(const char *cli, const char* usbsn = NULL);
160 
166  virtual bool downloadfw(char *fwfile);
167 
175  virtual bool hashverify(char *hashfile, bool write);
176 
185  virtual void setResponsebuffer(unsigned char* responseBuffer, int& maxsize);
186 
198  virtual bool downloadcsdb(char *fwdnx, char *miscbin, char *cmdcode,char *fwimage, bool direct );
199 
208  virtual bool downloadfw(char *fwdnx, char *fwimage, char *gpflags);
209 
218  virtual bool downloados(char *osdnx, char *osimage, char *gpflags);
219 
230  virtual bool downloadfwos(char *fwdnx, char *fwimage, char *osdnx, char* osimage, char* gpflags);
231 
243  virtual bool downloadfwos(char *fwdnx, char *fwimage, char *osdnx, char* osimage, char* gpflags, char* softfuse);
244 
257  virtual bool downloadmtfwosasync(char *fwdnx, char *fwimage, char *osdnx, char* osimage, char* gpflags, char* usbsn);
258 
272  virtual bool downloadmtfwosasync(char *fwdnx, char *fwimage, char *osdnx, char* osimage, char* gpflags, char* usbsn, char* softfuse);
273 
281  virtual bool registerstatuscallback(xfstkstatuspfn statuspfn, void *clientdata);
282 
289  virtual void settargetretrycount(int retries);
290 
296  virtual void setloglevel(unsigned long loglevel);
297 
305  virtual void setsoftfusepath(bool include, char * softfuse);
306 
314  virtual void setmiscdnxpath(bool enable, char * miscdnx);
315 
322  virtual int getavailabletargets();
323 
330  virtual int getavailabletargets(unsigned long devicetype);
331 
338  virtual int getavailabletargets(SoCDevices * socdevices);
339 
340 #ifdef XFSTK_OS_WIN
341 
350  virtual bool registerdevicecallback(DevicesCallBack* callBackStruct, unsigned long ProductId=0);
351 #endif
352 
359  virtual void usbdevicemutexlock();
360 
368  virtual void usbdevicemutexunlock();
369 
376  virtual void getversion(char* version);
377 
384  virtual std::string getfullversion(void) const;
385 
392  virtual bool getlasterror(LastError* er);
393 
400  virtual void setusbreadwritedelay(unsigned long delayms);
401 
411  virtual void setwipeifwi(bool enable);
412 
413 private:
414  xfstkstatuspfn physstatuspfn;
415  void *physclientdata;
416  void *xfstkfactoryhandle;
417  bool binterfaceavailable;
418  bool binterfaceclaimed;
419  bool interfaceavailable();
420  bool claiminterface();
421  void releaseinterface();
422  void findusbtargets();
423  char* miscdnx;
424  bool miscdnxenable;
425  char* softfuse;
426  bool softfuseinclude;
427  int retrycount;
428  void xfstklogmessage(char *message, void *clientdata);
429  void xfstkmultitargetstatuscallback(char *message, void *clientdata);
430  void showversion(void);
431 
432  xfstkdldrapi( const xfstkdldrapi& );
433  xfstkdldrapi& operator=( const xfstkdldrapi& );
434 };
435 
436 extern "C" {
437  XFSTKDLDRAPISHARED_EXPORT xfstkdldrapi* xfstkdldrapi_alloc();
438  XFSTKDLDRAPISHARED_EXPORT void xfstkdldrapi_dealloc(xfstkdldrapi* obj);
439 }
440 #endif // XFSTKDLDRAPI_H
int number_devices
Definition: xfstkdldrapi.h:95
void status(char *message, void *clientdata)
Definition: xfstk-dldr-example-parallel.cpp:28
#define MAX_USBSN_LENGTH
Definition: xfstkdldrapi.h:72
unsigned long root_hub
Definition: xfstkdldrapi.h:83
char error_message[128]
Definition: xfstkdldrapi.h:69
unsigned long error_code
Definition: xfstkdldrapi.h:68
data struct for port info for all the devices connected to host
Definition: xfstkdldrapi.h:94
data struct for port mapping API
Definition: xfstkdldrapi.h:81
XFSTKDLDRAPISHARED_EXPORT xfstkdldrapi * xfstkdldrapi_alloc()
void(* xfstkstatuspfn)(char *status, void *)
Represents an optional status callback function that can be provided to xfstk API to obtain status in...
Definition: xfstkdldrapi.h:113
This interface enables the development of Intel SoC firmware/operating system provisioning applicatio...
Definition: xfstkdldrapi.h:124
The last error happened during download.
Definition: xfstkdldrapi.h:67
XFSTKDLDRAPISHARED_EXPORT void xfstkdldrapi_dealloc(xfstkdldrapi *obj)