📄 oai_template.h
字号:
//*****************************************************************************
//
// OAI.H
//
// Copyright (c) 2004 National Semiconductor Corporation.
// All Rights Reserved
//
// This header file contains OS-specific services, data-type definitions,
// etc. required by MPL. This file must be customized for each OS/Platform
// and re-named OAI.H. A version of this file will typically be created
// for each platform and exist in the NSM driver's source directory.
//
//*****************************************************************************
#ifndef _OAI_H_
#define _OAI_H_
//******************************** MPL General Options ************************
// Modify the following to set the desire MPL options
//*****************************************************************************
// On Big endian machines, uncomment the following line or define it via
// the compiler command line
//#define MPL_BIG_ENDIAN
//**************************** END OF MPL General Options *********************
//******************************** MPL Board Options ************************
// Modify the following to set options based on board design
//*****************************************************************************
// On MacPhyter boards *without* a EEPROM on them disable the below
//#define MPL_NO_EEPROM
// On MacPhyter boards that use an EXTERNAL Phy disable the below
//#define MPL_EXTERNAL_PHY
//**************************** END OF MPL Board Options *********************
//******************************** MPL Diag Mode ******************************
// Modify the following to enable MPL Diagnostics Mode
//*****************************************************************************
// Uncomment to enable Diag mode
//#define MPL_DIAG_MODE
//******************************** MPL Task Offload ***************************
// Modify the following to define MPL task offload behavior
//*****************************************************************************
// Uncomment to enable statistics collection task
//#define MPL_TASK_STAT
// Uncomment to enable VLAN offload task
//#define MPL_TASK_VLAN
// Uncomment to enable multicast filtering task
//#define MPL_TASK_MCAST
// Uncomment to enable checksum offload task
//#define MPL_TASK_STAT
//**************************** END OF MPL Task Offload Options ****************
//******************** MPL COMPILER INDEPENDENT DATA TYPES ********************
// Modify the following to define MPL data types in terms of native
// compiler data types.
//*****************************************************************************
// Note: On platforms where the natural integer size is less then 32-bits
// in size (eg 16-bit platforms), NS_UINT and NS_SINT must be defined as a
// data type no less then 32-bits in size.
typedef unsigned int NS_UINT;
typedef int NS_SINT;
// Fixed width data types/pointers
typedef unsigned char NS_CHAR;
typedef unsigned char NS_UINT8;
typedef char NS_SINT8;
typedef unsigned short NS_UINT16;
typedef short NS_SINT16;
typedef unsigned long NS_UINT32;
typedef long NS_SINT32;
// Abstract data type for physical address references
typedef unsigned int NS_ADDR;
//**************** END OF MPL COMPILER INDEPENDENT DATA TYPES *****************
// Defines the maximum number of physical adapters supported by MPL.
// Customize this value appropriate to the environment.
#define MPL_MAX_ADAPTERS 8
//******************* OAI DATA DECLARATIONS (DO NOT MODIFY) *******************
//**********************************************************************
// Function parameter annotation macros.
//**********************************************************************
#ifndef IN
#define IN
#endif // IN
#ifndef OUT
#define OUT
#endif // OUT
// Void types
typedef void NS_VOID;
// Boolean data type
typedef NS_UINT NS_BOOLEAN;
#define NS_TRUE 1
#define NS_FALSE 0
// Handle structure for returning module opaque fields
typedef NS_UINT MPL_HANDLE;
// timer callback function pointer (see OaixxxTimer functions)
typedef NS_VOID (MPL_TIMERCALLBACK)(NS_VOID *pTimerArg);
// Mac address
typedef NS_UINT8 *MPL_MAC_ADDR;
// handle for DMA region (see OaiAlloc/FreeDmaRegion)
typedef struct _MPL_MEM_REGION {
NS_VOID *pAddr; // aligned (as requested in alloc request) region ptr, logical
NS_ADDR phyAddr; // aligned (as requested in alloc request) region ptr, physical
} MPL_MEM_REGION;
//************************** OAI FUNCTION PROTOTYPES **************************
// The following are function declarations of OS services required by MPL.
// Each function must be implemented in using native OS API's and linked
// with MPL
//*****************************************************************************
#if defined(__cplusplus)
extern "C"
{
#endif
//+++++ PCI Memory Mapped I/O access Functions
//Read from PCI memory-mapped IO location 'pAddr'.
NS_UINT32
OaiIoRead32(
IN NS_VOID *pClientDevHndl,
IN NS_UINT32 volatile *pAddr
);
NS_UINT16
OaiIoRead16(
IN NS_VOID *pClientDevHndl,
IN NS_UINT16 volatile *pAddr
);
NS_UINT8
OaiIoRead8(
IN NS_VOID *pClientDevHndl,
IN NS_UINT8 volatile *pAddr
);
//Write to PCI memory-mapped IO location 'pAddr'.
NS_VOID
OaiIoWrite32(
IN NS_VOID *pClientDevHndl,
IN NS_UINT32 volatile *pAddr,
IN NS_UINT32 writeData
);
NS_VOID
OaiIoWrite16(
IN NS_VOID *pClientDevHndl,
IN NS_UINT16 volatile *pAddr,
IN NS_UINT16 writeData
);
NS_VOID
OaiIoWrite8(
IN NS_VOID *pClientDevHndl,
IN NS_UINT8 volatile *pAddr,
IN NS_UINT8 writeData
);
//+++++ Host Memory Functions
//Allocate/free a region in host memory suitable for DMA
NS_BOOLEAN
OaiAllocDmaRegion(
IN NS_VOID *pClientDevHndl,
IN NS_UINT size,
IN NS_UINT byteAlignment,
OUT MPL_MEM_REGION **pRgnHndl
);
NS_VOID
OaiFreeDmaRegion(
IN NS_VOID *pClientDevHndl,
IN MPL_MEM_REGION *pRgnHndl
);
//Allocate/free general purpose host memory
NS_VOID *
OaiMalloc(
IN NS_UINT regionSize
);
NS_VOID
OaiFree(
IN NS_UINT regionSize,
IN NS_VOID *startAddrLogical
);
//Copy/zero host memory
NS_VOID
OaiMemCopy(
IN NS_VOID *dest,
IN NS_VOID *src,
IN NS_UINT len
);
NS_VOID
OaiZeroMem(
IN NS_VOID *pMemRegion,
IN NS_UINT regionSize
);
//+++++ Timer Functions
//Delay program execution for 'sleepInterval' usec
NS_VOID
OaiSleep(
IN NS_UINT sleepInterval
);
//Return 10ms tick count
NS_UINT32
OaiGetTickCount(NS_VOID);
//Allocate/free/start/cancel periodic timer w/ callback 'pTimerFunction'
NS_BOOLEAN
OaiCreateTimer(
IN MPL_TIMERCALLBACK pTimerFunction,
IN NS_VOID *pTimerArg,
OUT NS_VOID **pTimerHandle
);
NS_VOID
OaiDeleteTimer(
IN NS_VOID *pTimerHandle
);
NS_VOID
OaiStartTimer(
IN NS_VOID *pTimerHandle,
IN NS_UINT delayInMsec
);
NS_BOOLEAN
OaiCancelTimer(
IN NS_VOID *pTimerHandle
);
//+++++ Resource Synchronization Functions
//Initialize/free/acquire/release multiprocessor-safe synchronization lock
NS_BOOLEAN
OaiCreateLock(
OUT NS_VOID **pLockHandle
);
NS_VOID
OaiDestroyLock(
IN NS_VOID *pLockHandle
);
NS_VOID
OaiAcquireLock(
IN NS_VOID *pLockHandle
);
NS_VOID
OaiReleaseLock(
IN NS_VOID *pLockHandle
);
#if defined(__cplusplus)
}
#endif
//+++++ Debug Output Abstractions - Define appropriate to the environment.
// OAI_DEBUG_MSG takes a base string parameter, and zero or more optional
// insertion parameters.
#define OAI_DEBUG_MSG define_a_debug_trace_function_here
// OAI_DEBUG_BREAK breaks into the debugger.
#define OAI_DEBUG_BREAK define_a_debug_break_function_here
//********************** END OF OAI FUNCTION PROTOTYPES ***********************
#endif // _OAI_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -