4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
8 * Jaewon Lim <jaewon81.lim@samsung.com>
9 * Woojin Jung <woojin2.jung@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
11 * Cherepanov Vitaliy <v.cherepanov@samsung.com>
12 * Nikita Kalyazin <n.kalyazin@samsung.com>
14 * Licensed under the Apache License, Version 2.0 (the "License");
15 * you may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
18 * http://www.apache.org/licenses/LICENSE-2.0
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
28 * - Samsung RnD Institute Russia
36 #include <stdint.h> // for uint64_t, int64_t
37 #include <pthread.h> // for pthread_mutex_t
39 #include "da_protocol.h"
46 #define PROTOCOL_VERSION "2.1"
48 #define RUN_APP_LOADER
50 #define MAX_TARGET_COUNT 8
51 #define DA_MSG_MAX 4096
52 #define RECV_BUF_MAX 4104 // = sizeof(msg_t)
55 #define MAX_FILENAME 128
57 #define INPUT_ID_TOUCH 0
58 #define INPUT_ID_KEY 1
59 #define STR_TOUCH "TOUCH"
61 #define INPUT_ID_STR_KEY "ID_INPUT_KEY=1"
62 #define INPUT_ID_STR_TOUCH "ID_INPUT_TOUCHSCREEN=1"
63 #define INPUT_ID_STR_KEYBOARD "ID_INPUT_KEYBOARD=1"
64 #define INPUT_ID_STR_TABLET "ID_INPUT_TABLET=1"
70 ERR_LOCKFILE_CREATE_FAILED = -101,
71 ERR_ALREADY_RUNNING = -102,
72 ERR_INITIALIZE_SYSTEM_INFO_FAILED = -103,
73 ERR_HOST_SERVER_SOCKET_CREATE_FAILED = -104,
74 ERR_TARGET_SERVER_SOCKET_CREATE_FAILED = -105,
75 ERR_SIGNAL_MASK_SETTING_FAILED = -106,
76 ERR_WRONG_MESSAGE_FORMAT = -201,
77 ERR_WRONG_MESSAGE_TYPE = -202,
78 ERR_WRONG_MESSAGE_DATA = -203,
79 ERR_CANNOT_START_PROFILING = -204,
80 ERR_WRONG_PROTOCOL_VERSION = -205
83 enum TargetMessageType
97 #define IS_PROBE_MSG(type) (((type) & 0x0100) == 0x0100)
101 MSG_HOST_BEGIN = 100,
108 MSG_BATT_START = 106,
120 OPT_CPUMEM = 0x00000001,
121 OPT_FUNC = 0x00000002,
122 OPT_ALLOC = 0x00000004,
123 OPT_FILE = 0x00000008,
124 OPT_THREAD = 0x00000010,
126 OPT_SNAPSHOT = 0x00000040,
127 OPT_EVENT = 0x00000080,
128 OPT_RECORD = 0x00000100
135 DAS_TARGET_ARM_START = 1,
136 DAS_TARGET_X86_START = 2,
137 DAS_EMUL_ARM_START = 3,
138 DAS_EMUL_X86_START = 4,
139 DAS_TARGET_ARM_BATT_START = 5,
140 DAS_TARGET_X86_BATT_START = 6,
141 DAS_EMUL_ARM_BATT_START = 7,
142 DAS_EMUL_X86_BATT_START = 8,
150 #define likely(x) __builtin_expect((x), 1)
151 #define unlikely(x) __builtin_expect((x), 0)
154 #define EVENT_STOP 0x00000001
155 #define EVENT_PID 0x00000002
156 #define EVENT_ERROR 0x00000004
162 char data[DA_MSG_MAX];
169 pthread_mutex_t data_socket_mutex;
174 int64_t allocmem; // written only by recv thread
175 pid_t pid; // written only by recv thread
176 int socket; // written only by main thread
177 pthread_t recv_thread; // written only by main thread
178 int event_fd; // for thread communication (from recv thread to main thread)
179 int initial_log; // written only by main thread
192 } __file_descriptors;
196 int host_server_socket;
197 int target_server_socket;
199 unsigned int config_flag;
200 int app_launch_timerfd;
201 int connect_timeout_timerfd;
202 pthread_t sampling_thread;
203 pthread_t replay_thread;
204 pthread_t transfer_thread;
209 __da_target_info target[MAX_TARGET_COUNT];
210 __file_descriptors fd;
211 char appPath[128]; // application executable path
215 typedef struct _input_dev
218 char fileName[MAX_FILENAME];
221 extern input_dev g_key_dev[MAX_DEVICE];
222 extern input_dev g_touch_dev[MAX_DEVICE];
224 extern __da_manager manager;
226 void initialize_log();
228 long long get_total_alloc_size();
229 void unlink_portfile(void);
231 int makeRecvThread(int index);
238 // TODO maybe need move to other file
239 int start_profiling();
240 void stop_profiling();
242 int sendACKCodeToHost(enum HostMessageType resp, int msgcode);
243 void terminate_all();
244 void _device_write(input_dev *dev, struct input_event* in_ev);