xref: /OK3568_Linux_fs/external/rkupdate/DefineHeader.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 #ifndef DEFINE_HEADER
2 #define DEFINE_HEADER
3 #ifndef _U
4     #define _U _CTYPE_U
5 #endif
6 #ifndef _L
7     #define _L _CTYPE_L
8 #endif
9 #ifndef _N
10     #define _N _CTYPE_L
11 #endif
12 #ifndef _X
13     #define _X _CTYPE_X
14 #endif
15 #ifndef _P
16     #define _P _CTYPE_P
17 #endif
18 #ifndef _B
19     #define _B _CTYPE_B
20 #endif
21 #ifndef _C
22     #define _C _CTYPE_C
23 #endif
24 #ifndef _S
25     #define _S _CTYPE_S
26 #endif
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <stdarg.h>
30 #include <string.h>
31 #include <sys/stat.h>
32 #include <sys/ioctl.h>
33 #include <fcntl.h>
34 #include <dirent.h>
35 #include <time.h>
36 #include <unistd.h>
37 //#include <iconv.h>
38 #include <wchar.h>
39 #include <errno.h>
40 #include <ctype.h>
41 
42 #include "Property.hpp"
43 #include <list>
44 #include <vector>
45 //#include <set>
46 #include <string>
47 #include <sstream>
48 #include <algorithm>
49 using namespace std;
50 
51 typedef unsigned int u_int32;
52 typedef unsigned char u_int8;
53 typedef unsigned char BYTE;
54 typedef signed char CHAR;
55 typedef BYTE *PBYTE;
56 typedef unsigned char UCHAR;
57 typedef unsigned short WCHAR;
58 typedef unsigned short USHORT;
59 typedef unsigned int    UINT;
60 typedef unsigned int    DWORD;
61 //#ifdef _UNICODE
62 //    typedef wchar_t tchar;
63 //    typedef wstring tstring;
64 //    #define _T(x) L ## x
65 //    #define _tcslen  wcslen
66 //    #define _tcscpy wcscpy
67 //    #define _tcsicmp wcscmp
68 //    #define _tcscmp  wcscmp
69 //    #define _stprintf swprintf
70 //    #define _istprint iswprint
71 //#else
72 typedef char tchar;
73 typedef string tstring;
74 #define _T(x) x
75 #define _tcslen  strlen
76 #define _tcscpy strcpy
77 #define _tcsicmp strcasecmp
78 #define _tcscmp  strcmp
79 #define _stprintf sprintf
80 #define _istprint isprint
81 //#endif
82 typedef enum
83 {
84     RKNONE_DEVICE = 0,
85     RK27_DEVICE = 0x10,
86     RKCAYMAN_DEVICE,
87     RK28_DEVICE = 0x20,
88     RK281X_DEVICE,
89     RKPANDA_DEVICE,
90     RKNANO_DEVICE = 0x30,
91     RKSMART_DEVICE,
92     RKCROWN_DEVICE = 0x40,
93     RK29_DEVICE = 0x50,
94     RK292X_DEVICE,
95     RK30_DEVICE = 0x60,
96     RK30B_DEVICE,
97     RK31_DEVICE = 0x70,
98     RK32_DEVICE = 0x80
99 } ENUM_RKDEVICE_TYPE;
100 typedef enum
101 {
102     RK_OS = 0,
103     ANDROID_OS = 0x1
104 } ENUM_OS_TYPE;
105 
106 typedef enum
107 {
108     RKUSB_NONE = 0x0,
109     RKUSB_MASKROM = 0x01,
110     RKUSB_LOADER = 0x02,
111     RKUSB_MSC = 0x04
112 } ENUM_RKUSB_TYPE;
113 typedef enum
114 {
115     ENTRY471 = 1,
116     ENTRY472 = 2,
117     ENTRYLOADER = 4
118 } ENUM_RKBOOTENTRY;
119 #define  MSC_ANDROID_OPER 0xFF
120 typedef enum
121 {
122     MSC_NONE_OPER = 0x0,
123     MSC_FORMAT_OPER = 0x1,
124     MSC_COPY_OPER = 0x2,
125     MSC_FORMAT_DATA_OPER = 0x4,
126     MSC_COPY_DATA_OPER = 0x8
127 } ENUM_MSC_OPER;
128 typedef enum
129 {
130     MISC_MODIFY_NONE = 0,
131     MISC_MODIFY_WIPE_ALL,
132     MISC_MODIFY_WIPE_DATA,
133 } ENUM_MISC_MODIFY_FLAG;
134 typedef enum
135 {
136     WF_UPGRADE = 1,
137     WF_RESTORE,
138     WF_GETOLDDISKSIZE,
139     WF_READSN,
140     WF_WRITESN,
141     WF_ERASEFLASH,
142     WF_ERASEIDB,
143     WF_GETBLOCKSTATE,
144     WF_READMAC,
145     WF_WRITEMAC,
146     WF_READBT,
147     WF_WRITEBT,
148     WF_READIMEI,
149     WF_WRITEIMEI,
150     WF_READUID,
151     WF_READCUSTOMDATA,
152     WF_WRITECUSTOMDATA,
153     WF_READALLINFO,
154     WF_WRITEALLINFO,
155     WF_DOWNLOADBOOT
156 } ENUM_WORKFLOW;
157 #pragma pack(1)
158 typedef struct
159 {
160     USHORT  usYear;
161     BYTE    ucMonth;
162     BYTE    ucDay;
163     BYTE    ucHour;
164     BYTE    ucMinute;
165     BYTE    ucSecond;
166 } STRUCT_RKTIME, *PSTRUCT_RKTIME;
167 typedef struct
168 {
169     char szItemName[20];
170     UINT uiItemOffset;
171     UINT uiItemSize;
172 } STRUCT_PARAM_ITEM, *PSTRUCT_PARAM_ITEM;
173 typedef struct
174 {
175     char szItemName[20];
176     char szItemValue[256];
177 } STRUCT_CONFIG_ITEM, *PSTRUCT_CONFIG_ITEM;
178 typedef struct _STRUCT_RKDEVICE_DESC
179 {
180     USHORT usVid;
181     USHORT usPid;
182     USHORT usbcdUsb;
183     UINT     uiLocationID;
184     ENUM_RKUSB_TYPE emUsbType;
185     ENUM_RKDEVICE_TYPE emDeviceType;
186     void   *pUsbHandle;
187 } STRUCT_RKDEVICE_DESC, *PSTRUCT_RKDEVICE_DESC;
188 #pragma pack()
189 typedef list<STRUCT_RKDEVICE_DESC> RKDEVICE_DESC_SET;
190 typedef RKDEVICE_DESC_SET::iterator device_list_iter;
191 typedef vector<tstring> STRING_VECTOR;
192 typedef vector<UINT> UINT_VECTOR;
193 typedef vector<STRUCT_PARAM_ITEM> PARAM_ITEM_VECTOR;
194 typedef vector<STRUCT_CONFIG_ITEM> CONFIG_ITEM_VECTOR;
195 //typedef enum
196 //{
197 //      DOWNLOADBOOT_START=1,
198 //      DOWNLOADBOOT_FAIL=2,
199 //      DOWNLOADBOOT_PASS=3,
200 //      DOWNLOADIDBLOCK_START=4,
201 //      DOWNLOADIDBLOCK_FAIL=5,
202 //      DOWNLOADIDBLOCK_PASS=6,
203 //      DOWNLOADIMAGE_START=7,
204 //      DOWNLOADIMAGE_FAIL=8,
205 //      DOWNLOADIMAGE_PASS=9,
206 //      TESTDEVICE_START=10,
207 //      TESTDEVICE_FAIL=11,
208 //      TESTDEVICE_PASS=12,
209 //      RESETDEVICE_START=13,
210 //      RESETDEVICE_FAIL=14,
211 //      RESETDEVICE_PASS=15,
212 //      FORMATDISK_START=16,
213 //      FORMATDISK_FAIL=17,
214 //      FORMATDISK_PASS=18,
215 //      COPYDATA_START=19,
216 //      COPYDATA_FAIL=20,
217 //      COPYDATA_PASS=21,
218 //      WAITMSC_START=22,
219 //      WAITMSC_FAIL=23,
220 //      WAITMSC_PASS=24,
221 //      WAITLOADER_START=25,
222 //      WAITLOADER_FAIL=26,
223 //      WAITLOADER_PASS=27,
224 //      WAITMASKROM_START=28,
225 //      WAITMASKROM_FAIL=29,
226 //      WAITMASKROM_PASS=30,
227 //      ERASEIDB_START=31,
228 //      ERASEIDB_FAIL=32,
229 //      ERASEIDB_PASS=33,
230 //      SWITCHMSC_START=34,
231 //      SWITCHMSC_FAIL=35,
232 //      SWITCHMSC_PASS=36,
233 //      CHECKCHIP_START=37,
234 //      CHECKCHIP_FAIL=38,
235 //      CHECKCHIP_PASS=39,
236 //      PREPAREIDB_START=40,
237 //      PREPAREIDB_FAIL=41,
238 //      PREPAREIDB_PASS=42,
239 //      MUTEXRESETDEVICE_START=43,
240 //      MUTEXRESETDEVICE_FAIL=44,
241 //      MUTEXRESETDEVICE_PASS=45,
242 //      GETOLDDISKSIZE_START=46,
243 //      GETOLDDISKSIZE_FAIL=47,
244 //      GETOLDDISKSIZE_PASS=48,
245 //      READSN_START=49,
246 //      READSN_FAIL=50,
247 //      READSN_PASS=51,
248 //      WRITESN_START=52,
249 //      WRITESN_FAIL=53,
250 //      WRITESN_PASS=54,
251 //      ERASEALLBLOCKS_START=55,
252 //      ERASEALLBLOCKS_FAIL=56,
253 //      ERASEALLBLOCKS_PASS=57,
254 //      GETBLOCKSTATE_START=58,
255 //      GETBLOCKSTATE_FAIL=59,
256 //      GETBLOCKSTATE_PASS=60,
257 //      GETFLASHINFO_START=61,
258 //      GETFLASHINFO_FAIL=62,
259 //      GETFLASHINFO_PASS=63,
260 //      WRITEBACK_START=64,
261 //      WRITEBACK_FAIL=65,
262 //      WRITEBACK_PASS=66,
263 //      FINDUSERDISK_START=67,
264 //      FINDUSERDISK_FAIL=68,
265 //      FINDUSERDISK_PASS=69,
266 //      SHOWUSERDISK_START=70,
267 //      SHOWUSERDISK_FAIL=71,
268 //      SHOWUSERDISK_PASS=72,
269 //      READMAC_START=73,
270 //      READMAC_FAIL=74,
271 //      READMAC_PASS=75,
272 //      WRITEMAC_START=76,
273 //      WRITEMAC_FAIL=77,
274 //      WRITEMAC_PASS=78,
275 //      READBT_START=79,
276 //      READBT_FAIL=80,
277 //      READBT_PASS=81,
278 //      WRITEBT_START=82,
279 //      WRITEBT_FAIL=83,
280 //      WRITEBT_PASS=84,
281 //      LOWERFORMAT_START=85,
282 //      LOWERFORMAT_FAIL=86,
283 //      LOWERFORMAT_PASS=87,
284 //      READIMEI_START=88,
285 //      READIMEI_FAIL=89,
286 //      READIMEI_PASS=90,
287 //      WRITEIMEI_START=91,
288 //      WRITEIMEI_FAIL=92,
289 //      WRITEIMEI_PASS=93,
290 //      SHOWDATADISK_START=94,
291 //      SHOWDATADISK_FAIL=95,
292 //      SHOWDATADISK_PASS=96,
293 //      FINDDATADISK_START=97,
294 //      FINDDATADISK_FAIL=98,
295 //      FINDDATADISK_PASS=99,
296 //      FORMATDATADISK_START=100,
297 //      FORMATDATADISK_FAIL=101,
298 //      FORMATDATADISK_PASS=102,
299 //      COPYDATADISK_START=103,
300 //      COPYDATADISK_FAIL=104,
301 //      COPYDATADISK_PASS=105,
302 //      READUID_START=106,
303 //      READUID_FAIL=107,
304 //      READUID_PASS=108,
305 //      READCUSTOMDATA_START=109,
306 //      READCUSTOMDATA_FAIL=110,
307 //      READCUSTOMDATA_PASS=111,
308 //      WRITECUSTOMDATA_START=112,
309 //      WRITECUSTOMDATA_FAIL=113,
310 //      WRITECUSTOMDATA_PASS=114,
311 //      SETRESETFLAG_START=115,
312 //      SETRESETFLAG_FAIL=116,
313 //      SETRESETFLAG_PASS=117,
314 //      POWEROFF_START=118,
315 //      POWEROFF_FAIL=119,
316 //      POWEROFF_PASS=120,
317 //      READALLINFO_START=121,
318 //      READALLINFO_FAIL=122,
319 //      READALLINFO_PASS=123,
320 //      WRITEALLINFO_START=124,
321 //      WRITEALLINFO_FAIL=125,
322 //      WRITEALLINFO_PASS=126,
323 //      RESETMSC_START=127,
324 //      RESETMSC_FAIL=128,
325 //      RESETMSC_PASS=129
326 //}ENUM_UPGRADE_PROMPT;
327 //typedef enum
328 //{
329 //  TESTDEVICE_PROGRESS,
330 //  DOWNLOADIMAGE_PROGRESS,
331 //  CHECKIMAGE_PROGRESS,
332 //  TAGBADBLOCK_PROGRESS,
333 //  TESTBLOCK_PROGRESS,
334 //  ERASEFLASH_PROGRESS,
335 //  ERASESYSTEM_PROGRESS,
336 //  LOWERFORMAT_PROGRESS,
337 //  ERASEUSERDATA_PROGRESS
338 //}ENUM_PROGRESS_PROMPT;
339 //#define   MSC_SWITCHROCKUSB   0xFFFFFFFE
340 //#define MSC_GETVERSIONINFO    0xFFFFFFFF
341 //#define MSC_RESETDEVICE       0xFFFFFFFD
342 //#define MSC_GETCHIPINFO       0xFFFFFFFC
343 //#define MSC_SHOWUSERDISK  0xFFFFFFFB
344 //#define MSC_GETDEVIVEUID  0xFFFFFFF7
345 //#define MSC_SHOWDATADISK  0xFFFFFFF6
346 //#define MSC_GETPRODUCTMODEL 0xFFFFFFF3
347 //#define MSC_GETPARAMETER  0xFFFFFFF2
348 //#define MSC_GETIDBSECTOR  0xFFFFFFF1
349 //#define MSC_GETPRODUCTSN  0xFFFFFFEF
350 //typedef enum
351 //{
352 //  CALL_FIRST,
353 //  CALL_MIDDLE,
354 //  CALL_LAST
355 //}ENUM_CALL_STEP;
356 
357 //typedef void (*UpgradeStepPromptCB)(DWORD deviceLayer,ENUM_UPGRADE_PROMPT promptID,DWORD oldDeviceLayer);
358 //typedef void (*ProgressPromptCB)(DWORD deviceLayer,ENUM_PROGRESS_PROMPT promptID,long long totalValue,long long currentValue,ENUM_CALL_STEP emCall);
359 
360 //bool WideStringToString(wchar_t *pszSrc,char *&pszDest);
361 //bool StringToWideString(char *pszSrc,wchar_t *&pszDest);
362 //bool transform(string &src,bool lowercase);
363 typedef void (*UpgradeCallbackFunc)(char *pszPrompt);
364 typedef void (*UpgradeProgressCallbackFunc)(float portion, float seconds);
365 #endif
366