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