2 * linux/arch/parisc/kernel/process.c
3 * based on the work for i386
7 * This file handles the architecture-dependent parts of process handling..
10 #define __KERNEL_SYSCALLS__
13 #include <linux/elf.h>
14 #include <linux/errno.h>
15 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/personality.h>
19 #include <linux/ptrace.h>
20 #include <linux/sched.h>
21 #include <linux/stddef.h>
22 #include <linux/unistd.h>
25 #include <asm/offsets.h>
27 #include <asm/pdc_chassis.h>
28 #include <asm/pgalloc.h>
29 #include <asm/uaccess.h>
34 * Power off function, if any
36 void (*pm_power_off)(void);
38 void disable_hlt(void)
43 EXPORT_SYMBOL(disable_hlt);
50 EXPORT_SYMBOL(enable_hlt);
52 void default_idle(void)
58 * The idle thread. There's no useful work to be
59 * done, so just try to conserve power and have a
60 * low exit latency (ie sit in a loop waiting for
61 * somebody to say that they'd like to reschedule)
65 /* endless idle loop with no priority at all */
67 while (!need_resched())
76 #define COMMAND_GLOBAL 0xfffffffffffe0030UL
78 #define COMMAND_GLOBAL 0xfffe0030
81 #define CMD_RESET 5 /* reset any module */
84 ** The Wright Brothers and Gecko systems have a H/W problem
85 ** (Lasi...'nuf said) may cause a broadcast reset to lockup
86 ** the system. An HVERSION dependent PDC call was developed
87 ** to perform a "safe", platform specific broadcast reset instead
88 ** of kludging up all the code.
90 ** Older machines which do not implement PDC_BROADCAST_RESET will
91 ** return (with an error) and the regular broadcast reset can be
92 ** issued. Obviously, if the PDC does implement PDC_BROADCAST_RESET
93 ** the PDC call will not return (the system will be reset).
95 void machine_restart(char *cmd)
97 #ifdef FASTBOOT_SELFTEST_SUPPORT
99 ** If user has modified the Firmware Selftest Bitmap,
100 ** run the tests specified in the bitmap after the
101 ** system is rebooted w/PDC_DO_RESET.
103 ** ftc_bitmap = 0x1AUL "Skip destructive memory tests"
105 ** Using "directed resets" at each processor with the MEM_TOC
106 ** vector cleared will also avoid running destructive
107 ** memory self tests. (Not implemented yet)
110 pdc_do_firm_test_reset(ftc_bitmap);
113 /* set up a new led state on systems shipped with a LED State panel */
114 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);
116 /* "Normal" system reset */
119 /* Nope...box should reset with just CMD_RESET now */
120 gsc_writel(CMD_RESET, COMMAND_GLOBAL);
122 /* Wait for RESET to lay us to rest. */
127 EXPORT_SYMBOL(machine_restart);
129 void machine_halt(void)
132 ** The LED/ChassisCodes are updated by the led_halt()
133 ** function, called by the reboot notifier chain.
137 EXPORT_SYMBOL(machine_halt);
141 * This routine is called from sys_reboot to actually turn off the
144 void machine_power_off(void)
146 /* If there is a registered power off handler, call it. */
150 /* Put the soft power button back under hardware control.
151 * If the user had already pressed the power button, the
152 * following call will immediately power off. */
153 pdc_soft_power_button(0);
155 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);
157 /* It seems we have no way to power the system off via
158 * software. The user has to press the button himself. */
160 printk(KERN_EMERG "System shut down completed.\n"
161 KERN_EMERG "Please power this system off now.");
164 EXPORT_SYMBOL(machine_power_off);
168 * Create a kernel thread
171 extern pid_t __kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
172 pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
176 * FIXME: Once we are sure we don't need any debug here,
177 * kernel_thread can become a #define.
180 return __kernel_thread(fn, arg, flags);
184 * Free current thread data structures etc..
186 void exit_thread(void)
190 void flush_thread(void)
192 /* Only needs to handle fpu stuff or perf monitors.
193 ** REVISIT: several arches implement a "lazy fpu state".
198 void release_thread(struct task_struct *dead_task)
203 * Fill in the FPU structure for a core dump.
206 int dump_fpu (struct pt_regs * regs, elf_fpregset_t *r)
211 memcpy(r, regs->fr, sizeof *r);
215 int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r)
217 memcpy(r, tsk->thread.regs.fr, sizeof(*r));
221 /* Note that "fork()" is implemented in terms of clone, with
222 parameters (SIGCHLD, regs->gr[30], regs). */
224 sys_clone(unsigned long clone_flags, unsigned long usp,
225 struct pt_regs *regs)
227 int *user_tid = (int *)regs->gr[26];
228 return do_fork(clone_flags & ~CLONE_IDLETASK, usp, regs, 0, user_tid, NULL);
232 sys_vfork(struct pt_regs *regs)
234 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->gr[30], regs, 0, NULL, NULL);
238 copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
239 unsigned long unused, /* in ia64 this is "user_stack_size" */
240 struct task_struct * p, struct pt_regs * pregs)
242 struct pt_regs * cregs = &(p->thread.regs);
243 struct thread_info *ti = p->thread_info;
245 /* We have to use void * instead of a function pointer, because
246 * function pointers aren't a pointer to the function on 64-bit.
247 * Make them const so the compiler knows they live in .text */
248 extern void * const ret_from_kernel_thread;
249 extern void * const child_return;
251 extern void * const hpux_child_return;
256 /* Set the return value for the child. Note that this is not
257 actually restored by the syscall exit path, but we put it
258 here for consistency in case of signals. */
259 cregs->gr[28] = 0; /* child */
262 * We need to differentiate between a user fork and a
263 * kernel fork. We can't use user_mode, because the
264 * the syscall path doesn't save iaoq. Right now
265 * We rely on the fact that kernel_thread passes
270 cregs->ksp = (((unsigned long)(ti)) + THREAD_SZ_ALGN);
271 /* Must exit via ret_from_kernel_thread in order
272 * to call schedule_tail()
274 cregs->kpc = (unsigned long) &ret_from_kernel_thread;
276 * Copy function and argument to be called from
277 * ret_from_kernel_thread.
280 cregs->gr[27] = pregs->gr[27];
282 cregs->gr[26] = pregs->gr[26];
283 cregs->gr[25] = pregs->gr[25];
287 * Note that the fork wrappers are responsible
288 * for setting gr[21].
291 /* Use same stack depth as parent */
292 cregs->ksp = ((unsigned long)(ti))
293 + (pregs->gr[21] & (INIT_THREAD_SIZE - 1));
295 if (p->personality == PER_HPUX) {
297 cregs->kpc = (unsigned long) &hpux_child_return;
302 cregs->kpc = (unsigned long) &child_return;
309 unsigned long thread_saved_pc(struct task_struct *t)
311 return t->thread.regs.kpc;
315 * sys_execve() executes a new program.
318 asmlinkage int sys_execve(struct pt_regs *regs)
323 filename = getname((char *) regs->gr[26]);
324 error = PTR_ERR(filename);
325 if (IS_ERR(filename))
327 error = do_execve(filename, (char **) regs->gr[25],
328 (char **) regs->gr[24], regs);
330 current->ptrace &= ~PT_DTRACE;