static void mtd_panic_notify_add(struct mtd_info *mtd) { struct mtd_ipanic_data *ctx = &mtd_drv_ctx; struct ipanic_header *hdr; int rc; if (strcmp(mtd->name, AEE_IPANIC_PLABEL)) return; ctx->mtd = mtd; ctx->bounce = kzalloc(ctx->mtd->writesize, GFP_KERNEL); if (ctx->bounce == NULL) xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: mtd buffer kzalloc failed, %d \n", __func__, ctx->mtd->writesize); hdr = ctx->bounce; if (!mtd_ipanic_block_scan(ctx)) goto out_err; rc = mtd_ipanic_block_read_single(ctx, 0); if (rc < 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "aee-ipanic: Error reading block 0 (%d)\n", rc); mtd_ipanic_block_erase(); goto out_err; } xlog_printk(ANDROID_LOG_INFO, IPANIC_LOG_TAG, "aee-ipanic: Bound to mtd partition '%s', write size(%d), write size shift(%d)\n", mtd->name, mtd->writesize, mtd->writesize_shift); switch (ipanic_header_check(hdr)) { case 0: break; case 1: return; case 2: mtd_ipanic_block_erase(); return; } memcpy(&ctx->curr, hdr, sizeof(struct ipanic_header)); ipanic_header_dump(hdr); ctx->oops = create_proc_read_entry("aee_ipanic_oops", 0444, NULL, mtd_ipanic_proc_oops, NULL); if (ctx->oops == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, " %s: failed to create proc file apanic_oops\n", __func__); } /*it will free the ctx->curr assigne during bootup. then open the ke device will return NULL. so lose db */ //mtd_ipanic_oops_dump(); return; out_err: ctx->mtd = NULL; }
static struct aee_oops *emmc_ipanic_oops_copy(void) { struct aee_oops *oops = NULL; struct ipanic_header *hdr = NULL; int hdr_size = ALIGN(sizeof(struct ipanic_header), EMMC_BLOCK_SIZE); hdr = kzalloc(hdr_size, GFP_KERNEL); if (hdr == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: Cannot allocate ipanic header memory\n", __FUNCTION__); return NULL; } if (card_dump_func_read((unsigned char *)hdr, hdr_size, 0, EMMC_ID) < 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: emmc panic log header read failed\n", __func__); return NULL; } ipanic_block_scramble((unsigned char *)hdr, hdr_size); if (ipanic_header_check(hdr) != 0) { return NULL; } oops = aee_oops_create(AE_DEFECT_FATAL, AE_KE, IPANIC_MODULE_TAG); if (oops != NULL) { struct ipanic_oops_header *oops_header = (struct ipanic_oops_header *) emmc_allocate_and_read(hdr->oops_header_offset, hdr->oops_header_length); if (oops_header == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: Can't read oops header(len:%d)\n", __FUNCTION__, hdr->oops_header_length); goto error_return; } aee_oops_set_process_path(oops, oops_header->process_path); aee_oops_set_backtrace(oops, oops_header->backtrace); kfree(oops_header); if(hdr->oops_detail_length != 0) { oops->detail = emmc_allocate_and_read(hdr->oops_detail_offset, hdr->oops_detail_length); oops->detail_len = hdr->oops_detail_length; }else { #define TMPDETAILSTR "panic detail is empty" oops->detail = kstrdup(TMPDETAILSTR, GFP_KERNEL); oops->detail_len = sizeof TMPDETAILSTR; } if (oops->detail == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read detail failed(len: %d)\n", __FUNCTION__, oops->detail_len); goto error_return; } oops->console = emmc_allocate_and_read(hdr->console_offset, hdr->console_length); oops->console_len = hdr->console_length; if (oops->console == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read console failed(len: %d)\n", __FUNCTION__, oops->console_len); goto error_return; } /*If panic from kernel context, no user sapce info available. Shouldn't fail*/ if (0 == hdr->userspace_info_length) { oops->userspace_info = NULL; oops->userspace_info_len = 0; } else { oops->userspace_info = emmc_allocate_and_read(hdr->userspace_info_offset, hdr->userspace_info_length); oops->userspace_info_len = hdr->userspace_info_length; if (oops->userspace_info == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read usrespace info failed\n", __FUNCTION__); goto error_return; } } oops->android_main = emmc_allocate_and_read(hdr->android_main_offset, hdr->android_main_length); oops->android_main_len = hdr->android_main_length; if (oops->android_main == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read android_main failed\n", __FUNCTION__); goto error_return; } oops->android_radio = emmc_allocate_and_read(hdr->android_radio_offset, hdr->android_radio_length); oops->android_radio_len = hdr->android_radio_length; if (oops->android_radio == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read android_radio failed\n", __FUNCTION__); goto error_return; } oops->android_system = emmc_allocate_and_read(hdr->android_system_offset, hdr->android_system_length); oops->android_system_len = hdr->android_system_length; if (oops->android_system == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read android_system failed\n", __FUNCTION__); goto error_return; } xlog_printk(ANDROID_LOG_DEBUG, IPANIC_LOG_TAG, "ipanic_oops_copy return OK\n"); kfree(hdr); return oops; } else { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at header\n", __FUNCTION__); kfree(hdr); return NULL; } error_return: kfree(hdr); aee_oops_free(oops); return NULL; }