This source file includes following definitions.
- sys_idle
- hard_reset_now
- show_regs
- exit_thread
- flush_thread
- m68k_fork
- m68k_clone
- release_thread
- copy_thread
- dump_fpu
- dump_thread
- sys_execve
1
2
3
4
5
6
7
8
9
10
11 #include <linux/errno.h>
12 #include <linux/sched.h>
13 #include <linux/kernel.h>
14 #include <linux/mm.h>
15 #include <linux/stddef.h>
16 #include <linux/unistd.h>
17 #include <linux/ptrace.h>
18 #include <linux/malloc.h>
19 #include <linux/user.h>
20 #include <linux/a.out.h>
21
22 #include <asm/segment.h>
23 #include <asm/system.h>
24 #include <asm/traps.h>
25 #include <asm/machdep.h>
26
27 asmlinkage void ret_from_exception(void);
28
29
30
31
32 asmlinkage int sys_idle(void)
33 {
34 if (current->pid != 0)
35 return -EPERM;
36
37
38 current->counter = -100;
39 for (;;)
40 schedule();
41 }
42
43 void hard_reset_now(void)
44 {
45 if (mach_reset)
46 mach_reset();
47 }
48
49 void show_regs(struct pt_regs * regs)
50 {
51 printk("\n");
52 printk("Format %02x Vector: %04x PC: %08lx Status: %04x\n",
53 regs->format, regs->vector, regs->pc, regs->sr);
54 printk("ORIG_D0: %08lx D0: %08lx A1: %08lx\n",
55 regs->orig_d0, regs->d0, regs->a1);
56 printk("A0: %08lx D5: %08lx D4: %08lx\n",
57 regs->a0, regs->d5, regs->d4);
58 printk("D3: %08lx D2: %08lx D1: %08lx\n",
59 regs->d3, regs->d2, regs->d1);
60 if (!(regs->sr & PS_S))
61 printk("USP: %08lx\n", rdusp());
62 }
63
64
65
66
67 void exit_thread(void)
68 {
69 }
70
71 void flush_thread(void)
72 {
73 set_fs(USER_DS);
74 current->tss.fs = USER_DS;
75 }
76
77
78
79
80
81
82
83
84 asmlinkage int m68k_fork(struct pt_regs *regs)
85 {
86 return do_fork(SIGCHLD, rdusp(), regs);
87 }
88
89 asmlinkage int m68k_clone(struct pt_regs *regs)
90 {
91 unsigned long clone_flags;
92 unsigned long newsp;
93
94
95 clone_flags = regs->d1;
96 newsp = regs->d2;
97 if (!newsp)
98 newsp = rdusp();
99 return do_fork(clone_flags, newsp, regs);
100 }
101
102 void release_thread(struct task_struct *dead_task)
103 {
104 }
105
106 void copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
107 struct task_struct * p, struct pt_regs * regs)
108 {
109 struct pt_regs * childregs;
110 struct switch_stack * childstack, *stack;
111 unsigned long stack_offset, *retp;
112
113 stack_offset = PAGE_SIZE - sizeof(struct pt_regs);
114 childregs = (struct pt_regs *) (p->kernel_stack_page + stack_offset);
115
116 *childregs = *regs;
117 childregs->d0 = 0;
118
119 retp = ((unsigned long *) regs);
120 stack = ((struct switch_stack *) retp) - 1;
121
122 childstack = ((struct switch_stack *) childregs) - 1;
123 *childstack = *stack;
124 childstack->retpc = (unsigned long) ret_from_exception;
125
126 p->tss.usp = usp;
127 p->tss.ksp = (unsigned long)childstack;
128
129
130 asm volatile ("fsave %0" : : "m" (p->tss.fpstate[0]) : "memory");
131 if (p->tss.fpstate[0])
132 asm volatile ("fmovemx %/fp0-%/fp7,%0\n\t"
133 "fmoveml %/fpiar/%/fpcr/%/fpsr,%1"
134 : : "m" (p->tss.fp[0]), "m" (p->tss.fpcntl[0])
135 : "memory");
136
137 asm volatile ("frestore %0" : : "m" (p->tss.fpstate[0]));
138 }
139
140
141
142 int dump_fpu (struct user_m68kfp_struct *fpu)
143 {
144 char fpustate[216];
145
146
147 asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
148 if (!fpustate[0])
149 return 0;
150
151 asm volatile ("fmovem %/fpiar/%/fpcr/%/fpsr,%0"
152 :: "m" (fpu->fpcntl[0])
153 : "memory");
154 asm volatile ("fmovemx %/fp0-%/fp7,%0"
155 :: "m" (fpu->fpregs[0])
156 : "memory");
157 return 1;
158 }
159
160
161
162
163 void dump_thread(struct pt_regs * regs, struct user * dump)
164 {
165
166 dump->magic = CMAGIC;
167 dump->start_code = 0;
168 dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
169 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
170 dump->u_dsize = ((unsigned long) (current->mm->brk +
171 (PAGE_SIZE-1))) >> PAGE_SHIFT;
172 dump->u_dsize -= dump->u_tsize;
173 dump->u_ssize = 0;
174
175 if (dump->start_stack < TASK_SIZE)
176 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
177
178 dump->u_ar0 = (struct pt_regs *)(((int)(&dump->regs)) -((int)(dump)));
179 dump->regs = *regs;
180 dump->regs2 = ((struct switch_stack *)regs)[-1];
181
182 dump->u_fpvalid = dump_fpu (&dump->m68kfp);
183 }
184
185
186
187
188 asmlinkage int sys_execve(char *name, char **argv, char **envp)
189 {
190 int error;
191 char * filename;
192 struct pt_regs *regs = (struct pt_regs *) &name;
193
194 error = getname(name, &filename);
195 if (error)
196 return error;
197 error = do_execve(filename, argv, envp, regs);
198 putname(filename);
199 return error;
200 }