xref: /OK3568_Linux_fs/external/rkupdate/RKImage.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 #ifndef RKIMAGE_HEADER
2 #define RKIMAGE_HEADER
3 #include "DefineHeader.h"
4 #include "RKBoot.h"
5 #define  IMAGE_RESERVED_SIZE 61
6 #pragma pack(1)
7 typedef struct
8 {
9     UINT uiTag;
10     USHORT usSize;
11     DWORD  dwVersion;
12     DWORD  dwMergeVersion;
13     STRUCT_RKTIME stReleaseTime;
14     ENUM_RKDEVICE_TYPE emSupportChip;
15     DWORD  dwBootOffset;
16     DWORD  dwBootSize;
17     DWORD  dwFWOffset;
18     DWORD  dwFWSize;
19     BYTE   reserved[IMAGE_RESERVED_SIZE];
20 } STRUCT_RKIMAGE_HEAD, *PSTRUCT_RKIMAGE_HEAD;
21 #pragma pack()
22 class CRKImage
23 {
24 public:
25     UINT GetVersion();
26     property<CRKImage, UINT, READ_ONLY> Version;
27     UINT GetMergeVersion();
28     property<CRKImage, UINT, READ_ONLY> MergeVersion;
29     STRUCT_RKTIME GetReleaseTime();
30     property<CRKImage, STRUCT_RKTIME, READ_ONLY> ReleaseTime;
31     ENUM_RKDEVICE_TYPE GetSupportDevice();
32     property<CRKImage, ENUM_RKDEVICE_TYPE, READ_ONLY> SupportDevice;
33     ENUM_OS_TYPE GetOsType();
34     property<CRKImage, ENUM_OS_TYPE, READ_ONLY> OsType;
35     unsigned short GetBackupSize();
36     property<CRKImage, unsigned short, READ_ONLY> BackupSize;
37     UINT GetBootOffset();
38     property<CRKImage, UINT, READ_ONLY> BootOffset;
39     UINT GetBootSize();
40     property<CRKImage, UINT, READ_ONLY> BootSize;
41     UINT GetFWOffset();
42     property<CRKImage, UINT, READ_ONLY> FWOffset;
43     FILE *GetFWFileHandle();
44     property<CRKImage, FILE *, READ_ONLY> FWFileHandle;
45     long long GetFWSize();
46     property<CRKImage, long long, READ_ONLY> FWSize;
47     char *GetFwPath();
48     property<CRKImage, char *, READ_ONLY> FwPath;
49 
50     CRKBoot *m_bootObject;
51     bool Md5Check(long long nCheckSize);
52     bool SaveBootFile(tstring filename);
53     bool SaveFWFile(tstring filename);
54     bool GetData(long long dwOffset, DWORD dwSize, PBYTE lpBuffer);
55     void GetReservedData(PBYTE &lpData, USHORT &usSize);
56     long long GetImageSize();
57     int GetMd5Data(PBYTE &lpMd5, PBYTE &lpSignMd5);
58     CRKImage(tstring filename, bool &bCheck);
59     ~CRKImage();
60 protected:
61 
62 private:
63     DWORD m_version;
64     DWORD m_mergeVersion;
65     STRUCT_RKTIME m_releaseTime;
66     ENUM_RKDEVICE_TYPE m_supportDevice;
67     DWORD m_bootOffset;
68     DWORD m_bootSize;
69     DWORD m_fwOffset;
70     long long m_fwSize;
71     BYTE  m_md5[32];
72     BYTE  m_signMd5[256];
73     BYTE  m_reserved[IMAGE_RESERVED_SIZE];
74     bool  m_bSignFlag;
75     int   m_signMd5Size;
76     FILE *m_pFile;
77     char m_imgPath[256];
78     long long m_fileSize;
79 };
80 #endif
81