1*0aeed3e9SJustin Hibbits /* Copyright (c) 2008-2011 Freescale Semiconductor, Inc. 2*0aeed3e9SJustin Hibbits * All rights reserved. 3*0aeed3e9SJustin Hibbits * 4*0aeed3e9SJustin Hibbits * Redistribution and use in source and binary forms, with or without 5*0aeed3e9SJustin Hibbits * modification, are permitted provided that the following conditions are met: 6*0aeed3e9SJustin Hibbits * * Redistributions of source code must retain the above copyright 7*0aeed3e9SJustin Hibbits * notice, this list of conditions and the following disclaimer. 8*0aeed3e9SJustin Hibbits * * Redistributions in binary form must reproduce the above copyright 9*0aeed3e9SJustin Hibbits * notice, this list of conditions and the following disclaimer in the 10*0aeed3e9SJustin Hibbits * documentation and/or other materials provided with the distribution. 11*0aeed3e9SJustin Hibbits * * Neither the name of Freescale Semiconductor nor the 12*0aeed3e9SJustin Hibbits * names of its contributors may be used to endorse or promote products 13*0aeed3e9SJustin Hibbits * derived from this software without specific prior written permission. 14*0aeed3e9SJustin Hibbits * 15*0aeed3e9SJustin Hibbits * 16*0aeed3e9SJustin Hibbits * ALTERNATIVELY, this software may be distributed under the terms of the 17*0aeed3e9SJustin Hibbits * GNU General Public License ("GPL") as published by the Free Software 18*0aeed3e9SJustin Hibbits * Foundation, either version 2 of that License or (at your option) any 19*0aeed3e9SJustin Hibbits * later version. 20*0aeed3e9SJustin Hibbits * 21*0aeed3e9SJustin Hibbits * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY 22*0aeed3e9SJustin Hibbits * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23*0aeed3e9SJustin Hibbits * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24*0aeed3e9SJustin Hibbits * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY 25*0aeed3e9SJustin Hibbits * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26*0aeed3e9SJustin Hibbits * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27*0aeed3e9SJustin Hibbits * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28*0aeed3e9SJustin Hibbits * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29*0aeed3e9SJustin Hibbits * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30*0aeed3e9SJustin Hibbits * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*0aeed3e9SJustin Hibbits */ 32*0aeed3e9SJustin Hibbits 33*0aeed3e9SJustin Hibbits /**************************************************************************//** 34*0aeed3e9SJustin Hibbits @File xx_ext.h 35*0aeed3e9SJustin Hibbits 36*0aeed3e9SJustin Hibbits @Description Prototypes, externals and typedefs for system-supplied 37*0aeed3e9SJustin Hibbits (external) routines 38*0aeed3e9SJustin Hibbits *//***************************************************************************/ 39*0aeed3e9SJustin Hibbits 40*0aeed3e9SJustin Hibbits #ifndef __XX_EXT_H 41*0aeed3e9SJustin Hibbits #define __XX_EXT_H 42*0aeed3e9SJustin Hibbits 43*0aeed3e9SJustin Hibbits #include "std_ext.h" 44*0aeed3e9SJustin Hibbits #include "part_ext.h" 45*0aeed3e9SJustin Hibbits 46*0aeed3e9SJustin Hibbits #if defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED) 47*0aeed3e9SJustin Hibbits #include "xx_integration_ext.h" 48*0aeed3e9SJustin Hibbits #endif /* defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED) */ 49*0aeed3e9SJustin Hibbits 50*0aeed3e9SJustin Hibbits 51*0aeed3e9SJustin Hibbits /**************************************************************************//** 52*0aeed3e9SJustin Hibbits @Group xx_id XX Interface (System call hooks) 53*0aeed3e9SJustin Hibbits 54*0aeed3e9SJustin Hibbits @Description Prototypes, externals and typedefs for system-supplied 55*0aeed3e9SJustin Hibbits (external) routines 56*0aeed3e9SJustin Hibbits 57*0aeed3e9SJustin Hibbits @{ 58*0aeed3e9SJustin Hibbits *//***************************************************************************/ 59*0aeed3e9SJustin Hibbits 60*0aeed3e9SJustin Hibbits #if (defined(REPORT_EVENTS) && (REPORT_EVENTS > 0)) 61*0aeed3e9SJustin Hibbits /**************************************************************************//** 62*0aeed3e9SJustin Hibbits @Function XX_EventById 63*0aeed3e9SJustin Hibbits 64*0aeed3e9SJustin Hibbits @Description Event reporting routine - executed only when REPORT_EVENTS=1. 65*0aeed3e9SJustin Hibbits 66*0aeed3e9SJustin Hibbits @Param[in] event - Event code (e_Event). 67*0aeed3e9SJustin Hibbits @Param[in] appId - Application identifier. 68*0aeed3e9SJustin Hibbits @Param[in] flags - Event flags. 69*0aeed3e9SJustin Hibbits @Param[in] msg - Event message. 70*0aeed3e9SJustin Hibbits 71*0aeed3e9SJustin Hibbits @Return None 72*0aeed3e9SJustin Hibbits *//***************************************************************************/ 73*0aeed3e9SJustin Hibbits void XX_EventById(uint32_t event, t_Handle appId, uint16_t flags, char *msg); 74*0aeed3e9SJustin Hibbits 75*0aeed3e9SJustin Hibbits #else /* not REPORT_EVENTS */ 76*0aeed3e9SJustin Hibbits #define XX_EventById(event, appId, flags, msg) 77*0aeed3e9SJustin Hibbits #endif /* REPORT_EVENTS */ 78*0aeed3e9SJustin Hibbits 79*0aeed3e9SJustin Hibbits 80*0aeed3e9SJustin Hibbits #ifdef DEBUG_XX_MALLOC 81*0aeed3e9SJustin Hibbits void * XX_MallocDebug(uint32_t size, char *fname, int line); 82*0aeed3e9SJustin Hibbits 83*0aeed3e9SJustin Hibbits void * XX_MallocSmartDebug(uint32_t size, 84*0aeed3e9SJustin Hibbits int memPartitionId, 85*0aeed3e9SJustin Hibbits uint32_t alignment, 86*0aeed3e9SJustin Hibbits char *fname, 87*0aeed3e9SJustin Hibbits int line); 88*0aeed3e9SJustin Hibbits 89*0aeed3e9SJustin Hibbits #define XX_Malloc(sz) \ 90*0aeed3e9SJustin Hibbits XX_MallocDebug((sz), __FILE__, __LINE__) 91*0aeed3e9SJustin Hibbits 92*0aeed3e9SJustin Hibbits #define XX_MallocSmart(sz, memt, al) \ 93*0aeed3e9SJustin Hibbits XX_MallocSmartDebug((sz), (memt), (al), __FILE__, __LINE__) 94*0aeed3e9SJustin Hibbits 95*0aeed3e9SJustin Hibbits #else /* not DEBUG_XX_MALLOC */ 96*0aeed3e9SJustin Hibbits /**************************************************************************//** 97*0aeed3e9SJustin Hibbits @Function XX_Malloc 98*0aeed3e9SJustin Hibbits 99*0aeed3e9SJustin Hibbits @Description allocates contiguous block of memory. 100*0aeed3e9SJustin Hibbits 101*0aeed3e9SJustin Hibbits @Param[in] size - Number of bytes to allocate. 102*0aeed3e9SJustin Hibbits 103*0aeed3e9SJustin Hibbits @Return The address of the newly allocated block on success, NULL on failure. 104*0aeed3e9SJustin Hibbits *//***************************************************************************/ 105*0aeed3e9SJustin Hibbits void * XX_Malloc(uint32_t size); 106*0aeed3e9SJustin Hibbits 107*0aeed3e9SJustin Hibbits /**************************************************************************//** 108*0aeed3e9SJustin Hibbits @Function XX_MallocSmartInit 109*0aeed3e9SJustin Hibbits 110*0aeed3e9SJustin Hibbits @Description Initializes SmartMalloc allocator. 111*0aeed3e9SJustin Hibbits 112*0aeed3e9SJustin Hibbits @Return E_OK on success, error code otherwise. 113*0aeed3e9SJustin Hibbits *//***************************************************************************/ 114*0aeed3e9SJustin Hibbits int XX_MallocSmartInit(void); 115*0aeed3e9SJustin Hibbits 116*0aeed3e9SJustin Hibbits /**************************************************************************//** 117*0aeed3e9SJustin Hibbits @Function XX_MallocSmart 118*0aeed3e9SJustin Hibbits 119*0aeed3e9SJustin Hibbits @Description Allocates contiguous block of memory in a specified 120*0aeed3e9SJustin Hibbits alignment and from the specified segment. 121*0aeed3e9SJustin Hibbits 122*0aeed3e9SJustin Hibbits @Param[in] size - Number of bytes to allocate. 123*0aeed3e9SJustin Hibbits @Param[in] memPartitionId - Memory partition ID; The value zero must 124*0aeed3e9SJustin Hibbits be mapped to the default heap partition. 125*0aeed3e9SJustin Hibbits @Param[in] alignment - Required memory alignment (in bytes). 126*0aeed3e9SJustin Hibbits 127*0aeed3e9SJustin Hibbits @Return The address of the newly allocated block on success, NULL on failure. 128*0aeed3e9SJustin Hibbits *//***************************************************************************/ 129*0aeed3e9SJustin Hibbits void * XX_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment); 130*0aeed3e9SJustin Hibbits #endif /* not DEBUG_XX_MALLOC */ 131*0aeed3e9SJustin Hibbits 132*0aeed3e9SJustin Hibbits /**************************************************************************//** 133*0aeed3e9SJustin Hibbits @Function XX_FreeSmart 134*0aeed3e9SJustin Hibbits 135*0aeed3e9SJustin Hibbits @Description Frees the memory block pointed to by "p". 136*0aeed3e9SJustin Hibbits Only for memory allocated by XX_MallocSmart 137*0aeed3e9SJustin Hibbits 138*0aeed3e9SJustin Hibbits @Param[in] p_Memory - pointer to the memory block. 139*0aeed3e9SJustin Hibbits 140*0aeed3e9SJustin Hibbits @Return None. 141*0aeed3e9SJustin Hibbits *//***************************************************************************/ 142*0aeed3e9SJustin Hibbits void XX_FreeSmart(void *p_Memory); 143*0aeed3e9SJustin Hibbits 144*0aeed3e9SJustin Hibbits /**************************************************************************//** 145*0aeed3e9SJustin Hibbits @Function XX_Free 146*0aeed3e9SJustin Hibbits 147*0aeed3e9SJustin Hibbits @Description frees the memory block pointed to by "p". 148*0aeed3e9SJustin Hibbits 149*0aeed3e9SJustin Hibbits @Param[in] p_Memory - pointer to the memory block. 150*0aeed3e9SJustin Hibbits 151*0aeed3e9SJustin Hibbits @Return None. 152*0aeed3e9SJustin Hibbits *//***************************************************************************/ 153*0aeed3e9SJustin Hibbits void XX_Free(void *p_Memory); 154*0aeed3e9SJustin Hibbits 155*0aeed3e9SJustin Hibbits #ifndef NCSW_LINUX 156*0aeed3e9SJustin Hibbits /**************************************************************************//** 157*0aeed3e9SJustin Hibbits @Function XX_GetMemPartitionBase 158*0aeed3e9SJustin Hibbits 159*0aeed3e9SJustin Hibbits @Description This routine gets the address of a memory segment according to 160*0aeed3e9SJustin Hibbits the memory type. 161*0aeed3e9SJustin Hibbits 162*0aeed3e9SJustin Hibbits @Param[in] memPartitionId - Memory partition ID; The value zero must 163*0aeed3e9SJustin Hibbits be mapped to the default heap partition. 164*0aeed3e9SJustin Hibbits 165*0aeed3e9SJustin Hibbits @Return The address of the required memory type. 166*0aeed3e9SJustin Hibbits *//***************************************************************************/ 167*0aeed3e9SJustin Hibbits void * XX_GetMemPartitionBase(int memPartitionId); 168*0aeed3e9SJustin Hibbits #endif 169*0aeed3e9SJustin Hibbits 170*0aeed3e9SJustin Hibbits /**************************************************************************//** 171*0aeed3e9SJustin Hibbits @Function XX_Print 172*0aeed3e9SJustin Hibbits 173*0aeed3e9SJustin Hibbits @Description print a string. 174*0aeed3e9SJustin Hibbits 175*0aeed3e9SJustin Hibbits @Param[in] str - string to print. 176*0aeed3e9SJustin Hibbits 177*0aeed3e9SJustin Hibbits @Return None. 178*0aeed3e9SJustin Hibbits *//***************************************************************************/ 179*0aeed3e9SJustin Hibbits void XX_Print(char *str, ...); 180*0aeed3e9SJustin Hibbits 181*0aeed3e9SJustin Hibbits /**************************************************************************//** 182*0aeed3e9SJustin Hibbits @Function XX_GetChar 183*0aeed3e9SJustin Hibbits 184*0aeed3e9SJustin Hibbits @Description Get character from console. 185*0aeed3e9SJustin Hibbits 186*0aeed3e9SJustin Hibbits @Return Character is returned on success. Zero is returned otherwise. 187*0aeed3e9SJustin Hibbits *//***************************************************************************/ 188*0aeed3e9SJustin Hibbits char XX_GetChar(void); 189*0aeed3e9SJustin Hibbits 190*0aeed3e9SJustin Hibbits /**************************************************************************//** 191*0aeed3e9SJustin Hibbits @Function XX_PreallocAndBindIntr 192*0aeed3e9SJustin Hibbits 193*0aeed3e9SJustin Hibbits @Description Preallocate and optionally bind it to given CPU. 194*0aeed3e9SJustin Hibbits 195*0aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 196*0aeed3e9SJustin Hibbits @Param[in] cpu - CPU to bind to or -1 if iRQ should be unbound. 197*0aeed3e9SJustin Hibbits 198*0aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 199*0aeed3e9SJustin Hibbits *//***************************************************************************/ 200*0aeed3e9SJustin Hibbits t_Error XX_PreallocAndBindIntr(int irq, unsigned int cpu); 201*0aeed3e9SJustin Hibbits 202*0aeed3e9SJustin Hibbits /**************************************************************************//** 203*0aeed3e9SJustin Hibbits @Function XX_DeallocIntr 204*0aeed3e9SJustin Hibbits 205*0aeed3e9SJustin Hibbits @Description Deallocate preallocated interupt. 206*0aeed3e9SJustin Hibbits 207*0aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 208*0aeed3e9SJustin Hibbits 209*0aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 210*0aeed3e9SJustin Hibbits *//***************************************************************************/ 211*0aeed3e9SJustin Hibbits t_Error XX_DeallocIntr(int irq); 212*0aeed3e9SJustin Hibbits 213*0aeed3e9SJustin Hibbits /**************************************************************************//** 214*0aeed3e9SJustin Hibbits @Function XX_SetIntr 215*0aeed3e9SJustin Hibbits 216*0aeed3e9SJustin Hibbits @Description Set an interrupt service routine for a specific interrupt source. 217*0aeed3e9SJustin Hibbits 218*0aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 219*0aeed3e9SJustin Hibbits @Param[in] f_Isr - Callback routine that will be called when the interrupt occurs. 220*0aeed3e9SJustin Hibbits @Param[in] handle - The argument for the user callback routine. 221*0aeed3e9SJustin Hibbits 222*0aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 223*0aeed3e9SJustin Hibbits *//***************************************************************************/ 224*0aeed3e9SJustin Hibbits t_Error XX_SetIntr(int irq, t_Isr *f_Isr, t_Handle handle); 225*0aeed3e9SJustin Hibbits 226*0aeed3e9SJustin Hibbits /**************************************************************************//** 227*0aeed3e9SJustin Hibbits @Function XX_FreeIntr 228*0aeed3e9SJustin Hibbits 229*0aeed3e9SJustin Hibbits @Description Free a specific interrupt and a specific callback routine. 230*0aeed3e9SJustin Hibbits 231*0aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 232*0aeed3e9SJustin Hibbits 233*0aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 234*0aeed3e9SJustin Hibbits *//***************************************************************************/ 235*0aeed3e9SJustin Hibbits t_Error XX_FreeIntr(int irq); 236*0aeed3e9SJustin Hibbits 237*0aeed3e9SJustin Hibbits /**************************************************************************//** 238*0aeed3e9SJustin Hibbits @Function XX_EnableIntr 239*0aeed3e9SJustin Hibbits 240*0aeed3e9SJustin Hibbits @Description Enable a specific interrupt. 241*0aeed3e9SJustin Hibbits 242*0aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 243*0aeed3e9SJustin Hibbits 244*0aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 245*0aeed3e9SJustin Hibbits *//***************************************************************************/ 246*0aeed3e9SJustin Hibbits t_Error XX_EnableIntr(int irq); 247*0aeed3e9SJustin Hibbits 248*0aeed3e9SJustin Hibbits /**************************************************************************//** 249*0aeed3e9SJustin Hibbits @Function XX_DisableIntr 250*0aeed3e9SJustin Hibbits 251*0aeed3e9SJustin Hibbits @Description Disable a specific interrupt. 252*0aeed3e9SJustin Hibbits 253*0aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 254*0aeed3e9SJustin Hibbits 255*0aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 256*0aeed3e9SJustin Hibbits *//***************************************************************************/ 257*0aeed3e9SJustin Hibbits t_Error XX_DisableIntr(int irq); 258*0aeed3e9SJustin Hibbits 259*0aeed3e9SJustin Hibbits #if !(defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED)) 260*0aeed3e9SJustin Hibbits /**************************************************************************//** 261*0aeed3e9SJustin Hibbits @Function XX_DisableAllIntr 262*0aeed3e9SJustin Hibbits 263*0aeed3e9SJustin Hibbits @Description Disable all interrupts by masking them at the CPU. 264*0aeed3e9SJustin Hibbits 265*0aeed3e9SJustin Hibbits @Return A value that represents the interrupts state before the 266*0aeed3e9SJustin Hibbits operation, and should be passed to the matching 267*0aeed3e9SJustin Hibbits XX_RestoreAllIntr() call. 268*0aeed3e9SJustin Hibbits *//***************************************************************************/ 269*0aeed3e9SJustin Hibbits uint32_t XX_DisableAllIntr(void); 270*0aeed3e9SJustin Hibbits 271*0aeed3e9SJustin Hibbits /**************************************************************************//** 272*0aeed3e9SJustin Hibbits @Function XX_RestoreAllIntr 273*0aeed3e9SJustin Hibbits 274*0aeed3e9SJustin Hibbits @Description Restore previous state of interrupts level at the CPU. 275*0aeed3e9SJustin Hibbits 276*0aeed3e9SJustin Hibbits @Param[in] flags - A value that represents the interrupts state to restore, 277*0aeed3e9SJustin Hibbits as returned by the matching call for XX_DisableAllIntr(). 278*0aeed3e9SJustin Hibbits 279*0aeed3e9SJustin Hibbits @Return None. 280*0aeed3e9SJustin Hibbits *//***************************************************************************/ 281*0aeed3e9SJustin Hibbits void XX_RestoreAllIntr(uint32_t flags); 282*0aeed3e9SJustin Hibbits #endif /* !(defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED)) */ 283*0aeed3e9SJustin Hibbits 284*0aeed3e9SJustin Hibbits /**************************************************************************//** 285*0aeed3e9SJustin Hibbits @Function XX_Call 286*0aeed3e9SJustin Hibbits 287*0aeed3e9SJustin Hibbits @Description Call a service in another task. 288*0aeed3e9SJustin Hibbits 289*0aeed3e9SJustin Hibbits Activate the routine "f" via the queue identified by "IntrManagerId". The 290*0aeed3e9SJustin Hibbits parameter to "f" is Id - the handle of the destination object 291*0aeed3e9SJustin Hibbits 292*0aeed3e9SJustin Hibbits @Param[in] intrManagerId - Queue ID. 293*0aeed3e9SJustin Hibbits @Param[in] f - routine pointer. 294*0aeed3e9SJustin Hibbits @Param[in] Id - the parameter to be passed to f(). 295*0aeed3e9SJustin Hibbits @Param[in] h_App - Application handle. 296*0aeed3e9SJustin Hibbits @Param[in] flags - Unused, 297*0aeed3e9SJustin Hibbits 298*0aeed3e9SJustin Hibbits @Return E_OK is returned on success. E_FAIL is returned otherwise (usually an operating system level failure). 299*0aeed3e9SJustin Hibbits *//***************************************************************************/ 300*0aeed3e9SJustin Hibbits t_Error XX_Call( uint32_t intrManagerId, 301*0aeed3e9SJustin Hibbits t_Error (* f)(t_Handle), 302*0aeed3e9SJustin Hibbits t_Handle Id, 303*0aeed3e9SJustin Hibbits t_Handle h_App, 304*0aeed3e9SJustin Hibbits uint16_t flags ); 305*0aeed3e9SJustin Hibbits 306*0aeed3e9SJustin Hibbits /**************************************************************************//** 307*0aeed3e9SJustin Hibbits @Function XX_Exit 308*0aeed3e9SJustin Hibbits 309*0aeed3e9SJustin Hibbits @Description Stop execution and report status (where it is applicable) 310*0aeed3e9SJustin Hibbits 311*0aeed3e9SJustin Hibbits @Param[in] status - exit status 312*0aeed3e9SJustin Hibbits *//***************************************************************************/ 313*0aeed3e9SJustin Hibbits void XX_Exit(int status); 314*0aeed3e9SJustin Hibbits 315*0aeed3e9SJustin Hibbits /*****************************************************************************/ 316*0aeed3e9SJustin Hibbits /* Tasklet Service Routines */ 317*0aeed3e9SJustin Hibbits /*****************************************************************************/ 318*0aeed3e9SJustin Hibbits typedef t_Handle t_TaskletHandle; 319*0aeed3e9SJustin Hibbits 320*0aeed3e9SJustin Hibbits /**************************************************************************//** 321*0aeed3e9SJustin Hibbits @Function XX_InitTasklet 322*0aeed3e9SJustin Hibbits 323*0aeed3e9SJustin Hibbits @Description Create and initialize a tasklet object. 324*0aeed3e9SJustin Hibbits 325*0aeed3e9SJustin Hibbits @Param[in] routine - A routine to be ran as a tasklet. 326*0aeed3e9SJustin Hibbits @Param[in] data - An argument to pass to the tasklet. 327*0aeed3e9SJustin Hibbits 328*0aeed3e9SJustin Hibbits @Return Tasklet handle is returned on success. NULL is returned otherwise. 329*0aeed3e9SJustin Hibbits *//***************************************************************************/ 330*0aeed3e9SJustin Hibbits t_TaskletHandle XX_InitTasklet (void (*routine)(void *), void *data); 331*0aeed3e9SJustin Hibbits 332*0aeed3e9SJustin Hibbits /**************************************************************************//** 333*0aeed3e9SJustin Hibbits @Function XX_FreeTasklet 334*0aeed3e9SJustin Hibbits 335*0aeed3e9SJustin Hibbits @Description Free a tasklet object. 336*0aeed3e9SJustin Hibbits 337*0aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be free. 338*0aeed3e9SJustin Hibbits 339*0aeed3e9SJustin Hibbits @Return None. 340*0aeed3e9SJustin Hibbits *//***************************************************************************/ 341*0aeed3e9SJustin Hibbits void XX_FreeTasklet (t_TaskletHandle h_Tasklet); 342*0aeed3e9SJustin Hibbits 343*0aeed3e9SJustin Hibbits /**************************************************************************//** 344*0aeed3e9SJustin Hibbits @Function XX_ScheduleTask 345*0aeed3e9SJustin Hibbits 346*0aeed3e9SJustin Hibbits @Description Schedule a tasklet object. 347*0aeed3e9SJustin Hibbits 348*0aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be scheduled. 349*0aeed3e9SJustin Hibbits @Param[in] immediate - Indicate whether to schedule this tasklet on 350*0aeed3e9SJustin Hibbits the immediate queue or on the delayed one. 351*0aeed3e9SJustin Hibbits 352*0aeed3e9SJustin Hibbits @Return 0 - on success. Error code - otherwise. 353*0aeed3e9SJustin Hibbits *//***************************************************************************/ 354*0aeed3e9SJustin Hibbits int XX_ScheduleTask(t_TaskletHandle h_Tasklet, int immediate); 355*0aeed3e9SJustin Hibbits 356*0aeed3e9SJustin Hibbits /**************************************************************************//** 357*0aeed3e9SJustin Hibbits @Function XX_FlushScheduledTasks 358*0aeed3e9SJustin Hibbits 359*0aeed3e9SJustin Hibbits @Description Flush all tasks there are in the scheduled tasks queue. 360*0aeed3e9SJustin Hibbits 361*0aeed3e9SJustin Hibbits @Return None. 362*0aeed3e9SJustin Hibbits *//***************************************************************************/ 363*0aeed3e9SJustin Hibbits void XX_FlushScheduledTasks(void); 364*0aeed3e9SJustin Hibbits 365*0aeed3e9SJustin Hibbits /**************************************************************************//** 366*0aeed3e9SJustin Hibbits @Function XX_TaskletIsQueued 367*0aeed3e9SJustin Hibbits 368*0aeed3e9SJustin Hibbits @Description Check if task is queued. 369*0aeed3e9SJustin Hibbits 370*0aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be scheduled. 371*0aeed3e9SJustin Hibbits 372*0aeed3e9SJustin Hibbits @Return 1 - task is queued. 0 - otherwise. 373*0aeed3e9SJustin Hibbits *//***************************************************************************/ 374*0aeed3e9SJustin Hibbits int XX_TaskletIsQueued(t_TaskletHandle h_Tasklet); 375*0aeed3e9SJustin Hibbits 376*0aeed3e9SJustin Hibbits /**************************************************************************//** 377*0aeed3e9SJustin Hibbits @Function XX_SetTaskletData 378*0aeed3e9SJustin Hibbits 379*0aeed3e9SJustin Hibbits @Description Set data to a scheduled task. Used to change data of already 380*0aeed3e9SJustin Hibbits scheduled task. 381*0aeed3e9SJustin Hibbits 382*0aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be scheduled. 383*0aeed3e9SJustin Hibbits @Param[in] data - Data to be set. 384*0aeed3e9SJustin Hibbits *//***************************************************************************/ 385*0aeed3e9SJustin Hibbits void XX_SetTaskletData(t_TaskletHandle h_Tasklet, t_Handle data); 386*0aeed3e9SJustin Hibbits 387*0aeed3e9SJustin Hibbits /**************************************************************************//** 388*0aeed3e9SJustin Hibbits @Function XX_GetTaskletData 389*0aeed3e9SJustin Hibbits 390*0aeed3e9SJustin Hibbits @Description Get the data of scheduled task. 391*0aeed3e9SJustin Hibbits 392*0aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be scheduled. 393*0aeed3e9SJustin Hibbits 394*0aeed3e9SJustin Hibbits @Return handle to the data of the task. 395*0aeed3e9SJustin Hibbits *//***************************************************************************/ 396*0aeed3e9SJustin Hibbits t_Handle XX_GetTaskletData(t_TaskletHandle h_Tasklet); 397*0aeed3e9SJustin Hibbits 398*0aeed3e9SJustin Hibbits /**************************************************************************//** 399*0aeed3e9SJustin Hibbits @Function XX_BottomHalf 400*0aeed3e9SJustin Hibbits 401*0aeed3e9SJustin Hibbits @Description Bottom half implementation, invoked by the interrupt handler. 402*0aeed3e9SJustin Hibbits 403*0aeed3e9SJustin Hibbits This routine handles all bottom-half tasklets with interrupts 404*0aeed3e9SJustin Hibbits enabled. 405*0aeed3e9SJustin Hibbits 406*0aeed3e9SJustin Hibbits @Return None. 407*0aeed3e9SJustin Hibbits *//***************************************************************************/ 408*0aeed3e9SJustin Hibbits void XX_BottomHalf(void); 409*0aeed3e9SJustin Hibbits 410*0aeed3e9SJustin Hibbits 411*0aeed3e9SJustin Hibbits /*****************************************************************************/ 412*0aeed3e9SJustin Hibbits /* Spinlock Service Routines */ 413*0aeed3e9SJustin Hibbits /*****************************************************************************/ 414*0aeed3e9SJustin Hibbits 415*0aeed3e9SJustin Hibbits /**************************************************************************//** 416*0aeed3e9SJustin Hibbits @Function XX_InitSpinlock 417*0aeed3e9SJustin Hibbits 418*0aeed3e9SJustin Hibbits @Description Creates a spinlock. 419*0aeed3e9SJustin Hibbits 420*0aeed3e9SJustin Hibbits @Return Spinlock handle is returned on success; NULL otherwise. 421*0aeed3e9SJustin Hibbits *//***************************************************************************/ 422*0aeed3e9SJustin Hibbits t_Handle XX_InitSpinlock(void); 423*0aeed3e9SJustin Hibbits 424*0aeed3e9SJustin Hibbits /**************************************************************************//** 425*0aeed3e9SJustin Hibbits @Function XX_FreeSpinlock 426*0aeed3e9SJustin Hibbits 427*0aeed3e9SJustin Hibbits @Description Frees the memory allocated for the spinlock creation. 428*0aeed3e9SJustin Hibbits 429*0aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 430*0aeed3e9SJustin Hibbits 431*0aeed3e9SJustin Hibbits @Return None. 432*0aeed3e9SJustin Hibbits *//***************************************************************************/ 433*0aeed3e9SJustin Hibbits void XX_FreeSpinlock(t_Handle h_Spinlock); 434*0aeed3e9SJustin Hibbits 435*0aeed3e9SJustin Hibbits /**************************************************************************//** 436*0aeed3e9SJustin Hibbits @Function XX_LockSpinlock 437*0aeed3e9SJustin Hibbits 438*0aeed3e9SJustin Hibbits @Description Locks a spinlock. 439*0aeed3e9SJustin Hibbits 440*0aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 441*0aeed3e9SJustin Hibbits 442*0aeed3e9SJustin Hibbits @Return None. 443*0aeed3e9SJustin Hibbits *//***************************************************************************/ 444*0aeed3e9SJustin Hibbits void XX_LockSpinlock(t_Handle h_Spinlock); 445*0aeed3e9SJustin Hibbits 446*0aeed3e9SJustin Hibbits /**************************************************************************//** 447*0aeed3e9SJustin Hibbits @Function XX_UnlockSpinlock 448*0aeed3e9SJustin Hibbits 449*0aeed3e9SJustin Hibbits @Description Unlocks a spinlock. 450*0aeed3e9SJustin Hibbits 451*0aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 452*0aeed3e9SJustin Hibbits 453*0aeed3e9SJustin Hibbits @Return None. 454*0aeed3e9SJustin Hibbits *//***************************************************************************/ 455*0aeed3e9SJustin Hibbits void XX_UnlockSpinlock(t_Handle h_Spinlock); 456*0aeed3e9SJustin Hibbits 457*0aeed3e9SJustin Hibbits /**************************************************************************//** 458*0aeed3e9SJustin Hibbits @Function XX_LockIntrSpinlock 459*0aeed3e9SJustin Hibbits 460*0aeed3e9SJustin Hibbits @Description Locks a spinlock (interrupt safe). 461*0aeed3e9SJustin Hibbits 462*0aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 463*0aeed3e9SJustin Hibbits 464*0aeed3e9SJustin Hibbits @Return A value that represents the interrupts state before the 465*0aeed3e9SJustin Hibbits operation, and should be passed to the matching 466*0aeed3e9SJustin Hibbits XX_UnlockIntrSpinlock() call. 467*0aeed3e9SJustin Hibbits *//***************************************************************************/ 468*0aeed3e9SJustin Hibbits uint32_t XX_LockIntrSpinlock(t_Handle h_Spinlock); 469*0aeed3e9SJustin Hibbits 470*0aeed3e9SJustin Hibbits /**************************************************************************//** 471*0aeed3e9SJustin Hibbits @Function XX_UnlockIntrSpinlock 472*0aeed3e9SJustin Hibbits 473*0aeed3e9SJustin Hibbits @Description Unlocks a spinlock (interrupt safe). 474*0aeed3e9SJustin Hibbits 475*0aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 476*0aeed3e9SJustin Hibbits @Param[in] intrFlags - A value that represents the interrupts state to 477*0aeed3e9SJustin Hibbits restore, as returned by the matching call for 478*0aeed3e9SJustin Hibbits XX_LockIntrSpinlock(). 479*0aeed3e9SJustin Hibbits 480*0aeed3e9SJustin Hibbits @Return None. 481*0aeed3e9SJustin Hibbits *//***************************************************************************/ 482*0aeed3e9SJustin Hibbits void XX_UnlockIntrSpinlock(t_Handle h_Spinlock, uint32_t intrFlags); 483*0aeed3e9SJustin Hibbits 484*0aeed3e9SJustin Hibbits 485*0aeed3e9SJustin Hibbits /*****************************************************************************/ 486*0aeed3e9SJustin Hibbits /* Timers Service Routines */ 487*0aeed3e9SJustin Hibbits /*****************************************************************************/ 488*0aeed3e9SJustin Hibbits 489*0aeed3e9SJustin Hibbits /**************************************************************************//** 490*0aeed3e9SJustin Hibbits @Function XX_CurrentTime 491*0aeed3e9SJustin Hibbits 492*0aeed3e9SJustin Hibbits @Description Returns current system time. 493*0aeed3e9SJustin Hibbits 494*0aeed3e9SJustin Hibbits @Return Current system time (in milliseconds). 495*0aeed3e9SJustin Hibbits *//***************************************************************************/ 496*0aeed3e9SJustin Hibbits uint32_t XX_CurrentTime(void); 497*0aeed3e9SJustin Hibbits 498*0aeed3e9SJustin Hibbits /**************************************************************************//** 499*0aeed3e9SJustin Hibbits @Function XX_CreateTimer 500*0aeed3e9SJustin Hibbits 501*0aeed3e9SJustin Hibbits @Description Creates a timer. 502*0aeed3e9SJustin Hibbits 503*0aeed3e9SJustin Hibbits @Return Timer handle is returned on success; NULL otherwise. 504*0aeed3e9SJustin Hibbits *//***************************************************************************/ 505*0aeed3e9SJustin Hibbits t_Handle XX_CreateTimer(void); 506*0aeed3e9SJustin Hibbits 507*0aeed3e9SJustin Hibbits /**************************************************************************//** 508*0aeed3e9SJustin Hibbits @Function XX_FreeTimer 509*0aeed3e9SJustin Hibbits 510*0aeed3e9SJustin Hibbits @Description Frees the memory allocated for the timer creation. 511*0aeed3e9SJustin Hibbits 512*0aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 513*0aeed3e9SJustin Hibbits 514*0aeed3e9SJustin Hibbits @Return None. 515*0aeed3e9SJustin Hibbits *//***************************************************************************/ 516*0aeed3e9SJustin Hibbits void XX_FreeTimer(t_Handle h_Timer); 517*0aeed3e9SJustin Hibbits 518*0aeed3e9SJustin Hibbits /**************************************************************************//** 519*0aeed3e9SJustin Hibbits @Function XX_StartTimer 520*0aeed3e9SJustin Hibbits 521*0aeed3e9SJustin Hibbits @Description Starts a timer. 522*0aeed3e9SJustin Hibbits 523*0aeed3e9SJustin Hibbits The user can select to start the timer as periodic timer or as 524*0aeed3e9SJustin Hibbits one-shot timer. The user should provide a callback routine that 525*0aeed3e9SJustin Hibbits will be called when the timer expires. 526*0aeed3e9SJustin Hibbits 527*0aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 528*0aeed3e9SJustin Hibbits @Param[in] msecs - Timer expiration period (in milliseconds). 529*0aeed3e9SJustin Hibbits @Param[in] periodic - TRUE for a periodic timer; 530*0aeed3e9SJustin Hibbits FALSE for a one-shot timer.. 531*0aeed3e9SJustin Hibbits @Param[in] f_TimerExpired - A callback routine to be called when the 532*0aeed3e9SJustin Hibbits timer expires. 533*0aeed3e9SJustin Hibbits @Param[in] h_Arg - The argument to pass in the timer-expired 534*0aeed3e9SJustin Hibbits callback routine. 535*0aeed3e9SJustin Hibbits 536*0aeed3e9SJustin Hibbits @Return None. 537*0aeed3e9SJustin Hibbits *//***************************************************************************/ 538*0aeed3e9SJustin Hibbits void XX_StartTimer(t_Handle h_Timer, 539*0aeed3e9SJustin Hibbits uint32_t msecs, 540*0aeed3e9SJustin Hibbits bool periodic, 541*0aeed3e9SJustin Hibbits void (*f_TimerExpired)(t_Handle h_Arg), 542*0aeed3e9SJustin Hibbits t_Handle h_Arg); 543*0aeed3e9SJustin Hibbits 544*0aeed3e9SJustin Hibbits /**************************************************************************//** 545*0aeed3e9SJustin Hibbits @Function XX_StopTimer 546*0aeed3e9SJustin Hibbits 547*0aeed3e9SJustin Hibbits @Description Frees the memory allocated for the timer creation. 548*0aeed3e9SJustin Hibbits 549*0aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 550*0aeed3e9SJustin Hibbits 551*0aeed3e9SJustin Hibbits @Return None. 552*0aeed3e9SJustin Hibbits *//***************************************************************************/ 553*0aeed3e9SJustin Hibbits void XX_StopTimer(t_Handle h_Timer); 554*0aeed3e9SJustin Hibbits 555*0aeed3e9SJustin Hibbits /**************************************************************************//** 556*0aeed3e9SJustin Hibbits @Function XX_GetExpirationTime 557*0aeed3e9SJustin Hibbits 558*0aeed3e9SJustin Hibbits @Description Returns the time (in milliseconds) remaining until the 559*0aeed3e9SJustin Hibbits expiration of a timer. 560*0aeed3e9SJustin Hibbits 561*0aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 562*0aeed3e9SJustin Hibbits 563*0aeed3e9SJustin Hibbits @Return The time left until the timer expires. 564*0aeed3e9SJustin Hibbits *//***************************************************************************/ 565*0aeed3e9SJustin Hibbits uint32_t XX_GetExpirationTime(t_Handle h_Timer); 566*0aeed3e9SJustin Hibbits 567*0aeed3e9SJustin Hibbits /**************************************************************************//** 568*0aeed3e9SJustin Hibbits @Function XX_ModTimer 569*0aeed3e9SJustin Hibbits 570*0aeed3e9SJustin Hibbits @Description Updates the expiration time of a timer. 571*0aeed3e9SJustin Hibbits 572*0aeed3e9SJustin Hibbits This routine adds the given time to the current system time, 573*0aeed3e9SJustin Hibbits and sets this value as the new expiration time of the timer. 574*0aeed3e9SJustin Hibbits 575*0aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 576*0aeed3e9SJustin Hibbits @Param[in] msecs - The new interval until timer expiration 577*0aeed3e9SJustin Hibbits (in milliseconds). 578*0aeed3e9SJustin Hibbits 579*0aeed3e9SJustin Hibbits @Return None. 580*0aeed3e9SJustin Hibbits *//***************************************************************************/ 581*0aeed3e9SJustin Hibbits void XX_ModTimer(t_Handle h_Timer, uint32_t msecs); 582*0aeed3e9SJustin Hibbits 583*0aeed3e9SJustin Hibbits /**************************************************************************//** 584*0aeed3e9SJustin Hibbits @Function XX_TimerIsActive 585*0aeed3e9SJustin Hibbits 586*0aeed3e9SJustin Hibbits @Description Checks whether a timer is active (pending) or not. 587*0aeed3e9SJustin Hibbits 588*0aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 589*0aeed3e9SJustin Hibbits 590*0aeed3e9SJustin Hibbits @Return 0 - the timer is inactive; Non-zero value - the timer is active; 591*0aeed3e9SJustin Hibbits *//***************************************************************************/ 592*0aeed3e9SJustin Hibbits int XX_TimerIsActive(t_Handle h_Timer); 593*0aeed3e9SJustin Hibbits 594*0aeed3e9SJustin Hibbits /**************************************************************************//** 595*0aeed3e9SJustin Hibbits @Function XX_Sleep 596*0aeed3e9SJustin Hibbits 597*0aeed3e9SJustin Hibbits @Description Non-busy wait until the desired time (in milliseconds) has passed. 598*0aeed3e9SJustin Hibbits 599*0aeed3e9SJustin Hibbits @Param[in] msecs - The requested sleep time (in milliseconds). 600*0aeed3e9SJustin Hibbits 601*0aeed3e9SJustin Hibbits @Return None. 602*0aeed3e9SJustin Hibbits 603*0aeed3e9SJustin Hibbits @Cautions This routine enables interrupts during its wait time. 604*0aeed3e9SJustin Hibbits *//***************************************************************************/ 605*0aeed3e9SJustin Hibbits uint32_t XX_Sleep(uint32_t msecs); 606*0aeed3e9SJustin Hibbits 607*0aeed3e9SJustin Hibbits /**************************************************************************//** 608*0aeed3e9SJustin Hibbits @Function XX_UDelay 609*0aeed3e9SJustin Hibbits 610*0aeed3e9SJustin Hibbits @Description Busy-wait until the desired time (in microseconds) has passed. 611*0aeed3e9SJustin Hibbits 612*0aeed3e9SJustin Hibbits @Param[in] usecs - The requested delay time (in microseconds). 613*0aeed3e9SJustin Hibbits 614*0aeed3e9SJustin Hibbits @Return None. 615*0aeed3e9SJustin Hibbits 616*0aeed3e9SJustin Hibbits @Cautions It is highly unrecommended to call this routine during interrupt 617*0aeed3e9SJustin Hibbits time, because the system time may not be updated properly during 618*0aeed3e9SJustin Hibbits the delay loop. The behavior of this routine during interrupt 619*0aeed3e9SJustin Hibbits time is unexpected. 620*0aeed3e9SJustin Hibbits *//***************************************************************************/ 621*0aeed3e9SJustin Hibbits void XX_UDelay(uint32_t usecs); 622*0aeed3e9SJustin Hibbits 623*0aeed3e9SJustin Hibbits 624*0aeed3e9SJustin Hibbits /*****************************************************************************/ 625*0aeed3e9SJustin Hibbits /* Other Service Routines */ 626*0aeed3e9SJustin Hibbits /*****************************************************************************/ 627*0aeed3e9SJustin Hibbits 628*0aeed3e9SJustin Hibbits /**************************************************************************//** 629*0aeed3e9SJustin Hibbits @Function XX_PhysToVirt 630*0aeed3e9SJustin Hibbits 631*0aeed3e9SJustin Hibbits @Description Translates a physical address to the matching virtual address. 632*0aeed3e9SJustin Hibbits 633*0aeed3e9SJustin Hibbits @Param[in] addr - The physical address to translate. 634*0aeed3e9SJustin Hibbits 635*0aeed3e9SJustin Hibbits @Return Virtual address. 636*0aeed3e9SJustin Hibbits *//***************************************************************************/ 637*0aeed3e9SJustin Hibbits void * XX_PhysToVirt(physAddress_t addr); 638*0aeed3e9SJustin Hibbits 639*0aeed3e9SJustin Hibbits /**************************************************************************//** 640*0aeed3e9SJustin Hibbits @Function XX_VirtToPhys 641*0aeed3e9SJustin Hibbits 642*0aeed3e9SJustin Hibbits @Description Translates a virtual address to the matching physical address. 643*0aeed3e9SJustin Hibbits 644*0aeed3e9SJustin Hibbits @Param[in] addr - The virtual address to translate. 645*0aeed3e9SJustin Hibbits 646*0aeed3e9SJustin Hibbits @Return Physical address. 647*0aeed3e9SJustin Hibbits *//***************************************************************************/ 648*0aeed3e9SJustin Hibbits physAddress_t XX_VirtToPhys(void *addr); 649*0aeed3e9SJustin Hibbits 650*0aeed3e9SJustin Hibbits /**************************************************************************//** 651*0aeed3e9SJustin Hibbits @Function XX_PortalSetInfo 652*0aeed3e9SJustin Hibbits 653*0aeed3e9SJustin Hibbits @Description Save physical and virtual adresses of the portals. 654*0aeed3e9SJustin Hibbits 655*0aeed3e9SJustin Hibbits @Param[in] dev - Portals device - either bman or qman. 656*0aeed3e9SJustin Hibbits 657*0aeed3e9SJustin Hibbits @Return Physical, virtual addresses and size. 658*0aeed3e9SJustin Hibbits *//***************************************************************************/ 659*0aeed3e9SJustin Hibbits void XX_PortalSetInfo(device_t dev); 660*0aeed3e9SJustin Hibbits 661*0aeed3e9SJustin Hibbits /**************************************************************************//** 662*0aeed3e9SJustin Hibbits @Function XX_FmanSetIntrInfo 663*0aeed3e9SJustin Hibbits 664*0aeed3e9SJustin Hibbits @Description Workaround for FMan interrupt, which must be binded to one CPU 665*0aeed3e9SJustin Hibbits only. 666*0aeed3e9SJustin Hibbits 667*0aeed3e9SJustin Hibbits @Param[in] irq - Interrupt number. 668*0aeed3e9SJustin Hibbits 669*0aeed3e9SJustin Hibbits @Return None. 670*0aeed3e9SJustin Hibbits *//***************************************************************************/ 671*0aeed3e9SJustin Hibbits void XX_FmanFixIntr(int irq); 672*0aeed3e9SJustin Hibbits 673*0aeed3e9SJustin Hibbits /**************************************************************************//** 674*0aeed3e9SJustin Hibbits @Group xx_ipc XX Inter-Partition-Communication API 675*0aeed3e9SJustin Hibbits 676*0aeed3e9SJustin Hibbits @Description The following API is to be used when working with multiple 677*0aeed3e9SJustin Hibbits partitions configuration. 678*0aeed3e9SJustin Hibbits 679*0aeed3e9SJustin Hibbits @{ 680*0aeed3e9SJustin Hibbits *//***************************************************************************/ 681*0aeed3e9SJustin Hibbits 682*0aeed3e9SJustin Hibbits #define XX_IPC_MAX_ADDR_NAME_LENGTH 16 /**< Maximum length of an endpoint name string; 683*0aeed3e9SJustin Hibbits The IPC service can use this constant to limit 684*0aeed3e9SJustin Hibbits the storage space for IPC endpoint names. */ 685*0aeed3e9SJustin Hibbits 686*0aeed3e9SJustin Hibbits 687*0aeed3e9SJustin Hibbits /**************************************************************************//** 688*0aeed3e9SJustin Hibbits @Function t_IpcMsgCompletion 689*0aeed3e9SJustin Hibbits 690*0aeed3e9SJustin Hibbits @Description Callback function used upon IPC non-blocking transaction completion 691*0aeed3e9SJustin Hibbits to return message buffer to the caller and to forward reply if available. 692*0aeed3e9SJustin Hibbits 693*0aeed3e9SJustin Hibbits This callback function may be attached by the source endpoint to any outgoing 694*0aeed3e9SJustin Hibbits IPC message to indicate a non-blocking send (see also XX_IpcSendMessage() routine). 695*0aeed3e9SJustin Hibbits Upon completion of an IPC transaction (consisting of a message and an optional reply), 696*0aeed3e9SJustin Hibbits the IPC service invokes this callback routine to return the message buffer to the sender 697*0aeed3e9SJustin Hibbits and to provide the received reply, if requested. 698*0aeed3e9SJustin Hibbits 699*0aeed3e9SJustin Hibbits User provides this function. Driver invokes it. 700*0aeed3e9SJustin Hibbits 701*0aeed3e9SJustin Hibbits @Param[in] h_Module - Abstract handle to the sending module - the same handle as was passed 702*0aeed3e9SJustin Hibbits in the XX_IpcSendMessage() function; This handle is typically used to point 703*0aeed3e9SJustin Hibbits to the internal data structure of the source endpoint. 704*0aeed3e9SJustin Hibbits @Param[in] p_Msg - Pointer to original (sent) message buffer; 705*0aeed3e9SJustin Hibbits The source endpoint can free (or reuse) this buffer when message 706*0aeed3e9SJustin Hibbits completion callback is called. 707*0aeed3e9SJustin Hibbits @Param[in] p_Reply - Pointer to (received) reply buffer; 708*0aeed3e9SJustin Hibbits This pointer is the same as was provided by the source endpoint in 709*0aeed3e9SJustin Hibbits XX_IpcSendMessage(). 710*0aeed3e9SJustin Hibbits @Param[in] replyLength - Length (in bytes) of actual data in the reply buffer. 711*0aeed3e9SJustin Hibbits @Param[in] status - Completion status - E_OK or failure indication, e.g. IPC transaction completion 712*0aeed3e9SJustin Hibbits timeout. 713*0aeed3e9SJustin Hibbits 714*0aeed3e9SJustin Hibbits @Return None 715*0aeed3e9SJustin Hibbits *//***************************************************************************/ 716*0aeed3e9SJustin Hibbits typedef void (t_IpcMsgCompletion)(t_Handle h_Module, 717*0aeed3e9SJustin Hibbits uint8_t *p_Msg, 718*0aeed3e9SJustin Hibbits uint8_t *p_Reply, 719*0aeed3e9SJustin Hibbits uint32_t replyLength, 720*0aeed3e9SJustin Hibbits t_Error status); 721*0aeed3e9SJustin Hibbits 722*0aeed3e9SJustin Hibbits /**************************************************************************//** 723*0aeed3e9SJustin Hibbits @Function t_IpcMsgHandler 724*0aeed3e9SJustin Hibbits 725*0aeed3e9SJustin Hibbits @Description Callback function used as IPC message handler. 726*0aeed3e9SJustin Hibbits 727*0aeed3e9SJustin Hibbits The IPC service invokes message handlers for each IPC message received. 728*0aeed3e9SJustin Hibbits The actual function pointer should be registered by each destination endpoint 729*0aeed3e9SJustin Hibbits via the XX_IpcRegisterMsgHandler() routine. 730*0aeed3e9SJustin Hibbits 731*0aeed3e9SJustin Hibbits User provides this function. Driver invokes it. 732*0aeed3e9SJustin Hibbits 733*0aeed3e9SJustin Hibbits @Param[in] h_Module - Abstract handle to the message handling module - the same handle as 734*0aeed3e9SJustin Hibbits was passed in the XX_IpcRegisterMsgHandler() function; this handle is 735*0aeed3e9SJustin Hibbits typically used to point to the internal data structure of the destination 736*0aeed3e9SJustin Hibbits endpoint. 737*0aeed3e9SJustin Hibbits @Param[in] p_Msg - Pointer to message buffer with data received from peer. 738*0aeed3e9SJustin Hibbits @Param[in] msgLength - Length (in bytes) of message data. 739*0aeed3e9SJustin Hibbits @Param[in] p_Reply - Pointer to reply buffer, to be filled by the message handler and then sent 740*0aeed3e9SJustin Hibbits by the IPC service; 741*0aeed3e9SJustin Hibbits The reply buffer is allocated by the IPC service with size equals to the 742*0aeed3e9SJustin Hibbits replyLength parameter provided in message handler registration (see 743*0aeed3e9SJustin Hibbits XX_IpcRegisterMsgHandler() function); 744*0aeed3e9SJustin Hibbits If replyLength was initially specified as zero during message handler registration, 745*0aeed3e9SJustin Hibbits the IPC service may set this pointer to NULL and assume that a reply is not needed; 746*0aeed3e9SJustin Hibbits The IPC service is also responsible for freeing the reply buffer after the 747*0aeed3e9SJustin Hibbits reply has been sent or dismissed. 748*0aeed3e9SJustin Hibbits @Param[in,out] p_ReplyLength - Pointer to reply length, which has a dual role in this function: 749*0aeed3e9SJustin Hibbits [In] equals the replyLength parameter provided in message handler 750*0aeed3e9SJustin Hibbits registration (see XX_IpcRegisterMsgHandler() function), and 751*0aeed3e9SJustin Hibbits [Out] should be updated by message handler to the actual reply length; if 752*0aeed3e9SJustin Hibbits this value is set to zero, the IPC service must assume that a reply should 753*0aeed3e9SJustin Hibbits not be sent; 754*0aeed3e9SJustin Hibbits Note: If p_Reply is not NULL, p_ReplyLength must not be NULL as well. 755*0aeed3e9SJustin Hibbits 756*0aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 757*0aeed3e9SJustin Hibbits *//***************************************************************************/ 758*0aeed3e9SJustin Hibbits typedef t_Error (t_IpcMsgHandler)(t_Handle h_Module, 759*0aeed3e9SJustin Hibbits uint8_t *p_Msg, 760*0aeed3e9SJustin Hibbits uint32_t msgLength, 761*0aeed3e9SJustin Hibbits uint8_t *p_Reply, 762*0aeed3e9SJustin Hibbits uint32_t *p_ReplyLength); 763*0aeed3e9SJustin Hibbits 764*0aeed3e9SJustin Hibbits /**************************************************************************//** 765*0aeed3e9SJustin Hibbits @Function XX_IpcRegisterMsgHandler 766*0aeed3e9SJustin Hibbits 767*0aeed3e9SJustin Hibbits @Description IPC mailbox registration. 768*0aeed3e9SJustin Hibbits 769*0aeed3e9SJustin Hibbits This function is used for registering an IPC message handler in the IPC service. 770*0aeed3e9SJustin Hibbits This function is called by each destination endpoint to indicate that it is ready 771*0aeed3e9SJustin Hibbits to handle incoming messages. The IPC service invokes the message handler upon receiving 772*0aeed3e9SJustin Hibbits a message addressed to the specified destination endpoint. 773*0aeed3e9SJustin Hibbits 774*0aeed3e9SJustin Hibbits @Param[in] addr - The address name string associated with the destination endpoint; 775*0aeed3e9SJustin Hibbits This address must be unique across the IPC service domain to ensure 776*0aeed3e9SJustin Hibbits correct message routing. 777*0aeed3e9SJustin Hibbits @Param[in] f_MsgHandler - Pointer to the message handler callback for processing incoming 778*0aeed3e9SJustin Hibbits message; invoked by the IPC service upon receiving a message 779*0aeed3e9SJustin Hibbits addressed to the destination endpoint specified by the addr 780*0aeed3e9SJustin Hibbits parameter. 781*0aeed3e9SJustin Hibbits @Param[in] h_Module - Abstract handle to the message handling module, passed unchanged 782*0aeed3e9SJustin Hibbits to f_MsgHandler callback function. 783*0aeed3e9SJustin Hibbits @Param[in] replyLength - The maximal data length (in bytes) of any reply that the specified message handler 784*0aeed3e9SJustin Hibbits may generate; the IPC service provides the message handler with buffer 785*0aeed3e9SJustin Hibbits for reply according to the length specified here (refer also to the description 786*0aeed3e9SJustin Hibbits of #t_IpcMsgHandler callback function type); 787*0aeed3e9SJustin Hibbits This size shall be zero if the message handler never generates replies. 788*0aeed3e9SJustin Hibbits 789*0aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 790*0aeed3e9SJustin Hibbits *//***************************************************************************/ 791*0aeed3e9SJustin Hibbits t_Error XX_IpcRegisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH], 792*0aeed3e9SJustin Hibbits t_IpcMsgHandler *f_MsgHandler, 793*0aeed3e9SJustin Hibbits t_Handle h_Module, 794*0aeed3e9SJustin Hibbits uint32_t replyLength); 795*0aeed3e9SJustin Hibbits 796*0aeed3e9SJustin Hibbits /**************************************************************************//** 797*0aeed3e9SJustin Hibbits @Function XX_IpcUnregisterMsgHandler 798*0aeed3e9SJustin Hibbits 799*0aeed3e9SJustin Hibbits @Description Release IPC mailbox routine. 800*0aeed3e9SJustin Hibbits 801*0aeed3e9SJustin Hibbits This function is used for unregistering an IPC message handler from the IPC service. 802*0aeed3e9SJustin Hibbits This function is called by each destination endpoint to indicate that it is no longer 803*0aeed3e9SJustin Hibbits capable of handling incoming messages. 804*0aeed3e9SJustin Hibbits 805*0aeed3e9SJustin Hibbits @Param[in] addr - The address name string associated with the destination endpoint; 806*0aeed3e9SJustin Hibbits This address is the same as was used when the message handler was 807*0aeed3e9SJustin Hibbits registered via XX_IpcRegisterMsgHandler(). 808*0aeed3e9SJustin Hibbits 809*0aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 810*0aeed3e9SJustin Hibbits *//***************************************************************************/ 811*0aeed3e9SJustin Hibbits t_Error XX_IpcUnregisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH]); 812*0aeed3e9SJustin Hibbits 813*0aeed3e9SJustin Hibbits /**************************************************************************//** 814*0aeed3e9SJustin Hibbits @Function XX_IpcInitSession 815*0aeed3e9SJustin Hibbits 816*0aeed3e9SJustin Hibbits @Description This function is used for creating an IPC session between the source endpoint 817*0aeed3e9SJustin Hibbits and the destination endpoint. 818*0aeed3e9SJustin Hibbits 819*0aeed3e9SJustin Hibbits The actual implementation and representation of a session is left for the IPC service. 820*0aeed3e9SJustin Hibbits The function returns an abstract handle to the created session. This handle shall be used 821*0aeed3e9SJustin Hibbits by the source endpoint in subsequent calls to XX_IpcSendMessage(). 822*0aeed3e9SJustin Hibbits The IPC service assumes that before this function is called, no messages are sent from 823*0aeed3e9SJustin Hibbits the specified source endpoint to the specified destination endpoint. 824*0aeed3e9SJustin Hibbits 825*0aeed3e9SJustin Hibbits The IPC service may use a connection-oriented approach or a connectionless approach (or both) 826*0aeed3e9SJustin Hibbits as described below. 827*0aeed3e9SJustin Hibbits 828*0aeed3e9SJustin Hibbits @par Connection-Oriented Approach 829*0aeed3e9SJustin Hibbits 830*0aeed3e9SJustin Hibbits The IPC service may implement a session in a connection-oriented approach - when this function is called, 831*0aeed3e9SJustin Hibbits the IPC service should take the necessary steps to bring up a source-to-destination channel for messages 832*0aeed3e9SJustin Hibbits and a destination-to-source channel for replies. The returned handle should represent the internal 833*0aeed3e9SJustin Hibbits representation of these channels. 834*0aeed3e9SJustin Hibbits 835*0aeed3e9SJustin Hibbits @par Connectionless Approach 836*0aeed3e9SJustin Hibbits 837*0aeed3e9SJustin Hibbits The IPC service may implement a session in a connectionless approach - when this function is called, the 838*0aeed3e9SJustin Hibbits IPC service should not perform any particular steps, but it must store the pair of source and destination 839*0aeed3e9SJustin Hibbits addresses in some session representation and return it as a handle. When XX_IpcSendMessage() shall be 840*0aeed3e9SJustin Hibbits called, the IPC service may use this handle to provide the necessary identifiers for routing the messages 841*0aeed3e9SJustin Hibbits through the connectionless medium. 842*0aeed3e9SJustin Hibbits 843*0aeed3e9SJustin Hibbits @Param[in] destAddr - The address name string associated with the destination endpoint. 844*0aeed3e9SJustin Hibbits @Param[in] srcAddr - The address name string associated with the source endpoint. 845*0aeed3e9SJustin Hibbits 846*0aeed3e9SJustin Hibbits @Return Abstract handle to the initialized session, or NULL on error. 847*0aeed3e9SJustin Hibbits *//***************************************************************************/ 848*0aeed3e9SJustin Hibbits t_Handle XX_IpcInitSession(char destAddr[XX_IPC_MAX_ADDR_NAME_LENGTH], 849*0aeed3e9SJustin Hibbits char srcAddr[XX_IPC_MAX_ADDR_NAME_LENGTH]); 850*0aeed3e9SJustin Hibbits 851*0aeed3e9SJustin Hibbits /**************************************************************************//** 852*0aeed3e9SJustin Hibbits @Function XX_IpcFreeSession 853*0aeed3e9SJustin Hibbits 854*0aeed3e9SJustin Hibbits @Description This function is used for terminating an existing IPC session between a source endpoint 855*0aeed3e9SJustin Hibbits and a destination endpoint. 856*0aeed3e9SJustin Hibbits 857*0aeed3e9SJustin Hibbits The IPC service assumes that after this function is called, no messages shall be sent from 858*0aeed3e9SJustin Hibbits the associated source endpoint to the associated destination endpoint. 859*0aeed3e9SJustin Hibbits 860*0aeed3e9SJustin Hibbits @Param[in] h_Session - Abstract handle to the IPC session - the same handle as was originally 861*0aeed3e9SJustin Hibbits returned by the XX_IpcInitSession() function. 862*0aeed3e9SJustin Hibbits 863*0aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 864*0aeed3e9SJustin Hibbits *//***************************************************************************/ 865*0aeed3e9SJustin Hibbits t_Error XX_IpcFreeSession(t_Handle h_Session); 866*0aeed3e9SJustin Hibbits 867*0aeed3e9SJustin Hibbits /**************************************************************************//** 868*0aeed3e9SJustin Hibbits @Function XX_IpcSendMessage 869*0aeed3e9SJustin Hibbits 870*0aeed3e9SJustin Hibbits @Description IPC message send routine. 871*0aeed3e9SJustin Hibbits 872*0aeed3e9SJustin Hibbits This function may be used by a source endpoint to send an IPC message to a destination 873*0aeed3e9SJustin Hibbits endpoint. The source endpoint cannot send a message to the destination endpoint without 874*0aeed3e9SJustin Hibbits first initiating a session with that destination endpoint via XX_IpcInitSession() routine. 875*0aeed3e9SJustin Hibbits 876*0aeed3e9SJustin Hibbits The source endpoint must provide the buffer pointer and length of the outgoing message. 877*0aeed3e9SJustin Hibbits Optionally, it may also provide a buffer for an expected reply. In the latter case, the 878*0aeed3e9SJustin Hibbits transaction is not considered complete by the IPC service until the reply has been received. 879*0aeed3e9SJustin Hibbits If the source endpoint does not provide a reply buffer, the transaction is considered 880*0aeed3e9SJustin Hibbits complete after the message has been sent. The source endpoint must keep the message (and 881*0aeed3e9SJustin Hibbits optional reply) buffers valid until the transaction is complete. 882*0aeed3e9SJustin Hibbits 883*0aeed3e9SJustin Hibbits @par Non-blocking mode 884*0aeed3e9SJustin Hibbits 885*0aeed3e9SJustin Hibbits The source endpoint may request a non-blocking send by providing a non-NULL pointer to a message 886*0aeed3e9SJustin Hibbits completion callback function (f_Completion). Upon completion of the IPC transaction (consisting of a 887*0aeed3e9SJustin Hibbits message and an optional reply), the IPC service invokes this callback routine to return the message 888*0aeed3e9SJustin Hibbits buffer to the sender and to provide the received reply, if requested. 889*0aeed3e9SJustin Hibbits 890*0aeed3e9SJustin Hibbits @par Blocking mode 891*0aeed3e9SJustin Hibbits 892*0aeed3e9SJustin Hibbits The source endpoint may request a blocking send by setting f_Completion to NULL. The function is 893*0aeed3e9SJustin Hibbits expected to block until the IPC transaction is complete - either the reply has been received or (if no reply 894*0aeed3e9SJustin Hibbits was requested) the message has been sent. 895*0aeed3e9SJustin Hibbits 896*0aeed3e9SJustin Hibbits @Param[in] h_Session - Abstract handle to the IPC session - the same handle as was originally 897*0aeed3e9SJustin Hibbits returned by the XX_IpcInitSession() function. 898*0aeed3e9SJustin Hibbits @Param[in] p_Msg - Pointer to message buffer to send. 899*0aeed3e9SJustin Hibbits @Param[in] msgLength - Length (in bytes) of actual data in the message buffer. 900*0aeed3e9SJustin Hibbits @Param[in] p_Reply - Pointer to reply buffer - if this buffer is not NULL, the IPC service 901*0aeed3e9SJustin Hibbits fills this buffer with the received reply data; 902*0aeed3e9SJustin Hibbits In blocking mode, the reply data must be valid when the function returns; 903*0aeed3e9SJustin Hibbits In non-blocking mode, the reply data is valid when f_Completion is called; 904*0aeed3e9SJustin Hibbits If this pointer is NULL, no reply is expected. 905*0aeed3e9SJustin Hibbits @Param[in,out] p_ReplyLength - Pointer to reply length, which has a dual role in this function: 906*0aeed3e9SJustin Hibbits [In] specifies the maximal length (in bytes) of the reply buffer pointed by 907*0aeed3e9SJustin Hibbits p_Reply, and 908*0aeed3e9SJustin Hibbits [Out] in non-blocking mode this value is updated by the IPC service to the 909*0aeed3e9SJustin Hibbits actual reply length (in bytes). 910*0aeed3e9SJustin Hibbits @Param[in] f_Completion - Pointer to a completion callback to be used in non-blocking send mode; 911*0aeed3e9SJustin Hibbits The completion callback is invoked by the IPC service upon 912*0aeed3e9SJustin Hibbits completion of the IPC transaction (consisting of a message and an optional 913*0aeed3e9SJustin Hibbits reply); 914*0aeed3e9SJustin Hibbits If this pointer is NULL, the function is expected to block until the IPC 915*0aeed3e9SJustin Hibbits transaction is complete. 916*0aeed3e9SJustin Hibbits @Param[in] h_Arg - Abstract handle to the sending module; passed unchanged to the f_Completion 917*0aeed3e9SJustin Hibbits callback function as the first argument. 918*0aeed3e9SJustin Hibbits 919*0aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 920*0aeed3e9SJustin Hibbits *//***************************************************************************/ 921*0aeed3e9SJustin Hibbits t_Error XX_IpcSendMessage(t_Handle h_Session, 922*0aeed3e9SJustin Hibbits uint8_t *p_Msg, 923*0aeed3e9SJustin Hibbits uint32_t msgLength, 924*0aeed3e9SJustin Hibbits uint8_t *p_Reply, 925*0aeed3e9SJustin Hibbits uint32_t *p_ReplyLength, 926*0aeed3e9SJustin Hibbits t_IpcMsgCompletion *f_Completion, 927*0aeed3e9SJustin Hibbits t_Handle h_Arg); 928*0aeed3e9SJustin Hibbits 929*0aeed3e9SJustin Hibbits 930*0aeed3e9SJustin Hibbits /** @} */ /* end of xx_ipc group */ 931*0aeed3e9SJustin Hibbits /** @} */ /* end of xx_id group */ 932*0aeed3e9SJustin Hibbits 933*0aeed3e9SJustin Hibbits /** FreeBSD Specific additions. */ 934*0aeed3e9SJustin Hibbits void XX_TrackInit(void); 935*0aeed3e9SJustin Hibbits void XX_TrackAddress(void *addr); 936*0aeed3e9SJustin Hibbits void XX_UntrackAddress(void *addr); 937*0aeed3e9SJustin Hibbits 938*0aeed3e9SJustin Hibbits #endif /* __XX_EXT_H */ 939