process.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * linux/arch/h8300/kernel/process.c
  3. *
  4. * Yoshinori Sato <ysato@users.sourceforge.jp>
  5. *
  6. * Based on:
  7. *
  8. * linux/arch/m68knommu/kernel/process.c
  9. *
  10. * Copyright (C) 1998 D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
  11. * Kenneth Albanowski <kjahds@kjahds.com>,
  12. * The Silver Hammer Group, Ltd.
  13. *
  14. * linux/arch/m68k/kernel/process.c
  15. *
  16. * Copyright (C) 1995 Hamish Macdonald
  17. *
  18. * 68060 fixes by Jesper Skov
  19. */
  20. /*
  21. * This file handles the architecture-dependent parts of process handling..
  22. */
  23. #include <linux/errno.h>
  24. #include <linux/module.h>
  25. #include <linux/sched.h>
  26. #include <linux/kernel.h>
  27. #include <linux/mm.h>
  28. #include <linux/smp.h>
  29. #include <linux/stddef.h>
  30. #include <linux/unistd.h>
  31. #include <linux/ptrace.h>
  32. #include <linux/user.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/reboot.h>
  35. #include <linux/fs.h>
  36. #include <linux/slab.h>
  37. #include <linux/rcupdate.h>
  38. #include <asm/uaccess.h>
  39. #include <asm/traps.h>
  40. #include <asm/setup.h>
  41. #include <asm/pgtable.h>
  42. void (*pm_power_off)(void) = NULL;
  43. EXPORT_SYMBOL(pm_power_off);
  44. asmlinkage void ret_from_fork(void);
  45. asmlinkage void ret_from_kernel_thread(void);
  46. /*
  47. * The idle loop on an H8/300..
  48. */
  49. #if !defined(CONFIG_H8300H_SIM) && !defined(CONFIG_H8S_SIM)
  50. void arch_cpu_idle(void)
  51. {
  52. local_irq_enable();
  53. /* XXX: race here! What if need_resched() gets set now? */
  54. __asm__("sleep");
  55. }
  56. #endif
  57. void machine_restart(char * __unused)
  58. {
  59. local_irq_disable();
  60. __asm__("jmp @@0");
  61. }
  62. void machine_halt(void)
  63. {
  64. local_irq_disable();
  65. __asm__("sleep");
  66. for (;;);
  67. }
  68. void machine_power_off(void)
  69. {
  70. local_irq_disable();
  71. __asm__("sleep");
  72. for (;;);
  73. }
  74. void show_regs(struct pt_regs * regs)
  75. {
  76. show_regs_print_info(KERN_DEFAULT);
  77. printk("\nPC: %08lx Status: %02x",
  78. regs->pc, regs->ccr);
  79. printk("\nORIG_ER0: %08lx ER0: %08lx ER1: %08lx",
  80. regs->orig_er0, regs->er0, regs->er1);
  81. printk("\nER2: %08lx ER3: %08lx ER4: %08lx ER5: %08lx",
  82. regs->er2, regs->er3, regs->er4, regs->er5);
  83. printk("\nER6' %08lx ",regs->er6);
  84. if (user_mode(regs))
  85. printk("USP: %08lx\n", rdusp());
  86. else
  87. printk("\n");
  88. }
  89. void flush_thread(void)
  90. {
  91. }
  92. int copy_thread(unsigned long clone_flags,
  93. unsigned long usp, unsigned long topstk,
  94. struct task_struct * p)
  95. {
  96. struct pt_regs * childregs;
  97. childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;
  98. if (unlikely(p->flags & PF_KTHREAD)) {
  99. memset(childregs, 0, sizeof(struct pt_regs));
  100. childregs->retpc = (unsigned long) ret_from_kernel_thread;
  101. childregs->er4 = topstk; /* arg */
  102. childregs->er5 = usp; /* fn */
  103. p->thread.ksp = (unsigned long)childregs;
  104. }
  105. *childregs = *current_pt_regs();
  106. childregs->retpc = (unsigned long) ret_from_fork;
  107. childregs->er0 = 0;
  108. p->thread.usp = usp ?: rdusp();
  109. p->thread.ksp = (unsigned long)childregs;
  110. return 0;
  111. }
  112. unsigned long thread_saved_pc(struct task_struct *tsk)
  113. {
  114. return ((struct pt_regs *)tsk->thread.esp0)->pc;
  115. }
  116. unsigned long get_wchan(struct task_struct *p)
  117. {
  118. unsigned long fp, pc;
  119. unsigned long stack_page;
  120. int count = 0;
  121. if (!p || p == current || p->state == TASK_RUNNING)
  122. return 0;
  123. stack_page = (unsigned long)p;
  124. fp = ((struct pt_regs *)p->thread.ksp)->er6;
  125. do {
  126. if (fp < stack_page+sizeof(struct thread_info) ||
  127. fp >= 8184+stack_page)
  128. return 0;
  129. pc = ((unsigned long *)fp)[1];
  130. if (!in_sched_functions(pc))
  131. return pc;
  132. fp = *(unsigned long *) fp;
  133. } while (count++ < 16);
  134. return 0;
  135. }