summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tvsetting/CBlobDeviceRam.cpp (plain)
blob: c938be7071af28548472e1d77e4c3ed799e40c29
1#include <stdio.h>
2#include <string.h>
3
4#include <android/log.h>
5
6#include "CTvSettingDeviceRam.h"
7
8#define LOG_TAG "ssmram"
9#include "CTvLog.h"
10
11CTvSettingDeviceRam::CTvSettingDeviceRam()
12{
13 RAM_DEV_TOTAL_SIZE = 4 * 1024;
14 RAM_DEV_RW_START_OFFSET = 0;
15 RAM_DEV_RW_END_OFFSET = RAM_DEV_TOTAL_SIZE - 1;
16 RAM_DEV_W_PAGE_SIZE = 32;
17 RAM_DEV_R_PAGE_SIZE = 32;
18 RAM_DEV_SLAVE_ADDR = (0xA0 >> 1);
19 RAM_DEV_RW_TEST_OFFSET = -1;
20 device_use_buffer = 0;
21 device_buf = NULL;
22 gFilePathBuf[0] = '\0';
23}
24
25CTvSettingDeviceRam::~CTvSettingDeviceRam()
26{
27}
28
29int CTvSettingDeviceRam::GetDeviceTotalSize()
30{
31 return 0;
32}
33int CTvSettingDeviceRam::InitCheck()
34{
35 int tmp_dev_total_size = 0;
36
37 if (device_buf == NULL) {
38 tmp_dev_total_size = GetDeviceTotalSize();
39 if (tmp_dev_total_size <= 0) {
40 LOGE("%s, Device file size must be more than 0.\n", "TV");
41 return -1;
42 }
43
44 device_buf = new unsigned char[tmp_dev_total_size];
45 if (device_buf == NULL) {
46 return -1;
47 }
48
49 memset((void *) device_buf, CC_INIT_BYTE_VAL, tmp_dev_total_size);
50 }
51
52 return 0;
53}
54
55int CTvSettingDeviceRam::OpenDevice()
56{
57 return 0;
58}
59
60int CTvSettingDeviceRam::CloseDevice(int *device_fd)
61{
62
63
64 return 0;
65}
66
67int CTvSettingDeviceRam::CheckDeviceWrAvaliable(int offset, int len)
68{
69 /*int tmp_dev_start_offset = 0;
70 int tmp_dev_end_offset = 0;
71
72 GetDeviceRWStartOffset(&tmp_dev_start_offset);
73 if (tmp_dev_start_offset < 0) {
74 LOGE("%s, Device file r/w start offset must be greater than or euqal to 0.\n", "TV");
75 return -1;
76 }
77
78 GetDeviceRWEndOffset(&tmp_dev_end_offset);
79 if (tmp_dev_end_offset < 0) {
80 LOGE("%s, Device file r/w end offset must be more than 0.\n", "TV");
81 return -1;
82 }
83
84 if (len <= 0) {
85 LOGE("%s, The w/r length should be more than 0.\n", "TV");
86 return -1;
87 }
88
89 if ((len + tmp_dev_start_offset + offset) > tmp_dev_end_offset + 1) {
90 LOGE("%s, w/r would be overflow!!! len = %d, start offset = %d, offset = %d, end offset = %d.\n", "TV", len, tmp_dev_start_offset, offset, tmp_dev_end_offset);
91 return -1;
92 }
93
94 if (ValidOperateCheck() < 0) {
95 return -1;
96 }*/
97
98 return 0;
99}
100
101int CTvSettingDeviceRam::WriteSpecialBytes(int offset, int len, unsigned char data_buf[])
102{
103 int tmp_dev_w_page_size = 0;
104
105 //GetDeviceWritePageSize(&tmp_dev_w_page_size);
106 //if (len > tmp_dev_w_page_size) {
107 // LOGE("%s, The write length should be less than page size(%d).\n", "TV", tmp_dev_w_page_size);
108 // return -1;
109 // }
110
111 if (CheckDeviceWrAvaliable(offset, len) < 0) {
112 return -1;
113 }
114
115 memcpy((void *) (device_buf + offset), (void *) data_buf, len);
116
117 return 0;
118}
119
120int CTvSettingDeviceRam::ReadSpecialBytes(int offset, int len, unsigned char data_buf[])
121{
122 if (CheckDeviceWrAvaliable(offset, len) < 0) {
123 return -1;
124 }
125
126 memcpy((void *) data_buf, (void *) (device_buf + offset), len);
127
128 return 0;
129}
130