1//
2// IrDA Types
3//
4
5#ifndef _IrDA_Types_h
6#define _IrDA_Types_h
7
8#include <IOKit/IOLib.h>
9#include <libkern/c++/OSObject.h>
10
11#include "IrDADebugging.h"
12
13enum IrDAErrors {
14    noErr = 0,
15    kIrDAErrGeneric,
16    kIrDAErrWrongState,
17    kIrDAErrRequestCanceled,
18    kIrDAErrNotConnected,
19    kIrDAErrCancel,
20    kIrDAErrRetry,
21    kIrDAErrLinkBusy,
22    kIrDAErrTimeout,
23    kIrDAErrToolBusy,
24    kIrDAErrNoMemory,
25    kIrDAErrPacket,
26    kIrDAErrResourceNotAvailable,
27    kIrDAErrBadParameter,
28
29    errElementSizeMismatch,
30    errNoMemory,
31    errRangeCheck,
32    errBadArg,
33
34    // Discovery errors
35    errDiscoveryTooManySlots,
36    errDiscoveryInConnection,
37
38    // lap
39    errConnectionAborted,
40
41    // qos
42    errIncompatibleRemote,
43
44    // irlapconn (et al)
45    errCancel
46
47};
48
49typedef UInt32      IrDAErr;
50typedef SInt32      Size;
51typedef UInt8       UByte;
52typedef UInt8       UChar;
53typedef UInt16      UShort;
54typedef UInt32      ULong;
55typedef SInt32      SLong;
56typedef SLong       FastInt;
57typedef SInt32      Long;
58
59typedef SLong       ArrayIndex;
60enum    IndexValues  { kEmptyIndex = -1 };
61
62enum {
63    kPosBeg = 0,            // matches lseek(2) for no good reason
64    kPosCur = 1,
65    kPosEnd = 2
66};
67
68#define nil 0
69#define EOF (-1)
70
71#define ABS(a)    ( ((a) < 0) ? -(a) : (a) )
72#define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
73#define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
74#define MINMAX(min, expr, max) ( MIN(MAX(min, expr), max) )
75#define ODD(x)    ( (x) & 1 )
76#define EVEN(x)   ( !((x) & 1) )
77
78typedef SInt32  ArrayIndex;
79typedef UInt32  BitRate;
80
81// Time stuff
82typedef SInt32  TTimeout;                   // ms if > 0, us if < 0
83#define kMicroseconds -1
84#define kMilliseconds  1
85#define kSeconds      1000
86#define k9600bps                                        9600
87#define k19200bps                                       19200
88#define k38400bps                                       38400
89#define k57600bps                                       57600
90#define k115200bps                                      115200
91#define k576000bps                                      576000
92#define k1Mbps                                          1152000
93#define k4Mbs                                           4000000
94
95
96#define BlockMove(src, dest, len)           bcopy(src, dest, len)
97#define BlockMoveData(src, dest, len)       BlockMove(x, y, len)
98
99inline Long Min(Long a, Long b)                 { return (a < b) ? a : b; }
100inline Long Max(Long a, Long b)                 { return (a > b) ? a : b; }
101inline Long MinMax(Long l, Long x, Long h)      { return Min(Max(l, x), h); }
102inline ULong UMin(ULong a, ULong b)             { return (a < b) ? a : b; }
103inline ULong UMax(ULong a, ULong b)             { return (a > b) ? a : b; }
104inline ULong UMinMax(ULong l, ULong x, ULong h) { return UMin(UMax(l, x), h); }
105
106
107#endif  // _IrDA_Types_h
108