This source file includes following definitions.
- sys_idle
- hard_reset_now
- show_regwindow
- show_regs
- exit_thread
- release_thread
- flush_thread
- copy_thread
- dump_thread
- dump_fpu
- sparc_execve
- start_thread
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/ldt.h>
20 #include <linux/user.h>
21 #include <linux/a.out.h>
22
23 #include <asm/auxio.h>
24 #include <asm/oplib.h>
25 #include <asm/segment.h>
26 #include <asm/system.h>
27 #include <asm/page.h>
28 #include <asm/pgtable.h>
29 #include <asm/processor.h>
30 #include <asm/psr.h>
31
32 int current_user_segment = USER_DS;
33
34
35
36
37 asmlinkage int sys_idle(void)
38 {
39 if (current->pid != 0)
40 return -EPERM;
41
42
43 current->counter = -100;
44 for (;;) {
45 schedule();
46 }
47 }
48
49 void hard_reset_now(void)
50 {
51 prom_halt();
52 }
53
54 void show_regwindow(struct reg_window *rw)
55 {
56 printk("l0:%08lx l1:%08lx l2:%08lx l3:%08lx l4:%08lx l5:%08lx l6:%08lx l7:%08lx\n",
57 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
58 rw->locals[4], rw->locals[5], rw->locals[6], rw->locals[7]);
59 printk("i0:%08lx i1:%08lx i2:%08lx i3:%08lx i4:%08lx i5:%08lx i6:%08lx i7:%08lx\n",
60 rw->ins[0], rw->ins[1], rw->ins[2], rw->ins[3],
61 rw->ins[4], rw->ins[5], rw->ins[6], rw->ins[7]);
62 }
63
64 void show_regs(struct pt_regs * regs)
65 {
66 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx\n", regs->psr,
67 regs->pc, regs->npc, regs->y);
68 printk("%%g0: %08lx %%g1: %08lx %%g2: %08lx %%g3: %08lx\n",
69 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
70 regs->u_regs[3]);
71 printk("%%g4: %08lx %%g5: %08lx %%g6: %08lx %%g7: %08lx\n",
72 regs->u_regs[4], regs->u_regs[5], regs->u_regs[6],
73 regs->u_regs[7]);
74 printk("%%o0: %08lx %%o1: %08lx %%o2: %08lx %%o3: %08lx\n",
75 regs->u_regs[8], regs->u_regs[9], regs->u_regs[10],
76 regs->u_regs[11]);
77 printk("%%o4: %08lx %%o5: %08lx %%sp: %08lx %%ret_pc: %08lx\n",
78 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
79 regs->u_regs[15]);
80 }
81
82
83
84
85 void exit_thread(void)
86 {
87 if(last_task_used_math == current)
88 last_task_used_math = NULL;
89 mmu_exit_hook(current);
90 }
91
92
93
94
95 void release_thread(struct task_struct *dead_task)
96 {
97 mmu_release_hook(dead_task);
98 }
99
100 void flush_thread(void)
101 {
102
103 mmu_flush_hook(current);
104 flush_user_windows();
105 current->signal &= ~(1<<(SIGILL-1));
106 current->tss.w_saved = 0;
107 current->tss.uwinmask = 0;
108
109 current->tss.sig_address = 0;
110 current->tss.sig_desc = 0;
111
112
113 current->tss.sstk_info.cur_status = 0;
114 current->tss.sstk_info.the_stack = 0;
115
116 memset(¤t->tss.reg_window[0], 0,
117 (sizeof(struct reg_window) * NSWINS));
118 memset(¤t->tss.rwbuf_stkptrs[0], 0,
119 (sizeof(unsigned long) * NSWINS));
120 }
121
122
123
124
125
126
127
128
129
130 extern void ret_sys_call(void);
131
132 void copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
133 struct task_struct *p, struct pt_regs *regs)
134 {
135 struct pt_regs *childregs;
136 struct sparc_stackf *old_stack, *new_stack;
137 unsigned long stack_offset, kthread_usp = 0;
138
139 mmu_task_cacheflush(current);
140 p->tss.context = -1;
141
142
143 stack_offset = (PAGE_SIZE - TRACEREG_SZ);
144 childregs = ((struct pt_regs *) (p->kernel_stack_page + stack_offset));
145 *childregs = *regs;
146 new_stack = (((struct sparc_stackf *) childregs) - 1);
147 old_stack = (((struct sparc_stackf *) regs) - 1);
148 *new_stack = *old_stack;
149 p->tss.ksp = (unsigned long) new_stack;
150 p->tss.kpc = (((unsigned long) ret_sys_call) - 0x8);
151
152
153
154
155
156
157
158 if(regs->psr & PSR_PS) {
159 unsigned long n_stack = get_free_page(GFP_KERNEL);
160 childregs->u_regs[UREG_FP] = (n_stack | (sp & 0xfff));
161 memcpy((char *)n_stack,(char *)(sp & PAGE_MASK),PAGE_SIZE);
162 kthread_usp = n_stack;
163 }
164
165
166 childregs->u_regs[UREG_I0] = current->pid;
167 childregs->u_regs[UREG_I1] = 1;
168
169
170 regs->u_regs[UREG_I1] = 0;
171
172 mmu_fork_hook(p, kthread_usp);
173 }
174
175
176
177
178 void dump_thread(struct pt_regs * regs, struct user * dump)
179 {
180 }
181
182
183
184
185 int dump_fpu (void *fpu_structure)
186 {
187
188 return 0;
189 }
190
191
192
193
194
195 asmlinkage int sparc_execve(struct pt_regs *regs)
196 {
197 int error;
198 char *filename;
199
200 flush_user_windows();
201 mmu_task_cacheflush(current);
202 error = getname((char *) regs->u_regs[UREG_I0], &filename);
203 if(error)
204 return error;
205 error = do_execve(filename, (char **) regs->u_regs[UREG_I1],
206 (char **) regs->u_regs[UREG_I2], regs);
207 putname(filename);
208 return error;
209 }
210
211 void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
212 {
213 unsigned long saved_psr = (regs->psr & (PSR_CWP)) | PSR_S;
214
215 memset(regs, 0, sizeof(struct pt_regs));
216 regs->pc = ((pc & (~3)) - 4);
217 regs->npc = regs->pc + 4;
218 regs->psr = saved_psr;
219 regs->u_regs[UREG_G1] = sp;
220
221
222 regs->u_regs[UREG_G2] = regs->u_regs[UREG_G7] = regs->npc;
223
224
225
226
227
228
229
230
231 sp -= REGWIN_SZ;
232 regs->u_regs[UREG_FP] = sp;
233 }