2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
13 #include <sys/utsname.h>
14 #include <sys/param.h>
16 #include "asm/types.h"
25 #include "user_util.h"
26 #include "kern_util.h"
30 #include "ptrace_user.h"
31 #include "uml-config.h"
35 while(1) sleep(1000000);
38 void stack_protections(unsigned long address)
40 int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
42 if(mprotect((void *) address, page_size(), prot) < 0)
43 panic("protecting stack failed, errno = %d", errno);
46 void task_protections(unsigned long address)
48 unsigned long guard = address + page_size();
49 unsigned long stack = guard + page_size();
53 if(mprotect((void *) stack, page_size(), prot) < 0)
54 panic("protecting guard page failed, errno = %d", errno);
56 pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
57 prot = PROT_READ | PROT_WRITE | PROT_EXEC;
58 if(mprotect((void *) stack, pages * page_size(), prot) < 0)
59 panic("protecting stack failed, errno = %d", errno);
62 int wait_for_stop(int pid, int sig, int cont_type, void *relay)
64 sigset_t *relay_signals = relay;
68 CATCH_EINTR(ret = waitpid(pid, &status, WUNTRACED));
70 !WIFSTOPPED(status) || (WSTOPSIG(status) != sig)){
72 printk("wait failed, errno = %d\n",
75 else if(WIFEXITED(status))
76 printk("process %d exited with status %d\n",
77 pid, WEXITSTATUS(status));
78 else if(WIFSIGNALED(status))
79 printk("process %d exited with signal %d\n",
80 pid, WTERMSIG(status));
81 else if((WSTOPSIG(status) == SIGVTALRM) ||
82 (WSTOPSIG(status) == SIGALRM) ||
83 (WSTOPSIG(status) == SIGIO) ||
84 (WSTOPSIG(status) == SIGPROF) ||
85 (WSTOPSIG(status) == SIGCHLD) ||
86 (WSTOPSIG(status) == SIGWINCH) ||
87 (WSTOPSIG(status) == SIGINT)){
88 ptrace(cont_type, pid, 0, WSTOPSIG(status));
91 else if((relay_signals != NULL) &&
92 sigismember(relay_signals, WSTOPSIG(status))){
93 ptrace(cont_type, pid, 0, WSTOPSIG(status));
96 else printk("process %d stopped with signal %d\n",
97 pid, WSTOPSIG(status));
98 panic("wait_for_stop failed to wait for %d to stop "
99 "with %d\n", pid, sig);
110 CATCH_EINTR(err = tcgetattr(fd, &tt));
116 CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt));
120 /* XXX tcsetattr could have applied only some changes
121 * (and cfmakeraw() is a set of changes) */
125 void setup_machinename(char *machine_out)
130 #if defined(UML_CONFIG_UML_X86) && !defined(UML_CONFIG_64BIT)
131 if (!strcmp(host.machine, "x86_64")) {
132 strcpy(machine_out, "i686");
136 strcpy(machine_out, host.machine);
139 char host_info[(_UTSNAME_LENGTH + 1) * 4 + _UTSNAME_NODENAME_LENGTH + 1];
141 void setup_hostinfo(void)
146 sprintf(host_info, "%s %s %s %s %s", host.sysname, host.nodename,
147 host.release, host.version, host.machine);
150 int setjmp_wrapper(void (*proc)(void *, void *), ...)
156 n = sigsetjmp(buf, 1);
158 va_start(args, proc);
159 (*proc)(&buf, &args);
166 * Overrides for Emacs so that we follow Linus's tabbing style.
167 * Emacs will notice this stuff at the end of the file and automatically
168 * adjust the settings for this buffer only. This must remain at the end
170 * ---------------------------------------------------------------------------
172 * c-file-style: "linux"