process.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:17k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Architecture-specific setup.
  3.  *
  4.  * Copyright (C) 1998-2002 Hewlett-Packard Co
  5.  * David Mosberger-Tang <davidm@hpl.hp.com>
  6.  */
  7. #define __KERNEL_SYSCALLS__ /* see <asm/unistd.h> */
  8. #include <linux/config.h>
  9. #include <linux/pm.h>
  10. #include <linux/elf.h>
  11. #include <linux/errno.h>
  12. #include <linux/kernel.h>
  13. #include <linux/mm.h>
  14. #include <linux/personality.h>
  15. #include <linux/sched.h>
  16. #include <linux/slab.h>
  17. #include <linux/smp_lock.h>
  18. #include <linux/stddef.h>
  19. #include <linux/unistd.h>
  20. #include <linux/efi.h>
  21. #include <asm/delay.h>
  22. #include <asm/perfmon.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/processor.h>
  25. #include <asm/sal.h>
  26. #include <asm/uaccess.h>
  27. #include <asm/unwind.h>
  28. #include <asm/user.h>
  29. #ifdef CONFIG_IA64_SGI_SN
  30. #include <asm/sn/idle.h>
  31. #endif
  32. static void
  33. do_show_stack (struct unw_frame_info *info, void *arg)
  34. {
  35. unsigned long ip, sp, bsp;
  36. printk("nCall Trace: ");
  37. do {
  38. unw_get_ip(info, &ip);
  39. if (ip == 0)
  40. break;
  41. unw_get_sp(info, &sp);
  42. unw_get_bsp(info, &bsp);
  43. printk("[<%016lx>] sp=0x%016lx bsp=0x%016lxn", ip, sp, bsp);
  44. } while (unw_unwind(info) >= 0);
  45. }
  46. void
  47. show_trace_task (struct task_struct *task)
  48. {
  49. struct unw_frame_info info;
  50. unw_init_from_blocked_task(&info, task);
  51. do_show_stack(&info, 0);
  52. }
  53. void
  54. show_stack (struct task_struct *task)
  55. {
  56. if (!task)
  57. unw_init_running(do_show_stack, 0);
  58. else {
  59. struct unw_frame_info info;
  60. unw_init_from_blocked_task(&info, task);
  61. do_show_stack(&info, 0);
  62. }
  63. }
  64. void
  65. show_regs (struct pt_regs *regs)
  66. {
  67. unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
  68. printk("nPid: %d, comm: %20sn", current->pid, current->comm);
  69. printk("psr : %016lx ifs : %016lx ip  : [<%016lx>]    %sn",
  70.        regs->cr_ipsr, regs->cr_ifs, ip, print_tainted());
  71. printk("unat: %016lx pfs : %016lx rsc : %016lxn",
  72.        regs->ar_unat, regs->ar_pfs, regs->ar_rsc);
  73. printk("rnat: %016lx bsps: %016lx pr  : %016lxn",
  74.        regs->ar_rnat, regs->ar_bspstore, regs->pr);
  75. printk("ldrs: %016lx ccv : %016lx fpsr: %016lxn",
  76.        regs->loadrs, regs->ar_ccv, regs->ar_fpsr);
  77. printk("b0  : %016lx b6  : %016lx b7  : %016lxn", regs->b0, regs->b6, regs->b7);
  78. printk("f6  : %05lx%016lx f7  : %05lx%016lxn",
  79.        regs->f6.u.bits[1], regs->f6.u.bits[0],
  80.        regs->f7.u.bits[1], regs->f7.u.bits[0]);
  81. printk("f8  : %05lx%016lx f9  : %05lx%016lxn",
  82.        regs->f8.u.bits[1], regs->f8.u.bits[0],
  83.        regs->f9.u.bits[1], regs->f9.u.bits[0]);
  84. printk("r1  : %016lx r2  : %016lx r3  : %016lxn", regs->r1, regs->r2, regs->r3);
  85. printk("r8  : %016lx r9  : %016lx r10 : %016lxn", regs->r8, regs->r9, regs->r10);
  86. printk("r11 : %016lx r12 : %016lx r13 : %016lxn", regs->r11, regs->r12, regs->r13);
  87. printk("r14 : %016lx r15 : %016lx r16 : %016lxn", regs->r14, regs->r15, regs->r16);
  88. printk("r17 : %016lx r18 : %016lx r19 : %016lxn", regs->r17, regs->r18, regs->r19);
  89. printk("r20 : %016lx r21 : %016lx r22 : %016lxn", regs->r20, regs->r21, regs->r22);
  90. printk("r23 : %016lx r24 : %016lx r25 : %016lxn", regs->r23, regs->r24, regs->r25);
  91. printk("r26 : %016lx r27 : %016lx r28 : %016lxn", regs->r26, regs->r27, regs->r28);
  92. printk("r29 : %016lx r30 : %016lx r31 : %016lxn", regs->r29, regs->r30, regs->r31);
  93. if (user_mode(regs)) {
  94. /* print the stacked registers */
  95. unsigned long val, sof, *bsp, ndirty;
  96. int i, is_nat = 0;
  97. sof = regs->cr_ifs & 0x7f; /* size of frame */
  98. ndirty = (regs->loadrs >> 19);
  99. bsp = ia64_rse_skip_regs((unsigned long *) regs->ar_bspstore, ndirty);
  100. for (i = 0; i < sof; ++i) {
  101. get_user(val, ia64_rse_skip_regs(bsp, i));
  102. printk("r%-3u:%c%016lx%s", 32 + i, is_nat ? '*' : ' ', val,
  103.        ((i == sof - 1) || (i % 3) == 2) ? "n" : " ");
  104. }
  105. }
  106. if (!user_mode(regs))
  107. show_stack(0);
  108. }
  109. void __attribute__((noreturn))
  110. cpu_idle (void *unused)
  111. {
  112. /* endless idle loop with no priority at all */
  113. init_idle();
  114. current->nice = 20;
  115. current->counter = -100;
  116. while (1) {
  117. #ifdef CONFIG_SMP
  118. if (!current->need_resched)
  119. min_xtp();
  120. #endif
  121. while (!current->need_resched) {
  122. #ifdef CONFIG_IA64_SGI_SN
  123. snidle();
  124. #endif
  125. continue;
  126. }
  127. #ifdef CONFIG_IA64_SGI_SN
  128. snidleoff();
  129. #endif
  130. #ifdef CONFIG_SMP
  131. normal_xtp();
  132. #endif
  133. schedule();
  134. check_pgt_cache();
  135. if (pm_idle)
  136. (*pm_idle)();
  137. }
  138. }
  139. void
  140. ia64_save_extra (struct task_struct *task)
  141. {
  142. if ((task->thread.flags & IA64_THREAD_DBG_VALID) != 0)
  143. ia64_save_debug_regs(&task->thread.dbr[0]);
  144. #ifdef CONFIG_PERFMON
  145. if ((task->thread.flags & IA64_THREAD_PM_VALID) != 0)
  146. pfm_save_regs(task);
  147. # ifdef CONFIG_SMP
  148. if (local_cpu_data->pfm_syst_wide)
  149. pfm_syst_wide_update_task(task, 0);
  150. # endif
  151. #endif
  152. #ifdef CONFIG_IA32_SUPPORT
  153. if (IS_IA32_PROCESS(ia64_task_regs(task)))
  154. ia32_save_state(task);
  155. #endif
  156. }
  157. void
  158. ia64_load_extra (struct task_struct *task)
  159. {
  160. if ((task->thread.flags & IA64_THREAD_DBG_VALID) != 0)
  161. ia64_load_debug_regs(&task->thread.dbr[0]);
  162. #ifdef CONFIG_PERFMON
  163. if ((task->thread.flags & IA64_THREAD_PM_VALID) != 0)
  164. pfm_load_regs(task);
  165. # ifdef CONFIG_SMP
  166. if (local_cpu_data->pfm_syst_wide)
  167. pfm_syst_wide_update_task(task, 1);
  168. # endif
  169. #endif
  170. #ifdef CONFIG_IA32_SUPPORT
  171. if (IS_IA32_PROCESS(ia64_task_regs(task)))
  172. ia32_load_state(task);
  173. #endif
  174. }
  175. /*
  176.  * Copy the state of an ia-64 thread.
  177.  *
  178.  * We get here through the following  call chain:
  179.  *
  180.  * <clone syscall>
  181.  * sys_clone
  182.  * do_fork
  183.  * copy_thread
  184.  *
  185.  * This means that the stack layout is as follows:
  186.  *
  187.  * +---------------------+ (highest addr)
  188.  * |   struct pt_regs    |
  189.  * +---------------------+
  190.  * | struct switch_stack |
  191.  * +---------------------+
  192.  * |                     |
  193.  * |    memory stack     |
  194.  * |                     | <-- sp (lowest addr)
  195.  * +---------------------+
  196.  *
  197.  * Note: if we get called through kernel_thread() then the memory
  198.  * above "(highest addr)" is valid kernel stack memory that needs to
  199.  * be copied as well.
  200.  *
  201.  * Observe that we copy the unat values that are in pt_regs and
  202.  * switch_stack.  Spilling an integer to address X causes bit N in
  203.  * ar.unat to be set to the NaT bit of the register, with N=(X &
  204.  * 0x1ff)/8.  Thus, copying the unat value preserves the NaT bits ONLY
  205.  * if the pt_regs structure in the parent is congruent to that of the
  206.  * child, modulo 512.  Since the stack is page aligned and the page
  207.  * size is at least 4KB, this is always the case, so there is nothing
  208.  * to worry about.
  209.  */
  210. int
  211. copy_thread (int nr, unsigned long clone_flags,
  212.      unsigned long user_stack_base, unsigned long user_stack_size,
  213.      struct task_struct *p, struct pt_regs *regs)
  214. {
  215. unsigned long rbs, child_rbs, rbs_size, stack_offset, stack_top, stack_used;
  216. struct switch_stack *child_stack, *stack;
  217. extern char ia64_ret_from_clone, ia32_ret_from_clone;
  218. struct pt_regs *child_ptregs;
  219. int retval = 0;
  220. #ifdef CONFIG_SMP
  221. /*
  222.  * For SMP idle threads, fork_by_hand() calls do_fork with
  223.  * NULL regs.
  224.  */
  225. if (!regs)
  226. return 0;
  227. #endif
  228. stack_top = (unsigned long) current + IA64_STK_OFFSET;
  229. stack = ((struct switch_stack *) regs) - 1;
  230. stack_used = stack_top - (unsigned long) stack;
  231. stack_offset = IA64_STK_OFFSET - stack_used;
  232. child_stack = (struct switch_stack *) ((unsigned long) p + stack_offset);
  233. child_ptregs = (struct pt_regs *) (child_stack + 1);
  234. /* copy parent's switch_stack & pt_regs to child: */
  235. memcpy(child_stack, stack, stack_used);
  236. rbs = (unsigned long) current + IA64_RBS_OFFSET;
  237. child_rbs = (unsigned long) p + IA64_RBS_OFFSET;
  238. rbs_size = stack->ar_bspstore - rbs;
  239. /* copy the parent's register backing store to the child: */
  240. memcpy((void *) child_rbs, (void *) rbs, rbs_size);
  241. if (user_mode(child_ptregs)) {
  242. if (user_stack_base) {
  243. child_ptregs->r12 = user_stack_base + user_stack_size - 16;
  244. child_ptregs->ar_bspstore = user_stack_base;
  245. child_ptregs->ar_rnat = 0;
  246. child_ptregs->loadrs = 0;
  247. }
  248. } else {
  249. /*
  250.  * Note: we simply preserve the relative position of
  251.  * the stack pointer here.  There is no need to
  252.  * allocate a scratch area here, since that will have
  253.  * been taken care of by the caller of sys_clone()
  254.  * already.
  255.  */
  256. child_ptregs->r12 = (unsigned long) (child_ptregs + 1); /* kernel sp */
  257. child_ptregs->r13 = (unsigned long) p; /* set `current' pointer */
  258. }
  259. if (IS_IA32_PROCESS(regs))
  260. child_stack->b0 = (unsigned long) &ia32_ret_from_clone;
  261. else
  262. child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
  263. child_stack->ar_bspstore = child_rbs + rbs_size;
  264. /* copy parts of thread_struct: */
  265. p->thread.ksp = (unsigned long) child_stack - 16;
  266. /* stop some PSR bits from being inherited: */
  267. child_ptregs->cr_ipsr =  ((child_ptregs->cr_ipsr | IA64_PSR_BITS_TO_SET)
  268.   & ~IA64_PSR_BITS_TO_CLEAR);
  269. /*
  270.  * NOTE: The calling convention considers all floating point registers in the high
  271.  * partition (fph) to be scratch.  Since the only way to get to this point is
  272.  * through a system call, we know that the values in fph are all dead.  Hence,
  273.  * there is no need to inherit the fph state from the parent to the child and all
  274.  * we have to do is to make sure that IA64_THREAD_FPH_VALID is cleared in the
  275.  * child.
  276.  *
  277.  * XXX We could push this optimization a bit further by clearing
  278.  * IA64_THREAD_FPH_VALID on ANY system call.  However, it's not clear this is
  279.  * worth doing.  Also, it would be a slight deviation from the normal Linux system
  280.  * call behavior where scratch registers are preserved across system calls (unless
  281.  * used by the system call itself).
  282.  */
  283. # define THREAD_FLAGS_TO_CLEAR (IA64_THREAD_FPH_VALID | IA64_THREAD_DBG_VALID 
  284.  | IA64_THREAD_PM_VALID)
  285. # define THREAD_FLAGS_TO_SET 0
  286. p->thread.flags = ((current->thread.flags & ~THREAD_FLAGS_TO_CLEAR)
  287.    | THREAD_FLAGS_TO_SET);
  288. #ifdef CONFIG_IA32_SUPPORT
  289. /*
  290.  * If we're cloning an IA32 task then save the IA32 extra
  291.  * state from the current task to the new task
  292.  */
  293. if (IS_IA32_PROCESS(ia64_task_regs(current)))
  294. ia32_save_state(p);
  295. #endif
  296. #ifdef CONFIG_PERFMON
  297. /*
  298.  * reset notifiers and owner check (may not have a perfmon context)
  299.  */
  300. atomic_set(&p->thread.pfm_notifiers_check, 0);
  301. atomic_set(&p->thread.pfm_owners_check, 0);
  302. /* clear list of sampling buffer to free for new task */
  303. p->thread.pfm_smpl_buf_list = NULL;
  304. if (current->thread.pfm_context)
  305. retval = pfm_inherit(p, child_ptregs);
  306. #endif
  307. return retval;
  308. }
  309. void
  310. do_copy_regs (struct unw_frame_info *info, void *arg)
  311. {
  312. unsigned long mask, sp, nat_bits = 0, ip, ar_rnat, urbs_end, cfm;
  313. elf_greg_t *dst = arg;
  314. struct pt_regs *pt;
  315. char nat;
  316. int i;
  317. memset(dst, 0, sizeof(elf_gregset_t)); /* don't leak any kernel bits to user-level */
  318. if (unw_unwind_to_user(info) < 0)
  319. return;
  320. unw_get_sp(info, &sp);
  321. pt = (struct pt_regs *) (sp + 16);
  322. urbs_end = ia64_get_user_rbs_end(current, pt, &cfm);
  323. if (ia64_sync_user_rbs(current, info->sw, pt->ar_bspstore, urbs_end) < 0)
  324. return;
  325. ia64_peek(current, info->sw, urbs_end, (long) ia64_rse_rnat_addr((long *) urbs_end),
  326.   &ar_rnat);
  327. /*
  328.  * coredump format:
  329.  * r0-r31
  330.  * NaT bits (for r0-r31; bit N == 1 iff rN is a NaT)
  331.  * predicate registers (p0-p63)
  332.  * b0-b7
  333.  * ip cfm user-mask
  334.  * ar.rsc ar.bsp ar.bspstore ar.rnat
  335.  * ar.ccv ar.unat ar.fpsr ar.pfs ar.lc ar.ec
  336.  */
  337. /* r0 is zero */
  338. for (i = 1, mask = (1UL << i); i < 32; ++i) {
  339. unw_get_gr(info, i, &dst[i], &nat);
  340. if (nat)
  341. nat_bits |= mask;
  342. mask <<= 1;
  343. }
  344. dst[32] = nat_bits;
  345. unw_get_pr(info, &dst[33]);
  346. for (i = 0; i < 8; ++i)
  347. unw_get_br(info, i, &dst[34 + i]);
  348. unw_get_rp(info, &ip);
  349. dst[42] = ip + ia64_psr(pt)->ri;
  350. dst[43] = cfm;
  351. dst[44] = pt->cr_ipsr & IA64_PSR_UM;
  352. unw_get_ar(info, UNW_AR_RSC, &dst[45]);
  353. /*
  354.  * For bsp and bspstore, unw_get_ar() would return the kernel
  355.  * addresses, but we need the user-level addresses instead:
  356.  */
  357. dst[46] = urbs_end; /* note: by convention PT_AR_BSP points to the end of the urbs! */
  358. dst[47] = pt->ar_bspstore;
  359. dst[48] = ar_rnat;
  360. unw_get_ar(info, UNW_AR_CCV, &dst[49]);
  361. unw_get_ar(info, UNW_AR_UNAT, &dst[50]);
  362. unw_get_ar(info, UNW_AR_FPSR, &dst[51]);
  363. dst[52] = pt->ar_pfs; /* UNW_AR_PFS is == to pt->cr_ifs for interrupt frames */
  364. unw_get_ar(info, UNW_AR_LC, &dst[53]);
  365. unw_get_ar(info, UNW_AR_EC, &dst[54]);
  366. }
  367. void
  368. do_dump_fpu (struct unw_frame_info *info, void *arg)
  369. {
  370. elf_fpreg_t *dst = arg;
  371. int i;
  372. memset(dst, 0, sizeof(elf_fpregset_t)); /* don't leak any "random" bits */
  373. if (unw_unwind_to_user(info) < 0)
  374. return;
  375. /* f0 is 0.0, f1 is 1.0 */
  376. for (i = 2; i < 32; ++i)
  377. unw_get_fr(info, i, dst + i);
  378. ia64_flush_fph(current);
  379. if ((current->thread.flags & IA64_THREAD_FPH_VALID) != 0)
  380. memcpy(dst + 32, current->thread.fph, 96*16);
  381. }
  382. void
  383. ia64_elf_core_copy_regs (struct pt_regs *pt, elf_gregset_t dst)
  384. {
  385. unw_init_running(do_copy_regs, dst);
  386. }
  387. int
  388. dump_fpu (struct pt_regs *pt, elf_fpregset_t dst)
  389. {
  390. unw_init_running(do_dump_fpu, dst);
  391. return 1; /* f0-f31 are always valid so we always return 1 */
  392. }
  393. asmlinkage long
  394. sys_execve (char *filename, char **argv, char **envp, struct pt_regs *regs)
  395. {
  396. int error;
  397. filename = getname(filename);
  398. error = PTR_ERR(filename);
  399. if (IS_ERR(filename))
  400. goto out;
  401. error = do_execve(filename, argv, envp, regs);
  402. putname(filename);
  403. out:
  404. return error;
  405. }
  406. void
  407. ia64_set_personality (struct elf64_hdr *elf_ex, int ibcs2_interpreter)
  408. {
  409. set_personality(PER_LINUX);
  410. if (elf_ex->e_flags & EF_IA_64_LINUX_EXECUTABLE_STACK)
  411. current->thread.flags |= IA64_THREAD_XSTACK;
  412. else
  413. current->thread.flags &= ~IA64_THREAD_XSTACK;
  414. }
  415. pid_t
  416. kernel_thread (int (*fn)(void *), void *arg, unsigned long flags)
  417. {
  418. struct task_struct *parent = current;
  419. int result, tid;
  420. tid = clone(flags | CLONE_VM, 0);
  421. if (parent != current) {
  422. result = (*fn)(arg);
  423. _exit(result);
  424. }
  425. return tid;
  426. }
  427. /*
  428.  * Flush thread state.  This is called when a thread does an execve().
  429.  */
  430. void
  431. flush_thread (void)
  432. {
  433. /* drop floating-point and debug-register state if it exists: */
  434. current->thread.flags &= ~(IA64_THREAD_FPH_VALID | IA64_THREAD_DBG_VALID);
  435. #ifndef CONFIG_SMP
  436. if (ia64_get_fpu_owner() == current)
  437. ia64_set_fpu_owner(0);
  438. #endif
  439. }
  440. #ifdef CONFIG_PERFMON
  441. /*
  442.  * by the time we get here, the task is detached from the tasklist. This is important
  443.  * because it means that no other tasks can ever find it as a notified task, therfore there
  444.  * is no race condition between this code and let's say a pfm_context_create().
  445.  * Conversely, the pfm_cleanup_notifiers() cannot try to access a task's pfm context if this
  446.  * other task is in the middle of its own pfm_context_exit() because it would already be out of
  447.  * the task list. Note that this case is very unlikely between a direct child and its parents
  448.  * (if it is the notified process) because of the way the exit is notified via SIGCHLD.
  449.  */
  450. void
  451. release_thread (struct task_struct *task)
  452. {
  453. if (task->thread.pfm_context)
  454. pfm_context_exit(task);
  455. if (atomic_read(&task->thread.pfm_notifiers_check) > 0)
  456. pfm_cleanup_notifiers(task);
  457. if (atomic_read(&task->thread.pfm_owners_check) > 0)
  458. pfm_cleanup_owners(task);
  459. if (task->thread.pfm_smpl_buf_list)
  460. pfm_cleanup_smpl_buf(task);
  461. }
  462. #endif
  463. /*
  464.  * Clean up state associated with current thread.  This is called when
  465.  * the thread calls exit().
  466.  */
  467. void
  468. exit_thread (void)
  469. {
  470. #ifndef CONFIG_SMP
  471. if (ia64_get_fpu_owner() == current)
  472. ia64_set_fpu_owner(0);
  473. #endif
  474. #ifdef CONFIG_PERFMON
  475.        /* stop monitoring */
  476. if (current->thread.pfm_context)
  477. pfm_flush_regs(current);
  478. /* free debug register resources */
  479. if (current->thread.flags & IA64_THREAD_DBG_VALID)
  480. pfm_release_debug_registers(current);
  481. #endif
  482. }
  483. unsigned long
  484. get_wchan (struct task_struct *p)
  485. {
  486. struct unw_frame_info info;
  487. unsigned long ip;
  488. int count = 0;
  489. /*
  490.  * These bracket the sleeping functions..
  491.  */
  492. extern void scheduling_functions_start_here(void);
  493. extern void scheduling_functions_end_here(void);
  494. # define first_sched ((unsigned long) scheduling_functions_start_here)
  495. # define last_sched ((unsigned long) scheduling_functions_end_here)
  496. /*
  497.  * Note: p may not be a blocked task (it could be current or
  498.  * another process running on some other CPU.  Rather than
  499.  * trying to determine if p is really blocked, we just assume
  500.  * it's blocked and rely on the unwind routines to fail
  501.  * gracefully if the process wasn't really blocked after all.
  502.  * --davidm 99/12/15
  503.  */
  504. unw_init_from_blocked_task(&info, p);
  505. do {
  506. if (unw_unwind(&info) < 0)
  507. return 0;
  508. unw_get_ip(&info, &ip);
  509. if (ip < first_sched || ip >= last_sched)
  510. return ip;
  511. } while (count++ < 16);
  512. return 0;
  513. # undef first_sched
  514. # undef last_sched
  515. }
  516. void
  517. cpu_halt (void)
  518. {
  519. pal_power_mgmt_info_u_t power_info[8];
  520. unsigned long min_power;
  521. int i, min_power_state;
  522. if (ia64_pal_halt_info(power_info) != 0)
  523. return;
  524. min_power_state = 0;
  525. min_power = power_info[0].pal_power_mgmt_info_s.power_consumption;
  526. for (i = 1; i < 8; ++i)
  527. if (power_info[i].pal_power_mgmt_info_s.im
  528.     && power_info[i].pal_power_mgmt_info_s.power_consumption < min_power) {
  529. min_power = power_info[i].pal_power_mgmt_info_s.power_consumption;
  530. min_power_state = i;
  531. }
  532. while (1)
  533. ia64_pal_halt(min_power_state);
  534. }
  535. void
  536. machine_restart (char *restart_cmd)
  537. {
  538. (*efi.reset_system)(EFI_RESET_WARM, 0, 0, 0);
  539. }
  540. void
  541. machine_halt (void)
  542. {
  543. cpu_halt();
  544. }
  545. void
  546. machine_power_off (void)
  547. {
  548. if (pm_power_off)
  549. pm_power_off();
  550. machine_halt();
  551. }