-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DiagID Control packet Handling #11
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
#include "dm.h" | ||
#include "hdlc.h" | ||
#include "util.h" | ||
#include "diag_cntl.h" | ||
|
||
#define DIAG_CMD_KEEP_ALIVE_SUBSYS 50 | ||
#define DIAG_CMD_KEEP_ALIVE_CMD 3 | ||
|
@@ -52,6 +53,9 @@ | |
#define MOBILE_MODEL_STRING "DB410C" | ||
#define MSM_REVISION_NUMBER 2 | ||
|
||
#define DIAG_CMD_DIAG_SUBSYS 18 | ||
#define DIAG_CMD_DIAG_GET_DIAG_ID 0x222 | ||
|
||
static int handle_diag_version(struct diag_client *client, const void *buf, | ||
size_t len) | ||
{ | ||
|
@@ -117,11 +121,56 @@ static int handle_keep_alive(struct diag_client *client, const void *buf, | |
return dm_send(client, resp, sizeof(resp)); | ||
} | ||
|
||
static int handle_diag_id(struct diag_client *client, const void *buf, size_t len) | ||
{ | ||
struct diag_cmd_diag_id_query_req_t { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. diag_id_query_req |
||
uint8_t cmd_code; | ||
uint8_t subsys_id; | ||
uint16_t subsys_cmd_code; | ||
uint8_t version; | ||
} __packed; | ||
struct diag_cmd_diag_id_query_rsp_t { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. diag_id_query_resp |
||
struct diag_cmd_diag_id_query_req_t req_info; | ||
uint8_t num_entries; | ||
uint8_t payload[]; | ||
} __packed; | ||
struct diag_id_tbl_t *diag_id_item = NULL; | ||
struct list_head *diag_ids_head = NULL; | ||
uint8_t resp_buffer[DIAG_MAX_RSP_SIZE] = {0}; | ||
uint8_t *offset_resp = NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. offset_resp does not need to be null initialized, the first use of it is to assign it to resp_buffer |
||
uint8_t process_name_len = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't used anymore? |
||
size_t resp_len = 0; | ||
int num_entries = 0; | ||
KyleDengChunkai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (!buf || len < sizeof(struct diag_cmd_diag_id_query_req_t)) | ||
return -EMSGSIZE; | ||
|
||
struct diag_cmd_diag_id_query_req_t *req = (struct diag_cmd_diag_id_query_req_t *)buf; | ||
struct diag_cmd_diag_id_query_rsp_t *resp = (struct diag_cmd_diag_id_query_rsp_t *)resp_buffer; | ||
memcpy(resp_buffer, req, sizeof(struct diag_cmd_diag_id_query_req_t)); | ||
offset_resp = (uint8_t *)resp_buffer; | ||
resp_len = offsetof(struct diag_cmd_diag_id_query_rsp_t, payload); | ||
|
||
diag_ids_head = diag_get_diag_ids_head(); | ||
list_for_each_entry(diag_id_item, diag_ids_head, node) { | ||
if (resp_len >= DIAG_MAX_RSP_SIZE) | ||
break; | ||
memcpy(offset_resp + resp_len, &diag_id_item->diagid_info, diag_id_item->diag_id_info_len); | ||
resp_len += diag_id_item->diag_id_info_len; | ||
num_entries++; | ||
} | ||
KyleDengChunkai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
resp->num_entries = num_entries; | ||
|
||
return dm_send(client, resp_buffer, resp_len); | ||
} | ||
|
||
void register_app_cmds(void) | ||
{ | ||
register_fallback_cmd(DIAG_CMD_DIAG_VERSION_ID, handle_diag_version); | ||
register_fallback_cmd(DIAG_CMD_DIAG_VERSION_NO, handle_diag_version_no); | ||
register_fallback_cmd(DIAG_CMD_EXTENDED_BUILD_ID, handle_extended_build_id); | ||
register_fallback_subsys_cmd(DIAG_CMD_KEEP_ALIVE_SUBSYS, | ||
DIAG_CMD_KEEP_ALIVE_CMD, handle_keep_alive); | ||
register_fallback_subsys_cmd(DIAG_CMD_DIAG_SUBSYS, | ||
DIAG_CMD_DIAG_GET_DIAG_ID, handle_diag_id); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these headers are in alphabetical order, move this under "diag.h"