Commit | Line | Data |
---|---|---|
f32bb79c | 1 | /* |
1da177e4 LT |
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 | * | |
1da177e4 LT |
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> | |
cdb04527 | 19 | #include <asm/system.h> |
1da177e4 LT |
20 | #include <linux/module.h> |
21 | #include <linux/spinlock.h> | |
1da177e4 LT |
22 | #include <linux/init_task.h> |
23 | #include <linux/sched.h> | |
24 | #include <linux/fs.h> | |
25 | #include <linux/user.h> | |
26 | #include <linux/elfcore.h> | |
27 | #include <linux/mqueue.h> | |
16dcb4bb | 28 | #include <linux/reboot.h> |
1da177e4 LT |
29 | |
30 | //#define DEBUG | |
31 | ||
32 | /* | |
33 | * Initial task structure. Make this a per-architecture thing, | |
34 | * because different architectures tend to have different | |
35 | * alignment requirements and potentially different initial | |
36 | * setup. | |
37 | */ | |
38 | ||
1da177e4 LT |
39 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
40 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | |
1da177e4 LT |
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 | /* | |
53 | * Initial task structure. | |
54 | * | |
55 | * All other task structs will be allocated on slabs in fork.c | |
56 | */ | |
57 | struct task_struct init_task = INIT_TASK(init_task); | |
58 | ||
59 | EXPORT_SYMBOL(init_task); | |
60 | ||
61 | /* | |
62 | * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if | |
63 | * there would ever be a halt sequence (for power save when idle) with | |
64 | * some largish delay when halting or resuming *and* a driver that can't | |
65 | * afford that delay. The hlt_counter would then be checked before | |
66 | * executing the halt sequence, and the driver marks the unhaltable | |
67 | * region by enable_hlt/disable_hlt. | |
68 | */ | |
69 | ||
5d01e6ce | 70 | int cris_hlt_counter=0; |
1da177e4 LT |
71 | |
72 | void disable_hlt(void) | |
73 | { | |
5d01e6ce | 74 | cris_hlt_counter++; |
1da177e4 LT |
75 | } |
76 | ||
77 | EXPORT_SYMBOL(disable_hlt); | |
78 | ||
79 | void enable_hlt(void) | |
80 | { | |
5d01e6ce | 81 | cris_hlt_counter--; |
1da177e4 LT |
82 | } |
83 | ||
84 | EXPORT_SYMBOL(enable_hlt); | |
85 | ||
86 | /* | |
87 | * The following aren't currently used. | |
88 | */ | |
89 | void (*pm_idle)(void); | |
90 | ||
7b275523 JN |
91 | extern void default_idle(void); |
92 | ||
93 | void (*pm_power_off)(void); | |
94 | EXPORT_SYMBOL(pm_power_off); | |
95 | ||
1da177e4 LT |
96 | /* |
97 | * The idle thread. There's no useful work to be | |
98 | * done, so just try to conserve power and have a | |
99 | * low exit latency (ie sit in a loop waiting for | |
100 | * somebody to say that they'd like to reschedule) | |
101 | */ | |
f32bb79c | 102 | |
1da177e4 LT |
103 | void cpu_idle (void) |
104 | { | |
105 | /* endless idle loop with no priority at all */ | |
106 | while (1) { | |
107 | while (!need_resched()) { | |
5d01e6ce MS |
108 | void (*idle)(void); |
109 | /* | |
110 | * Mark this as an RCU critical section so that | |
111 | * synchronize_kernel() in the unload path waits | |
112 | * for our completion. | |
113 | */ | |
114 | idle = pm_idle; | |
1da177e4 LT |
115 | if (!idle) |
116 | idle = default_idle; | |
1da177e4 LT |
117 | idle(); |
118 | } | |
5bfb5d69 | 119 | preempt_enable_no_resched(); |
1da177e4 | 120 | schedule(); |
5bfb5d69 | 121 | preempt_disable(); |
1da177e4 | 122 | } |
1da177e4 LT |
123 | } |
124 | ||
125 | void hard_reset_now (void); | |
126 | ||
16dcb4bb | 127 | void machine_restart(char *cmd) |
1da177e4 LT |
128 | { |
129 | hard_reset_now(); | |
130 | } | |
131 | ||
1da177e4 LT |
132 | /* |
133 | * Similar to machine_power_off, but don't shut off power. Add code | |
134 | * here to freeze the system for e.g. post-mortem debug purpose when | |
135 | * possible. This halt has nothing to do with the idle halt. | |
136 | */ | |
137 | ||
138 | void machine_halt(void) | |
139 | { | |
140 | } | |
141 | ||
1da177e4 LT |
142 | /* If or when software power-off is implemented, add code here. */ |
143 | ||
144 | void machine_power_off(void) | |
145 | { | |
146 | } | |
147 | ||
1da177e4 LT |
148 | /* |
149 | * When a process does an "exec", machine state like FPU and debug | |
150 | * registers need to be reset. This is a hook function for that. | |
151 | * Currently we don't have any such state to reset, so this is empty. | |
152 | */ | |
153 | ||
154 | void flush_thread(void) | |
155 | { | |
156 | } | |
157 | ||
1da177e4 LT |
158 | /* Fill in the fpu structure for a core dump. */ |
159 | int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) | |
160 | { | |
161 | return 0; | |
162 | } |