process.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * linux/arch/cris/kernel/process.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. * Copyright (C) 2000-2002 Axis Communications AB
  6. *
  7. * Authors: Bjorn Wesen (bjornw@axis.com)
  8. *
  9. */
  10. /*
  11. * This file handles the architecture-dependent parts of process handling..
  12. */
  13. #include <asm/atomic.h>
  14. #include <asm/pgtable.h>
  15. #include <asm/uaccess.h>
  16. #include <asm/irq.h>
  17. #include <asm/system.h>
  18. #include <linux/module.h>
  19. #include <linux/spinlock.h>
  20. #include <linux/fs_struct.h>
  21. #include <linux/init_task.h>
  22. #include <linux/sched.h>
  23. #include <linux/fs.h>
  24. #include <linux/user.h>
  25. #include <linux/elfcore.h>
  26. #include <linux/mqueue.h>
  27. #include <linux/reboot.h>
  28. //#define DEBUG
  29. /*
  30. * Initial task structure. Make this a per-architecture thing,
  31. * because different architectures tend to have different
  32. * alignment requirements and potentially different initial
  33. * setup.
  34. */
  35. static struct fs_struct init_fs = INIT_FS;
  36. static struct files_struct init_files = INIT_FILES;
  37. static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
  38. static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
  39. struct mm_struct init_mm = INIT_MM(init_mm);
  40. EXPORT_SYMBOL(init_mm);
  41. /*
  42. * Initial thread structure.
  43. *
  44. * We need to make sure that this is 8192-byte aligned due to the
  45. * way process stacks are handled. This is done by having a special
  46. * "init_task" linker map entry..
  47. */
  48. union thread_union init_thread_union
  49. __attribute__((__section__(".data.init_task"))) =
  50. { INIT_THREAD_INFO(init_task) };
  51. /*
  52. * Initial task structure.
  53. *
  54. * All other task structs will be allocated on slabs in fork.c
  55. */
  56. struct task_struct init_task = INIT_TASK(init_task);
  57. EXPORT_SYMBOL(init_task);
  58. /*
  59. * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if
  60. * there would ever be a halt sequence (for power save when idle) with
  61. * some largish delay when halting or resuming *and* a driver that can't
  62. * afford that delay. The hlt_counter would then be checked before
  63. * executing the halt sequence, and the driver marks the unhaltable
  64. * region by enable_hlt/disable_hlt.
  65. */
  66. int cris_hlt_counter=0;
  67. void disable_hlt(void)
  68. {
  69. cris_hlt_counter++;
  70. }
  71. EXPORT_SYMBOL(disable_hlt);
  72. void enable_hlt(void)
  73. {
  74. cris_hlt_counter--;
  75. }
  76. EXPORT_SYMBOL(enable_hlt);
  77. /*
  78. * The following aren't currently used.
  79. */
  80. void (*pm_idle)(void);
  81. extern void default_idle(void);
  82. void (*pm_power_off)(void);
  83. EXPORT_SYMBOL(pm_power_off);
  84. /*
  85. * The idle thread. There's no useful work to be
  86. * done, so just try to conserve power and have a
  87. * low exit latency (ie sit in a loop waiting for
  88. * somebody to say that they'd like to reschedule)
  89. */
  90. void cpu_idle (void)
  91. {
  92. /* endless idle loop with no priority at all */
  93. while (1) {
  94. while (!need_resched()) {
  95. void (*idle)(void);
  96. /*
  97. * Mark this as an RCU critical section so that
  98. * synchronize_kernel() in the unload path waits
  99. * for our completion.
  100. */
  101. idle = pm_idle;
  102. if (!idle)
  103. idle = default_idle;
  104. idle();
  105. }
  106. preempt_enable_no_resched();
  107. schedule();
  108. preempt_disable();
  109. }
  110. }
  111. void hard_reset_now (void);
  112. void machine_restart(char *cmd)
  113. {
  114. hard_reset_now();
  115. }
  116. /*
  117. * Similar to machine_power_off, but don't shut off power. Add code
  118. * here to freeze the system for e.g. post-mortem debug purpose when
  119. * possible. This halt has nothing to do with the idle halt.
  120. */
  121. void machine_halt(void)
  122. {
  123. }
  124. /* If or when software power-off is implemented, add code here. */
  125. void machine_power_off(void)
  126. {
  127. }
  128. /*
  129. * When a process does an "exec", machine state like FPU and debug
  130. * registers need to be reset. This is a hook function for that.
  131. * Currently we don't have any such state to reset, so this is empty.
  132. */
  133. void flush_thread(void)
  134. {
  135. }
  136. /* Fill in the fpu structure for a core dump. */
  137. int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
  138. {
  139. return 0;
  140. }