aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/metag/include/asm/thread_info.h155
-rw-r--r--arch/metag/kernel/process.c461
2 files changed, 616 insertions, 0 deletions
diff --git a/arch/metag/include/asm/thread_info.h b/arch/metag/include/asm/thread_info.h
new file mode 100644
index 000000000000..0ecd34d8b5f6
--- /dev/null
+++ b/arch/metag/include/asm/thread_info.h
@@ -0,0 +1,155 @@
1/* thread_info.h: Meta low-level thread information
2 *
3 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
4 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
5 *
6 * Meta port by Imagination Technologies
7 */
8
9#ifndef _ASM_THREAD_INFO_H
10#define _ASM_THREAD_INFO_H
11
12#include <linux/compiler.h>
13#include <asm/page.h>
14
15#ifndef __ASSEMBLY__
16#include <asm/processor.h>
17#endif
18
19/*
20 * low level task data that entry.S needs immediate access to
21 * - this struct should fit entirely inside of one cache line
22 * - this struct shares the supervisor stack pages
23 * - if the contents of this structure are changed, the assembly constants must
24 * also be changed
25 */
26#ifndef __ASSEMBLY__
27
28/* This must be 8 byte aligned so we can ensure stack alignment. */
29struct thread_info {
30 struct task_struct *task; /* main task structure */
31 struct exec_domain *exec_domain; /* execution domain */
32 unsigned long flags; /* low level flags */
33 unsigned long status; /* thread-synchronous flags */
34 u32 cpu; /* current CPU */
35 int preempt_count; /* 0 => preemptable, <0 => BUG */
36
37 mm_segment_t addr_limit; /* thread address space */
38 struct restart_block restart_block;
39
40 u8 supervisor_stack[0];
41};
42
43#else /* !__ASSEMBLY__ */
44
45#include <generated/asm-offsets.h>
46
47#endif
48
49#define PREEMPT_ACTIVE 0x10000000
50
51#ifdef CONFIG_4KSTACKS
52#define THREAD_SHIFT 12
53#else
54#define THREAD_SHIFT 13
55#endif
56
57#if THREAD_SHIFT >= PAGE_SHIFT
58#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
59#else
60#define THREAD_SIZE_ORDER 0
61#endif
62
63#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
64
65#define STACK_WARN (THREAD_SIZE/8)
66/*
67 * macros/functions for gaining access to the thread information structure
68 */
69#ifndef __ASSEMBLY__
70
71#define INIT_THREAD_INFO(tsk) \
72{ \
73 .task = &tsk, \
74 .exec_domain = &default_exec_domain, \
75 .flags = 0, \
76 .cpu = 0, \
77 .preempt_count = INIT_PREEMPT_COUNT, \
78 .addr_limit = KERNEL_DS, \
79 .restart_block = { \
80 .fn = do_no_restart_syscall, \
81 }, \
82}
83
84#define init_thread_info (init_thread_union.thread_info)
85#define init_stack (init_thread_union.stack)
86
87/* how to get the current stack pointer from C */
88register unsigned long current_stack_pointer asm("A0StP") __used;
89
90/* how to get the thread information struct from C */
91static inline struct thread_info *current_thread_info(void)
92{
93 return (struct thread_info *)(current_stack_pointer &
94 ~(THREAD_SIZE - 1));
95}
96
97#define __HAVE_ARCH_KSTACK_END
98static inline int kstack_end(void *addr)
99{
100 return addr == (void *) (((unsigned long) addr & ~(THREAD_SIZE - 1))
101 + sizeof(struct thread_info));
102}
103
104#endif
105
106/*
107 * thread information flags
108 * - these are process state flags that various assembly files may need to
109 * access
110 * - pending work-to-be-done flags are in LSW
111 * - other flags in MSW
112 */
113#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
114#define TIF_SIGPENDING 1 /* signal pending */
115#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
116#define TIF_SINGLESTEP 3 /* restore singlestep on return to user
117 mode */
118#define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
119#define TIF_SECCOMP 5 /* secure computing */
120#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
121#define TIF_NOTIFY_RESUME 7 /* callback before returning to user */
122#define TIF_POLLING_NRFLAG 8 /* true if poll_idle() is polling
123 TIF_NEED_RESCHED */
124#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
125#define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint instrumentation */
126
127
128#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
129#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
130#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
131#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
132#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
133#define _TIF_SECCOMP (1<<TIF_SECCOMP)
134#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
135#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
136#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
137
138/* work to do in syscall trace */
139#define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
140 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
141 _TIF_SYSCALL_TRACEPOINT)
142
143/* work to do on any return to u-space */
144#define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \
145 _TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \
146 _TIF_SINGLESTEP | _TIF_RESTORE_SIGMASK | \
147 _TIF_NOTIFY_RESUME)
148
149/* work to do on interrupt/exception return */
150#define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
151 _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
152
153#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
154
155#endif /* _ASM_THREAD_INFO_H */
diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c
new file mode 100644
index 000000000000..c6efe62e5b76
--- /dev/null
+++ b/arch/metag/kernel/process.c
@@ -0,0 +1,461 @@
1/*
2 * Copyright (C) 2005,2006,2007,2008,2009,2010,2011 Imagination Technologies
3 *
4 * This file contains the architecture-dependent parts of process handling.
5 *
6 */
7
8#include <linux/errno.h>
9#include <linux/export.h>
10#include <linux/sched.h>
11#include <linux/kernel.h>
12#include <linux/mm.h>
13#include <linux/unistd.h>
14#include <linux/ptrace.h>
15#include <linux/user.h>
16#include <linux/reboot.h>
17#include <linux/elfcore.h>
18#include <linux/fs.h>
19#include <linux/tick.h>
20#include <linux/slab.h>
21#include <linux/mman.h>
22#include <linux/pm.h>
23#include <linux/syscalls.h>
24#include <linux/uaccess.h>
25#include <asm/core_reg.h>
26#include <asm/user_gateway.h>
27#include <asm/tcm.h>
28#include <asm/traps.h>
29#include <asm/switch_to.h>
30
31/*
32 * Wait for the next interrupt and enable local interrupts
33 */
34static inline void arch_idle(void)
35{
36 int tmp;
37
38 /*
39 * Quickly jump straight into the interrupt entry point without actually