diff options
-rw-r--r-- | include/radio.h | 4 | ||||
-rw-r--r-- | samsung-ipc/device/aries/aries_ipc.c | 48 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.c | 48 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_ipc.c | 32 | ||||
-rw-r--r-- | samsung-ipc/ipc_util.c | 66 |
5 files changed, 83 insertions, 115 deletions
diff --git a/include/radio.h b/include/radio.h index d606a3e..1e58d5b 100644 --- a/include/radio.h +++ b/include/radio.h @@ -98,6 +98,10 @@ void ipc_client_send_get(struct ipc_client *client, const unsigned short command void ipc_client_send_exec(struct ipc_client *client, const unsigned short command, unsigned char mseq); /* Utility functions */ +void ipc_client_log_recv(struct ipc_client *client, + struct ipc_message_info *response, char *prefix); +void ipc_client_log_send(struct ipc_client *client, + struct ipc_message_info *request, char *prefix); const char *ipc_response_type_to_str(int type); const char *ipc_request_type_to_str(int type); const char *ipc_command_to_str(int command); diff --git a/samsung-ipc/device/aries/aries_ipc.c b/samsung-ipc/device/aries/aries_ipc.c index 5ae509f..ab16960 100644 --- a/samsung-ipc/device/aries/aries_ipc.c +++ b/samsung-ipc/device/aries/aries_ipc.c @@ -445,19 +445,7 @@ int aries_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info assert(client->handlers->write != NULL); - ipc_client_log(client, "aries_ipc_fmt_client_send: SEND FMT!"); - ipc_client_log(client, "aries_ipc_fmt_client_send: IPC request (mseq=0x%02x command=%s (0x%04x) type=%s)", - request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request), ipc_request_type_to_str(request->type)); - -#ifdef DEBUG - if(request->length > 0) - { - ipc_client_log(client, "==== FMT DATA DUMP ===="); - ipc_hex_dump(client, (void *) request->data, request->length); - } -#endif - - ipc_client_log(client, ""); + ipc_client_log_send(client, request, __func__); rc = client->handlers->write(data, reqhdr.length, client->handlers->write_data); return rc; @@ -482,19 +470,7 @@ int aries_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info assert(client->handlers->write != NULL); - ipc_client_log(client, "aries_ipc_rfs_client_send: SEND RFS (id=%d cmd=%d len=%d)!", rfs_hdr->id, rfs_hdr->cmd, rfs_hdr->len); - ipc_client_log(client, "aries_ipc_rfs_client_send: IPC request (mseq=0x%02x command=%s (0x%04x))", - request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request)); - -#ifdef DEBUG - if(request->length > 0) - { - ipc_client_log(client, "==== RFS DATA DUMP ===="); - ipc_hex_dump(client, (void *) (data + sizeof(struct rfs_hdr)), request->length); - } -#endif - - ipc_client_log(client, ""); + ipc_client_log_send(client, request, __func__); rc = client->handlers->write((uint8_t*) data, rfs_hdr->len, client->handlers->write_data); return rc; @@ -536,23 +512,15 @@ int aries_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info response->length = resphdr->length - sizeof(struct ipc_header); response->data = NULL; - ipc_client_log(client, "aries_ipc_fmt_client_recv: RECV FMT!"); - ipc_client_log(client, "aries_ipc_fmt_client_recv: IPC response (aseq=0x%02x command=%s (0x%04x) type=%s)", - response->aseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response), ipc_response_type_to_str(response->type)); - if(response->length > 0) { -#ifdef DEBUG - ipc_client_log(client, "==== FMT DATA DUMP ===="); - ipc_hex_dump(client, (void *) (data + sizeof(struct ipc_header)), response->length); -#endif response->data = malloc(response->length); memcpy(response->data, (uint8_t *) data + sizeof(struct ipc_header), response->length); } free(data); - ipc_client_log(client, ""); + ipc_client_log_recv(client, response, __func__); return 0; } @@ -592,23 +560,15 @@ int aries_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info response->length = rfs_hdr->len - sizeof(struct rfs_hdr); response->data = NULL; - ipc_client_log(client, "aries_ipc_rfs_client_recv: RECV RFS (id=%d cmd=%d len=%d)!", rfs_hdr->id, rfs_hdr->cmd, rfs_hdr->len - sizeof(struct rfs_hdr)); - ipc_client_log(client, "aries_ipc_rfs_client_recv: IPC response (aseq=0x%02x command=%s (0x%04x))", - response->mseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response)); - if(response->length > 0) { -#ifdef DEBUG - ipc_client_log(client, "==== RFS DATA DUMP ===="); - ipc_hex_dump(client, (void *) (data + sizeof(struct rfs_hdr)), response->length); -#endif response->data = malloc(response->length); memcpy(response->data, (uint8_t *) (data + sizeof(struct rfs_hdr)), response->length); } free(data); - ipc_client_log(client, ""); + ipc_client_log_recv(client, response, __func__); return 0; } diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c index 1efe9b0..202f9b8 100644 --- a/samsung-ipc/device/crespo/crespo_ipc.c +++ b/samsung-ipc/device/crespo/crespo_ipc.c @@ -333,19 +333,7 @@ int crespo_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_inf assert(client->handlers->write != NULL); - ipc_client_log(client, "crespo_ipc_fmt_client_send: SEND FMT (id=%d cmd=%d size=%d)!", modem_data.id, modem_data.cmd, modem_data.size); - ipc_client_log(client, "crespo_ipc_fmt_client_send: IPC request (mseq=0x%02x command=%s (0x%04x) type=%s)", - request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request), ipc_request_type_to_str(request->type)); - -#ifdef DEBUG - if(request->length > 0) - { - ipc_client_log(client, "==== FMT DATA DUMP ===="); - ipc_hex_dump(client, (void *) request->data, request->length); - } -#endif - - ipc_client_log(client, ""); + 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; @@ -368,19 +356,7 @@ int crespo_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_inf assert(client->handlers->write != NULL); - ipc_client_log(client, "crespo_ipc_rfs_client_send: SEND RFS (id=%d cmd=%d size=%d)!", modem_data.id, modem_data.cmd, modem_data.size); - ipc_client_log(client, "crespo_ipc_rfs_client_send: IPC request (mseq=0x%02x command=%s (0x%04x))", - request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request)); - -#ifdef DEBUG - if(request->length > 0) - { - ipc_client_log(client, "==== RFS DATA DUMP ===="); - ipc_hex_dump(client, (void *) request->data, request->length); - } -#endif - - ipc_client_log(client, ""); + 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; @@ -424,23 +400,15 @@ int crespo_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_inf response->length = modem_data.size - sizeof(struct ipc_header); response->data = NULL; - ipc_client_log(client, "crespo_ipc_fmt_client_recv: RECV FMT (id=%d cmd=%d size=%d)!", modem_data.id, modem_data.cmd, modem_data.size); - ipc_client_log(client, "crespo_ipc_fmt_client_recv: IPC response (aseq=0x%02x command=%s (0x%04x) type=%s)", - response->aseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response), ipc_response_type_to_str(response->type)); - if(response->length > 0) { -#ifdef DEBUG - ipc_client_log(client, "==== FMT DATA DUMP ===="); - ipc_hex_dump(client, (void *) (modem_data.data + sizeof(struct ipc_header)), response->length); -#endif response->data = malloc(response->length); memcpy(response->data, (uint8_t *) modem_data.data + sizeof(struct ipc_header), response->length); } free(modem_data.data); - ipc_client_log(client, ""); + ipc_client_log_recv(client, response, __func__); wake_unlock("secril_fmt-interface", 20); @@ -482,23 +450,15 @@ int crespo_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_inf response->length = modem_data.size; response->data = NULL; - ipc_client_log(client, "crespo_ipc_rfs_client_recv: RECV RFS (id=%d cmd=%d size=%d)!", modem_data.id, modem_data.cmd, modem_data.size); - ipc_client_log(client, "crespo_ipc_rfs_client_recv: IPC response (aseq=0x%02x command=%s (0x%04x))", - response->mseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response)); - if(response->length > 0) { -#ifdef DEBUG - ipc_client_log(client, "==== RFS 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, ""); + ipc_client_log_recv(client, response, __func__); wake_unlock("secril_rfs-interface", 20); diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c index 7c84003..6f4d8ec 100644 --- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c +++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c @@ -71,11 +71,7 @@ int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_in payload = (frame + sizeof(*hdr)); memcpy(payload, request->data, request->length); - ipc_client_log(client, "sending %s %s\n", - ipc_command_to_str(IPC_COMMAND(request)), - ipc_response_type_to_str(request->type)); - - ipc_hex_dump(client, frame, frame_length); + ipc_client_log_send(client, request, __func__); client->handlers->write(frame, frame_length, client->handlers->write_data); @@ -126,11 +122,7 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in response->data = (unsigned char*)malloc(response->length); memcpy(response->data, buf + sizeof(ipc), response->length); - ipc_client_log(client, "received %s %s\n", - ipc_command_to_str(IPC_COMMAND(response)), - - ipc_response_type_to_str(response->type)); - ipc_hex_dump(client, response->data, left); + ipc_client_log_recv(client, response, __func__); return 0; } @@ -174,23 +166,11 @@ int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_in response->length = header.size - sizeof(struct rfs_hdr); response->data = NULL; - ipc_client_log(client, "READ %d bytes, header size says %d", - rc, header.size); - ipc_client_log(client, "%s: RECV RFS (id=%d cmd=%d size=%d)!", - __func__, header.id, header.cmd, header.size); - ipc_client_log(client, - "%s: IPC response (aseq=0x%02x command=%s (0x%04x))", - __func__, response->mseq, - ipc_command_to_str(IPC_COMMAND(response)), - IPC_COMMAND(response)); - if (response->length > 0) { response->data = malloc(response->length); memcpy(response->data, (void *) (buf + sizeof(struct rfs_hdr)), rc - sizeof(struct rfs_hdr)); - ipc_client_log(client, "writing at offset 0 %d bytes", - rc - sizeof(struct rfs_hdr)); } header_recv = 1; @@ -202,6 +182,8 @@ int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_in count += rc; } while (count < header.size); + ipc_client_log_recv(client, response, __func__); + return 0; } @@ -223,11 +205,7 @@ int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_in memcpy((void *) (data + sizeof(struct rfs_hdr)), request->data, request->length); - ipc_client_log(client, "%s: SEND RFS (id=%d cmd=%d size=%d)!", - __func__, header->id, header->cmd, header->size); - ipc_client_log(client, "%s: IPC request (mseq=0x%02x command=%s (0x%04x))", - __func__, request->mseq, ipc_command_to_str(IPC_COMMAND(request)), - IPC_COMMAND(request)); + ipc_client_log_send(client, request, __func__); rc = client->handlers->write(data, data_length, client->handlers->write_data); return rc; diff --git a/samsung-ipc/ipc_util.c b/samsung-ipc/ipc_util.c index 10e2ca9..500f4a1 100644 --- a/samsung-ipc/ipc_util.c +++ b/samsung-ipc/ipc_util.c @@ -34,6 +34,72 @@ #define IPC_STR(f) case f: return strdup(#f); +void ipc_client_log_recv(struct ipc_client *client, + struct ipc_message_info *response, char *prefix) +{ + switch (client->type) { + case IPC_CLIENT_TYPE_FMT: + ipc_client_log(client, "%s: RECV FMT!", prefix); + ipc_client_log(client, "%s: Response: aseq=0x%02x command=%s (0x%04x) type=%s", + prefix, response->aseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response), ipc_response_type_to_str(response->type)); +#ifdef DEBUG + if (response->length > 0) { + ipc_client_log(client, "==== FMT DATA DUMP ===="); + ipc_hex_dump(client, (void *) response->data, + response->length > 0x100 ? 0x100 : response->length); + } +#endif + break; + case IPC_CLIENT_TYPE_RFS: + ipc_client_log(client, "%s: RECV RFS!", prefix); + ipc_client_log(client, "%s: Response: aseq=0x%02x command=%s (0x%04x)", + prefix, response->aseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response)); +#ifdef DEBUG + if (response->length > 0) { + ipc_client_log(client, "==== RFS DATA DUMP ===="); + ipc_hex_dump(client, (void *) response->data, + response->length > 0x100 ? 0x100 : response->length); + } +#endif + break; + } + + ipc_client_log(client, ""); +} + +void ipc_client_log_send(struct ipc_client *client, + struct ipc_message_info *request, char *prefix) +{ + switch (client->type) { + case IPC_CLIENT_TYPE_FMT: + ipc_client_log(client, "%s: SEND FMT!", prefix); + ipc_client_log(client, "%s: Request: mseq=0x%02x command=%s (0x%04x) type=%s", + prefix, request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request), ipc_response_type_to_str(request->type)); +#ifdef DEBUG + if (request->length > 0) { + ipc_client_log(client, "==== FMT DATA DUMP ===="); + ipc_hex_dump(client, (void *) request->data, + request->length > 0x100 ? 0x100 : request->length); + } +#endif + break; + case IPC_CLIENT_TYPE_RFS: + ipc_client_log(client, "%s: SEND RFS!", prefix); + ipc_client_log(client, "%s: Request: mseq=0x%02x command=%s (0x%04x)", + prefix, request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request)); +#ifdef DEBUG + if (request->length > 0) { + ipc_client_log(client, "==== RFS DATA DUMP ===="); + ipc_hex_dump(client, (void *) request->data, + request->length > 0x100 ? 0x100 : request->length); + } +#endif + break; + } + + ipc_client_log(client, ""); +} + const char *ipc_response_type_to_str(int type) { switch(type) { case IPC_TYPE_INDI: |