diff options
-rw-r--r-- | include/rfs.h | 42 | ||||
-rw-r--r-- | include/types.h | 2 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.c | 83 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.h | 12 | ||||
-rw-r--r-- | samsung-ipc/device/h1/h1_ipc.c | 2 | ||||
-rw-r--r-- | samsung-ipc/ipc.c | 7 |
6 files changed, 124 insertions, 24 deletions
diff --git a/include/rfs.h b/include/rfs.h new file mode 100644 index 0000000..7ce8cc2 --- /dev/null +++ b/include/rfs.h @@ -0,0 +1,42 @@ +/** + * This file is part of libsamsung-ipc. + * + * Copyright (C) 2011 Paul Kocialkowski <contact@paulk.fr> + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libsamsung-ipc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __RFS_H__ +#define __RFS_H__ + +struct ipc_message_info; + +#define IPC_RFS_NV_READ_ITEM 0x4201 +#define IPC_RFS_NV_WRITE_ITEM 0x4202 + +struct ipc_rfs_io { + unsigned int offset; + unsigned int length; +} __attribute__((__packed__)); + +struct ipc_rfs_io_confirm { + unsigned char confirm; + unsigned int offset; + unsigned int length; +} __attribute__((__packed__)); + +#endif + +// vim:ts=4:sw=4:expandtab diff --git a/include/types.h b/include/types.h index 0505820..0211042 100644 --- a/include/types.h +++ b/include/types.h @@ -29,6 +29,7 @@ #include "sec.h" #include "sms.h" #include "pwr.h" +#include "rfs.h" #include "snd.h" #include "gprs.h" @@ -62,6 +63,7 @@ #define IPC_GROUP_IMEI 0x10 #define IPC_GROUP_GPS 0x11 #define IPC_GROUP_SAP 0x12 +#define IPC_GROUP_RFS 0x42 #define IPC_GROUP_GEN 0x80 /* Pb */ diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c index 1ceff76..180973a 100644 --- a/samsung-ipc/device/crespo/crespo_ipc.c +++ b/samsung-ipc/device/crespo/crespo_ipc.c @@ -294,7 +294,7 @@ exit: return rc; } -int crespo_ipc_client_send(struct ipc_client *client, struct ipc_message_info *request) +int crespo_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request) { struct modem_io modem_data; struct ipc_header reqhdr; @@ -359,7 +359,7 @@ int wake_unlock(char *lock_name, int len) return rc; } -int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_message_info *response) +int crespo_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info *response) { struct modem_io modem_data; struct ipc_header *resphdr; @@ -377,15 +377,15 @@ int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_message_info *r bread = client->handlers->read((uint8_t*) &modem_data, sizeof(struct modem_io) + MAX_MODEM_DATA_SIZE, client->handlers->read_data); if (bread < 0) { - ipc_client_log(client, "ERROR: crespo_ipc_client_recv: can't receive enough bytes from modem to process incoming response!"); + ipc_client_log(client, "ERROR: crespo_ipc_fmt_client_recv: can't receive enough bytes from modem to process incoming response!"); return 1; } - ipc_client_log(client, "INFO: crespo_ipc_client_recv: Modem RECV FMT (id=%d cmd=%d size=%d)!", modem_data.id, modem_data.cmd, modem_data.size); + ipc_client_log(client, "INFO: crespo_ipc_fmt_client_recv: Modem RECV FMT (id=%d cmd=%d size=%d)!", modem_data.id, modem_data.cmd, modem_data.size); if(modem_data.size <= 0 || modem_data.size >= 0x1000 || modem_data.data == NULL) { - ipc_client_log(client, "ERROR: crespo_ipc_client_recv: we retrieve less bytes from the modem than we exepected!"); + ipc_client_log(client, "ERROR: crespo_ipc_fmt_client_recv: we retrieve less bytes from the modem than we exepected!"); return 1; } @@ -401,7 +401,7 @@ int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_message_info *r response->length = modem_data.size - sizeof(struct ipc_header); response->data = NULL; - ipc_client_log(client, "INFO: crespo_ipc_client_recv: response: type = %d (%s), group = %d, index = %d (%s)", + ipc_client_log(client, "INFO: crespo_ipc_fmt_client_recv: response: type = %d (%s), group = %d, index = %d (%s)", resphdr->type, ipc_response_type_to_str(resphdr->type), resphdr->group, resphdr->index, ipc_command_type_to_str(IPC_COMMAND(resphdr))); if(response->length > 0) @@ -423,6 +423,65 @@ int crespo_ipc_client_recv(struct ipc_client *client, struct ipc_message_info *r return 0; } +int crespo_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info *response) +{ + struct modem_io modem_data; + int bread = 0; + + memset(&modem_data, 0, sizeof(struct modem_io)); + modem_data.data = malloc(MAX_MODEM_DATA_SIZE); + modem_data.size = MAX_MODEM_DATA_SIZE; + + memset(response, 0, sizeof(struct ipc_message_info)); + + wake_lock("secril_rfs-interface", 20); + + 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); + if (bread < 0) + { + ipc_client_log(client, "ERROR: crespo_ipc_rfs_client_recv: can't receive enough bytes from modem to process incoming response!"); + return 1; + } + + ipc_client_log(client, "INFO: crespo_ipc_rfs_client_recv: Modem RECV RFS (id=%d cmd=%d size=%d)!", modem_data.id, modem_data.cmd, modem_data.size); + + if(modem_data.size <= 0 || modem_data.size >= 0x1000 || modem_data.data == NULL) + { + ipc_client_log(client, "ERROR: crespo_ipc_rfs_client_recv: we retrieve less bytes from the modem than we exepected!"); + return 1; + } + + response->mseq = 0; + response->aseq = modem_data.id; + response->group = IPC_GROUP_RFS; + response->index = modem_data.cmd; + response->type = 0; + response->length = modem_data.size; + response->data = NULL; + + ipc_client_log(client, "INFO: crespo_ipc_rfs_client_recv: response: group = %d, index = %d (%s)", + response->group, response->index, ipc_command_type_to_str(IPC_COMMAND(response))); + + if(response->length > 0) + { +#ifdef DEBUG + ipc_client_log(client, "INFO: ==== DATA DUMP ===="); + ipc_hex_dump(client, (void *) (modem_data.data), response->length); +#endif + response->data = malloc(response->length); + memcpy(response->data, (uint8_t *) modem_data.data, response->length); + } + + free(modem_data.data); + + ipc_client_log(client, ""); + + wake_unlock("secril_rfs-interface", 20); + + return 0; +} + int crespo_ipc_open(void *data, unsigned int size, void *io_data) { int type = *((int *) data); @@ -566,10 +625,16 @@ struct ipc_handlers ipc_default_handlers = { .power_off = crespo_ipc_power_off, }; -struct ipc_ops ipc_ops = { - .send = crespo_ipc_client_send, - .recv = crespo_ipc_client_recv, +struct ipc_ops ipc_fmt_ops = { + .send = crespo_ipc_fmt_client_send, + .recv = crespo_ipc_fmt_client_recv, .bootstrap = crespo_modem_bootstrap, }; +struct ipc_ops ipc_rfs_ops = { + .send = crespo_ipc_fmt_client_send, + .recv = crespo_ipc_rfs_client_recv, + .bootstrap = NULL, +}; + // vim:ts=4:sw=4:expandtab diff --git a/samsung-ipc/device/crespo/crespo_ipc.h b/samsung-ipc/device/crespo/crespo_ipc.h index e583c13..2667f2f 100644 --- a/samsung-ipc/device/crespo/crespo_ipc.h +++ b/samsung-ipc/device/crespo/crespo_ipc.h @@ -28,18 +28,6 @@ #define MAX_MODEM_DATA_SIZE 0x1000 -struct samsung_rfs_msg -{ - uint32_t offset; - uint32_t size; -}; - -struct samsung_rfs_cfrm -{ - uint8_t confirmation; - struct samsung_rfs_msg msg; -}; - int wake_lock(char *lock_name, int len); int wake_unlock(char *lock_name, int len); diff --git a/samsung-ipc/device/h1/h1_ipc.c b/samsung-ipc/device/h1/h1_ipc.c index b281265..ac229e5 100644 --- a/samsung-ipc/device/h1/h1_ipc.c +++ b/samsung-ipc/device/h1/h1_ipc.c @@ -220,7 +220,7 @@ struct ipc_handlers ipc_default_handlers = { .write = h1_ipc_write, }; -struct ipc_ops ipc_ops = { +struct ipc_ops ipc_fmt_ops = { .send = h1_ipc_send, .recv = h1_ipc_recv, .bootstrap = NULL, diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c index 511d7d8..77e5d97 100644 --- a/samsung-ipc/ipc.c +++ b/samsung-ipc/ipc.c @@ -29,7 +29,8 @@ #include "ipc_private.h" -extern struct ipc_ops ipc_ops; +extern struct ipc_ops ipc_fmt_ops; +extern struct ipc_ops ipc_rfs_ops; extern struct ipc_handlers ipc_default_handlers; void log_handler_default(const char *message, void *user_data) @@ -58,8 +59,10 @@ struct ipc_client* ipc_client_new(int client_type) switch (client_type) { case IPC_CLIENT_TYPE_FMT: + ops = &ipc_fmt_ops; + break; case IPC_CLIENT_TYPE_RFS: - ops = &ipc_ops; + ops = &ipc_rfs_ops; break; default: return NULL; |