blob: b8259a7473f1d1fcaa97a155213d3119eeb9158c
1 | #ifndef BLOB_BASE_DEVICE_H |
2 | #define BLOB_BASE_DEVICE_H |
3 | |
4 | class CBlobDevice { |
5 | |
6 | public: |
7 | static const int CC_MAX_FILE_PATH = 256; |
8 | static const int CC_ERR_FILE_HANDLE = -1; |
9 | static const int CC_INIT_BYTE_VAL = 0xFF; |
10 | static const int CC_SSM_PROTECT_ON = 0; |
11 | static const int CC_SSM_PROTECT_OFF = 1; |
12 | |
13 | static const int CC_DEVICE_E2PROM = (0); |
14 | static const int CC_DEVICE_SPI = (1); |
15 | static const int CC_DEVICE_FILE = (2); |
16 | static const int CC_DEVICE_RAM = (3); |
17 | |
18 | CBlobDevice(); |
19 | virtual ~CBlobDevice(); |
20 | |
21 | virtual int WriteBytes(int offset, int size, unsigned char *buf) = 0; |
22 | virtual int ReadBytes(int offset, int size, unsigned char *buf) = 0; |
23 | virtual int EraseAllData() = 0; |
24 | virtual int InitCheck() = 0; |
25 | virtual int OpenDevice() = 0; |
26 | virtual int CloseDevice() = 0; |
27 | int WriteOneByte(int offset, unsigned char val) |
28 | { |
29 | return WriteBytes(offset, 1, &val); |
30 | } |
31 | int ReadOneByte(int offset, unsigned char *ptrVal) |
32 | { |
33 | return ReadBytes(offset, 1, ptrVal); |
34 | } |
35 | |
36 | int m_dev_type; //device type |
37 | int m_dev_total_size; //device total size(Byte) |
38 | |
39 | char m_dev_path[CC_MAX_FILE_PATH]; //device path |
40 | int m_dev_fd; |
41 | |
42 | protected: |
43 | unsigned char *mDataBuf; |
44 | |
45 | private: |
46 | int IsFileExist(const char *file_name); |
47 | |
48 | }; |
49 | |
50 | #endif // ANDROID_SSM_BASE_H |
51 |