added a lot of printk output to ease writing of emulator
[linux-2.4.21-pre4.git] / include / linux / personality.h
1 #ifndef _LINUX_PERSONALITY_H
2 #define _LINUX_PERSONALITY_H
3
4 /*
5  * Handling of different ABIs (personalities).
6  */
7
8 struct exec_domain;
9 struct pt_regs;
10
11 extern int              register_exec_domain(struct exec_domain *);
12 extern int              unregister_exec_domain(struct exec_domain *);
13 extern int              __set_personality(unsigned long);
14
15
16 /*
17  * Sysctl variables related to binary emulation.
18  */
19 extern unsigned long abi_defhandler_coff;
20 extern unsigned long abi_defhandler_elf;
21 extern unsigned long abi_defhandler_lcall7;
22 extern unsigned long abi_defhandler_libcso;
23 extern int abi_fake_utsname;
24
25
26 /*
27  * Flags for bug emulation.
28  *
29  * These occupy the top three bytes.
30  */
31 enum {
32         MMAP_PAGE_ZERO =        0x0100000,
33         ADDR_LIMIT_32BIT =      0x0800000,
34         SHORT_INODE =           0x1000000,
35         WHOLE_SECONDS =         0x2000000,
36         STICKY_TIMEOUTS =       0x4000000,
37 };
38
39 /*
40  * Personality types.
41  *
42  * These go in the low byte.  Avoid using the top bit, it will
43  * conflict with error returns.
44  */
45 enum {
46         PER_LINUX =             0x0000,
47         PER_LINUX_32BIT =       0x0000 | ADDR_LIMIT_32BIT,
48         PER_SVR4 =              0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
49         PER_SVR3 =              0x0002 | STICKY_TIMEOUTS | SHORT_INODE,
50         PER_SCOSVR3 =           0x0003 | STICKY_TIMEOUTS |
51                                          WHOLE_SECONDS | SHORT_INODE,
52         PER_OSR5 =              0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,
53         PER_WYSEV386 =          0x0004 | STICKY_TIMEOUTS | SHORT_INODE,
54         PER_ISCR4 =             0x0005 | STICKY_TIMEOUTS,
55         PER_BSD =               0x0006,
56         PER_SUNOS =             0x0006 | STICKY_TIMEOUTS,
57         PER_XENIX =             0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
58         PER_LINUX32 =           0x0008,
59         PER_IRIX32 =            0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
60         PER_IRIXN32 =           0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
61         PER_IRIX64 =            0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
62         PER_RISCOS =            0x000c,
63         PER_SOLARIS =           0x000d | STICKY_TIMEOUTS,
64         PER_UW7 =               0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
65         PER_HPUX =              0x000f,
66         PER_OSF4 =              0x0010,                  /* OSF/1 v4 */
67         PER_MASK =              0x00ff,
68 };
69
70
71 /*
72  * Description of an execution domain.
73  * 
74  * The first two members are refernced from assembly source
75  * and should stay where they are unless explicitly needed.
76  */
77 typedef void (*handler_t)(int, struct pt_regs *);
78
79 struct exec_domain {
80         const char              *name;          /* name of the execdomain */
81         handler_t               handler;        /* handler for syscalls */
82         unsigned char           pers_low;       /* lowest personality */
83         unsigned char           pers_high;      /* highest personality */
84         unsigned long           *signal_map;    /* signal mapping */
85         unsigned long           *signal_invmap; /* reverse signal mapping */
86         struct map_segment      *err_map;       /* error mapping */
87         struct map_segment      *socktype_map;  /* socket type mapping */
88         struct map_segment      *sockopt_map;   /* socket option mapping */
89         struct map_segment      *af_map;        /* address family mapping */
90         struct module           *module;        /* module context of the ed. */
91         struct exec_domain      *next;          /* linked list (internal) */
92 };
93
94 /*
95  * Return the base personality without flags.
96  */
97 #define personality(pers)       (pers & PER_MASK)
98
99 /*
100  * Personality of the currently running process.
101  */
102 #define get_personality         (current->personality)
103
104 /*
105  * Change personality of the currently running process.
106  */
107 #define set_personality(pers) \
108         ((current->personality == pers) ? 0 : __set_personality(pers))
109
110 /*
111  * Load an execution domain.
112  */
113 #define get_exec_domain(ep)                             \
114 do {                                                    \
115         if (ep != NULL && ep->module != NULL)           \
116                 __MOD_INC_USE_COUNT(ep->module);        \
117 } while (0)
118
119 /*
120  * Unload an execution domain.
121  */
122 #define put_exec_domain(ep)                             \
123 do {                                                    \
124         if (ep != NULL && ep->module != NULL)           \
125                 __MOD_DEC_USE_COUNT(ep->module);        \
126 } while (0)
127
128 #endif /* _LINUX_PERSONALITY_H */