2 * Virtio general purpose interface
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
7 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
8 * DongKyun Yun <dk77.yun@samsung.com>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 #define _XOPEN_SOURCE 600
36 #include "qemu-common.h"
38 #include "helper_gpi.h"
41 #include "tizen/src/debug_ch.h"
42 MULTI_DEBUG_CHANNEL(qemu, gpi);
48 static struct object_ops *call_ops = NULL;
53 static int sync_sdb_port(char *args_in, int args_len, char *r_buffer, int r_len)
57 snprintf(tmp, sizeof(tmp)-1, "%d", get_sdb_base_port());
59 if( r_len < strlen(tmp) ){
60 ERR("short return buffer length [%d < %d(%s)] \n", r_len, strlen(tmp), tmp);
64 memcpy(r_buffer, tmp, strlen(tmp));
65 TRACE("sdb-port: => return [%s]\n", r_buffer);
70 static int dummy_function(char *args_in, int args_len, char *r_buffer, int r_len)
72 ERR("Need the specific operation \n");
77 static void do_call_init(void)
81 call_ops = qemu_mallocz(CAll_HANDLE_MAX*sizeof(object_ops_t) );
83 /* set dummy function */
84 for( i = 0; i < CAll_HANDLE_MAX ; i++ ) {
85 call_ops[i].ftn = &dummy_function;
89 call_ops[FTN_SYNC_SDB_PORT].ftn = &sync_sdb_port;
95 int call_gpi(int pid, int ftn_num, char *in_args, int args_len, char *r_buffer, int r_len)
100 TRACE("ftn_num(%d) args_len(%d) r_len(%d) \n", ftn_num, args_len, r_len);
107 ret = call_ops[ftn_num].ftn(in_args, args_len, r_buffer, r_len);
108 TRACE("return [%s]\n", r_buffer);