1
2
3
4
5
6
7
8
9
10
11#include <linux/sched.h>
12#include <linux/slab.h>
13#include <linux/err.h>
14#include <linux/fs.h>
15#include <hwregs/reg_rdwr.h>
16#include <hwregs/reg_map.h>
17#include <hwregs/timer_defs.h>
18#include <hwregs/intr_vect_defs.h>
19#include <linux/ptrace.h>
20
21extern void stop_watchdog(void);
22
23
24void default_idle(void)
25{
26
27 __asm__ volatile("ei \n\t"
28 "halt ");
29}
30
31
32
33
34
35extern void deconfigure_bp(long pid);
36void exit_thread(void)
37{
38 deconfigure_bp(current->pid);
39}
40
41
42
43
44
45
46extern void arch_enable_nmi(void);
47
48void
49hard_reset_now(void)
50{
51
52
53
54
55
56#if defined(CONFIG_ETRAX_WATCHDOG)
57 extern int cause_of_death;
58#endif
59
60 printk("*** HARD RESET ***\n");
61 local_irq_disable();
62
63#if defined(CONFIG_ETRAX_WATCHDOG)
64 cause_of_death = 0xbedead;
65#else
66{
67 reg_timer_rw_wd_ctrl wd_ctrl = {0};
68
69 stop_watchdog();
70
71 wd_ctrl.key = 16;
72 wd_ctrl.cnt = 1;
73 wd_ctrl.cmd = regk_timer_start;
74
75 arch_enable_nmi();
76 REG_WR(timer, regi_timer0, rw_wd_ctrl, wd_ctrl);
77}
78#endif
79
80 while (1)
81 ;
82}
83
84
85
86
87unsigned long thread_saved_pc(struct task_struct *t)
88{
89 return task_pt_regs(t)->erp;
90}
91
92
93
94
95
96
97
98
99
100
101extern asmlinkage void ret_from_fork(void);
102extern asmlinkage void ret_from_kernel_thread(void);
103
104int
105copy_thread(unsigned long clone_flags, unsigned long usp,
106 unsigned long arg, struct task_struct *p)
107{
108 struct pt_regs *childregs = task_pt_regs(p);
109 struct switch_stack *swstack = ((struct switch_stack *) childregs) - 1;
110
111
112
113
114
115
116 if (unlikely(p->flags & PF_KTHREAD)) {
117 memset(swstack, 0,
118 sizeof(struct switch_stack) + sizeof(struct pt_regs));
119 swstack->r1 = usp;
120 swstack->r2 = arg;
121 childregs->ccs = 1 << (I_CCS_BITNR + CCS_SHIFT);
122 swstack->return_ip = (unsigned long) ret_from_kernel_thread;
123 p->thread.ksp = (unsigned long) swstack;
124 p->thread.usp = 0;
125 return 0;
126 }
127 *childregs = *current_pt_regs();
128 childregs->r10 = 0;
129
130
131
132
133 if (p->mm && (clone_flags & CLONE_SETTLS)) {
134 task_thread_info(p)->tls = childregs->mof;
135 }
136
137
138
139
140 swstack->r9 = 0;
141
142
143
144
145
146 swstack->return_ip = (unsigned long) ret_from_fork;
147
148
149 p->thread.usp = usp ?: rdusp();
150 p->thread.ksp = (unsigned long) swstack;
151
152 return 0;
153}
154
155unsigned long
156get_wchan(struct task_struct *p)
157{
158
159 return 0;
160}
161#undef last_sched
162#undef first_sched
163
164void show_regs(struct pt_regs * regs)
165{
166 unsigned long usp = rdusp();
167
168 show_regs_print_info(KERN_DEFAULT);
169
170 printk("ERP: %08lx SRP: %08lx CCS: %08lx USP: %08lx MOF: %08lx\n",
171 regs->erp, regs->srp, regs->ccs, usp, regs->mof);
172
173 printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n",
174 regs->r0, regs->r1, regs->r2, regs->r3);
175
176 printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",
177 regs->r4, regs->r5, regs->r6, regs->r7);
178
179 printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
180 regs->r8, regs->r9, regs->r10, regs->r11);
181
182 printk("r12: %08lx r13: %08lx oR10: %08lx\n",
183 regs->r12, regs->r13, regs->orig_r10);
184}
185