This source file includes following definitions.
- dump_fpu
- switch_to
- sys_idle
- hard_reset_now
- show_regs
- exit_thread
- flush_thread
- copy_thread
- dump_thread
- start_thread
- sys_newselect
- sys_fork
- sys_execve
- sys_clone
- print_backtrace
1
2
3
4
5
6
7
8
9
10
11
12
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
16 #include <linux/mm.h>
17 #include <linux/stddef.h>
18 #include <linux/unistd.h>
19 #include <linux/ptrace.h>
20 #include <linux/malloc.h>
21 #include <linux/ldt.h>
22 #include <linux/user.h>
23 #include <linux/a.out.h>
24
25 #include <asm/pgtable.h>
26 #include <asm/segment.h>
27 #include <asm/system.h>
28 #include <asm/io.h>
29
30 #include <asm/processor.h>
31
32 int dump_fpu (struct user_i387_struct* fpu)
33 {
34 return 1;
35 }
36
37 void
38 switch_to(struct task_struct *new)
39 {
40 struct pt_regs *regs;
41 struct thread_struct *new_tss, *old_tss;
42 int s;
43 regs = (struct pt_regs *)new->tss.ksp;
44
45
46
47
48 s = _disable_interrupts();
49 new_tss = &new->tss;
50 old_tss = ¤t->tss;
51 current = new;
52 _switch(old_tss, new_tss);
53
54
55
56 _enable_interrupts(s);
57 }
58
59 asmlinkage int sys_idle(void)
60 {
61
62 if (current->pid != 0)
63 return -EPERM;
64
65
66 current->counter = -100;
67 for (;;) {
68
69 schedule();
70 }
71 }
72
73 void hard_reset_now(void)
74 {
75 halt();
76 }
77
78 void show_regs(struct pt_regs * regs)
79 {
80 _panic("show_regs");
81 }
82
83
84
85
86 void exit_thread(void)
87 {
88 }
89
90 void flush_thread(void)
91 {
92 }
93
94
95
96
97 void copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
98 struct task_struct * p, struct pt_regs * regs)
99 {
100 int i;
101 SEGREG *segs;
102 struct pt_regs * childregs;
103
104
105
106
107 segs = (SEGREG *)p->tss.segs;
108 for (i = 0; i < 8; i++)
109 {
110 segs[i].ks = 0;
111 segs[i].kp = 1;
112 segs[i].vsid = i | (nr << 4);
113 }
114
115 for (i = 8; i < 16; i++)
116 {
117 segs[i].ks = 0;
118 segs[i].kp = 1;
119 segs[i].vsid = i;
120 }
121
122 childregs = ((struct pt_regs *) (p->kernel_stack_page + 2*PAGE_SIZE)) - 2;
123 *childregs = *regs;
124 childregs->gpr[3] = 0;
125 p->tss.ksp = childregs;
126 if (usp >= (unsigned long)regs)
127 {
128 childregs->gpr[1] = childregs+1;
129 } else
130 {
131 childregs->gpr[1] = usp;
132 }
133 }
134
135
136
137
138 void dump_thread(struct pt_regs * regs, struct user * dump)
139 {
140 }
141
142 #if 0
143
144
145
146 void start_thread(struct pt_regs * regs, unsigned long eip, unsigned long esp)
147 {
148 regs->nip = eip;
149 regs->gpr[1] = esp;
150 regs->msr = MSR_USER;
151 #if 0
152
153
154 printk("Start thread [%x] at PC: %x, SR: %x, SP: %x\n",
155 regs, eip, regs->msr, esp);
156
157
158 #endif
159 }
160 #endif
161
162 asmlinkage int sys_newselect(int p1, int p2, int p3, int p4, int p5, int p6, struct pt_regs *regs)
163 {
164 panic("sys_newselect unimplemented");
165 }
166
167 asmlinkage int sys_fork(int p1, int p2, int p3, int p4, int p5, int p6, struct pt_regs *regs)
168 {
169 printk("process.c: sys_fork() called\n");
170 return do_fork( CLONE_VM|SIGCHLD, regs->gpr[1], regs);
171 }
172
173 asmlinkage int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
174 unsigned long a3, unsigned long a4, unsigned long a5,
175 struct pt_regs *regs)
176 {
177 int error;
178 char * filename;
179
180
181 #if 1
182
183 if ( regs->marker != 0xDEADDEAD )
184 {
185 panic("process.c: sys_execve(): regs->marker != DEADDEAD\n");
186 }
187 #endif
188 error = getname((char *) a0, &filename);
189 if (error)
190 return error;
191 error = do_execve(filename, (char **) a1, (char **) a2, regs);
192 #if 0
193 if (error)
194 {
195 printk("EXECVE - file = '%s', error = %d\n", filename, error);
196 }
197 #endif
198 putname(filename);
199 return error;
200 }
201
202
203 asmlinkage int sys_clone(unsigned long clone_flags, unsigned long usp, unsigned long a2,
204 unsigned long a3, unsigned long a4, unsigned long a5,
205 struct pt_regs *regs)
206 {
207 int i;
208
209 if (!usp)
210 usp = regs->gpr[1];
211
212
213 i = do_fork(CLONE_VM, regs->gpr[1], regs);
214
215 return i;
216 }
217
218
219
220 void
221 print_backtrace(void)
222 {
223 unsigned long *sp = (unsigned long *)_get_SP();
224 int cnt = 0;
225 printk("... Call backtrace:\n");
226 while (*sp)
227 {
228 printk("%08X ", sp[2]);
229 sp = *sp;
230 if (++cnt == 8)
231 {
232 printk("\n");
233 }
234 if (cnt > 16) break;
235 }
236 printk("\n");
237 }
238