No empty .Rs/.Re
[netbsd-mini2440.git] / sys / compat / irix / irix_usema.h
blobbfa26c1d1bb5927b86ae6918d680d41acc2beed1
1 /* $NetBSD: irix_usema.h,v 1.13 2008/04/28 20:23:42 martin Exp $ */
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Emmanuel Dreyfus.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _IRIX_USEMA_H_
33 #define _IRIX_USEMA_H_
35 #include <sys/param.h>
36 #include <sys/device.h>
37 #include <sys/rwlock.h>
38 #include <sys/queue.h>
39 #include <sys/vnode.h>
41 #include <compat/irix/irix_types.h>
42 #include <compat/irix/irix_exec.h>
44 extern struct vfsops irix_usema_dummy_vfsops;
45 void irix_usema_dummy_vfs_init(void);
46 extern const struct vnodeopv_desc * const irix_usema_vnodeopv_descs[];
47 extern const struct vnodeopv_desc irix_usema_opv_desc;
48 extern int (**irix_usema_vnodeop_p)(void *);
49 extern const struct vnodeopv_entry_desc irix_usema_vnodeop_entries[];
52 void irix_usemaattach(struct device *, struct device *, void *);
54 int irix_usema_close(void *);
55 int irix_usema_access(void *);
56 int irix_usema_getattr(void *);
57 int irix_usema_setattr(void *);
58 int irix_usema_fcntl(void *);
59 int irix_usema_ioctl(void *);
60 int irix_usema_poll(void *);
61 int irix_usema_inactive(void *);
63 void irix_usema_exit_cleanup(struct proc *, struct proc *);
64 #ifdef DEBUG_IRIX
65 void irix_usema_debug(void);
66 #endif
68 #define IRIX_USEMADEV_MINOR 1
69 #define IRIX_USEMACLNDEV_MINOR 0
71 /* Semaphore internal structure: undocumented in IRIX */
72 struct irix_semaphore {
73 int is_val; /* Sempahore value */
74 int is_uk1; /* unknown, usually small integer < 3000 */
75 int is_uk2; /* metric, debug or history pointer ? */
76 int is_uk3; /* unknown, usually equal to 0 */
77 int is_uk4; /* unknown, usually equal to 0 */
78 int is_shid; /* unique ID for the shared arena ? */
79 int is_oid; /* owner id? usually equal to -1 */
80 int is_uk7; /* unknown, usually equal to -1 */
81 int is_uk8; /* unknown, usually equal to 0 */
82 int is_uk9; /* unknown, usually equal to 0 */
83 int is_uk10; /* semaphore page base address ? */
84 int is_uk12; /* unknown, usually equal to 0 */
85 int is_uk13; /* metric, debug or history pointer ? */
86 int is_uk14; /* padding? */
89 struct irix_usema_idaddr {
90 int iui_uk1; /* unknown, usually equal to 0 */
91 int *iui_oidp; /* pointer to is_oid field in struct irix_semaphore */
94 /* waiting processes list */
95 struct irix_waiting_proc_rec {
96 TAILQ_ENTRY(irix_waiting_proc_rec) iwpr_list;
97 struct proc *iwpr_p;
100 /* semaphore list, their vnode counterparts, and waiting processes lists */
101 struct irix_usema_rec {
102 LIST_ENTRY(irix_usema_rec) iur_list;
103 struct vnode *iur_vn;
104 struct irix_semaphore *iur_sem;
105 int iur_shid;
106 struct proc *iur_p;
107 struct selinfo iur_si;
108 int iur_waiting_count;
109 TAILQ_HEAD(iur_waiting_p, irix_waiting_proc_rec) iur_waiting_p;
110 TAILQ_HEAD(iur_released_p, irix_waiting_proc_rec) iur_released_p;
111 krwlock_t iur_lock; /* lock for both lists */
114 /* From IRIX's <sys/usioctl.h> */
115 #define IRIX_USEMADEV "/dev/usema"
116 #define IRIX_USEMACLNDEV "/dev/usemaclone"
118 #define IRIX_UIOC ('u' << 16 | 's' << 8)
119 #define IRIX_UIOC_MASK 0x00ffff00
121 #define IRIX_UIOCATTACHSEMA (IRIX_UIOC|2)
122 #define IRIX_UIOCBLOCK (IRIX_UIOC|3)
123 #define IRIX_UIOCABLOCK (IRIX_UIOC|4)
124 #define IRIX_UIOCNOIBLOCK (IRIX_UIOC|5)
125 #define IRIX_UIOCUNBLOCK (IRIX_UIOC|6)
126 #define IRIX_UIOCAUNBLOCK (IRIX_UIOC|7)
127 #define IRIX_UIOCINIT (IRIX_UIOC|8)
128 #define IRIX_UIOCGETSEMASTATE (IRIX_UIOC|9)
129 #define IRIX_UIOCABLOCKPID (IRIX_UIOC|10)
130 #define IRIX_UIOCADDPID (IRIX_UIOC|11)
131 #define IRIX_UIOCABLOCKQ (IRIX_UIOC|12)
132 #define IRIX_UIOCAUNBLOCKQ (IRIX_UIOC|13)
133 #define IRIX_UIOCIDADDR (IRIX_UIOC|14)
134 #define IRIX_UIOCSETSEMASTATE (IRIX_UIOC|15)
135 #define IRIX_UIOCGETCOUNT (IRIX_UIOC|16)
137 struct irix_usattach_s {
138 irix_dev_t us_dev;
139 void *us_handle;
141 typedef struct irix_usattach_s irix_usattach_t;
143 struct irix_irix5_usattach_s {
144 __uint32_t us_dev;
145 __uint32_t us_handle;
147 typedef struct irix_irix5_usattach_s irix_irix5_usattach_t;
149 struct irix_ussemastate_s {
150 int ntid;
151 int nprepost;
152 int nfilled;
153 int nthread;
154 struct irix_ussematidstate_s {
155 pid_t pid;
156 int tid;
157 int count;
158 } *tidinfo;
160 typedef struct irix_ussemastate_s irix_ussemastate_t;
161 typedef struct irix_ussematidstate_s irix_ussematidstate_t;
164 /* usync_fcntl() commands, undocumented in IRIX */
165 #define IRIX_USYNC_BLOCK 1
166 #define IRIX_USYNC_INTR_BLOCK 2
167 #define IRIX_USYNC_UNBLOCK_ALL 3
168 #define IRIX_USYNC_UNBLOCK 4
169 #define IRIX_USYNC_NOTIFY_REGISTER 5
170 #define IRIX_USYNC_NOTIFY 6
171 #define IRIX_USYNC_NOTIFY_DELETE 7
172 #define IRIX_USYNC_NOTIFY_CLEAR 8
173 #define IRIX_USYNC_GET_STATE 11
175 struct irix_usync_arg {
176 int iua_uk0; /* unknown, usually small integer around 1000 */
177 int iua_uk1; /* unknown, usually pointer to code in libc */
178 int iua_uk2; /* unknown, usually null */
179 struct irix_semaphore *iua_sem; /* semaphore address */
182 #endif /* _IRIX_USEMA_H_ */