Пример #1
0
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);
}
Пример #2
0
static int __init sec_log_setup(char *str)
{
	unsigned size = memparse(str, &str);

/*
	unsigned *sec_log_mag;
	unsigned start;
	unsigned long flags;
*/

	if (size && (size == roundup_pow_of_two(size)) && (*str == '@')) {
		unsigned long base = 0;

		base = simple_strtoul(++str, &str, 0);
#ifdef CONFIG_PRINTK_NOCACHE
		sec_log_save_size = size;
		sec_log_save_base = base;
		sec_log_size = size;
		sec_log_reserve_base = base - 8;
		sec_log_reserve_size = size + 8;

		return 1;
#endif

	}
#if 0
	sec_getlog_supply_kloginfo(sec_log_buf);
#endif

// out:
	return 1;
}
Пример #3
0
static int __init sec_log_setup(char *str)
{
	unsigned size = memparse(str, &str);
	unsigned long base = 0;
	unsigned *sec_log_mag;

	if (!size || size != roundup_pow_of_two(size) || *str != '@'
	    || kstrtoul(str + 1, 0, &base))
		goto out;

	base = 0x46000000;
	size = 0x200000;

	/* If we encounter any problem parsing str ... */
	if (reserve_bootmem(base - 8, size + 8, BOOTMEM_EXCLUSIVE)) {
		pr_err("%s: failed reserving size %d + 8 " \
		       "at base 0x%lx - 8\n", __func__, size, base);
		goto out;
	}

#ifdef CONFIG_SEC_LOG_NONCACHED
	log_buf_iodesc[0].pfn = __phys_to_pfn((unsigned long)base - 0x100000);
	log_buf_iodesc[0].length = (unsigned long)(size + 0x100000);
	iotable_init(log_buf_iodesc, ARRAY_SIZE(log_buf_iodesc));
	flush_tlb_all();
	sec_log_mag = (S3C_VA_KLOG_BUF + 0x100000) - 8;
	sec_log_ptr = (S3C_VA_KLOG_BUF + 0x100000) - 4;
	sec_log_buf = S3C_VA_KLOG_BUF + 0x100000;
#else
	sec_log_mag = phys_to_virt(base) - 8;
	sec_log_ptr = phys_to_virt(base) - 4;
	sec_log_buf = phys_to_virt(base);
#endif

	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);

	if (*sec_log_mag != LOG_MAGIC) {
		pr_info("%s: no old log found\n", __func__);
		*sec_log_ptr = 0;
		*sec_log_mag = LOG_MAGIC;
	} else
		sec_log_save_old();

	register_log_char_hook(emit_sec_log_char);

	sec_getlog_supply_kloginfo(phys_to_virt(base));

out:
	return 0;
}
Пример #4
0
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;
}
Пример #5
0
// 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;
}
Пример #6
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;
}
void __init setup_log_buf(int early)
{
	unsigned long flags;
	unsigned start, dest_idx, offset;
	char *new_log_buf;
	int free;

	if (!new_log_buf_len) {
#if defined(CONFIG_SEC_DEBUG)
		//{{ Mark for GetLog
		sec_getlog_supply_kloginfo(__log_buf);
		//}} Mark for GetLog
#endif
		return;
	}
	if (early) {
		unsigned long mem;

		mem = memblock_alloc(new_log_buf_len, PAGE_SIZE);
		if (mem == MEMBLOCK_ERROR)
			return;
		new_log_buf = __va(mem);
	} else {
		new_log_buf = alloc_bootmem_nopanic(new_log_buf_len);
	}

	if (unlikely(!new_log_buf)) {
		pr_err("log_buf_len: %ld bytes not available\n",
			new_log_buf_len);
		return;
	}

	spin_lock_irqsave(&logbuf_lock, flags);
	log_buf_len = new_log_buf_len;
	log_buf = new_log_buf;
	new_log_buf_len = 0;
	free = __LOG_BUF_LEN - log_end;

	offset = start = min(con_start, log_start);
	dest_idx = 0;
	while (start != log_end) {
		unsigned log_idx_mask = start & (__LOG_BUF_LEN - 1);

		log_buf[dest_idx] = __log_buf[log_idx_mask];
		start++;
		dest_idx++;
	}
	log_start -= offset;
	con_start -= offset;
	log_end -= offset;
	spin_unlock_irqrestore(&logbuf_lock, flags);

#if defined(CONFIG_SEC_DEBUG)
		//{{ Mark for GetLog
	sec_getlog_supply_kloginfo(__log_buf);
		//}} Mark for GetLog
#endif

	pr_info("log_buf_len: %d\n", log_buf_len);
	pr_info("early log buf free: %d(%d%%)\n",
		free, (free * 100) / __LOG_BUF_LEN);
}
Пример #8
0
static int __init sec_logbuf_conf_memtype(void)
{
#ifdef CONFIG_SEC_LOG_BUF_NOCACHE
	void __iomem *base = 0;
#else
	unsigned long base = 0;
#endif
	unsigned *sec_log_mag;
	unsigned size_of_log_ptr = sizeof(*sec_log_mag);
	unsigned size_of_log_mag = sizeof(*sec_log_ptr);
	unsigned size_struct_sec_log_buffer = sizeof(struct sec_log_buffer);
	
	/* Round-up to 4 byte alignment */
	size_struct_sec_log_buffer = (((size_struct_sec_log_buffer + 4) / 4)* 4);
	pr_info("%s: size_of_log_ptr:%d size_of_log_mag:%d"
		"size_struct_sec_log_buffer:%d\n",
		__func__, size_of_log_ptr, size_of_log_mag,
					size_struct_sec_log_buffer);

	/**********************************************************************
	 ___________________
	|   sec_log_buffer  |   16 bytes,4 byte aligned sec_log_buffer struct
	|___________________|
	|                   |
	|   sec_log_buf     |	1 MB, sec log buffer
	|                   |
	|___________________|
	|   sec_log_ptr	    |	4 bytes,which holds the index of sec_log_buf[]
	|___________________|
	|   sec_log_mag     |	4 bytes, which holds the magic address
	|___________________|

	***********************************************************************/

	if(sec_log_buf_nocache_enable == 1)
	{
		base = ioremap_nocache(sec_logbuf_base_addr, LOG_LENGTH_B);
		if(base == NULL){
			printk("ioremap nocache fail\n");
			return -1;
		}
		sec_log_buffer = base;
		sec_log_mag = base+ size_struct_sec_log_buffer +
							sec_logbuf_size + size_of_log_ptr;
		sec_log_ptr = base + size_struct_sec_log_buffer + sec_logbuf_size;
		sec_log_buf = base + size_struct_sec_log_buffer;
		sec_log_size = sec_logbuf_size;
	}
	else if(sec_log_buf_nocache_enable == 0) {
		base = sec_logbuf_base_addr;
		sec_log_mag = phys_to_virt(base) + size_struct_sec_log_buffer +
							sec_logbuf_size + size_of_log_ptr;
		sec_log_ptr = phys_to_virt(base) + size_struct_sec_log_buffer + sec_logbuf_size;
		sec_log_buffer = phys_to_virt(base);                
		sec_log_buf = phys_to_virt(base) + size_struct_sec_log_buffer;
		sec_log_size = sec_logbuf_size;

	}
	else {
		printk("%s: sec logbuffer fail to alloc both cache and non-cache\n",__func__);
		return -1;
	}

	pr_info("%s: Addresses: struct sec_log_buffer:%p sec_log_buf:%p"
		"sec_log_ptr:%p sec_log_mag:%p\n",
		__func__, sec_log_buffer, sec_log_buf, sec_log_ptr,
		sec_log_mag);

	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);

	if (*sec_log_mag != LOG_MAGIC) {
		pr_info("%s: no old log found\n", __func__);
		*sec_log_ptr = 0;
		*sec_log_mag = LOG_MAGIC;
	} else {
		if (*sec_log_ptr)
			sec_log_save_old();
		else
			pr_err("%s: unlikely *sec_log_ptr is zero, skip sec_log_save_old\n", __func__);
	}
#ifdef CONFIG_SEC_DEBUG_REG_ACCESS
	sec_debug_set_last_regs_access();
#endif
	sec_log_buffer->sig = RAM_CONSOLE_SIG;
	sec_log_buffer->size = 0;
	sec_log_buffer->start = *sec_log_ptr;
	sec_log_buffer->from = 0;
	sec_log_buffer->to = 0;

	register_log_text_hook(emit_sec_log, sec_log_buf, sec_log_ptr,
		sec_log_size);
		
	sec_getlog_supply_kloginfo(sec_log_buf );

	return 0;
}