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 | |
| 15 | #include <asm/atomic.h> |
| 16 | #include <asm/pgtable.h> |
| 17 | #include <asm/uaccess.h> |
| 18 | #include <asm/irq.h> |
Adrian Bunk | cdb0452 | 2006-03-24 03:15:57 -0800 | [diff] [blame] | 19 | #include <asm/system.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/module.h> |
| 21 | #include <linux/spinlock.h> |
| 22 | #include <linux/fs_struct.h> |
| 23 | #include <linux/init_task.h> |
| 24 | #include <linux/sched.h> |
| 25 | #include <linux/fs.h> |
| 26 | #include <linux/user.h> |
| 27 | #include <linux/elfcore.h> |
| 28 | #include <linux/mqueue.h> |
Eric W. Biederman | 16dcb4b | 2005-07-26 11:32:34 -0600 | [diff] [blame] | 29 | #include <linux/reboot.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | //#define DEBUG |
| 32 | |
| 33 | /* |
| 34 | * Initial task structure. Make this a per-architecture thing, |
| 35 | * because different architectures tend to have different |
| 36 | * alignment requirements and potentially different initial |
| 37 | * setup. |
| 38 | */ |
| 39 | |
| 40 | static struct fs_struct init_fs = INIT_FS; |
| 41 | static struct files_struct init_files = INIT_FILES; |
| 42 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
| 43 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
| 44 | struct mm_struct init_mm = INIT_MM(init_mm); |
| 45 | |
| 46 | EXPORT_SYMBOL(init_mm); |
| 47 | |
| 48 | /* |
| 49 | * Initial thread structure. |
| 50 | * |
| 51 | * We need to make sure that this is 8192-byte aligned due to the |
| 52 | * way process stacks are handled. This is done by having a special |
| 53 | * "init_task" linker map entry.. |
| 54 | */ |
| 55 | union thread_union init_thread_union |
| 56 | __attribute__((__section__(".data.init_task"))) = |
| 57 | { INIT_THREAD_INFO(init_task) }; |
| 58 | |
| 59 | /* |
| 60 | * Initial task structure. |
| 61 | * |
| 62 | * All other task structs will be allocated on slabs in fork.c |
| 63 | */ |
| 64 | struct task_struct init_task = INIT_TASK(init_task); |
| 65 | |
| 66 | EXPORT_SYMBOL(init_task); |
| 67 | |
| 68 | /* |
| 69 | * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if |
| 70 | * there would ever be a halt sequence (for power save when idle) with |
| 71 | * some largish delay when halting or resuming *and* a driver that can't |
| 72 | * afford that delay. The hlt_counter would then be checked before |
| 73 | * executing the halt sequence, and the driver marks the unhaltable |
| 74 | * region by enable_hlt/disable_hlt. |
| 75 | */ |
| 76 | |
Mikael Starvik | 5d01e6c | 2005-07-27 11:44:43 -0700 | [diff] [blame] | 77 | int cris_hlt_counter=0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | void disable_hlt(void) |
| 80 | { |
Mikael Starvik | 5d01e6c | 2005-07-27 11:44:43 -0700 | [diff] [blame] | 81 | cris_hlt_counter++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | EXPORT_SYMBOL(disable_hlt); |
| 85 | |
| 86 | void enable_hlt(void) |
| 87 | { |
Mikael Starvik | 5d01e6c | 2005-07-27 11:44:43 -0700 | [diff] [blame] | 88 | cris_hlt_counter--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | EXPORT_SYMBOL(enable_hlt); |
| 92 | |
| 93 | /* |
| 94 | * The following aren't currently used. |
| 95 | */ |
| 96 | void (*pm_idle)(void); |
| 97 | |
Jesper Nilsson | 7b27552 | 2007-11-14 17:00:59 -0800 | [diff] [blame] | 98 | extern void default_idle(void); |
| 99 | |
| 100 | void (*pm_power_off)(void); |
| 101 | EXPORT_SYMBOL(pm_power_off); |
| 102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | /* |
| 104 | * The idle thread. There's no useful work to be |
| 105 | * done, so just try to conserve power and have a |
| 106 | * low exit latency (ie sit in a loop waiting for |
| 107 | * somebody to say that they'd like to reschedule) |
| 108 | */ |
Jesper Nilsson | f32bb79 | 2008-01-28 16:29:21 +0100 | [diff] [blame^] | 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | void cpu_idle (void) |
| 111 | { |
| 112 | /* endless idle loop with no priority at all */ |
| 113 | while (1) { |
| 114 | while (!need_resched()) { |
Mikael Starvik | 5d01e6c | 2005-07-27 11:44:43 -0700 | [diff] [blame] | 115 | void (*idle)(void); |
| 116 | /* |
| 117 | * Mark this as an RCU critical section so that |
| 118 | * synchronize_kernel() in the unload path waits |
| 119 | * for our completion. |
| 120 | */ |
| 121 | idle = pm_idle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | if (!idle) |
| 123 | idle = default_idle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | idle(); |
| 125 | } |
Nick Piggin | 5bfb5d6 | 2005-11-08 21:39:01 -0800 | [diff] [blame] | 126 | preempt_enable_no_resched(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | schedule(); |
Nick Piggin | 5bfb5d6 | 2005-11-08 21:39:01 -0800 | [diff] [blame] | 128 | preempt_disable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | void hard_reset_now (void); |
| 133 | |
Eric W. Biederman | 16dcb4b | 2005-07-26 11:32:34 -0600 | [diff] [blame] | 134 | void machine_restart(char *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | { |
| 136 | hard_reset_now(); |
| 137 | } |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | /* |
| 140 | * Similar to machine_power_off, but don't shut off power. Add code |
| 141 | * here to freeze the system for e.g. post-mortem debug purpose when |
| 142 | * possible. This halt has nothing to do with the idle halt. |
| 143 | */ |
| 144 | |
| 145 | void machine_halt(void) |
| 146 | { |
| 147 | } |
| 148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | /* If or when software power-off is implemented, add code here. */ |
| 150 | |
| 151 | void machine_power_off(void) |
| 152 | { |
| 153 | } |
| 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | /* |
| 156 | * When a process does an "exec", machine state like FPU and debug |
| 157 | * registers need to be reset. This is a hook function for that. |
| 158 | * Currently we don't have any such state to reset, so this is empty. |
| 159 | */ |
| 160 | |
| 161 | void flush_thread(void) |
| 162 | { |
| 163 | } |
| 164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | /* Fill in the fpu structure for a core dump. */ |
| 166 | int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) |
| 167 | { |
| 168 | return 0; |
| 169 | } |