static int __init ram_console_late_init(void) { struct proc_dir_entry *entry; struct persistent_ram_zone *prz = ram_console_zone; #if defined(CONFIG_HTC_DEBUG_RAMCONSOLE) bool is_last_bldr_ramdump_mode = false; #endif if (!prz) return 0; if (persistent_ram_old_size(prz) == 0) return 0; entry = create_proc_entry("last_kmsg", S_IFREG | S_IRUGO, NULL); if (!entry) { printk(KERN_ERR "ram_console: failed to create proc entry\n"); persistent_ram_free_old(prz); return 0; } #if defined(CONFIG_HTC_DEBUG_RAMCONSOLE) if (bl_old_log != NULL) { bl_old_log_buf = kmalloc(bl_old_log_size, GFP_KERNEL); if (bl_old_log_buf == NULL) { printk(KERN_ERR "[K] ram_console: failed to allocate buffer for last bootloader log, size: %zu\n", bl_old_log_size); } else { printk(KERN_INFO "[K] ram_console: allocate buffer for last bootloader log, size: %zu\n", bl_old_log_size); bldr_log_parser(bl_old_log, bl_old_log_buf, bl_old_log_size, &bl_old_log_buf_size); is_last_bldr_ramdump_mode = bldr_rst_msg_parser(bl_old_log_buf, bl_old_log_buf_size, true); if (is_last_bldr_ramdump_mode) printk(KERN_INFO "[K] ram_console: Found abnormal rst_msg pattern in last bootloader log\n"); } } if (bl_log != NULL) { bl_log_buf = kmalloc(bl_log_size, GFP_KERNEL); if (bl_log_buf == NULL) { printk(KERN_ERR "[K] ram_console: failed to allocate buffer for bootloader log, size: %zu\n", bl_log_size); } else { printk(KERN_INFO "[K] ram_console: allocate buffer for bootloader log, size: %zu\n", bl_log_size); bldr_log_parser(bl_log, bl_log_buf, bl_log_size, &bl_log_buf_size); if (!is_last_bldr_ramdump_mode) { if (bldr_rst_msg_parser(bl_log_buf, bl_log_buf_size, false)) printk(KERN_INFO "[K] ram_console: Found abnormal rst_msg pattern in bootloader log\n"); } } } #endif entry->proc_fops = &ram_console_file_ops; entry->size = persistent_ram_old_size(prz) + persistent_ram_ecc_string(prz, NULL, 0) + bootinfo_size; #if defined(CONFIG_HTC_DEBUG_RAMCONSOLE) entry->size += bl_old_log_buf_size; entry->size += bl_log_buf_size; #endif return 0; }
int bldr_log_setup(phys_addr_t bldr_phy_addr, size_t bldr_log_size, bool is_last_bldr) { char *bldr_base; int ret = 0; if (!bldr_log_size) { ret = EINVAL; goto _out; } bldr_base = ioremap(bldr_phy_addr, bldr_log_size); if (!bldr_base) { pr_warn("%s: failed to map last bootloader log buffer\n", __func__); ret = -ENOMEM; goto _out; } if (is_last_bldr) { bl_last_log_buf = kmalloc(bldr_log_size, GFP_KERNEL); if (!bl_last_log_buf) { pr_warn("%s: failed to alloc last bootloader log buffer\n", __func__); ret = -ENOMEM; goto _unmap; } else { pr_info("bootloader_log: allocate buffer for last bootloader log, size: %zu\n", bldr_log_size); bldr_log_parser(bldr_base, bl_last_log_buf, bldr_log_size, &bl_last_log_buf_size); } } else { bl_cur_log_buf = kmalloc(bldr_log_size, GFP_KERNEL); if (!bl_cur_log_buf) { pr_warn("%s: failed to alloc last bootloader log buffer\n", __func__); goto _unmap; } else { pr_info("bootloader_log: allocate buffer for bootloader log, size: %zu\n", bldr_log_size); bldr_log_parser(bldr_base, bl_cur_log_buf, bldr_log_size, &bl_cur_log_buf_size); } } _unmap: iounmap(bldr_base); _out: return ret; }
static int __init ram_console_late_init(void) { struct proc_dir_entry *entry; #ifdef CONFIG_DEBUG_LAST_BLDR_LOG if (last_bldr_log != NULL) { last_bldr_log_buf = kmalloc(last_bldr_log_size, GFP_KERNEL); if (last_bldr_log_buf == NULL) printk(KERN_ERR "[K] ram_console: failed to allocate buffer %ld for last bldr log\n", last_bldr_log_size); else { printk(KERN_INFO "[K] ram_console: allocate buffer %ld for last bldr log\n", last_bldr_log_size); bldr_log_parser(last_bldr_log, last_bldr_log_buf, last_bldr_log_size, &last_bldr_log_buf_size); } } #endif #ifdef CONFIG_DEBUG_BLDR_LOG if (bldr_log != NULL) { bldr_log_buf = kmalloc(bldr_log_size, GFP_KERNEL); if (bldr_log_buf == NULL) printk(KERN_ERR "[K] ram_console: failed to allocate buffer %ld for bldr log\n", bldr_log_size); else { printk(KERN_INFO "[K] ram_console: allocate buffer %ld for bldr log\n", bldr_log_size); bldr_log_parser(bldr_log, bldr_log_buf, bldr_log_size, &bldr_log_buf_size); } } #endif if (ram_console_old_log == NULL) return 0; #ifdef CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT ram_console_old_log = kmalloc(ram_console_old_log_size, GFP_KERNEL); if (ram_console_old_log == NULL) { printk(KERN_ERR "[K] ram_console: failed to allocate buffer for old log\n"); ram_console_old_log_size = 0; return 0; } memcpy(ram_console_old_log, ram_console_old_log_init_buffer, ram_console_old_log_size); #endif entry = create_proc_entry("last_kmsg", S_IFREG | S_IRUGO, NULL); if (!entry) { printk(KERN_ERR "[K] ram_console: failed to create proc entry\n"); kfree(ram_console_old_log); ram_console_old_log = NULL; return 0; } entry->proc_fops = &ram_console_file_ops; entry->size = ram_console_old_log_size; #ifdef CONFIG_DEBUG_LAST_BLDR_LOG entry->size += last_bldr_log_size; #endif #ifdef CONFIG_DEBUG_BLDR_LOG entry->size += bldr_log_size; #endif return 0; }