^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* BSDI osd_util.h,v 1.8 1998/06/03 19:14:58 karels Exp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 1996-1999 Distributed Processing Technology Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Redistribution and use in source form, with or without modification, are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * permitted provided that redistributions of source code must retain the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * above copyright notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * This software is provided `as is' by Distributed Processing Technology and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * any express or implied warranties, including, but not limited to, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * implied warranties of merchantability and fitness for a particular purpose,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * are disclaimed. In no event shall Distributed Processing Technology be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * liable for any direct, indirect, incidental, special, exemplary or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * consequential damages (including, but not limited to, procurement of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * substitute goods or services; loss of use, data, or profits; or business
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * interruptions) however caused and on any theory of liability, whether in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * contract, strict liability, or tort (including negligence or otherwise)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * arising in any way out of the use of this driver software, even if advised
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * of the possibility of such damage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #ifndef __OSD_UTIL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define __OSD_UTIL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /*File - OSD_UTIL.H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) *Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * This file contains defines and function prototypes that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) *operating system dependent. The resources defined in this file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) *are not specific to any particular application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *Copyright Distributed Processing Technology, Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * 140 Candace Dr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Maitland, Fl. 32751 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Phone: (407) 830-5522 Fax: (407) 260-5366
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * All Rights Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *Author: Doug Anderson
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *Date: 1/7/94
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) *Editors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *Remarks:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /*Definitions - Defines & Constants ----------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /*----------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* Operating system selections: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /*----------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /*#define _DPT_MSDOS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /*#define _DPT_WIN_3X */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /*#define _DPT_WIN_4X */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*#define _DPT_WIN_NT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /*#define _DPT_NETWARE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /*#define _DPT_OS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /*#define _DPT_SCO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /*#define _DPT_UNIXWARE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /*#define _DPT_SOLARIS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /*#define _DPT_NEXTSTEP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /*#define _DPT_BANYAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /*-------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Include the OS specific defines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /*-------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /*#define OS_SELECTION From Above List */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /*#define SEMAPHORE_T ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*#define DLL_HANDLE_T ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #if (defined(KERNEL) && (defined(__FreeBSD__) || defined(__bsdi__)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) # include "i386/isa/dpt_osd_defs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) # include "osd_defs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #ifndef DPT_UNALIGNED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define DPT_UNALIGNED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #ifndef DPT_EXPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define DPT_EXPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #ifndef DPT_IMPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define DPT_IMPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #ifndef DPT_RUNTIME_IMPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define DPT_RUNTIME_IMPORT DPT_IMPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*--------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* OS dependent defines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /*--------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #if defined (_DPT_MSDOS) || defined (_DPT_WIN_3X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define _DPT_16_BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define _DPT_32_BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define _DPT_UNIX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #if defined (_DPT_WIN_3x) || defined (_DPT_WIN_4X) || defined (_DPT_WIN_NT) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) || defined (_DPT_OS2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define _DPT_DLL_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #if !defined (_DPT_MSDOS) && !defined (_DPT_WIN_3X) && !defined (_DPT_NETWARE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define _DPT_PREEMPTIVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #if !defined (_DPT_MSDOS) && !defined (_DPT_WIN_3X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define _DPT_MULTI_THREADED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #if !defined (_DPT_MSDOS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define _DPT_MULTI_TASKING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /* These exist for platforms that */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* chunk when accessing mis-aligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #if defined (SNI_MIPS) || defined (_DPT_SOLARIS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #if defined (_DPT_BIG_ENDIAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #if !defined (_DPT_STRICT_ALIGN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define _DPT_STRICT_ALIGN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* Determine if in C or C++ mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #ifdef __cplusplus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define _DPT_CPP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define _DPT_C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /*-------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /* Under Solaris the compiler refuses to accept code like: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* { {"DPT"}, 0, NULL .... }, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /* and complains about the {"DPT"} part by saying "cannot use { } */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /* to initialize char*". */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /* By defining these ugly macros we can get around this and also */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /* not have to copy and #ifdef large sections of code. I know that */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* these macros are *really* ugly, but they should help reduce */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /* maintenance in the long run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /*-------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #if !defined (DPTSQO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #if defined (_DPT_SOLARIS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define DPTSQO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #define DPTSQC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define DPTSQO {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #define DPTSQC }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #endif /* solaris */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #endif /* DPTSQO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /*---------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* OS dependent typedefs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /*---------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #if defined (_DPT_MSDOS) || defined (_DPT_SCO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #define BYTE unsigned char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #define WORD unsigned short
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #ifndef _DPT_TYPEDEFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #define _DPT_TYPEDEFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) typedef unsigned char uCHAR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) typedef unsigned short uSHORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) typedef unsigned int uINT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) typedef unsigned long uLONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) typedef union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) uCHAR u8[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) uSHORT u16[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) uLONG u32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) } access_U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #if !defined (NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define NULL 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /*Prototypes - function ----------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #ifdef __cplusplus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) extern "C" { /* Declare all these functions as "C" functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*------------------------ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /* Byte reversal functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /*------------------------ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /* Reverses the byte ordering of a 2 byte variable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #if (!defined(osdSwap2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) uSHORT osdSwap2(DPT_UNALIGNED uSHORT *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #endif // !osdSwap2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /* Reverses the byte ordering of a 4 byte variable and shifts left 8 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #if (!defined(osdSwap3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) uLONG osdSwap3(DPT_UNALIGNED uLONG *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #endif // !osdSwap3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) #ifdef _DPT_NETWARE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #include "novpass.h" /* For DPT_Bswapl() prototype */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* Inline the byte swap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #ifdef __cplusplus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) inline uLONG osdSwap4(uLONG *inLong) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) return *inLong = DPT_Bswapl(*inLong);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #define osdSwap4(inLong) DPT_Bswapl(inLong)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) #endif // cplusplus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) /* Reverses the byte ordering of a 4 byte variable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) # if (!defined(osdSwap4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) uLONG osdSwap4(DPT_UNALIGNED uLONG *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) # endif // !osdSwap4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) /* The following functions ALWAYS swap regardless of the *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * presence of DPT_BIG_ENDIAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) uSHORT trueSwap2(DPT_UNALIGNED uSHORT *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) uLONG trueSwap4(DPT_UNALIGNED uLONG *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) #endif // netware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /*-------------------------------------*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * Network order swap functions *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * These functions/macros will be used *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * by the structure insert()/extract() *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * functions. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * We will enclose all structure *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * portability modifications inside *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * #ifdefs. When we are ready, we *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * will #define DPT_PORTABLE to begin *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * using the modifications. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) *-------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) uLONG netSwap4(uLONG val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) #if defined (_DPT_BIG_ENDIAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) // for big-endian we need to swap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) #ifndef NET_SWAP_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #define NET_SWAP_2(x) (((x) >> 8) | ((x) << 8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) #endif // NET_SWAP_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #ifndef NET_SWAP_4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #define NET_SWAP_4(x) netSwap4((x))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #endif // NET_SWAP_4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) // for little-endian we don't need to do anything
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #ifndef NET_SWAP_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) #define NET_SWAP_2(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) #endif // NET_SWAP_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #ifndef NET_SWAP_4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) #define NET_SWAP_4(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) #endif // NET_SWAP_4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) #endif // big endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) /*----------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) /* Run-time loadable module functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /*----------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) /* Loads the specified run-time loadable DLL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) DLL_HANDLE_T osdLoadModule(uCHAR *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) /* Unloads the specified run-time loadable DLL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) uSHORT osdUnloadModule(DLL_HANDLE_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* Returns a pointer to a function inside a run-time loadable DLL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) void * osdGetFnAddr(DLL_HANDLE_T,uCHAR *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) /*--------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) /* Mutually exclusive semaphore functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /*--------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /* Create a named semaphore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) SEMAPHORE_T osdCreateNamedSemaphore(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /* Create a mutually exlusive semaphore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) SEMAPHORE_T osdCreateSemaphore(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) /* create an event semaphore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) SEMAPHORE_T osdCreateEventSemaphore(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) /* create a named event semaphore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) SEMAPHORE_T osdCreateNamedEventSemaphore(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) /* Destroy the specified mutually exclusive semaphore object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) uSHORT osdDestroySemaphore(SEMAPHORE_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) /* Request access to the specified mutually exclusive semaphore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) uLONG osdRequestSemaphore(SEMAPHORE_T,uLONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) /* Release access to the specified mutually exclusive semaphore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) uSHORT osdReleaseSemaphore(SEMAPHORE_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /* wait for a event to happen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) uLONG osdWaitForEventSemaphore(SEMAPHORE_T, uLONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) /* signal an event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) uLONG osdSignalEventSemaphore(SEMAPHORE_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) /* reset the event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) uLONG osdResetEventSemaphore(SEMAPHORE_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) /*----------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /* Thread functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) /*----------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) /* Releases control to the task switcher in non-preemptive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) /* multitasking operating systems. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) void osdSwitchThreads(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) /* Starts a thread function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) uLONG osdStartThread(void *,void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /* what is my thread id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) uLONG osdGetThreadID(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) /* wakes up the specifed thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) void osdWakeThread(uLONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) /* osd sleep for x milliseconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) void osdSleep(uLONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) #define DPT_THREAD_PRIORITY_LOWEST 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) #define DPT_THREAD_PRIORITY_NORMAL 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) #define DPT_THREAD_PRIORITY_HIGHEST 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) uCHAR osdSetThreadPriority(uLONG tid, uCHAR priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) #ifdef __cplusplus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) } /* end the xtern "C" declaration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) #endif /* osd_util_h */