2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
12 #include <sys/utsname.h>
13 #include <sys/param.h>
15 #include "asm/types.h"
24 #include "kern_util.h"
28 #include "ptrace_user.h"
29 #include "uml-config.h"
33 void stack_protections(unsigned long address)
35 int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
37 if(mprotect((void *) address, page_size(), prot) < 0)
38 panic("protecting stack failed, errno = %d", errno);
41 void task_protections(unsigned long address)
43 unsigned long guard = address + page_size();
44 unsigned long stack = guard + page_size();
48 if(mprotect((void *) stack, page_size(), prot) < 0)
49 panic("protecting guard page failed, errno = %d", errno);
51 pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
52 prot = PROT_READ | PROT_WRITE | PROT_EXEC;
53 if(mprotect((void *) stack, pages * page_size(), prot) < 0)
54 panic("protecting stack failed, errno = %d", errno);
62 CATCH_EINTR(err = tcgetattr(fd, &tt));
68 CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt));
72 /* XXX tcsetattr could have applied only some changes
73 * (and cfmakeraw() is a set of changes) */
77 void setup_machinename(char *machine_out)
82 #ifdef UML_CONFIG_UML_X86
83 # ifndef UML_CONFIG_64BIT
84 if (!strcmp(host.machine, "x86_64")) {
85 strcpy(machine_out, "i686");
89 if (!strcmp(host.machine, "i686")) {
90 strcpy(machine_out, "x86_64");
95 strcpy(machine_out, host.machine);
98 void setup_hostinfo(char *buf, int len)
103 snprintf(buf, len, "%s %s %s %s %s", host.sysname, host.nodename,
104 host.release, host.version, host.machine);
107 int setjmp_wrapper(void (*proc)(void *, void *), ...)
113 n = UML_SETJMP(&buf);
115 va_start(args, proc);
116 (*proc)(&buf, &args);