1 /***************************************************************************\ 2 |* *| 3 |* Copyright 2001-2004 NVIDIA Corporation. All Rights Reserved. *| 4 |* *| 5 |* THE INFORMATION CONTAINED HEREIN IS PROPRIETARY AND CONFIDENTIAL *| 6 |* TO NVIDIA, CORPORATION. USE, REPRODUCTION OR DISCLOSURE TO ANY *| 7 |* THIRD PARTY IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORP. *| 8 |* *| 9 |* THE INFORMATION CONTAINED HEREIN IS PROVIDED "AS IS" WITHOUT *| 10 |* EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING ALL IMPLIED *| 11 |* WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A *| 12 |* PARTICULAR PURPOSE. *| 13 |* *| 14 \***************************************************************************/ 15 16 /* 17 FILE: os.h 18 DATE: 2/7/00 19 20 This file contains the os interface. Note that the os interface is 21 itself an OS-independent API. The OS specific module is implemented 22 by ndis.c for Win9X/NT and linuxnet.c for linux. 23 */ 24 #ifndef _OS_H_ 25 #define _OS_H_ 26 27 #include "phy.h" 28 29 #define HDO_VERSION_STRING "HDR O: $Revision: #21 $"; 30 31 // This is the maximum packet size that we will be sending 32 // #define MAX_PACKET_SIZE 2048 33 //#define RX_BUFFER_SIZE 2048 34 35 #define MIN_PACKET_MTU_SIZE 576 36 #define MAX_PACKET_MTU_SIZE 9202 37 #define MAX_PACKET_SIZE_2048 2048 38 #define MAX_PACKET_SIZE_1514 1514 39 #define MAX_PACKET_SIZE_1518 1518 40 #define MAX_PACKET_SIZE_JUMBO (9 * 1024) 41 42 typedef struct _MEMORY_BLOCK 43 { 44 PNV_VOID pLogical; 45 PNV_VOID pPhysical; 46 NV_UINT32 uiLength; 47 } MEMORY_BLOCK, *PMEMORY_BLOCK; 48 49 #define ALLOC_MEMORY_NONCACHED 0x0001 50 #define ALLOC_MEMORY_ALIGNED 0x0002 51 52 typedef struct _MEMORY_BLOCKEX 53 { 54 PNV_VOID pLogical; 55 PNV_VOID pPhysical; 56 NV_UINT32 uiLength; 57 /* Parameter to OS layer to indicate what type of memory is needed */ 58 NV_UINT16 AllocFlags; 59 NV_UINT16 AlignmentSize; //always power of 2 60 /* Following three fields used for aligned memory allocation */ 61 PNV_VOID pLogicalOrig; 62 NV_UINT32 pPhysicalOrigLow; 63 NV_UINT32 pPhysicalOrigHigh; 64 NV_UINT32 uiLengthOrig; 65 } MEMORY_BLOCKEX, *PMEMORY_BLOCKEX; 66 67 68 // The typedefs for the OS functions 69 typedef NV_API_CALL NV_SINT32 (* PFN_MEMORY_ALLOC) (PNV_VOID pOSCX, PMEMORY_BLOCK pMem); 70 typedef NV_API_CALL NV_SINT32 (* PFN_MEMORY_FREE) (PNV_VOID pOSCX, PMEMORY_BLOCK pMem); 71 typedef NV_API_CALL NV_SINT32 (* PFN_MEMORY_ALLOCEX) (PNV_VOID pOSCX, PMEMORY_BLOCKEX pMem); 72 typedef NV_API_CALL NV_SINT32 (* PFN_MEMORY_FREEEX) (PNV_VOID pOSCX, PMEMORY_BLOCKEX pMem); 73 typedef NV_API_CALL NV_SINT32 (* PFN_CLEAR_MEMORY) (PNV_VOID pOSCX, PNV_VOID pMem, NV_SINT32 iLength); 74 typedef NV_API_CALL NV_SINT32 (* PFN_STALL_EXECUTION) (PNV_VOID pOSCX, NV_UINT32 ulTimeInMicroseconds); 75 typedef NV_API_CALL NV_SINT32 (* PFN_ALLOC_RECEIVE_BUFFER) (PNV_VOID pOSCX, PMEMORY_BLOCK pMem, PNV_VOID *ppvID); 76 typedef NV_API_CALL NV_SINT32 (* PFN_FREE_RECEIVE_BUFFER) (PNV_VOID pOSCX, PMEMORY_BLOCK pMem, PNV_VOID pvID); 77 typedef NV_API_CALL NV_SINT32 (* PFN_PACKET_WAS_SENT) (PNV_VOID pOSCX, PNV_VOID pvID, NV_UINT32 ulSuccess); 78 typedef NV_API_CALL NV_SINT32 (* PFN_PACKET_WAS_RECEIVED) (PNV_VOID pOSCX, PNV_VOID pvADReadData, NV_UINT32 ulSuccess, NV_UINT8 *pNewBuffer, NV_UINT8 uc8021pPriority); 79 typedef NV_API_CALL NV_SINT32 (* PFN_LINK_STATE_HAS_CHANGED) (PNV_VOID pOSCX, NV_SINT32 nEnabled); 80 typedef NV_API_CALL NV_SINT32 (* PFN_ALLOC_TIMER) (PNV_VOID pvContext, PNV_VOID *ppvTimer); 81 typedef NV_API_CALL NV_SINT32 (* PFN_FREE_TIMER) (PNV_VOID pvContext, PNV_VOID pvTimer); 82 typedef NV_API_CALL NV_SINT32 (* PFN_INITIALIZE_TIMER) (PNV_VOID pvContext, PNV_VOID pvTimer, PTIMER_FUNC pvFunc, PNV_VOID pvFuncParameter); 83 typedef NV_API_CALL NV_SINT32 (* PFN_SET_TIMER) (PNV_VOID pvContext, PNV_VOID pvTimer, NV_UINT32 dwMillisecondsDelay); 84 typedef NV_API_CALL NV_SINT32 (* PFN_CANCEL_TIMER) (PNV_VOID pvContext, PNV_VOID pvTimer); 85 86 typedef NV_API_CALL NV_SINT32 (* PFN_PREPROCESS_PACKET) (PNV_VOID pvContext, PNV_VOID pvADReadData, PNV_VOID *ppvID, 87 NV_UINT8 *pNewBuffer, NV_UINT8 uc8021pPriority); 88 typedef NV_API_CALL PNV_VOID (* PFN_PREPROCESS_PACKET_NOPQ) (PNV_VOID pvContext, PNV_VOID pvADReadData); 89 typedef NV_API_CALL NV_SINT32 (* PFN_INDICATE_PACKETS) (PNV_VOID pvContext, PNV_VOID *ppvID, NV_UINT32 ulNumPacket); 90 typedef NV_API_CALL NV_SINT32 (* PFN_LOCK_ALLOC) (PNV_VOID pOSCX, NV_SINT32 iLockType, PNV_VOID *ppvLock); 91 typedef NV_API_CALL NV_SINT32 (* PFN_LOCK_ACQUIRE) (PNV_VOID pOSCX, NV_SINT32 iLockType, PNV_VOID pvLock); 92 typedef NV_API_CALL NV_SINT32 (* PFN_LOCK_RELEASE) (PNV_VOID pOSCX, NV_SINT32 iLockType, PNV_VOID pvLock); 93 typedef NV_API_CALL PNV_VOID (* PFN_RETURN_BUFFER_VIRTUAL) (PNV_VOID pvContext, PNV_VOID pvADReadData); 94 95 // Here are the OS functions that those objects below the OS interface 96 // can call up to. 97 typedef struct _OS_API 98 { 99 // OS Context -- this is a parameter to every OS API call 100 PNV_VOID pOSCX; 101 102 // Basic OS functions 103 PFN_MEMORY_ALLOC pfnAllocMemory; 104 PFN_MEMORY_FREE pfnFreeMemory; 105 PFN_MEMORY_ALLOCEX pfnAllocMemoryEx; 106 PFN_MEMORY_FREEEX pfnFreeMemoryEx; 107 PFN_CLEAR_MEMORY pfnClearMemory; 108 PFN_STALL_EXECUTION pfnStallExecution; 109 PFN_ALLOC_RECEIVE_BUFFER pfnAllocReceiveBuffer; 110 PFN_FREE_RECEIVE_BUFFER pfnFreeReceiveBuffer; 111 PFN_PACKET_WAS_SENT pfnPacketWasSent; 112 PFN_PACKET_WAS_RECEIVED pfnPacketWasReceived; 113 PFN_LINK_STATE_HAS_CHANGED pfnLinkStateHasChanged; 114 PFN_ALLOC_TIMER pfnAllocTimer; 115 PFN_FREE_TIMER pfnFreeTimer; 116 PFN_INITIALIZE_TIMER pfnInitializeTimer; 117 PFN_SET_TIMER pfnSetTimer; 118 PFN_CANCEL_TIMER pfnCancelTimer; 119 PFN_PREPROCESS_PACKET pfnPreprocessPacket; 120 PFN_PREPROCESS_PACKET_NOPQ pfnPreprocessPacketNopq; 121 PFN_INDICATE_PACKETS pfnIndicatePackets; 122 PFN_LOCK_ALLOC pfnLockAlloc; 123 PFN_LOCK_ACQUIRE pfnLockAcquire; 124 PFN_LOCK_RELEASE pfnLockRelease; 125 PFN_RETURN_BUFFER_VIRTUAL pfnReturnBufferVirtual; 126 } OS_API, *POS_API; 127 128 #endif // _OS_H_ 129