This source file includes following definitions.
- sys_idle
- sys_idle
- cpu_idle
- hard_reset_now
- show_regwindow
- show_regs
- exit_thread
- release_thread
- flush_thread
- copy_thread
- dump_thread
- dump_fpu
- sparc_execve
1
2
3
4
5
6
7
8
9
10
11 #define __KERNEL_SYSCALLS__
12 #include <stdarg.h>
13
14 #include <linux/errno.h>
15 #include <linux/sched.h>
16 #include <linux/kernel.h>
17 #include <linux/mm.h>
18 #include <linux/stddef.h>
19 #include <linux/unistd.h>
20 #include <linux/ptrace.h>
21 #include <linux/malloc.h>
22 #include <linux/ldt.h>
23 #include <linux/user.h>
24 #include <linux/a.out.h>
25
26 #include <asm/auxio.h>
27 #include <asm/oplib.h>
28 #include <asm/segment.h>
29 #include <asm/system.h>
30 #include <asm/page.h>
31 #include <asm/pgtable.h>
32 #include <asm/delay.h>
33 #include <asm/processor.h>
34 #include <asm/psr.h>
35 #include <asm/system.h>
36
37 extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
38
39 int active_ds = USER_DS;
40
41 #ifndef __SMP__
42
43
44
45
46 asmlinkage int sys_idle(void)
47 {
48 if (current->pid != 0)
49 return -EPERM;
50
51
52 current->counter = -100;
53 for (;;) {
54 schedule();
55 }
56 return 0;
57 }
58
59 #else
60
61
62
63
64 asmlinkage int sys_idle(void)
65 {
66 if (current->pid != 0)
67 return -EPERM;
68
69
70 current->counter = -100;
71 schedule();
72 return 0;
73 }
74
75
76 int cpu_idle(void *unused)
77 {
78 volatile int *spap = &smp_process_available;
79 volatile int cval;
80
81 current->priority = -50;
82 while(1) {
83 if(0==read_smp_counter(spap))
84 continue;
85 while(*spap == -1)
86 ;
87 cli();
88
89 while((cval = smp_swap(spap, -1)) == -1)
90 ;
91 if (0==cval) {
92
93 smp_process_available = 0;
94 sti();
95 continue;
96 }
97
98 smp_swap(spap, (cval - 1));
99 sti();
100 idle();
101 }
102 }
103
104 #endif
105
106 extern char saved_command_line[];
107
108 void hard_reset_now(void)
109 {
110 sti();
111 udelay(8000);
112 cli();
113 prom_feval("reset");
114 panic("Reboot failed!");
115 }
116
117 void show_regwindow(struct reg_window *rw)
118 {
119 printk("l0:%08lx l1:%08lx l2:%08lx l3:%08lx l4:%08lx l5:%08lx l6:%08lx l7:%08lx\n",
120 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
121 rw->locals[4], rw->locals[5], rw->locals[6], rw->locals[7]);
122 printk("i0:%08lx i1:%08lx i2:%08lx i3:%08lx i4:%08lx i5:%08lx i6:%08lx i7:%08lx\n",
123 rw->ins[0], rw->ins[1], rw->ins[2], rw->ins[3],
124 rw->ins[4], rw->ins[5], rw->ins[6], rw->ins[7]);
125 }
126
127 void show_regs(struct pt_regs * regs)
128 {
129 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx\n", regs->psr,
130 regs->pc, regs->npc, regs->y);
131 printk("%%g0: %08lx %%g1: %08lx %%g2: %08lx %%g3: %08lx\n",
132 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
133 regs->u_regs[3]);
134 printk("%%g4: %08lx %%g5: %08lx %%g6: %08lx %%g7: %08lx\n",
135 regs->u_regs[4], regs->u_regs[5], regs->u_regs[6],
136 regs->u_regs[7]);
137 printk("%%o0: %08lx %%o1: %08lx %%o2: %08lx %%o3: %08lx\n",
138 regs->u_regs[8], regs->u_regs[9], regs->u_regs[10],
139 regs->u_regs[11]);
140 printk("%%o4: %08lx %%o5: %08lx %%sp: %08lx %%ret_pc: %08lx\n",
141 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
142 regs->u_regs[15]);
143 }
144
145
146
147
148 void exit_thread(void)
149 {
150 flush_user_windows();
151 #ifndef __SMP__
152 if(last_task_used_math == current) {
153 #else
154 if(current->flags & PF_USEDFPU) {
155 #endif
156
157 put_psr(get_psr() | PSR_EF);
158 fpsave(¤t->tss.float_regs[0], ¤t->tss.fsr,
159 ¤t->tss.fpqueue[0], ¤t->tss.fpqdepth);
160 #ifndef __SMP__
161 last_task_used_math = NULL;
162 #else
163 current->flags &= ~PF_USEDFPU;
164 #endif
165 }
166 mmu_exit_hook();
167 }
168
169
170
171
172 void release_thread(struct task_struct *dead_task)
173 {
174 }
175
176 void flush_thread(void)
177 {
178
179 flush_user_windows();
180 current->tss.w_saved = 0;
181 current->tss.uwinmask = 0;
182 current->tss.sig_address = 0;
183 current->tss.sig_desc = 0;
184 current->tss.sstk_info.cur_status = 0;
185 current->tss.sstk_info.the_stack = 0;
186
187 #ifndef __SMP__
188 if(last_task_used_math == current) {
189 #else
190 if(current->flags & PF_USEDFPU) {
191 #endif
192
193 put_psr(get_psr() | PSR_EF);
194 fpsave(¤t->tss.float_regs[0], ¤t->tss.fsr,
195 ¤t->tss.fpqueue[0], ¤t->tss.fpqdepth);
196 #ifndef __SMP__
197 last_task_used_math = NULL;
198 #else
199 current->flags &= ~PF_USEDFPU;
200 #endif
201 }
202
203 memset(¤t->tss.reg_window[0], 0,
204 (sizeof(struct reg_window) * NSWINS));
205 memset(¤t->tss.rwbuf_stkptrs[0], 0,
206 (sizeof(unsigned long) * NSWINS));
207 mmu_flush_hook();
208
209 current->tss.flags &= ~SPARC_FLAG_KTHREAD;
210 }
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225 extern void ret_sys_call(void);
226
227 void copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
228 struct task_struct *p, struct pt_regs *regs)
229 {
230 struct pt_regs *childregs;
231 struct reg_window *old_stack, *new_stack;
232 unsigned long stack_offset;
233
234 #ifndef __SMP__
235 if(last_task_used_math == current) {
236 #else
237 if(current->flags & PF_USEDFPU) {
238 #endif
239 put_psr(get_psr() | PSR_EF);
240 fpsave(&p->tss.float_regs[0], &p->tss.fsr,
241 &p->tss.fpqueue[0], &p->tss.fpqdepth);
242 #ifdef __SMP__
243 current->flags &= ~PF_USEDFPU;
244 #endif
245 }
246
247
248 if(sparc_cpu_model == sun4c)
249 stack_offset = ((PAGE_SIZE*3) - TRACEREG_SZ);
250 else
251 stack_offset = ((PAGE_SIZE<<2) - TRACEREG_SZ);
252
253 if(regs->psr & PSR_PS)
254 stack_offset -= REGWIN_SZ;
255 childregs = ((struct pt_regs *) (p->kernel_stack_page + stack_offset));
256 *childregs = *regs;
257 new_stack = (((struct reg_window *) childregs) - 1);
258 old_stack = (((struct reg_window *) regs) - 1);
259 *new_stack = *old_stack;
260 p->tss.ksp = p->saved_kernel_stack = (unsigned long) new_stack;
261 p->tss.kpc = (((unsigned long) ret_sys_call) - 0x8);
262 p->tss.kpsr = current->tss.fork_kpsr;
263 p->tss.kwim = current->tss.fork_kwim;
264 p->tss.kregs = childregs;
265 childregs->u_regs[UREG_FP] = sp;
266
267 if(regs->psr & PSR_PS) {
268 stack_offset += TRACEREG_SZ;
269 childregs->u_regs[UREG_FP] = p->kernel_stack_page + stack_offset;
270 p->tss.flags |= SPARC_FLAG_KTHREAD;
271 } else
272 p->tss.flags &= ~SPARC_FLAG_KTHREAD;
273
274
275 childregs->u_regs[UREG_I0] = current->pid;
276 childregs->u_regs[UREG_I1] = 1;
277
278
279 regs->u_regs[UREG_I1] = 0;
280 }
281
282
283
284
285 void dump_thread(struct pt_regs * regs, struct user * dump)
286 {
287 unsigned long first_stack_page;
288
289 dump->magic = SUNOS_CORE_MAGIC;
290 dump->len = sizeof(struct user);
291 dump->regs.psr = regs->psr;
292 dump->regs.pc = regs->pc;
293 dump->regs.npc = regs->npc;
294 dump->regs.y = regs->y;
295
296 memcpy(&dump->regs.regs[0], ®s->u_regs[1], (sizeof(unsigned long) * 15));
297 dump->uexec = current->tss.core_exec;
298 dump->u_tsize = (((unsigned long) current->mm->end_code) -
299 ((unsigned long) current->mm->start_code)) & ~(PAGE_SIZE - 1);
300 dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1)));
301 dump->u_dsize -= dump->u_tsize;
302 dump->u_dsize &= ~(PAGE_SIZE - 1);
303 first_stack_page = (regs->u_regs[UREG_FP] & ~(PAGE_SIZE - 1));
304 dump->u_ssize = (TASK_SIZE - first_stack_page) & ~(PAGE_SIZE - 1);
305 memcpy(&dump->fpu.fpstatus.fregs.regs[0], ¤t->tss.float_regs[0], (sizeof(unsigned long) * 32));
306 dump->fpu.fpstatus.fsr = current->tss.fsr;
307 dump->fpu.fpstatus.flags = dump->fpu.fpstatus.extra = 0;
308 dump->fpu.fpstatus.fpq_count = current->tss.fpqdepth;
309 memcpy(&dump->fpu.fpstatus.fpq[0], ¤t->tss.fpqueue[0],
310 ((sizeof(unsigned long) * 2) * 16));
311 dump->sigcode = current->tss.sig_desc;
312 }
313
314
315
316
317 int dump_fpu (void *fpu_structure)
318 {
319
320 return 0;
321 }
322
323
324
325
326
327 asmlinkage int sparc_execve(struct pt_regs *regs)
328 {
329 int error;
330 char *filename;
331
332 flush_user_windows();
333 error = getname((char *) regs->u_regs[UREG_I0], &filename);
334 if(error)
335 return error;
336 error = do_execve(filename, (char **) regs->u_regs[UREG_I1],
337 (char **) regs->u_regs[UREG_I2], regs);
338 putname(filename);
339 return error;
340 }