static int wmt_dev_dbg_read(char *page, char **start, off_t off, int count, int *eof, void *data){ INT32 len = 0; if(off > 0){ len = 0; } else { /*len = sprintf(page, "%d\n", g_psm_enable);*/ if ( gCoexBuf.availSize <= 0) { WMT_INFO_FUNC("no data available, please run echo 15 xx > /proc/driver/wmt_psm first\n"); len = osal_sprintf(page, "no data available, please run echo 15 xx > /proc/driver/wmt_psm first\n"); } else { INT32 i = 0; /*we do not check page buffer, because there are only 100 bytes in g_coex_buf, no reason page buffer is not enough, a bomb is placed here on unexpected condition*/ for (i = 0; i < gCoexBuf.availSize; i++) { len += osal_sprintf(page + len, "0x%02x ", gCoexBuf.buffer[i]); } len += osal_sprintf(page + len, "\n"); } } gCoexBuf.availSize = 0; return len; }
static void print_aes(OE oe, Aes aes) { uint i = 0, j = 0; byte b[5*16+2] = {0}; b[0] = '\n'; b[5*16+1] = '\n'; for(i = 0;i < 4;++i) { for(j = 0; j < 4;++j) { if (j == 3) osal_sprintf(b+16*i+j*4+1," %2x\n",aes->state[j+4*i]); else osal_sprintf(b+16*i+j*4+1," %2x ",aes->state[j+4*i]); } } oe->p(b); }
static int run(char * ip, uint myid, uint count, OE oe, MiniMacs mm) { CArena mc = CArena_new(oe); MpcPeer mission_control = 0; if (mc->connect("87.104.238.146", 65000).rc != 0) { oe->syslog(OSAL_LOGLEVEL_FATAL,"Failed to connect to the performance monitor."); return -1; }; mission_control = mc->get_peer(0); if (!mission_control) { oe->p("Failed connection to mission control. aborting.\n"); return -1; } if (mm->get_id() == 0) { if (mm->invite(1,2020+myid) != 0) { byte d[256] = {0}; char m[128] = {0}; osal_sprintf(m,"Failed to invite %u peers on port %u",1,2020+myid); oe->p(m); i2b(myid, d); osal_sprintf(d+4,"error"); mission_control->send(Data_shallow(d,128)); return 0; } } else { if (mm->connect(ip,2020+myid) != 0) { char m[128] = {0}; osal_sprintf(m,"Failed to connect to peer %s:%u",ip,2020+myid); oe->p(m); return 0; } } { byte key[128] = {0}; byte ptxt[128] = {0}; mpc_aes(mm,ptxt, key,myid,count,mission_control); CArena_destroy(&mc); } PrintMeasurements(oe); return 0; }
/* * ] Connect to the monitor * * ] Listen for clients with ids greater than this client. * * ] Connect to clients with ids less than this client. (in this way * client 1 connects to no one and listens for every one, vice verse * client N connects to everyone and listens for no one.) * * ] Execute mpc_aes with the connected peers * * ] Destroy the CArena connected to comm with the monitor and leave. */ static int run(char * ip, uint myid, uint count, OE oe, MiniMacs mm) { CArena mc = CArena_new(oe); MpcPeer mission_control = 0; // connect to monitor if (mc->connect(bitlab, 65000).rc != 0) { oe->syslog(OSAL_LOGLEVEL_FATAL,"Failed to connect to the performance monitor."); return -1; }; mission_control = mc->get_peer(0); if (!mission_control) { oe->p("Failed connection to mission control. aborting.\n"); return -1; } // listen for all parties with id greater than mm->myid { byte msg[92] = {0}; uint port = 2020+100*mm->get_id(); uint wait4=mm->get_no_players()-(mm->get_id()+1); osal_sprintf(msg,"Waiting for %u players to connect.",wait4); oe->p(msg); if (wait4 > 0) { if (mm->invite(wait4,port) != 0) { byte d[256] = {0}; char m[128] = {0}; osal_sprintf(m,"Failed to invite %u peers on port %u",wait4,2020+myid); oe->syslog(OSAL_LOGLEVEL_FATAL,m); i2b(myid, d); osal_sprintf(d+4,"error"); mission_control->send(Data_shallow(d,128)); return 0; }; } } // connect to all parties with id less than mm->myid { int id = 0; for(id = mm->get_id()-1;id >= 0;--id) { byte address[16] = {0}; byte msg[92] = {0}; uint port = 2020+100*id; osal_sprintf(msg,"connecting to %u ...",port); oe->p(msg); osal_sprintf(address,"10.11.82.%d",id+1); if (mm->connect(address,port) != 0) { byte d[256] = {0}; char m[128] = {0}; osal_sprintf(m,"Failed to connect to %s peers on port %u",address,port); oe->syslog(OSAL_LOGLEVEL_FATAL,m); i2b(myid, d); osal_sprintf(d+4,"error"); mission_control->send(Data_shallow(d,128)); return 0; } } } // invoke AES circuit with zero plaintext and zero key { byte key[128] = {0}; byte ptxt[128] = {0}; mpc_aes(mm,ptxt, key,myid,count,mission_control); CArena_destroy(&mc); } // print time measurements if compiled in PrintMeasurements(oe); return 0; }
ssize_t wmt_dbg_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) { INT32 retval = 0; INT32 i_ret = 0; CHAR *warn_msg = "no data available, please run echo 15 xx > /proc/driver/wmt_psm first\n"; if(*f_pos > 0){ retval = 0; } else { /*len = sprintf(page, "%d\n", g_psm_enable);*/ if ( gCoexBuf.availSize <= 0) { WMT_INFO_FUNC("no data available, please run echo 15 xx > /proc/driver/wmt_psm first\n"); retval = osal_strlen(warn_msg) + 1; if (count < retval) { retval = count; } i_ret = copy_to_user(buf, warn_msg, retval); if (i_ret) { WMT_ERR_FUNC("copy to buffer failed, ret:%d\n", retval); retval = -EFAULT; goto err_exit; } *f_pos += retval; } else { INT32 i = 0; INT32 len = 0; CHAR msg_info[128]; INT32 max_num = 0; /*we do not check page buffer, because there are only 100 bytes in g_coex_buf, no reason page buffer is not enough, a bomb is placed here on unexpected condition*/ WMT_INFO_FUNC("%d bytes avaliable\n", gCoexBuf.availSize); max_num = ((osal_sizeof(msg_info) > count ? osal_sizeof(msg_info) : count) -1) / 5; if (max_num > gCoexBuf.availSize) { max_num = gCoexBuf.availSize; } else { WMT_INFO_FUNC("round to %d bytes due to local buffer size limitation\n", max_num); } for (i = 0; i < max_num; i++) { len += osal_sprintf(msg_info + len, "0x%02x ", gCoexBuf.buffer[i]); } len += osal_sprintf(msg_info + len, "\n"); retval = len; i_ret = copy_to_user(buf, msg_info, retval); if (i_ret) { WMT_ERR_FUNC("copy to buffer failed, ret:%d\n", retval); retval = -EFAULT; goto err_exit; } *f_pos += retval; } } gCoexBuf.availSize = 0; err_exit: return retval; }
INT32 stp_dbg_cpupcr_infor_format(UINT8 **buf, UINT32 *str_len) { UINT32 len = 0; UINT32 i = 0; if (!g_stp_dbg_cpupcr) { STP_DBG_ERR_FUNC("NULL pointer\n"); return -1; } /*format common information about issue*/ len = osal_sprintf(*buf, "<main>\n\t"); len += osal_sprintf(*buf + len, "<chipid>\n\t\tMT%x\n\t</chipid>\n\t", g_stp_dbg_cpupcr->chipId); len += osal_sprintf(*buf + len, "<version>\n\t\t"); len += osal_sprintf(*buf + len, "<rom>%s</rom>\n\t\t", g_stp_dbg_cpupcr->romVer); if (!(osal_memcmp(g_stp_dbg_cpupcr->branchVer, "ALPS", STP_PATCH_BRANCH_SZIE))) { len += osal_sprintf(*buf + len, "<branch>Internal Dev</branch>\n\t\t", g_stp_dbg_cpupcr->branchVer); } else { len += osal_sprintf(*buf + len, "<branch>W%sMP</branch>\n\t\t", g_stp_dbg_cpupcr->branchVer); } len += osal_sprintf(*buf + len, "<patch>%s</patch>\n\t\t", g_stp_dbg_cpupcr->patchVer); if (!g_stp_dbg_cpupcr->wifiVer[0]) { len += osal_sprintf(*buf + len, "<wifi>NULL</wifi>\n\t"); } else { len += osal_sprintf(*buf + len, "<wifi>%s</wifi>\n\t", g_stp_dbg_cpupcr->wifiVer); } len += osal_sprintf(*buf + len, "</version>\n\t"); /*format issue information: no ack, assert*/ len += osal_sprintf(*buf + len, "<issue>\n\t\t<classification>\n\t\t\t"); if ((STP_FW_NOACK_ISSUE == g_stp_dbg_cpupcr->issue_type) || (STP_DBG_PROC_TEST == g_stp_dbg_cpupcr->issue_type) || (STP_FW_WARM_RST_ISSUE == g_stp_dbg_cpupcr->issue_type)) { len += osal_sprintf(*buf + len, "%s\n\t\t</classification>\n\t\t<rc>\n\t\t\t", g_stp_dbg_cpupcr->assert_info); len += osal_sprintf(*buf + len, "NULL\n\t\t</rc>\n\t</issue>\n\t"); len += osal_sprintf(*buf + len, "<hint>\n\t\t<time_align>NULL</time_align>\n\t\t"); len += osal_sprintf(*buf + len, "<host>NULL</host>\n\t\t"); len += osal_sprintf(*buf + len, "<client>\n\t\t\t<task>%s</task>\n\t\t\t", _stp_dbg_id_to_task(g_stp_dbg_cpupcr->fwTaskId)); len += osal_sprintf(*buf + len, "<irqx>IRQ_0x%x</irqx>\n\t\t\t", g_stp_dbg_cpupcr->fwRrq); len += osal_sprintf(*buf + len, "<isr>0x%x</isr>\n\t\t\t", g_stp_dbg_cpupcr->fwIsr); } else if ((STP_FW_ASSERT_ISSUE == g_stp_dbg_cpupcr->issue_type)) { len += osal_sprintf(*buf + len, "%s\n\t\t</classification>\n\t\t<rc>\n\t\t\t", g_stp_dbg_cpupcr->assert_info); len += osal_sprintf(*buf + len, "%s\n\t\t</rc>\n\t</issue>\n\t", g_stp_dbg_cpupcr->assert_type); len += osal_sprintf(*buf + len, "<hint>\n\t\t<time_align>NULL</time_align>\n\t\t"); len += osal_sprintf(*buf + len, "<host>NULL</host>\n\t\t"); len += osal_sprintf(*buf + len, "<client>\n\t\t\t<task>%s</task>\n\t\t\t", _stp_dbg_id_to_task(g_stp_dbg_cpupcr->fwTaskId)); len += osal_sprintf(*buf + len, "<irqx>IRQ_0x%x</irqx>\n\t\t\t", g_stp_dbg_cpupcr->fwRrq); len += osal_sprintf(*buf + len, "<isr>0x%x</isr>\n\t\t\t", g_stp_dbg_cpupcr->fwIsr); } else { len += osal_sprintf(*buf + len, "NULL\n\t\t</classification>\n\t\t<rc>\n\t\t\t"); len += osal_sprintf(*buf + len, "NULL\n\t\t</rc>\n\t</issue>\n\t"); len += osal_sprintf(*buf + len, "<hint>\n\t\t<time_align>NULL</time_align>\n\t\t"); len += osal_sprintf(*buf + len, "<host>NULL</host>\n\t\t"); len += osal_sprintf(*buf + len, "<client>\n\t\t\t<task>NULL</task>\n\t\t\t"); len += osal_sprintf(*buf + len, "<irqx>NULL</irqx>\n\t\t\t"); len += osal_sprintf(*buf + len, "<isr>NULL</isr>\n\t\t\t"); } len += osal_sprintf(*buf + len, "<pctrace>"); STP_DBG_INFO_FUNC("stp-dbg:sub len1 for debug(%d)\n", len); if (!g_stp_dbg_cpupcr->count) { len += osal_sprintf(*buf + len, "NULL"); } else { for (i = 0; i < g_stp_dbg_cpupcr->count; i++) { len += osal_sprintf(*buf + len, "%08x,", g_stp_dbg_cpupcr->buffer[i]); } } STP_DBG_INFO_FUNC("stp-dbg:sub len2 for debug(%d)\n", len); len += osal_sprintf(*buf + len, "</pctrace>\n\t\t\t"); len += osal_sprintf(*buf + len, "<extension>NULL</extension>\n\t\t</client>\n\t</hint>\n</main>\n"); STP_DBG_INFO_FUNC("buffer len[%d]\n", len); //STP_DBG_INFO_FUNC("Format infor:\n%s\n",*buf); *str_len = len; osal_memset(&g_stp_dbg_cpupcr->buffer[0], 0, STP_DBG_CPUPCR_NUM); g_stp_dbg_cpupcr->count = 0; return 0; }