blob: 104ff4dd9b98dd1aa0c00177ae1e83d2f8138a54 [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>
Frederic Weisbeckerc633f9e2012-08-22 17:27:34 +020028#include <linux/rcupdate.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30//#define DEBUG
31
32/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if
34 * there would ever be a halt sequence (for power save when idle) with
35 * some largish delay when halting or resuming *and* a driver that can't
36 * afford that delay. The hlt_counter would then be checked before
37 * executing the halt sequence, and the driver marks the unhaltable
38 * region by enable_hlt/disable_hlt.
39 */
40
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070041int cris_hlt_counter=0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43void disable_hlt(void)
44{
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070045 cris_hlt_counter++;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046}
47
48EXPORT_SYMBOL(disable_hlt);
49
50void enable_hlt(void)
51{
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070052 cris_hlt_counter--;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54
55EXPORT_SYMBOL(enable_hlt);
56
Jesper Nilsson7b275522007-11-14 17:00:59 -080057extern void default_idle(void);
58
59void (*pm_power_off)(void);
60EXPORT_SYMBOL(pm_power_off);
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062/*
63 * The idle thread. There's no useful work to be
64 * done, so just try to conserve power and have a
65 * low exit latency (ie sit in a loop waiting for
66 * somebody to say that they'd like to reschedule)
67 */
Jesper Nilssonf32bb792008-01-28 16:29:21 +010068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069void cpu_idle (void)
70{
71 /* endless idle loop with no priority at all */
72 while (1) {
Frederic Weisbeckerc633f9e2012-08-22 17:27:34 +020073 rcu_idle_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 while (!need_resched()) {
Mikael Starvik5d01e6c2005-07-27 11:44:43 -070075 /*
76 * Mark this as an RCU critical section so that
77 * synchronize_kernel() in the unload path waits
78 * for our completion.
79 */
Len Brown28f14182013-02-09 22:34:18 -050080 default_idle();
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 }
Frederic Weisbeckerc633f9e2012-08-22 17:27:34 +020082 rcu_idle_exit();
Thomas Gleixnerbd2f5532011-03-21 12:33:18 +010083 schedule_preempt_disabled();
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070085}
86
87void hard_reset_now (void);
88
Eric W. Biederman16dcb4b2005-07-26 11:32:34 -060089void machine_restart(char *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090{
91 hard_reset_now();
92}
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094/*
95 * Similar to machine_power_off, but don't shut off power. Add code
96 * here to freeze the system for e.g. post-mortem debug purpose when
97 * possible. This halt has nothing to do with the idle halt.
98 */
99
100void machine_halt(void)
101{
102}
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104/* If or when software power-off is implemented, add code here. */
105
106void machine_power_off(void)
107{
108}
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110/*
111 * When a process does an "exec", machine state like FPU and debug
112 * registers need to be reset. This is a hook function for that.
113 * Currently we don't have any such state to reset, so this is empty.
114 */
115
116void flush_thread(void)
117{
118}
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120/* Fill in the fpu structure for a core dump. */
121int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
122{
123 return 0;
124}