blob: 891dad85e8bd4fae33233f5abb71c453b3ade5c2 [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
Arun Sharma600634972011-07-26 16:09:06 -070015#include <linux/atomic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#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 Torvalds1da177e2005-04-16 15:20:36 -070021#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. Biederman16dcb4b2005-07-26 11:32:34 -060027#include <linux/reboot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29//#define DEBUG
30
31/*
32 * Initial task structure. Make this a per-architecture thing,
33 * because different architectures tend to have different
34 * alignment requirements and potentially different initial
35 * setup.
36 */
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
39static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040/*
41 * Initial thread structure.
42 *
43 * We need to make sure that this is 8192-byte aligned due to the
44 * way process stacks are handled. This is done by having a special
45 * "init_task" linker map entry..
46 */
Joe Perchesd200c922009-09-20 18:14:13 -040047union thread_union init_thread_union __init_task_data =
48 { INIT_THREAD_INFO(init_task) };
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50/*
51 * Initial task structure.
52 *
53 * All other task structs will be allocated on slabs in fork.c
54 */
55struct task_struct init_task = INIT_TASK(init_task);
56
57EXPORT_SYMBOL(init_task);
58
59/*
60 * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if
61 * there would ever be a halt sequence (for power save when idle) with
62 * some largish delay when halting or resuming *and* a driver that can't
63 * afford that delay. The hlt_counter would then be checked before
64 * executing the halt sequence, and the driver marks the unhaltable
65 * region by enable_hlt/disable_hlt.
66 */
67
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070068int cris_hlt_counter=0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70void disable_hlt(void)
71{
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070072 cris_hlt_counter++;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073}
74
75EXPORT_SYMBOL(disable_hlt);
76
77void enable_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(enable_hlt);
83
84/*
85 * The following aren't currently used.
86 */
87void (*pm_idle)(void);
88
Jesper Nilsson7b275522007-11-14 17:00:59 -080089extern void default_idle(void);
90
91void (*pm_power_off)(void);
92EXPORT_SYMBOL(pm_power_off);
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094/*
95 * The idle thread. There's no useful work to be
96 * done, so just try to conserve power and have a
97 * low exit latency (ie sit in a loop waiting for
98 * somebody to say that they'd like to reschedule)
99 */
Jesper Nilssonf32bb792008-01-28 16:29:21 +0100100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101void cpu_idle (void)
102{
103 /* endless idle loop with no priority at all */
104 while (1) {
105 while (!need_resched()) {
Mikael Starvik5d01e6c2005-07-27 11:44:43 -0700106 void (*idle)(void);
107 /*
108 * Mark this as an RCU critical section so that
109 * synchronize_kernel() in the unload path waits
110 * for our completion.
111 */
112 idle = pm_idle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 if (!idle)
114 idle = default_idle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 idle();
116 }
Thomas Gleixnerbd2f5532011-03-21 12:33:18 +0100117 schedule_preempt_disabled();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119}
120
121void hard_reset_now (void);
122
Eric W. Biederman16dcb4b2005-07-26 11:32:34 -0600123void machine_restart(char *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124{
125 hard_reset_now();
126}
127
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128/*
129 * Similar to machine_power_off, but don't shut off power. Add code
130 * here to freeze the system for e.g. post-mortem debug purpose when
131 * possible. This halt has nothing to do with the idle halt.
132 */
133
134void machine_halt(void)
135{
136}
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138/* If or when software power-off is implemented, add code here. */
139
140void machine_power_off(void)
141{
142}
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144/*
145 * When a process does an "exec", machine state like FPU and debug
146 * registers need to be reset. This is a hook function for that.
147 * Currently we don't have any such state to reset, so this is empty.
148 */
149
150void flush_thread(void)
151{
152}
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154/* Fill in the fpu structure for a core dump. */
155int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
156{
157 return 0;
158}