blob: 5933656db5a2ca58b9a2f583ce5945a57d1b832b [file] [log] [blame]
Jesper Nilssonf32bb792008-01-28 16:29:21 +01001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * 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 Torvalds1da177e2005-04-16 15:20:36 -07009 */
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 Bunkcdb04522006-03-24 03:15:57 -080019#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#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. Biederman16dcb4b2005-07-26 11:32:34 -060029#include <linux/reboot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
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
40static struct fs_struct init_fs = INIT_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
42static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
43struct mm_struct init_mm = INIT_MM(init_mm);
44
45EXPORT_SYMBOL(init_mm);
46
47/*
48 * Initial thread structure.
49 *
50 * We need to make sure that this is 8192-byte aligned due to the
51 * way process stacks are handled. This is done by having a special
52 * "init_task" linker map entry..
53 */
54union thread_union init_thread_union
55 __attribute__((__section__(".data.init_task"))) =
56 { INIT_THREAD_INFO(init_task) };
57
58/*
59 * Initial task structure.
60 *
61 * All other task structs will be allocated on slabs in fork.c
62 */
63struct task_struct init_task = INIT_TASK(init_task);
64
65EXPORT_SYMBOL(init_task);
66
67/*
68 * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if
69 * there would ever be a halt sequence (for power save when idle) with
70 * some largish delay when halting or resuming *and* a driver that can't
71 * afford that delay. The hlt_counter would then be checked before
72 * executing the halt sequence, and the driver marks the unhaltable
73 * region by enable_hlt/disable_hlt.
74 */
75
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070076int cris_hlt_counter=0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78void disable_hlt(void)
79{
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070080 cris_hlt_counter++;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
82
83EXPORT_SYMBOL(disable_hlt);
84
85void enable_hlt(void)
86{
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070087 cris_hlt_counter--;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088}
89
90EXPORT_SYMBOL(enable_hlt);
91
92/*
93 * The following aren't currently used.
94 */
95void (*pm_idle)(void);
96
Jesper Nilsson7b275522007-11-14 17:00:59 -080097extern void default_idle(void);
98
99void (*pm_power_off)(void);
100EXPORT_SYMBOL(pm_power_off);
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102/*
103 * The idle thread. There's no useful work to be
104 * done, so just try to conserve power and have a
105 * low exit latency (ie sit in a loop waiting for
106 * somebody to say that they'd like to reschedule)
107 */
Jesper Nilssonf32bb792008-01-28 16:29:21 +0100108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109void cpu_idle (void)
110{
111 /* endless idle loop with no priority at all */
112 while (1) {
113 while (!need_resched()) {
Mikael Starvik5d01e6c2005-07-27 11:44:43 -0700114 void (*idle)(void);
115 /*
116 * Mark this as an RCU critical section so that
117 * synchronize_kernel() in the unload path waits
118 * for our completion.
119 */
120 idle = pm_idle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 if (!idle)
122 idle = default_idle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 idle();
124 }
Nick Piggin5bfb5d62005-11-08 21:39:01 -0800125 preempt_enable_no_resched();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 schedule();
Nick Piggin5bfb5d62005-11-08 21:39:01 -0800127 preempt_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129}
130
131void hard_reset_now (void);
132
Eric W. Biederman16dcb4b2005-07-26 11:32:34 -0600133void machine_restart(char *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134{
135 hard_reset_now();
136}
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138/*
139 * Similar to machine_power_off, but don't shut off power. Add code
140 * here to freeze the system for e.g. post-mortem debug purpose when
141 * possible. This halt has nothing to do with the idle halt.
142 */
143
144void machine_halt(void)
145{
146}
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148/* If or when software power-off is implemented, add code here. */
149
150void machine_power_off(void)
151{
152}
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154/*
155 * When a process does an "exec", machine state like FPU and debug
156 * registers need to be reset. This is a hook function for that.
157 * Currently we don't have any such state to reset, so this is empty.
158 */
159
160void flush_thread(void)
161{
162}
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164/* Fill in the fpu structure for a core dump. */
165int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
166{
167 return 0;
168}