分类:
2012-02-07 16:40:27
原文地址:Linux内核源代码分析——第5章 系 统 调 用 作者:ai616818
linux/kernel/sys.c:
asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void * arg)
这里提供系统调用reboot。可以通过lib引用完成。
case LINUX_REBOOT_CMD_RESTART:
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
printk(KERN_EMERG "Restarting system.\n");
machine_restart(NULL);
break;
linux/arch/arm/kernel/process.c
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);
/*
* Now call the architecture specific reboot code.
*/
arch_reset(reboot_mode);
/*
* Whoops - the architecture was unable to reboot.
* Tell the user!
*/
mdelay(1000);
printk("Reboot failed -- System halted\n");
while (1);
}
linux/include/asm-arm/cpu-multi32.h:
extern const struct processor arm7_processor_functions;
#define cpu_proc_fin() processor._proc_fin()
linux/arch/arm/mm/proc-arm6,7.S:
/*
* Purpose : Function pointers used to access above functions - all calls
* come through these
*/
.type arm7_processor_functions, #object
ENTRY(arm7_processor_functions)
.word cpu_arm7_data_abort
.word cpu_arm7_check_bugs
.word cpu_arm7_proc_init
.word cpu_arm7_proc_fin
.word cpu_arm7_reset
.word cpu_arm7_do_idle
/* cache */
.word cpu_arm7_cache_clean_invalidate_all
.word cpu_arm7_cache_clean_invalidate_range
.word cpu_arm7_flush_ram_page
/* dcache */
.word cpu_arm7_dcache_invalidate_range
.word cpu_arm7_dcache_clean_range
.word cpu_arm7_dcache_clean_page
.word cpu_arm7_dcache_clean_entry
/* icache */
.word cpu_arm7_icache_invalidate_range
.word cpu_arm7_icache_invalidate_page
/* tlb */
.word cpu_arm7_tlb_invalidate_all
.word cpu_arm7_tlb_invalidate_range
.word cpu_arm7_tlb_invalidate_page
/* pgtable */
.word cpu_arm7_set_pgd
.word cpu_arm7_set_pmd
.word cpu_arm7_set_pte
.size arm7_processor_functions, . - arm7_processor_functions
linux/include/asm-arm/arch-sa1100/system.h:
static inline void arch_reset(char mode)
{
if (mode == 's') {
/* Jump into ROM at address 0 */
cpu_reset(0);
} else {
/* Use on-chip reset capability */
RSRR = RSRR_SWR;
}
}
linux/include/asm-arm/cpu-multi32.h:
#define cpu_reset(addr) processor.reset(addr)
linux/arch/arm/mm/proc-arm6,7.S:
ENTRY(cpu_arm7_reset)
mov r1, #0
mcr p15, 0, r1, c7, c0, 0 @ flush cache
mcr p15, 0, r1, c5, c0, 0 @ flush TLB
mov r1, #0x30
mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc
mov pc, r0