Minimal changes to get m6502 to compile (won't work)
[Apout.git] / bsdtrap.h
1 /* bsdtrap.h. Definitions for values and structures used in bsdtrap.c
2  *
3  * $Revision: 1.30 $
4  * $Date: 1999/03/01 19:14:16 $
5  */
6
7 /* In this file, we list the trap number for each system call,
8  * and the structures associated with several of the systems
9  * calls in 2.11BSD UNIX
10  */
11
12 #define S_INDIR         0
13 #define S_EXIT          1
14 #define S_FORK          2
15 #define S_READ          3
16 #define S_WRITE         4
17 #define S_OPEN          5
18 #define S_CLOSE         6
19 #define S_WAIT4         7
20 #define S_CREAT         8
21 #define S_LINK          9
22 #define S_UNLINK        10
23 #define S_EXECV         11
24 #define S_CHDIR         12
25 #define S_FCHDIR        13
26 #define S_MKNOD         14
27 #define S_CHMOD         15
28 #define S_CHOWN         16
29 #define S_CHFLAGS       17
30 #define S_FCHFLAGS      18
31 #define S_LSEEK         19
32 #define S_GETPID        20
33 #define S_MOUNT         21
34 #define S_UMOUNT        22
35 #define S_SYSCTL        23
36 #define S_GETUID        24
37 #define S_GETEUID       25
38 #define S_PTRACE        26
39 #define S_GETPPID       27
40 #define S_STATFS        28
41 #define S_FSTATFS       29
42 #define S_GETFSSTAT     30
43 #define S_SIGACTION     31
44 #define S_SIGPROCMASK   32
45 #define S_ACCESS        33
46 #define S_SIGPENDING    34
47 #define S_SIGALTSTACK   35
48 #define S_SYNC          36
49 #define S_KILL          37
50 #define S_STAT          38
51 #define S_GETLOGIN      39
52 #define S_LSTAT         40
53 #define S_DUP           41
54 #define S_PIPE          42
55 #define S_SETLOGIN      43
56 #define S_PROFIL        44
57 #define S_SETUID        45
58 #define S_SETEUID       46
59 #define S_GETGID        47
60 #define S_GETEGID       48
61 #define S_SETGID        49
62 #define S_SETEGID       50
63 #define S_ACCT          51
64 #define S_OLDPHYS       52
65 #define S_OLDLOCK       53
66 #define S_IOCTL         54
67 #define S_REBOOT        55
68 #define S_SYMLINK       57
69 #define S_READLINK      58
70 #define S_EXECVE        59
71 #define S_UMASK         60
72 #define S_CHROOT        61
73 #define S_FSTAT         62
74 #define S_GETPAGESIZE   64
75 #define S_VFORK         66
76 #define S_SBRK          69
77 #define S_VHANGUP       76
78 #define S_GETGROUPS     79
79 #define S_SETGROUPS     80
80 #define S_GETPGRP       81
81 #define S_SETPGRP       82
82 #define S_SETITIMER     83
83 #define S_WAIT          84
84 #define S_GETITIMER     86
85 #define S_GETHOSTNAME   87
86 #define S_SETHOSTNAME   88
87 #define S_GETDTABLESIZE 89
88 #define S_DUP2          90
89 #define S_UNUSED1       91
90 #define S_FCNTL         92
91 #define S_SELECT        93
92 #define S_UNUSED2       94
93 #define S_FSYNC         95
94 #define S_SETPRIORITY   96
95 #define S_SOCKET        97
96 #define S_CONNECT       98
97 #define S_ACCEPT        99
98 #define S_GETPRIORITY   100
99 #define S_SEND          101
100 #define S_RECV          102
101 #define S_SIGRETURN     103
102 #define S_BIND          104
103 #define S_SETSOCKOPT    105
104 #define S_LISTEN        106
105 #define S_SIGSUSPEND    107
106 #define S_SIGVEC        108
107 #define S_SIGBLOCK      109
108 #define S_SIGSETMASK    110
109 #define S_SIGPAUSE      111
110 #define S_SIGSTACK      112
111 #define S_RECVMSG       113
112 #define S_SENDMSG       114
113 #define S_GETTIMEOFDAY  116
114 #define S_GETRUSAGE     117
115 #define S_GETSOCKOPT    118
116 #define S_READV         120
117 #define S_WRITEV        121
118 #define S_SETTIMEOFDAY  122
119 #define S_FCHOWN        123
120 #define S_FCHMOD        124
121 #define S_RECVFROM      125
122 #define S_SETREUID      126
123 #define S_SETREGID      127
124 #define S_RENAME        128
125 #define S_TRUNCATE      129
126 #define S_FTRUNCATE     130
127 #define S_FLOCK         131
128 #define S_SENDTO        133
129 #define S_SHUTDOWN      134
130 #define S_SOCKETPAIR    135
131 #define S_MKDIR         136
132 #define S_RMDIR         137
133 #define S_UTIMES        138
134 #define S_ADJTIME       140
135 #define S_GETPEERNAME   141
136 #define S_GETHOSTID     142
137 #define S_SETHOSTID     143
138 #define S_GETRLIMIT     144
139 #define S_SETRLIMIT     145
140 #define S_KILLPG        146
141 #define S_NOSYS147      147
142 #define S_SETQUOTA      148
143 #define S_QUOTA         149
144 #define S_GETSOCKNAME   150
145
146
147 /*
148  * System call names.
149  */
150 #ifdef BSDTRAP_NAME
151 char *bsdtrap_name[] = {
152     "indir",                    /*   0 = indir */
153     "exit",                     /*   1 = exit */
154     "fork",                     /*   2 = fork */
155     "read",                     /*   3 = read */
156     "write",                    /*   4 = write */
157     "open",                     /*   5 = open */
158     "close",                    /*   6 = close */
159     "wait4",                    /*   7 = wait4 */
160     "creat",                    /*   8 = creat */
161     "link",                     /*   9 = link */
162     "unlink",                   /*  10 = unlink */
163     "execv",                    /*  11 = execv */
164     "chdir",                    /*  12 = chdir */
165     "fchdir",                   /*  13 = fchdir */
166     "mknod",                    /*  14 = mknod */
167     "chmod",                    /*  15 = chmod */
168     "chown",                    /*  16 = chown; now 3 args */
169     "chflags",                  /*  17 = chflags */
170     "fchflags",                 /*  18 = fchflags */
171     "lseek",                    /*  19 = lseek */
172     "getpid",                   /*  20 = getpid */
173     "mount",                    /*  21 = mount */
174     "umount",                   /*  22 = umount */
175     "__sysctl",                 /*  23 = __sysctl */
176     "getuid",                   /*  24 = getuid */
177     "geteuid",                  /*  25 = geteuid */
178     "ptrace",                   /*  26 = ptrace */
179     "getppid",                  /*  27 = getppid */
180     "statfs",                   /*  28 = statfs */
181     "fstatfs",                  /*  29 = fstatfs */
182     "getfsstat",                /*  30 = getfsstat */
183     "sigaction",                /*  31 = sigaction */
184     "sigprocmask",              /*  32 = sigprocmask */
185     "access",                   /*  33 = access */
186     "sigpending",               /*  34 = sigpending */
187     "sigaltstack",              /*  35 = sigaltstack */
188     "sync",                     /*  36 = sync */
189     "kill",                     /*  37 = kill */
190     "stat",                     /*  38 = stat */
191     "getlogin",                 /*  39 = getlogin */
192     "lstat",                    /*  40 = lstat */
193     "dup",                      /*  41 = dup */
194     "pipe",                     /*  42 = pipe */
195     "setlogin",                 /*  43 = setlogin */
196     "profil",                   /*  44 = profil */
197     "setuid",                   /*  45 = setuid */
198     "seteuid",                  /*  46 = seteuid */
199     "getgid",                   /*  47 = getgid */
200     "getegid",                  /*  48 = getegid */
201     "setgid",                   /*  49 = setgid */
202     "setegid",                  /*  50 = setegid */
203     "acct",                     /*  51 = turn acct off/on */
204     "old phys",                 /*  52 = old set phys addr */
205     "old lock",                 /*  53 = old lock in core */
206     "ioctl",                    /*  54 = ioctl */
207     "reboot",                   /*  55 = reboot */
208     "old mpx - nosys",          /*  56 = old mpxchan */
209     "symlink",                  /*  57 = symlink */
210     "readlink",                 /*  58 = readlink */
211     "execve",                   /*  59 = execve */
212     "umask",                    /*  60 = umask */
213     "chroot",                   /*  61 = chroot */
214     "fstat",                    /*  62 = fstat */
215     "#63",                      /*  63 = used internally */
216     "getpagesize",              /*  64 = getpagesize */
217     "4.3 mremap - nosys",       /*  65 = mremap */
218     "vfork",                    /*  66 = vfork */
219     "old vread - nosys",        /*  67 = old vread */
220     "old vwrite - nosys",       /*  68 = old vwrite */
221     "sbrk",                     /*  69 = sbrk */
222     "4.3 sstk - nosys",         /*  70 = sstk */
223     "4.3 mmap - nosys",         /*  71 = mmap */
224     "old vadvise - nosys",      /*  72 = old vadvise */
225     "4.3 munmap - nosys",       /*  73 = munmap */
226     "4.3 mprotect - nosys",     /*  74 = mprotect */
227     "4.3 madvise - nosys",      /*  75 = madvise */
228     "vhangup",                  /*  76 = vhangup */
229     "old vlimit - nosys",       /*  77 = old vlimit */
230     "4.3 mincore - nosys",      /*  78 = mincore */
231     "getgroups",                /*  79 = getgroups */
232     "setgroups",                /*  80 = setgroups */
233     "getpgrp",                  /*  81 = getpgrp */
234     "setpgrp",                  /*  82 = setpgrp */
235     "setitimer",                /*  83 = setitimer */
236     "wait",                     /*  84 = wait */
237     "4.3 swapon - nosys",       /*  85 = swapon */
238     "getitimer",                /*  86 = getitimer */
239     "gethostname",              /*  87 = gethostname */
240     "sethostname",              /*  88 = sethostname */
241     "getdtablesize",            /*  89 = getdtablesize */
242     "dup2",                     /*  90 = dup2 */
243     "nosys",                    /*  91 = unused */
244     "fcntl",                    /*  92 = fcntl */
245     "select",                   /*  93 = select */
246     "nosys",                    /*  94 = unused */
247     "fsync",                    /*  95 = fsync */
248     "setpriority",              /*  96 = setpriority */
249     "socket",                   /*  97 = socket */
250     "connect",                  /*  98 = connect */
251     "accept",                   /*  99 = accept */
252     "getpriority",              /* 100 = getpriority */
253     "send",                     /* 101 = send */
254     "recv",                     /* 102 = recv */
255     "sigreturn",                /* 103 = sigreturn */
256     "bind",                     /* 104 = bind */
257     "setsockopt",               /* 105 = setsockopt */
258     "listen",                   /* 106 = listen */
259     "sigsuspend",               /* 107 = sigsuspend */
260     "sigvec",                   /* 108 = sigvec */
261     "sigblock",                 /* 109 = sigblock */
262     "sigsetmask",               /* 110 = sigsetmask */
263     "sigpause",                 /* 111 = sigpause */
264     "sigstack",                 /* 112 = sigstack */
265     "recvmsg",                  /* 113 = recvmsg */
266     "sendmsg",                  /* 114 = sendmsg */
267     "old vtrace - nosys",       /* 115 = old vtrace */
268     "gettimeofday",             /* 116 = gettimeofday */
269     "getrusage",                /* 117 = getrusage */
270     "getsockopt",               /* 118 = getsockopt */
271     "4.3 resuba - nosys",       /* 119 = resuba */
272     "readv",                    /* 120 = readv */
273     "writev",                   /* 121 = writev */
274     "settimeofday",             /* 122 = settimeofday */
275     "fchown",                   /* 123 = fchown */
276     "fchmod",                   /* 124 = fchmod */
277     "recvfrom",                 /* 125 = recvfrom */
278     "setreuid",                 /* 126 = setreuid */
279     "setregid",                 /* 127 = setregid */
280     "rename",                   /* 128 = rename */
281     "truncate",                 /* 129 = truncate */
282     "ftruncate",                /* 130 = ftruncate */
283     "flock",                    /* 131 = flock */
284     "old portal - nosys",       /* 132 = old portal */
285     "sendto",                   /* 133 = sendto */
286     "shutdown",                 /* 134 = shutdown */
287     "socketpair",               /* 135 = socketpair */
288     "mkdir",                    /* 136 = mkdir */
289     "rmdir",                    /* 137 = rmdir */
290     "utimes",                   /* 138 = utimes */
291     "4.2 sigreturn - nosys",    /* 139 = old 4.2 sigreturn */
292     "adjtime",                  /* 140 = adjtime */
293     "getpeername",              /* 141 = getpeername */
294     "gethostid",                /* 142 = gethostid */
295     "sethostid",                /* 143 = sethostid */
296     "getrlimit",                /* 144 = getrlimit */
297     "setrlimit",                /* 145 = setrlimit */
298     "killpg",                   /* 146 = killpg */
299     "#147",                     /* 147 = nosys */
300     "setquota",                 /* 148 = setquota */
301     "quota",                    /* 149 = quota */
302     "getsockname",              /* 150 = getsockname */
303 };
304 #endif
305
306 /* fcntl defines used by open */
307 #define BSD_RDONLY        0x0000        /* open for reading only */
308 #define BSD_WRONLY        0x0001        /* open for writing only */
309 #define BSD_RDWR          0x0002        /* open for reading and writing */
310 #define BSD_NONBLOCK      0x0004        /* no delay */
311 #define BSD_APPEND        0x0008        /* set append mode */
312 #define BSD_SHLOCK        0x0010        /* open with shared file lock */
313 #define BSD_EXLOCK        0x0020        /* open with exclusive file lock */
314 #define BSD_ASYNC         0x0040        /* signal pgrp when data ready */
315 #define BSD_FSYNC         0x0080        /* synchronous writes */
316 #define BSD_CREAT         0x0200        /* create if nonexistant */
317 #define BSD_TRUNC         0x0400        /* truncate to zero length */
318 #define BSD_EXCL          0x0800        /* error if already exists */
319
320
321 /* stat struct, used by S_STAT, S_FSTAT, S_LSTAT */
322 struct tr_stat {
323     int16_t st_dev;
324     u_int16_t st_ino;
325     u_int16_t st_mode;
326     int16_t st_nlink;
327     u_int16_t st_uid;
328     u_int16_t st_gid;
329     int16_t st_rdev;
330     int8_t st_size[4];          /* Alignment problems */
331     int8_t st_atim[4];          /* Alignment problems */
332     int16_t st_spare1;
333     int8_t st_mtim[4];          /* Alignment problems */
334     int16_t st_spare2;
335     int8_t st_ctim[4];          /* Alignment problems */
336     int16_t st_spare3;
337     int8_t st_blksize[4];       /* Alignment problems */
338     int8_t st_blocks[4];        /* Alignment problems */
339     u_int16_t st_flags;
340     u_int16_t st_spare4[3];
341 };
342
343 /* Directory entry */
344 #define TR_DIRBLKSIZ    512
345 #define TR_MAXNAMLEN    63
346 struct tr_direct {
347     u_int16_t d_ino;            /* inode number of entry */
348     u_int16_t d_reclen;         /* length of this record */
349     u_int16_t d_namlen;         /* length of string in d_name */
350     char d_name[TR_MAXNAMLEN + 1];      /* name must be no longer than this */
351 };
352
353 /* used by S_ADJTIME */
354 struct tr_timeval {
355     u_int32_t tv_sec;           /* seconds */
356     u_int32_t tv_usec;          /* and microseconds */
357 };
358 /* Used by S_GETTIMEOFDAY */
359 struct tr_timezone {
360     int16_t tz_minuteswest;     /* minutes west of Greenwich */
361     int16_t tz_dsttime;         /* type of dst correction */
362 };
363
364 /* used in itimer calls */
365 struct tr_itimerval {
366     struct tr_timeval it_interval;      /* timer interval */
367     struct tr_timeval it_value; /* current value */
368 };
369
370 /* Used by socket calls */
371 struct tr_sockaddr {
372     u_int16_t sa_family;        /* address family */
373     char sa_data[14];           /* up to 14 bytes of direct address */
374 };
375
376 /* used in rlimit calls */
377 struct tr_rlimit {
378     int32_t rlim_cur;           /* current (soft) limit */
379     int32_t rlim_max;           /* maximum value for rlim_cur */
380 };
381
382 struct tr_rusage {
383     struct tr_timeval ru_utime; /* user time used */
384     struct tr_timeval ru_stime; /* system time used */
385     u_int32_t ru_maxrss;
386     u_int32_t ru_ixrss;         /* integral shared memory size */
387     u_int32_t ru_idrss;         /* integral unshared data size */
388     u_int32_t ru_isrss;         /* integral unshared stack size */
389     u_int32_t ru_minflt;        /* page reclaims */
390     u_int32_t ru_majflt;        /* page faults */
391     u_int32_t ru_ovly;          /* overlay changes */
392     u_int32_t ru_nswap;         /* swaps */
393     u_int32_t ru_inblock;       /* block input operations */
394     u_int32_t ru_oublock;       /* block output operations */
395     u_int32_t ru_msgsnd;        /* messages sent */
396     u_int32_t ru_msgrcv;        /* messages received */
397     u_int32_t ru_nsignals;      /* signals received */
398     u_int32_t ru_nvcsw;         /* voluntary context switches */
399     u_int32_t ru_nivcsw;        /* involuntary context switches */
400 };
401
402 /* for writev, readv */
403 struct tr_iovec {
404     u_int16_t iov_base;
405     u_int16_t iov_len;
406 };
407
408
409 /* A union which will point at the trap args, so that
410  * we can get at the various args of different types
411  */
412 typedef union {
413     int16_t sarg[6];            /* Signed 16-bit args */
414     u_int16_t uarg[6];          /* Unsigned 16-bit args */
415 } arglist;
416
417 #define sarg1   A->sarg[0]
418 #define sarg2   A->sarg[1]
419 #define sarg3   A->sarg[2]
420 #define sarg4   A->sarg[3]
421 #define sarg5   A->sarg[4]
422 #define sarg6   A->sarg[5]
423 #define uarg1   A->uarg[0]
424 #define uarg2   A->uarg[1]
425 #define uarg3   A->uarg[2]
426 #define uarg4   A->uarg[3]
427 #define uarg5   A->uarg[4]
428 #define uarg6   A->uarg[5]