diff options
-rw-r--r-- | include/protocol.h | 8 | ||||
-rw-r--r-- | include/samsung-ipc.h | 10 | ||||
-rw-r--r-- | samsung-ipc/device/aries/aries_ipc.c | 54 | ||||
-rw-r--r-- | samsung-ipc/device/aries/sipc4.h | 256 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.c | 24 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_sec_modem.c | 59 | ||||
-rw-r--r-- | samsung-ipc/ipc_util.c | 32 |
7 files changed, 105 insertions, 338 deletions
diff --git a/include/protocol.h b/include/protocol.h index 5a9c2cc..db651ea 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -75,7 +75,7 @@ * Structures */ -struct ipc_header { +struct ipc_fmt_header { unsigned short length; unsigned char mseq; unsigned char aseq; @@ -84,6 +84,12 @@ struct ipc_header { unsigned char type; } __attribute__((__packed__)); +struct ipc_rfs_header { + unsigned int length; + unsigned char index; + unsigned char id; +} __attribute__((__packed__)); + #endif // vim:ts=4:sw=4:expandtab diff --git a/include/samsung-ipc.h b/include/samsung-ipc.h index b68f6fc..1868709 100644 --- a/include/samsung-ipc.h +++ b/include/samsung-ipc.h @@ -37,7 +37,9 @@ struct ipc_client; struct ipc_handlers; -struct ipc_header; + +struct ipc_fmt_header; +struct ipc_rfs_header; struct ipc_message_info { unsigned char mseq; @@ -115,8 +117,10 @@ void ipc_client_log_recv(struct ipc_client *client, struct ipc_message_info *response, const char *prefix); void ipc_client_log_send(struct ipc_client *client, struct ipc_message_info *request, const char *prefix); -void ipc_header_fill(struct ipc_header *header, struct ipc_message_info *message); -void ipc_message_info_fill(struct ipc_header *header, struct ipc_message_info *message); +void ipc_fmt_header_fill(struct ipc_fmt_header *header, struct ipc_message_info *message); +void ipc_fmt_message_fill(struct ipc_fmt_header *header, struct ipc_message_info *message); +void ipc_rfs_header_fill(struct ipc_rfs_header *header, struct ipc_message_info *message); +void ipc_rfs_message_fill(struct ipc_rfs_header *header, struct ipc_message_info *message); /* * Samsung-IPC protocol diff --git a/samsung-ipc/device/aries/aries_ipc.c b/samsung-ipc/device/aries/aries_ipc.c index 1a3566b..7339594 100644 --- a/samsung-ipc/device/aries/aries_ipc.c +++ b/samsung-ipc/device/aries/aries_ipc.c @@ -35,7 +35,6 @@ #include <ipc.h> #include <util.h> -#include "sipc4.h" #include "onedram.h" #include "phonet.h" @@ -243,20 +242,20 @@ complete: int aries_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request) { - struct ipc_header header; + struct ipc_fmt_header header; void *buffer; int rc; if (client == NULL || client->handlers == NULL || client->handlers->write == NULL || request == NULL) return -1; - ipc_header_fill(&header, request); + ipc_fmt_header_fill(&header, request); buffer = malloc(header.length); - memcpy(buffer, &header, sizeof(struct ipc_header)); + memcpy(buffer, &header, sizeof(struct ipc_fmt_header)); if (request->data != NULL && request->length > 0) - memcpy((void *) ((unsigned char *) buffer + sizeof(struct ipc_header)), request->data, request->length); + memcpy((void *) ((unsigned char *) buffer + sizeof(struct ipc_fmt_header)), request->data, request->length); ipc_client_log_send(client, request, __func__); @@ -281,7 +280,7 @@ complete: int aries_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response) { - struct ipc_header *header; + struct ipc_fmt_header *header; void *buffer = NULL; int length; int rc; @@ -293,20 +292,20 @@ int aries_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *respo buffer = malloc(length); rc = client->handlers->read(client->handlers->transport_data, buffer, length); - if (rc < (int) sizeof(struct ipc_header)) { + if (rc < (int) sizeof(struct ipc_fmt_header)) { ipc_client_log(client, "Reading FMT data from the modem failed"); goto error; } - header = (struct ipc_header *) buffer; + header = (struct ipc_fmt_header *) buffer; - ipc_message_info_fill(header, response); + ipc_fmt_message_fill(header, response); - if (header->length > sizeof(struct ipc_header)) { - response->length = header->length - sizeof(struct ipc_header); + if (header->length > sizeof(struct ipc_fmt_header)) { + response->length = header->length - sizeof(struct ipc_fmt_header); response->data = malloc(response->length); - memcpy(response->data, (void *) ((unsigned char *) buffer + sizeof(struct ipc_header)), response->length); + memcpy(response->data, (void *) ((unsigned char *) buffer + sizeof(struct ipc_fmt_header)), response->length); } ipc_client_log_recv(client, response, __func__); @@ -328,26 +327,24 @@ complete: int aries_ipc_rfs_send(struct ipc_client *client, struct ipc_message_info *request) { - struct rfs_hdr header; + struct ipc_rfs_header header; void *buffer; int rc; if (client == NULL || client->handlers == NULL || client->handlers->write == NULL || request == NULL) return -1; - header.id = request->mseq; - header.cmd = request->index; - header.len = sizeof(struct rfs_hdr) + request->length; + ipc_rfs_header_fill(&header, request); - buffer = malloc(header.len); + buffer = malloc(header.length); - memcpy(buffer, &header, sizeof(struct rfs_hdr)); + memcpy(buffer, &header, sizeof(struct ipc_rfs_header)); if (request->data != NULL && request->length > 0) - memcpy((void *) ((unsigned char *) buffer + sizeof(struct rfs_hdr)), request->data, request->length); + memcpy((void *) ((unsigned char *) buffer + sizeof(struct ipc_rfs_header)), request->data, request->length); ipc_client_log_send(client, request, __func__); - rc = client->handlers->write(client->handlers->transport_data, buffer, header.len); + rc = client->handlers->write(client->handlers->transport_data, buffer, header.length); if (rc < 0) { ipc_client_log(client, "Writing RFS data to the modem failed"); goto error; @@ -368,7 +365,7 @@ complete: int aries_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *response) { - struct rfs_hdr *header; + struct ipc_rfs_header *header; void *buffer = NULL; int length; int rc; @@ -380,23 +377,20 @@ int aries_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *respo buffer = malloc(length); rc = client->handlers->read(client->handlers->transport_data, buffer, length); - if (rc < (int) sizeof(struct rfs_hdr)) { + if (rc < (int) sizeof(struct ipc_rfs_header)) { ipc_client_log(client, "Reading RFS data from the modem failed"); goto error; } - header = (struct rfs_hdr *) buffer; + header = (struct ipc_rfs_header *) buffer; - memset(response, 0, sizeof(struct ipc_message_info)); - response->aseq = header->id; - response->group = IPC_GROUP_RFS; - response->index = header->cmd; + ipc_rfs_message_fill(header, response); - if (header->len > sizeof(struct rfs_hdr)) { - response->length = header->len - sizeof(struct rfs_hdr); + if (header->length > sizeof(struct ipc_rfs_header)) { + response->length = header->length - sizeof(struct ipc_rfs_header); response->data = malloc(response->length); - memcpy(response->data, (void *) ((unsigned char *) buffer + sizeof(struct rfs_hdr)), response->length); + memcpy(response->data, (void *) ((unsigned char *) buffer + sizeof(struct ipc_rfs_header)), response->length); } ipc_client_log_recv(client, response, __func__); diff --git a/samsung-ipc/device/aries/sipc4.h b/samsung-ipc/device/aries/sipc4.h deleted file mode 100644 index 616d005..0000000 --- a/samsung-ipc/device/aries/sipc4.h +++ /dev/null @@ -1,256 +0,0 @@ -/** - * SAMSUNG MODEM IPC header version 4 - * - * Copyright (C) 2010 Samsung Electronics. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef __SAMSUNG_IPC_V4_H__ -#define __SAMSUNG_IPC_V4_H__ - -typedef uint32_t u32; -typedef uint16_t u16; -typedef uint8_t u8; - -/* IPC4.1 NEW PARTITION MAP - * This map is seen by AP side - - 0x00_0000 =========================================== - MAGIC(4)| ACCESS(4) | RESERVED(8) - 0x00_0010 ------------------------------------------- - FMT_OUT_PTR | FMT_IN_PTR - HEAD(4) | TAIL(4) | HEAD(4) | TAIL(4) - 0x00_0020 ------------------------------------------- - RAW_OUT_PTR | RAW_IN_PTR - HEAD(4) | TAIL(4) | HEAD(4) | TAIL(4) - 0x00_0030 ------------------------------------------- - RFS_OUT_PTR | RFS_IN_PTR - HEAD(4) | TAIL(4) | HEAD(4) | TAIL(4) - 0x00_0040 ------------------------------------------- - RESERVED (4KB - 64B) - 0x00_1000 ------------------------------------------- - CP Fatal Display (160B) - 0x00_10A0 ------------------------------------------- - RESERVED (1MB - 4kb-4kb-4kb - 160B) - 0x0F_E000 ------------------------------------------- - Formatted Out (4KB) - 0x0F_F000 ------------------------------------------- - Formatted In (4KB) - 0x10_0000 =========================================== - Raw Out (1MB) - 0x20_0000 =========================================== - Raw In (1MB) - 0x30_0000 =========================================== - RemoteFS Out (1MB) - 0x40_0000 =========================================== - RemoteFS In (1MB) - 0x50_0000 =========================================== - - 0xFF_FFFF =========================================== -*/ - -#define FMT_OUT 0x0FE000 -#define FMT_IN 0x0FF000 -#define FMT_SZ 0x1000 /* 4096 bytes */ - -#define RAW_OUT 0x100000 -#define RAW_IN 0x200000 -#define RAW_SZ 0x100000 /* 1 MB */ - -#define RFS_OUT 0x300000 -#define RFS_IN 0x400000 -#define RFS_SZ 0x100000 /* 1 MB */ - -#define FATAL_DISP 0x001000 -#define FATAL_DISP_SZ 0xA0 /* 160 bytes */ - -#define SIPC_MAP_SIZE (RFS_IN + RFS_SZ) -#define SIPC_NAME "IPCv4.1" - -enum { - IPCIDX_FMT = 0, - IPCIDX_RAW, - IPCIDX_RFS, - IPCIDX_MAX -}; - -struct ringbuf_cont { - u32 out_head; - u32 out_tail; - u32 in_head; - u32 in_tail; -}; - -struct sipc_mapped { /* map to the onedram start addr */ - u32 magic; - u32 access; - u32 hwrev; - u32 reserved; - - struct ringbuf_cont rbcont[IPCIDX_MAX]; -}; - - -#define PN_CMD 0x00 -#define PN_FMT 0x01 -#define PN_RFS 0x41 -#define PN_RAW(chid) (0x20 | (chid)) -#define CHID(x) ((x) & 0x1F) - -#define res_to_ridx(x) ((x) >> 5) - -/* - * IPC Frame Format - */ -#define HDLC_START 0x7F -#define HDLC_END 0x7E - -/* Formatted IPC Frame */ -struct fmt_hdr { - u16 len; - u8 control; -} __attribute__ ((packed)); - -#define FMT_ID_MASK 0x7F /* Information ID mask */ -#define FMT_ID_SIZE 0x80 /* = 128 ( 0 ~ 127 ) */ -#define FMT_MB_MASK 0x80 /* More bit mask */ - -#define FMT_TX_MIN 5 /* ??? */ - -#define is_fmt_last(x) (!((x) & FMT_MB_MASK)) - -/* RAW IPC Frame */ -struct raw_hdr { - u32 len; - u8 channel; - u8 control; -} __attribute__ ((packed)); - - -/* RFS IPC Frame */ -struct rfs_hdr { - u32 len; - u8 cmd; - u8 id; -} __attribute__ ((packed)); - -/* - * RAW frame channel ID - */ -enum { - CHID_0 = 0, - CHID_CSD_VT_DATA, - CHID_PDS_PVT_CONTROL, - CHID_PDS_VT_AUDIO, - CHID_PDS_VT_VIDEO, - CHID_5, /* 5 */ - CHID_6, - CHID_CDMA_DATA, - CHID_PCM_DATA, - CHID_TRANSFER_SCREEN, - CHID_PSD_DATA1, /* 10 */ - CHID_PSD_DATA2, - CHID_PSD_DATA3, - CHID_PSD_DATA4, - CHID_PSD_DATA5, - CHID_PSD_DATA6, /* 15 */ - CHID_PSD_DATA7, - CHID_PSD_DATA8, - CHID_PSD_DATA9, - CHID_PSD_DATA10, - CHID_PSD_DATA11, /* 20 */ - CHID_PSD_DATA12, - CHID_PSD_DATA13, - CHID_PSD_DATA14, - CHID_PSD_DATA15, - CHID_BT_DUN, /* 25 */ - CHID_CIQ_BRIDGE_DATA, - CHID_27, - CHID_CP_LOG1, - CHID_CP_LOG2, - CHID_30, /* 30 */ - CHID_31, - CHID_MAX -}; - -#define PDP_MAX 15 -#define PN_PDP_START PN_RAW(CHID_PSD_DATA1) -#define PN_PDP_END PN_RAW(CHID_PSD_DATA15) - -#define PN_PDP(chid) (0x20 | ((chid) + CHID_PSD_DATA1 - 1)) -#define PDP_ID(res) ((res) - PN_PDP_START) - - -/* - * IPC 4.0 Mailbox message definition - */ -#define MB_VALID 0x0080 -#define MB_COMMAND 0x0040 - -#define MB_CMD(x) (MB_VALID | MB_COMMAND | x) -#define MB_DATA(x) (MB_VALID | x) - -/* - * If not command - */ -#define MBD_SEND_FMT 0x0002 -#define MBD_SEND_RAW 0x0001 -#define MBD_SEND_RFS 0x0100 -#define MBD_REQ_ACK_FMT 0x0020 -#define MBD_REQ_ACK_RAW 0x0010 -#define MBD_REQ_ACK_RFS 0x0400 -#define MBD_RES_ACK_FMT 0x0008 -#define MBD_RES_ACK_RAW 0x0004 -#define MBD_RES_ACK_RFS 0x0200 - -/* - * If command - */ -enum { - MBC_NONE = 0, - MBC_INIT_START, // 0x0001 - MBC_INIT_END, // 0x0002 - MBC_REQ_ACTIVE, // 0x0003 - MBC_RES_ACTIVE, // 0x0004 - MBC_TIME_SYNC, // 0x0005 - MBC_POWER_OFF, // 0x0006 - MBC_RESET, // 0x0007 - MBC_PHONE_START, // 0x0008 - MBC_ERR_DISPLAY, // 0x0009 - MBC_POWER_SAVE, // 0x000A - MBC_NV_REBUILD, // 0x000B - MBC_EMER_DOWN, // 0x000C - MBC_REQ_SEM, // 0x000D - MBC_RES_SEM, // 0x000E - MBC_MAX // 0x000F -}; -#define MBC_MASK 0xFF - -/* CMD_INIT_END extended bit */ -#define CP_BOOT_ONLINE 0x0000 -#define CP_BOOT_AIRPLANE 0x1000 -#define AP_OS_ANDROID 0x0100 -#define AP_OS_WINMOBILE 0x0200 -#define AP_OS_LINUX 0x0300 -#define AP_OS_SYMBIAN 0x0400 - -/* CMD_PHONE_START extended bit */ -#define CP_QUALCOMM 0x0100 -#define CP_INFINEON 0x0200 -#define CP_BROADCOM 0x0300 - -#endif /* __SAMSUNG_IPC_V4_H__ */ - diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c index 279eddb..f4dfbfe 100644 --- a/samsung-ipc/device/crespo/crespo_ipc.c +++ b/samsung-ipc/device/crespo/crespo_ipc.c @@ -132,22 +132,22 @@ complete: int crespo_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request) { - struct ipc_header header; + struct ipc_fmt_header header; struct modem_io mio; int rc; if (client == NULL || client->handlers == NULL || client->handlers->write == NULL || request == NULL) return -1; - ipc_header_fill(&header, request); + ipc_fmt_header_fill(&header, request); memset(&mio, 0, sizeof(struct modem_io)); - mio.size = request->length + sizeof(struct ipc_header); + mio.size = request->length + sizeof(struct ipc_fmt_header); mio.data = malloc(mio.size); - memcpy(mio.data, &header, sizeof(struct ipc_header)); + memcpy(mio.data, &header, sizeof(struct ipc_fmt_header)); if (request->data != NULL && request->length > 0) - memcpy((void *) ((unsigned char *) mio.data + sizeof(struct ipc_header)), request->data, request->length); + memcpy((void *) ((unsigned char *) mio.data + sizeof(struct ipc_fmt_header)), request->data, request->length); ipc_client_log_send(client, request, __func__); @@ -172,7 +172,7 @@ complete: int crespo_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response) { - struct ipc_header *header; + struct ipc_fmt_header *header; struct modem_io mio; int rc; @@ -184,20 +184,20 @@ int crespo_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *resp mio.data = malloc(mio.size); rc = client->handlers->read(client->handlers->transport_data, &mio, sizeof(struct modem_io) + mio.size); - if (rc < 0 || mio.data == NULL || mio.size < sizeof(struct ipc_header)) { + if (rc < 0 || mio.data == NULL || mio.size < sizeof(struct ipc_fmt_header)) { ipc_client_log(client, "Reading FMT data from the modem failed"); goto error; } - header = (struct ipc_header *) mio.data; + header = (struct ipc_fmt_header *) mio.data; - ipc_message_info_fill(header, response); + ipc_fmt_message_fill(header, response); - if (mio.size > sizeof(struct ipc_header)) { - response->length = mio.size - sizeof(struct ipc_header); + if (mio.size > sizeof(struct ipc_fmt_header)) { + response->length = mio.size - sizeof(struct ipc_fmt_header); response->data = malloc(response->length); - memcpy(response->data, (void *) ((unsigned char *) mio.data + sizeof(struct ipc_header)), response->length); + memcpy(response->data, (void *) ((unsigned char *) mio.data + sizeof(struct ipc_fmt_header)), response->length); } ipc_client_log_recv(client, response, __func__); diff --git a/samsung-ipc/device/xmm6260/xmm6260_sec_modem.c b/samsung-ipc/device/xmm6260/xmm6260_sec_modem.c index 1a3629d..97b1ed4 100644 --- a/samsung-ipc/device/xmm6260/xmm6260_sec_modem.c +++ b/samsung-ipc/device/xmm6260/xmm6260_sec_modem.c @@ -174,7 +174,7 @@ int xmm6260_sec_modem_link_get_hostwake_wait(int device_fd) int xmm6260_sec_modem_ipc_fmt_send(struct ipc_client *client, struct ipc_message_info *request) { - struct ipc_header header; + struct ipc_fmt_header header; void *buffer; unsigned char *p; int count; @@ -183,13 +183,13 @@ int xmm6260_sec_modem_ipc_fmt_send(struct ipc_client *client, struct ipc_message if (client == NULL || client->handlers == NULL || client->handlers->write == NULL || request == NULL) return -1; - ipc_header_fill(&header, request); + ipc_fmt_header_fill(&header, request); buffer = malloc(header.length); - memcpy(buffer, &header, sizeof(struct ipc_header)); + memcpy(buffer, &header, sizeof(struct ipc_fmt_header)); if (request->data != NULL && request->length > 0) - memcpy((void *) ((unsigned char *) buffer + sizeof(struct ipc_header)), request->data, request->length); + memcpy((void *) ((unsigned char *) buffer + sizeof(struct ipc_fmt_header)), request->data, request->length); ipc_client_log_send(client, request, __func__); @@ -222,7 +222,7 @@ complete: int xmm6260_sec_modem_ipc_fmt_recv(struct ipc_client *client, struct ipc_message_info *response) { - struct ipc_header *header; + struct ipc_fmt_header *header; void *buffer = NULL; unsigned char *p; int length; @@ -236,24 +236,24 @@ int xmm6260_sec_modem_ipc_fmt_recv(struct ipc_client *client, struct ipc_message buffer = malloc(length); rc = client->handlers->read(client->handlers->transport_data, buffer, length); - if (rc < (int) sizeof(struct ipc_header)) { + if (rc < (int) sizeof(struct ipc_fmt_header)) { ipc_client_log(client, "Reading FMT header from the modem failed"); goto error; } - header = (struct ipc_header *) buffer; + header = (struct ipc_fmt_header *) buffer; - ipc_message_info_fill(header, response); + ipc_fmt_message_fill(header, response); - if (header->length > sizeof(struct ipc_header)) { - response->length = header->length - sizeof(struct ipc_header); + if (header->length > sizeof(struct ipc_fmt_header)) { + response->length = header->length - sizeof(struct ipc_fmt_header); response->data = malloc(response->length); p = (unsigned char *) response->data; - count = rc - sizeof(struct ipc_header); + count = rc - sizeof(struct ipc_fmt_header); if (count > 0) { - memcpy(p, (void *) ((unsigned char *) buffer + sizeof(struct ipc_header)), count); + memcpy(p, (void *) ((unsigned char *) buffer + sizeof(struct ipc_fmt_header)), count); p += count; } @@ -286,7 +286,7 @@ complete: int xmm6260_sec_modem_ipc_rfs_send(struct ipc_client *client, struct ipc_message_info *request) { - struct rfs_hdr header; + struct ipc_rfs_header header; void *buffer; unsigned char *p; int count; @@ -296,23 +296,21 @@ int xmm6260_sec_modem_ipc_rfs_send(struct ipc_client *client, struct ipc_message if (client == NULL || client->handlers == NULL || client->handlers->write == NULL || request == NULL) return -1; - header.id = request->mseq; - header.cmd = request->index; - header.len = sizeof(struct rfs_hdr) + request->length; + ipc_rfs_header_fill(&header, request); - buffer = malloc(header.len); + buffer = malloc(header.length); - memcpy(buffer, &header, sizeof(struct rfs_hdr)); + memcpy(buffer, &header, sizeof(struct ipc_rfs_header)); if (request->data != NULL && request->length > 0) - memcpy((void *) ((unsigned char *) buffer + sizeof(struct rfs_hdr)), request->data, request->length); + memcpy((void *) ((unsigned char *) buffer + sizeof(struct ipc_rfs_header)), request->data, request->length); ipc_client_log_send(client, request, __func__); p = (unsigned char *) buffer; count = 0; - while (count < (int) header.len) { - rc = client->handlers->write(client->handlers->transport_data, p, header.len - count); + while (count < (int) header.length) { + rc = client->handlers->write(client->handlers->transport_data, p, header.length - count); if (rc <= 0) { ipc_client_log(client, "Writing RFS data to the modem failed"); goto error; @@ -337,7 +335,7 @@ complete: int xmm6260_sec_modem_ipc_rfs_recv(struct ipc_client *client, struct ipc_message_info *response) { - struct rfs_hdr *header; + struct ipc_rfs_header *header; void *buffer = NULL; unsigned char *p; int length; @@ -351,27 +349,24 @@ int xmm6260_sec_modem_ipc_rfs_recv(struct ipc_client *client, struct ipc_message buffer = malloc(length); rc = client->handlers->read(client->handlers->transport_data, buffer, length); - if (rc < (int) sizeof(struct rfs_hdr)) { + if (rc < (int) sizeof(struct ipc_rfs_header)) { ipc_client_log(client, "Reading RFS header from the modem failed"); goto error; } - header = (struct rfs_hdr *) buffer; + header = (struct ipc_rfs_header *) buffer; - memset(response, 0, sizeof(struct ipc_message_info)); - response->aseq = header->id; - response->group = IPC_GROUP_RFS; - response->index = header->cmd; + ipc_rfs_message_fill(header, response); - if (header->len > sizeof(struct rfs_hdr)) { - response->length = header->len - sizeof(struct rfs_hdr); + if (header->length > sizeof(struct ipc_rfs_header)) { + response->length = header->length - sizeof(struct ipc_rfs_header); response->data = malloc(response->length); p = (unsigned char *) response->data; - count = rc - sizeof(struct rfs_hdr); + count = rc - sizeof(struct ipc_rfs_header); if (count > 0) { - memcpy(p, (void *) ((unsigned char *) buffer + sizeof(struct rfs_hdr)), count); + memcpy(p, (void *) ((unsigned char *) buffer + sizeof(struct ipc_rfs_header)), count); p += count; } diff --git a/samsung-ipc/ipc_util.c b/samsung-ipc/ipc_util.c index f8b7fe9..1af1fec 100644 --- a/samsung-ipc/ipc_util.c +++ b/samsung-ipc/ipc_util.c @@ -442,21 +442,21 @@ void ipc_client_log_send(struct ipc_client *client, } } -void ipc_header_fill(struct ipc_header *header, struct ipc_message_info *message) +void ipc_fmt_header_fill(struct ipc_fmt_header *header, struct ipc_message_info *message) { if (header == NULL || message == NULL) return; - memset(header, 0, sizeof(struct ipc_header)); + memset(header, 0, sizeof(struct ipc_fmt_header)); header->mseq = message->mseq; header->aseq = message->aseq; header->group = message->group; header->index = message->index; header->type = message->type; - header->length = message->length + sizeof(struct ipc_header); + header->length = message->length + sizeof(struct ipc_fmt_header); } -void ipc_message_info_fill(struct ipc_header *header, struct ipc_message_info *message) +void ipc_fmt_message_fill(struct ipc_fmt_header *header, struct ipc_message_info *message) { if (header == NULL || message == NULL) return; @@ -472,4 +472,28 @@ void ipc_message_info_fill(struct ipc_header *header, struct ipc_message_info *m message->data = NULL; } +void ipc_rfs_header_fill(struct ipc_rfs_header *header, struct ipc_message_info *message) +{ + if (header == NULL || message == NULL) + return; + + memset(header, 0, sizeof(struct ipc_rfs_header)); + header->id = message->mseq; + header->index = message->index; + header->length = message->length + sizeof(struct ipc_rfs_header); +} + +void ipc_rfs_message_fill(struct ipc_rfs_header *header, struct ipc_message_info *message) +{ + if (header == NULL || message == NULL) + return; + + memset(message, 0, sizeof(struct ipc_message_info)); + message->aseq = header->id; + message->group = IPC_GROUP_RFS; + message->index = header->index; + message->length = 0; + message->data = NULL; +} + // vim:ts=4:sw=4:expandtab |