Jesper Nilsson | f32bb79 | 2008-01-28 16:29:21 +0100 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * This file handles the architecture-dependent parts of process handling.. |
| 13 | */ |
| 14 | |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 15 | #include <linux/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/pgtable.h> |
| 17 | #include <asm/uaccess.h> |
| 18 | #include <asm/irq.h> |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/spinlock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Eric W. Biederman | 16dcb4b | 2005-07-26 11:32:34 -0600 | [diff] [blame] | 27 | #include <linux/reboot.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
| 29 | //#define DEBUG |
| 30 | |
| 31 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if |
| 33 | * there would ever be a halt sequence (for power save when idle) with |
| 34 | * some largish delay when halting or resuming *and* a driver that can't |
| 35 | * afford that delay. The hlt_counter would then be checked before |
| 36 | * executing the halt sequence, and the driver marks the unhaltable |
| 37 | * region by enable_hlt/disable_hlt. |
| 38 | */ |
| 39 | |
Mikael Starvik | 5d01e6c | 2005-07-27 11:44:43 -0700 | [diff] [blame] | 40 | int cris_hlt_counter=0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | void disable_hlt(void) |
| 43 | { |
Mikael Starvik | 5d01e6c | 2005-07-27 11:44:43 -0700 | [diff] [blame] | 44 | cris_hlt_counter++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | EXPORT_SYMBOL(disable_hlt); |
| 48 | |
| 49 | void enable_hlt(void) |
| 50 | { |
Mikael Starvik | 5d01e6c | 2005-07-27 11:44:43 -0700 | [diff] [blame] | 51 | cris_hlt_counter--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | EXPORT_SYMBOL(enable_hlt); |
| 55 | |
| 56 | /* |
| 57 | * The following aren't currently used. |
| 58 | */ |
| 59 | void (*pm_idle)(void); |
| 60 | |
Jesper Nilsson | 7b27552 | 2007-11-14 17:00:59 -0800 | [diff] [blame] | 61 | extern void default_idle(void); |
| 62 | |
| 63 | void (*pm_power_off)(void); |
| 64 | EXPORT_SYMBOL(pm_power_off); |
| 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | /* |
| 67 | * The idle thread. There's no useful work to be |
| 68 | * done, so just try to conserve power and have a |
| 69 | * low exit latency (ie sit in a loop waiting for |
| 70 | * somebody to say that they'd like to reschedule) |
| 71 | */ |
Jesper Nilsson | f32bb79 | 2008-01-28 16:29:21 +0100 | [diff] [blame] | 72 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | void cpu_idle (void) |
| 74 | { |
| 75 | /* endless idle loop with no priority at all */ |
| 76 | while (1) { |
| 77 | while (!need_resched()) { |
Mikael Starvik | 5d01e6c | 2005-07-27 11:44:43 -0700 | [diff] [blame] | 78 | void (*idle)(void); |
| 79 | /* |
| 80 | * Mark this as an RCU critical section so that |
| 81 | * synchronize_kernel() in the unload path waits |
| 82 | * for our completion. |
| 83 | */ |
| 84 | idle = pm_idle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | if (!idle) |
| 86 | idle = default_idle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | idle(); |
| 88 | } |
Thomas Gleixner | bd2f553 | 2011-03-21 12:33:18 +0100 | [diff] [blame] | 89 | schedule_preempt_disabled(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | void hard_reset_now (void); |
| 94 | |
Eric W. Biederman | 16dcb4b | 2005-07-26 11:32:34 -0600 | [diff] [blame] | 95 | void machine_restart(char *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | { |
| 97 | hard_reset_now(); |
| 98 | } |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | /* |
| 101 | * Similar to machine_power_off, but don't shut off power. Add code |
| 102 | * here to freeze the system for e.g. post-mortem debug purpose when |
| 103 | * possible. This halt has nothing to do with the idle halt. |
| 104 | */ |
| 105 | |
| 106 | void machine_halt(void) |
| 107 | { |
| 108 | } |
| 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | /* If or when software power-off is implemented, add code here. */ |
| 111 | |
| 112 | void machine_power_off(void) |
| 113 | { |
| 114 | } |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | /* |
| 117 | * When a process does an "exec", machine state like FPU and debug |
| 118 | * registers need to be reset. This is a hook function for that. |
| 119 | * Currently we don't have any such state to reset, so this is empty. |
| 120 | */ |
| 121 | |
| 122 | void flush_thread(void) |
| 123 | { |
| 124 | } |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | /* Fill in the fpu structure for a core dump. */ |
| 127 | int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) |
| 128 | { |
| 129 | return 0; |
| 130 | } |