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 void stack_protections(unsigned long address
)
37 int prot
= PROT_READ
| PROT_WRITE
| PROT_EXEC
;
39 if(mprotect((void *) address
, page_size(), prot
) < 0)
40 panic("protecting stack failed, errno = %d", errno
);
43 void task_protections(unsigned long address
)
45 unsigned long guard
= address
+ page_size();
46 unsigned long stack
= guard
+ page_size();
50 if(mprotect((void *) stack
, page_size(), prot
) < 0)
51 panic("protecting guard page failed, errno = %d", errno
);
53 pages
= (1 << UML_CONFIG_KERNEL_STACK_ORDER
) - 2;
54 prot
= PROT_READ
| PROT_WRITE
| PROT_EXEC
;
55 if(mprotect((void *) stack
, pages
* page_size(), prot
) < 0)
56 panic("protecting stack failed, errno = %d", errno
);
64 CATCH_EINTR(err
= tcgetattr(fd
, &tt
));
70 CATCH_EINTR(err
= tcsetattr(fd
, TCSADRAIN
, &tt
));
74 /* XXX tcsetattr could have applied only some changes
75 * (and cfmakeraw() is a set of changes) */
79 void setup_machinename(char *machine_out
)
84 #if defined(UML_CONFIG_UML_X86) && !defined(UML_CONFIG_64BIT)
85 if (!strcmp(host
.machine
, "x86_64")) {
86 strcpy(machine_out
, "i686");
90 strcpy(machine_out
, host
.machine
);
93 char host_info
[(_UTSNAME_LENGTH
+ 1) * 4 + _UTSNAME_NODENAME_LENGTH
+ 1];
95 void setup_hostinfo(void)
100 sprintf(host_info
, "%s %s %s %s %s", host
.sysname
, host
.nodename
,
101 host
.release
, host
.version
, host
.machine
);
104 int setjmp_wrapper(void (*proc
)(void *, void *), ...)
110 n
= sigsetjmp(buf
, 1);
112 va_start(args
, proc
);
113 (*proc
)(&buf
, &args
);