static int ipanic_write_log_buf(unsigned int off, int log_copy_start, int log_copy_end)
{
	int saved_oip;
	int rc, rc2;
	unsigned int last_chunk = 0, copy_count = 0;

	while (!last_chunk) {
		saved_oip = oops_in_progress;
		oops_in_progress = 1;
        rc = log_buf_copy2(emmc_bounce, PAGE_SIZE, log_copy_start, log_copy_end);
		BUG_ON(rc < 0);
		log_copy_start += rc;
		copy_count += rc;
		if (rc != PAGE_SIZE)
			last_chunk = rc;

		oops_in_progress = saved_oip;
		if (rc <= 0)
			break;

		rc2 = emmc_ipanic_write(emmc_bounce, off, rc);
		if (rc2 <= 0) {
			xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG,
			       "aee-ipanic: Flash write failed (%d)\n", rc2);
			return rc2;
		}
		off += rc2;
	}
	return copy_count;
}
/*
 * Writes the contents of the console to the specified offset in flash.
 * Returns number of bytes written
 */
static int ipanic_write_log_buf(struct mtd_info *mtd, unsigned int off, int log_copy_start, int log_copy_end)
{
	struct mtd_ipanic_data *ctx = &mtd_drv_ctx;
	int saved_oip;
	int rc, rc2;
	unsigned int last_chunk = 0, copy_count = 0;

	while (!last_chunk) {
		saved_oip = oops_in_progress;
		oops_in_progress = 1;
		rc = log_buf_copy2(ctx->bounce, mtd->writesize, log_copy_start, log_copy_end);
		BUG_ON(rc < 0);
		log_copy_start += rc;
		copy_count += rc;
		if (rc != mtd->writesize)
			last_chunk = rc;

		oops_in_progress = saved_oip;
		if (rc <= 0)
			break;

		rc2 = mtd_ipanic_block_write(ctx, off, rc);
		if (rc2 <= 0) {
			xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG,
			       "aee-ipanic: Flash write failed (%d)\n", rc2);
			return rc2;
		}
		off += rc2;
	}
	return copy_count;
}
Esempio n. 3
0
int ipanic_write_log_buf(struct mtd_info *mtd, unsigned int off, struct ipanic_log_index start, struct ipanic_log_index end)  
{
	struct mtd_ipanic_data *ctx = &mtd_drv_ctx;
	int saved_oip;
	int rc, rc2;
	unsigned int last_chunk = 0, copy_count = 0;

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)
    int log_copy_start = start.value;
    int log_copy_end = end.value;
    if (log_copy_start == log_copy_end) {
      int rc3 = mtd_ipanic_block_write(ctx, off, 5);
      return rc3;
    }
#else
    struct kmsg_dumper dumper;
    dumper.active = true;
    dumper.cur_idx = start.idx;
    dumper.cur_seq = start.seq;
    dumper.next_idx = end.idx;
    dumper.next_seq = end.seq;
    if (dumper.cur_idx == dumper.next_idx) {
        int rc3 = mtd_ipanic_block_write(ctx, off, 5);
        return rc3; 
    } 
#endif
    
	while (!last_chunk) {
		saved_oip = oops_in_progress;
		oops_in_progress = 1;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)		
		rc = log_buf_copy2(ctx->bounce, mtd->writesize, log_copy_start, log_copy_end);
		BUG_ON(rc < 0);
		log_copy_start += rc;
#else		
		rc = ipanic_kmsg_dump3(&dumper, ctx->bounce, PAGE_SIZE);
		BUG_ON(rc < 0);
#endif
		copy_count += rc;
		if (rc != mtd->writesize)
			last_chunk = rc;

		oops_in_progress = saved_oip;
		if (rc <= 0)
			break;

		rc2 = mtd_ipanic_block_write(ctx, off, rc);
		if (rc2 <= 0) {
			xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG,
			       "aee-ipanic: Flash write failed (%d)\n", rc2);
			return rc2;
		}
		off += rc2;
	}
	return copy_count;
}