aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-06-27 12:58:30 +0200
committerPaul Kocialkowski <contact@paulk.fr>2013-06-27 12:58:30 +0200
commitb73c6cf5a94e1c7f9be38917f26da37e13fe452e (patch)
tree569586654512f79d70a1bb065b15b8f9f3373a0e /samsung-ipc
parent0916c6823f2af47257b09899ba62e44eb56eee72 (diff)
downloadhardware_replicant_libsamsung-ipc-b73c6cf5a94e1c7f9be38917f26da37e13fe452e.tar.gz
hardware_replicant_libsamsung-ipc-b73c6cf5a94e1c7f9be38917f26da37e13fe452e.tar.bz2
hardware_replicant_libsamsung-ipc-b73c6cf5a94e1c7f9be38917f26da37e13fe452e.zip
Rework handlers and ipc functions for better consistency
Detailed list of the changes introduced by this commit: * Rename ipc_client_bootstrap_modem to ipc_client_bootstrap * Rename ipc_client_new/free to ipc_client_create/destroy * Rename log_handler to log_callback and change arguments order * Remove handlers common data and fd mechanisms * Set transport, power and gprs common data for handlers * Add data_create and data_destroy handlers * Rework arguments order for handlers * Add poll transport handler * Remove functions types typedefs * Remove dumb ipc_client_send_* functions * Remove ipc_client_gprs_handlers_available * Adapt device files for the new API changes * Adapt modemctrl for the new API changes Change-Id: Ia9ba1045dbbf9f5e31a201aa8629b49019158972 Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/device/aries/aries_ipc.c350
-rw-r--r--samsung-ipc/device/aries/aries_ipc.h5
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.c271
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.h4
-rw-r--r--samsung-ipc/device/galaxys2/galaxys2_ipc.c36
-rw-r--r--samsung-ipc/device/galaxys2/galaxys2_loader.c2
-rw-r--r--samsung-ipc/device/galaxys2/galaxys2_loader.h2
-rw-r--r--samsung-ipc/device/maguro/maguro_ipc.c41
-rw-r--r--samsung-ipc/device/maguro/maguro_loader.c4
-rw-r--r--samsung-ipc/device/maguro/maguro_loader.h4
-rw-r--r--samsung-ipc/device/piranha/piranha_ipc.c30
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_ipc.c164
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_ipc.h33
-rw-r--r--samsung-ipc/ipc.c310
-rw-r--r--samsung-ipc/ipc.h51
-rw-r--r--samsung-ipc/ipc_devices.c74
-rw-r--r--samsung-ipc/ipc_devices.h47
17 files changed, 672 insertions, 756 deletions
diff --git a/samsung-ipc/device/aries/aries_ipc.c b/samsung-ipc/device/aries/aries_ipc.c
index 5c8705d..2986321 100644
--- a/samsung-ipc/device/aries/aries_ipc.c
+++ b/samsung-ipc/device/aries/aries_ipc.c
@@ -1,10 +1,10 @@
-/**
+/*
* This file is part of libsamsung-ipc.
*
- * Copyright (C) 2011 Paul Kocialkowski <contact@paulk.fr>
- * Joerie de Gram <j.de.gram@gmail.com>
- * Simon Busch <morphis@gravedo.de>
- * Igor Almeida <igor.contato@gmail.com>
+ * Copyright (C) 2011-2013 Paul Kocialkowski <contact@paulk.fr>
+ * Copyright (C) 2011 Simon Busch <morphis@gravedo.de>
+ * Copyright (C) 2011 Igor Almeida <igor.contato@gmail.com>
+ * Copyright (C) 2011 Joerie de Gram <j.de.gram@gmail.com>
*
* libsamsung-ipc is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#include <stdlib.h>
@@ -100,7 +101,7 @@ int phonet_iface_ifup(void)
return 0;
}
-int aries_modem_bootstrap(struct ipc_client *client)
+int aries_ipc_bootstrap(struct ipc_client *client)
{
int s3c2410_serial3_fd = -1;
int onedram_fd = -1;
@@ -412,7 +413,7 @@ exit:
return rc;
}
-int aries_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request)
+int aries_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request)
{
struct ipc_header reqhdr;
void *data;
@@ -434,36 +435,11 @@ int aries_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info
ipc_client_log_send(client, request, __func__);
- rc = client->handlers->write(data, reqhdr.length, client->handlers->write_data);
+ rc = client->handlers->write(client->handlers->transport_data, data, reqhdr.length);
return rc;
}
-int aries_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info *request)
-{
- struct rfs_hdr *rfs_hdr;
- void *data;
- int rc = 0;
-
- data = malloc(request->length + sizeof(struct rfs_hdr));
- memset(data, 0, request->length + sizeof(struct rfs_hdr));
-
- rfs_hdr = (struct rfs_hdr *) data;
-
- rfs_hdr->id = request->mseq;
- rfs_hdr->cmd = request->index;
- rfs_hdr->len = request->length + sizeof(struct rfs_hdr);
-
- memcpy((void *) (data + sizeof(struct rfs_hdr)), request->data, request->length);
-
- assert(client->handlers->write != NULL);
-
- ipc_client_log_send(client, request, __func__);
-
- rc = client->handlers->write((uint8_t*) data, rfs_hdr->len, client->handlers->write_data);
- return rc;
-}
-
-int aries_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info *response)
+int aries_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response)
{
struct ipc_header *resphdr;
void *data;
@@ -475,7 +451,7 @@ int aries_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info
memset(response, 0, sizeof(struct ipc_message_info));
assert(client->handlers->read != NULL);
- bread = client->handlers->read((uint8_t*) data, MAX_MODEM_DATA_SIZE, client->handlers->read_data);
+ bread = client->handlers->read(client->handlers->transport_data, (uint8_t*) data, MAX_MODEM_DATA_SIZE);
if (bread < 0)
{
@@ -513,7 +489,32 @@ int aries_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info
return 0;
}
-int aries_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info *response)
+int aries_ipc_rfs_send(struct ipc_client *client, struct ipc_message_info *request)
+{
+ struct rfs_hdr *rfs_hdr;
+ void *data;
+ int rc = 0;
+
+ data = malloc(request->length + sizeof(struct rfs_hdr));
+ memset(data, 0, request->length + sizeof(struct rfs_hdr));
+
+ rfs_hdr = (struct rfs_hdr *) data;
+
+ rfs_hdr->id = request->mseq;
+ rfs_hdr->cmd = request->index;
+ rfs_hdr->len = request->length + sizeof(struct rfs_hdr);
+
+ memcpy((void *) (data + sizeof(struct rfs_hdr)), request->data, request->length);
+
+ assert(client->handlers->write != NULL);
+
+ ipc_client_log_send(client, request, __func__);
+
+ rc = client->handlers->write(client->handlers->transport_data, (uint8_t*) data, rfs_hdr->len);
+ return rc;
+}
+
+int aries_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *response)
{
void *data;
int bread = 0;
@@ -525,7 +526,7 @@ int aries_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info
memset(response, 0, sizeof(struct ipc_message_info));
assert(client->handlers->read != NULL);
- bread = client->handlers->read((uint8_t*) data, MAX_MODEM_DATA_SIZE, client->handlers->read_data);
+ bread = client->handlers->read(client->handlers->transport_data, (uint8_t*) data, MAX_MODEM_DATA_SIZE);
if (bread < 0)
{
ipc_client_log(client, "aries_ipc_rfs_client_recv: can't receive enough bytes from modem to process incoming response!");
@@ -561,31 +562,27 @@ int aries_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info
return 0;
}
-int aries_ipc_open(int type, void *io_data)
+int aries_ipc_open(void *transport_data, int type)
{
- struct aries_ipc_handlers_common_data *common_data;
+ struct aries_ipc_transport_data *data;
struct sockaddr_pn *spn;
struct ifreq ifr;
int reuse;
int socket_rfs_magic;
- int fd = -1;
+ int fd;
int rc;
- if(io_data == NULL)
- goto error;
+ if (transport_data == NULL)
+ return -1;
- common_data = (struct aries_ipc_handlers_common_data *) io_data;
- spn = common_data->spn;
+ data = (struct aries_ipc_transport_data *) transport_data;
+ memset(data, 0, sizeof(struct aries_ipc_transport_data));
- if(spn == NULL)
- goto error;
+ spn = &data->spn;
memset(&ifr, 0, sizeof(ifr));
- memset(ifr.ifr_name, 0, IFNAMSIZ);
- memset(spn, 0, sizeof(struct sockaddr_pn));
-
strncpy(ifr.ifr_name, PHONET_IFACE, IFNAMSIZ);
spn->spn_family = AF_PHONET;
@@ -609,56 +606,50 @@ int aries_ipc_open(int type, void *io_data)
rc = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, ifr.ifr_name, IFNAMSIZ);
if(rc < 0)
- goto error;
+ return -1;
rc = ioctl(fd, SIOCGIFINDEX, &ifr);
if(rc < 0)
- goto error;
+ return -1;
reuse = 1;
rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
if(rc < 0)
- goto error;
+ return -1;
rc = bind(fd, spn, sizeof(struct sockaddr_pn));
if(rc < 0)
- goto error;
+ return -1;
- common_data->fd = fd;
+ data->fd = fd;
if(type == IPC_CLIENT_TYPE_RFS)
{
socket_rfs_magic = SOCKET_RFS_MAGIC;
rc = setsockopt(fd, SOL_SOCKET, SO_RFSMAGIC, &socket_rfs_magic, sizeof(socket_rfs_magic));
if(rc < 0)
- goto error;
+ return -1;
}
rc = phonet_iface_ifup();
if(rc < 0)
- goto error;
-
- goto end;
-
-error:
- return -1;
+ return -1;
-end:
return 0;
}
-int aries_ipc_close(void *io_data)
+int aries_ipc_close(void *transport_data)
{
- struct aries_ipc_handlers_common_data *common_data;
- int fd = -1;
+ struct aries_ipc_transport_data *data;
+ int fd;
- if(io_data == NULL)
+ if (transport_data == NULL)
return -1;
- common_data = (struct aries_ipc_handlers_common_data *) io_data;
- fd = common_data->fd;
+ data = (struct aries_ipc_transport_data *) transport_data;
- if(fd < 0)
+ fd = data->fd;
+ if (fd < 0)
return -1;
close(fd);
@@ -666,68 +657,84 @@ int aries_ipc_close(void *io_data)
return 0;
}
-int aries_ipc_read(void *data, unsigned int size, void *io_data)
+int aries_ipc_read(void *transport_data, void *buffer, unsigned int length)
{
- struct aries_ipc_handlers_common_data *common_data;
- int spn_len;
- int fd = -1;
+ struct aries_ipc_transport_data *data;
+ int spn_size;
+ int fd;
int rc;
- if(io_data == NULL)
+ if (transport_data == NULL || buffer == NULL)
return -1;
- if(data == NULL)
- return -1;
-
- common_data = (struct aries_ipc_handlers_common_data *) io_data;
- fd = common_data->fd;
+ data = (struct aries_ipc_transport_data *) transport_data;
- if(fd < 0)
+ fd = data->fd;
+ if (fd < 0)
return -1;
- spn_len = sizeof(struct sockaddr_pn);
- rc = recvfrom(fd, data, size, 0, common_data->spn, &spn_len);
+ spn_size = sizeof(struct sockaddr_pn);
- if(rc < 0)
+ rc = recvfrom(fd, buffer, length, 0, &data->spn, &spn_size);
+ if (rc < 0)
return -1;
return 0;
}
-int aries_ipc_write(void *data, unsigned int size, void *io_data)
+int aries_ipc_write(void *transport_data, void *buffer, unsigned int length)
{
- struct aries_ipc_handlers_common_data *common_data;
- int spn_len;
- int fd = -1;
+ struct aries_ipc_transport_data *data;
+ int spn_size;
+ int fd;
int rc;
- if(io_data == NULL)
+ if (transport_data == NULL || buffer == NULL)
return -1;
- if(data == NULL)
+ data = (struct aries_ipc_transport_data *) transport_data;
+
+ fd = data->fd;
+ if (fd < 0)
return -1;
- common_data = (struct aries_ipc_handlers_common_data *) io_data;
- fd = common_data->fd;
+ spn_size = sizeof(struct sockaddr_pn);
- if(fd < 0)
+ rc = sendto(fd, buffer, length, 0, &data->spn, spn_size);
+ if (rc < 0)
return -1;
- spn_len = sizeof(struct sockaddr_pn);
+ return 0;
+}
- rc = sendto(fd, data, size, 0, common_data->spn, spn_len);
+int aries_ipc_poll(void *transport_data, struct timeval *timeout)
+{
+ struct aries_ipc_transport_data *data;
+ fd_set fds;
+ int fd;
+ int rc;
- if(rc < 0)
+ if (transport_data == NULL)
return -1;
- return 0;
+ data = (struct aries_ipc_transport_data *) transport_data;
+
+ fd = data->fd;
+ if (fd < 0)
+ return -1;
+
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+
+ rc = select(FD_SETSIZE, &fds, NULL, NULL, timeout);
+ return rc;
}
-int aries_ipc_power_on(void *data)
+int aries_ipc_power_on(void *power_data)
{
int fd = open("/sys/class/modemctl/xmm/status", O_RDONLY);
char status[1] = { 0 };
- char power_data[4] = "on";
+ char data[4] = "on";
int rc;
if(fd < 0)
@@ -748,7 +755,7 @@ int aries_ipc_power_on(void *data)
if(fd < 0)
return -1;
- rc = write(fd, power_data, 2);
+ rc = write(fd, data, 2);
close(fd);
@@ -758,11 +765,11 @@ int aries_ipc_power_on(void *data)
return 0;
}
-int aries_ipc_power_off(void *data)
+int aries_ipc_power_off(void *power_data)
{
int fd = open("/sys/class/modemctl/xmm/status", O_RDONLY);
char status[1] = { 0 };
- char power_data[5] = "off";
+ char data[5] = "off";
int rc;
if(fd < 0)
@@ -783,7 +790,7 @@ int aries_ipc_power_off(void *data)
if(fd < 0)
return -1;
- rc = write(fd, power_data, 3);
+ rc = write(fd, data, 3);
close(fd);
@@ -793,9 +800,7 @@ int aries_ipc_power_off(void *data)
return 0;
}
-//TODO: there are also suspend/resume nodes
-
-int aries_ipc_gprs_activate(void *data, int cid)
+int aries_ipc_gprs_activate(void *gprs_data, int cid)
{
int fd = open("/sys/class/net/svnet0/pdp/activate", O_RDWR);
char *activate_data = NULL;
@@ -820,7 +825,7 @@ int aries_ipc_gprs_activate(void *data, int cid)
}
-int aries_ipc_gprs_deactivate(void *data, int cid)
+int aries_ipc_gprs_deactivate(void *gprs_data, int cid)
{
int fd = open("/sys/class/net/svnet0/pdp/deactivate", O_RDWR);
char *deactivate_data = NULL;
@@ -844,6 +849,27 @@ int aries_ipc_gprs_deactivate(void *data, int cid)
return 0;
}
+int aries_ipc_data_create(void **transport_data, void **power_data, void **gprs_data)
+{
+ if (transport_data == NULL)
+ return -1;
+
+ *transport_data = (void *) malloc(sizeof(struct aries_ipc_transport_data));
+ memset(*transport_data, 0, sizeof(struct aries_ipc_transport_data));
+
+ return 0;
+}
+
+int aries_ipc_data_destroy(void *transport_data, void *power_data, void *gprs_data)
+{
+ if (transport_data == NULL)
+ return -1;
+
+ free(transport_data);
+
+ return 0;
+}
+
char *aries_ipc_gprs_get_iface(int cid)
{
struct ifreq ifr;
@@ -871,117 +897,47 @@ char *aries_ipc_gprs_get_iface(int cid)
return NULL;
}
-int aries_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap)
+int aries_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *capabilities)
{
- if (cap == NULL)
+ if (capabilities == NULL)
return -1;
- cap->port_list = 1;
- cap->cid_max = GPRS_IFACE_COUNT;
+ capabilities->port_list = 1;
+ capabilities->cid_max = GPRS_IFACE_COUNT;
return 0;
}
-void *aries_ipc_common_data_create(void)
-{
- struct aries_ipc_handlers_common_data *common_data;
- void *io_data;
- int io_data_len;
- int spn_len;
-
- io_data_len = sizeof(struct aries_ipc_handlers_common_data);
- io_data = malloc(io_data_len);
-
- if(io_data == NULL)
- return NULL;
-
- memset(io_data, 0, io_data_len);
-
- common_data = (struct aries_ipc_handlers_common_data *) io_data;
-
- spn_len = sizeof(struct sockaddr_pn);
- common_data->spn = malloc(spn_len);
-
- if(common_data == NULL)
- return NULL;
-
- memset(common_data->spn, 0, spn_len);
-
- return io_data;
-}
-
-int aries_ipc_common_data_destroy(void *io_data)
-{
- struct aries_ipc_handlers_common_data *common_data;
-
- // This was already done, not an error but we need to return
- if(io_data == NULL)
- return 0;
-
- common_data = (struct aries_ipc_handlers_common_data *) io_data;
-
- if(common_data->spn != NULL)
- free(common_data->spn);
-
- free(io_data);
-
- return 0;
-}
-
-int aries_ipc_common_data_set_fd(void *io_data, int fd)
-{
- struct aries_ipc_handlers_common_data *common_data;
-
- if(io_data == NULL)
- return -1;
-
- common_data = (struct aries_ipc_handlers_common_data *) io_data;
- common_data->fd = fd;
-
- return 0;
-}
-
-int aries_ipc_common_data_get_fd(void *io_data)
-{
- struct aries_ipc_handlers_common_data *common_data;
-
- if(io_data == NULL)
- return -1;
-
- common_data = (struct aries_ipc_handlers_common_data *) io_data;
-
- return common_data->fd;
-}
-
-struct ipc_ops aries_fmt_ops = {
- .send = aries_ipc_fmt_client_send,
- .recv = aries_ipc_fmt_client_recv,
- .bootstrap = aries_modem_bootstrap,
+struct ipc_ops aries_ipc_fmt_ops = {
+ .bootstrap = aries_ipc_bootstrap,
+ .send = aries_ipc_fmt_send,
+ .recv = aries_ipc_fmt_recv,
};
-struct ipc_ops aries_rfs_ops = {
- .send = aries_ipc_rfs_client_send,
- .recv = aries_ipc_rfs_client_recv,
+struct ipc_ops aries_ipc_rfs_ops = {
.bootstrap = NULL,
+ .send = aries_ipc_rfs_send,
+ .recv = aries_ipc_rfs_recv,
};
-struct ipc_handlers aries_default_handlers = {
- .read = aries_ipc_read,
- .write = aries_ipc_write,
+struct ipc_handlers aries_ipc_handlers = {
.open = aries_ipc_open,
.close = aries_ipc_close,
+ .read = aries_ipc_read,
+ .write = aries_ipc_write,
+ .poll = aries_ipc_poll,
+ .transport_data = NULL,
.power_on = aries_ipc_power_on,
.power_off = aries_ipc_power_off,
+ .power_data = NULL,
.gprs_activate = aries_ipc_gprs_activate,
.gprs_deactivate = aries_ipc_gprs_deactivate,
- .common_data = NULL,
- .common_data_create = aries_ipc_common_data_create,
- .common_data_destroy = aries_ipc_common_data_destroy,
- .common_data_set_fd = aries_ipc_common_data_set_fd,
- .common_data_get_fd = aries_ipc_common_data_get_fd,
+ .gprs_data = NULL,
+ .data_create = aries_ipc_data_create,
+ .data_destroy = aries_ipc_data_destroy,
};
-struct ipc_gprs_specs aries_gprs_specs = {
+struct ipc_gprs_specs aries_ipc_gprs_specs = {
.gprs_get_iface = aries_ipc_gprs_get_iface,
.gprs_get_capabilities = aries_ipc_gprs_get_capabilities,
};
diff --git a/samsung-ipc/device/aries/aries_ipc.h b/samsung-ipc/device/aries/aries_ipc.h
index e313296..056fdfb 100644
--- a/samsung-ipc/device/aries/aries_ipc.h
+++ b/samsung-ipc/device/aries/aries_ipc.h
@@ -47,10 +47,9 @@
int phonet_iface_ifdown(void);
int phonet_iface_ifup(void);
-struct aries_ipc_handlers_common_data
-{
+struct aries_ipc_transport_data {
+ struct sockaddr_pn spn;
int fd;
- struct sockaddr_pn *spn;
};
#endif
diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c
index 6bef48a..c903e05 100644
--- a/samsung-ipc/device/crespo/crespo_ipc.c
+++ b/samsung-ipc/device/crespo/crespo_ipc.c
@@ -40,7 +40,7 @@
#include "crespo_ipc.h"
#include "ipc.h"
-int crespo_modem_bootstrap(struct ipc_client *client)
+int crespo_ipc_bootstrap(struct ipc_client *client)
{
int s3c2410_serial3_fd = -1;
int modem_ctl_fd = -1;
@@ -298,7 +298,7 @@ exit:
return rc;
}
-int crespo_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request)
+int crespo_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request)
{
struct modem_io modem_data;
struct ipc_header reqhdr;
@@ -323,34 +323,11 @@ int crespo_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_inf
ipc_client_log_send(client, request, __func__);
- rc = client->handlers->write((uint8_t*) &modem_data, sizeof(struct modem_io), client->handlers->write_data);
+ rc = client->handlers->write(client->handlers->transport_data, (uint8_t*) &modem_data, sizeof(struct modem_io));
return rc;
}
-int crespo_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info *request)
-{
- struct modem_io modem_data;
- int rc = 0;
-
- memset(&modem_data, 0, sizeof(struct modem_io));
-
- modem_data.id = request->mseq;
- modem_data.cmd = request->index;
-
- modem_data.size = request->length;
- modem_data.data = malloc(request->length);
-
- memcpy(modem_data.data, request->data, request->length);
-
- assert(client->handlers->write != NULL);
-
- ipc_client_log_send(client, request, __func__);
-
- rc = client->handlers->write((uint8_t*) &modem_data, sizeof(struct modem_io), client->handlers->write_data);
- return rc;
-}
-
-int crespo_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info *response)
+int crespo_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response)
{
struct modem_io modem_data;
struct ipc_header *resphdr;
@@ -365,7 +342,7 @@ int crespo_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_inf
wake_lock("secril_fmt-interface");
assert(client->handlers->read != NULL);
- bread = client->handlers->read((uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE, client->handlers->read_data);
+ bread = client->handlers->read(client->handlers->transport_data, (uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE);
if (bread < 0)
{
ipc_client_log(client, "crespo_ipc_fmt_client_recv: can't receive enough bytes from modem to process incoming response!");
@@ -404,7 +381,30 @@ int crespo_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_inf
return 0;
}
-int crespo_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info *response)
+int crespo_ipc_rfs_send(struct ipc_client *client, struct ipc_message_info *request)
+{
+ struct modem_io modem_data;
+ int rc = 0;
+
+ memset(&modem_data, 0, sizeof(struct modem_io));
+
+ modem_data.id = request->mseq;
+ modem_data.cmd = request->index;
+
+ modem_data.size = request->length;
+ modem_data.data = malloc(request->length);
+
+ memcpy(modem_data.data, request->data, request->length);
+
+ assert(client->handlers->write != NULL);
+
+ ipc_client_log_send(client, request, __func__);
+
+ rc = client->handlers->write(client->handlers->transport_data, (uint8_t*) &modem_data, sizeof(struct modem_io));
+ return rc;
+}
+
+int crespo_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *response)
{
struct modem_io modem_data;
int bread = 0;
@@ -418,7 +418,7 @@ int crespo_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_inf
wake_lock("secril_rfs-interface");
assert(client->handlers->read != NULL);
- bread = client->handlers->read((uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE, client->handlers->read_data);
+ bread = client->handlers->read(client->handlers->transport_data, (uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE);
if (bread < 0)
{
ipc_client_log(client, "crespo_ipc_rfs_client_recv: can't receive enough bytes from modem to process incoming response!");
@@ -454,9 +454,15 @@ int crespo_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_inf
return 0;
}
-int crespo_ipc_open(int type, void *io_data)
+int crespo_ipc_open(void *transport_data, int type)
{
- int fd = -1;
+ struct crespo_ipc_transport_data *data;
+ int fd;
+
+ if (transport_data == NULL)
+ return -1;
+
+ data = (struct crespo_ipc_transport_data *) transport_data;
switch(type)
{
@@ -467,30 +473,29 @@ int crespo_ipc_open(int type, void *io_data)
fd = open("/dev/modem_rfs", O_RDWR | O_NOCTTY | O_NONBLOCK);
break;
default:
- break;
+ return -1;
}
if(fd < 0)
return -1;
- if(io_data == NULL)
- return -1;
-
- memcpy(io_data, &fd, sizeof(int));
+ data->fd = fd;
return 0;
}
-int crespo_ipc_close(void *io_data)
+int crespo_ipc_close(void *transport_data)
{
- int fd = -1;
+ struct crespo_ipc_transport_data *data;
+ int fd;
- if(io_data == NULL)
+ if (transport_data == NULL)
return -1;
- fd = *((int *) io_data);
+ data = (struct crespo_ipc_transport_data *) transport_data;
- if(fd < 0)
+ fd = data->fd;
+ if (fd < 0)
return -1;
close(fd);
@@ -498,52 +503,74 @@ int crespo_ipc_close(void *io_data)
return 0;
}
-int crespo_ipc_read(void *data, unsigned int size, void *io_data)
+int crespo_ipc_read(void *transport_data, void *buffer, unsigned int length)
{
- int fd = -1;
+ struct crespo_ipc_transport_data *data;
+ int fd;
int rc;
- if(io_data == NULL)
+ if (transport_data == NULL)
return -1;
- if(data == NULL)
- return -1;
-
- fd = *((int *) io_data);
+ data = (struct crespo_ipc_transport_data *) transport_data;
- if(fd < 0)
+ fd = data->fd;
+ if (fd < 0)
return -1;
- rc = ioctl(fd, IOCTL_MODEM_RECV, data);
-
+ rc = ioctl(fd, IOCTL_MODEM_RECV, buffer);
if(rc < 0)
return -1;
return 0;
}
-int crespo_ipc_write(void *data, unsigned int size, void *io_data)
+int crespo_ipc_write(void *transport_data, void *buffer, unsigned int length)
{
- int fd = -1;
+ struct crespo_ipc_transport_data *data;
+ int fd;
int rc;
- if(io_data == NULL)
+ if (transport_data == NULL)
return -1;
- fd = *((int *) io_data);
+ data = (struct crespo_ipc_transport_data *) transport_data;
- if(fd < 0)
+ fd = data->fd;
+ if (fd < 0)
return -1;
- rc = ioctl(fd, IOCTL_MODEM_SEND, data);
-
+ rc = ioctl(fd, IOCTL_MODEM_SEND, buffer);
if(rc < 0)
return -1;
return 0;
}
-int crespo_ipc_power_on(void *io_data)
+int crespo_ipc_poll(void *transport_data, struct timeval *timeout)
+{
+ struct crespo_ipc_transport_data *data;
+ fd_set fds;
+ int fd;
+ int rc;
+
+ if (transport_data == NULL)
+ return -1;
+
+ data = (struct crespo_ipc_transport_data *) transport_data;
+
+ fd = data->fd;
+ if (fd < 0)
+ return -1;
+
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+
+ rc = select(FD_SETSIZE, &fds, NULL, NULL, timeout);
+ return rc;
+}
+
+int crespo_ipc_power_on(void *power_data)
{
int fd=open("/dev/modem_ctl", O_RDWR);
int rc;
@@ -565,7 +592,7 @@ int crespo_ipc_power_on(void *io_data)
return 0;
}
-int crespo_ipc_power_off(void *io_data)
+int crespo_ipc_power_off(void *power_data)
{
int fd=open("/dev/modem_ctl", O_RDWR);
int rc;
@@ -587,133 +614,105 @@ int crespo_ipc_power_off(void *io_data)
return 0;
}
-char *crespo_2_6_35_ipc_gprs_get_iface(int cid)
-{
- char *iface = NULL;
-
- asprintf(&iface, "%s%d", GPRS_IFACE_PREFIX, 0);
-
- return iface;
-}
-
-char *crespo_3_0_ipc_gprs_get_iface(int cid)
-{
- char *iface = NULL;
-
- if(cid > GPRS_IFACE_COUNT)
- return NULL;
-
- asprintf(&iface, "%s%d", GPRS_IFACE_PREFIX, cid - 1);
-
- return iface;
-}
-
-int crespo_2_6_35_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap)
+int crespo_ipc_data_create(void **transport_data, void **power_data, void **gprs_data)
{
- if (cap == NULL)
+ if (transport_data == NULL)
return -1;
- cap->port_list = 0;
- cap->cid_max = 1;
+ *transport_data = (void *) malloc(sizeof(struct crespo_ipc_transport_data));
+ memset(*transport_data, 0, sizeof(struct crespo_ipc_transport_data));
return 0;
}
-int crespo_3_0_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap)
+int crespo_ipc_data_destroy(void *transport_data, void *power_data, void *gprs_data)
{
- if (cap == NULL)
+ if (transport_data == NULL)
return -1;
- cap->port_list = 0;
- cap->cid_max = GPRS_IFACE_COUNT;
+ free(transport_data);
return 0;
}
-void *crespo_ipc_common_data_create(void)
+char *crespo_2_6_35_ipc_gprs_get_iface(int cid)
{
- void *io_data;
- int io_data_len;
-
- io_data_len = sizeof(int);
- io_data = malloc(io_data_len);
-
- if(io_data == NULL)
- return NULL;
+ char *iface = NULL;
- memset(io_data, 0, io_data_len);
+ asprintf(&iface, "%s%d", GPRS_IFACE_PREFIX, 0);
- return io_data;
+ return iface;
}
-int crespo_ipc_common_data_destroy(void *io_data)
+char *crespo_3_0_ipc_gprs_get_iface(int cid)
{
- // This was already done, not an error but we need to return
- if(io_data == NULL)
- return 0;
+ char *iface = NULL;
- free(io_data);
+ if(cid > GPRS_IFACE_COUNT)
+ return NULL;
- return 0;
+ asprintf(&iface, "%s%d", GPRS_IFACE_PREFIX, cid - 1);
+
+ return iface;
}
-int crespo_ipc_common_data_set_fd(void *io_data, int fd)
+int crespo_2_6_35_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *capabilities)
{
- int *common_data;
-
- if(io_data == NULL)
+ if (capabilities == NULL)
return -1;
- common_data = (int *) io_data;
- *common_data = fd;
+ capabilities->port_list = 0;
+ capabilities->cid_max = 1;
return 0;
}
-int crespo_ipc_common_data_get_fd(void *io_data)
+int crespo_3_0_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *capabilities)
{
- int *common_data;
-
- if(io_data == NULL)
+ if (capabilities == NULL)
return -1;
- common_data = (int *) io_data;
+ capabilities->port_list = 0;
+ capabilities->cid_max = GPRS_IFACE_COUNT;
- return (int) *(common_data);
+ return 0;
}
-struct ipc_ops crespo_fmt_ops = {
- .send = crespo_ipc_fmt_client_send,
- .recv = crespo_ipc_fmt_client_recv,
- .bootstrap = crespo_modem_bootstrap,
+struct ipc_ops crespo_ipc_fmt_ops = {
+ .bootstrap = crespo_ipc_bootstrap,
+ .send = crespo_ipc_fmt_send,
+ .recv = crespo_ipc_fmt_recv,
};
-struct ipc_ops crespo_rfs_ops = {
- .send = crespo_ipc_rfs_client_send,
- .recv = crespo_ipc_rfs_client_recv,
+struct ipc_ops crespo_ipc_rfs_ops = {
.bootstrap = NULL,
+ .send = crespo_ipc_rfs_send,
+ .recv = crespo_ipc_rfs_recv,
};
-struct ipc_handlers crespo_default_handlers = {
- .read = crespo_ipc_read,
- .write = crespo_ipc_write,
+struct ipc_handlers crespo_ipc_handlers = {
.open = crespo_ipc_open,
.close = crespo_ipc_close,
+ .read = crespo_ipc_read,
+ .write = crespo_ipc_write,
+ .poll = crespo_ipc_poll,
+ .transport_data = NULL,
.power_on = crespo_ipc_power_on,
.power_off = crespo_ipc_power_off,
- .common_data = NULL,
- .common_data_create = crespo_ipc_common_data_create,
- .common_data_destroy = crespo_ipc_common_data_destroy,
- .common_data_set_fd = crespo_ipc_common_data_set_fd,
- .common_data_get_fd = crespo_ipc_common_data_get_fd,
+ .power_data = NULL,
+ .gprs_activate = NULL,
+ .gprs_deactivate = NULL,
+ .gprs_data = NULL,
+ .data_create = crespo_ipc_data_create,
+ .data_destroy = crespo_ipc_data_destroy,
};
-struct ipc_gprs_specs crespo_2_6_35_gprs_specs = {
+struct ipc_gprs_specs crespo_2_6_35_ipc_gprs_specs = {
.gprs_get_iface = crespo_2_6_35_ipc_gprs_get_iface,
.gprs_get_capabilities = crespo_2_6_35_ipc_gprs_get_capabilities,
};
-struct ipc_gprs_specs crespo_3_0_gprs_specs = {
+struct ipc_gprs_specs crespo_3_0_ipc_gprs_specs = {
.gprs_get_iface = crespo_3_0_ipc_gprs_get_iface,
.gprs_get_capabilities = crespo_3_0_ipc_gprs_get_capabilities,
};
diff --git a/samsung-ipc/device/crespo/crespo_ipc.h b/samsung-ipc/device/crespo/crespo_ipc.h
index 184b1d6..f633d1b 100644
--- a/samsung-ipc/device/crespo/crespo_ipc.h
+++ b/samsung-ipc/device/crespo/crespo_ipc.h
@@ -31,7 +31,9 @@
#define GPRS_IFACE_PREFIX "rmnet"
#define GPRS_IFACE_COUNT 3
-extern struct ipc_handlers crespo_ipc_default_handlers;
+struct crespo_ipc_transport_data {
+ int fd;
+};
#endif
diff --git a/samsung-ipc/device/galaxys2/galaxys2_ipc.c b/samsung-ipc/device/galaxys2/galaxys2_ipc.c
index dbaced5..d68cf0d 100644
--- a/samsung-ipc/device/galaxys2/galaxys2_ipc.c
+++ b/samsung-ipc/device/galaxys2/galaxys2_ipc.c
@@ -30,34 +30,38 @@
#include "xmm6260_ipc.h"
#include "galaxys2_loader.h"
-struct ipc_ops galaxys2_fmt_ops = {
- .send = xmm6260_ipc_fmt_client_send,
- .recv = xmm6260_ipc_fmt_client_recv,
- .bootstrap = galaxys2_modem_bootstrap,
+struct ipc_ops galaxys2_ipc_fmt_ops = {
+ .bootstrap = galaxys2_ipc_bootstrap,
+ .send = xmm6260_ipc_fmt_send,
+ .recv = xmm6260_ipc_fmt_recv,
};
-struct ipc_ops galaxys2_rfs_ops = {
- .send = xmm6260_ipc_rfs_client_send,
- .recv = xmm6260_ipc_rfs_client_recv,
+struct ipc_ops galaxys2_ipc_rfs_ops = {
.bootstrap = NULL,
+ .send = xmm6260_ipc_rfs_send,
+ .recv = xmm6260_ipc_rfs_recv,
};
-struct ipc_handlers galaxys2_default_handlers = {
- .read = xmm6260_ipc_read,
- .write = xmm6260_ipc_write,
+struct ipc_handlers galaxys2_ipc_handlers = {
.open = xmm6260_ipc_open,
.close = xmm6260_ipc_close,
+ .read = xmm6260_ipc_read,
+ .write = xmm6260_ipc_write,
+ .poll = xmm6260_ipc_poll,
+ .transport_data = NULL,
.power_on = xmm6260_ipc_power_on,
.power_off = xmm6260_ipc_power_off,
- .common_data = NULL,
- .common_data_create = xmm6260_ipc_common_data_create,
- .common_data_destroy = xmm6260_ipc_common_data_destroy,
- .common_data_set_fd = xmm6260_ipc_common_data_set_fd,
- .common_data_get_fd = xmm6260_ipc_common_data_get_fd,
+ .power_data = NULL,
+ .gprs_activate = NULL,
+ .gprs_deactivate = NULL,
+ .gprs_data = NULL,
+ .data_create = xmm6260_ipc_data_create,
+ .data_destroy = xmm6260_ipc_data_destroy,
};
-struct ipc_gprs_specs galaxys2_gprs_specs = {
+struct ipc_gprs_specs galaxys2_ipc_gprs_specs = {
.gprs_get_iface = xmm6260_ipc_gprs_get_iface,
.gprs_get_capabilities = xmm6260_ipc_gprs_get_capabilities,
};
+// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/device/galaxys2/galaxys2_loader.c b/samsung-ipc/device/galaxys2/galaxys2_loader.c
index 35fb4e1..03dca93 100644
--- a/samsung-ipc/device/galaxys2/galaxys2_loader.c
+++ b/samsung-ipc/device/galaxys2/galaxys2_loader.c
@@ -623,7 +623,7 @@ fail:
return ret;
}
-int galaxys2_modem_bootstrap(struct ipc_client *client) {
+int galaxys2_ipc_bootstrap(struct ipc_client *client) {
int ret = 0;
struct modemctl_io_data io_data;
memset(&io_data, 0, sizeof(client, io_data));
diff --git a/samsung-ipc/device/galaxys2/galaxys2_loader.h b/samsung-ipc/device/galaxys2/galaxys2_loader.h
index 24fbfbc..e300d70 100644
--- a/samsung-ipc/device/galaxys2/galaxys2_loader.h
+++ b/samsung-ipc/device/galaxys2/galaxys2_loader.h
@@ -75,7 +75,7 @@ struct galaxys2_boot_cmd {
uint32_t data_size;
} __attribute__((packed));
-int galaxys2_modem_bootstrap(struct ipc_client *client);
+int galaxys2_ipc_bootstrap(struct ipc_client *client);
#endif
diff --git a/samsung-ipc/device/maguro/maguro_ipc.c b/samsung-ipc/device/maguro/maguro_ipc.c
index a25d357..f68e7e6 100644
--- a/samsung-ipc/device/maguro/maguro_ipc.c
+++ b/samsung-ipc/device/maguro/maguro_ipc.c
@@ -31,41 +31,46 @@
#include "xmm6260_ipc.h"
#include "maguro_loader.h"
-struct ipc_ops maguro_fmt_ops = {
- .send = xmm6260_ipc_fmt_client_send,
- .recv = xmm6260_ipc_fmt_client_recv,
- .bootstrap = maguro_modem_bootstrap,
+struct ipc_ops maguro_ipc_fmt_ops = {
+ .bootstrap = maguro_ipc_bootstrap,
+ .send = xmm6260_ipc_fmt_send,
+ .recv = xmm6260_ipc_fmt_recv,
};
-struct ipc_ops maguro_rfs_ops = {
- .send = xmm6260_ipc_rfs_client_send,
- .recv = xmm6260_ipc_rfs_client_recv,
+struct ipc_ops maguro_ipc_rfs_ops = {
.bootstrap = NULL,
+ .send = xmm6260_ipc_rfs_send,
+ .recv = xmm6260_ipc_rfs_recv,
};
-struct ipc_handlers maguro_default_handlers = {
- .read = xmm6260_ipc_read,
- .write = xmm6260_ipc_write,
+struct ipc_handlers maguro_ipc_handlers = {
.open = xmm6260_ipc_open,
.close = xmm6260_ipc_close,
+ .read = xmm6260_ipc_read,
+ .write = xmm6260_ipc_write,
+ .poll = xmm6260_ipc_poll,
+ .transport_data = NULL,
.power_on = xmm6260_ipc_power_on,
- .power_off = maguro_power_off,
- .common_data = NULL,
- .common_data_create = xmm6260_ipc_common_data_create,
- .common_data_destroy = xmm6260_ipc_common_data_destroy,
- .common_data_set_fd = xmm6260_ipc_common_data_set_fd,
- .common_data_get_fd = xmm6260_ipc_common_data_get_fd,
+ .power_off = xmm6260_ipc_power_off,
+ .power_data = NULL,
+ .gprs_activate = NULL,
+ .gprs_deactivate = NULL,
+ .gprs_data = NULL,
+ .data_create = xmm6260_ipc_data_create,
+ .data_destroy = xmm6260_ipc_data_destroy,
};
-struct ipc_gprs_specs maguro_gprs_specs = {
+struct ipc_gprs_specs maguro_ipc_gprs_specs = {
.gprs_get_iface = xmm6260_ipc_gprs_get_iface,
.gprs_get_capabilities = xmm6260_ipc_gprs_get_capabilities,
};
-struct ipc_nv_data_specs maguro_nv_data_specs = {
+struct ipc_nv_data_specs maguro_ipc_nv_data_specs = {
.nv_data_path = "/factory/nv_data.bin",
.nv_data_md5_path = "/factory/nv_data.bin.md5",
.nv_state_path = "/factory/.nv_state",
.nv_data_bak_path = "/factory/.nv_data.bak",
.nv_data_md5_bak_path = "/factory/.nv_data.bak.md5",
};
+
+// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/device/maguro/maguro_loader.c b/samsung-ipc/device/maguro/maguro_loader.c
index e6d8287..785585f 100644
--- a/samsung-ipc/device/maguro/maguro_loader.c
+++ b/samsung-ipc/device/maguro/maguro_loader.c
@@ -638,7 +638,7 @@ fail:
return ret;
}
-int maguro_power_off(void *io_data_unused) {
+int maguro_ipc_power_off(void *io_data_unused) {
int ret = -1;
struct modemctl_io_data io_data;
@@ -659,7 +659,7 @@ fail:
return ret;
}
-int maguro_modem_bootstrap(struct ipc_client *client)
+int maguro_ipc_bootstrap(struct ipc_client *client)
{
int ret = -1, n = 0, fd = -1, i;
struct modemctl_io_data io_data;
diff --git a/samsung-ipc/device/maguro/maguro_loader.h b/samsung-ipc/device/maguro/maguro_loader.h
index 15b982b..2f97133 100644
--- a/samsung-ipc/device/maguro/maguro_loader.h
+++ b/samsung-ipc/device/maguro/maguro_loader.h
@@ -96,8 +96,8 @@ struct maguro_boot_tail_header name = {\
.unknown = "\xea\xea",\
}
-int maguro_modem_bootstrap(struct ipc_client *client);
-int maguro_power_off(void *io_data);
+int maguro_ipc_bootstrap(struct ipc_client *client);
+int maguro_ipc_power_off(void *io_data);
#endif
diff --git a/samsung-ipc/device/piranha/piranha_ipc.c b/samsung-ipc/device/piranha/piranha_ipc.c
index 81761b9..17b7133 100644
--- a/samsung-ipc/device/piranha/piranha_ipc.c
+++ b/samsung-ipc/device/piranha/piranha_ipc.c
@@ -24,34 +24,38 @@
#include "xmm6260_ipc.h"
#include "piranha_loader.h"
-struct ipc_ops piranha_fmt_ops = {
- .send = xmm6260_ipc_fmt_client_send,
- .recv = xmm6260_ipc_fmt_client_recv,
+struct ipc_ops piranha_ipc_fmt_ops = {
.bootstrap = piranha_modem_bootstrap,
+ .send = xmm6260_ipc_fmt_send,
+ .recv = xmm6260_ipc_fmt_recv,
};
-struct ipc_ops piranha_rfs_ops = {
- .send = xmm6260_ipc_rfs_client_send,
- .recv = xmm6260_ipc_rfs_client_recv,
+struct ipc_ops piranha_ipc_rfs_ops = {
.bootstrap = NULL,
+ .send = xmm6260_ipc_rfs_send,
+ .recv = xmm6260_ipc_rfs_recv,
};
-struct ipc_handlers piranha_default_handlers = {
+struct ipc_handlers piranha_ipc_handlers = {
.read = xmm6260_ipc_read,
.write = xmm6260_ipc_write,
.open = xmm6260_ipc_open,
.close = xmm6260_ipc_close,
+ .poll = xmm6260_ipc_poll,
+ .transport_data = NULL,
.power_on = xmm6260_ipc_power_on,
.power_off = xmm6260_ipc_power_off,
- .common_data = NULL,
- .common_data_create = xmm6260_ipc_common_data_create,
- .common_data_destroy = xmm6260_ipc_common_data_destroy,
- .common_data_set_fd = xmm6260_ipc_common_data_set_fd,
- .common_data_get_fd = xmm6260_ipc_common_data_get_fd,
+ .power_data = NULL,
+ .gprs_activate = NULL,
+ .gprs_deactivate = NULL,
+ .gprs_data = NULL,
+ .data_create = xmm6260_ipc_data_create,
+ .data_destroy = xmm6260_ipc_data_destroy,
};
-struct ipc_gprs_specs piranha_gprs_specs = {
+struct ipc_gprs_specs piranha_ipc_gprs_specs = {
.gprs_get_iface = xmm6260_ipc_gprs_get_iface,
.gprs_get_capabilities = xmm6260_ipc_gprs_get_capabilities,
};
+// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
index c2d7a3b..2d485ab 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c
+++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
@@ -50,7 +50,7 @@
#define FMT_LOCK_NAME "xmm6260-fmt-lock"
#define RFS_LOCK_NAME "xmm6260-rfs-lock"
-int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request)
+int xmm6260_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request)
{
struct ipc_header *hdr;
unsigned char *frame;
@@ -79,7 +79,7 @@ int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_in
ipc_client_log_send(client, request, __func__);
- client->handlers->write(frame, frame_length, client->handlers->write_data);
+ client->handlers->write(client->handlers->transport_data, frame, frame_length);
free(frame);
@@ -88,7 +88,7 @@ int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_in
return 0;
}
-int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info *response)
+int xmm6260_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response)
{
unsigned char buf[IPC_MAX_XFER] = {};
unsigned char *data;
@@ -106,8 +106,7 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
wake_lock(FMT_LOCK_NAME);
- num_read = client->handlers->read(buf, IPC_MAX_XFER,
- client->handlers->read_data);
+ num_read = client->handlers->read(client->handlers->transport_data, buf, IPC_MAX_XFER);
if (num_read <= 0) {
ipc_client_log(client, "read failed to read ipc length: %d", num_read);
@@ -120,7 +119,7 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
left = ipc.length - num_read;
if (left > 0)
- num_read = client->handlers->read(buf + num_read, left, client->handlers->read_data);
+ num_read = client->handlers->read(client->handlers->transport_data, buf + num_read, left);
memcpy(&ipc, buf, sizeof(ipc));
@@ -145,7 +144,7 @@ done:
return 0;
}
-int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info *response)
+int xmm6260_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *response)
{
unsigned char buf[IPC_MAX_XFER] = {};
struct rfs_hdr header;
@@ -157,7 +156,7 @@ int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_in
wake_lock(RFS_LOCK_NAME);
do {
- rc = client->handlers->read(buf, IPC_MAX_XFER, client->handlers->read_data);
+ rc = client->handlers->read(client->handlers->transport_data, buf, IPC_MAX_XFER);
if (rc < 0) {
ipc_client_log(client, "Failed to read RFS data.");
@@ -213,7 +212,7 @@ done:
return ret;
}
-int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info *request)
+int xmm6260_ipc_rfs_send(struct ipc_client *client, struct ipc_message_info *request)
{
struct rfs_hdr *header = NULL;
char *data = NULL;
@@ -235,15 +234,21 @@ int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_in
ipc_client_log_send(client, request, __func__);
- rc = client->handlers->write(data, data_length, client->handlers->write_data);
+ rc = client->handlers->write(client->handlers->transport_data, data, data_length);
wake_unlock(RFS_LOCK_NAME);
return rc;
}
-int xmm6260_ipc_open(int type, void *io_data)
+int xmm6260_ipc_open(void *transport_data, int type)
{
- int fd = -1;
+ struct xmm6260_ipc_transport_data *data;
+ int fd;
+
+ if (transport_data == NULL)
+ return -1;
+
+ data = (struct xmm6260_ipc_transport_data *) transport_data;
switch(type)
{
@@ -260,24 +265,23 @@ int xmm6260_ipc_open(int type, void *io_data)
if(fd < 0)
return -1;
- if(io_data == NULL)
- return -1;
-
- memcpy(io_data, &fd, sizeof(int));
+ data->fd = fd;
return 0;
}
-int xmm6260_ipc_close(void *io_data)
+int xmm6260_ipc_close(void *transport_data)
{
- int fd = -1;
+ struct xmm6260_ipc_transport_data *data;
+ int fd;
- if(io_data == NULL)
+ if (transport_data == NULL)
return -1;
- fd = *((int *) io_data);
+ data = (struct xmm6260_ipc_transport_data *) transport_data;
- if(fd < 0)
+ fd = data->fd;
+ if (fd < 0)
return -1;
close(fd);
@@ -285,19 +289,18 @@ int xmm6260_ipc_close(void *io_data)
return 0;
}
-int xmm6260_ipc_read(void *data, unsigned int size, void *io_data)
+int xmm6260_ipc_read(void *transport_data, void *buffer, unsigned int length)
{
- int fd = -1;
+ struct xmm6260_ipc_transport_data *data;
+ int fd;
int rc;
- if(io_data == NULL)
+ if (transport_data == NULL)
return -1;
- if(data == NULL)
- return -1;
-
- fd = *((int *) io_data);
+ data = (struct xmm6260_ipc_transport_data *) transport_data;
+ fd = data->fd;
if(fd < 0)
return -1;
@@ -305,117 +308,110 @@ int xmm6260_ipc_read(void *data, unsigned int size, void *io_data)
if (rc < 0)
return -1;
- rc = read(fd, data, size);
+ rc = read(fd, buffer, length);
if(rc < 0)
return -1;
return rc;
}
-int xmm6260_ipc_write(void *data, unsigned int size, void *io_data)
+int xmm6260_ipc_write(void *transport_data, void *buffer, unsigned int length)
{
- int fd = -1;
+ struct xmm6260_ipc_transport_data *data;
+ int fd;
int rc;
- if(io_data == NULL)
+ if (transport_data == NULL)
return -1;
- fd = *((int *) io_data);
+ data = (struct xmm6260_ipc_transport_data *) transport_data;
+ fd = data->fd;
if(fd < 0)
return -1;
- rc = write(fd, data, size);
-
+ rc = write(fd, buffer, length);
if(rc < 0)
return -1;
return rc;
}
-int xmm6260_ipc_power_on(void *io_data)
+int xmm6260_ipc_poll(void *transport_data, struct timeval *timeout)
{
- return 0;
-}
+ struct xmm6260_ipc_transport_data *data;
+ fd_set fds;
+ int fd;
+ int rc;
-int xmm6260_ipc_power_off(void *io_data)
-{
- return 0;
-}
+ if (transport_data == NULL)
+ return -1;
-char *xmm6260_ipc_gprs_get_iface(int cid)
-{
- char *iface = NULL;
+ data = (struct xmm6260_ipc_transport_data *) transport_data;
- if(cid > GPRS_IFACE_COUNT)
- return NULL;
+ fd = data->fd;
+ if (fd < 0)
+ return -1;
- asprintf(&iface, "%s%d", GPRS_IFACE_PREFIX, cid - 1);
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
- return iface;
+ rc = select(FD_SETSIZE, &fds, NULL, NULL, timeout);
+ return rc;
}
-int xmm6260_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap)
+int xmm6260_ipc_power_on(void *power_data)
{
- if (cap == NULL)
- return -1;
-
- cap->port_list = 1;
- cap->cid_max = GPRS_IFACE_COUNT;
-
return 0;
}
-void *xmm6260_ipc_common_data_create(void)
+int xmm6260_ipc_power_off(void *power_data)
{
- void *io_data;
- int io_data_len;
-
- io_data_len = sizeof(int);
- io_data = malloc(io_data_len);
+ return 0;
+}
- if(io_data == NULL)
- return NULL;
+int xmm6260_ipc_data_create(void **transport_data, void **power_data, void **gprs_data)
+{
+ if (transport_data == NULL)
+ return -1;
- memset(io_data, 0, io_data_len);
+ *transport_data = (void *) malloc(sizeof(struct xmm6260_ipc_transport_data));
+ memset(*transport_data, 0, sizeof(struct xmm6260_ipc_transport_data));
- return io_data;
+ return 0;
}
-int xmm6260_ipc_common_data_destroy(void *io_data)
+int xmm6260_ipc_data_destroy(void *transport_data, void *power_data, void *gprs_data)
{
- // This was already done, not an error but we need to return
- if(io_data == NULL)
- return 0;
+ if (transport_data == NULL)
+ return -1;
- free(io_data);
+ free(transport_data);
return 0;
}
-int xmm6260_ipc_common_data_set_fd(void *io_data, int fd)
+char *xmm6260_ipc_gprs_get_iface(int cid)
{
- int *common_data;
+ char *iface = NULL;
- if(io_data == NULL)
- return -1;
+ if(cid > GPRS_IFACE_COUNT)
+ return NULL;
- common_data = (int *) io_data;
- *common_data = fd;
+ asprintf(&iface, "%s%d", GPRS_IFACE_PREFIX, cid - 1);
- return 0;
+ return iface;
}
-int xmm6260_ipc_common_data_get_fd(void *io_data)
+int xmm6260_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *capabilities)
{
- int *common_data;
-
- if(io_data == NULL)
+ if (capabilities == NULL)
return -1;
- common_data = (int *) io_data;
+ capabilities->port_list = 1;
+ capabilities->cid_max = GPRS_IFACE_COUNT;
- return (int) *(common_data);
+ return 0;
}
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.h b/samsung-ipc/device/xmm6260/xmm6260_ipc.h
index b00f7db..588469d 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_ipc.h
+++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.h
@@ -36,22 +36,25 @@ struct rfs_hdr {
uint8_t id;
} __attribute__ ((packed));
-int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request);
-int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info *response);
-int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info *response);
-int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info *request);
-int xmm6260_ipc_open(int type, void *io_data);
-int xmm6260_ipc_close(void *io_data);
-int xmm6260_ipc_read(void *data, unsigned int size, void *io_data);
-int xmm6260_ipc_write(void *data, unsigned int size, void *io_data);
-int xmm6260_ipc_power_on(void *io_data);
-int xmm6260_ipc_power_off(void *io_data);
+int xmm6260_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request);
+int xmm6260_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response);
+int xmm6260_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *response);
+int xmm6260_ipc_rfs_send(struct ipc_client *client, struct ipc_message_info *request);
+int xmm6260_ipc_open(void *transport_data, int type);
+int xmm6260_ipc_close(void *transport_data);
+int xmm6260_ipc_read(void *transport_data, void *buffer, unsigned int length);
+int xmm6260_ipc_write(void *transport_data, void *buffer, unsigned int length);
+int xmm6260_ipc_poll(void *transport_data, struct timeval *timeout);
+int xmm6260_ipc_power_on(void *power_data);
+int xmm6260_ipc_power_off(void *power_data);
+int xmm6260_ipc_data_create(void **transport_data, void **power_data, void **gprs_data);
+int xmm6260_ipc_data_destroy(void *transport_data, void *power_data, void *gprs_data);
char* xmm6260_ipc_gprs_get_iface(int cid);
-int xmm6260_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap);
-void *xmm6260_ipc_common_data_create(void);
-int xmm6260_ipc_common_data_destroy(void *io_data);
-int xmm6260_ipc_common_data_set_fd(void *io_data, int fd);
-int xmm6260_ipc_common_data_get_fd(void *io_data);
+int xmm6260_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *capabilities);
+
+struct xmm6260_ipc_transport_data {
+ int fd;
+};
#endif
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index 870bc15..5e9b3d3 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -41,26 +41,6 @@
#include "ipc.h"
#include "ipc_devices.h"
-void log_handler_default(const char *message, void *user_data)
-{
- printf("%s\n", message);
-}
-
-void ipc_client_log(struct ipc_client *client, const char *message, ...)
-{
- if (!message || !client || !client->log_handler) {
- return;
- }
-
- va_list args;
- char buffer[4096];
-
- va_start(args, message);
- vsprintf(buffer, message, args);
- client->log_handler(buffer, client->log_data);
- va_end(args);
-}
-
int ipc_device_detect(void)
{
char *board_name = NULL;
@@ -142,7 +122,7 @@ int ipc_device_detect(void)
return index;
}
-struct ipc_client *ipc_client_new(int client_type)
+struct ipc_client *ipc_client_create(int client_type)
{
struct ipc_client *client;
int device_index = -1;
@@ -168,189 +148,184 @@ struct ipc_client *ipc_client_new(int client_type)
case IPC_CLIENT_TYPE_FMT:
client->ops = ipc_devices[device_index].fmt_ops;
break;
+ default:
+ return NULL;
}
- client->handlers = (struct ipc_handlers *) malloc(sizeof(struct ipc_handlers));
client->gprs_specs = ipc_devices[device_index].gprs_specs;
client->nv_data_specs = ipc_devices[device_index].nv_data_specs;
+ // Handlers are subject to be modified
+ client->handlers = (struct ipc_handlers *) malloc(sizeof(struct ipc_handlers));
+ memset(client->handlers, 0, sizeof(struct ipc_handlers));
+
if (ipc_devices[device_index].handlers != 0)
memcpy(client->handlers, ipc_devices[device_index].handlers, sizeof(struct ipc_handlers));
return client;
}
-int ipc_client_free(struct ipc_client *client)
+int ipc_client_destroy(struct ipc_client *client)
{
- free(client->handlers);
+ if (client == NULL)
+ return -1;
+
+ if (client->handlers != NULL)
+ free(client->handlers);
+
+ memset(client, 0, sizeof(struct ipc_client));
free(client);
- client = NULL;
+
return 0;
}
-int ipc_client_set_log_handler(struct ipc_client *client,
- ipc_client_log_handler_cb log_handler_cb, void *user_data)
+void ipc_client_log(struct ipc_client *client, const char *message, ...)
{
- if (client == NULL)
- return -1;
+ char buffer[4096];
+ va_list args;
- client->log_handler = log_handler_cb;
- client->log_data = user_data;
+ if (client == NULL || client->log_callback == NULL || message == NULL)
+ return;
- return 0;
+ va_start(args, message);
+ vsnprintf(buffer, 4096, message, args);
+ client->log_callback(client->log_data, buffer);
+ va_end(args);
}
-int ipc_client_set_handlers(struct ipc_client *client,
- struct ipc_handlers *handlers)
+int ipc_client_set_log_callback(struct ipc_client *client,
+ void (*log_callback)(void *log_data, const char *message), void *log_data)
{
- if (client == NULL || handlers == NULL)
+ if (client == NULL)
return -1;
- memcpy(client->handlers, handlers, sizeof(struct ipc_handlers));
+ client->log_callback = log_callback;
+ client->log_data = log_data;
return 0;
}
-int ipc_client_set_io_handlers(struct ipc_client *client,
- ipc_io_handler_cb read, void *read_data,
- ipc_io_handler_cb write,void *write_data)
+int ipc_client_set_transport_handlers(struct ipc_client *client,
+ int (*open)(void *transport_data, int type),
+ int (*close)(void *transport_data),
+ int (*read)(void *transport_data, void *buffer, unsigned int length),
+ int (*write)(void *transport_data, void *buffer, unsigned int length),
+ int (*poll)(void *transport_data, struct timeval *timeout),
+ void *transport_data)
{
if (client == NULL || client->handlers == NULL)
return -1;
if (read != NULL)
client->handlers->read = read;
- if (read_data != NULL)
- client->handlers->read_data = read_data;
if (write != NULL)
client->handlers->write = write;
- if (write_data != NULL)
- client->handlers->write_data = write_data;
+ if (poll != NULL)
+ client->handlers->poll = poll;
+ if (open != NULL)
+ client->handlers->open = open;
+ if (close != NULL)
+ client->handlers->close = close;
+ if (transport_data != NULL)
+ client->handlers->transport_data = transport_data;
return 0;
}
-int ipc_client_set_handlers_common_data(struct ipc_client *client, void *data)
+int ipc_client_set_power_handlers(struct ipc_client *client,
+ int (*power_on)(void *power_data),
+ int (*power_off)(void *power_data),
+ void *power_data)
{
- void *common_data;
-
- if (client == NULL || client->handlers == NULL || data == NULL)
+ if (client == NULL || client->handlers == NULL)
return -1;
- common_data = data;
- client->handlers->common_data = common_data;
-
- client->handlers->read_data = common_data;
- client->handlers->write_data = common_data;
- client->handlers->open_data = common_data;
- client->handlers->close_data = common_data;
- client->handlers->power_on_data = common_data;
- client->handlers->power_off_data = common_data;
- client->handlers->gprs_activate_data = common_data;
- client->handlers->gprs_deactivate_data = common_data;
+ if (power_on != NULL)
+ client->handlers->power_on = power_on;
+ if (power_off != NULL)
+ client->handlers->power_off = power_off;
+ if (power_data != NULL)
+ client->handlers->power_data = power_data;
return 0;
}
-void *ipc_client_get_handlers_common_data(struct ipc_client *client)
+int ipc_client_set_gprs_handlers(struct ipc_client *client,
+ int (*gprs_activate)(void *gprs_data, int cid),
+ int (*gprs_deactivate)(void *gprs_data, int cid),
+ void *gprs_data)
{
if (client == NULL || client->handlers == NULL)
- return NULL;
-
- return client->handlers->common_data;
-}
-
-int ipc_client_create_handlers_common_data(struct ipc_client *client)
-{
- void *common_data;
-
- if (client == NULL || client->handlers == NULL)
return -1;
- common_data = client->handlers->common_data_create();
- client->handlers->common_data = common_data;
-
- client->handlers->read_data = common_data;
- client->handlers->write_data = common_data;
- client->handlers->open_data = common_data;
- client->handlers->close_data = common_data;
- client->handlers->power_on_data = common_data;
- client->handlers->power_off_data = common_data;
- client->handlers->gprs_activate_data = common_data;
- client->handlers->gprs_deactivate_data = common_data;
+ if (gprs_activate != NULL)
+ client->handlers->gprs_activate = gprs_activate;
+ if (gprs_deactivate != NULL)
+ client->handlers->gprs_deactivate = gprs_deactivate;
+ if (gprs_data != NULL)
+ client->handlers->gprs_data = gprs_data;
return 0;
}
-int ipc_client_destroy_handlers_common_data(struct ipc_client *client)
+int ipc_client_bootstrap(struct ipc_client *client)
{
- void *common_data;
- int rc;
-
- if (client == NULL || client->handlers == NULL ||
- client->handlers->common_data_destroy == NULL)
- return -1;
-
- rc = client->handlers->common_data_destroy(client->handlers->common_data);
-
- if (rc < 0)
+ if (client == NULL || client->ops == NULL ||
+ client->ops->bootstrap == NULL)
return -1;
- common_data = NULL;
- client->handlers->common_data = common_data;
-
- client->handlers->read_data = common_data;
- client->handlers->write_data = common_data;
- client->handlers->open_data = common_data;
- client->handlers->close_data = common_data;
- client->handlers->power_on_data = common_data;
- client->handlers->power_off_data = common_data;
- client->handlers->gprs_activate_data = common_data;
- client->handlers->gprs_deactivate_data = common_data;
-
- return 0;
+ return client->ops->bootstrap(client);
}
-int ipc_client_set_handlers_common_data_fd(struct ipc_client *client, int fd)
+int ipc_client_send(struct ipc_client *client, const unsigned short command,
+ const char type, unsigned char *data, const int length, unsigned char mseq)
{
- if (client == NULL || client->handlers == NULL ||
- client->handlers->common_data_set_fd == NULL)
+ struct ipc_message_info request;
+
+ if (client == NULL || client->ops == NULL || client->ops->send == NULL)
return -1;
- return client->handlers->common_data_set_fd(client->handlers->common_data, fd);
+ request.mseq = mseq;
+ request.aseq = 0xff;
+ request.group = IPC_GROUP(command);
+ request.index = IPC_INDEX(command);
+ request.type = type;
+ request.length = length;
+ request.data = data;
+
+ return client->ops->send(client, &request);
}
-int ipc_client_get_handlers_common_data_fd(struct ipc_client *client)
+int ipc_client_recv(struct ipc_client *client,
+ struct ipc_message_info *response)
{
- if (client == NULL || client->handlers == NULL ||
- client->handlers->common_data_get_fd == NULL)
+ if (client == NULL || client->ops == NULL || client->ops->recv == NULL)
return -1;
- return client->handlers->common_data_get_fd(client->handlers->common_data);
+ return client->ops->recv(client, response);
}
-
-int ipc_client_bootstrap_modem(struct ipc_client *client)
+void ipc_client_response_free(struct ipc_client *client,
+ struct ipc_message_info *response)
{
- if (client == NULL || client->ops == NULL ||
- client->ops->bootstrap == NULL)
- return -1;
+ if (response == NULL)
+ return;
- return client->ops->bootstrap(client);
+ if (response->data != NULL && response->length > 0) {
+ free(response->data);
+ response->data = NULL;
+ }
+
+ memset(response, 0, sizeof(struct ipc_message_info));
}
int ipc_client_open(struct ipc_client *client)
{
- int type;
- int fd;
-
if (client == NULL || client->handlers == NULL ||
client->handlers->open == NULL)
return -1;
- type = client->type;
-
- return client->handlers->open(type, client->handlers->open_data);
+ return client->handlers->open(client->handlers->transport_data, client->type);
}
int ipc_client_close(struct ipc_client *client)
@@ -359,36 +334,34 @@ int ipc_client_close(struct ipc_client *client)
client->handlers->close == NULL)
return -1;
- return client->handlers->close(client->handlers->close_data);
+ return client->handlers->close(client->handlers->transport_data);
}
-int ipc_client_power_on(struct ipc_client *client)
+int ipc_client_poll(struct ipc_client *client, struct timeval *timeout)
{
if (client == NULL || client->handlers == NULL ||
- client->handlers->power_on == NULL)
+ client->handlers->poll == NULL)
return -1;
- return client->handlers->power_on(client->handlers->power_on_data);
+ return client->handlers->poll(client->handlers->transport_data, timeout);
}
-int ipc_client_power_off(struct ipc_client *client)
+int ipc_client_power_on(struct ipc_client *client)
{
if (client == NULL || client->handlers == NULL ||
- client->handlers->power_off == NULL)
+ client->handlers->power_on == NULL)
return -1;
- return client->handlers->power_off(client->handlers->power_off_data);
+ return client->handlers->power_on(client->handlers->power_data);
}
-int ipc_client_gprs_handlers_available(struct ipc_client *client)
+int ipc_client_power_off(struct ipc_client *client)
{
- if (client == NULL || client->handlers == NULL)
+ if (client == NULL || client->handlers == NULL ||
+ client->handlers->power_off == NULL)
return -1;
- if(client->handlers->gprs_activate != NULL && client->handlers->gprs_deactivate != NULL)
- return 1;
- else
- return 0;
+ return client->handlers->power_off(client->handlers->power_data);
}
int ipc_client_gprs_activate(struct ipc_client *client, int cid)
@@ -397,7 +370,7 @@ int ipc_client_gprs_activate(struct ipc_client *client, int cid)
client->handlers->gprs_activate == NULL)
return -1;
- return client->handlers->gprs_activate(client->handlers->gprs_activate_data, cid);
+ return client->handlers->gprs_activate(client->handlers->gprs_data, cid);
}
int ipc_client_gprs_deactivate(struct ipc_client *client, int cid)
@@ -406,65 +379,44 @@ int ipc_client_gprs_deactivate(struct ipc_client *client, int cid)
client->handlers->gprs_deactivate == NULL)
return -1;
- return client->handlers->gprs_deactivate(client->handlers->gprs_deactivate_data, cid);
-}
-
-char *ipc_client_gprs_get_iface(struct ipc_client *client, int cid)
-{
- if (client == NULL || client->gprs_specs == NULL ||
- client->gprs_specs->gprs_get_iface == NULL)
- return NULL;
-
- return client->gprs_specs->gprs_get_iface(cid);
+ return client->handlers->gprs_deactivate(client->handlers->gprs_data, cid);
}
-int ipc_client_gprs_get_capabilities(struct ipc_client *client, struct ipc_client_gprs_capabilities *cap)
+int ipc_client_data_create(struct ipc_client *client)
{
- if (client == NULL || client->gprs_specs == NULL ||
- client->gprs_specs->gprs_get_capabilities == NULL)
+ if (client == NULL || client->handlers == NULL)
return -1;
- return client->gprs_specs->gprs_get_capabilities(cap);
+ return client->handlers->data_create(&client->handlers->transport_data,
+ &client->handlers->power_data, &client->handlers->power_data);
}
-int ipc_client_send(struct ipc_client *client, const unsigned short command,
- const char type, unsigned char *data, const int length, unsigned char mseq)
+int ipc_client_data_destroy(struct ipc_client *client)
{
- struct ipc_message_info request;
-
- if (client == NULL || client->ops == NULL || client->ops->send == NULL)
+ if (client == NULL || client->handlers == NULL)
return -1;
- request.mseq = mseq;
- request.aseq = 0xff;
- request.group = IPC_GROUP(command);
- request.index = IPC_INDEX(command);
- request.type = type;
- request.length = length;
- request.data = data;
-
- return client->ops->send(client, &request);
+ return client->handlers->data_destroy(client->handlers->transport_data,
+ client->handlers->power_data, client->handlers->power_data);
}
-int ipc_client_recv(struct ipc_client *client,
- struct ipc_message_info *response)
+char *ipc_client_gprs_get_iface(struct ipc_client *client, int cid)
{
- if (client == NULL || client->ops == NULL || client->ops->recv == NULL)
- return -1;
+ if (client == NULL || client->gprs_specs == NULL ||
+ client->gprs_specs->gprs_get_iface == NULL)
+ return NULL;
- return client->ops->recv(client, response);
+ return client->gprs_specs->gprs_get_iface(cid);
}
-void ipc_client_response_free(struct ipc_client *client,
- struct ipc_message_info *response)
+int ipc_client_gprs_get_capabilities(struct ipc_client *client,
+ struct ipc_client_gprs_capabilities *capabilities)
{
- if (response == NULL)
- return;
+ if (client == NULL || client->gprs_specs == NULL ||
+ client->gprs_specs->gprs_get_capabilities == NULL)
+ return -1;
- if (response->data != NULL) {
- free(response->data);
- response->data = NULL;
- }
+ return client->gprs_specs->gprs_get_capabilities(capabilities);
}
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/ipc.h b/samsung-ipc/ipc.h
index d52e949..7e98004 100644
--- a/samsung-ipc/ipc.h
+++ b/samsung-ipc/ipc.h
@@ -18,6 +18,8 @@
*
*/
+#include <time.h>
+
#include <samsung-ipc.h>
#ifndef __IPC_H__
@@ -34,41 +36,36 @@ struct ipc_ops {
};
struct ipc_handlers {
- /* Transport handlers/data */
- ipc_io_handler_cb read;
- void *read_data;
- ipc_io_handler_cb write;
- void *write_data;
+ /* Transport handlers */
+ int (*open)(void *transport_data, int type);
+ int (*close)(void *transport_data);
+
+ int (*read)(void *transport_data, void *buffer, unsigned int length);
+ int (*write)(void *transport_data, void *buffer, unsigned int length);
+ int (*poll)(void *transport_data, struct timeval *timeout);
- int (*open)(int type, void *io_data);
- int (*close)(void *io_data);
- void *open_data;
- void *close_data;
+ void *transport_data;
/* Power handlers */
- ipc_handler_cb power_on;
- void *power_on_data;
- ipc_handler_cb power_off;
- void *power_off_data;
+ int (*power_on)(void *power_data);
+ int (*power_off)(void *power_data);
+
+ void *power_data;
/* GPRS handlers */
- int (*gprs_activate)(void *io_data, int cid);
- void *gprs_activate_data;
- int (*gprs_deactivate)(void *io_data, int cid);
- void *gprs_deactivate_data;
-
- /* Handlers common data*/
- void *common_data;
-
- void *(*common_data_create)(void);
- int (*common_data_destroy)(void *io_data);
- int (*common_data_set_fd)(void *io_data, int fd);
- int (*common_data_get_fd)(void *io_data);
+ int (*gprs_activate)(void *gprs_data, int cid);
+ int (*gprs_deactivate)(void *gprs_data, int cid);
+
+ void *gprs_data;
+
+ /* Data */
+ int (*data_create)(void **transport_data, void **power_data, void **gprs_data);
+ int (*data_destroy)(void *transport_data, void *power_data, void *gprs_data);
};
struct ipc_gprs_specs {
char *(*gprs_get_iface)(int cid);
- int (*gprs_get_capabilities)(struct ipc_client_gprs_capabilities *cap);
+ int (*gprs_get_capabilities)(struct ipc_client_gprs_capabilities *capabilities);
};
struct ipc_nv_data_specs {
@@ -85,7 +82,7 @@ struct ipc_nv_data_specs {
struct ipc_client {
int type;
- ipc_client_log_handler_cb log_handler;
+ void (*log_callback)(void *log_data, const char *message);
void *log_data;
struct ipc_ops *ops;
diff --git a/samsung-ipc/ipc_devices.c b/samsung-ipc/ipc_devices.c
index 95f6455..77b58dd 100644
--- a/samsung-ipc/ipc_devices.c
+++ b/samsung-ipc/ipc_devices.c
@@ -29,90 +29,90 @@ struct ipc_device_desc ipc_devices[] = {
.name = "crespo",
.board_name = "herring",
.kernel_version = "2.6.35",
- .fmt_ops = &crespo_fmt_ops,
- .rfs_ops = &crespo_rfs_ops,
- .handlers = &crespo_default_handlers,
- .gprs_specs = &crespo_2_6_35_gprs_specs,
+ .fmt_ops = &crespo_ipc_fmt_ops,
+ .rfs_ops = &crespo_ipc_rfs_ops,
+ .handlers = &crespo_ipc_handlers,
+ .gprs_specs = &crespo_2_6_35_ipc_gprs_specs,
.nv_data_specs = NULL,
},
{
.name = "crespo",
.board_name = "herring",
.kernel_version = "3.0",
- .fmt_ops = &crespo_fmt_ops,
- .rfs_ops = &crespo_rfs_ops,
- .handlers = &crespo_default_handlers,
- .gprs_specs = &crespo_3_0_gprs_specs,
+ .fmt_ops = &crespo_ipc_fmt_ops,
+ .rfs_ops = &crespo_ipc_rfs_ops,
+ .handlers = &crespo_ipc_handlers,
+ .gprs_specs = &crespo_3_0_ipc_gprs_specs,
.nv_data_specs = NULL,
},
{
.name = "aries",
.board_name = "aries",
.kernel_version = NULL,
- .fmt_ops = &aries_fmt_ops,
- .rfs_ops = &aries_rfs_ops,
- .handlers = &aries_default_handlers,
- .gprs_specs = &aries_gprs_specs,
+ .fmt_ops = &aries_ipc_fmt_ops,
+ .rfs_ops = &aries_ipc_rfs_ops,
+ .handlers = &aries_ipc_handlers,
+ .gprs_specs = &aries_ipc_gprs_specs,
.nv_data_specs = NULL,
},
{
.name = "aries",
.board_name = "gt-p1000",
.kernel_version = NULL,
- .fmt_ops = &aries_fmt_ops,
- .rfs_ops = &aries_rfs_ops,
- .handlers = &aries_default_handlers,
- .gprs_specs = &aries_gprs_specs,
+ .fmt_ops = &aries_ipc_fmt_ops,
+ .rfs_ops = &aries_ipc_rfs_ops,
+ .handlers = &aries_ipc_handlers,
+ .gprs_specs = &aries_ipc_gprs_specs,
.nv_data_specs = NULL,
},
{
.name = "galaxys2",
.board_name = "i9100",
.kernel_version = NULL,
- .fmt_ops = &galaxys2_fmt_ops,
- .rfs_ops = &galaxys2_rfs_ops,
- .handlers = &galaxys2_default_handlers,
- .gprs_specs = &galaxys2_gprs_specs,
+ .fmt_ops = &galaxys2_ipc_fmt_ops,
+ .rfs_ops = &galaxys2_ipc_rfs_ops,
+ .handlers = &galaxys2_ipc_handlers,
+ .gprs_specs = &galaxys2_ipc_gprs_specs,
.nv_data_specs = NULL,
},
{
.name = "galaxys2",
.board_name = "smdk4210",
.kernel_version = NULL,
- .fmt_ops = &galaxys2_fmt_ops,
- .rfs_ops = &galaxys2_rfs_ops,
- .handlers = &galaxys2_default_handlers,
- .gprs_specs = &galaxys2_gprs_specs,
+ .fmt_ops = &galaxys2_ipc_fmt_ops,
+ .rfs_ops = &galaxys2_ipc_rfs_ops,
+ .handlers = &galaxys2_ipc_handlers,
+ .gprs_specs = &galaxys2_ipc_gprs_specs,
.nv_data_specs = NULL,
},
{
.name = "maguro",
.board_name = "tuna",
.kernel_version = NULL,
- .fmt_ops = &maguro_fmt_ops,
- .rfs_ops = &maguro_rfs_ops,
- .handlers = &maguro_default_handlers,
- .gprs_specs = &maguro_gprs_specs,
- .nv_data_specs = &maguro_nv_data_specs,
+ .fmt_ops = &maguro_ipc_fmt_ops,
+ .rfs_ops = &maguro_ipc_rfs_ops,
+ .handlers = &maguro_ipc_handlers,
+ .gprs_specs = &maguro_ipc_gprs_specs,
+ .nv_data_specs = &maguro_ipc_nv_data_specs,
},
{
.name = "piranha",
.board_name = "espresso10",
.kernel_version = NULL,
- .fmt_ops = &piranha_fmt_ops,
- .rfs_ops = &piranha_rfs_ops,
- .handlers = &piranha_default_handlers,
- .gprs_specs = &piranha_gprs_specs,
+ .fmt_ops = &piranha_ipc_fmt_ops,
+ .rfs_ops = &piranha_ipc_rfs_ops,
+ .handlers = &piranha_ipc_handlers,
+ .gprs_specs = &piranha_ipc_gprs_specs,
.nv_data_specs = NULL,
},
{
.name = "piranha",
.board_name = "espresso",
.kernel_version = NULL,
- .fmt_ops = &piranha_fmt_ops,
- .rfs_ops = &piranha_rfs_ops,
- .handlers = &piranha_default_handlers,
- .gprs_specs = &piranha_gprs_specs,
+ .fmt_ops = &piranha_ipc_fmt_ops,
+ .rfs_ops = &piranha_ipc_rfs_ops,
+ .handlers = &piranha_ipc_handlers,
+ .gprs_specs = &piranha_ipc_gprs_specs,
.nv_data_specs = NULL,
}
};
diff --git a/samsung-ipc/ipc_devices.h b/samsung-ipc/ipc_devices.h
index 8c7dc95..17c16f1 100644
--- a/samsung-ipc/ipc_devices.h
+++ b/samsung-ipc/ipc_devices.h
@@ -39,38 +39,37 @@ extern struct ipc_device_desc ipc_devices[];
extern int ipc_devices_count;
/* crespo */
-extern struct ipc_ops crespo_fmt_ops;
-extern struct ipc_ops crespo_rfs_ops;
-extern struct ipc_handlers crespo_default_handlers;
-extern struct ipc_gprs_specs crespo_2_6_35_gprs_specs;
-extern struct ipc_gprs_specs crespo_3_0_gprs_specs;
+extern struct ipc_ops crespo_ipc_fmt_ops;
+extern struct ipc_ops crespo_ipc_rfs_ops;
+extern struct ipc_handlers crespo_ipc_handlers;
+extern struct ipc_gprs_specs crespo_2_6_35_ipc_gprs_specs;
+extern struct ipc_gprs_specs crespo_3_0_ipc_gprs_specs;
/* aries */
-extern struct ipc_ops aries_fmt_ops;
-extern struct ipc_ops aries_rfs_ops;
-extern struct ipc_handlers aries_default_handlers;
-extern struct ipc_gprs_specs aries_gprs_specs;
+extern struct ipc_ops aries_ipc_fmt_ops;
+extern struct ipc_ops aries_ipc_rfs_ops;
+extern struct ipc_handlers aries_ipc_handlers;
+extern struct ipc_gprs_specs aries_ipc_gprs_specs;
/* galaxys2 */
-extern struct ipc_ops galaxys2_fmt_ops;
-extern struct ipc_ops galaxys2_fmt_ops;
-extern struct ipc_ops galaxys2_rfs_ops;
-extern struct ipc_handlers galaxys2_default_handlers;
-extern struct ipc_gprs_specs galaxys2_gprs_specs;
+extern struct ipc_ops galaxys2_ipc_fmt_ops;
+extern struct ipc_ops galaxys2_ipc_rfs_ops;
+extern struct ipc_handlers galaxys2_ipc_handlers;
+extern struct ipc_gprs_specs galaxys2_ipc_gprs_specs;
/* maguro */
-extern struct ipc_ops maguro_fmt_ops;
-extern struct ipc_ops maguro_rfs_ops;
-extern struct ipc_handlers maguro_default_handlers;
-extern struct ipc_gprs_specs maguro_gprs_specs;
-extern struct ipc_nv_data_specs maguro_nv_data_specs;
+extern struct ipc_ops maguro_ipc_fmt_ops;
+extern struct ipc_ops maguro_ipc_rfs_ops;
+extern struct ipc_handlers maguro_ipc_handlers;
+extern struct ipc_gprs_specs maguro_ipc_gprs_specs;
+extern struct ipc_nv_data_specs maguro_ipc_nv_data_specs;
/* piranha */
-extern struct ipc_ops piranha_fmt_ops;
-extern struct ipc_ops piranha_rfs_ops;
-extern struct ipc_handlers piranha_default_handlers;
-extern struct ipc_gprs_specs piranha_gprs_specs;
-extern struct ipc_nv_data_specs piranha_nv_data_specs;
+extern struct ipc_ops piranha_ipc_fmt_ops;
+extern struct ipc_ops piranha_ipc_rfs_ops;
+extern struct ipc_handlers piranha_ipc_handlers;
+extern struct ipc_gprs_specs piranha_ipc_gprs_specs;
+extern struct ipc_nv_data_specs piranha_ipc_nv_data_specs;
#endif