Beispiel #1
0
void machine_restart(char * __unused)
{
	/*
	 * Clean and disable cache, and turn off interrupts
	 */
	cpu_proc_fin();

	/*
	 * Tell the mm system that we are going to reboot -
	 * we may need it to insert some 1:1 mappings so that
	 * soft boot works.
	 */
	setup_mm_for_reboot(reboot_mode);

	/*
         * copy branch instruction to reset location and call it
         */

        *(unsigned long *)0 = *(unsigned long *)0x03800000;
        ((void(*)(void))0)();

	/*
	 * Whoops - the architecture was unable to reboot.
	 * Tell the user! Should never happen...
	 */
	mdelay(1000);
	printk("Reboot failed -- System halted\n");
	while (1);
}
Beispiel #2
0
static int proc_splboot_store(struct file *file,
                             const char *buffer,
                             unsigned long count,
                             void *data)
{
	loader_param* param = (loader_param*)(splmem+IMAGE_LOADER_SIZE);
	if(!spl_image_stored){
		printk(KERN_EMERG "Need store image.\n");
		return 0;
	}
	printk(KERN_EMERG "Starting new spl\n");

	param->version = 0;
	param->param_size = sizeof(*param);
	param->mddiaddr = (unsigned int)mddiaddr;
	param->machine_type = s_machine_type;
	strncpy(param->bootparam, s_bootparam, BOOTPARAM_SIZE);
	strncpy(param->serialno, s_serialno, SERIALNO_SIZE);
	if(boot_image_stored){
		param->bootimgaddr = IMAGE_BOOT_ADDR;
		param->bootimgsize = bootimg_off;
	}
	memcpy(spladdr, splmem, s_splsize);

	flush_icache_range((unsigned long) spladdr,
			   (unsigned long) spladdr + s_splsize);
	printk(KERN_INFO "Bye!\n");
	setup_mm_for_reboot(0);
	memdump(spladdr, 0x100);
	printk(KERN_INFO "spladdr=%p s_spladdr=%08x\n", spladdr, s_spladdr);
	spladdr = (void*)s_spladdr;
	memdump(spladdr, 0x100);
	cpu_reset(s_spladdr);
	return 0;
}
Beispiel #3
0
void machine_kexec(struct kimage *image)
{
	unsigned long page_list;
	unsigned long reboot_code_buffer_phys;
	void *reboot_code_buffer;


	page_list = image->head & PAGE_MASK;

	/* we need both effective and real address here */
	reboot_code_buffer_phys =
	    page_to_pfn(image->control_code_page) << PAGE_SHIFT;
	reboot_code_buffer = page_address(image->control_code_page);

	/* Prepare parameters for reboot_code_buffer*/
	kexec_start_address = image->start;
	kexec_indirection_page = page_list;
	kexec_mach_type = machine_arch_type;
	kexec_boot_atags = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET;

	/* copy our kernel relocation code to the control code page */
	memcpy(reboot_code_buffer,
	       relocate_new_kernel, relocate_new_kernel_size);


	flush_icache_range((unsigned long) reboot_code_buffer,
			   (unsigned long) reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE);
	printk(KERN_INFO "Bye!\n");

	cpu_proc_fin();
	setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
	cpu_reset(reboot_code_buffer_phys);
}
Beispiel #4
0
void machine_restart(char *cmd)
{
	/*
	 * Clean and disable cache, and turn off interrupts
	 */
	cpu_proc_fin();

	/*
	 * Tell the mm system that we are going to reboot -
	 * we may need it to insert some 1:1 mappings so that
	 * soft boot works.
	 */
	setup_mm_for_reboot(reboot_mode_nds32);

	/* Execute kernel restart handler call chain */
	do_kernel_restart(cmd);

	/*
	 * Now call the architecture specific reboot code.
	 */
	arch_reset(reboot_mode_nds32);

	/*
	 * Whoops - the architecture was unable to reboot.
	 * Tell the user!
	 */
	mdelay(1000);
	pr_info("Reboot failed -- System halted\n");
	while (1) ;
}
static void msm_pm_restart(char str, const char *cmd)
{
        unsigned size;
        samsung_vendor1_id *smem_vendor1 = \
                (samsung_vendor1_id *)smem_get_entry(SMEM_ID_VENDOR1, &size);

        if (smem_vendor1) {
                smem_vendor1->silent_reset = 0xAEAEAEAE;
                smem_vendor1->reboot_reason = restart_reason;
        smem_vendor1->AP_reserved[0] = 0;
        } else {
                printk(KERN_EMERG "smem_flag is NULL\n");
        }

        pr_debug("The reset reason is %x\n", restart_reason);

        /* Disable interrupts */
        local_irq_disable();
        local_fiq_disable();

        /*
         * Take out a flat memory mapping  and will
         * insert a 1:1 mapping in place of
         * the user-mode pages to ensure predictable results
         * This function takes care of flushing the caches
         * and flushing the TLB.
         */
        setup_mm_for_reboot();

        msm_proc_comm(PCOM_RESET_CHIP, &restart_reason, 0);

        for (;;)
                ;
}
Beispiel #6
0
static void rk_reboot( void)
{
	local_irq_disable();
//	cpu_proc_fin();
       setup_mm_for_reboot('r');
	rk2818_soft_restart();
}
/*
 * The framework loads the hibernation image into a linked list anchored
 * at restore_pblist, for swsusp_arch_resume() to copy back to the proper
 * destinations.
 *
 * To make this work if resume is triggered from initramfs, the
 * pagetables need to be switched to allow writes to kernel mem.
 */
void notrace mtk_arch_restore_image(void)
{
	phys_reset_t phys_reset;
	struct pbe *pbe;

	for (pbe = restore_pblist; pbe; pbe = pbe->next)
		copy_page(pbe->orig_address, pbe->address);

#if 0	/* [ALPS01496758]  since CA17 has cache bug, replace with the modified assemlby version */
	/* Clean and invalidate caches */
	flush_cache_all();

	/* Turn off caching */
	cpu_proc_fin();

	/* Push out any further dirty data, and ensure cache is empty */
	flush_cache_all();
#else
	__disable_dcache__inner_flush_dcache_L1__inner_flush_dcache_L2();
#endif

	/* Take out a flat memory mapping. */
	setup_mm_for_reboot();
	phys_reset = (phys_reset_t)(unsigned long)virt_to_phys(cpu_reset);
	/* Return from cpu_suspend/swsusp_arch_suspend */
	phys_reset((unsigned long)virt_to_phys(cpu_resume));

	/* Should never get here. */
	BUG();
}
static void __soft_restart(void *addr)
{
	phys_reset_t phys_reset;

	/* Take out a flat memory mapping. */
	setup_mm_for_reboot();

	/* Clean and invalidate caches */
	flush_cache_all();

	/* Turn off caching */
	cpu_proc_fin();

	/* Push out any further dirty data, and ensure cache is empty */
	flush_cache_all();

	/* Push out the dirty data from external caches */
	outer_disable();

	/* Switch to the identity mapping. */
	phys_reset = (phys_reset_t)(unsigned long)virt_to_phys(cpu_reset);
	phys_reset((unsigned long)addr);

	/* Should never get here. */
	BUG();
}
Beispiel #9
0
static void kld_reboot( int reset , int boot )
{
        local_irq_disable();
        kld_set_reset_flag(reset , boot );
        cpu_proc_fin();
        setup_mm_for_reboot('r');
        rk28_soft_restart();
}
/* main function */
int init_module()
//static int __init init_module(void)
{
        mm_segment_t old_fs;
        int err = 0;
        unsigned long kernel_size;
        unsigned long initrd_size;
        void *reloaded_reboot_code;

        printk("reloaded for Cybook Gen 3, 2007 [email protected], 2008 [email protected]\n");

	write_gpio_bit(GPIO_B8, 1); /* switch off the led */

        /* load kernel and initrd */
        old_fs = get_fs();
        set_fs(KERNEL_DS);
        if ((err = get_size(kernel, &kernel_size)) < 0) 
                printk("%s: stat failed (%d)\n", kernel, err);
        else if (*initrd && (err = get_size(initrd, &initrd_size)) < 0)
                printk("%s: stat failed (%d)\n", initrd, err);
        set_fs(old_fs);
        if (err < 0)
                return -ENOENT;

        printk("%s: %ld bytes\n", kernel, kernel_size);
        load_file(kernel, kernel_size, reloaded_kernel_segments);
        if (*initrd) {
                printk("%s: %ld bytes\n", initrd, initrd_size);
                load_file(initrd, initrd_size, reloaded_initrd_segments);
        }

        /* */
        reloaded_machtype = machtype;
        printk("reloaded_machtype = %ld\n", reloaded_machtype);
        reloaded_taglist = virt_to_phys(make_taglist(*initrd ? initrd_size : 0));
        printk("reloaded_taglist  = %lx (%p)\n", reloaded_taglist, phys_to_virt(reloaded_taglist));
        if (!(reloaded_reboot_code = kmalloc(reloaded_reboot_size, GFP_KERNEL))) 
                panic("reboot code: Out of memory\n");
        printk("copying %lu bytes reboot code from %p to %p\n",
               reloaded_reboot_size, reloaded_do_reboot, reloaded_reboot_code);
        memcpy(reloaded_reboot_code, reloaded_do_reboot, reloaded_reboot_size);
        reloaded_reboot_start = virt_to_phys(reloaded_reboot_code);
        printk("reloaded_reboot_start  = %lx\n", reloaded_reboot_start);
	
	write_gpio_bit(GPIO_B8, 0); /* switch the led on */

        /* go */
        printk(KERN_INFO "Reloading...\n");
        disable_irq(IRQ_USBH);
        CLKCON &= ~CLKCON_USBH;
	flush_icache_range((unsigned long)reloaded_reboot_code, (unsigned long)reloaded_reboot_code + reloaded_reboot_size);
        cpu_arm920_proc_fin();
        setup_mm_for_reboot(0);
        reloaded_reboot();

        panic("FAILED\n");
        return -1;
}
Beispiel #11
0
static int tegra_sleep_cpu(unsigned long v2p)
{
	setup_mm_for_reboot();
	tegra_sleep_cpu_finish(v2p);

	/* should never here */
	BUG();

	return 0;
}
void machine_kexec(struct kimage *image)
{
	unsigned long page_list;
	unsigned long reboot_code_buffer_phys;
	void *reboot_code_buffer;

	arch_kexec();

	page_list = image->head & PAGE_MASK;

	/* we need both effective and real address here */
	reboot_code_buffer_phys =
	    page_to_pfn(image->control_code_page) << PAGE_SHIFT;
	reboot_code_buffer = page_address(image->control_code_page);

	/* Prepare parameters for reboot_code_buffer*/
	mem_text_write_kernel_word(&kexec_start_address, image->start);
	mem_text_write_kernel_word(&kexec_indirection_page, page_list);
	mem_text_write_kernel_word(&kexec_mach_type, machine_arch_type);
	mem_text_write_kernel_word(&kexec_boot_atags, image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET);

#ifdef CONFIG_KEXEC_HARDBOOT
	mem_text_write_kernel_word(&kexec_hardboot, image->hardboot);
#endif

	/* copy our kernel relocation code to the control code page */
	memcpy(reboot_code_buffer,
	       relocate_new_kernel, relocate_new_kernel_size);


	flush_icache_range((unsigned long) reboot_code_buffer,
			   (unsigned long) reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE);
	printk(KERN_INFO "Bye!\n");

	if (kexec_reinit)
		kexec_reinit();
	local_irq_disable();
	local_fiq_disable();
	setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
#ifdef CONFIG_KEXEC_HARDBOOT
	if (image->hardboot && kexec_hardboot_hook)
		/* Run any final machine-specific shutdown code. */
		kexec_hardboot_hook();
#endif
	flush_cache_all();
	outer_flush_all();
	outer_disable();
	cpu_proc_fin();
	outer_inv_all();
	flush_cache_all();
	__virt_to_phys(cpu_reset)(reboot_code_buffer_phys);
}
Beispiel #13
0
static void msm_pm_restart(char str, const char *cmd)
{
	int rc;
	unsigned size;

#if defined(CONFIG_MACH_ARUBASLIM_OPEN)
	unsigned int freq = 600000;

	rc = acpuclk_set_rate(0, freq, SETRATE_CPUFREQ);
	if (rc) {
		printk(KERN_ERR "%s(): failed to restore clock rate(%lu)\n",
			__func__, freq);
	}
	pr_info("%s: Current ACPU frequency %ld\n", __func__, acpuclk_get_rate(0));
#endif

	samsung_vendor1_id *smem_vendor1 = \
		(samsung_vendor1_id *)smem_get_entry(SMEM_ID_VENDOR1, &size);

	if (smem_vendor1) {
		smem_vendor1->silent_reset = 0xAEAEAEAE;
		smem_vendor1->reboot_reason = restart_reason;
        smem_vendor1->AP_reserved[0] = 0;
	} else {
		printk(KERN_EMERG "smem_flag is NULL\n");
	}

	pr_debug("The reset reason is %x\n", restart_reason);

	rc = ncp6335d_restart_config();
	if (rc)
		pr_err("Unable to configure NCP6335D for restart\n");

	/* Disable interrupts */
	local_irq_disable();
	local_fiq_disable();

	/*
	 * Take out a flat memory mapping  and will
	 * insert a 1:1 mapping in place of
	 * the user-mode pages to ensure predictable results
	 * This function takes care of flushing the caches
	 * and flushing the TLB.
	 */
	setup_mm_for_reboot();

	msm_proc_comm(PCOM_RESET_CHIP, &restart_reason, 0);

	for (;;)
		;
}
Beispiel #14
0
void mcpm_cpu_suspend(u64 expected_residency)
{
	phys_reset_t phys_reset;

	BUG_ON(!platform_ops);
	BUG_ON(!irqs_disabled());

	/* Very similar to mcpm_cpu_power_down() */
	setup_mm_for_reboot();
	platform_ops->suspend(expected_residency);
	phys_reset = (phys_reset_t)(unsigned long)virt_to_phys(cpu_reset);
	phys_reset(virt_to_phys(mcpm_entry_point));
	BUG();
}
/* MTD-Kernel-HC-handle_reset-03+[ */
static void msm_pm_restart(char str, const char *cmd)
{
	
	uint32_t oem_cmd = SMEM_PROC_COMM_OEM_RESET_CHIP_EBOOT;
	uint32_t smem_response = 0;
	uint32_t ret = 0;

	pr_debug("The reset reason is %x\n", restart_reason);

	/* MTD-Kernel-HC-handle_reset-02+[ */
	if (cmd)
	{
		if (!strncmp(cmd, "panic", 5))
		{
			restart_reason = 0x46544443;
			pr_err("restart_reason = panic\n");
		}
	}
	/* MTD-Kernel-HC-handle_reset-02+] */

	/* Disable interrupts */
	local_irq_disable();
	local_fiq_disable();

	/*
	 * Take out a flat memory mapping  and will
	 * insert a 1:1 mapping in place of
	 * the user-mode pages to ensure predictable results
	 * This function takes care of flushing the caches
	 * and flushing the TLB.
	 */
	setup_mm_for_reboot();
	
	ret = msm_proc_comm_oem(PCOM_CUSTOMER_CMD1, &oem_cmd, &smem_response, &restart_reason);
	
	if (ret != 0)
	{
		pr_err("SMEM_PROC_COMM_OEM_RESET_CHIP_EBOOT failed, ret = %d\n", ret);
		msm_proc_comm(PCOM_RESET_CHIP, &restart_reason, 0);
	}

	for (;;)
		;
}
Beispiel #16
0
void mcpm_cpu_power_down(void)
{
	phys_reset_t phys_reset;

	if (WARN_ON_ONCE(!platform_ops || !platform_ops->power_down))
		return;
	BUG_ON(!irqs_disabled());

	/*
	 * Do this before calling into the power_down method,
	 * as it might not always be safe to do afterwards.
	 */
	setup_mm_for_reboot();

	platform_ops->power_down();

	/*
	 * It is possible for a power_up request to happen concurrently
	 * with a power_down request for the same CPU. In this case the
	 * power_down method might not be able to actually enter a
	 * powered down state with the WFI instruction if the power_up
	 * method has removed the required reset condition.  The
	 * power_down method is then allowed to return. We must perform
	 * a re-entry in the kernel as if the power_up method just had
	 * deasserted reset on the CPU.
	 *
	 * To simplify race issues, the platform specific implementation
	 * must accommodate for the possibility of unordered calls to
	 * power_down and power_up with a usage count. Therefore, if a
	 * call to power_up is issued for a CPU that is not down, then
	 * the next call to power_down must not attempt a full shutdown
	 * but only do the minimum (normally disabling L1 cache and CPU
	 * coherency) and return just as if a concurrent power_up request
	 * had happened as described above.
	 */

	phys_reset = (phys_reset_t)(unsigned long)virt_to_phys(cpu_reset);
	phys_reset(virt_to_phys(mcpm_entry_point));

	/* should never get here */
	BUG();
}
Beispiel #17
0
static int __init nocache_trampoline(unsigned long _arg)
{
	void (*cache_disable)(void) = (void *)_arg;
	unsigned int mpidr = read_cpuid_mpidr();
	unsigned int cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
	unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
	phys_reset_t phys_reset;

	mcpm_set_entry_vector(cpu, cluster, cpu_resume);
	setup_mm_for_reboot();

	__mcpm_cpu_going_down(cpu, cluster);
	BUG_ON(!__mcpm_outbound_enter_critical(cpu, cluster));
	cache_disable();
	__mcpm_outbound_leave_critical(cluster, CLUSTER_DOWN);
	__mcpm_cpu_down(cpu, cluster);

	phys_reset = (phys_reset_t)(unsigned long)virt_to_phys(cpu_reset);
	phys_reset(virt_to_phys(mcpm_entry_point));
	BUG();
}
static void msm_pm_restart(char str, const char *cmd)
{
	pr_debug("The reset reason is %x\n", restart_reason);

	/*                    */
	local_irq_disable();
	local_fiq_disable();

	/*
                                            
                                    
                                                     
                                                   
                         
  */
	setup_mm_for_reboot();

	msm_proc_comm(PCOM_RESET_CHIP, &restart_reason, 0);

	for (;;)
		;
}
static void msm_pm_restart(char str, const char *cmd)
{
	pr_debug("The reset reason is %x\n", restart_reason);

	/* Disable interrupts */
	local_irq_disable();
	local_fiq_disable();

	/*
	 * Take out a flat memory mapping  and will
	 * insert a 1:1 mapping in place of
	 * the user-mode pages to ensure predictable results
	 * This function takes care of flushing the caches
	 * and flushing the TLB.
	 */
	setup_mm_for_reboot();

	msm_proc_comm(PCOM_RESET_CHIP, &restart_reason, 0);

	for (;;)
		;
}
Beispiel #20
0
void mcpm_cpu_power_down(void)
{
	unsigned int mpidr, cpu, cluster;
	bool cpu_going_down, last_man;
	phys_reset_t phys_reset;

	mpidr = read_cpuid_mpidr();
	cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
	cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
	pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
	if (WARN_ON_ONCE(!platform_ops))
	       return;
	BUG_ON(!irqs_disabled());

	setup_mm_for_reboot();

	__mcpm_cpu_going_down(cpu, cluster);
	arch_spin_lock(&mcpm_lock);
	BUG_ON(__mcpm_cluster_state(cluster) != CLUSTER_UP);

	mcpm_cpu_use_count[cluster][cpu]--;
	BUG_ON(mcpm_cpu_use_count[cluster][cpu] != 0 &&
	       mcpm_cpu_use_count[cluster][cpu] != 1);
	cpu_going_down = !mcpm_cpu_use_count[cluster][cpu];
	last_man = mcpm_cluster_unused(cluster);

	if (last_man && __mcpm_outbound_enter_critical(cpu, cluster)) {
		platform_ops->cpu_powerdown_prepare(cpu, cluster);
		platform_ops->cluster_powerdown_prepare(cluster);
		arch_spin_unlock(&mcpm_lock);
		platform_ops->cluster_cache_disable();
		__mcpm_outbound_leave_critical(cluster, CLUSTER_DOWN);
	} else {
		if (cpu_going_down)
			platform_ops->cpu_powerdown_prepare(cpu, cluster);
		arch_spin_unlock(&mcpm_lock);
		/*
		 * If cpu_going_down is false here, that means a power_up
		 * request raced ahead of us.  Even if we do not want to
		 * shut this CPU down, the caller still expects execution
		 * to return through the system resume entry path, like
		 * when the WFI is aborted due to a new IRQ or the like..
		 * So let's continue with cache cleaning in all cases.
		 */
		platform_ops->cpu_cache_disable();
	}

	__mcpm_cpu_down(cpu, cluster);

	/* Now we are prepared for power-down, do it: */
	if (cpu_going_down)
		wfi();

	/*
	 * It is possible for a power_up request to happen concurrently
	 * with a power_down request for the same CPU. In this case the
	 * CPU might not be able to actually enter a powered down state
	 * with the WFI instruction if the power_up request has removed
	 * the required reset condition.  We must perform a re-entry in
	 * the kernel as if the power_up method just had deasserted reset
	 * on the CPU.
	 */
	phys_reset = (phys_reset_t)(unsigned long)virt_to_phys(cpu_reset);
	phys_reset(virt_to_phys(mcpm_entry_point));

	/* should never get here */
	BUG();
}