Ejemplo n.º 1
0
int stp_dbg_dmp_out(MTKSTP_DBG_T *stp_dbg, char *buf, int *len) {

    unsigned long flags;
    int remaining = 0;
    *len = 0;
    spin_lock_irqsave(&(stp_dbg->logsys->lock), flags);

    if(stp_dbg->logsys->size > 0) {
        memcpy(buf, &(stp_dbg->logsys->queue[stp_dbg->logsys->out].buffer[0]),
               stp_dbg->logsys->queue[stp_dbg->logsys->out].len);

        (*len) = stp_dbg->logsys->queue[stp_dbg->logsys->out].len;
        stp_dbg->logsys->out = (stp_dbg->logsys->out >= (STP_DBG_LOG_ENTRY_NUM - 1))?(0):(stp_dbg->logsys->out + 1);
        stp_dbg->logsys->size--;

        STP_DBG_DBG_FUNC("logsys size = %d, out = %d\n", stp_dbg->logsys->size, stp_dbg->logsys->out);
    } else {
        STP_DBG_LOUD_FUNC("logsys EMPTY!\n");
    }

    remaining = (stp_dbg->logsys->size == 0)?(0):(1);

    spin_unlock_irqrestore(&(stp_dbg->logsys->lock), flags);

    return remaining;
}
Ejemplo n.º 2
0
static INT32 _stp_dbg_dmp_in (MTKSTP_DBG_T *stp_dbg, CHAR *buf, INT32 len)
{
    UINT32 internalFlag = stp_dbg->logsys->size < STP_DBG_LOG_ENTRY_NUM;
#ifdef CONFIG_LOG_STP_INTERNAL
    internalFlag = 1;
#endif

    osal_lock_unsleepable_lock(&(stp_dbg->logsys->lock));

    if (internalFlag){
        stp_dbg->logsys->queue[stp_dbg->logsys->in].id = 0;
        stp_dbg->logsys->queue[stp_dbg->logsys->in].len = len;

        osal_memcpy(&(stp_dbg->logsys->queue[stp_dbg->logsys->in].buffer[0]),buf, ((len >= STP_DBG_LOG_ENTRY_SZ)? (STP_DBG_LOG_ENTRY_SZ):(len)));
            stp_dbg->logsys->size++;
            stp_dbg->logsys->size = (stp_dbg->logsys->size > STP_DBG_LOG_ENTRY_NUM) ? STP_DBG_LOG_ENTRY_NUM : stp_dbg->logsys->size;
            stp_dbg->logsys->in = (stp_dbg->logsys->in >= (STP_DBG_LOG_ENTRY_NUM - 1))?(0):(stp_dbg->logsys->in + 1);
            STP_DBG_DBG_FUNC("logsys size = %d, in = %d\n", stp_dbg->logsys->size, stp_dbg->logsys->in);
    } else {
        STP_DBG_WARN_FUNC("logsys FULL!\n");
    }

    osal_unlock_unsleepable_lock(&(stp_dbg->logsys->lock));

    return 0;
}
Ejemplo n.º 3
0
static int _stp_dbg_dmp_in(MTKSTP_DBG_T *stp_dbg, char *buf, int len) {

    unsigned long flags;
    unsigned int internalFlag = stp_dbg->logsys->size < STP_DBG_LOG_ENTRY_NUM;
    //#ifdef CONFIG_LOG_STP_INTERNAL
    //Here we record log in this circle buffer, if buffer is full , select to overlap earlier log, logic should be okay
    internalFlag = 1;
    //#endif
    spin_lock_irqsave(&(stp_dbg->logsys->lock), flags);

    if(internalFlag) {
        stp_dbg->logsys->queue[stp_dbg->logsys->in].id = 0;
        stp_dbg->logsys->queue[stp_dbg->logsys->in].len = len;
        memset(&(stp_dbg->logsys->queue[stp_dbg->logsys->in].buffer[0]),
               0, ((len >= STP_DBG_LOG_ENTRY_SZ)? (STP_DBG_LOG_ENTRY_SZ):(len)));
        memcpy(&(stp_dbg->logsys->queue[stp_dbg->logsys->in].buffer[0]),
               buf, ((len >= STP_DBG_LOG_ENTRY_SZ)? (STP_DBG_LOG_ENTRY_SZ):(len)));

        stp_dbg->logsys->size++;
        stp_dbg->logsys->size = (stp_dbg->logsys->size > STP_DBG_LOG_ENTRY_NUM) ? STP_DBG_LOG_ENTRY_NUM : stp_dbg->logsys->size;

        if (0 != gStpDbgLogOut)
        {
            STP_DBG_HDR_T *pHdr = NULL;
            char* pBuf = NULL;
            unsigned int len =0;
            pHdr = (STP_DBG_HDR_T *)&(stp_dbg->logsys->queue[stp_dbg->logsys->in].buffer[0]);
            pBuf = (char *)&(stp_dbg->logsys->queue[stp_dbg->logsys->in].buffer[0]) + sizeof (STP_DBG_HDR_T);
            len = stp_dbg->logsys->queue[stp_dbg->logsys->in].len - sizeof (STP_DBG_HDR_T);
            printk("STP-DBG:%d.%ds, %s:pT%sn(%d)l(%d)s(%d)a(%d)\n", \
                   pHdr->sec,
                   pHdr->usec,
                   pHdr->dir == PKT_DIR_TX ? "Tx" : "Rx",
                   gStpDbgType[pHdr->type],
                   pHdr->no,
                   pHdr->len,
                   pHdr->seq,
                   pHdr->ack

                  );
            if (0 < len) {
                stp_dbg_dump_data(pBuf, pHdr->dir == PKT_DIR_TX ? "Tx" : "Rx", len);
            }

        }
        stp_dbg->logsys->in = (stp_dbg->logsys->in >= (STP_DBG_LOG_ENTRY_NUM - 1))?(0):(stp_dbg->logsys->in + 1);
        STP_DBG_DBG_FUNC("logsys size = %d, in = %d\n", stp_dbg->logsys->size, stp_dbg->logsys->in);
    } else {
        STP_DBG_WARN_FUNC("logsys FULL!\n");
    }

    spin_unlock_irqrestore(&(stp_dbg->logsys->lock), flags);

    return 0;
}
Ejemplo n.º 4
0
INT32 stp_dbg_dmp_out (MTKSTP_DBG_T *stp_dbg, CHAR *buf, INT32 *len)
{
    INT32 remaining = 0;

    osal_lock_unsleepable_lock(&(stp_dbg->logsys->lock));
    if (stp_dbg->logsys->size > 0){
        osal_memcmp(buf, &(stp_dbg->logsys->queue[stp_dbg->logsys->out].buffer[0]),
             stp_dbg->logsys->queue[stp_dbg->logsys->out].len);

        (*len) = stp_dbg->logsys->queue[stp_dbg->logsys->out].len;
        stp_dbg->logsys->out = (stp_dbg->logsys->out >= (STP_DBG_LOG_ENTRY_NUM - 1))?(0):(stp_dbg->logsys->out + 1);
        stp_dbg->logsys->size--;

        STP_DBG_DBG_FUNC("logsys size = %d, out = %d\n", stp_dbg->logsys->size, stp_dbg->logsys->out);
    } else {
        STP_DBG_LOUD_FUNC("logsys EMPTY!\n");
    }

    remaining = (stp_dbg->logsys->size == 0)?(0):(1);

    osal_unlock_unsleepable_lock(&(stp_dbg->logsys->lock));

    return remaining;
}
Ejemplo n.º 5
0
INT32 _stp_dbg_parser_assert_str(CHAR *str, ENUM_ASSERT_INFO_PARSER_TYPE type)
{
    char *pStr = NULL;
    char *pDtr = NULL;
    char *pTemp = NULL;
    char *pTemp2 = NULL;
    char tempBuf[64] = {0};
    UINT32 len = 0;

    char *parser_sub_string[] = {
        "<ASSERT> ",
        "id=",
        "isr=",
        "irq=",
        "rc="
    };

    if (!str) {
        STP_DBG_ERR_FUNC("NULL string source\n");
        return -1;
    }

    if (!g_stp_dbg_cpupcr) {
        STP_DBG_ERR_FUNC("NULL pointer\n");
        return -2;
    }

    pStr = str;
    STP_DBG_DBG_FUNC("source infor:%s\n", pStr);

    switch (type) {
    case STP_DBG_ASSERT_INFO:
        pDtr = osal_strstr(pStr, parser_sub_string[type]);

        if (NULL != pDtr) {
            pDtr += osal_strlen(parser_sub_string[type]);
            pTemp = osal_strchr(pDtr, ' ');
        } else {
            STP_DBG_ERR_FUNC("parser str is NULL,substring(%s)\n", parser_sub_string[type]);
            return -3;
        }

        len = pTemp - pDtr;
        osal_memcpy(&g_stp_dbg_cpupcr->assert_info[0], "assert@", osal_strlen("assert@"));
        osal_memcpy(&g_stp_dbg_cpupcr->assert_info[osal_strlen("assert@")], pDtr, len);
        g_stp_dbg_cpupcr->assert_info[osal_strlen("assert@") + len] = '_';

        pTemp = osal_strchr(pDtr, '#');
        pTemp += 1;

        pTemp2 = osal_strchr(pTemp, ' ');
        osal_memcpy(&g_stp_dbg_cpupcr->assert_info[osal_strlen("assert@") + len + 1], pTemp, pTemp2 - pTemp);
        g_stp_dbg_cpupcr->assert_info[osal_strlen("assert@") + len + 1 + pTemp2 - pTemp] = '\0';
        STP_DBG_INFO_FUNC("assert info:%s\n", &g_stp_dbg_cpupcr->assert_info[0]);
        break;

    case STP_DBG_FW_TASK_ID:
        pDtr = osal_strstr(pStr, parser_sub_string[type]);

        if (NULL != pDtr) {
            pDtr += osal_strlen(parser_sub_string[type]);
            pTemp = osal_strchr(pDtr, ' ');
        } else {
            STP_DBG_ERR_FUNC("parser str is NULL,substring(%s)\n", parser_sub_string[type]);
            return -3;
        }

        len = pTemp - pDtr;
        osal_memcpy(&tempBuf[0], pDtr, len);
        tempBuf[len] = '\0';
        g_stp_dbg_cpupcr->fwTaskId = osal_strtol(tempBuf, NULL, 16);

        STP_DBG_INFO_FUNC("fw task id :%x\n", (UINT32)osal_strtol(tempBuf, NULL, 16));
        break;

    case STP_DBG_FW_ISR:
        pDtr = osal_strstr(pStr, parser_sub_string[type]);

        if (NULL != pDtr) {
            pDtr += osal_strlen(parser_sub_string[type]);
            pTemp = osal_strchr(pDtr, ',');
        } else {
            STP_DBG_ERR_FUNC("parser str is NULL,substring(%s)\n", parser_sub_string[type]);
            return -3;
        }

        len = pTemp - pDtr;
        osal_memcpy(&tempBuf[0], pDtr, len);
        tempBuf[len] = '\0';

        g_stp_dbg_cpupcr->fwIsr = osal_strtol(tempBuf, NULL, 16);

        STP_DBG_INFO_FUNC("fw isr str:%x\n", (UINT32)osal_strtol(tempBuf, NULL, 16));
        break;

    case STP_DBG_FW_IRQ:
        pDtr = osal_strstr(pStr, parser_sub_string[type]);

        if (NULL != pDtr) {
            pDtr += osal_strlen(parser_sub_string[type]);
            pTemp = osal_strchr(pDtr, ',');
        } else {
            STP_DBG_ERR_FUNC("parser str is NULL,substring(%s)\n", parser_sub_string[type]);
            return -3;
        }

        len = pTemp - pDtr;
        osal_memcpy(&tempBuf[0], pDtr, len);
        tempBuf[len] = '\0';
        g_stp_dbg_cpupcr->fwRrq = osal_strtol(tempBuf, NULL, 16);

        STP_DBG_INFO_FUNC("fw irq value:%x\n", (UINT32)osal_strtol(tempBuf, NULL, 16));
        break;

    case STP_DBG_ASSERT_TYPE:
        pDtr = osal_strstr(pStr, parser_sub_string[type]);

        if (NULL != pDtr) {
            pDtr += osal_strlen(parser_sub_string[type]);
            pTemp = osal_strchr(pDtr, ',');
        } else {
            STP_DBG_ERR_FUNC("parser str is NULL,substring(%s)\n", parser_sub_string[type]);
            return -3;
        }

        len = pTemp - pDtr;
        osal_memcpy(&tempBuf[0], pDtr, len);
        tempBuf[len] = '\0';

        if (0 == osal_memcmp(tempBuf, "*", len)) {
            osal_memcpy(&g_stp_dbg_cpupcr->assert_type[0], "general assert", osal_strlen("general assert"));
        }

        if (0 == osal_memcmp(tempBuf, "Watch Dog Timeout", len)) {
            osal_memcpy(&g_stp_dbg_cpupcr->assert_type[0], "wdt", osal_strlen("wdt"));
        }

        if (0 == osal_memcmp(tempBuf, "RB_FULL", osal_strlen("RB_FULL"))) {
            osal_memcpy(&g_stp_dbg_cpupcr->assert_type[0], tempBuf, len);

            pDtr = osal_strstr(&g_stp_dbg_cpupcr->assert_type[0], "RB_FULL(");

            if (NULL != pDtr) {
                pDtr += osal_strlen("RB_FULL(");
                pTemp = osal_strchr(pDtr, ')');
            } else {
                STP_DBG_ERR_FUNC("parser str is NULL,substring(RB_FULL()\n");
                return -4;
            }

            len = pTemp - pDtr;
            osal_memcpy(&tempBuf[0], pDtr, len);
            tempBuf[len] = '\0';

            g_stp_dbg_cpupcr->fwTaskId = osal_strtol(tempBuf, NULL, 16);

            STP_DBG_INFO_FUNC("update fw task id :%x\n", (UINT32)osal_strtol(tempBuf, NULL, 16));
        }

        STP_DBG_INFO_FUNC("fw asert type:%s\n", g_stp_dbg_cpupcr->assert_type);
        break;

    default:
        STP_DBG_ERR_FUNC("unknow parser type\n");
        break;
    }

    return 0;
}