1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/sched.h>
14#include <linux/slab.h>
15#include <linux/err.h>
16#include <linux/fs.h>
17#include <arch/svinto.h>
18#include <linux/init.h>
19#include <arch/system.h>
20#include <linux/ptrace.h>
21
22#ifdef CONFIG_ETRAX_GPIO
23void etrax_gpio_wake_up_check(void);
24#endif
25
26
27
28
29
30void default_idle(void)
31{
32#ifdef CONFIG_ETRAX_GPIO
33 etrax_gpio_wake_up_check();
34#endif
35 local_irq_enable();
36}
37
38
39
40
41
42void exit_thread(void)
43{
44
45}
46
47
48
49
50
51
52void hard_reset_now (void)
53{
54
55
56
57
58
59#if defined(CONFIG_ETRAX_WATCHDOG)
60 extern int cause_of_death;
61#endif
62
63 printk("*** HARD RESET ***\n");
64 local_irq_disable();
65
66#if defined(CONFIG_ETRAX_WATCHDOG)
67 cause_of_death = 0xbedead;
68#else
69
70
71 *R_WATCHDOG = IO_FIELD(R_WATCHDOG, key, 3) |
72 IO_STATE(R_WATCHDOG, enable, start);
73#endif
74
75 while(1) ;
76}
77
78
79
80
81unsigned long thread_saved_pc(struct task_struct *t)
82{
83 return task_pt_regs(t)->irp;
84}
85
86
87
88
89
90
91
92
93
94asmlinkage void ret_from_fork(void);
95asmlinkage void ret_from_kernel_thread(void);
96
97int copy_thread(unsigned long clone_flags, unsigned long usp,
98 unsigned long arg, struct task_struct *p)
99{
100 struct pt_regs *childregs = task_pt_regs(p);
101 struct switch_stack *swstack = ((struct switch_stack *)childregs) - 1;
102
103
104
105
106
107 if (unlikely(p->flags & PF_KTHREAD)) {
108 memset(swstack, 0,
109 sizeof(struct switch_stack) + sizeof(struct pt_regs));
110 swstack->r1 = usp;
111 swstack->r2 = arg;
112 childregs->dccr = 1 << I_DCCR_BITNR;
113 swstack->return_ip = (unsigned long) ret_from_kernel_thread;
114 p->thread.ksp = (unsigned long) swstack;
115 p->thread.usp = 0;
116 return 0;
117 }
118 *childregs = *current_pt_regs();
119
120 childregs->r10 = 0;
121
122
123
124 swstack->r9 = 0;
125
126
127
128 swstack->return_ip = (unsigned long) ret_from_fork;
129
130
131
132 p->thread.usp = usp ?: rdusp();
133
134
135
136 p->thread.ksp = (unsigned long) swstack;
137
138#ifdef DEBUG
139 printk("copy_thread: new regs at 0x%p, as shown below:\n", childregs);
140 show_registers(childregs);
141#endif
142
143 return 0;
144}
145
146unsigned long get_wchan(struct task_struct *p)
147{
148#if 0
149
150
151 unsigned long ebp, esp, eip;
152 unsigned long stack_page;
153 int count = 0;
154 if (!p || p == current || p->state == TASK_RUNNING)
155 return 0;
156 stack_page = (unsigned long)p;
157 esp = p->thread.esp;
158 if (!stack_page || esp < stack_page || esp > 8188+stack_page)
159 return 0;
160
161 ebp = *(unsigned long *) esp;
162 do {
163 if (ebp < stack_page || ebp > 8184+stack_page)
164 return 0;
165 eip = *(unsigned long *) (ebp+4);
166 if (!in_sched_functions(eip))
167 return eip;
168 ebp = *(unsigned long *) ebp;
169 } while (count++ < 16);
170#endif
171 return 0;
172}
173#undef last_sched
174#undef first_sched
175
176void show_regs(struct pt_regs * regs)
177{
178 unsigned long usp = rdusp();
179
180 show_regs_print_info(KERN_DEFAULT);
181
182 printk("IRP: %08lx SRP: %08lx DCCR: %08lx USP: %08lx MOF: %08lx\n",
183 regs->irp, regs->srp, regs->dccr, usp, regs->mof );
184 printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n",
185 regs->r0, regs->r1, regs->r2, regs->r3);
186 printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",
187 regs->r4, regs->r5, regs->r6, regs->r7);
188 printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
189 regs->r8, regs->r9, regs->r10, regs->r11);
190 printk("r12: %08lx r13: %08lx oR10: %08lx\n",
191 regs->r12, regs->r13, regs->orig_r10);
192}
193
194