|
Lines 361-377
Link Here
|
| 361 |
return retval; |
361 |
return retval; |
| 362 |
} |
362 |
} |
| 363 |
|
363 |
|
|
|
364 |
/** |
| 365 |
* emergency_restart - reboot the system |
| 366 |
* |
| 367 |
* Without shutting down any hardware or taking any locks |
| 368 |
* reboot the system. This is called when we know we are in |
| 369 |
* trouble so this is our best effort to reboot. This is |
| 370 |
* safe to call in interrupt context. |
| 371 |
*/ |
| 372 |
|
| 364 |
void emergency_restart(void) |
373 |
void emergency_restart(void) |
| 365 |
{ |
374 |
{ |
| 366 |
machine_emergency_restart(); |
375 |
machine_emergency_restart(); |
| 367 |
} |
376 |
} |
| 368 |
EXPORT_SYMBOL_GPL(emergency_restart); |
377 |
EXPORT_SYMBOL_GPL(emergency_restart); |
| 369 |
|
378 |
|
| 370 |
void kernel_restart(char *cmd) |
379 |
/** |
|
|
380 |
* kernel_restart - reboot the system |
| 381 |
* |
| 382 |
* Shutdown everything and perform a clean reboot. |
| 383 |
* This is not safe to call in interrupt context. |
| 384 |
*/ |
| 385 |
void kernel_restart_prepare(char *cmd) |
| 371 |
{ |
386 |
{ |
| 372 |
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd); |
387 |
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd); |
| 373 |
system_state = SYSTEM_RESTART; |
388 |
system_state = SYSTEM_RESTART; |
| 374 |
device_shutdown(); |
389 |
device_shutdown(); |
|
|
390 |
} |
| 391 |
void kernel_restart(char *cmd) |
| 392 |
{ |
| 393 |
kernel_restart_prepare(cmd); |
| 375 |
if (!cmd) { |
394 |
if (!cmd) { |
| 376 |
printk(KERN_EMERG "Restarting system.\n"); |
395 |
printk(KERN_EMERG "Restarting system.\n"); |
| 377 |
} else { |
396 |
} else { |
|
Lines 382-387
Link Here
|
| 382 |
} |
401 |
} |
| 383 |
EXPORT_SYMBOL_GPL(kernel_restart); |
402 |
EXPORT_SYMBOL_GPL(kernel_restart); |
| 384 |
|
403 |
|
|
|
404 |
/** |
| 405 |
* kernel_kexec - reboot the system |
| 406 |
* |
| 407 |
* Move into place and start executing a preloaded standalone |
| 408 |
* executable. If nothing was preloaded return an error. |
| 409 |
*/ |
| 385 |
void kernel_kexec(void) |
410 |
void kernel_kexec(void) |
| 386 |
{ |
411 |
{ |
| 387 |
#ifdef CONFIG_KEXEC |
412 |
#ifdef CONFIG_KEXEC |
|
Lines 390-398
Link Here
|
| 390 |
if (!image) { |
415 |
if (!image) { |
| 391 |
return; |
416 |
return; |
| 392 |
} |
417 |
} |
| 393 |
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); |
418 |
kernel_restart_prepare(NULL); |
| 394 |
system_state = SYSTEM_RESTART; |
|
|
| 395 |
device_shutdown(); |
| 396 |
printk(KERN_EMERG "Starting new kernel\n"); |
419 |
printk(KERN_EMERG "Starting new kernel\n"); |
| 397 |
machine_shutdown(); |
420 |
machine_shutdown(); |
| 398 |
machine_kexec(image); |
421 |
machine_kexec(image); |
|
Lines 400-420
Link Here
|
| 400 |
} |
423 |
} |
| 401 |
EXPORT_SYMBOL_GPL(kernel_kexec); |
424 |
EXPORT_SYMBOL_GPL(kernel_kexec); |
| 402 |
|
425 |
|
| 403 |
void kernel_halt(void) |
426 |
/** |
|
|
427 |
* kernel_halt - halt the system |
| 428 |
* |
| 429 |
* Shutdown everything and perform a clean system halt. |
| 430 |
*/ |
| 431 |
void kernel_halt_prepare(void) |
| 404 |
{ |
432 |
{ |
| 405 |
notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); |
433 |
notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); |
| 406 |
system_state = SYSTEM_HALT; |
434 |
system_state = SYSTEM_HALT; |
| 407 |
device_shutdown(); |
435 |
device_shutdown(); |
|
|
436 |
} |
| 437 |
void kernel_halt(void) |
| 438 |
{ |
| 439 |
kernel_halt_prepare(); |
| 408 |
printk(KERN_EMERG "System halted.\n"); |
440 |
printk(KERN_EMERG "System halted.\n"); |
| 409 |
machine_halt(); |
441 |
machine_halt(); |
| 410 |
} |
442 |
} |
| 411 |
EXPORT_SYMBOL_GPL(kernel_halt); |
443 |
EXPORT_SYMBOL_GPL(kernel_halt); |
| 412 |
|
444 |
|
| 413 |
void kernel_power_off(void) |
445 |
/** |
|
|
446 |
* kernel_power_off - power_off the system |
| 447 |
* |
| 448 |
* Shutdown everything and perform a clean system power_off. |
| 449 |
*/ |
| 450 |
void kernel_power_off_prepare(void) |
| 414 |
{ |
451 |
{ |
| 415 |
notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); |
452 |
notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); |
| 416 |
system_state = SYSTEM_POWER_OFF; |
453 |
system_state = SYSTEM_POWER_OFF; |
| 417 |
device_shutdown(); |
454 |
device_shutdown(); |
|
|
455 |
} |
| 456 |
void kernel_power_off(void) |
| 457 |
{ |
| 458 |
kernel_power_off_prepare(); |
| 418 |
printk(KERN_EMERG "Power down.\n"); |
459 |
printk(KERN_EMERG "Power down.\n"); |
| 419 |
machine_power_off(); |
460 |
machine_power_off(); |
| 420 |
} |
461 |
} |