blob: 60816e876455112047e21d6191a1a2380aa27dd0 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070040static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
41static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
42struct mm_struct init_mm = INIT_MM(init_mm);
43
44EXPORT_SYMBOL(init_mm);
45
46/*
47 * Initial thread structure.
48 *
49 * We need to make sure that this is 8192-byte aligned due to the
50 * way process stacks are handled. This is done by having a special
51 * "init_task" linker map entry..
52 */
53union thread_union init_thread_union
54 __attribute__((__section__(".data.init_task"))) =
55 { INIT_THREAD_INFO(init_task) };
56
57/*
58 * Initial task structure.
59 *
60 * All other task structs will be allocated on slabs in fork.c
61 */
62struct task_struct init_task = INIT_TASK(init_task);
63
64EXPORT_SYMBOL(init_task);
65
66/*
67 * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if
68 * there would ever be a halt sequence (for power save when idle) with
69 * some largish delay when halting or resuming *and* a driver that can't
70 * afford that delay. The hlt_counter would then be checked before
71 * executing the halt sequence, and the driver marks the unhaltable
72 * region by enable_hlt/disable_hlt.
73 */
74
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070075int cris_hlt_counter=0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77void disable_hlt(void)
78{
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070079 cris_hlt_counter++;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080}
81
82EXPORT_SYMBOL(disable_hlt);
83
84void enable_hlt(void)
85{
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070086 cris_hlt_counter--;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087}
88
89EXPORT_SYMBOL(enable_hlt);
90
91/*
92 * The following aren't currently used.
93 */
94void (*pm_idle)(void);
95
Jesper Nilsson7b275522007-11-14 17:00:59 -080096extern void default_idle(void);
97
98void (*pm_power_off)(void);
99EXPORT_SYMBOL(pm_power_off);
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101/*
102 * The idle thread. There's no useful work to be
103 * done, so just try to conserve power and have a
104 * low exit latency (ie sit in a loop waiting for
105 * somebody to say that they'd like to reschedule)
106 */
Jesper Nilssonf32bb792008-01-28 16:29:21 +0100107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108void cpu_idle (void)
109{
110 /* endless idle loop with no priority at all */
111 while (1) {
112 while (!need_resched()) {
Mikael Starvik5d01e6c2005-07-27 11:44:43 -0700113 void (*idle)(void);
114 /*
115 * Mark this as an RCU critical section so that
116 * synchronize_kernel() in the unload path waits
117 * for our completion.
118 */
119 idle = pm_idle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 if (!idle)
121 idle = default_idle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 idle();
123 }
Nick Piggin5bfb5d62005-11-08 21:39:01 -0800124 preempt_enable_no_resched();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 schedule();
Nick Piggin5bfb5d62005-11-08 21:39:01 -0800126 preempt_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
130void hard_reset_now (void);
131
Eric W. Biederman16dcb4b2005-07-26 11:32:34 -0600132void machine_restart(char *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133{
134 hard_reset_now();
135}
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137/*
138 * Similar to machine_power_off, but don't shut off power. Add code
139 * here to freeze the system for e.g. post-mortem debug purpose when
140 * possible. This halt has nothing to do with the idle halt.
141 */
142
143void machine_halt(void)
144{
145}
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147/* If or when software power-off is implemented, add code here. */
148
149void machine_power_off(void)
150{
151}
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153/*
154 * When a process does an "exec", machine state like FPU and debug
155 * registers need to be reset. This is a hook function for that.
156 * Currently we don't have any such state to reset, so this is empty.
157 */
158
159void flush_thread(void)
160{
161}
162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163/* Fill in the fpu structure for a core dump. */
164int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
165{
166 return 0;
167}