1*852ba100SJustin Hibbits /* Copyright (c) 2008-2012 Freescale Semiconductor, Inc 20aeed3e9SJustin Hibbits * All rights reserved. 30aeed3e9SJustin Hibbits * 40aeed3e9SJustin Hibbits * Redistribution and use in source and binary forms, with or without 50aeed3e9SJustin Hibbits * modification, are permitted provided that the following conditions are met: 60aeed3e9SJustin Hibbits * * Redistributions of source code must retain the above copyright 70aeed3e9SJustin Hibbits * notice, this list of conditions and the following disclaimer. 80aeed3e9SJustin Hibbits * * Redistributions in binary form must reproduce the above copyright 90aeed3e9SJustin Hibbits * notice, this list of conditions and the following disclaimer in the 100aeed3e9SJustin Hibbits * documentation and/or other materials provided with the distribution. 110aeed3e9SJustin Hibbits * * Neither the name of Freescale Semiconductor nor the 120aeed3e9SJustin Hibbits * names of its contributors may be used to endorse or promote products 130aeed3e9SJustin Hibbits * derived from this software without specific prior written permission. 140aeed3e9SJustin Hibbits * 150aeed3e9SJustin Hibbits * 160aeed3e9SJustin Hibbits * ALTERNATIVELY, this software may be distributed under the terms of the 170aeed3e9SJustin Hibbits * GNU General Public License ("GPL") as published by the Free Software 180aeed3e9SJustin Hibbits * Foundation, either version 2 of that License or (at your option) any 190aeed3e9SJustin Hibbits * later version. 200aeed3e9SJustin Hibbits * 210aeed3e9SJustin Hibbits * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY 220aeed3e9SJustin Hibbits * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 230aeed3e9SJustin Hibbits * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 240aeed3e9SJustin Hibbits * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY 250aeed3e9SJustin Hibbits * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 260aeed3e9SJustin Hibbits * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 270aeed3e9SJustin Hibbits * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 280aeed3e9SJustin Hibbits * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 290aeed3e9SJustin Hibbits * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 300aeed3e9SJustin Hibbits * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 310aeed3e9SJustin Hibbits */ 320aeed3e9SJustin Hibbits 33*852ba100SJustin Hibbits 340aeed3e9SJustin Hibbits /**************************************************************************//** 350aeed3e9SJustin Hibbits @File ncsw_ext.h 360aeed3e9SJustin Hibbits 370aeed3e9SJustin Hibbits @Description General NetCommSw Standard Definitions 380aeed3e9SJustin Hibbits *//***************************************************************************/ 390aeed3e9SJustin Hibbits 400aeed3e9SJustin Hibbits #ifndef __NCSW_EXT_H 410aeed3e9SJustin Hibbits #define __NCSW_EXT_H 420aeed3e9SJustin Hibbits 43*852ba100SJustin Hibbits 440aeed3e9SJustin Hibbits #include "memcpy_ext.h" 450aeed3e9SJustin Hibbits 46*852ba100SJustin Hibbits #define WRITE_BLOCK IOMemSet32 /* include memcpy_ext.h */ 47*852ba100SJustin Hibbits #define COPY_BLOCK Mem2IOCpy32 /* include memcpy_ext.h */ 480aeed3e9SJustin Hibbits 490aeed3e9SJustin Hibbits #define PTR_TO_UINT(_ptr) ((uintptr_t)(_ptr)) 500aeed3e9SJustin Hibbits #define UINT_TO_PTR(_val) ((void*)(uintptr_t)(_val)) 510aeed3e9SJustin Hibbits 520aeed3e9SJustin Hibbits #define PTR_MOVE(_ptr, _offset) (void*)((uint8_t*)(_ptr) + (_offset)) 530aeed3e9SJustin Hibbits 540aeed3e9SJustin Hibbits 55*852ba100SJustin Hibbits #define WRITE_UINT8_UINT24(arg, data08, data24) \ 56*852ba100SJustin Hibbits WRITE_UINT32(arg,((uint32_t)(data08)<<24)|((uint32_t)(data24)&0x00FFFFFF)) 57*852ba100SJustin Hibbits #define WRITE_UINT24_UINT8(arg, data24, data08) \ 58*852ba100SJustin Hibbits WRITE_UINT32(arg,((uint32_t)(data24)<< 8)|((uint32_t)(data08)&0x000000FF)) 590aeed3e9SJustin Hibbits 600aeed3e9SJustin Hibbits /* Little-Endian access macros */ 610aeed3e9SJustin Hibbits 620aeed3e9SJustin Hibbits #define WRITE_UINT16_LE(arg, data) \ 630aeed3e9SJustin Hibbits WRITE_UINT16((arg), SwapUint16(data)) 640aeed3e9SJustin Hibbits 650aeed3e9SJustin Hibbits #define WRITE_UINT32_LE(arg, data) \ 660aeed3e9SJustin Hibbits WRITE_UINT32((arg), SwapUint32(data)) 670aeed3e9SJustin Hibbits 680aeed3e9SJustin Hibbits #define WRITE_UINT64_LE(arg, data) \ 690aeed3e9SJustin Hibbits WRITE_UINT64((arg), SwapUint64(data)) 700aeed3e9SJustin Hibbits 710aeed3e9SJustin Hibbits #define GET_UINT16_LE(arg) \ 720aeed3e9SJustin Hibbits SwapUint16(GET_UINT16(arg)) 730aeed3e9SJustin Hibbits 740aeed3e9SJustin Hibbits #define GET_UINT32_LE(arg) \ 750aeed3e9SJustin Hibbits SwapUint32(GET_UINT32(arg)) 760aeed3e9SJustin Hibbits 770aeed3e9SJustin Hibbits #define GET_UINT64_LE(arg) \ 780aeed3e9SJustin Hibbits SwapUint64(GET_UINT64(arg)) 790aeed3e9SJustin Hibbits 800aeed3e9SJustin Hibbits /* Write and Read again macros */ 810aeed3e9SJustin Hibbits #define WRITE_UINT_SYNC(size, arg, data) \ 820aeed3e9SJustin Hibbits do { \ 830aeed3e9SJustin Hibbits WRITE_UINT##size((arg), (data)); \ 840aeed3e9SJustin Hibbits CORE_MemoryBarrier(); \ 850aeed3e9SJustin Hibbits } while (0) 860aeed3e9SJustin Hibbits 870aeed3e9SJustin Hibbits #define WRITE_UINT8_SYNC(arg, data) WRITE_UINT_SYNC(8, (arg), (data)) 880aeed3e9SJustin Hibbits 890aeed3e9SJustin Hibbits #define WRITE_UINT16_SYNC(arg, data) WRITE_UINT_SYNC(16, (arg), (data)) 900aeed3e9SJustin Hibbits #define WRITE_UINT32_SYNC(arg, data) WRITE_UINT_SYNC(32, (arg), (data)) 910aeed3e9SJustin Hibbits 920aeed3e9SJustin Hibbits #define MAKE_UINT64(high32, low32) (((uint64_t)high32 << 32) | (low32)) 930aeed3e9SJustin Hibbits 940aeed3e9SJustin Hibbits 950aeed3e9SJustin Hibbits /*----------------------*/ 960aeed3e9SJustin Hibbits /* Miscellaneous macros */ 970aeed3e9SJustin Hibbits /*----------------------*/ 980aeed3e9SJustin Hibbits 99*852ba100SJustin Hibbits #define UNUSED(_x) ((void)(_x)) 1000aeed3e9SJustin Hibbits 1010aeed3e9SJustin Hibbits #define KILOBYTE 0x400UL /* 1024 */ 1020aeed3e9SJustin Hibbits #define MEGABYTE (KILOBYTE * KILOBYTE) /* 1024*1024 */ 103*852ba100SJustin Hibbits #define GIGABYTE ((uint64_t)(KILOBYTE * MEGABYTE)) /* 1024*1024*1024 */ 104*852ba100SJustin Hibbits #define TERABYTE ((uint64_t)(KILOBYTE * GIGABYTE)) /* 1024*1024*1024*1024 */ 1050aeed3e9SJustin Hibbits 106*852ba100SJustin Hibbits #ifndef NO_IRQ 107*852ba100SJustin Hibbits #define NO_IRQ (0) 108*852ba100SJustin Hibbits #endif 1090aeed3e9SJustin Hibbits #define NCSW_MASTER_ID (0) 1100aeed3e9SJustin Hibbits 1110aeed3e9SJustin Hibbits /* Macro for checking if a number is a power of 2 */ 1120aeed3e9SJustin Hibbits #define POWER_OF_2(n) (!((n) & ((n)-1))) 1130aeed3e9SJustin Hibbits 1140aeed3e9SJustin Hibbits /* Macro for calculating log of base 2 */ 1150aeed3e9SJustin Hibbits #define LOG2(num, log2Num) \ 1160aeed3e9SJustin Hibbits do \ 1170aeed3e9SJustin Hibbits { \ 1180aeed3e9SJustin Hibbits uint64_t tmp = (num); \ 1190aeed3e9SJustin Hibbits log2Num = 0; \ 1200aeed3e9SJustin Hibbits while (tmp > 1) \ 1210aeed3e9SJustin Hibbits { \ 1220aeed3e9SJustin Hibbits log2Num++; \ 1230aeed3e9SJustin Hibbits tmp >>= 1; \ 1240aeed3e9SJustin Hibbits } \ 1250aeed3e9SJustin Hibbits } while (0) 1260aeed3e9SJustin Hibbits 1270aeed3e9SJustin Hibbits #define NEXT_POWER_OF_2(_num, _nextPow) \ 1280aeed3e9SJustin Hibbits do \ 1290aeed3e9SJustin Hibbits { \ 1300aeed3e9SJustin Hibbits if (POWER_OF_2(_num)) \ 1310aeed3e9SJustin Hibbits _nextPow = (_num); \ 1320aeed3e9SJustin Hibbits else \ 1330aeed3e9SJustin Hibbits { \ 1340aeed3e9SJustin Hibbits uint64_t tmp = (_num); \ 1350aeed3e9SJustin Hibbits _nextPow = 1; \ 1360aeed3e9SJustin Hibbits while (tmp) \ 1370aeed3e9SJustin Hibbits { \ 1380aeed3e9SJustin Hibbits _nextPow <<= 1; \ 1390aeed3e9SJustin Hibbits tmp >>= 1; \ 1400aeed3e9SJustin Hibbits } \ 1410aeed3e9SJustin Hibbits } \ 1420aeed3e9SJustin Hibbits } while (0) 1430aeed3e9SJustin Hibbits 1440aeed3e9SJustin Hibbits /* Ceiling division - not the fastest way, but safer in terms of overflow */ 145*852ba100SJustin Hibbits #define DIV_CEIL(x,y) (((x)/(y)) + (((((x)/(y))*(y)) == (x)) ? 0 : 1)) 1460aeed3e9SJustin Hibbits 1470aeed3e9SJustin Hibbits /* Round up a number to be a multiple of a second number */ 1480aeed3e9SJustin Hibbits #define ROUND_UP(x,y) ((((x) + (y) - 1) / (y)) * (y)) 1490aeed3e9SJustin Hibbits 1500aeed3e9SJustin Hibbits /* Timing macro for converting usec units to number of ticks. */ 1510aeed3e9SJustin Hibbits /* (number of usec * clock_Hz) / 1,000,000) - since */ 1520aeed3e9SJustin Hibbits /* clk is in MHz units, no division needed. */ 1530aeed3e9SJustin Hibbits #define USEC_TO_CLK(usec,clk) ((usec) * (clk)) 1540aeed3e9SJustin Hibbits #define CYCLES_TO_USEC(cycles,clk) ((cycles) / (clk)) 1550aeed3e9SJustin Hibbits 1560aeed3e9SJustin Hibbits /* Timing macros for converting between nsec units and number of clocks. */ 1570aeed3e9SJustin Hibbits #define NSEC_TO_CLK(nsec,clk) DIV_CEIL(((nsec) * (clk)), 1000) 1580aeed3e9SJustin Hibbits #define CYCLES_TO_NSEC(cycles,clk) (((cycles) * 1000) / (clk)) 1590aeed3e9SJustin Hibbits 1600aeed3e9SJustin Hibbits /* Timing macros for converting between psec units and number of clocks. */ 1610aeed3e9SJustin Hibbits #define PSEC_TO_CLK(psec,clk) DIV_CEIL(((psec) * (clk)), 1000000) 1620aeed3e9SJustin Hibbits #define CYCLES_TO_PSEC(cycles,clk) (((cycles) * 1000000) / (clk)) 1630aeed3e9SJustin Hibbits 1640aeed3e9SJustin Hibbits /* Min, Max macros */ 1650aeed3e9SJustin Hibbits #define IN_RANGE(min,val,max) ((min)<=(val) && (val)<=(max)) 1660aeed3e9SJustin Hibbits 1670aeed3e9SJustin Hibbits #define ABS(a) ((a<0)?(a*-1):a) 1680aeed3e9SJustin Hibbits 1690aeed3e9SJustin Hibbits #if !(defined(ARRAY_SIZE)) 1700aeed3e9SJustin Hibbits #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 1710aeed3e9SJustin Hibbits #endif /* !defined(ARRAY_SIZE) */ 1720aeed3e9SJustin Hibbits 1730aeed3e9SJustin Hibbits 1740aeed3e9SJustin Hibbits /* possible alignments */ 1750aeed3e9SJustin Hibbits #define HALF_WORD_ALIGNMENT 2 1760aeed3e9SJustin Hibbits #define WORD_ALIGNMENT 4 1770aeed3e9SJustin Hibbits #define DOUBLE_WORD_ALIGNMENT 8 1780aeed3e9SJustin Hibbits #define BURST_ALIGNMENT 32 1790aeed3e9SJustin Hibbits 1800aeed3e9SJustin Hibbits #define HALF_WORD_ALIGNED 0x00000001 1810aeed3e9SJustin Hibbits #define WORD_ALIGNED 0x00000003 1820aeed3e9SJustin Hibbits #define DOUBLE_WORD_ALIGNED 0x00000007 1830aeed3e9SJustin Hibbits #define BURST_ALIGNED 0x0000001f 1840aeed3e9SJustin Hibbits #ifndef IS_ALIGNED 1850aeed3e9SJustin Hibbits #define IS_ALIGNED(n,align) (!((uint32_t)(n) & (align - 1))) 1860aeed3e9SJustin Hibbits #endif /* IS_ALIGNED */ 1870aeed3e9SJustin Hibbits 1880aeed3e9SJustin Hibbits 1890aeed3e9SJustin Hibbits #define LAST_BUF 1 1900aeed3e9SJustin Hibbits #define FIRST_BUF 2 1910aeed3e9SJustin Hibbits #define SINGLE_BUF (LAST_BUF | FIRST_BUF) 1920aeed3e9SJustin Hibbits #define MIDDLE_BUF 4 1930aeed3e9SJustin Hibbits 1940aeed3e9SJustin Hibbits #define ARRAY_END -1 1950aeed3e9SJustin Hibbits 1960aeed3e9SJustin Hibbits #define ILLEGAL_BASE (~0) 1970aeed3e9SJustin Hibbits 1980aeed3e9SJustin Hibbits #define BUF_POSITION(first, last) state[(!!(last))<<1 | !!(first)] 1990aeed3e9SJustin Hibbits #define DECLARE_POSITION static uint8_t state[4] = { (uint8_t)MIDDLE_BUF, (uint8_t)FIRST_BUF, (uint8_t)LAST_BUF, (uint8_t)SINGLE_BUF }; 2000aeed3e9SJustin Hibbits 2010aeed3e9SJustin Hibbits 2020aeed3e9SJustin Hibbits /**************************************************************************//** 2030aeed3e9SJustin Hibbits @Description Timers operation mode 2040aeed3e9SJustin Hibbits *//***************************************************************************/ 2050aeed3e9SJustin Hibbits typedef enum e_TimerMode 2060aeed3e9SJustin Hibbits { 2070aeed3e9SJustin Hibbits e_TIMER_MODE_INVALID = 0, 2080aeed3e9SJustin Hibbits e_TIMER_MODE_FREE_RUN, /**< Free run - counter continues to increase 2090aeed3e9SJustin Hibbits after reaching the reference value. */ 2100aeed3e9SJustin Hibbits e_TIMER_MODE_PERIODIC, /**< Periodic - counter restarts counting from 0 2110aeed3e9SJustin Hibbits after reaching the reference value. */ 2120aeed3e9SJustin Hibbits e_TIMER_MODE_SINGLE /**< Single (one-shot) - counter stops counting 2130aeed3e9SJustin Hibbits after reaching the reference value. */ 2140aeed3e9SJustin Hibbits } e_TimerMode; 2150aeed3e9SJustin Hibbits 2160aeed3e9SJustin Hibbits 2170aeed3e9SJustin Hibbits /**************************************************************************//** 2180aeed3e9SJustin Hibbits @Description Enumeration (bit flags) of communication modes (Transmit, 2190aeed3e9SJustin Hibbits receive or both). 2200aeed3e9SJustin Hibbits *//***************************************************************************/ 2210aeed3e9SJustin Hibbits typedef enum e_CommMode 2220aeed3e9SJustin Hibbits { 2230aeed3e9SJustin Hibbits e_COMM_MODE_NONE = 0, /**< No transmit/receive communication */ 2240aeed3e9SJustin Hibbits e_COMM_MODE_RX = 1, /**< Only receive communication */ 2250aeed3e9SJustin Hibbits e_COMM_MODE_TX = 2, /**< Only transmit communication */ 2260aeed3e9SJustin Hibbits e_COMM_MODE_RX_AND_TX = 3 /**< Both transmit and receive communication */ 2270aeed3e9SJustin Hibbits } e_CommMode; 2280aeed3e9SJustin Hibbits 2290aeed3e9SJustin Hibbits /**************************************************************************//** 2300aeed3e9SJustin Hibbits @Description General Diagnostic Mode 2310aeed3e9SJustin Hibbits *//***************************************************************************/ 2320aeed3e9SJustin Hibbits typedef enum e_DiagMode 2330aeed3e9SJustin Hibbits { 2340aeed3e9SJustin Hibbits e_DIAG_MODE_NONE = 0, /**< Normal operation; no diagnostic mode */ 2350aeed3e9SJustin Hibbits e_DIAG_MODE_CTRL_LOOPBACK, /**< Loopback in the controller */ 2360aeed3e9SJustin Hibbits e_DIAG_MODE_CHIP_LOOPBACK, /**< Loopback in the chip but not in the 2370aeed3e9SJustin Hibbits controller; e.g. IO-pins, SerDes, etc. */ 2380aeed3e9SJustin Hibbits e_DIAG_MODE_PHY_LOOPBACK, /**< Loopback in the external PHY */ 2390aeed3e9SJustin Hibbits e_DIAG_MODE_EXT_LOOPBACK, /**< Loopback in the external line (beyond the PHY) */ 2400aeed3e9SJustin Hibbits e_DIAG_MODE_CTRL_ECHO, /**< Echo incoming data by the controller */ 2410aeed3e9SJustin Hibbits e_DIAG_MODE_PHY_ECHO /**< Echo incoming data by the PHY */ 2420aeed3e9SJustin Hibbits } e_DiagMode; 2430aeed3e9SJustin Hibbits 2440aeed3e9SJustin Hibbits /**************************************************************************//** 2450aeed3e9SJustin Hibbits @Description Possible RxStore callback responses. 2460aeed3e9SJustin Hibbits *//***************************************************************************/ 2470aeed3e9SJustin Hibbits typedef enum e_RxStoreResponse 2480aeed3e9SJustin Hibbits { 2490aeed3e9SJustin Hibbits e_RX_STORE_RESPONSE_PAUSE /**< Pause invoking callback with received data; 2500aeed3e9SJustin Hibbits in polling mode, start again invoking callback 2510aeed3e9SJustin Hibbits only next time user invokes the receive routine; 2520aeed3e9SJustin Hibbits in interrupt mode, start again invoking callback 2530aeed3e9SJustin Hibbits only next time a receive event triggers an interrupt; 2540aeed3e9SJustin Hibbits in all cases, received data that are pending are not 2550aeed3e9SJustin Hibbits lost, rather, their processing is temporarily deferred; 2560aeed3e9SJustin Hibbits in all cases, received data are processed in the order 2570aeed3e9SJustin Hibbits in which they were received. */ 2580aeed3e9SJustin Hibbits , e_RX_STORE_RESPONSE_CONTINUE /**< Continue invoking callback with received data. */ 2590aeed3e9SJustin Hibbits } e_RxStoreResponse; 2600aeed3e9SJustin Hibbits 2610aeed3e9SJustin Hibbits 2620aeed3e9SJustin Hibbits /**************************************************************************//** 2630aeed3e9SJustin Hibbits @Description General Handle 2640aeed3e9SJustin Hibbits *//***************************************************************************/ 2650aeed3e9SJustin Hibbits typedef void * t_Handle; /**< handle, used as object's descriptor */ 2660aeed3e9SJustin Hibbits 2670aeed3e9SJustin Hibbits /**************************************************************************//** 2680aeed3e9SJustin Hibbits @Description MUTEX type 2690aeed3e9SJustin Hibbits *//***************************************************************************/ 2700aeed3e9SJustin Hibbits typedef uint32_t t_Mutex; 2710aeed3e9SJustin Hibbits 2720aeed3e9SJustin Hibbits /**************************************************************************//** 2730aeed3e9SJustin Hibbits @Description Error Code. 2740aeed3e9SJustin Hibbits 2750aeed3e9SJustin Hibbits The high word of the error code is the code of the software 2760aeed3e9SJustin Hibbits module (driver). The low word is the error type (e_ErrorType). 2770aeed3e9SJustin Hibbits To get the values from the error code, use GET_ERROR_TYPE() 2780aeed3e9SJustin Hibbits and GET_ERROR_MODULE(). 2790aeed3e9SJustin Hibbits *//***************************************************************************/ 2800aeed3e9SJustin Hibbits typedef uint32_t t_Error; 2810aeed3e9SJustin Hibbits 2820aeed3e9SJustin Hibbits /**************************************************************************//** 2830aeed3e9SJustin Hibbits @Description General prototype of interrupt service routine (ISR). 2840aeed3e9SJustin Hibbits 2850aeed3e9SJustin Hibbits @Param[in] handle - Optional handle of the module handling the interrupt. 2860aeed3e9SJustin Hibbits 2870aeed3e9SJustin Hibbits @Return None 2880aeed3e9SJustin Hibbits *//***************************************************************************/ 2890aeed3e9SJustin Hibbits typedef void (t_Isr)(t_Handle handle); 2900aeed3e9SJustin Hibbits 2910aeed3e9SJustin Hibbits /**************************************************************************//** 2920aeed3e9SJustin Hibbits @Anchor mem_attr 2930aeed3e9SJustin Hibbits 2940aeed3e9SJustin Hibbits @Collection Memory Attributes 2950aeed3e9SJustin Hibbits 2960aeed3e9SJustin Hibbits Various attributes of memory partitions. These values may be 2970aeed3e9SJustin Hibbits or'ed together to create a mask of all memory attributes. 2980aeed3e9SJustin Hibbits @{ 2990aeed3e9SJustin Hibbits *//***************************************************************************/ 3000aeed3e9SJustin Hibbits #define MEMORY_ATTR_CACHEABLE 0x00000001 3010aeed3e9SJustin Hibbits /**< Memory is cacheable */ 3020aeed3e9SJustin Hibbits #define MEMORY_ATTR_QE_2ND_BUS_ACCESS 0x00000002 3030aeed3e9SJustin Hibbits /**< Memory can be accessed by QUICC Engine 3040aeed3e9SJustin Hibbits through its secondary bus interface */ 3050aeed3e9SJustin Hibbits 3060aeed3e9SJustin Hibbits /* @} */ 3070aeed3e9SJustin Hibbits 3080aeed3e9SJustin Hibbits 3090aeed3e9SJustin Hibbits /**************************************************************************//** 3100aeed3e9SJustin Hibbits @Function t_GetBufFunction 3110aeed3e9SJustin Hibbits 3120aeed3e9SJustin Hibbits @Description User callback function called by driver to get data buffer. 3130aeed3e9SJustin Hibbits 3140aeed3e9SJustin Hibbits User provides this function. Driver invokes it. 3150aeed3e9SJustin Hibbits 3160aeed3e9SJustin Hibbits @Param[in] h_BufferPool - A handle to buffer pool manager 3170aeed3e9SJustin Hibbits @Param[out] p_BufContextHandle - Returns the user's private context that 3180aeed3e9SJustin Hibbits should be associated with the buffer 3190aeed3e9SJustin Hibbits 3200aeed3e9SJustin Hibbits @Return Pointer to data buffer, NULL if error 3210aeed3e9SJustin Hibbits *//***************************************************************************/ 3220aeed3e9SJustin Hibbits typedef uint8_t * (t_GetBufFunction)(t_Handle h_BufferPool, 3230aeed3e9SJustin Hibbits t_Handle *p_BufContextHandle); 3240aeed3e9SJustin Hibbits 3250aeed3e9SJustin Hibbits /**************************************************************************//** 3260aeed3e9SJustin Hibbits @Function t_PutBufFunction 3270aeed3e9SJustin Hibbits 3280aeed3e9SJustin Hibbits @Description User callback function called by driver to return data buffer. 3290aeed3e9SJustin Hibbits 3300aeed3e9SJustin Hibbits User provides this function. Driver invokes it. 3310aeed3e9SJustin Hibbits 3320aeed3e9SJustin Hibbits @Param[in] h_BufferPool - A handle to buffer pool manager 3330aeed3e9SJustin Hibbits @Param[in] p_Buffer - A pointer to buffer to return 3340aeed3e9SJustin Hibbits @Param[in] h_BufContext - The user's private context associated with 3350aeed3e9SJustin Hibbits the returned buffer 3360aeed3e9SJustin Hibbits 3370aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise 3380aeed3e9SJustin Hibbits *//***************************************************************************/ 3390aeed3e9SJustin Hibbits typedef t_Error (t_PutBufFunction)(t_Handle h_BufferPool, 3400aeed3e9SJustin Hibbits uint8_t *p_Buffer, 3410aeed3e9SJustin Hibbits t_Handle h_BufContext); 3420aeed3e9SJustin Hibbits 3430aeed3e9SJustin Hibbits /**************************************************************************//** 3440aeed3e9SJustin Hibbits @Function t_PhysToVirt 3450aeed3e9SJustin Hibbits 3460aeed3e9SJustin Hibbits @Description Translates a physical address to the matching virtual address. 3470aeed3e9SJustin Hibbits 3480aeed3e9SJustin Hibbits @Param[in] addr - The physical address to translate. 3490aeed3e9SJustin Hibbits 3500aeed3e9SJustin Hibbits @Return Virtual address. 3510aeed3e9SJustin Hibbits *//***************************************************************************/ 3520aeed3e9SJustin Hibbits typedef void * t_PhysToVirt(physAddress_t addr); 3530aeed3e9SJustin Hibbits 3540aeed3e9SJustin Hibbits /**************************************************************************//** 3550aeed3e9SJustin Hibbits @Function t_VirtToPhys 3560aeed3e9SJustin Hibbits 3570aeed3e9SJustin Hibbits @Description Translates a virtual address to the matching physical address. 3580aeed3e9SJustin Hibbits 3590aeed3e9SJustin Hibbits @Param[in] addr - The virtual address to translate. 3600aeed3e9SJustin Hibbits 3610aeed3e9SJustin Hibbits @Return Physical address. 3620aeed3e9SJustin Hibbits *//***************************************************************************/ 3630aeed3e9SJustin Hibbits typedef physAddress_t t_VirtToPhys(void *addr); 3640aeed3e9SJustin Hibbits 3650aeed3e9SJustin Hibbits /**************************************************************************//** 3660aeed3e9SJustin Hibbits @Description Buffer Pool Information Structure. 3670aeed3e9SJustin Hibbits *//***************************************************************************/ 3680aeed3e9SJustin Hibbits typedef struct t_BufferPoolInfo 3690aeed3e9SJustin Hibbits { 3700aeed3e9SJustin Hibbits t_Handle h_BufferPool; /**< A handle to the buffer pool manager */ 3710aeed3e9SJustin Hibbits t_GetBufFunction *f_GetBuf; /**< User callback to get a free buffer */ 3720aeed3e9SJustin Hibbits t_PutBufFunction *f_PutBuf; /**< User callback to return a buffer */ 3730aeed3e9SJustin Hibbits uint16_t bufferSize; /**< Buffer size (in bytes) */ 3740aeed3e9SJustin Hibbits 3750aeed3e9SJustin Hibbits t_PhysToVirt *f_PhysToVirt; /**< User callback to translate pool buffers 3760aeed3e9SJustin Hibbits physical addresses to virtual addresses */ 3770aeed3e9SJustin Hibbits t_VirtToPhys *f_VirtToPhys; /**< User callback to translate pool buffers 3780aeed3e9SJustin Hibbits virtual addresses to physical addresses */ 3790aeed3e9SJustin Hibbits } t_BufferPoolInfo; 3800aeed3e9SJustin Hibbits 3810aeed3e9SJustin Hibbits 3820aeed3e9SJustin Hibbits /**************************************************************************//** 3830aeed3e9SJustin Hibbits @Description User callback function called by driver when transmit completed. 3840aeed3e9SJustin Hibbits 3850aeed3e9SJustin Hibbits User provides this function. Driver invokes it. 3860aeed3e9SJustin Hibbits 3870aeed3e9SJustin Hibbits @Param[in] h_App - Application's handle, as was provided to the 3880aeed3e9SJustin Hibbits driver by the user 3890aeed3e9SJustin Hibbits @Param[in] queueId - Transmit queue ID 3900aeed3e9SJustin Hibbits @Param[in] p_Data - Pointer to the data buffer 3910aeed3e9SJustin Hibbits @Param[in] h_BufContext - The user's private context associated with 3920aeed3e9SJustin Hibbits the given data buffer 3930aeed3e9SJustin Hibbits @Param[in] status - Transmit status and errors 3940aeed3e9SJustin Hibbits @Param[in] flags - Driver-dependent information 3950aeed3e9SJustin Hibbits *//***************************************************************************/ 3960aeed3e9SJustin Hibbits typedef void (t_TxConfFunction)(t_Handle h_App, 3970aeed3e9SJustin Hibbits uint32_t queueId, 3980aeed3e9SJustin Hibbits uint8_t *p_Data, 3990aeed3e9SJustin Hibbits t_Handle h_BufContext, 4000aeed3e9SJustin Hibbits uint16_t status, 4010aeed3e9SJustin Hibbits uint32_t flags); 4020aeed3e9SJustin Hibbits 4030aeed3e9SJustin Hibbits /**************************************************************************//** 4040aeed3e9SJustin Hibbits @Description User callback function called by driver with receive data. 4050aeed3e9SJustin Hibbits 4060aeed3e9SJustin Hibbits User provides this function. Driver invokes it. 4070aeed3e9SJustin Hibbits 4080aeed3e9SJustin Hibbits @Param[in] h_App - Application's handle, as was provided to the 4090aeed3e9SJustin Hibbits driver by the user 4100aeed3e9SJustin Hibbits @Param[in] queueId - Receive queue ID 4110aeed3e9SJustin Hibbits @Param[in] p_Data - Pointer to the buffer with received data 4120aeed3e9SJustin Hibbits @Param[in] h_BufContext - The user's private context associated with 4130aeed3e9SJustin Hibbits the given data buffer 4140aeed3e9SJustin Hibbits @Param[in] length - Length of received data 4150aeed3e9SJustin Hibbits @Param[in] status - Receive status and errors 4160aeed3e9SJustin Hibbits @Param[in] position - Position of buffer in frame 4170aeed3e9SJustin Hibbits @Param[in] flags - Driver-dependent information 4180aeed3e9SJustin Hibbits 4190aeed3e9SJustin Hibbits @Retval e_RX_STORE_RESPONSE_CONTINUE - order the driver to continue Rx 4200aeed3e9SJustin Hibbits operation for all ready data. 4210aeed3e9SJustin Hibbits @Retval e_RX_STORE_RESPONSE_PAUSE - order the driver to stop Rx operation. 4220aeed3e9SJustin Hibbits *//***************************************************************************/ 4230aeed3e9SJustin Hibbits typedef e_RxStoreResponse (t_RxStoreFunction)(t_Handle h_App, 4240aeed3e9SJustin Hibbits uint32_t queueId, 4250aeed3e9SJustin Hibbits uint8_t *p_Data, 4260aeed3e9SJustin Hibbits t_Handle h_BufContext, 4270aeed3e9SJustin Hibbits uint32_t length, 4280aeed3e9SJustin Hibbits uint16_t status, 4290aeed3e9SJustin Hibbits uint8_t position, 4300aeed3e9SJustin Hibbits uint32_t flags); 4310aeed3e9SJustin Hibbits 4320aeed3e9SJustin Hibbits 4330aeed3e9SJustin Hibbits #endif /* __NCSW_EXT_H */ 434