5 This file contains the os interface. Note that the os interface is
6 itself an OS-independent API. The OS specific module is implemented
7 by ndis.c for Win9X/NT and linuxnet.c for linux.
14 #define HDO_VERSION_STRING "HDR O: $Revision: #21 $";
16 // This is the maximum packet size that we will be sending
17 #define MAX_PACKET_SIZE 2048
18 //#define RX_BUFFER_SIZE 2048
20 typedef struct _MEMORY_BLOCK
25 } MEMORY_BLOCK, *PMEMORY_BLOCK;
27 #define ALLOC_MEMORY_NONCACHED 0x0001
28 #define ALLOC_MEMORY_ALIGNED 0x0002
30 typedef struct _MEMORY_BLOCKEX
35 /* Parameter to OS layer to indicate what type of memory is needed */
37 USHORT AlignmentSize; //always power of 2
38 /* Following three fields used for aligned memory allocation */
40 ULONG pPhysicalOrigLow;
41 ULONG pPhysicalOrigHigh;
43 } MEMORY_BLOCKEX, *PMEMORY_BLOCKEX;
46 // The typedefs for the OS functions
47 typedef int (* PFN_MEMORY_ALLOC) (PVOID pOSCX, PMEMORY_BLOCK pMem);
48 typedef int (* PFN_MEMORY_FREE) (PVOID pOSCX, PMEMORY_BLOCK pMem);
49 typedef int (* PFN_MEMORY_ALLOCEX) (PVOID pOSCX, PMEMORY_BLOCKEX pMem);
50 typedef int (* PFN_MEMORY_FREEEX) (PVOID pOSCX, PMEMORY_BLOCKEX pMem);
51 typedef int (* PFN_CLEAR_MEMORY) (PVOID pOSCX, PVOID pMem, int iLength);
52 typedef int (* PFN_STALL_EXECUTION) (PVOID pOSCX, ULONG ulTimeInMicroseconds);
53 typedef int (* PFN_ALLOC_RECEIVE_BUFFER) (PVOID pOSCX, PMEMORY_BLOCK pMem, PVOID *ppvID);
54 typedef int (* PFN_FREE_RECEIVE_BUFFER) (PVOID pOSCX, PMEMORY_BLOCK pMem, PVOID pvID);
55 typedef int (* PFN_PACKET_WAS_SENT) (PVOID pOSCX, PVOID pvID, ULONG ulSuccess);
56 typedef int (* PFN_PACKET_WAS_RECEIVED) (PVOID pOSCX, PVOID pvADReadData, ULONG ulSuccess, UCHAR *pNewBuffer, UCHAR uc8021pPriority);
57 typedef int (* PFN_LINK_STATE_HAS_CHANGED) (PVOID pOSCX, int nEnabled);
58 typedef int (* PFN_ALLOC_TIMER) (PVOID pvContext, PVOID *ppvTimer);
59 typedef int (* PFN_FREE_TIMER) (PVOID pvContext, PVOID pvTimer);
60 typedef int (* PFN_INITIALIZE_TIMER) (PVOID pvContext, PVOID pvTimer, PTIMER_FUNC pvFunc, PVOID pvFuncParameter);
61 typedef int (* PFN_SET_TIMER) (PVOID pvContext, PVOID pvTimer, ULONG dwMillisecondsDelay);
62 typedef int (* PFN_CANCEL_TIMER) (PVOID pvContext, PVOID pvTimer);
64 typedef int (* PFN_PREPROCESS_PACKET) (PVOID pvContext, PVOID pvADReadData, PVOID *ppvID,
65 UCHAR *pNewBuffer, UCHAR uc8021pPriority);
66 typedef PVOID (* PFN_PREPROCESS_PACKET_NOPQ) (PVOID pvContext, PVOID pvADReadData);
67 typedef int (* PFN_INDICATE_PACKETS) (PVOID pvContext, PVOID *ppvID, ULONG ulNumPacket);
68 typedef int (* PFN_LOCK_ALLOC) (PVOID pOSCX, int iLockType, PVOID *ppvLock);
69 typedef int (* PFN_LOCK_ACQUIRE) (PVOID pOSCX, int iLockType, PVOID pvLock);
70 typedef int (* PFN_LOCK_RELEASE) (PVOID pOSCX, int iLockType, PVOID pvLock);
71 typedef PVOID (* PFN_RETURN_BUFFER_VIRTUAL) (PVOID pvContext, PVOID pvADReadData);
73 // Here are the OS functions that those objects below the OS interface
75 typedef struct _OS_API
77 // OS Context -- this is a parameter to every OS API call
81 PFN_MEMORY_ALLOC pfnAllocMemory;
82 PFN_MEMORY_FREE pfnFreeMemory;
83 PFN_MEMORY_ALLOCEX pfnAllocMemoryEx;
84 PFN_MEMORY_FREEEX pfnFreeMemoryEx;
85 PFN_CLEAR_MEMORY pfnClearMemory;
86 PFN_STALL_EXECUTION pfnStallExecution;
87 PFN_ALLOC_RECEIVE_BUFFER pfnAllocReceiveBuffer;
88 PFN_FREE_RECEIVE_BUFFER pfnFreeReceiveBuffer;
89 PFN_PACKET_WAS_SENT pfnPacketWasSent;
90 PFN_PACKET_WAS_RECEIVED pfnPacketWasReceived;
91 PFN_LINK_STATE_HAS_CHANGED pfnLinkStateHasChanged;
92 PFN_ALLOC_TIMER pfnAllocTimer;
93 PFN_FREE_TIMER pfnFreeTimer;
94 PFN_INITIALIZE_TIMER pfnInitializeTimer;
95 PFN_SET_TIMER pfnSetTimer;
96 PFN_CANCEL_TIMER pfnCancelTimer;
97 PFN_PREPROCESS_PACKET pfnPreprocessPacket;
98 PFN_PREPROCESS_PACKET_NOPQ pfnPreprocessPacketNopq;
99 PFN_INDICATE_PACKETS pfnIndicatePackets;
100 PFN_LOCK_ALLOC pfnLockAlloc;
101 PFN_LOCK_ACQUIRE pfnLockAcquire;
102 PFN_LOCK_RELEASE pfnLockRelease;
103 PFN_RETURN_BUFFER_VIRTUAL pfnReturnBufferVirtual;