void printk_remap_nocache(void) { unsigned long long nocache_base = 0; unsigned *sec_log_mag; unsigned long flags; unsigned start; #if 1 if( 0 == sec_debug_is_enabled() ) { sec_getlog_supply_kloginfo(log_buf); return; } #endif pr_err("%s: sec_log_save_size %d at sec_log_save_base 0x%x \n", __func__, sec_log_save_size, (unsigned int)sec_log_save_base); pr_err("%s: sec_log_reserve_size %d at sec_log_reserve_base 0x%x \n", __func__, sec_log_reserve_size, (unsigned int)sec_log_reserve_base); #if 0 free_bootmem(sec_log_reserve_base, sec_log_reserve_size); #endif nocache_base = ioremap_nocache(sec_log_save_base - 4096, sec_log_save_size + 8192); nocache_base = nocache_base + 4096; sec_log_mag = nocache_base - 8; sec_log_ptr = nocache_base - 4; sec_log_buf = nocache_base; sec_log_size = sec_log_save_size; sec_log_irq_en = nocache_base - 0xC ; #if 0 pr_err("%s: sec_log_save_size %d at sec_log_save_base 0x%x \n", __func__, sec_log_save_size, (unsigned int)sec_log_save_base); pr_err("%s: nocache_base %x " " sec_log_mag:0x%x " "at sec_log_ptr 0x%x " "at sec_log_buf 0x%p \n", __func__, nocache_base, *sec_log_mag, *sec_log_ptr, sec_log_buf); #endif spin_lock_irqsave(&logbuf_lock, flags); if (*sec_log_mag != LOG_MAGIC) { *sec_log_ptr = 0; *sec_log_mag = LOG_MAGIC; } start = min(con_start, log_start); while (start != log_end) { emit_sec_log_char(__log_buf [start++ & (__LOG_BUF_LEN - 1)]); } spin_unlock_irqrestore(&logbuf_lock, flags); sec_getlog_supply_kloginfo(sec_log_buf); }
static void emit_log_char(char c) { LOG_BUF(log_end) = c; log_end++; if (log_end - log_start > log_buf_len) log_start = log_end - log_buf_len; if (log_end - con_start > log_buf_len) con_start = log_end - log_buf_len; if (logged_chars < log_buf_len) logged_chars++; emit_sec_log_char(c); }
static int __init sec_log_setup(char *str) { unsigned size = memparse(str, &str); unsigned long flags; if (size && (size == roundup_pow_of_two(size)) && (*str == '@')) { unsigned long long base = 0; unsigned *sec_log_mag; unsigned start; base = simple_strtoul(++str, &str, 0); if (reserve_bootmem(base - 8, size + 8, BOOTMEM_EXCLUSIVE)) { pr_err("%s: failed reserving size %d + 8 " "at base 0x%llx - 8\n", __func__, size, base); goto out; } sec_log_mag = phys_to_virt(base) - 8; sec_log_ptr = phys_to_virt(base) - 4; sec_log_buf = phys_to_virt(base); sec_log_size = size; pr_info("%s: *sec_log_mag:%x *sec_log_ptr:%x " "sec_log_buf:%p sec_log_size:%d\n", __func__, *sec_log_mag, *sec_log_ptr, sec_log_buf, sec_log_size); spin_lock_irqsave(&logbuf_lock, flags); if (*sec_log_mag != LOG_MAGIC) { *sec_log_ptr = 0; *sec_log_mag = LOG_MAGIC; } start = min(con_start, log_start); while (start != log_end) { emit_sec_log_char(__log_buf [start++ & (__LOG_BUF_LEN - 1)]); } spin_unlock_irqrestore(&logbuf_lock, flags); } sec_getlog_supply_kloginfo(sec_log_buf); out: return 1; }
// void printk_remap_nocache(void) static int __init printk_remap_nocache(void) { unsigned long nocache_base = 0; unsigned *sec_log_mag; unsigned long flags; unsigned start; pr_err("%s: sec_log_save_size %d at sec_log_save_base 0x%x \n", __func__, sec_log_save_size, (unsigned int)sec_log_save_base); pr_err("%s: sec_log_reserve_size %d at sec_log_reserve_base 0x%x \n", __func__, sec_log_reserve_size, (unsigned int)sec_log_reserve_base); nocache_base = (unsigned long)ioremap_nocache(sec_log_save_base - 4096, sec_log_save_size + 8192); nocache_base = nocache_base + 4096; sec_log_mag = (unsigned *)(nocache_base - 8); sec_log_ptr = (unsigned *)(nocache_base - 4); sec_log_buf = (char *)nocache_base; sec_log_size = sec_log_save_size; sec_log_irq_en = (unsigned int *)(nocache_base - 0xC); if (*sec_log_mag != LOG_MAGIC) { *sec_log_ptr = 0; *sec_log_mag = LOG_MAGIC; } else { sec_log_save_old(); } spin_lock_irqsave(&logbuf_lock, flags); start = min(con_start, log_start); while (start != log_end) { emit_sec_log_char(__log_buf [start++ & (__LOG_BUF_LEN - 1)]); } spin_unlock_irqrestore(&logbuf_lock, flags); sec_getlog_supply_kloginfo(log_buf); return 0; }
static int __init printk_remap_nocache(void) { void __iomem *nocache_base = 0; unsigned *sec_log_mag; unsigned long flags; unsigned start; int rc = 0; sec_getlog_supply_kloginfo(log_buf); if (0 == sec_debug_is_enabled()) { #ifdef CONFIG_SEC_SSR_DUMP nocache_base = ioremap_nocache(sec_log_save_base - 4096, sec_log_save_size + 8192); nocache_base = nocache_base + 4096; sec_log_mag = nocache_base - 8; sec_log_ptr = nocache_base - 4; sec_log_buf = nocache_base; ramdump_kernel_log_addr = sec_log_ptr; pr_debug("ramdump_kernel_log_addr = 0x%x\n", ramdump_kernel_log_addr); sec_log_size = sec_log_save_size; sec_log_irq_en = nocache_base - 0xC ; #endif #ifdef CONFIG_SEC_DEBUG_LOW_LOG nocache_base = ioremap_nocache(sec_log_save_base - 4096, sec_log_save_size + 8192); nocache_base = nocache_base + 4096; sec_log_mag = nocache_base - 8; sec_log_ptr = nocache_base - 4; sec_log_buf = nocache_base; sec_log_size = sec_log_save_size; sec_log_irq_en = nocache_base - 0xC ; #endif return rc; } pr_err("%s: sec_log_save_size %d at sec_log_save_base 0x%x\n", __func__, sec_log_save_size, (unsigned int)sec_log_save_base); pr_err("%s: sec_log_reserve_size %d at sec_log_reserve_base 0x%x\n", __func__, sec_log_reserve_size, (unsigned int)sec_log_reserve_base); nocache_base = ioremap_nocache(sec_log_save_base - 4096, sec_log_save_size + 8192); nocache_base = nocache_base + 4096; sec_log_mag = nocache_base - 8; sec_log_ptr = nocache_base - 4; sec_log_buf = nocache_base; #ifdef CONFIG_SEC_SSR_DUMP ramdump_kernel_log_addr = sec_log_ptr; pr_info("%s: ramdump_kernel_log_addr = 0x%x\n", __func__, ramdump_kernel_log_addr); #endif sec_log_size = sec_log_save_size; sec_log_irq_en = nocache_base - 0xC ; spin_lock_irqsave(&logbuf_lock, flags); if (*sec_log_mag != LOG_MAGIC) { *sec_log_ptr = 0; *sec_log_mag = LOG_MAGIC; } start = min(con_start, log_start); while (start != log_end) { emit_sec_log_char(__log_buf [start++ & (__LOG_BUF_LEN - 1)]); } spin_unlock_irqrestore(&logbuf_lock, flags); return rc; }