From c3930b01730cbdc6f4a838f95fc7ee817f18934d Mon Sep 17 00:00:00 2001 From: "munkyu.im" Date: Tue, 12 Nov 2013 18:23:15 +0900 Subject: [PATCH] ecs: apply nfc multi-session modified protobuf protocol added id, type value to identify each connection Change-Id: I8318f1a409ac667a94a7ec9b55900cfb5564f06e Signed-off-by: munkyu.im --- package/changelog | 3 + package/pkginfo.manifest | 2 +- tizen/src/ecs/ecs.c | 51 ++++++++++++++++- tizen/src/ecs/ecs.h | 27 +++++++-- tizen/src/ecs/ecs_mon.c | 21 +++---- tizen/src/ecs/ecs_msg.c | 119 +++++++++++++++++++++++++++++----------- tizen/src/ecs/genmsg/ecs.pb-c.c | 58 +------------------- tizen/src/ecs/genmsg/ecs.pb-c.h | 7 +-- tizen/src/ecs/msg/ecs.proto | 4 -- tizen/src/hw/maru_virtio_nfc.c | 115 ++++++++++++-------------------------- tizen/src/hw/maru_virtio_nfc.h | 3 +- 11 files changed, 213 insertions(+), 197 deletions(-) diff --git a/package/changelog b/package/changelog index 756764a..c72af52 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,6 @@ +* 1.6.3 +- modify protobuf protocol +== Munkyu Im 2013-11-12 * 1.6.2 - changed message format when a sdb server registers in guest server - previously it gets ip, port, serial, but now serial only diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index d41a782..fe1d672 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,4 +1,4 @@ -Version: 1.6.2 +Version: 1.6.3 Maintainer: Yeong-Kyoon Lee Source: emulator diff --git a/tizen/src/ecs/ecs.c b/tizen/src/ecs/ecs.c index 3902236..7662fe1 100644 --- a/tizen/src/ecs/ecs.c +++ b/tizen/src/ecs/ecs.c @@ -70,6 +70,7 @@ static int port; static int port_setting = -1; static int log_fd = -1; +static int g_client_id = 1; static pthread_mutex_t mutex_clilist = PTHREAD_MUTEX_INITIALIZER; @@ -196,6 +197,12 @@ bool send_to_all_client(const char* data, const int len) { return true; } +void send_to_single_client(ECS_Client *clii, const char* data, const int len) +{ + pthread_mutex_lock(&mutex_clilist); + send_to_client(clii->client_fd, data, len); + pthread_mutex_unlock(&mutex_clilist); +} void send_to_client(int fd, const char* data, const int len) { @@ -433,6 +440,17 @@ static ECS_Client *ecs_find_client(int fd) { return NULL; } +ECS_Client *find_client(unsigned char id, unsigned char type) { + ECS_Client *clii; + + QTAILQ_FOREACH(clii, &clients, next) + { + if (clii->client_id == id && clii->client_type == type) + return clii; + } + return NULL; +} + static int ecs_add_client(ECS_State *cs, int fd) { ECS_Client *clii = g_malloc0(sizeof(ECS_Client)); @@ -447,6 +465,7 @@ static int ecs_add_client(ECS_State *cs, int fd) { clii->client_fd = fd; clii->cs = cs; + clii->client_type = TYPE_NONE; ecs_json_message_parser_init(&clii->parser, handle_qmp_command, clii); @@ -521,7 +540,7 @@ static void epoll_init(ECS_State *cs) { #endif static void send_keep_alive_msg(ECS_Client *clii) { - send_to_client(clii->client_fd, keepalive_buf, payloadsize); + send_to_single_client(clii, keepalive_buf, payloadsize); } static void make_keep_alive_msg(void) { @@ -851,6 +870,7 @@ bool handle_protobuf_msg(ECS_Client* cli, char* data, int len) } else if (master->type == ECS__MASTER__TYPE__DEVICE_REQ) { + cli->client_type = TYPE_ECP; ECS__DeviceReq* msg = master->device_req; if (!msg) goto fail; @@ -861,6 +881,35 @@ bool handle_protobuf_msg(ECS_Client* cli, char* data, int len) ECS__NfcReq* msg = master->nfc_req; if (!msg) goto fail; + + pthread_mutex_lock(&mutex_clilist); + if(cli->client_type == TYPE_NONE) { + if (!strncmp(msg->category, MSG_TYPE_NFC, 3)) { + QTAILQ_REMOVE(&clients, cli, next); + cli->client_type = TYPE_ECP; + if(g_client_id > 255) { + g_client_id = 1; + } + cli->client_id = g_client_id++; + + QTAILQ_INSERT_TAIL(&clients, cli, next); + } + else if (!strncmp(msg->category, MSG_TYPE_SIMUL_NFC, 9)) { + QTAILQ_REMOVE(&clients, cli, next); + cli->client_type = TYPE_SIMUL_NFC; + if(g_client_id > 255) { + g_client_id = 1; + } + cli->client_id = g_client_id++; + QTAILQ_INSERT_TAIL(&clients, cli, next); + } + else { + LOG("unsupported category is found: %s", msg->category); + goto fail; + } + } + pthread_mutex_unlock(&mutex_clilist); + msgproc_nfc_req(cli, msg); } #if 0 diff --git a/tizen/src/ecs/ecs.h b/tizen/src/ecs/ecs.h index 8f874cc..c006383 100644 --- a/tizen/src/ecs/ecs.h +++ b/tizen/src/ecs/ecs.h @@ -81,6 +81,7 @@ #define MSG_TYPE_SENSOR "sensor" #define MSG_TYPE_NFC "nfc" +#define MSG_TYPE_SIMUL_NFC "simul_nfc" #define MSG_GROUP_STATUS 15 @@ -109,7 +110,7 @@ typedef unsigned char type_action; #define OUT_BUF_SIZE 4096 #define READ_BUF_LEN 4096 - +#define MAX_ID_SIZE 255 typedef struct sbuf { int _netlen; @@ -144,9 +145,14 @@ typedef struct ECS_State { Monitor *mon; } ECS_State; +#define TYPE_NONE 0x00 +#define TYPE_ECP 0x01 +#define TYPE_SIMUL_NFC 0x02 + typedef struct ECS_Client { - int client_fd; - int client_id; + unsigned char client_fd; + unsigned char client_id; + unsigned char client_type; int keep_alive; const char* type; @@ -157,11 +163,21 @@ typedef struct ECS_Client { QTAILQ_ENTRY(ECS_Client) next; } ECS_Client; +#define MAX_BUF_SIZE 255 + +typedef struct nfc_msg_info { + unsigned char client_id; + unsigned char client_type; + uint32_t use; + unsigned char buf[MAX_BUF_SIZE]; + +}nfc_msg_info; int start_ecs(void); int stop_ecs(void); int get_ecs_port(void); +ECS_Client *find_client(unsigned char id, unsigned char type); bool handle_protobuf_msg(ECS_Client* cli, char* data, const int len); bool ntf_to_injector(const char* data, const int len); @@ -173,10 +189,11 @@ bool send_to_ecp(ECS__Master* master); bool send_injector_ntf(const char* data, const int len); bool send_monitor_ntf(const char* data, const int len); bool send_device_ntf(const char* data, const int len); -bool send_nfc_ntf(const char* data, const int len); +bool send_nfc_ntf(struct nfc_msg_info *msg); +void send_to_single_client(ECS_Client *clii, const char* data, const int len); bool send_to_all_client(const char* data, const int len); -void send_to_client(int fd, const char* data, const int len) ; +void send_to_client(int fd, const char* data, const int len); void ecs_client_close(ECS_Client* clii); int ecs_write(int fd, const uint8_t *buf, int len); diff --git a/tizen/src/ecs/ecs_mon.c b/tizen/src/ecs/ecs_mon.c index 15a0d0f..a7880e2 100644 --- a/tizen/src/ecs/ecs_mon.c +++ b/tizen/src/ecs/ecs_mon.c @@ -691,16 +691,17 @@ static bool device_command_proc(ECS_Client *clii, QObject *obj) { set_sensor_data(length, data); } } - else if (!strncmp(cmd, MSG_TYPE_NFC, 3)) { - if (group == MSG_GROUP_STATUS) { - send_to_nfc(request_nfc_get, data, length); - } - else - { - send_to_nfc(request_nfc_set, data, length); - } - } - + /* + else if (!strncmp(cmd, MSG_TYPE_NFC, 3)) { + if (group == MSG_GROUP_STATUS) { + send_to_nfc(request_nfc_get, data, length); + } + else + { + send_to_nfc(request_nfc_set, data, length); + } + } + */ return true; } diff --git a/tizen/src/ecs/ecs_msg.c b/tizen/src/ecs/ecs_msg.c index 0472143..9a9e39c 100644 --- a/tizen/src/ecs/ecs_msg.c +++ b/tizen/src/ecs/ecs_msg.c @@ -82,6 +82,25 @@ static void* build_master(ECS__Master* master, int* payloadsize) return buf; } +static bool send_single_msg(ECS__Master* master, ECS_Client *clii) +{ + int payloadsize = 0; + void* buf = build_master(master, &payloadsize); + if (!buf) + { + LOG("invalid buf"); + return false; + } + + send_to_single_client(clii, buf, payloadsize); + + if (buf) + { + g_free(buf); + } + return true; +} + bool send_to_ecp(ECS__Master* master) { int payloadsize = 0; @@ -122,9 +141,32 @@ static bool send_to_single_client(ECS__Master* master, ECS_Client *ccli) return true; } #endif +static void msgproc_injector_ans(ECS_Client* ccli, const char* category, bool succeed) +{ + int catlen = 0; + ECS__Master master = ECS__MASTER__INIT; + ECS__InjectorAns ans = ECS__INJECTOR_ANS__INIT; + + LOG("injector ans - category : %s, succed : %d", category, succeed); + + catlen = strlen(category); + ans.category = (char*) g_malloc0(catlen + 1); + memcpy(ans.category, category, catlen); + + ans.errcode = !succeed; + master.type = ECS__MASTER__TYPE__INJECTOR_ANS; + master.injector_ans = &ans; + + send_single_msg(&master, ccli); + + if (ans.category) + g_free(ans.category); +} + bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg) { char cmd[10]; + bool ret = false; memset(cmd, 0, 10); strcpy(cmd, msg->category); type_length length = (type_length) msg->length; @@ -146,7 +188,7 @@ bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg) int sndlen = datalen + 14; char* sndbuf = (char*) g_malloc(sndlen + 1); if (!sndbuf) { - return false; + goto injector_req_fail; } memset(sndbuf, 0, sndlen + 1); @@ -168,11 +210,19 @@ bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg) } } - send_to_evdi(route_ij, sndbuf, sndlen); + ret = send_to_evdi(route_ij, sndbuf, sndlen); g_free(sndbuf); + if (!ret) + goto injector_req_fail; + + msgproc_injector_ans(ccli, cmd, ret); return true; + +injector_req_fail: + msgproc_injector_ans(ccli, cmd, ret); + return false; } #if 0 void msgproc_checkversion_req(ECS_Client* ccli, ECS__CheckVersionReq* msg) @@ -292,14 +342,6 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg) } do_host_kbd_enable(is_on); } - } else if (!strncmp(cmd, MSG_TYPE_NFC, 3)) { - if (group == MSG_GROUP_STATUS) { - send_to_nfc(request_nfc_get, data, length); - } - else - { - send_to_nfc(request_nfc_set, data, length); - } } if (data) @@ -310,25 +352,28 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg) bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg) { - char cmd[10]; - char* data = NULL; - memset(cmd, 0, 10); - strcpy(cmd, msg->category); + int datalen = msg->data.len; + void* data = (void*)g_malloc(datalen); + if(!data) { + LOG("g_malloc failed!"); + return false; + } + + memset(data, 0, datalen); + memcpy(data, msg->data.data, msg->data.len); if (msg->has_data && msg->data.len > 0) { - data = (char*)msg->data.data; - printf("recv from nfc injector: "); - print_binary(data, data[1] + 2); + LOG("recv from nfc injector: "); + print_binary(data, datalen); } - if (!strncmp(cmd, MSG_TYPE_NFC, 3)) { - if (data != NULL) { - send_to_nfc(request_nfc_set, data, msg->data.len); - } + if (data != NULL) { + send_to_nfc(ccli->client_id, ccli->client_type, data, msg->data.len); + return true; } - return true; + return false; } bool ntf_to_injector(const char* data, const int len) { @@ -507,17 +552,29 @@ bool send_device_ntf(const char* data, const int len) return true; } -bool send_nfc_ntf(const char* data, const int len) +bool send_nfc_ntf(struct nfc_msg_info* msg) { const int catsize = 10; char cat[catsize + 1]; + ECS_Client *clii; memset(cat, 0, catsize + 1); - read_val_str(data, cat, catsize); - - const char* ijdata = data + catsize; - - LOG("header category = %s", cat); + print_binary((char*)msg->buf, msg->use); + LOG("id: %02x, type: %02x, use: %d", msg->client_id, msg->client_type, msg->use); + clii = find_client(msg->client_id, msg->client_type); + if (clii) { + if(clii->client_type == TYPE_SIMUL_NFC) { + strncpy(cat, MSG_TYPE_NFC, 3); + } else if (clii->client_type == TYPE_ECP) { + strncpy(cat, MSG_TYPE_SIMUL_NFC, 9); + }else { + LOG("cannot find type!"); + } + LOG("header category = %s", cat); + } + else { + LOG("cannot find client!"); + } ECS__Master master = ECS__MASTER__INIT; ECS__NfcNtf ntf = ECS__NFC_NTF__INIT; @@ -529,15 +586,13 @@ bool send_nfc_ntf(const char* data, const int len) ntf.data.data = g_malloc(MAX_BUF_SIZE); ntf.data.len = MAX_BUF_SIZE; - memcpy(ntf.data.data, ijdata, MAX_BUF_SIZE); + memcpy(ntf.data.data, msg->buf, MAX_BUF_SIZE); - LOG("length = %d", len); printf("send to nfc injector: "); - print_binary(ijdata, ijdata[1] + 2); master.type = ECS__MASTER__TYPE__NFC_NTF; master.nfc_ntf = &ntf; - send_to_ecp(&master); + send_single_msg(&master, clii); if (ntf.data.data && ntf.data.len > 0) { diff --git a/tizen/src/ecs/genmsg/ecs.pb-c.c b/tizen/src/ecs/genmsg/ecs.pb-c.c index b5a05d3..e8a2a15 100644 --- a/tizen/src/ecs/genmsg/ecs.pb-c.c +++ b/tizen/src/ecs/genmsg/ecs.pb-c.c @@ -949,7 +949,7 @@ const ProtobufCMessageDescriptor ecs__injector_req__descriptor = (ProtobufCMessageInit) ecs__injector_req__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor ecs__injector_ans__field_descriptors[7] = +static const ProtobufCFieldDescriptor ecs__injector_ans__field_descriptors[3] = { { "errcode", @@ -987,68 +987,16 @@ static const ProtobufCFieldDescriptor ecs__injector_ans__field_descriptors[7] = 0, /* packed */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, - { - "length", - 4, - PROTOBUF_C_LABEL_REQUIRED, - PROTOBUF_C_TYPE_INT32, - 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorAns, length), - NULL, - NULL, - 0, /* packed */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "group", - 5, - PROTOBUF_C_LABEL_REQUIRED, - PROTOBUF_C_TYPE_INT32, - 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorAns, group), - NULL, - NULL, - 0, /* packed */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "action", - 6, - PROTOBUF_C_LABEL_REQUIRED, - PROTOBUF_C_TYPE_INT32, - 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorAns, action), - NULL, - NULL, - 0, /* packed */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "data", - 7, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__InjectorAns, has_data), - PROTOBUF_C_OFFSETOF(ECS__InjectorAns, data), - NULL, - NULL, - 0, /* packed */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, }; static const unsigned ecs__injector_ans__field_indices_by_name[] = { - 5, /* field[5] = action */ 2, /* field[2] = category */ - 6, /* field[6] = data */ 0, /* field[0] = errcode */ 1, /* field[1] = errstr */ - 4, /* field[4] = group */ - 3, /* field[3] = length */ }; static const ProtobufCIntRange ecs__injector_ans__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 7 } + { 0, 3 } }; const ProtobufCMessageDescriptor ecs__injector_ans__descriptor = { @@ -1058,7 +1006,7 @@ const ProtobufCMessageDescriptor ecs__injector_ans__descriptor = "ECS__InjectorAns", "ECS", sizeof(ECS__InjectorAns), - 7, + 3, ecs__injector_ans__field_descriptors, ecs__injector_ans__field_indices_by_name, 1, ecs__injector_ans__number_ranges, diff --git a/tizen/src/ecs/genmsg/ecs.pb-c.h b/tizen/src/ecs/genmsg/ecs.pb-c.h index a7ef93c..f3449dc 100644 --- a/tizen/src/ecs/genmsg/ecs.pb-c.h +++ b/tizen/src/ecs/genmsg/ecs.pb-c.h @@ -95,15 +95,10 @@ struct _ECS__InjectorAns int32_t errcode; char *errstr; char *category; - int32_t length; - int32_t group; - int32_t action; - protobuf_c_boolean has_data; - ProtobufCBinaryData data; }; #define ECS__INJECTOR_ANS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&ecs__injector_ans__descriptor) \ - , 0, NULL, NULL, 0, 0, 0, 0,{0,NULL} } + , 0, NULL, NULL } struct _ECS__InjectorNtf diff --git a/tizen/src/ecs/msg/ecs.proto b/tizen/src/ecs/msg/ecs.proto index ad7fa07..a00e6ff 100644 --- a/tizen/src/ecs/msg/ecs.proto +++ b/tizen/src/ecs/msg/ecs.proto @@ -35,10 +35,6 @@ message InjectorAns { required int32 errcode = 1; optional string errstr = 2; required string category = 3; - required int32 length = 4; - required int32 group = 5; - required int32 action = 6; - optional bytes data = 7; } message InjectorNtf { diff --git a/tizen/src/hw/maru_virtio_nfc.c b/tizen/src/hw/maru_virtio_nfc.c index aaccc8b..bb1fcf4 100755 --- a/tizen/src/hw/maru_virtio_nfc.c +++ b/tizen/src/hw/maru_virtio_nfc.c @@ -36,7 +36,6 @@ MULTI_DEBUG_CHANNEL(qemu, virtio-nfc); #define NFC_DEVICE_NAME "virtio-nfc" -#define MAX_BUF_SIZE 255 enum { IOTYPE_INPUT = 0, @@ -50,34 +49,18 @@ enum { VirtIONFC* vio_nfc; - -typedef unsigned int CSCliSN; - -typedef struct msg_info { - char buf[MAX_BUF_SIZE]; - - uint32_t route; - uint32_t use; - uint16_t count; - uint16_t index; - - CSCliSN cclisn; -}msg_info; - -// - typedef struct MsgInfo { - msg_info info; + nfc_msg_info info; QTAILQ_ENTRY(MsgInfo) next; }MsgInfo; static QTAILQ_HEAD(MsgInfoRecvHead , MsgInfo) nfc_recv_msg_queue = - QTAILQ_HEAD_INITIALIZER(nfc_recv_msg_queue); +QTAILQ_HEAD_INITIALIZER(nfc_recv_msg_queue); static QTAILQ_HEAD(MsgInfoSendHead , MsgInfo) nfc_send_msg_queue = - QTAILQ_HEAD_INITIALIZER(nfc_send_msg_queue); +QTAILQ_HEAD_INITIALIZER(nfc_send_msg_queue); // @@ -89,24 +72,23 @@ typedef struct NFCBuf { } NFCBuf; static QTAILQ_HEAD(NFCMsgHead , NFCBuf) nfc_in_queue = - QTAILQ_HEAD_INITIALIZER(nfc_in_queue); - -static int count = 0; +QTAILQ_HEAD_INITIALIZER(nfc_in_queue); static pthread_mutex_t recv_buf_mutex = PTHREAD_MUTEX_INITIALIZER; -bool send_to_nfc(enum request_cmd_nfc req, const char* data, const uint32_t len) +bool send_to_nfc(unsigned char id, unsigned char type, const char* data, const uint32_t len) { MsgInfo* _msg = (MsgInfo*) malloc(sizeof(MsgInfo)); if (!_msg) return false; - memset(&_msg->info, 0, sizeof(msg_info)); + memset(&_msg->info, 0, sizeof(nfc_msg_info)); memcpy(_msg->info.buf, data, len); _msg->info.use = len; - _msg->info.index = count++; - _msg->info.route = req; + _msg->info.client_id = id; + _msg->info.client_type = type; + pthread_mutex_lock(&recv_buf_mutex); QTAILQ_INSERT_TAIL(&nfc_recv_msg_queue, _msg, next); @@ -140,31 +122,31 @@ static void flush_nfc_recv_queue(void) while (!QTAILQ_EMPTY(&nfc_recv_msg_queue)) { - MsgInfo* msginfo = QTAILQ_FIRST(&nfc_recv_msg_queue); - if (!msginfo) - break; + MsgInfo* msginfo = QTAILQ_FIRST(&nfc_recv_msg_queue); + if (!msginfo) + break; - VirtQueueElement elem; - index = virtqueue_pop(vio_nfc->rvq, &elem); - if (index == 0) - { - //ERR("unexpected empty queue"); - break; - } + VirtQueueElement elem; + index = virtqueue_pop(vio_nfc->rvq, &elem); + if (index == 0) + { + //ERR("unexpected empty queue"); + break; + } - INFO(">> virtqueue_pop. index: %d, out_num : %d, in_num : %d\n", index, elem.out_num, elem.in_num); + INFO(">> virtqueue_pop. index: %d, out_num : %d, in_num : %d\n", index, elem.out_num, elem.in_num); - memcpy(elem.in_sg[0].iov_base, &msginfo->info, sizeof(struct msg_info)); + memcpy(elem.in_sg[0].iov_base, &msginfo->info, sizeof(struct nfc_msg_info)); - INFO(">> send to guest count = %d, use = %d, msg = %s, iov_len = %d \n", - ++g_cnt, msginfo->info.use, msginfo->info.buf, elem.in_sg[0].iov_len); + INFO(">> send to guest count = %d, use = %d, msg = %s, iov_len = %d \n", + ++g_cnt, msginfo->info.use, msginfo->info.buf, elem.in_sg[0].iov_len); - virtqueue_push(vio_nfc->rvq, &elem, sizeof(msg_info)); - virtio_notify(&vio_nfc->vdev, vio_nfc->rvq); + virtqueue_push(vio_nfc->rvq, &elem, sizeof(nfc_msg_info)); + virtio_notify(&vio_nfc->vdev, vio_nfc->rvq); - QTAILQ_REMOVE(&nfc_recv_msg_queue, msginfo, next); - if (msginfo) - free(msginfo); + QTAILQ_REMOVE(&nfc_recv_msg_queue, msginfo, next); + if (msginfo) + free(msginfo); } pthread_mutex_unlock(&recv_buf_mutex); @@ -177,37 +159,11 @@ static void virtio_nfc_recv(VirtIODevice *vdev, VirtQueue *vq) flush_nfc_recv_queue(); } -static void send_to_ecs(struct msg_info* msg) -{ - type_length length = 0; - - int buf_len = MAX_BUF_SIZE; - int message_len = buf_len + 10; - - char* ecs_message = (char*) malloc(message_len + 1); - if (!ecs_message) - return; - - memset(ecs_message, 0, message_len + 1); - - length = (unsigned short) buf_len; - - memcpy(ecs_message, "nfc", 10); - memcpy(ecs_message + 10, msg->buf, buf_len); - - INFO("ntf_to_injector- len: %d, data: %s\n", length , msg->buf); - - send_nfc_ntf(ecs_message, message_len); - - if (ecs_message) - free(ecs_message); -} - static void virtio_nfc_send(VirtIODevice *vdev, VirtQueue *vq) { VirtIONFC *vnfc = (VirtIONFC *)vdev; int index = 0; - struct msg_info _msg; + struct nfc_msg_info _msg; if (virtio_queue_empty(vnfc->svq)) { INFO("<< virtqueue is empty.\n"); @@ -225,14 +181,13 @@ static void virtio_nfc_send(VirtIODevice *vdev, VirtQueue *vq) break; } - INFO("<< use=%d, iov_len = %d\n", _msg.use, elem.out_sg[0].iov_len); + INFO("<< iov_len = %d\n", elem.out_sg[0].iov_len); memset(&_msg, 0x00, sizeof(_msg)); memcpy(&_msg, elem.out_sg[0].iov_base, elem.out_sg[0].iov_len); INFO("<< recv from guest len = %d, msg = %s \n", _msg.use, _msg.buf); - - send_to_ecs(&_msg); + send_nfc_ntf(&_msg); } @@ -241,7 +196,7 @@ static void virtio_nfc_send(VirtIODevice *vdev, VirtQueue *vq) } static uint32_t virtio_nfc_get_features(VirtIODevice *vdev, - uint32_t request_feature) + uint32_t request_feature) { TRACE("virtio_nfc_get_features.\n"); return 0; @@ -278,8 +233,8 @@ static int virtio_nfc_exit(DeviceState* dev) VirtIODevice *vdev = VIRTIO_DEVICE(dev); if (vio_nfc->bh) { - qemu_bh_delete(vio_nfc->bh); - } + qemu_bh_delete(vio_nfc->bh); + } virtio_cleanup(vdev); @@ -302,8 +257,6 @@ static void virtio_nfc_class_init(ObjectClass *klass, void *data) vdc->reset = virtio_nfc_reset; } - - static const TypeInfo virtio_device_info = { .name = TYPE_VIRTIO_NFC, .parent = TYPE_VIRTIO_DEVICE, diff --git a/tizen/src/hw/maru_virtio_nfc.h b/tizen/src/hw/maru_virtio_nfc.h index ae6f16e..17c539a 100755 --- a/tizen/src/hw/maru_virtio_nfc.h +++ b/tizen/src/hw/maru_virtio_nfc.h @@ -62,8 +62,7 @@ typedef struct VirtIONFC{ OBJECT_CHECK(VirtIONFC, (obj), TYPE_VIRTIO_NFC) -bool send_to_nfc(enum request_cmd_nfc req, const char* data, const uint32_t len); - +bool send_to_nfc(unsigned char id, unsigned char type, const char* data, const uint32_t len); #ifdef __cplusplus } -- 2.7.4