kernel/reboot.c文件是重新启动过程的与体系结构无关的部分。
arch/x86/kernel/reboot.c和所有其他arch/*/kernel/reboot.c是某些功能的体系结构特定版本,由kernel/reboot.c使用。
例如,在arch/x86/kernel/reboot.c中有machine_real_restart() function(假设我们使用BIOS启动,实际选择在native_machine_emergency_restart),这是最后调用的内核函数。它要求BIOS做实际重新引导:
69 void __noreturn machine_real_restart(unsigned int type)
73 /*
74 * Write zero to CMOS register number 0x0f, which the BIOS POST
75 * routine will recognize as telling it to do a proper reboot. (Well
76 * that's what this book in front of me says -- it may only apply to
77 * the Phoenix BIOS though, it's not clear). At the same time,
78 * disable NMIs by setting the top bit in the CMOS address register,
79 * as we're about to do peculiar things to the CPU. I'm not sure if
80 * `outb_p' is needed instead of just `outb'. Use it to be on the
81 * safe side. (Yes, CMOS_WRITE does outb_p's. - Paul G.)
82 */
84 CMOS_WRITE(0x00, 0x8f);
96 /* Jump to the identity-mapped low memory code */
97 #ifdef CONFIG_X86_32
98 asm volatile("jmpl *%0" : :
99 "rm" (real_mode_header->machine_real_restart_asm),
100 "a" (type));
53 /**
54 * emergency_restart - reboot the system
55 *
56 * Without shutting down any hardware or taking any locks
57 * reboot the system. This is called when we know we are in
58 * trouble so this is our best effort to reboot. This is
59 * safe to call in interrupt context.
60 */
61 void emergency_restart(void)
62 {
63 kmsg_dump(KMSG_DUMP_EMERG);
64 machine_emergency_restart();
65 }
66 EXPORT_SYMBOL_GPL(emergency_restart);
125 /**
126 * kernel_restart - reboot the system
130 * Shutdown everything and perform a clean reboot.
131 * This is not safe to call in interrupt context.
132 */
133 void kernel_restart(char *cmd)
134 {
135 kernel_restart_prepare(cmd);
...
143 machine_restart(cmd);
144 }
145 EXPORT_SYMBOL_GPL(kernel_restart);
我们可以看到,这个通用函数调用特定achine_restart做一切必要的行动来告诉我们重启硬件架构。在x86的它会做......是的,它会调用restart function pointer from machine_ops:
658 void machine_restart(char *cmd)
659 {
660 machine_ops.restart(cmd);
661 }
X86的restart points to的native_machine_restart再次呼吁__machine_emergency_restart,它将调用相同machine_real_restart。