1a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 2a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * fwDebug.c 3a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 4a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * Copyright(c) 1998 - 2009 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 35a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 36a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/** \file FWDebug.c 37a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 38a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \see FWDebug.h 39a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 40a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 41a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#define __FILE_ID__ FILE_ID_103 42a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "tidef.h" 43a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "fwDebug_api.h" 44a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "osApi.h" 45a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "report.h" 46a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "BusDrv.h" 47a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#include "TwIf.h" 48a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 49a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 50a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 51a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt#define DMA_SIZE_BUF 256 52a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 53a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidttypedef struct 54a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 55a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_HANDLE hOs; 56a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_HANDLE hReport; 57a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_HANDLE hTwif; 58a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 59a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDubCallback fCb; 60a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_HANDLE hCb; 61a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 62a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT8* pReadBuf; 63a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 64a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TTxnStruct tTxn; 65a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT8* pDMABuf; 66a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 67a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt}TFwDebug; 68a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 69a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* Local functions */ 70a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidtstatic void fwDbg_WriteAddrCb (TI_HANDLE hFwDebug,TTxnStruct* pTxn); 71a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidtstatic void fwDbg_ReadAddrCb (TI_HANDLE hFwDebug,TTxnStruct* pTxn); 72a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 73a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 74a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 75a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 76a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Create the FW Debug module 77a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 78a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hOs - Handle to OS 79a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return The created object 80a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 81a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 82a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * This function will allocate memory to FW Debug module. 83a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 84a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 85a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 86a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_HANDLE fwDbg_Create (TI_HANDLE hOs) 87a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 88a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug *pFwDebug = (TFwDebug *)os_memoryAlloc(hOs,sizeof(TFwDebug)); 89a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 90a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (pFwDebug == NULL) 91a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 92a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt WLAN_OS_REPORT (("FATAL ERROR: fwDbg_Create(): Error Creating TFwDebug - Aborting\n")); 93a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return NULL; 94a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 95a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 96a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* reset module object */ 97a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryZero (hOs, pFwDebug, sizeof (TFwDebug)); 98a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->hOs = hOs; 99a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 100a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return pFwDebug; 101a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 102a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 103a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 104a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 105a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Initialize the module 106a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 107a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hFwDebug - Handle to FW Debug 108a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hReport - Handle to report 109a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hTwif - Handle to TWIF 110a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return none 111a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 112a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 113a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 114a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 115a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 116a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 117a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidtvoid fwDbg_Init (TI_HANDLE hFwDebug, 118a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_HANDLE hReport, 119a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_HANDLE hTwif) 120a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 121a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug* pFwDebug = (TFwDebug*)hFwDebug; 122a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->hReport = hReport; 123a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->hTwif = hTwif; 124a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 125a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* Allocate DMA memory for read write transact */ 126a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->pDMABuf = (TI_UINT8*)os_memoryAlloc(pFwDebug->hOs,DMA_SIZE_BUF); 127a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 128a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 129a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 130a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 131a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Destroy the object 132a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 133a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hFwDebug - Handle to FW Debug 134a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return none 135a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 136a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 137a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * Deallocate the object memory 138a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 139a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 140a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 141a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidtvoid fwDbg_Destroy (TI_HANDLE hFwDebug) 142a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 143a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug* pFwDebug = (TFwDebug*)hFwDebug; 144a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 145a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (pFwDebug) 146a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 147a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (pFwDebug->pDMABuf) 148a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 149a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryFree(pFwDebug->hOs,pFwDebug->pDMABuf,DMA_SIZE_BUF); 150a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 151a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryFree(pFwDebug->hOs,pFwDebug,sizeof(pFwDebug)); 152a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 153a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 154a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 155a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 156a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 157a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Write Address to FW 158a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 159a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hFwDebug - Handle to FW Debug 160a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param Address - Absolute HW address 161a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param Length - Length in byte to write 162a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param Buffer - Buffer to copy to FW 163a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param fCb - CB function 164a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hCb - CB Handle 165a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return none 166a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 167a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 168a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * Write buffer to HW must receive length in byte max size 256 bytes 169a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * address must be absolute HW address. 170a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 171a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 172a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 173a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_STATUS fwDbg_WriteAddr (TI_HANDLE hFwDebug, 174a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT32 Address, 175a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT32 Length, 176a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT8* Buffer, 177a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDubCallback fCb, 178a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_HANDLE hCb) 179a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 180a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_STATUS rc; 181a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TTxnStruct *pTxn; 182a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug* pFwDebug = (TFwDebug*)hFwDebug; 183a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 184a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pTxn = &pFwDebug->tTxn; 185a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 186a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* check if length is large than default threshold */ 187a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (Length > DMA_SIZE_BUF) 188a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 189a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTRACE1(pFwDebug->hOs, REPORT_SEVERITY_ERROR, "fwDbg_WriteAddr : Buffer Length too large -- %d",Length); 190a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TXN_STATUS_ERROR; 191a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 192a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 193a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->fCb = fCb; 194a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->hCb = hCb; 195a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* copy the given buffer to DMA buffer */ 196a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryCopy(pFwDebug->hOs,pFwDebug->pDMABuf,Buffer,Length); 197a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* Build the command TxnStruct */ 198a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TXN_PARAM_SET(pTxn, TXN_LOW_PRIORITY, TXN_FUNC_ID_WLAN, TXN_DIRECTION_WRITE, TXN_INC_ADDR) 199a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* Applying a CB in case of an async read */ 200a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt BUILD_TTxnStruct(pTxn, Address, pFwDebug->pDMABuf, Length,(TTxnDoneCb)fwDbg_WriteAddrCb, pFwDebug) 201a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt rc = twIf_Transact(pFwDebug->hTwif,pTxn); 202a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 203a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return rc; 204a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 205a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 206a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 207a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 208a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Read Address to FW 209a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 210a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hFwDebug - Handle to FW Debug 211a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param Address - Absolute HW address 212a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param Length - Length in byte to write 213a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param Buffer - Buffer to copy to FW 214a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param fCb - CB function 215a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hCb - CB Handle 216a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return none 217a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 218a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 219a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * Read from HW, must receive length in byte max size 256 bytes 220a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * address must be absolute HW address. 221a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 222a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 223a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 224a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_STATUS fwDbg_ReadAddr (TI_HANDLE hFwDebug, 225a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT32 Address, 226a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT32 Length, 227a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_UINT8* Buffer, 228a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDubCallback fCb, 229a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_HANDLE hCb) 230a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 231a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TI_STATUS rc; 232a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TTxnStruct *pTxn; 233a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug *pFwDebug = (TFwDebug*)hFwDebug; 234a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pTxn = &pFwDebug->tTxn; 235a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* check if length is large than default threshold */ 236a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (Length > DMA_SIZE_BUF) 237a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 238a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTRACE1(pFwDebug->hOs, REPORT_SEVERITY_ERROR, "fwDbg_ReadAddr : Buffer Length too large -- %d",Length); 239a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return TXN_STATUS_ERROR; 240a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 241a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 242a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->fCb = fCb; 243a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->hCb = hCb; 244a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->pReadBuf = Buffer; 245a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 246a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* Build the command TxnStruct */ 247a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TXN_PARAM_SET(pTxn, TXN_LOW_PRIORITY, TXN_FUNC_ID_WLAN, TXN_DIRECTION_READ, TXN_INC_ADDR) 248a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* Applying a CB in case of an async read */ 249a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt BUILD_TTxnStruct(pTxn, Address, pFwDebug->pDMABuf, Length,(TTxnDoneCb)fwDbg_ReadAddrCb, pFwDebug) 250a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt rc = twIf_Transact(pFwDebug->hTwif,pTxn); 251a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (rc == TXN_STATUS_COMPLETE) 252a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 253a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* copy from DMA buufer to given buffer */ 254a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryCopy(pFwDebug->hOs,pFwDebug->pReadBuf,pFwDebug->pDMABuf,Length); 255a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 256a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return rc; 257a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 258a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 259a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 260a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 261a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Write CB function 262a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 263a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hFwDebug - Handle to FW Debug 264a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param pTxn - pointer ti Transact 265a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return none 266a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 267a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 268a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * This function called from TWIF upon Async Write 269a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 270a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 271a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 272a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidtstatic void fwDbg_WriteAddrCb (TI_HANDLE hFwDebug,TTxnStruct* pTxn) 273a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 274a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug *pFwDebug = (TFwDebug*)hFwDebug; 275a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 276a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (pFwDebug->fCb && pFwDebug->hCb) 277a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 278a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->fCb(pFwDebug->hCb); 279a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 280a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 281a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 282a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 283a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 284a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Read CB function 285a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 286a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hFwDebug - Handle to FW Debug 287a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param pTxn - pointer ti Transact 288a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return none 289a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 290a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 291a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * This function called from TWIF upon Async Read 292a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 293a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 294a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 295a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidtstatic void fwDbg_ReadAddrCb (TI_HANDLE hFwDebug,TTxnStruct* pTxn) 296a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 297a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug *pFwDebug = (TFwDebug*)hFwDebug; 298a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt /* copy from DMA buufer to given buffer */ 299a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt os_memoryCopy(pFwDebug->hOs,pFwDebug->pReadBuf,pFwDebug->pDMABuf,pTxn->aLen[0]); 300a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 301a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt if (pFwDebug->fCb && pFwDebug->hCb) 302a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt { 303a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt pFwDebug->fCb(pFwDebug->hCb); 304a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt } 305a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 306a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 307a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 308a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 309a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Check HW address 310a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 311a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hFwDebug - Handle to FW Debug 312a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return TI_TRUE, TI_FALSE 313a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 314a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 315a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * This function called to check the given address to be a valid memory address. 316a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 317a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 318a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 319a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_BOOL fwDbg_isValidMemoryAddr (TI_HANDLE hFwDebug, TI_UINT32 Address, TI_UINT32 Length) 320a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 321a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug *pFwDebug = (TFwDebug*)hFwDebug; 322a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 323a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return twIf_isValidMemoryAddr(pFwDebug->hTwif, Address, Length); 324a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 325a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 326a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 327a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt/* 328a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \brief Check HW address 329a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 330a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \param hFwDebug - Handle to FW Debug 331a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \return TI_TRUE, TI_FALSE 332a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 333a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \par Description 334a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * This function called to check the given address to be a valid register address. 335a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * 336a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt * \sa 337a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt */ 338a615fb1650af6e111053506f1b764b28a5b4631dDmitry ShmidtTI_BOOL fwDbg_isValidRegAddr (TI_HANDLE hFwDebug, TI_UINT32 Address, TI_UINT32 Length) 339a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt{ 340a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt TFwDebug *pFwDebug = (TFwDebug*)hFwDebug; 341a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 342a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt return twIf_isValidRegAddr(pFwDebug->hTwif, Address, Length); 343a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt} 344a615fb1650af6e111053506f1b764b28a5b4631dDmitry Shmidt 345