xref: /original-bsd/sys/hp/hpux/hpux.h (revision bfa5ee2d)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: hpux.h 1.33 93/08/05$
13  *
14  *	@(#)hpux.h	8.4 (Berkeley) 02/13/94
15  */
16 
17 #include <hp/hpux/hpux_exec.h>
18 
19 /* HP-UX style UTSNAME struct used by uname syscall */
20 
21 struct hpuxutsname {
22 	char	sysname[9];
23 	char	nodename[9];
24 	char	release[9];
25 	char	version[9];
26 	char	machine[9];
27 	char	idnumber[15];
28 };
29 
30 /* HP-UX style "old" IOCTLs */
31 
32 struct hpuxsgttyb {
33 	char	sg_ispeed;
34 	char	sg_ospeed;
35 	char	sg_erase;
36 	char	sg_kill;
37 	int	sg_flags;	/* only a short in BSD */
38 };
39 
40 #define V7_HUPCL	00001
41 #define V7_XTABS	00002
42 #define V7_NOAL		04000
43 
44 #define	HPUXTIOCGETP	_IOR('t', 8, struct hpuxsgttyb)
45 #define	HPUXTIOCSETP	_IOW('t', 9, struct hpuxsgttyb)
46 
47 /* 6.5 job control related ioctls which need to be mapped */
48 
49 #define	HPUXTIOCSLTC	_IOW('T', 23, struct ltchars)
50 #define	HPUXTIOCGLTC	_IOR('T', 24, struct ltchars)
51 #define	HPUXTIOCLBIS	_IOW('T', 25, int)
52 #define	HPUXTIOCLBIC	_IOW('T', 26, int)
53 #define	HPUXTIOCLSET	_IOW('T', 27, int)
54 #define	HPUXTIOCLGET	_IOR('T', 28, int)
55 #	define HPUXLTOSTOP	0000001
56 #define	HPUXTIOCSPGRP	_IOW('T', 29, int)
57 #define	HPUXTIOCGPGRP	_IOR('T', 30, int)
58 #define HPUXTIOCCONS	_IO('t', 104)
59 #define HPUXTIOCSWINSZ	_IOW('t', 106, struct winsize)
60 #define HPUXTIOCGWINSZ	_IOR('t', 107, struct winsize)
61 
62 /* non-blocking IO--doesn't interfere with O_NDELAY */
63 #define HPUXFIOSNBIO	_IOW('f', 126, int)
64 
65 /* HP-UX stat structure */
66 
67 #define bsdtohpuxdev(d)	((major(d) << 24) | minor(d))
68 
69 struct	hpuxstat {
70 	long	hst_dev;
71 	u_long	hst_ino;
72 	u_short	hst_mode;
73 	short	hst_nlink;
74 	u_short	hst_uid;
75 	u_short	hst_gid;
76 	long	hst_rdev;
77 	long	hst_size;
78 	time_t	hst_atime;
79 	int	hst_spare1;
80 	time_t	hst_mtime;
81 	int	hst_spare2;
82 	time_t	hst_ctime;
83 	int	hst_spare3;
84 	long	hst_blksize;
85 	long	hst_blocks;
86 	u_int	hst_remote;
87 	long	hst_netdev;
88 	u_long	hst_netino;
89 	long	hst_spare4[9];
90 };
91 
92 /*
93  * Skeletal 6.X HP-UX user structure info for ptrace() mapping.
94  * Yes, this is as bogus as it gets...
95  */
96 
97 /* 6.0/6.2 offsets */
98 #define ooHU_AROFF	0x004
99 #define ooHU_TSOFF	0x092
100 #define ooHU_EDOFF	0x91E
101 #define ooHU_FPOFF	0xA66
102 
103 /* 6.5 offsets */
104 #define oHU_AROFF	0x004
105 #define oHU_TSOFF	0x0B2
106 #define oHU_EDOFF	0x93A
107 #define oHU_FPOFF	0xA86
108 
109 /* 7.X offsets */
110 #define HU_AROFF	0x004
111 #define HU_TSOFF	0x0B4
112 #define HU_EDOFF	0x8C8
113 #define HU_FPOFF	0xA28
114 
115 #define HU_PAD1	(HU_AROFF)
116 #define HU_PAD2	(HU_TSOFF-HU_AROFF-4)
117 #define HU_PAD3	(HU_EDOFF-HU_TSOFF-12)
118 #define HU_PAD4	(HU_FPOFF-HU_EDOFF-sizeof(struct hpux_exec))
119 
120 struct hpuxuser {
121 	u_char	whocares1[HU_PAD1];	/* +0x000 */
122 	int	*hpuxu_ar0;		/* +0x004 */
123 	u_char	whocares2[HU_PAD2];	/* +0x008 */
124 	int	hpuxu_tsize;		/* +0x0B2 */
125 	int	hpuxu_dsize;		/* +0x0B6 */
126 	int	hpuxu_ssize;		/* +0x0BA */
127 	u_char	whocares3[HU_PAD3];	/* +0x0BE */
128 	struct	hpux_exec hpuxu_exdata;	/* +0x93A */
129 	u_char	whocares4[HU_PAD4];	/* +0x95E */
130 	struct	hpuxfp {		/* +0xA66 */
131 		int hpfp_save[54];
132 		int hpfp_ctrl[3];
133 		int hpfp_reg[24];
134 	} hpuxu_fp;
135 	short	hpuxu_dragon;		/* +0xBCA */
136 };
137 
138 /* HP-UX compat file flags */
139 #define HPUXNDELAY	00000004
140 #define HPUXFCREAT	00000400
141 #define	HPUXFTRUNC	00001000
142 #define	HPUXFEXCL	00002000
143 #define HPUXFSYNCIO	00100000
144 #define HPUXNONBLOCK	00200000
145 #define HPUXFREMOTE	01000000
146 
147 /* HP-UX fcntl file locking */
148 struct hpuxflock {
149 	short	hl_type;
150 	short	hl_whence;
151 	long	hl_start;
152 	long	hl_len;
153 	long	hl_pid;
154 };
155 
156 #define HPUXF_GETLK	7
157 #define HPUXF_SETLK	8
158 #define HPUXF_SETLKW	9
159 
160 #define HPUXF_RDLCK	1
161 #define HPUXF_WRLCK	2
162 #define HPUXF_UNLCK	3
163 
164 /* HP-UX only sysV shmctl() commands */
165 #define SHM_LOCK	3	/* Lock segment in core */
166 #define SHM_UNLOCK	4	/* Unlock segment */
167 
168 /* SHM stuff reflecting POSIX types */
169 struct hpuxipc_perm {
170 	long	uid;	/* owner's user id */
171 	long	gid;	/* owner's group id */
172 	long	cuid;	/* creator's user id */
173 	long	cgid;	/* creator's group id */
174 	u_short	mode;	/* access modes */
175 	u_short	seq;	/* slot usage sequence number */
176 	long	key;	/* key */
177 };
178 
179 struct hpuxshmid_ds {
180 	struct hpuxipc_perm shm_perm;	/* operation permission struct */
181 	int		shm_segsz;	/* segment size (bytes) */
182 	struct pte	*shm_ptbl;	/* ptr to associated page table */
183 	long		shm_lpid;	/* pid of last shmop */
184 	long		shm_cpid;	/* pid of creator */
185 	u_short		shm_nattch;	/* current # attached */
186 	u_short		shm_cnattch;	/* in memory # attached */
187 	time_t		shm_atime;	/* last shmat time */
188 	time_t		shm_dtime;	/* last shmdt time */
189 	time_t		shm_ctime;	/* last change time */
190 	/* actually longer */
191 };
192 
193 /* HP-UX rtprio values */
194 #define RTPRIO_MIN	0
195 #define RTPRIO_MAX	127
196 #define RTPRIO_NOCHG	1000
197 #define RTPRIO_RTOFF	1001
198 
199 /* HP-UX only sigvec sv_flags values */
200 #define HPUXSV_RESET	000000004
201 
202 /*
203  * HP-UX returns SIGILL instead of SIGFPE for the CHK and TRAPV exceptions.
204  * It also returns different u_code values for certain illegal instruction
205  * and floating point exceptions.  Here are the proper HP-UX u_code values
206  * (numbers from hpux 6.2 manual pages).
207  */
208 
209 /* SIGILL codes */
210 #define	HPUX_ILL_ILLINST_TRAP	0	/* T_ILLINST+USER */
211 #define	HPUX_ILL_CHK_TRAP	6	/* T_CHKINST+USER */
212 #define	HPUX_ILL_TRAPV_TRAP	7	/* T_TRAPVINST+USER */
213 #define	HPUX_ILL_PRIV_TRAP	8	/* T_PRIVINST+USER */
214 
215 /* SIGFPE codes */
216 #define	HPUX_FPE_INTDIV_TRAP	5	/* T_ZERODIV+USER */
217 
218 /* HP-UX POSIX signal stuff implementation */
219 typedef struct __hpuxsigset_t { long sigset[8]; } hpuxsigset_t;
220 struct hpuxsigaction {
221 	void		(*sa_handler)();
222 	hpuxsigset_t	sa_mask;
223 	int		sa_flags;
224 };
225 #define HPUXSA_ONSTACK		1
226 #define HPUXSA_RESETHAND	4
227 #define HPUXSA_NOCLDSTOP	8
228 
229 #define	HPUXSIG_BLOCK	0	/* block specified signal set */
230 #define	HPUXSIG_UNBLOCK	1	/* unblock specified signal set */
231 #define	HPUXSIG_SETMASK	2	/* set specified signal set */
232 
233 /* sysconf stuff */
234 #define HPUX_SYSCONF_CLKTICK	2
235 #define HPUX_SYSCONF_OPENMAX	4
236 #define HPUX_SYSCONF_CPUTYPE	10001
237 #define HPUX_SYSCONF_CPUM020	0x20C
238 #define HPUX_SYSCONF_CPUM030	0x20D
239 #define HPUX_SYSCONF_CPUM040	0x20E
240 #define HPUX_SYSCONF_CPUPA10	0x20B
241 #define HPUX_SYSCONF_CPUPA11	0x210
242 
243 /* mmap stuff */
244 #define HPUXMAP_FIXED	0x04
245 #define HPUXMAP_REPLACE	0x08
246 #define HPUXMAP_ANON	0x10
247 
248 /* rlimit stuff */
249 #define HPUXRLIMIT_NOFILE	6
250 
251 /*
252  * In BSD EAGAIN and EWOULDBLOCK are the same error code.
253  * However, for HP-UX we must split them out to seperate codes.
254  * The easiest way to do this was to check the return value of
255  * BSD routines which are known to return EAGAIN (but never
256  * EWOULDBLOCK) and change it to the pseudo-code OEAGAIN when
257  * we see it.  The error translation table will them map that
258  * code to the HP-UX EAGAIN value.
259  */
260 #define OEAGAIN	82
261