1852ba100SJustin 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 33852ba100SJustin Hibbits 340aeed3e9SJustin Hibbits /**************************************************************************//** 350aeed3e9SJustin Hibbits @File xx_ext.h 360aeed3e9SJustin Hibbits 370aeed3e9SJustin Hibbits @Description Prototypes, externals and typedefs for system-supplied 380aeed3e9SJustin Hibbits (external) routines 390aeed3e9SJustin Hibbits *//***************************************************************************/ 400aeed3e9SJustin Hibbits 410aeed3e9SJustin Hibbits #ifndef __XX_EXT_H 420aeed3e9SJustin Hibbits #define __XX_EXT_H 430aeed3e9SJustin Hibbits 440aeed3e9SJustin Hibbits #include "std_ext.h" 45852ba100SJustin Hibbits #include "xx_common.h" 460aeed3e9SJustin Hibbits #include "part_ext.h" 470aeed3e9SJustin Hibbits 480aeed3e9SJustin Hibbits 490aeed3e9SJustin Hibbits 500aeed3e9SJustin Hibbits /**************************************************************************//** 510aeed3e9SJustin Hibbits @Group xx_id XX Interface (System call hooks) 520aeed3e9SJustin Hibbits 530aeed3e9SJustin Hibbits @Description Prototypes, externals and typedefs for system-supplied 540aeed3e9SJustin Hibbits (external) routines 550aeed3e9SJustin Hibbits 560aeed3e9SJustin Hibbits @{ 570aeed3e9SJustin Hibbits *//***************************************************************************/ 580aeed3e9SJustin Hibbits 590aeed3e9SJustin Hibbits #ifdef DEBUG_XX_MALLOC 600aeed3e9SJustin Hibbits void * XX_MallocDebug(uint32_t size, char *fname, int line); 610aeed3e9SJustin Hibbits 620aeed3e9SJustin Hibbits void * XX_MallocSmartDebug(uint32_t size, 630aeed3e9SJustin Hibbits int memPartitionId, 640aeed3e9SJustin Hibbits uint32_t alignment, 650aeed3e9SJustin Hibbits char *fname, 660aeed3e9SJustin Hibbits int line); 670aeed3e9SJustin Hibbits 680aeed3e9SJustin Hibbits #define XX_Malloc(sz) \ 690aeed3e9SJustin Hibbits XX_MallocDebug((sz), __FILE__, __LINE__) 700aeed3e9SJustin Hibbits 710aeed3e9SJustin Hibbits #define XX_MallocSmart(sz, memt, al) \ 720aeed3e9SJustin Hibbits XX_MallocSmartDebug((sz), (memt), (al), __FILE__, __LINE__) 730aeed3e9SJustin Hibbits 740aeed3e9SJustin Hibbits #else /* not DEBUG_XX_MALLOC */ 750aeed3e9SJustin Hibbits /**************************************************************************//** 760aeed3e9SJustin Hibbits @Function XX_Malloc 770aeed3e9SJustin Hibbits 780aeed3e9SJustin Hibbits @Description allocates contiguous block of memory. 790aeed3e9SJustin Hibbits 800aeed3e9SJustin Hibbits @Param[in] size - Number of bytes to allocate. 810aeed3e9SJustin Hibbits 820aeed3e9SJustin Hibbits @Return The address of the newly allocated block on success, NULL on failure. 830aeed3e9SJustin Hibbits *//***************************************************************************/ 840aeed3e9SJustin Hibbits void * XX_Malloc(uint32_t size); 850aeed3e9SJustin Hibbits 860aeed3e9SJustin Hibbits /**************************************************************************//** 870aeed3e9SJustin Hibbits @Function XX_MallocSmart 880aeed3e9SJustin Hibbits 890aeed3e9SJustin Hibbits @Description Allocates contiguous block of memory in a specified 900aeed3e9SJustin Hibbits alignment and from the specified segment. 910aeed3e9SJustin Hibbits 920aeed3e9SJustin Hibbits @Param[in] size - Number of bytes to allocate. 930aeed3e9SJustin Hibbits @Param[in] memPartitionId - Memory partition ID; The value zero must 940aeed3e9SJustin Hibbits be mapped to the default heap partition. 950aeed3e9SJustin Hibbits @Param[in] alignment - Required memory alignment (in bytes). 960aeed3e9SJustin Hibbits 970aeed3e9SJustin Hibbits @Return The address of the newly allocated block on success, NULL on failure. 980aeed3e9SJustin Hibbits *//***************************************************************************/ 990aeed3e9SJustin Hibbits void * XX_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment); 100852ba100SJustin Hibbits 101852ba100SJustin Hibbits int XX_MallocSmartInit(void); 1020aeed3e9SJustin Hibbits #endif /* not DEBUG_XX_MALLOC */ 1030aeed3e9SJustin Hibbits 1040aeed3e9SJustin Hibbits /**************************************************************************//** 1050aeed3e9SJustin Hibbits @Function XX_FreeSmart 1060aeed3e9SJustin Hibbits 1070aeed3e9SJustin Hibbits @Description Frees the memory block pointed to by "p". 1080aeed3e9SJustin Hibbits Only for memory allocated by XX_MallocSmart 1090aeed3e9SJustin Hibbits 1100aeed3e9SJustin Hibbits @Param[in] p_Memory - pointer to the memory block. 1110aeed3e9SJustin Hibbits 1120aeed3e9SJustin Hibbits @Return None. 1130aeed3e9SJustin Hibbits *//***************************************************************************/ 1140aeed3e9SJustin Hibbits void XX_FreeSmart(void *p_Memory); 1150aeed3e9SJustin Hibbits 1160aeed3e9SJustin Hibbits /**************************************************************************//** 1170aeed3e9SJustin Hibbits @Function XX_Free 1180aeed3e9SJustin Hibbits 1190aeed3e9SJustin Hibbits @Description frees the memory block pointed to by "p". 1200aeed3e9SJustin Hibbits 1210aeed3e9SJustin Hibbits @Param[in] p_Memory - pointer to the memory block. 1220aeed3e9SJustin Hibbits 1230aeed3e9SJustin Hibbits @Return None. 1240aeed3e9SJustin Hibbits *//***************************************************************************/ 1250aeed3e9SJustin Hibbits void XX_Free(void *p_Memory); 1260aeed3e9SJustin Hibbits 1270aeed3e9SJustin Hibbits /**************************************************************************//** 1280aeed3e9SJustin Hibbits @Function XX_Print 1290aeed3e9SJustin Hibbits 1300aeed3e9SJustin Hibbits @Description print a string. 1310aeed3e9SJustin Hibbits 1320aeed3e9SJustin Hibbits @Param[in] str - string to print. 1330aeed3e9SJustin Hibbits 1340aeed3e9SJustin Hibbits @Return None. 1350aeed3e9SJustin Hibbits *//***************************************************************************/ 1360aeed3e9SJustin Hibbits void XX_Print(char *str, ...); 1370aeed3e9SJustin Hibbits 1380aeed3e9SJustin Hibbits /**************************************************************************//** 1390aeed3e9SJustin Hibbits @Function XX_SetIntr 1400aeed3e9SJustin Hibbits 1410aeed3e9SJustin Hibbits @Description Set an interrupt service routine for a specific interrupt source. 1420aeed3e9SJustin Hibbits 1430aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 1440aeed3e9SJustin Hibbits @Param[in] f_Isr - Callback routine that will be called when the interrupt occurs. 1450aeed3e9SJustin Hibbits @Param[in] handle - The argument for the user callback routine. 1460aeed3e9SJustin Hibbits 1470aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 1480aeed3e9SJustin Hibbits *//***************************************************************************/ 149f77405e3SJustin Hibbits t_Error XX_SetIntr(uintptr_t irq, t_Isr *f_Isr, t_Handle handle); 1500aeed3e9SJustin Hibbits 1510aeed3e9SJustin Hibbits /**************************************************************************//** 1520aeed3e9SJustin Hibbits @Function XX_FreeIntr 1530aeed3e9SJustin Hibbits 1540aeed3e9SJustin Hibbits @Description Free a specific interrupt and a specific callback routine. 1550aeed3e9SJustin Hibbits 1560aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 1570aeed3e9SJustin Hibbits 1580aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 1590aeed3e9SJustin Hibbits *//***************************************************************************/ 160f77405e3SJustin Hibbits t_Error XX_FreeIntr(uintptr_t irq); 1610aeed3e9SJustin Hibbits 1620aeed3e9SJustin Hibbits /**************************************************************************//** 1630aeed3e9SJustin Hibbits @Function XX_EnableIntr 1640aeed3e9SJustin Hibbits 1650aeed3e9SJustin Hibbits @Description Enable a specific interrupt. 1660aeed3e9SJustin Hibbits 1670aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 1680aeed3e9SJustin Hibbits 1690aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 1700aeed3e9SJustin Hibbits *//***************************************************************************/ 171f77405e3SJustin Hibbits t_Error XX_EnableIntr(uintptr_t irq); 1720aeed3e9SJustin Hibbits 1730aeed3e9SJustin Hibbits /**************************************************************************//** 1740aeed3e9SJustin Hibbits @Function XX_DisableIntr 1750aeed3e9SJustin Hibbits 1760aeed3e9SJustin Hibbits @Description Disable a specific interrupt. 1770aeed3e9SJustin Hibbits 1780aeed3e9SJustin Hibbits @Param[in] irq - Interrupt ID (system-specific number). 1790aeed3e9SJustin Hibbits 1800aeed3e9SJustin Hibbits @Return E_OK on success; error code otherwise.. 1810aeed3e9SJustin Hibbits *//***************************************************************************/ 182f77405e3SJustin Hibbits t_Error XX_DisableIntr(uintptr_t irq); 1830aeed3e9SJustin Hibbits 1840aeed3e9SJustin Hibbits /**************************************************************************//** 1850aeed3e9SJustin Hibbits @Function XX_DisableAllIntr 1860aeed3e9SJustin Hibbits 1870aeed3e9SJustin Hibbits @Description Disable all interrupts by masking them at the CPU. 1880aeed3e9SJustin Hibbits 1890aeed3e9SJustin Hibbits @Return A value that represents the interrupts state before the 1900aeed3e9SJustin Hibbits operation, and should be passed to the matching 1910aeed3e9SJustin Hibbits XX_RestoreAllIntr() call. 1920aeed3e9SJustin Hibbits *//***************************************************************************/ 1930aeed3e9SJustin Hibbits uint32_t XX_DisableAllIntr(void); 1940aeed3e9SJustin Hibbits 1950aeed3e9SJustin Hibbits /**************************************************************************//** 1960aeed3e9SJustin Hibbits @Function XX_RestoreAllIntr 1970aeed3e9SJustin Hibbits 1980aeed3e9SJustin Hibbits @Description Restore previous state of interrupts level at the CPU. 1990aeed3e9SJustin Hibbits 2000aeed3e9SJustin Hibbits @Param[in] flags - A value that represents the interrupts state to restore, 2010aeed3e9SJustin Hibbits as returned by the matching call for XX_DisableAllIntr(). 2020aeed3e9SJustin Hibbits 2030aeed3e9SJustin Hibbits @Return None. 2040aeed3e9SJustin Hibbits *//***************************************************************************/ 2050aeed3e9SJustin Hibbits void XX_RestoreAllIntr(uint32_t flags); 2060aeed3e9SJustin Hibbits 2070aeed3e9SJustin Hibbits 208*b9931c07SBrandon Bergren t_Error XX_PreallocAndBindIntr(device_t dev, uintptr_t irq, unsigned int cpu); 209852ba100SJustin Hibbits t_Error XX_DeallocIntr(uintptr_t irq); 2100aeed3e9SJustin Hibbits 2110aeed3e9SJustin Hibbits /**************************************************************************//** 2120aeed3e9SJustin Hibbits @Function XX_Exit 2130aeed3e9SJustin Hibbits 2140aeed3e9SJustin Hibbits @Description Stop execution and report status (where it is applicable) 2150aeed3e9SJustin Hibbits 2160aeed3e9SJustin Hibbits @Param[in] status - exit status 2170aeed3e9SJustin Hibbits *//***************************************************************************/ 2180aeed3e9SJustin Hibbits void XX_Exit(int status); 2190aeed3e9SJustin Hibbits 220852ba100SJustin Hibbits 2210aeed3e9SJustin Hibbits /*****************************************************************************/ 2220aeed3e9SJustin Hibbits /* Tasklet Service Routines */ 2230aeed3e9SJustin Hibbits /*****************************************************************************/ 2240aeed3e9SJustin Hibbits typedef t_Handle t_TaskletHandle; 2250aeed3e9SJustin Hibbits 2260aeed3e9SJustin Hibbits /**************************************************************************//** 2270aeed3e9SJustin Hibbits @Function XX_InitTasklet 2280aeed3e9SJustin Hibbits 2290aeed3e9SJustin Hibbits @Description Create and initialize a tasklet object. 2300aeed3e9SJustin Hibbits 2310aeed3e9SJustin Hibbits @Param[in] routine - A routine to be ran as a tasklet. 2320aeed3e9SJustin Hibbits @Param[in] data - An argument to pass to the tasklet. 2330aeed3e9SJustin Hibbits 2340aeed3e9SJustin Hibbits @Return Tasklet handle is returned on success. NULL is returned otherwise. 2350aeed3e9SJustin Hibbits *//***************************************************************************/ 2360aeed3e9SJustin Hibbits t_TaskletHandle XX_InitTasklet (void (*routine)(void *), void *data); 2370aeed3e9SJustin Hibbits 2380aeed3e9SJustin Hibbits /**************************************************************************//** 2390aeed3e9SJustin Hibbits @Function XX_FreeTasklet 2400aeed3e9SJustin Hibbits 2410aeed3e9SJustin Hibbits @Description Free a tasklet object. 2420aeed3e9SJustin Hibbits 2430aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be free. 2440aeed3e9SJustin Hibbits 2450aeed3e9SJustin Hibbits @Return None. 2460aeed3e9SJustin Hibbits *//***************************************************************************/ 2470aeed3e9SJustin Hibbits void XX_FreeTasklet (t_TaskletHandle h_Tasklet); 2480aeed3e9SJustin Hibbits 2490aeed3e9SJustin Hibbits /**************************************************************************//** 2500aeed3e9SJustin Hibbits @Function XX_ScheduleTask 2510aeed3e9SJustin Hibbits 2520aeed3e9SJustin Hibbits @Description Schedule a tasklet object. 2530aeed3e9SJustin Hibbits 2540aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be scheduled. 2550aeed3e9SJustin Hibbits @Param[in] immediate - Indicate whether to schedule this tasklet on 2560aeed3e9SJustin Hibbits the immediate queue or on the delayed one. 2570aeed3e9SJustin Hibbits 2580aeed3e9SJustin Hibbits @Return 0 - on success. Error code - otherwise. 2590aeed3e9SJustin Hibbits *//***************************************************************************/ 2600aeed3e9SJustin Hibbits int XX_ScheduleTask(t_TaskletHandle h_Tasklet, int immediate); 2610aeed3e9SJustin Hibbits 2620aeed3e9SJustin Hibbits /**************************************************************************//** 2630aeed3e9SJustin Hibbits @Function XX_FlushScheduledTasks 2640aeed3e9SJustin Hibbits 2650aeed3e9SJustin Hibbits @Description Flush all tasks there are in the scheduled tasks queue. 2660aeed3e9SJustin Hibbits 2670aeed3e9SJustin Hibbits @Return None. 2680aeed3e9SJustin Hibbits *//***************************************************************************/ 2690aeed3e9SJustin Hibbits void XX_FlushScheduledTasks(void); 2700aeed3e9SJustin Hibbits 2710aeed3e9SJustin Hibbits /**************************************************************************//** 2720aeed3e9SJustin Hibbits @Function XX_TaskletIsQueued 2730aeed3e9SJustin Hibbits 2740aeed3e9SJustin Hibbits @Description Check if task is queued. 2750aeed3e9SJustin Hibbits 2760aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be scheduled. 2770aeed3e9SJustin Hibbits 2780aeed3e9SJustin Hibbits @Return 1 - task is queued. 0 - otherwise. 2790aeed3e9SJustin Hibbits *//***************************************************************************/ 2800aeed3e9SJustin Hibbits int XX_TaskletIsQueued(t_TaskletHandle h_Tasklet); 2810aeed3e9SJustin Hibbits 2820aeed3e9SJustin Hibbits /**************************************************************************//** 2830aeed3e9SJustin Hibbits @Function XX_SetTaskletData 2840aeed3e9SJustin Hibbits 2850aeed3e9SJustin Hibbits @Description Set data to a scheduled task. Used to change data of already 2860aeed3e9SJustin Hibbits scheduled task. 2870aeed3e9SJustin Hibbits 2880aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be scheduled. 2890aeed3e9SJustin Hibbits @Param[in] data - Data to be set. 2900aeed3e9SJustin Hibbits *//***************************************************************************/ 2910aeed3e9SJustin Hibbits void XX_SetTaskletData(t_TaskletHandle h_Tasklet, t_Handle data); 2920aeed3e9SJustin Hibbits 2930aeed3e9SJustin Hibbits /**************************************************************************//** 2940aeed3e9SJustin Hibbits @Function XX_GetTaskletData 2950aeed3e9SJustin Hibbits 2960aeed3e9SJustin Hibbits @Description Get the data of scheduled task. 2970aeed3e9SJustin Hibbits 2980aeed3e9SJustin Hibbits @Param[in] h_Tasklet - A handle to a tasklet to be scheduled. 2990aeed3e9SJustin Hibbits 3000aeed3e9SJustin Hibbits @Return handle to the data of the task. 3010aeed3e9SJustin Hibbits *//***************************************************************************/ 3020aeed3e9SJustin Hibbits t_Handle XX_GetTaskletData(t_TaskletHandle h_Tasklet); 3030aeed3e9SJustin Hibbits 3040aeed3e9SJustin Hibbits /**************************************************************************//** 3050aeed3e9SJustin Hibbits @Function XX_BottomHalf 3060aeed3e9SJustin Hibbits 3070aeed3e9SJustin Hibbits @Description Bottom half implementation, invoked by the interrupt handler. 3080aeed3e9SJustin Hibbits 3090aeed3e9SJustin Hibbits This routine handles all bottom-half tasklets with interrupts 3100aeed3e9SJustin Hibbits enabled. 3110aeed3e9SJustin Hibbits 3120aeed3e9SJustin Hibbits @Return None. 3130aeed3e9SJustin Hibbits *//***************************************************************************/ 3140aeed3e9SJustin Hibbits void XX_BottomHalf(void); 3150aeed3e9SJustin Hibbits 3160aeed3e9SJustin Hibbits 3170aeed3e9SJustin Hibbits /*****************************************************************************/ 3180aeed3e9SJustin Hibbits /* Spinlock Service Routines */ 3190aeed3e9SJustin Hibbits /*****************************************************************************/ 3200aeed3e9SJustin Hibbits 3210aeed3e9SJustin Hibbits /**************************************************************************//** 3220aeed3e9SJustin Hibbits @Function XX_InitSpinlock 3230aeed3e9SJustin Hibbits 3240aeed3e9SJustin Hibbits @Description Creates a spinlock. 3250aeed3e9SJustin Hibbits 3260aeed3e9SJustin Hibbits @Return Spinlock handle is returned on success; NULL otherwise. 3270aeed3e9SJustin Hibbits *//***************************************************************************/ 3280aeed3e9SJustin Hibbits t_Handle XX_InitSpinlock(void); 3290aeed3e9SJustin Hibbits 3300aeed3e9SJustin Hibbits /**************************************************************************//** 3310aeed3e9SJustin Hibbits @Function XX_FreeSpinlock 3320aeed3e9SJustin Hibbits 3330aeed3e9SJustin Hibbits @Description Frees the memory allocated for the spinlock creation. 3340aeed3e9SJustin Hibbits 3350aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 3360aeed3e9SJustin Hibbits 3370aeed3e9SJustin Hibbits @Return None. 3380aeed3e9SJustin Hibbits *//***************************************************************************/ 3390aeed3e9SJustin Hibbits void XX_FreeSpinlock(t_Handle h_Spinlock); 3400aeed3e9SJustin Hibbits 3410aeed3e9SJustin Hibbits /**************************************************************************//** 3420aeed3e9SJustin Hibbits @Function XX_LockSpinlock 3430aeed3e9SJustin Hibbits 3440aeed3e9SJustin Hibbits @Description Locks a spinlock. 3450aeed3e9SJustin Hibbits 3460aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 3470aeed3e9SJustin Hibbits 3480aeed3e9SJustin Hibbits @Return None. 3490aeed3e9SJustin Hibbits *//***************************************************************************/ 3500aeed3e9SJustin Hibbits void XX_LockSpinlock(t_Handle h_Spinlock); 3510aeed3e9SJustin Hibbits 3520aeed3e9SJustin Hibbits /**************************************************************************//** 3530aeed3e9SJustin Hibbits @Function XX_UnlockSpinlock 3540aeed3e9SJustin Hibbits 3550aeed3e9SJustin Hibbits @Description Unlocks a spinlock. 3560aeed3e9SJustin Hibbits 3570aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 3580aeed3e9SJustin Hibbits 3590aeed3e9SJustin Hibbits @Return None. 3600aeed3e9SJustin Hibbits *//***************************************************************************/ 3610aeed3e9SJustin Hibbits void XX_UnlockSpinlock(t_Handle h_Spinlock); 3620aeed3e9SJustin Hibbits 3630aeed3e9SJustin Hibbits /**************************************************************************//** 3640aeed3e9SJustin Hibbits @Function XX_LockIntrSpinlock 3650aeed3e9SJustin Hibbits 3660aeed3e9SJustin Hibbits @Description Locks a spinlock (interrupt safe). 3670aeed3e9SJustin Hibbits 3680aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 3690aeed3e9SJustin Hibbits 3700aeed3e9SJustin Hibbits @Return A value that represents the interrupts state before the 3710aeed3e9SJustin Hibbits operation, and should be passed to the matching 3720aeed3e9SJustin Hibbits XX_UnlockIntrSpinlock() call. 3730aeed3e9SJustin Hibbits *//***************************************************************************/ 3740aeed3e9SJustin Hibbits uint32_t XX_LockIntrSpinlock(t_Handle h_Spinlock); 3750aeed3e9SJustin Hibbits 3760aeed3e9SJustin Hibbits /**************************************************************************//** 3770aeed3e9SJustin Hibbits @Function XX_UnlockIntrSpinlock 3780aeed3e9SJustin Hibbits 3790aeed3e9SJustin Hibbits @Description Unlocks a spinlock (interrupt safe). 3800aeed3e9SJustin Hibbits 3810aeed3e9SJustin Hibbits @Param[in] h_Spinlock - A handle to a spinlock. 3820aeed3e9SJustin Hibbits @Param[in] intrFlags - A value that represents the interrupts state to 3830aeed3e9SJustin Hibbits restore, as returned by the matching call for 3840aeed3e9SJustin Hibbits XX_LockIntrSpinlock(). 3850aeed3e9SJustin Hibbits 3860aeed3e9SJustin Hibbits @Return None. 3870aeed3e9SJustin Hibbits *//***************************************************************************/ 3880aeed3e9SJustin Hibbits void XX_UnlockIntrSpinlock(t_Handle h_Spinlock, uint32_t intrFlags); 3890aeed3e9SJustin Hibbits 3900aeed3e9SJustin Hibbits 3910aeed3e9SJustin Hibbits /*****************************************************************************/ 3920aeed3e9SJustin Hibbits /* Timers Service Routines */ 3930aeed3e9SJustin Hibbits /*****************************************************************************/ 3940aeed3e9SJustin Hibbits 3950aeed3e9SJustin Hibbits /**************************************************************************//** 3960aeed3e9SJustin Hibbits @Function XX_CurrentTime 3970aeed3e9SJustin Hibbits 3980aeed3e9SJustin Hibbits @Description Returns current system time. 3990aeed3e9SJustin Hibbits 4000aeed3e9SJustin Hibbits @Return Current system time (in milliseconds). 4010aeed3e9SJustin Hibbits *//***************************************************************************/ 4020aeed3e9SJustin Hibbits uint32_t XX_CurrentTime(void); 4030aeed3e9SJustin Hibbits 4040aeed3e9SJustin Hibbits /**************************************************************************//** 4050aeed3e9SJustin Hibbits @Function XX_CreateTimer 4060aeed3e9SJustin Hibbits 4070aeed3e9SJustin Hibbits @Description Creates a timer. 4080aeed3e9SJustin Hibbits 4090aeed3e9SJustin Hibbits @Return Timer handle is returned on success; NULL otherwise. 4100aeed3e9SJustin Hibbits *//***************************************************************************/ 4110aeed3e9SJustin Hibbits t_Handle XX_CreateTimer(void); 4120aeed3e9SJustin Hibbits 4130aeed3e9SJustin Hibbits /**************************************************************************//** 4140aeed3e9SJustin Hibbits @Function XX_FreeTimer 4150aeed3e9SJustin Hibbits 4160aeed3e9SJustin Hibbits @Description Frees the memory allocated for the timer creation. 4170aeed3e9SJustin Hibbits 4180aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 4190aeed3e9SJustin Hibbits 4200aeed3e9SJustin Hibbits @Return None. 4210aeed3e9SJustin Hibbits *//***************************************************************************/ 4220aeed3e9SJustin Hibbits void XX_FreeTimer(t_Handle h_Timer); 4230aeed3e9SJustin Hibbits 4240aeed3e9SJustin Hibbits /**************************************************************************//** 4250aeed3e9SJustin Hibbits @Function XX_StartTimer 4260aeed3e9SJustin Hibbits 4270aeed3e9SJustin Hibbits @Description Starts a timer. 4280aeed3e9SJustin Hibbits 4290aeed3e9SJustin Hibbits The user can select to start the timer as periodic timer or as 4300aeed3e9SJustin Hibbits one-shot timer. The user should provide a callback routine that 4310aeed3e9SJustin Hibbits will be called when the timer expires. 4320aeed3e9SJustin Hibbits 4330aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 4340aeed3e9SJustin Hibbits @Param[in] msecs - Timer expiration period (in milliseconds). 4350aeed3e9SJustin Hibbits @Param[in] periodic - TRUE for a periodic timer; 4360aeed3e9SJustin Hibbits FALSE for a one-shot timer.. 4370aeed3e9SJustin Hibbits @Param[in] f_TimerExpired - A callback routine to be called when the 4380aeed3e9SJustin Hibbits timer expires. 4390aeed3e9SJustin Hibbits @Param[in] h_Arg - The argument to pass in the timer-expired 4400aeed3e9SJustin Hibbits callback routine. 4410aeed3e9SJustin Hibbits 4420aeed3e9SJustin Hibbits @Return None. 4430aeed3e9SJustin Hibbits *//***************************************************************************/ 4440aeed3e9SJustin Hibbits void XX_StartTimer(t_Handle h_Timer, 4450aeed3e9SJustin Hibbits uint32_t msecs, 4460aeed3e9SJustin Hibbits bool periodic, 4470aeed3e9SJustin Hibbits void (*f_TimerExpired)(t_Handle h_Arg), 4480aeed3e9SJustin Hibbits t_Handle h_Arg); 4490aeed3e9SJustin Hibbits 4500aeed3e9SJustin Hibbits /**************************************************************************//** 4510aeed3e9SJustin Hibbits @Function XX_StopTimer 4520aeed3e9SJustin Hibbits 4530aeed3e9SJustin Hibbits @Description Frees the memory allocated for the timer creation. 4540aeed3e9SJustin Hibbits 4550aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 4560aeed3e9SJustin Hibbits 4570aeed3e9SJustin Hibbits @Return None. 4580aeed3e9SJustin Hibbits *//***************************************************************************/ 4590aeed3e9SJustin Hibbits void XX_StopTimer(t_Handle h_Timer); 4600aeed3e9SJustin Hibbits 4610aeed3e9SJustin Hibbits /**************************************************************************//** 4620aeed3e9SJustin Hibbits @Function XX_ModTimer 4630aeed3e9SJustin Hibbits 4640aeed3e9SJustin Hibbits @Description Updates the expiration time of a timer. 4650aeed3e9SJustin Hibbits 4660aeed3e9SJustin Hibbits This routine adds the given time to the current system time, 4670aeed3e9SJustin Hibbits and sets this value as the new expiration time of the timer. 4680aeed3e9SJustin Hibbits 4690aeed3e9SJustin Hibbits @Param[in] h_Timer - A handle to a timer. 4700aeed3e9SJustin Hibbits @Param[in] msecs - The new interval until timer expiration 4710aeed3e9SJustin Hibbits (in milliseconds). 4720aeed3e9SJustin Hibbits 4730aeed3e9SJustin Hibbits @Return None. 4740aeed3e9SJustin Hibbits *//***************************************************************************/ 4750aeed3e9SJustin Hibbits void XX_ModTimer(t_Handle h_Timer, uint32_t msecs); 4760aeed3e9SJustin Hibbits 4770aeed3e9SJustin Hibbits /**************************************************************************//** 4780aeed3e9SJustin Hibbits @Function XX_Sleep 4790aeed3e9SJustin Hibbits 4800aeed3e9SJustin Hibbits @Description Non-busy wait until the desired time (in milliseconds) has passed. 4810aeed3e9SJustin Hibbits 4820aeed3e9SJustin Hibbits @Param[in] msecs - The requested sleep time (in milliseconds). 4830aeed3e9SJustin Hibbits 484852ba100SJustin Hibbits @Return Zero if the requested time has elapsed; Otherwise, the value 485852ba100SJustin Hibbits returned will be the unslept amount) in milliseconds. 4860aeed3e9SJustin Hibbits 4870aeed3e9SJustin Hibbits @Cautions This routine enables interrupts during its wait time. 4880aeed3e9SJustin Hibbits *//***************************************************************************/ 4890aeed3e9SJustin Hibbits uint32_t XX_Sleep(uint32_t msecs); 4900aeed3e9SJustin Hibbits 4910aeed3e9SJustin Hibbits /**************************************************************************//** 4920aeed3e9SJustin Hibbits @Function XX_UDelay 4930aeed3e9SJustin Hibbits 4940aeed3e9SJustin Hibbits @Description Busy-wait until the desired time (in microseconds) has passed. 4950aeed3e9SJustin Hibbits 4960aeed3e9SJustin Hibbits @Param[in] usecs - The requested delay time (in microseconds). 4970aeed3e9SJustin Hibbits 4980aeed3e9SJustin Hibbits @Return None. 4990aeed3e9SJustin Hibbits 5000aeed3e9SJustin Hibbits @Cautions It is highly unrecommended to call this routine during interrupt 5010aeed3e9SJustin Hibbits time, because the system time may not be updated properly during 5020aeed3e9SJustin Hibbits the delay loop. The behavior of this routine during interrupt 5030aeed3e9SJustin Hibbits time is unexpected. 5040aeed3e9SJustin Hibbits *//***************************************************************************/ 5050aeed3e9SJustin Hibbits void XX_UDelay(uint32_t usecs); 5060aeed3e9SJustin Hibbits 5070aeed3e9SJustin Hibbits 5080aeed3e9SJustin Hibbits /*****************************************************************************/ 5090aeed3e9SJustin Hibbits /* Other Service Routines */ 5100aeed3e9SJustin Hibbits /*****************************************************************************/ 5110aeed3e9SJustin Hibbits 5120aeed3e9SJustin Hibbits /**************************************************************************//** 5130aeed3e9SJustin Hibbits @Function XX_PhysToVirt 5140aeed3e9SJustin Hibbits 5150aeed3e9SJustin Hibbits @Description Translates a physical address to the matching virtual address. 5160aeed3e9SJustin Hibbits 5170aeed3e9SJustin Hibbits @Param[in] addr - The physical address to translate. 5180aeed3e9SJustin Hibbits 5190aeed3e9SJustin Hibbits @Return Virtual address. 5200aeed3e9SJustin Hibbits *//***************************************************************************/ 5210aeed3e9SJustin Hibbits void * XX_PhysToVirt(physAddress_t addr); 5220aeed3e9SJustin Hibbits 5230aeed3e9SJustin Hibbits /**************************************************************************//** 5240aeed3e9SJustin Hibbits @Function XX_VirtToPhys 5250aeed3e9SJustin Hibbits 5260aeed3e9SJustin Hibbits @Description Translates a virtual address to the matching physical address. 5270aeed3e9SJustin Hibbits 5280aeed3e9SJustin Hibbits @Param[in] addr - The virtual address to translate. 5290aeed3e9SJustin Hibbits 5300aeed3e9SJustin Hibbits @Return Physical address. 5310aeed3e9SJustin Hibbits *//***************************************************************************/ 5320aeed3e9SJustin Hibbits physAddress_t XX_VirtToPhys(void *addr); 5330aeed3e9SJustin Hibbits 5340aeed3e9SJustin Hibbits 5350aeed3e9SJustin Hibbits /**************************************************************************//** 5360aeed3e9SJustin Hibbits @Group xx_ipc XX Inter-Partition-Communication API 5370aeed3e9SJustin Hibbits 5380aeed3e9SJustin Hibbits @Description The following API is to be used when working with multiple 5390aeed3e9SJustin Hibbits partitions configuration. 5400aeed3e9SJustin Hibbits 5410aeed3e9SJustin Hibbits @{ 5420aeed3e9SJustin Hibbits *//***************************************************************************/ 5430aeed3e9SJustin Hibbits 5440aeed3e9SJustin Hibbits #define XX_IPC_MAX_ADDR_NAME_LENGTH 16 /**< Maximum length of an endpoint name string; 5450aeed3e9SJustin Hibbits The IPC service can use this constant to limit 5460aeed3e9SJustin Hibbits the storage space for IPC endpoint names. */ 5470aeed3e9SJustin Hibbits 5480aeed3e9SJustin Hibbits 5490aeed3e9SJustin Hibbits /**************************************************************************//** 5500aeed3e9SJustin Hibbits @Function t_IpcMsgCompletion 5510aeed3e9SJustin Hibbits 5520aeed3e9SJustin Hibbits @Description Callback function used upon IPC non-blocking transaction completion 5530aeed3e9SJustin Hibbits to return message buffer to the caller and to forward reply if available. 5540aeed3e9SJustin Hibbits 5550aeed3e9SJustin Hibbits This callback function may be attached by the source endpoint to any outgoing 5560aeed3e9SJustin Hibbits IPC message to indicate a non-blocking send (see also XX_IpcSendMessage() routine). 5570aeed3e9SJustin Hibbits Upon completion of an IPC transaction (consisting of a message and an optional reply), 5580aeed3e9SJustin Hibbits the IPC service invokes this callback routine to return the message buffer to the sender 5590aeed3e9SJustin Hibbits and to provide the received reply, if requested. 5600aeed3e9SJustin Hibbits 5610aeed3e9SJustin Hibbits User provides this function. Driver invokes it. 5620aeed3e9SJustin Hibbits 5630aeed3e9SJustin Hibbits @Param[in] h_Module - Abstract handle to the sending module - the same handle as was passed 5640aeed3e9SJustin Hibbits in the XX_IpcSendMessage() function; This handle is typically used to point 5650aeed3e9SJustin Hibbits to the internal data structure of the source endpoint. 5660aeed3e9SJustin Hibbits @Param[in] p_Msg - Pointer to original (sent) message buffer; 5670aeed3e9SJustin Hibbits The source endpoint can free (or reuse) this buffer when message 5680aeed3e9SJustin Hibbits completion callback is called. 5690aeed3e9SJustin Hibbits @Param[in] p_Reply - Pointer to (received) reply buffer; 5700aeed3e9SJustin Hibbits This pointer is the same as was provided by the source endpoint in 5710aeed3e9SJustin Hibbits XX_IpcSendMessage(). 5720aeed3e9SJustin Hibbits @Param[in] replyLength - Length (in bytes) of actual data in the reply buffer. 5730aeed3e9SJustin Hibbits @Param[in] status - Completion status - E_OK or failure indication, e.g. IPC transaction completion 5740aeed3e9SJustin Hibbits timeout. 5750aeed3e9SJustin Hibbits 5760aeed3e9SJustin Hibbits @Return None 5770aeed3e9SJustin Hibbits *//***************************************************************************/ 5780aeed3e9SJustin Hibbits typedef void (t_IpcMsgCompletion)(t_Handle h_Module, 5790aeed3e9SJustin Hibbits uint8_t *p_Msg, 5800aeed3e9SJustin Hibbits uint8_t *p_Reply, 5810aeed3e9SJustin Hibbits uint32_t replyLength, 5820aeed3e9SJustin Hibbits t_Error status); 5830aeed3e9SJustin Hibbits 5840aeed3e9SJustin Hibbits /**************************************************************************//** 5850aeed3e9SJustin Hibbits @Function t_IpcMsgHandler 5860aeed3e9SJustin Hibbits 5870aeed3e9SJustin Hibbits @Description Callback function used as IPC message handler. 5880aeed3e9SJustin Hibbits 5890aeed3e9SJustin Hibbits The IPC service invokes message handlers for each IPC message received. 5900aeed3e9SJustin Hibbits The actual function pointer should be registered by each destination endpoint 5910aeed3e9SJustin Hibbits via the XX_IpcRegisterMsgHandler() routine. 5920aeed3e9SJustin Hibbits 5930aeed3e9SJustin Hibbits User provides this function. Driver invokes it. 5940aeed3e9SJustin Hibbits 5950aeed3e9SJustin Hibbits @Param[in] h_Module - Abstract handle to the message handling module - the same handle as 5960aeed3e9SJustin Hibbits was passed in the XX_IpcRegisterMsgHandler() function; this handle is 5970aeed3e9SJustin Hibbits typically used to point to the internal data structure of the destination 5980aeed3e9SJustin Hibbits endpoint. 5990aeed3e9SJustin Hibbits @Param[in] p_Msg - Pointer to message buffer with data received from peer. 6000aeed3e9SJustin Hibbits @Param[in] msgLength - Length (in bytes) of message data. 6010aeed3e9SJustin Hibbits @Param[in] p_Reply - Pointer to reply buffer, to be filled by the message handler and then sent 6020aeed3e9SJustin Hibbits by the IPC service; 6030aeed3e9SJustin Hibbits The reply buffer is allocated by the IPC service with size equals to the 6040aeed3e9SJustin Hibbits replyLength parameter provided in message handler registration (see 6050aeed3e9SJustin Hibbits XX_IpcRegisterMsgHandler() function); 6060aeed3e9SJustin Hibbits If replyLength was initially specified as zero during message handler registration, 6070aeed3e9SJustin Hibbits the IPC service may set this pointer to NULL and assume that a reply is not needed; 6080aeed3e9SJustin Hibbits The IPC service is also responsible for freeing the reply buffer after the 6090aeed3e9SJustin Hibbits reply has been sent or dismissed. 6100aeed3e9SJustin Hibbits @Param[in,out] p_ReplyLength - Pointer to reply length, which has a dual role in this function: 6110aeed3e9SJustin Hibbits [In] equals the replyLength parameter provided in message handler 6120aeed3e9SJustin Hibbits registration (see XX_IpcRegisterMsgHandler() function), and 6130aeed3e9SJustin Hibbits [Out] should be updated by message handler to the actual reply length; if 6140aeed3e9SJustin Hibbits this value is set to zero, the IPC service must assume that a reply should 6150aeed3e9SJustin Hibbits not be sent; 6160aeed3e9SJustin Hibbits Note: If p_Reply is not NULL, p_ReplyLength must not be NULL as well. 6170aeed3e9SJustin Hibbits 6180aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 6190aeed3e9SJustin Hibbits *//***************************************************************************/ 6200aeed3e9SJustin Hibbits typedef t_Error (t_IpcMsgHandler)(t_Handle h_Module, 6210aeed3e9SJustin Hibbits uint8_t *p_Msg, 6220aeed3e9SJustin Hibbits uint32_t msgLength, 6230aeed3e9SJustin Hibbits uint8_t *p_Reply, 6240aeed3e9SJustin Hibbits uint32_t *p_ReplyLength); 6250aeed3e9SJustin Hibbits 6260aeed3e9SJustin Hibbits /**************************************************************************//** 6270aeed3e9SJustin Hibbits @Function XX_IpcRegisterMsgHandler 6280aeed3e9SJustin Hibbits 6290aeed3e9SJustin Hibbits @Description IPC mailbox registration. 6300aeed3e9SJustin Hibbits 6310aeed3e9SJustin Hibbits This function is used for registering an IPC message handler in the IPC service. 6320aeed3e9SJustin Hibbits This function is called by each destination endpoint to indicate that it is ready 6330aeed3e9SJustin Hibbits to handle incoming messages. The IPC service invokes the message handler upon receiving 6340aeed3e9SJustin Hibbits a message addressed to the specified destination endpoint. 6350aeed3e9SJustin Hibbits 6360aeed3e9SJustin Hibbits @Param[in] addr - The address name string associated with the destination endpoint; 6370aeed3e9SJustin Hibbits This address must be unique across the IPC service domain to ensure 6380aeed3e9SJustin Hibbits correct message routing. 6390aeed3e9SJustin Hibbits @Param[in] f_MsgHandler - Pointer to the message handler callback for processing incoming 6400aeed3e9SJustin Hibbits message; invoked by the IPC service upon receiving a message 6410aeed3e9SJustin Hibbits addressed to the destination endpoint specified by the addr 6420aeed3e9SJustin Hibbits parameter. 6430aeed3e9SJustin Hibbits @Param[in] h_Module - Abstract handle to the message handling module, passed unchanged 6440aeed3e9SJustin Hibbits to f_MsgHandler callback function. 6450aeed3e9SJustin Hibbits @Param[in] replyLength - The maximal data length (in bytes) of any reply that the specified message handler 6460aeed3e9SJustin Hibbits may generate; the IPC service provides the message handler with buffer 6470aeed3e9SJustin Hibbits for reply according to the length specified here (refer also to the description 6480aeed3e9SJustin Hibbits of #t_IpcMsgHandler callback function type); 6490aeed3e9SJustin Hibbits This size shall be zero if the message handler never generates replies. 6500aeed3e9SJustin Hibbits 6510aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 6520aeed3e9SJustin Hibbits *//***************************************************************************/ 6530aeed3e9SJustin Hibbits t_Error XX_IpcRegisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH], 6540aeed3e9SJustin Hibbits t_IpcMsgHandler *f_MsgHandler, 6550aeed3e9SJustin Hibbits t_Handle h_Module, 6560aeed3e9SJustin Hibbits uint32_t replyLength); 6570aeed3e9SJustin Hibbits 6580aeed3e9SJustin Hibbits /**************************************************************************//** 6590aeed3e9SJustin Hibbits @Function XX_IpcUnregisterMsgHandler 6600aeed3e9SJustin Hibbits 6610aeed3e9SJustin Hibbits @Description Release IPC mailbox routine. 6620aeed3e9SJustin Hibbits 6630aeed3e9SJustin Hibbits This function is used for unregistering an IPC message handler from the IPC service. 6640aeed3e9SJustin Hibbits This function is called by each destination endpoint to indicate that it is no longer 6650aeed3e9SJustin Hibbits capable of handling incoming messages. 6660aeed3e9SJustin Hibbits 6670aeed3e9SJustin Hibbits @Param[in] addr - The address name string associated with the destination endpoint; 6680aeed3e9SJustin Hibbits This address is the same as was used when the message handler was 6690aeed3e9SJustin Hibbits registered via XX_IpcRegisterMsgHandler(). 6700aeed3e9SJustin Hibbits 6710aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 6720aeed3e9SJustin Hibbits *//***************************************************************************/ 6730aeed3e9SJustin Hibbits t_Error XX_IpcUnregisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH]); 6740aeed3e9SJustin Hibbits 6750aeed3e9SJustin Hibbits /**************************************************************************//** 6760aeed3e9SJustin Hibbits @Function XX_IpcInitSession 6770aeed3e9SJustin Hibbits 6780aeed3e9SJustin Hibbits @Description This function is used for creating an IPC session between the source endpoint 6790aeed3e9SJustin Hibbits and the destination endpoint. 6800aeed3e9SJustin Hibbits 6810aeed3e9SJustin Hibbits The actual implementation and representation of a session is left for the IPC service. 6820aeed3e9SJustin Hibbits The function returns an abstract handle to the created session. This handle shall be used 6830aeed3e9SJustin Hibbits by the source endpoint in subsequent calls to XX_IpcSendMessage(). 6840aeed3e9SJustin Hibbits The IPC service assumes that before this function is called, no messages are sent from 6850aeed3e9SJustin Hibbits the specified source endpoint to the specified destination endpoint. 6860aeed3e9SJustin Hibbits 6870aeed3e9SJustin Hibbits The IPC service may use a connection-oriented approach or a connectionless approach (or both) 6880aeed3e9SJustin Hibbits as described below. 6890aeed3e9SJustin Hibbits 6900aeed3e9SJustin Hibbits @par Connection-Oriented Approach 6910aeed3e9SJustin Hibbits 6920aeed3e9SJustin Hibbits The IPC service may implement a session in a connection-oriented approach - when this function is called, 6930aeed3e9SJustin Hibbits the IPC service should take the necessary steps to bring up a source-to-destination channel for messages 6940aeed3e9SJustin Hibbits and a destination-to-source channel for replies. The returned handle should represent the internal 6950aeed3e9SJustin Hibbits representation of these channels. 6960aeed3e9SJustin Hibbits 6970aeed3e9SJustin Hibbits @par Connectionless Approach 6980aeed3e9SJustin Hibbits 6990aeed3e9SJustin Hibbits The IPC service may implement a session in a connectionless approach - when this function is called, the 7000aeed3e9SJustin Hibbits IPC service should not perform any particular steps, but it must store the pair of source and destination 7010aeed3e9SJustin Hibbits addresses in some session representation and return it as a handle. When XX_IpcSendMessage() shall be 7020aeed3e9SJustin Hibbits called, the IPC service may use this handle to provide the necessary identifiers for routing the messages 7030aeed3e9SJustin Hibbits through the connectionless medium. 7040aeed3e9SJustin Hibbits 7050aeed3e9SJustin Hibbits @Param[in] destAddr - The address name string associated with the destination endpoint. 7060aeed3e9SJustin Hibbits @Param[in] srcAddr - The address name string associated with the source endpoint. 7070aeed3e9SJustin Hibbits 7080aeed3e9SJustin Hibbits @Return Abstract handle to the initialized session, or NULL on error. 7090aeed3e9SJustin Hibbits *//***************************************************************************/ 7100aeed3e9SJustin Hibbits t_Handle XX_IpcInitSession(char destAddr[XX_IPC_MAX_ADDR_NAME_LENGTH], 7110aeed3e9SJustin Hibbits char srcAddr[XX_IPC_MAX_ADDR_NAME_LENGTH]); 7120aeed3e9SJustin Hibbits 7130aeed3e9SJustin Hibbits /**************************************************************************//** 7140aeed3e9SJustin Hibbits @Function XX_IpcFreeSession 7150aeed3e9SJustin Hibbits 7160aeed3e9SJustin Hibbits @Description This function is used for terminating an existing IPC session between a source endpoint 7170aeed3e9SJustin Hibbits and a destination endpoint. 7180aeed3e9SJustin Hibbits 7190aeed3e9SJustin Hibbits The IPC service assumes that after this function is called, no messages shall be sent from 7200aeed3e9SJustin Hibbits the associated source endpoint to the associated destination endpoint. 7210aeed3e9SJustin Hibbits 7220aeed3e9SJustin Hibbits @Param[in] h_Session - Abstract handle to the IPC session - the same handle as was originally 7230aeed3e9SJustin Hibbits returned by the XX_IpcInitSession() function. 7240aeed3e9SJustin Hibbits 7250aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 7260aeed3e9SJustin Hibbits *//***************************************************************************/ 7270aeed3e9SJustin Hibbits t_Error XX_IpcFreeSession(t_Handle h_Session); 7280aeed3e9SJustin Hibbits 7290aeed3e9SJustin Hibbits /**************************************************************************//** 7300aeed3e9SJustin Hibbits @Function XX_IpcSendMessage 7310aeed3e9SJustin Hibbits 7320aeed3e9SJustin Hibbits @Description IPC message send routine. 7330aeed3e9SJustin Hibbits 7340aeed3e9SJustin Hibbits This function may be used by a source endpoint to send an IPC message to a destination 7350aeed3e9SJustin Hibbits endpoint. The source endpoint cannot send a message to the destination endpoint without 7360aeed3e9SJustin Hibbits first initiating a session with that destination endpoint via XX_IpcInitSession() routine. 7370aeed3e9SJustin Hibbits 7380aeed3e9SJustin Hibbits The source endpoint must provide the buffer pointer and length of the outgoing message. 7390aeed3e9SJustin Hibbits Optionally, it may also provide a buffer for an expected reply. In the latter case, the 7400aeed3e9SJustin Hibbits transaction is not considered complete by the IPC service until the reply has been received. 7410aeed3e9SJustin Hibbits If the source endpoint does not provide a reply buffer, the transaction is considered 7420aeed3e9SJustin Hibbits complete after the message has been sent. The source endpoint must keep the message (and 7430aeed3e9SJustin Hibbits optional reply) buffers valid until the transaction is complete. 7440aeed3e9SJustin Hibbits 7450aeed3e9SJustin Hibbits @par Non-blocking mode 7460aeed3e9SJustin Hibbits 7470aeed3e9SJustin Hibbits The source endpoint may request a non-blocking send by providing a non-NULL pointer to a message 7480aeed3e9SJustin Hibbits completion callback function (f_Completion). Upon completion of the IPC transaction (consisting of a 7490aeed3e9SJustin Hibbits message and an optional reply), the IPC service invokes this callback routine to return the message 7500aeed3e9SJustin Hibbits buffer to the sender and to provide the received reply, if requested. 7510aeed3e9SJustin Hibbits 7520aeed3e9SJustin Hibbits @par Blocking mode 7530aeed3e9SJustin Hibbits 7540aeed3e9SJustin Hibbits The source endpoint may request a blocking send by setting f_Completion to NULL. The function is 7550aeed3e9SJustin Hibbits expected to block until the IPC transaction is complete - either the reply has been received or (if no reply 7560aeed3e9SJustin Hibbits was requested) the message has been sent. 7570aeed3e9SJustin Hibbits 7580aeed3e9SJustin Hibbits @Param[in] h_Session - Abstract handle to the IPC session - the same handle as was originally 7590aeed3e9SJustin Hibbits returned by the XX_IpcInitSession() function. 7600aeed3e9SJustin Hibbits @Param[in] p_Msg - Pointer to message buffer to send. 7610aeed3e9SJustin Hibbits @Param[in] msgLength - Length (in bytes) of actual data in the message buffer. 7620aeed3e9SJustin Hibbits @Param[in] p_Reply - Pointer to reply buffer - if this buffer is not NULL, the IPC service 7630aeed3e9SJustin Hibbits fills this buffer with the received reply data; 7640aeed3e9SJustin Hibbits In blocking mode, the reply data must be valid when the function returns; 7650aeed3e9SJustin Hibbits In non-blocking mode, the reply data is valid when f_Completion is called; 7660aeed3e9SJustin Hibbits If this pointer is NULL, no reply is expected. 7670aeed3e9SJustin Hibbits @Param[in,out] p_ReplyLength - Pointer to reply length, which has a dual role in this function: 7680aeed3e9SJustin Hibbits [In] specifies the maximal length (in bytes) of the reply buffer pointed by 7690aeed3e9SJustin Hibbits p_Reply, and 7700aeed3e9SJustin Hibbits [Out] in non-blocking mode this value is updated by the IPC service to the 7710aeed3e9SJustin Hibbits actual reply length (in bytes). 7720aeed3e9SJustin Hibbits @Param[in] f_Completion - Pointer to a completion callback to be used in non-blocking send mode; 7730aeed3e9SJustin Hibbits The completion callback is invoked by the IPC service upon 7740aeed3e9SJustin Hibbits completion of the IPC transaction (consisting of a message and an optional 7750aeed3e9SJustin Hibbits reply); 7760aeed3e9SJustin Hibbits If this pointer is NULL, the function is expected to block until the IPC 7770aeed3e9SJustin Hibbits transaction is complete. 7780aeed3e9SJustin Hibbits @Param[in] h_Arg - Abstract handle to the sending module; passed unchanged to the f_Completion 7790aeed3e9SJustin Hibbits callback function as the first argument. 7800aeed3e9SJustin Hibbits 7810aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 7820aeed3e9SJustin Hibbits *//***************************************************************************/ 7830aeed3e9SJustin Hibbits t_Error XX_IpcSendMessage(t_Handle h_Session, 7840aeed3e9SJustin Hibbits uint8_t *p_Msg, 7850aeed3e9SJustin Hibbits uint32_t msgLength, 7860aeed3e9SJustin Hibbits uint8_t *p_Reply, 7870aeed3e9SJustin Hibbits uint32_t *p_ReplyLength, 7880aeed3e9SJustin Hibbits t_IpcMsgCompletion *f_Completion, 7890aeed3e9SJustin Hibbits t_Handle h_Arg); 7900aeed3e9SJustin Hibbits 7910aeed3e9SJustin Hibbits 7920aeed3e9SJustin Hibbits /** @} */ /* end of xx_ipc group */ 7930aeed3e9SJustin Hibbits /** @} */ /* end of xx_id group */ 7940aeed3e9SJustin Hibbits 795852ba100SJustin Hibbits 796852ba100SJustin Hibbits void XX_PortalSetInfo(device_t dev); 7970aeed3e9SJustin Hibbits #endif /* __XX_EXT_H */ 798