Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / n8 / n8_semaphore_bsd.c
blob3719a32ee305701807da79cf4efb69f5ab0766bd
1 /*-
2 * Copyright (C) 2001-2003 by NBMK Encryption Technologies.
3 * All rights reserved.
5 * NBMK Encryption Technologies provides no support of any kind for
6 * this software. Questions or concerns about it may be addressed to
7 * the members of the relevant open-source community at
8 * <tech-crypto@netbsd.org>.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided
20 * with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /*****************************************************************************
36 * @(#) n8_semaphore_bsd.c 1.2@(#)
37 *****************************************************************************/
39 /*****************************************************************************/
40 /** @file n8_semaphore_bsd.c
41 * @brief This file implements the n8 semaphore operations for BSD kernel
42 * environment.
44 *****************************************************************************/
46 /*****************************************************************************
47 * Revision history:
48 * 12/02/02 brr Added n8_delete_process_init_sem function.
49 * 06/12/02 hml Implemented the processSem ops. They are all empty for BSD.
50 * 03/18/02 brr Original version.
51 ****************************************************************************/
52 /** @defgroup n8_semaphore NetOctave Semaphore Operations
55 #include "helper.h"
56 #include "n8_pub_errors.h"
57 #include "n8_semaphore.h"
59 static int initComplete = FALSE;
60 static ATOMICLOCK_t initProcessMutex_g = SIMPLELOCK_INITIALIZER;
62 /*****************************************************************************
63 * n8_acquire_process_init_sem
64 *****************************************************************************/
65 /** @ingroup n8_semaphore
66 * @brief Acquire the statically defined initilization semaphore.
68 * This function is the POSIX implementation of a function that grabs
69 * the statically allocated initialization semaphore. It turns out this
70 * is needed in order to prevent any race conditions on initialization.
72 * @par Externals:
73 * initProcessMutex_g RW: The global process initialization mutex.
75 * @return
76 * None.
78 * @par Errors:
79 * None.
81 * @par Assumptions:
82 *****************************************************************************/
83 void
84 n8_acquire_process_init_sem()
86 N8_AtomicLock(initProcessMutex_g);
89 /*****************************************************************************
90 * n8_release_process_init_sem
91 *****************************************************************************/
92 /** @ingroup n8_semaphore
93 * @brief Release the statically defined initilization semaphore.
95 * This function is the POSIX implementation of a function that releases
96 * the statically allocated initialization semaphore. It turns out this
97 * is needed in order to prevent any race conditions on initialization.
99 * @par Externals:
100 * initProcessMutex_g RW: The global process initialization mutex.
102 * @return
103 * None.
105 * @par Errors:
106 * None.
108 * @par Assumptions:
109 *****************************************************************************/
110 void
111 n8_release_process_init_sem()
113 N8_AtomicUnlock(initProcessMutex_g);
116 /*****************************************************************************
117 * n8_create_process_init_sem
118 *****************************************************************************/
119 /** @ingroup n8_semaphore
120 * @brief Creates the process initialization semaphore
122 * This function allocates a kernel semaphore,
124 * @return
126 * @par Errors:
128 * @par Locks:
129 * None.
130 * A text description of locks required by this routine and
131 * locks aquired by this routine. Optional if there are no locks.
133 * @par Assumptions:
134 * initVal is a sane number
135 *****************************************************************************/
137 void
138 n8_create_process_init_sem(void)
140 if (initComplete == FALSE)
142 N8_AtomicLockInit(initProcessMutex_g);
143 initComplete = TRUE;
147 /*****************************************************************************
148 * n8_delete_process_init_sem
149 *****************************************************************************/
150 /** @ingroup n8_semaphore
151 * @brief Deletes the process initialization semaphore
153 * This function deletes a kernel semaphore,
155 * @return
157 * @par Errors:
159 * @par Locks:
160 * None.
161 * A text description of locks required by this routine and
162 * locks aquired by this routine. Optional if there are no locks.
164 * @par Assumptions:
165 * initVal is a sane number
166 *****************************************************************************/
168 void
169 n8_delete_process_init_sem(void)
171 N8_AtomicLockDel(initProcessMutex_g);
172 initComplete = FALSE;
175 /*****************************************************************************
176 * N8_acquireProcessSem
177 *****************************************************************************/
178 /** @ingroup n8_semaphore
179 * @brief Acquire a lock of type N8_Lock_t.
181 * This function is the kernel space implementation of a function that grabs
182 * a lock of type N8_Lock_t. Does nothing in BSD.
185 * @par Externals:
186 * None.
188 * @return
189 * None.
191 * @par Errors:
192 * None.
194 * @par Assumptions:
195 *****************************************************************************/
196 void
197 N8_acquireProcessSem(n8_Lock_t *lock_p)
201 /*****************************************************************************
202 * N8_releaseProcessSem
203 *****************************************************************************/
204 /** @ingroup n8_semaphore
205 * @brief Release a lock of type N8_Lock_t.
207 * This function is the kernel space implementation of a function that releases
208 * a lock of type N8_Lock_t. Does nothing in BSD.
211 * @par Externals:
212 * None.
214 * @return
215 * None.
217 * @par Errors:
218 * None.
220 * @par Assumptions:
221 *****************************************************************************/
222 void
223 N8_releaseProcessSem(n8_Lock_t *lock_p)
227 /*****************************************************************************
228 * N8_initProcessSem
229 *****************************************************************************/
230 /** @ingroup n8_semaphore
231 * @brief Initialize a lock of type N8_Lock_t.
233 * This function is the kernel space implementation of a function that
234 * initializes a lock of type N8_Lock_t. Does nothing in BSD.
237 * @par Externals:
238 * None.
240 * @return
241 * None.
243 * @par Errors:
244 * None.
246 * @par Assumptions:
247 *****************************************************************************/
248 void
249 N8_initProcessSem(n8_Lock_t *lock_p)
253 /*****************************************************************************
254 * N8_deleteProcessSem
255 *****************************************************************************/
256 /** @ingroup n8_semaphore
257 * @brief Initialize a lock of type N8_Lock_t.
259 * This function is the kernel space implementation of a function that
260 * deletes a lock of type N8_Lock_t. Does nothing in BSD.
263 * @par Externals:
264 * None.
266 * @return
267 * None.
269 * @par Errors:
270 * None.
272 * @par Assumptions:
273 *****************************************************************************/
274 void
275 N8_deleteProcessSem(n8_Lock_t *lock_p)