예제 #1
0
static int ipanic_mmprofile(void *data, unsigned char *buffer, size_t sz_buf)
{
	int errno = 0;
	static unsigned int index;
	static unsigned int mmprofile_dump_size;
	unsigned long pbuf = 0;
	unsigned int bufsize = 0;

	if (mmprofile_dump_size == 0) {
		mmprofile_dump_size = MMProfileGetDumpSize();
		if (mmprofile_dump_size == 0 || mmprofile_dump_size > IPANIC_MMPROFILE_LIMIT) {
			LOGE("%s: INVALID MMProfile size[%x]", __func__, mmprofile_dump_size);
			return -3;
		}
	}

	MMProfileGetDumpBuffer(index, (unsigned int*)&pbuf, &bufsize);
	if (bufsize == 0) {
		errno = 0;
	} else if (bufsize > sz_buf) {
		errno = -4;
	} else {
		memcpy(buffer, (void *)pbuf, bufsize);
		index += bufsize;
		errno = bufsize;
	}
	return errno;
}
예제 #2
0
static void ipanic_write_mmprofile(int offset, struct ipanic_header *hdr)
{
    int rc = 0;
    unsigned int index = 0;
    unsigned int pbuf = 0;
    unsigned int bufsize = 0;
    unsigned int mmprofile_dump_size = 0;

    offset = ALIGN(offset, EMMC_BLOCK_SIZE);
    hdr->mmprofile_offset = offset;

#ifdef MTK_MMPROFILE_SUPPORT

    mmprofile_dump_size = MMProfileGetDumpSize();
    if (mmprofile_dump_size == 0 || mmprofile_dump_size > IPANIC_OOPS_MMPROFILE_LENGTH_LIMIT) {
        xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: ignore INVALID MMProfile dump size 0x%x", mmprofile_dump_size);
        return;
    }

    do {
        MMProfileGetDumpBuffer(index, &pbuf, &bufsize);
        if (bufsize == 0) {
            hdr->mmprofile_length = index;
            break;
        }

        index += bufsize;

        rc = emmc_ipanic_write((char*)pbuf, offset, bufsize);
        if (rc < 0) {
            xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: Error writing MMProfile to emmc! (%d)\n", __func__, rc);
            hdr->mmprofile_length = 0;
        }
        else {
            offset += rc;
        }
    } while(rc <= IPANIC_OOPS_MMPROFILE_LENGTH_LIMIT);

#else
    //MTK_MMPROFILE_SUPPORT disabled, no mmprofile dumped.
    hdr->mmprofile_length = 0;
#endif
}