void diag_send_data(struct diag_master_table entry, unsigned char *buf, int len, int type) { driver->pkt_length = len; if (entry.process_id != NON_APPS_PROC && type != MODEM_DATA) { diag_update_pkt_buffer(buf); diag_update_sleeping_process(entry.process_id); } else { if (len > 0) { if (entry.client_id == MODEM_PROC && driver->ch) { if (cpu_is_msm8960() && (int)(*(char *)buf) == MODE_CMD) if ((int)(*(char *)(buf+1)) == RESET_ID) return; smd_write(driver->ch, buf, len); } else if (entry.client_id == QDSP_PROC && driver->chqdsp) { smd_write(driver->chqdsp, buf, len); } else if (entry.client_id == WCNSS_PROC && driver->ch_wcnss) { smd_write(driver->ch_wcnss, buf, len); } else { pr_alert("diag: incorrect channel"); } } } }
void diag_send_data(struct diag_master_table entry, unsigned char *buf, int len, int type) { driver->pkt_length = len; if (entry.process_id != NON_APPS_PROC && type != MODEM_DATA) { diag_update_pkt_buffer(buf); diag_update_sleeping_process(entry.process_id, PKT_TYPE); } else { if (len > 0) { if ((entry.client_id >= 0) && (entry.client_id < NUM_SMD_DATA_CHANNELS)) { int index = entry.client_id; if (driver->smd_data[index].ch) { if ((index == MODEM_DATA) && diag_check_mode_reset(buf)) { return; } smd_write(driver->smd_data[index].ch, buf, len); } else { pr_err("diag: In %s, smd channel %d not open\n", __func__, index); } } else { pr_alert("diag: In %s, incorrect channel: %d", __func__, entry.client_id); } } } }
static int diag_process_apps_pkt(unsigned char *buf, int len) { uint16_t start; uint16_t end, subsys_cmd_code; int i, cmd_code, subsys_id; int packet_type = 1; unsigned char *temp = buf; /* event mask */ if ((*buf == 0x60) && (*(++buf) == 0x0)) { diag_update_event_mask(buf, 0, 0); diag_update_userspace_clients(EVENT_MASKS_TYPE); } /* check for set event mask */ else if (*buf == 0x82) { buf += 4; diag_update_event_mask(buf, 1, *(uint16_t *)buf); diag_update_userspace_clients( EVENT_MASKS_TYPE); } /* log mask */ else if (*buf == 0x73) { buf += 4; if (*(int *)buf == 3) { buf += 4; /* Read Equip ID and pass as first param below*/ diag_update_log_mask(*(int *)buf, buf+8, *(int *)(buf+4)); diag_update_userspace_clients(LOG_MASKS_TYPE); } } /* Check for set message mask */ else if ((*buf == 0x7d) && (*(++buf) == 0x4)) { buf++; start = *(uint16_t *)buf; buf += 2; end = *(uint16_t *)buf; buf += 4; diag_update_msg_mask((uint32_t)start, (uint32_t)end , buf); diag_update_userspace_clients(MSG_MASKS_TYPE); } /* Set all run-time masks if ((*buf == 0x7d) && (*(++buf) == 0x5)) { TO DO } */ #if defined(CONFIG_DIAG_NO_MODEM) && defined(CONFIG_DIAG_OVER_USB) /* Respond to polling for Apps only DIAG */ else if ((*buf == 0x4b) && (*(buf+1) == 0x32) && (*(buf+2) == 0x03)) { for (i = 0; i < 3; i++) driver->apps_rsp_buf[i] = *(buf+i); for (i = 0; i < 13; i++) driver->apps_rsp_buf[i+3] = 0; ENCODE_RSP_AND_SEND(15); return 0; } /* respond to 0x0 command */ else if (*buf == 0x00) { for (i = 0; i < 55; i++) driver->apps_rsp_buf[i] = 0; ENCODE_RSP_AND_SEND(54); return 0; } /* respond to 0x7c command */ else if (*buf == 0x7c) { driver->apps_rsp_buf[0] = 0x7c; for (i = 1; i < 8; i++) driver->apps_rsp_buf[i] = 0; *(int *)(driver->apps_rsp_buf + 8) = 4062; /* ID for APQ 8060 */ *(unsigned char *)(driver->apps_rsp_buf + 12) = '\0'; *(unsigned char *)(driver->apps_rsp_buf + 13) = '\0'; ENCODE_RSP_AND_SEND(13); return 0; } #endif /* DIAG over USB & NO MODEM present */ /* Check for registered clients and forward packet to user-space */ else{ cmd_code = (int)(*(char *)buf); temp++; subsys_id = (int)(*(char *)temp); temp++; subsys_cmd_code = *(uint16_t *)temp; temp += 2; for (i = 0; i < diag_max_registration; i++) { if (driver->table[i].process_id != 0) { if (driver->table[i].cmd_code == cmd_code && driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i].process_id); return 0; } /* end of if */ else if (driver->table[i].cmd_code == 255 && cmd_code == 75) { if (driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i]. process_id); return 0; } } /* end of else-if */ else if (driver->table[i].cmd_code == 255 && driver->table[i].subsys_id == 255) { if (driver->table[i].cmd_code_lo <= cmd_code && driver->table[i]. cmd_code_hi >= cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process (driver->table[i]. process_id); return 0; } } /* end of else-if */ } /* if(driver->table[i].process_id != 0) */ } /* for (i = 0; i < diag_max_registration; i++) */ } /* else */ return packet_type; }
static int diag_process_apps_pkt(unsigned char *buf, int len) { uint16_t start; uint16_t end, subsys_cmd_code; int i, cmd_code, subsys_id; int packet_type = 1; unsigned char *temp = buf; /* event mask */ if ((*buf == 0x60) && (*(++buf) == 0x0)) { diag_update_event_mask(buf, 0, 0); diag_update_userspace_clients(EVENT_MASKS_TYPE); } /* check for set event mask */ else if (*buf == 0x82) { buf += 4; diag_update_event_mask(buf, 1, *(uint16_t *)buf); diag_update_userspace_clients( EVENT_MASKS_TYPE); } /* log mask */ else if (*buf == 0x73) { buf += 4; if (*(int *)buf == 3) { buf += 8; diag_update_log_mask(buf+4, *(int *)buf); diag_update_userspace_clients(LOG_MASKS_TYPE); } } /* Check for set message mask */ else if ((*buf == 0x7d) && (*(++buf) == 0x4)) { buf++; start = *(uint16_t *)buf; buf += 2; end = *(uint16_t *)buf; buf += 4; diag_update_msg_mask((uint32_t)start, (uint32_t)end , buf); diag_update_userspace_clients(MSG_MASKS_TYPE); } /* Set all run-time masks if ((*buf == 0x7d) && (*(++buf) == 0x5)) { TO DO } */ /* Check for registered clients and forward packet to user-space */ else{ cmd_code = (int)(*(char *)buf); temp++; subsys_id = (int)(*(char *)temp); temp++; subsys_cmd_code = *(uint16_t *)temp; temp += 2; for (i = 0; i < REG_TABLE_SIZE; i++) { if (driver->table[i].process_id != 0) { if (driver->table[i].cmd_code == cmd_code && driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i].process_id); return 0; } /* end of if */ else if (driver->table[i].cmd_code == 255 && cmd_code == 75) { if (driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i]. process_id); return 0; } } /* end of else-if */ else if (driver->table[i].cmd_code == 255 && driver->table[i].subsys_id == 255) { if (driver->table[i].cmd_code_lo <= cmd_code && driver->table[i]. cmd_code_hi >= cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process (driver->table[i]. process_id); return 0; } } /* end of else-if */ } /* if(driver->table[i].process_id != 0) */ } /* for (i = 0; i < REG_TABLE_SIZE; i++) */ } /* else */ return packet_type; }
static void diag_smd_dci_send_req(int proc_num) { void *buf = NULL; smd_channel_t *smd_ch = NULL; int i, r, found = 1; int cmd_code_len = 1; if (driver->in_busy_dci) return; if (proc_num == MODEM_PROC) { buf = driver->buf_in_dci; smd_ch = driver->ch_dci; } if (!smd_ch || !buf) return; r = smd_read_avail(smd_ch); if (r > IN_BUF_SIZE) { if (r < MAX_IN_BUF_SIZE) { pr_err("diag: SMD DCI sending pkt upto %d bytes", r); buf = krealloc(buf, r, GFP_KERNEL); } else { pr_err("diag: DCI pkt > %d bytes", MAX_IN_BUF_SIZE); return; } } if (buf && r > 0) { smd_read(smd_ch, buf, r); diag_printk(1,"diag:%s data received ---\n",__func__); for (i = 0; i < r; i++) diag_printk(1,"\t %x \t", *(((unsigned char *)buf)+i)); if (*(uint8_t *)(buf+4) != DCI_CMD_CODE) cmd_code_len = 4; /* delayed response */ driver->write_ptr_dci->length = (int)(*(uint16_t *)(buf+2)) - (4+cmd_code_len); diag_printk(1,"diag:%s len = %d\n",__func__, (int)(*(uint16_t *)(buf+2)) - (4+cmd_code_len)); /* look up DCI client with tag */ for (i = 0; i < dci_max_reg; i++) { if (driver->dci_tbl[i].tag == *(int *)(buf+(4+cmd_code_len))) { found = 0; break; } } if (found) pr_alert("diag: No matching PID for DCI data\n"); diag_printk(1,"\n diag:%s PID = %d",__func__, driver->dci_tbl[i].pid); if (driver->dci_tbl[i].pid == 0) pr_alert("diag: Receiving DCI process deleted\n"); *(int *)(buf+4+cmd_code_len) = driver->dci_tbl[i].uid; /* update len after adding UID */ driver->write_ptr_dci->length = driver->write_ptr_dci->length + 4; diag_printk(1,"diag:%s data receivd, wake process\n",__func__); driver->in_busy_dci = 1; diag_update_sleeping_process(driver->dci_tbl[i].pid, DCI_DATA_TYPE); /* delete immediate response entry */ if (driver->buf_in_dci[8+cmd_code_len] != 0x80) driver->dci_tbl[i].pid = 0; for (i = 0; i < dci_max_reg; i++) if (driver->dci_tbl[i].pid != 0) diag_printk(1,"diag:%s PID = %d, UID = %d, tag = %d\n", __func__,driver->dci_tbl[i].pid, driver->dci_tbl[i].uid, driver->dci_tbl[i].tag); diag_printk(1,"diag:%s completed clearing table\n",__func__); } }
static int diag_process_apps_pkt(unsigned char *buf, int len) { uint16_t subsys_cmd_code; int subsys_id, ssid_first, ssid_last, ssid_range; int packet_type = 1, i, cmd_code; unsigned char *temp = buf; #if defined(CONFIG_DIAG_OVER_USB) int payload_length; unsigned char *ptr; #endif #if 1 //def LG_FW_USB_ACCESS_LOCK // LGE_CHANGE_S [email protected] if ((buf[0]!=0xA1 && buf[0]!=0x29) && user_diag_enable == 0) return 0; #endif /* set event mask */ if (*buf == 0x82) { buf += 4; diag_update_event_mask(buf, 1, *(uint16_t *)buf); diag_update_userspace_clients(EVENT_MASKS_TYPE); } /* event mask change */ else if ((*buf == 0x60) && (*(buf+1) == 0x0)) { diag_update_event_mask(buf+1, 0, 0); diag_update_userspace_clients(EVENT_MASKS_TYPE); #if defined(CONFIG_DIAG_OVER_USB) /* Check for Apps Only 8960 */ if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID)) { /* echo response back for apps only DIAG */ driver->apps_rsp_buf[0] = 0x60; driver->apps_rsp_buf[1] = 0x0; driver->apps_rsp_buf[2] = 0x0; ENCODE_RSP_AND_SEND(2); return 0; } #endif } /* Set log masks */ else if (*buf == 0x73 && *(int *)(buf+4) == 3) { buf += 8; /* Read Equip ID and pass as first param below*/ diag_update_log_mask(*(int *)buf, buf+8, *(int *)(buf+4)); diag_update_userspace_clients(LOG_MASKS_TYPE); #if defined(CONFIG_DIAG_OVER_USB) /* Check for Apps Only 8960 */ if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID)) { /* echo response back for Apps only DIAG */ driver->apps_rsp_buf[0] = 0x73; *(int *)(driver->apps_rsp_buf + 4) = 0x3; /* op. ID */ *(int *)(driver->apps_rsp_buf + 8) = 0x0; /* success */ payload_length = 8 + ((*(int *)(buf + 4)) + 7)/8; for (i = 0; i < payload_length; i++) *(int *)(driver->apps_rsp_buf+12+i) = *(buf+8+i); ENCODE_RSP_AND_SEND(12 + payload_length - 1); return 0; } #endif } /* Check for set message mask */ else if ((*buf == 0x7d) && (*(buf+1) == 0x4)) { ssid_first = *(uint16_t *)(buf + 2); ssid_last = *(uint16_t *)(buf + 4); ssid_range = 4 * (ssid_last - ssid_first + 1); diag_update_msg_mask(ssid_first, ssid_last , buf + 8); diag_update_userspace_clients(MSG_MASKS_TYPE); #if defined(CONFIG_DIAG_OVER_USB) if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID)) { /* echo response back for apps only DIAG */ for (i = 0; i < 8 + ssid_range; i++) *(driver->apps_rsp_buf + i) = *(buf+i); ENCODE_RSP_AND_SEND(8 + ssid_range - 1); return 0; } #endif } #if defined(CONFIG_DIAG_OVER_USB) /* Check for Apps Only 8960 & get event mask request */ else if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID) && *buf == 0x81) { driver->apps_rsp_buf[0] = 0x81; driver->apps_rsp_buf[1] = 0x0; *(uint16_t *)(driver->apps_rsp_buf + 2) = 0x0; *(uint16_t *)(driver->apps_rsp_buf + 4) = EVENT_LAST_ID + 1; for (i = 0; i < EVENT_LAST_ID/8 + 1; i++) *(unsigned char *)(driver->apps_rsp_buf + 6 + i) = 0x0; ENCODE_RSP_AND_SEND(6 + EVENT_LAST_ID/8); return 0; } /* Get log ID range & Check for Apps Only 8960 */ else if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID) && (*buf == 0x73) && *(int *)(buf+4) == 1) { driver->apps_rsp_buf[0] = 0x73; *(int *)(driver->apps_rsp_buf + 4) = 0x1; /* operation ID */ *(int *)(driver->apps_rsp_buf + 8) = 0x0; /* success code */ *(int *)(driver->apps_rsp_buf + 12) = LOG_GET_ITEM_NUM(LOG_0); *(int *)(driver->apps_rsp_buf + 16) = LOG_GET_ITEM_NUM(LOG_1); *(int *)(driver->apps_rsp_buf + 20) = LOG_GET_ITEM_NUM(LOG_2); *(int *)(driver->apps_rsp_buf + 24) = LOG_GET_ITEM_NUM(LOG_3); *(int *)(driver->apps_rsp_buf + 28) = LOG_GET_ITEM_NUM(LOG_4); *(int *)(driver->apps_rsp_buf + 32) = LOG_GET_ITEM_NUM(LOG_5); *(int *)(driver->apps_rsp_buf + 36) = LOG_GET_ITEM_NUM(LOG_6); *(int *)(driver->apps_rsp_buf + 40) = LOG_GET_ITEM_NUM(LOG_7); *(int *)(driver->apps_rsp_buf + 44) = LOG_GET_ITEM_NUM(LOG_8); *(int *)(driver->apps_rsp_buf + 48) = LOG_GET_ITEM_NUM(LOG_9); *(int *)(driver->apps_rsp_buf + 52) = LOG_GET_ITEM_NUM(LOG_10); *(int *)(driver->apps_rsp_buf + 56) = LOG_GET_ITEM_NUM(LOG_11); *(int *)(driver->apps_rsp_buf + 60) = LOG_GET_ITEM_NUM(LOG_12); *(int *)(driver->apps_rsp_buf + 64) = LOG_GET_ITEM_NUM(LOG_13); *(int *)(driver->apps_rsp_buf + 68) = LOG_GET_ITEM_NUM(LOG_14); *(int *)(driver->apps_rsp_buf + 72) = LOG_GET_ITEM_NUM(LOG_15); ENCODE_RSP_AND_SEND(75); return 0; } /* Respond to Get SSID Range request message */ else if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID) && (*buf == 0x7d) && (*(buf+1) == 0x1)) { driver->apps_rsp_buf[0] = 0x7d; driver->apps_rsp_buf[1] = 0x1; driver->apps_rsp_buf[2] = 0x1; driver->apps_rsp_buf[3] = 0x0; *(int *)(driver->apps_rsp_buf + 4) = MSG_MASK_TBL_CNT; *(uint16_t *)(driver->apps_rsp_buf + 8) = MSG_SSID_0; *(uint16_t *)(driver->apps_rsp_buf + 10) = MSG_SSID_0_LAST; *(uint16_t *)(driver->apps_rsp_buf + 12) = MSG_SSID_1; *(uint16_t *)(driver->apps_rsp_buf + 14) = MSG_SSID_1_LAST; *(uint16_t *)(driver->apps_rsp_buf + 16) = MSG_SSID_2; *(uint16_t *)(driver->apps_rsp_buf + 18) = MSG_SSID_2_LAST; *(uint16_t *)(driver->apps_rsp_buf + 20) = MSG_SSID_3; *(uint16_t *)(driver->apps_rsp_buf + 22) = MSG_SSID_3_LAST; *(uint16_t *)(driver->apps_rsp_buf + 24) = MSG_SSID_4; *(uint16_t *)(driver->apps_rsp_buf + 26) = MSG_SSID_4_LAST; *(uint16_t *)(driver->apps_rsp_buf + 28) = MSG_SSID_5; *(uint16_t *)(driver->apps_rsp_buf + 30) = MSG_SSID_5_LAST; *(uint16_t *)(driver->apps_rsp_buf + 32) = MSG_SSID_6; *(uint16_t *)(driver->apps_rsp_buf + 34) = MSG_SSID_6_LAST; *(uint16_t *)(driver->apps_rsp_buf + 36) = MSG_SSID_7; *(uint16_t *)(driver->apps_rsp_buf + 38) = MSG_SSID_7_LAST; *(uint16_t *)(driver->apps_rsp_buf + 40) = MSG_SSID_8; *(uint16_t *)(driver->apps_rsp_buf + 42) = MSG_SSID_8_LAST; *(uint16_t *)(driver->apps_rsp_buf + 44) = MSG_SSID_9; *(uint16_t *)(driver->apps_rsp_buf + 46) = MSG_SSID_9_LAST; *(uint16_t *)(driver->apps_rsp_buf + 48) = MSG_SSID_10; *(uint16_t *)(driver->apps_rsp_buf + 50) = MSG_SSID_10_LAST; *(uint16_t *)(driver->apps_rsp_buf + 52) = MSG_SSID_11; *(uint16_t *)(driver->apps_rsp_buf + 54) = MSG_SSID_11_LAST; *(uint16_t *)(driver->apps_rsp_buf + 56) = MSG_SSID_12; *(uint16_t *)(driver->apps_rsp_buf + 58) = MSG_SSID_12_LAST; *(uint16_t *)(driver->apps_rsp_buf + 60) = MSG_SSID_13; *(uint16_t *)(driver->apps_rsp_buf + 62) = MSG_SSID_13_LAST; *(uint16_t *)(driver->apps_rsp_buf + 64) = MSG_SSID_14; *(uint16_t *)(driver->apps_rsp_buf + 66) = MSG_SSID_14_LAST; *(uint16_t *)(driver->apps_rsp_buf + 68) = MSG_SSID_15; *(uint16_t *)(driver->apps_rsp_buf + 70) = MSG_SSID_15_LAST; *(uint16_t *)(driver->apps_rsp_buf + 72) = MSG_SSID_16; *(uint16_t *)(driver->apps_rsp_buf + 74) = MSG_SSID_16_LAST; *(uint16_t *)(driver->apps_rsp_buf + 76) = MSG_SSID_17; *(uint16_t *)(driver->apps_rsp_buf + 78) = MSG_SSID_17_LAST; *(uint16_t *)(driver->apps_rsp_buf + 80) = MSG_SSID_18; *(uint16_t *)(driver->apps_rsp_buf + 82) = MSG_SSID_18_LAST; ENCODE_RSP_AND_SEND(83); return 0; } /* Check for AO8960 Respond to Get Subsys Build mask */ else if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID) && (*buf == 0x7d) && (*(buf+1) == 0x2)) { ssid_first = *(uint16_t *)(buf + 2); ssid_last = *(uint16_t *)(buf + 4); ssid_range = 4 * (ssid_last - ssid_first + 1); /* frame response */ driver->apps_rsp_buf[0] = 0x7d; driver->apps_rsp_buf[1] = 0x2; *(uint16_t *)(driver->apps_rsp_buf + 2) = ssid_first; *(uint16_t *)(driver->apps_rsp_buf + 4) = ssid_last; driver->apps_rsp_buf[6] = 0x1; driver->apps_rsp_buf[7] = 0x0; ptr = driver->apps_rsp_buf + 8; /* bld time masks */ switch (ssid_first) { case MSG_SSID_0: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_0[i/4]; break; case MSG_SSID_1: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_1[i/4]; break; case MSG_SSID_2: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_2[i/4]; break; case MSG_SSID_3: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_3[i/4]; break; case MSG_SSID_4: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_4[i/4]; break; case MSG_SSID_5: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_5[i/4]; break; case MSG_SSID_6: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_6[i/4]; break; case MSG_SSID_7: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_7[i/4]; break; case MSG_SSID_8: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_8[i/4]; break; case MSG_SSID_9: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_9[i/4]; break; case MSG_SSID_10: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_10[i/4]; break; case MSG_SSID_11: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_11[i/4]; break; case MSG_SSID_12: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_12[i/4]; break; case MSG_SSID_13: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_13[i/4]; break; case MSG_SSID_14: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_14[i/4]; break; case MSG_SSID_15: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_15[i/4]; break; case MSG_SSID_16: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_16[i/4]; break; case MSG_SSID_17: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_17[i/4]; break; case MSG_SSID_18: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_18[i/4]; break; } ENCODE_RSP_AND_SEND(8 + ssid_range - 1); return 0; } /* Check for download command */ else if (cpu_is_msm8x60() && (*buf == 0x3A)) { /* send response back */ driver->apps_rsp_buf[0] = *buf; ENCODE_RSP_AND_SEND(0); msleep(5000); /* call download API */ msm_set_restart_mode(RESTART_DLOAD); printk(KERN_CRIT "diag: download mode set, Rebooting SoC..\n"); lock_kernel(); kernel_restart(NULL); unlock_kernel(); /* Not required, represents that command isnt sent to modem */ return 0; } /* Check for ID for NO MODEM present */ else if (!(driver->ch) && chk_config_get_id()) { /* Respond to polling for Apps only DIAG */ if ((*buf == 0x4b) && (*(buf+1) == 0x32) && (*(buf+2) == 0x03)) { for (i = 0; i < 3; i++) driver->apps_rsp_buf[i] = *(buf+i); for (i = 0; i < 13; i++) driver->apps_rsp_buf[i+3] = 0; ENCODE_RSP_AND_SEND(15); return 0; } /* respond to 0x0 command */ else if (*buf == 0x00) { for (i = 0; i < 55; i++) driver->apps_rsp_buf[i] = 0; ENCODE_RSP_AND_SEND(54); return 0; } /* respond to 0x7c command */ else if (*buf == 0x7c) { driver->apps_rsp_buf[0] = 0x7c; for (i = 1; i < 8; i++) driver->apps_rsp_buf[i] = 0; /* Tools ID for APQ 8060 */ *(int *)(driver->apps_rsp_buf + 8) = chk_config_get_id(); *(unsigned char *)(driver->apps_rsp_buf + 12) = '\0'; *(unsigned char *)(driver->apps_rsp_buf + 13) = '\0'; ENCODE_RSP_AND_SEND(13); return 0; } } #endif /* Check for registered clients and forward packet to user-space */ cmd_code = (int)(*(char *)buf); temp++; subsys_id = (int)(*(char *)temp); temp++; subsys_cmd_code = *(uint16_t *)temp; temp += 2; for (i = 0; i < diag_max_registration; i++) { if (driver->table[i].process_id != 0) { if (driver->table[i].cmd_code == cmd_code && driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i].process_id); return 0; } /* end of if */ else if (driver->table[i].cmd_code == 255 && cmd_code == 75) {// DIAG_SUBSYS_CMD_F if (driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i]. process_id); return 0; } } /* end of else-if */ else if (driver->table[i].cmd_code == 255 && driver->table[i].subsys_id == 255) { if (driver->table[i].cmd_code_lo <= cmd_code && driver->table[i]. cmd_code_hi >= cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process (driver->table[i]. process_id); return 0; } } /* end of else-if */ } /* if(driver->table[i].process_id != 0) */ } /* for (i = 0; i < diag_max_registration; i++) */ return packet_type; }
static int diag_process_apps_pkt(unsigned char *buf, int len) { uint16_t start; uint16_t end, subsys_cmd_code; int i, cmd_code, subsys_id; int packet_type = 1; unsigned char *temp = buf; if (*buf == 0xFA) { g_testmode = 1; } if ((*buf == 0x60) && (*(++buf) == 0x0)) { diag_update_event_mask(buf, 0, 0); diag_update_userspace_clients(EVENT_MASKS_TYPE); } else if (*buf == 0x82) { buf += 4; diag_update_event_mask(buf, 1, *(uint16_t *)buf); diag_update_userspace_clients( EVENT_MASKS_TYPE); } else if (*buf == 0x73) { buf += 4; if (*(int *)buf == 3) { buf += 8; diag_update_log_mask(buf+4, *(int *)buf); diag_update_userspace_clients(LOG_MASKS_TYPE); } } else if ((*buf == 0x7d) && (*(++buf) == 0x4)) { buf++; start = *(uint16_t *)buf; buf += 2; end = *(uint16_t *)buf; buf += 4; diag_update_msg_mask((uint32_t)start, (uint32_t)end , buf); diag_update_userspace_clients(MSG_MASKS_TYPE); } else{ cmd_code = (int)(*(char *)buf); temp++; subsys_id = (int)(*(char *)temp); temp++; subsys_cmd_code = *(uint16_t *)temp; temp += 2; for (i = 0; i < diag_max_registration; i++) { if (driver->table[i].process_id != 0) { if (driver->table[i].cmd_code == cmd_code && driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i].process_id); return 0; } else if (driver->table[i].cmd_code == 255 && cmd_code == 75) { if (driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i]. process_id); return 0; } } else if (driver->table[i].cmd_code == 255 && driver->table[i].subsys_id == 255) { if (driver->table[i].cmd_code_lo <= cmd_code && driver->table[i]. cmd_code_hi >= cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process (driver->table[i]. process_id); return 0; } } } } } return packet_type; }
static int diag_process_apps_pkt(unsigned char *buf, int len) { uint16_t start; uint16_t end, subsys_cmd_code; int i, cmd_code, subsys_id; int packet_type = 1; unsigned char *temp = buf; /* event mask */ if ((*buf == 0x60) && (*(++buf) == 0x0)) { diag_update_event_mask(buf, 0, 0); diag_update_userspace_clients(EVENT_MASKS_TYPE); } /* check for set event mask */ else if (*buf == 0x82) { buf += 4; diag_update_event_mask(buf, 1, *(uint16_t *)buf); diag_update_userspace_clients( EVENT_MASKS_TYPE); } /* log mask */ else if (*buf == 0x73) { buf += 4; if (*(int *)buf == 3) { buf += 8; diag_update_log_mask(buf+4, *(int *)buf); diag_update_userspace_clients(LOG_MASKS_TYPE); } } /* Check for set message mask */ else if ((*buf == 0x7d) && ((*(buf+1) == 0x4) || (*(buf+1) == 0x5))) { /* printk("len = %d\n", len); print_hex_dump(KERN_DEBUG, "Read Packet Data" " from message mask: ", 16, 1, DUMP_PREFIX_ADDRESS, buf, len, 1); */ if (*(buf+1) == 0x4) { buf += 2; start = *(uint16_t *)buf; buf += 2; end = *(uint16_t *)buf; buf += 4; diag_update_msg_mask((uint32_t)start, (uint32_t)end , buf, 0); diag_update_userspace_clients(MSG_MASKS_TYPE); } else { diag_update_msg_mask(0, 0x4e, buf, 1); diag_update_userspace_clients(MSG_MASKS_TYPE); } } /* Set all run-time masks if ((*buf == 0x7d) && (*(++buf) == 0x5)) { TO DO } */ /* Check for registered clients and forward packet to user-space */ else{ cmd_code = (int)(*(char *)buf); temp++; subsys_id = (int)(*(char *)temp); temp++; subsys_cmd_code = *(uint16_t *)temp; temp += 2; for (i = 0; i < diag_max_registration; i++) { if (driver->table[i].process_id != 0) { if (driver->table[i].cmd_code == cmd_code && driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i].process_id); return 0; } /* end of if */ else if (driver->table[i].cmd_code == 255 && cmd_code == 75) { if (driver->table[i].subsys_id == subsys_id && driver->table[i].cmd_code_lo <= subsys_cmd_code && driver->table[i].cmd_code_hi >= subsys_cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process( driver->table[i]. process_id); return 0; } } /* end of else-if */ else if (driver->table[i].cmd_code == 255 && driver->table[i].subsys_id == 255) { if (driver->table[i].cmd_code_lo <= cmd_code && driver->table[i]. cmd_code_hi >= cmd_code){ driver->pkt_length = len; diag_update_pkt_buffer(buf); diag_update_sleeping_process (driver->table[i]. process_id); return 0; } } /* end of else-if */ } /* if(driver->table[i].process_id != 0) */ } /* for (i = 0; i < diag_max_registration; i++) */ } /* else */ return packet_type; }