1a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 2a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * EvHandler.c 3a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 43bb9a92880f8cda8c242707ad02077f13b009632Dmitry Shmidt * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. 5a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * All rights reserved. 6a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 7a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * Redistribution and use in source and binary forms, with or without 8a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * modification, are permitted provided that the following conditions 9a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * are met: 10a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 11a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * * Redistributions of source code must retain the above copyright 12a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * notice, this list of conditions and the following disclaimer. 13a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * * Redistributions in binary form must reproduce the above copyright 14a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * notice, this list of conditions and the following disclaimer in 15a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * the documentation and/or other materials provided with the 16a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * distribution. 17a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * * Neither the name Texas Instruments nor the names of its 18a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * contributors may be used to endorse or promote products derived 19a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * from this software without specific prior written permission. 20a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 21a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 33a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 34a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#define __FILE_ID__ FILE_ID_50 35a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "IPCKernelApi.h" 36a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "EvHandler.h" 37a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "osApi.h" 38a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "osDebug.h" 39a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 40a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#ifndef _WINDOWS 41a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "windows_types.h" 42a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#else 43a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include <windows.h> 44a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#endif /*_WINDOWS*/ 45a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 46a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#ifdef EV_HANDLER_DEBUG 47a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_HANDLE ghEvHandler; /* for debug, remove later*/ 48a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#endif 49a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 50a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* ************************** Upper Interface **********************************/ 51a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 52a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_HANDLE EvHandler_Create (TI_HANDLE hOs) 53a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 54a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TEvHandlerObj *pEvHandler; 55a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 56a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINT(DBG_INIT_LOUD, (" EvHandlerInit\n")); 57a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler = os_memoryAlloc(hOs,sizeof(TEvHandlerObj)); 583bb9a92880f8cda8c242707ad02077f13b009632Dmitry Shmidt 593bb9a92880f8cda8c242707ad02077f13b009632Dmitry Shmidt if(NULL == pEvHandler) 603bb9a92880f8cda8c242707ad02077f13b009632Dmitry Shmidt { 613bb9a92880f8cda8c242707ad02077f13b009632Dmitry Shmidt PRINT(DBG_INIT_LOUD, ("EvHandler_Create() - Allocation failed! Returning NULL.\n")); 623bb9a92880f8cda8c242707ad02077f13b009632Dmitry Shmidt return NULL; 633bb9a92880f8cda8c242707ad02077f13b009632Dmitry Shmidt } 643bb9a92880f8cda8c242707ad02077f13b009632Dmitry Shmidt 65a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryZero(hOs,pEvHandler,sizeof(TEvHandlerObj)); 66a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 67a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt #ifdef EV_HANDLER_DEBUG 68a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt ghEvHandler= pEvHandler; 69a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_VERY_LOUD, ("EvHandlerInit: ghEvHandler set to %08X\n", ghEvHandler)); 70a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt #endif 71a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 72a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler->hOs = hOs; 73ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt 74a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler->LastUMEventType = 0xFFFFFFFF; 75a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 76a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return (TI_HANDLE) pEvHandler; 77a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 78a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 79a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_UINT32 EvHandlerUnload (TI_HANDLE hEvHandler) 80a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 81a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 82ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt TEvHandlerObj *pEvHandler; 83a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 84a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINT(DBG_INIT_LOUD, (" ev_handler_unLoad\n")); 85a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler = (TEvHandlerObj *)hEvHandler; 86a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 87a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryFree(pEvHandler->hOs,pEvHandler,sizeof(TEvHandlerObj)); 88a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 89ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt return TI_OK; 90a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 91a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 92a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 93a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_UINT32 EvHandlerRegisterEvent(TI_HANDLE hEvHandler, TI_UINT8* pData, TI_UINT32 Length) 94a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 95a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TEvHandlerObj *pEvHandler; 96ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt IPC_EVENT_PARAMS *pEvParams; 97ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt TI_UINT32 ModuleIndex; 98a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 99a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if( (hEvHandler==NULL) || (pData == NULL)){ 100a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINT(DBG_INIT_ERROR, "EvHandler:EvHandlerRegisterEvent Bad Handle passed \n"); 101a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TI_NOK; 102a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 103a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 104a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#ifdef EV_HANDLER_DEBUG 105a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (ghEvHandler != hEvHandler) 106a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 107a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TI_NOK; 108a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 109a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#endif 110a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 111a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler = (TEvHandlerObj *)hEvHandler; 112ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt pEvParams = (IPC_EVENT_PARAMS *)pData; 113a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 114a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_LOUD, (" EvHandlerRegisterEvent EventType = %d \n",pEvParams->uEventType)); 115a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 116ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt /* used to be: if ( sizeof(IPC_EVENT_PARAMS) != Length) 117a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt relaxed size checking (okay if output buffer is larger) */ 118ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt if (sizeof(IPC_EVENT_PARAMS) > Length) 119a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 120a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_ERROR, (" EvHandlerRegisterEvent Error sizeof(IPC_EVENT_PARAMS) != Length," 121a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt "%d != %d \n",sizeof(IPC_EVENT_PARAMS), (int)Length)); 122a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return (TI_UINT32)STATUS_INVALID_PARAMETER; 123a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 124a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 125ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt if (pEvParams->uEventType >= IPC_EVENT_MAX){ 126a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_ERROR, (" EvHandlerRegisterEvent Error - Invalid Event Type = %d \n", 127a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvParams->uEventType)); 128a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return (TI_UINT32)STATUS_INVALID_PARAMETER; 129a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 130a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 131a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt ModuleIndex = 0; 132a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 133ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt while ((ModuleIndex < MAX_REGISTERED_MODULES) && 134ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt (pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID != NULL)) 135a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 136ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt ModuleIndex++; 137a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 138a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 139ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt if (ModuleIndex == MAX_REGISTERED_MODULES) 140a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 141ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt PRINTF(DBG_INIT_WARNING, (" EvHandlerRegisterEvent %d " 142ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt "Registration queue full or event already registered!\n", 143ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt pEvParams->uEventType)); 144ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt return (TI_UINT32)STATUS_INVALID_PARAMETER; 145a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 146a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 147a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryCopy(pEvHandler->hOs,(TI_UINT8*)&pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex], 148a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt (TI_UINT8*)pEvParams,Length); 149a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 150a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvParams->uEventID = (TI_HANDLE)&pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex]; 151a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 152a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID = pEvParams->uEventID; 153a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 154a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINT(DBG_INIT_LOUD, " EvHandlerRegisterEvent Out \n"); 155a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return STATUS_SUCCESS; 156a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 157a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 158a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 159a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 160a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_UINT32 EvHandlerUnRegisterEvent(TI_HANDLE hEvHandler, TI_HANDLE uEventID) 161a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 162a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TEvHandlerObj *pEvHandler; 163ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt IPC_EVENT_PARAMS *pEvParams; 164ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt TI_UINT32 ModuleIndex; 165a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 166ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt#ifdef EV_HANDLER_DEBUG 167ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt if (ghEvHandler != hEvHandler ) 168a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 169a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TI_NOK; 170a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 171ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt#endif 172a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 173ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt if (uEventID == NULL) 174a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 175a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TI_NOK; 176a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 177a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 178a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler = (TEvHandlerObj *)hEvHandler; 179ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt pEvParams = (IPC_EVENT_PARAMS *)uEventID; 180a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 181a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_LOUD, (" EvHandlerUnRegisterEvent EventType = %d \n",pEvParams->uEventType)); 182a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 183a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if( pEvParams->uEventType >= IPC_EVENT_MAX){ 184a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_ERROR, (" EvHandlerRegisterEvent Error Event Type = %d \n", 185a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvParams->uEventType)); 186a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return (TI_UINT32)STATUS_INVALID_PARAMETER; 187a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 188a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 189a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt ModuleIndex = 0; 190a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 191ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt while ((ModuleIndex < MAX_REGISTERED_MODULES) && 192ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt (pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID != pEvParams->uEventID)) 193a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 194ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt ModuleIndex++; 195a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 196a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 197ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt if (ModuleIndex == MAX_REGISTERED_MODULES) 198a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 199ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt PRINTF(DBG_INIT_ERROR, (" EvHandlerUnRegisterEvent %d " 200a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt "Registration queue doesn't hold this event!\n", 201a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvParams->uEventType )); 202ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt return (TI_UINT32)STATUS_INVALID_PARAMETER; 203a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 204a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID = NULL; 205a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 206a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return STATUS_SUCCESS; 207a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 208a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 209a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* ************************** Upper Interface End*********************************/ 210a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 211a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* ************************** Bottom Interface **********************************/ 212a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 213a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_UINT32 EvHandlerSendEvent(TI_HANDLE hEvHandler, TI_UINT32 EvType, TI_UINT8* pData, TI_UINT32 Length) 214a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 215a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TEvHandlerObj *pEvHandler; 216a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt IPC_EV_DATA* pNewEvent; 217a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT32 TailIndex=0; 218a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT32 ModuleIndex=0; 219a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 220a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_LOUD, (" EvHandlerSendEvent %d \n", EvType)); 221a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 222a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if(hEvHandler == NULL){ 223a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINT(DBG_INIT_ERROR, "EvHandlerSendEvent Bad Handle passed \n"); 224a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TI_NOK; 225a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 226a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 227a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#ifdef EV_HANDLER_DEBUG 228a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (ghEvHandler != hEvHandler) 229a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 230a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TI_NOK; 231a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 232a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#endif 233a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 234a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler = (TEvHandlerObj *)hEvHandler; 235a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 236a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TailIndex = pEvHandler->SendEventArray.TailIndex; 237a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 238a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt while ((ModuleIndex < MAX_REGISTERED_MODULES) && (EvType <= IPC_EVENT_MAX)) 239a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 240a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (pEvHandler->RegistrationArray[EvType][ModuleIndex].uEventID != NULL ) 241a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 242a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if(pEvHandler->SendEventArray.Counter == MAX_SEND_EVENTS) 243ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt { 244a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINT(DBG_INIT_ERROR, " EvHandlerSendEvent Array Full u Fool! \n"); 245a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TI_NOK; 246a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 247a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 248a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pNewEvent = &pEvHandler->SendEventArray.Array[TailIndex]; 249a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 250a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* copy the event parameters and data to the events queue*/ 251a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryCopy(pEvHandler->hOs,(TI_UINT8*)&pNewEvent->EvParams, 252a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt (TI_UINT8*)&pEvHandler->RegistrationArray[EvType][ModuleIndex], 253a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt sizeof(IPC_EVENT_PARAMS)); 254a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 255a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryZero(pEvHandler->hOs,(TI_UINT8*)pNewEvent->uBuffer, sizeof(pNewEvent->uBuffer)); 256ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt 257ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt os_memoryCopy(pEvHandler->hOs, 258ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt (TI_UINT8*)pNewEvent->uBuffer, 259ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt (TI_UINT8*)pData, 260ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt Length); 261ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt 262a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pNewEvent->uBufferSize = Length; 263ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt 264a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if(pNewEvent->EvParams.uDeliveryType == DELIVERY_PUSH) 265a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 266ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt PRINTF(DBG_INIT_LOUD, (" EvHandlerSendEvent %d to OS \n", EvType)); 267a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_LOUD, ("EvHandlerSendEvent Matching OS Registered event found at EvType = %d," 268a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt "ModuleIndex = %d \n", EvType, ModuleIndex)); 269a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt IPC_EventSend (pEvHandler->hOs,(TI_UINT8*)pNewEvent,sizeof(IPC_EV_DATA)); 270a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 271a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt else { 272a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 273a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler->LastUMEventType = EvType; 274a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler->SendEventArray.TailIndex = (TailIndex+1) % MAX_SEND_EVENTS; 275a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pEvHandler->SendEventArray.Counter++; 276a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TailIndex = pEvHandler->SendEventArray.TailIndex; 277a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_LOUD, (" EvHandlerSendEvent %d to User Mode \n", EvType)); 278a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt PRINTF(DBG_INIT_LOUD, ("EvHandlerSendEvent Matching User Mode Registered event found at EvType = %d," 279a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt "ModuleIndex = %d \n", EvType, ModuleIndex)); 280a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (pEvHandler->SendEventArray.Counter == 1) 281a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 282a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt IPC_EventSend (pEvHandler->hOs,NULL,0); 283a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 284ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt } 285a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } /* end if*/ 286a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 287ddac9c138c5b4b16b99fb8bc5f0f10418efa1029Dmitry Shmidt ModuleIndex++; 288a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 289a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } /* end of while*/ 290a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 291a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TI_OK; 292a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 293a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 294a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* ************************** Bottom Interface End **********************************/ 295