2 * Copyright (c) 1996-1999 Distributed Processing Technology Corporation
5 * Redistribution and use in source form, with or without modification, are
6 * permitted provided that redistributions of source code must retain the
7 * above copyright notice, this list of conditions and the following disclaimer.
9 * This software is provided `as is' by Distributed Processing Technology and
10 * any express or implied warranties, including, but not limited to, the
11 * implied warranties of merchantability and fitness for a particular purpose,
12 * are disclaimed. In no event shall Distributed Processing Technology be
13 * liable for any direct, indirect, incidental, special, exemplary or
14 * consequential damages (including, but not limited to, procurement of
15 * substitute goods or services; loss of use, data, or profits; or business
16 * interruptions) however caused and on any theory of liability, whether in
17 * contract, strict liability, or tort (including negligence or otherwise)
18 * arising in any way out of the use of this driver software, even if advised
19 * of the possibility of such damage.
28 ****************************************************************************
32 * This file contains defines and function prototypes that are
33 *operating system dependent. The resources defined in this file
34 *are not specific to any particular application.
36 *Copyright Distributed Processing Technology, Corp.
38 * Maitland, Fl. 32751 USA
39 * Phone: (407) 830-5522 Fax: (407) 260-5366
42 *Author: Doug Anderson
50 *****************************************************************************/
53 /*Definitions - Defines & Constants ----------------------------------------- */
55 /*----------------------------- */
56 /* Operating system selections: */
57 /*----------------------------- */
59 /*#define _DPT_MSDOS */
60 /*#define _DPT_WIN_3X */
61 /*#define _DPT_WIN_4X */
62 /*#define _DPT_WIN_NT */
63 /*#define _DPT_NETWARE */
66 /*#define _DPT_UNIXWARE */
67 /*#define _DPT_SOLARIS */
68 /*#define _DPT_NEXTSTEP */
69 /*#define _DPT_BANYAN */
71 /*-------------------------------- */
72 /* Include the OS specific defines */
73 /*-------------------------------- */
75 /*#define OS_SELECTION From Above List */
76 /*#define SEMAPHORE_T ??? */
77 /*#define DLL_HANDLE_T ??? */
79 #if (defined(KERNEL) && defined(__bsdi__))
80 # include "i386/isa/dpt_osd_defs.h"
81 #elif ((defined(KERNEL) || defined(_KERNEL)) && defined(__FreeBSD__))
82 # if (KERN_VERSION < 3)
83 # include "i386/isa/dpt_osd_defs.h"
85 # include "dev/asr/osd_defs.h"
88 # include "osd_defs.h"
103 #ifndef DPT_RUNTIME_IMPORT
104 #define DPT_RUNTIME_IMPORT DPT_IMPORT
107 /*--------------------- */
108 /* OS dependent defines */
109 /*--------------------- */
111 #if defined(_DPT_MSDOS) || defined(_DPT_WIN_3X)
117 #if defined(_DPT_SCO) || defined(_DPT_UNIXWARE) || defined(_DPT_SOLARIS) || defined(_DPT_AIX) || defined(SNI_MIPS) || defined(_DPT_BSDI) || defined(_DPT_FREE_BSD) || defined(_DPT_LINUX)
121 #if defined(_DPT_WIN_3x) || defined(_DPT_WIN_4X) || defined(_DPT_WIN_NT) \
123 #define _DPT_DLL_SUPPORT
126 #if !defined(_DPT_MSDOS) && !defined(_DPT_WIN_3X) && !defined(_DPT_NETWARE)
127 #define _DPT_PREEMPTIVE
130 #if !defined(_DPT_MSDOS) && !defined(_DPT_WIN_3X)
131 #define _DPT_MULTI_THREADED
134 #if !defined(_DPT_MSDOS)
135 #define _DPT_MULTI_TASKING
138 /* These exist for platforms that */
139 /* chunk when accessing mis-aligned */
141 #if defined(SNI_MIPS) || defined(_DPT_SOLARIS)
142 #if defined(_DPT_BIG_ENDIAN)
143 #if !defined(_DPT_STRICT_ALIGN)
144 #define _DPT_STRICT_ALIGN
149 /* Determine if in C or C++ mode */
156 /*-------------------------------------------------------------------*/
157 /* Under Solaris the compiler refuses to accept code like: */
158 /* { {"DPT"}, 0, NULL .... }, */
159 /* and complains about the {"DPT"} part by saying "cannot use { } */
160 /* to initialize char*". */
162 /* By defining these ugly macros we can get around this and also */
163 /* not have to copy and #ifdef large sections of code. I know that */
164 /* these macros are *really* ugly, but they should help reduce */
165 /* maintenance in the long run. */
167 /* In the meantime, just pray that we can all move to Win32 as soon */
169 /*-------------------------------------------------------------------*/
171 #if defined(_DPT_SOLARIS)
181 /*---------------------- */
182 /* OS dependent typedefs */
183 /*---------------------- */
185 #if defined(_DPT_MSDOS) || defined(_DPT_SCO)
186 #define BYTE unsigned char
187 #define WORD unsigned short
190 #ifndef _DPT_TYPEDEFS
191 #define _DPT_TYPEDEFS
192 typedef unsigned char uCHAR;
193 typedef unsigned short uSHORT;
194 typedef unsigned int uINT;
195 typedef unsigned long uLONG;
209 /*Prototypes - function ----------------------------------------------------- */
212 extern "C" { /* Declare all these functions as "C" functions */
215 /*------------------------ */
216 /* Byte reversal functions */
217 /*------------------------ */
219 /* Reverses the byte ordering of a 2 byte variable */
220 #if (!defined(osdSwap2))
221 uSHORT osdSwap2(DPT_UNALIGNED uSHORT *);
222 #endif /* !osdSwap2 */
224 /* Reverses the byte ordering of a 4 byte variable and shifts left 8 bits */
225 #if (!defined(osdSwap3))
226 uLONG osdSwap3(DPT_UNALIGNED uLONG *);
227 #endif /* !osdSwap3 */
231 #include "novpass.h" /* For DPT_Bswapl() prototype */
232 /* Inline the byte swap */
234 inline uLONG osdSwap4(uLONG *inLong) {
235 return *inLong = DPT_Bswapl(*inLong);
238 #define osdSwap4(inLong) DPT_Bswapl(inLong)
239 #endif /* cplusplus */
241 /* Reverses the byte ordering of a 4 byte variable */
242 # if (!defined(osdSwap4))
243 uLONG osdSwap4(DPT_UNALIGNED uLONG *);
244 # endif /* !osdSwap4 */
246 /* The following functions ALWAYS swap regardless of the *
247 * presence of DPT_BIG_ENDIAN */
249 uSHORT trueSwap2(DPT_UNALIGNED uSHORT *);
250 uLONG trueSwap4(DPT_UNALIGNED uLONG *);
255 /*-------------------------------------*
256 * Network order swap functions *
258 * These functions/macros will be used *
259 * by the structure insert()/extract() *
262 * We will enclose all structure *
263 * portability modifications inside *
264 * #ifdefs. When we are ready, we *
265 * will #define DPT_PORTABLE to begin *
266 * using the modifications. *
267 *-------------------------------------*/
268 uLONG netSwap4(uLONG val);
270 #if defined(_DPT_BIG_ENDIAN)
272 /* for big-endian we need to swap */
275 #define NET_SWAP_2(x) (((x) >> 8) | ((x) << 8))
276 #endif /* NET_SWAP_2 */
279 #define NET_SWAP_4(x) netSwap4((x))
280 #endif /* NET_SWAP_4 */
284 /* for little-endian we don't need to do anything */
287 #define NET_SWAP_2(x) (x)
288 #endif /* NET_SWAP_2 */
291 #define NET_SWAP_4(x) (x)
292 #endif /* NET_SWAP_4 */
294 #endif /* big endian */
298 /*----------------------------------- */
299 /* Run-time loadable module functions */
300 /*----------------------------------- */
302 /* Loads the specified run-time loadable DLL */
303 DLL_HANDLE_T osdLoadModule(uCHAR *);
304 /* Unloads the specified run-time loadable DLL */
305 uSHORT osdUnloadModule(DLL_HANDLE_T);
306 /* Returns a pointer to a function inside a run-time loadable DLL */
307 void * osdGetFnAddr(DLL_HANDLE_T,uCHAR *);
309 /*--------------------------------------- */
310 /* Mutually exclusive semaphore functions */
311 /*--------------------------------------- */
313 /* Create a named semaphore */
314 SEMAPHORE_T osdCreateNamedSemaphore(char *);
315 /* Create a mutually exlusive semaphore */
316 SEMAPHORE_T osdCreateSemaphore(void);
317 /* create an event semaphore */
318 SEMAPHORE_T osdCreateEventSemaphore(void);
319 /* create a named event semaphore */
320 SEMAPHORE_T osdCreateNamedEventSemaphore(char *);
322 /* Destroy the specified mutually exclusive semaphore object */
323 uSHORT osdDestroySemaphore(SEMAPHORE_T);
324 /* Request access to the specified mutually exclusive semaphore */
325 uLONG osdRequestSemaphore(SEMAPHORE_T,uLONG);
326 /* Release access to the specified mutually exclusive semaphore */
327 uSHORT osdReleaseSemaphore(SEMAPHORE_T);
328 /* wait for an event to happen */
329 uLONG osdWaitForEventSemaphore(SEMAPHORE_T, uLONG);
330 /* signal an event */
331 uLONG osdSignalEventSemaphore(SEMAPHORE_T);
332 /* reset the event */
333 uLONG osdResetEventSemaphore(SEMAPHORE_T);
335 /*----------------- */
336 /* Thread functions */
337 /*----------------- */
339 /* Releases control to the task switcher in non-preemptive */
340 /* multitasking operating systems. */
341 void osdSwitchThreads(void);
343 /* Starts a thread function */
344 uLONG osdStartThread(void *,void *);
346 /* what is my thread id */
347 uLONG osdGetThreadID(void);
349 /* wakes up the specifed thread */
350 void osdWakeThread(uLONG);
352 /* osd sleep for x miliseconds */
353 void osdSleep(uLONG);
355 #define DPT_THREAD_PRIORITY_LOWEST 0x00
356 #define DPT_THREAD_PRIORITY_NORMAL 0x01
357 #define DPT_THREAD_PRIORITY_HIGHEST 0x02
359 uCHAR osdSetThreadPriority(uLONG tid, uCHAR priority);
362 } /* end the xtern "C" declaration */
365 #endif /* osd_util_h */