From: San Mehat Date: Sat, 20 Dec 2008 19:19:26 +0000 (-0800) Subject: Fix wifi for public cupcake by bringing forward two patches that got missed: X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40c1cfdc6961ae6dffef24e494bd7e7012a9bac7;p=pandora-wifi.git Fix wifi for public cupcake by bringing forward two patches that got missed: - Add kernel pre-alloc support - Minor cleanups Signed-off-by: San Mehat --- diff --git a/sta_dk_4_0_4_32/common/src/utils/memMngrEx.c b/sta_dk_4_0_4_32/common/src/utils/memMngrEx.c index e399080..954f406 100644 --- a/sta_dk_4_0_4_32/common/src/utils/memMngrEx.c +++ b/sta_dk_4_0_4_32/common/src/utils/memMngrEx.c @@ -170,7 +170,7 @@ TI_HANDLE wlan_memMngrInit(TI_HANDLE hOs) return NULL; } #else - if((pMemMngr->buffersPool[count].dataBufPoolPtr = (UINT8 *)os_memoryAlloc(hOs, + if((pMemMngr->buffersPool[count].dataBufPoolPtr = (UINT8 *)os_memoryPreAlloc(hOs, count, pMemMngr->buffersPool[count].buffersSize * pMemMngr->buffersPool[count].dataBufMaxNumber)) == NULL) { wlan_memMngrDestroy(pMemMngr); diff --git a/sta_dk_4_0_4_32/pform/common/inc/osApi.h b/sta_dk_4_0_4_32/pform/common/inc/osApi.h index 41696ab..ae3edea 100644 --- a/sta_dk_4_0_4_32/pform/common/inc/osApi.h +++ b/sta_dk_4_0_4_32/pform/common/inc/osApi.h @@ -150,6 +150,13 @@ os_memoryAlloc( UINT32 Size ); +PVOID +os_memoryPreAlloc( + TI_HANDLE OsContext, + int section, + UINT32 Size + ); + PVOID os_memoryCAlloc( TI_HANDLE OsContext, diff --git a/sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h b/sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h index b181124..a1d27c9 100644 --- a/sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h +++ b/sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h @@ -71,16 +71,18 @@ #define TIWLAN_DRV_IF_NAME TIWLAN_DRV_NAME"%d" #define TIWLAN_DRV_NAME_WIRELESS_PROTO "IEEE 802.11-DS" +void *wifi_kernel_prealloc(int section, unsigned long size); + #ifdef TIWLAN_MSM7000 #ifdef CONFIG_WIFI_CONTROL_FUNC #include -#include +#include int msm_wifi_power(int on); int msm_wifi_reset(int on); #else extern int trout_wifi_power(int on); -extern void trout_wifi_reset(int on); -extern void trout_wifi_set_carddetect(int val); +extern int trout_wifi_reset(int on); +extern int trout_wifi_set_carddetect(int val); #define msm_wifi_power(a) trout_wifi_power(a) #define msm_wifi_reset(a) trout_wifi_reset(a) #endif diff --git a/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c b/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c index 6cb428a..8999333 100644 --- a/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c +++ b/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c @@ -1828,6 +1828,16 @@ static struct sdio_driver tiwlan_sdio_drv = { .id_table = tiwlan_sdio_ids, }; +void *wifi_kernel_prealloc(int section, unsigned long size) +{ +#ifdef CONFIG_WIFI_CONTROL_FUNC + if( wifi_control_data && wifi_control_data->mem_prealloc ) + return wifi_control_data->mem_prealloc( section, size ); + else +#endif + return NULL; +} + #ifdef CONFIG_WIFI_CONTROL_FUNC static int wifi_probe( struct platform_device *pdev ) { diff --git a/sta_dk_4_0_4_32/pform/linux/src/osmemapi.c b/sta_dk_4_0_4_32/pform/linux/src/osmemapi.c index e7e658d..18d5620 100644 --- a/sta_dk_4_0_4_32/pform/linux/src/osmemapi.c +++ b/sta_dk_4_0_4_32/pform/linux/src/osmemapi.c @@ -137,6 +137,61 @@ os_memoryAlloc( return (PVOID)((char *)blk + sizeof(struct os_mem_block)); } +/**************************************************************************************** + * os_memoryPreFree() + **************************************************************************************** +DESCRIPTION: Frees preallocated by the kernel memory. + +ARGUMENTS: ptr - pointer to memory +*****************************************************************************************/ +void os_memoryPreFree( void *ptr ) +{ +} + +/**************************************************************************************** + * os_memoryPreAlloc() + **************************************************************************************** +DESCRIPTION: Gets system-space memory preallocated by kernel. + +ARGUMENTS: OsContext - our adapter context. + section - section number + Size - Specifies the size, in bytes, to be allocated. + +RETURN: Pointer to the allocated memory. + NULL if there is insufficient memory available. +*****************************************************************************************/ +PVOID +os_memoryPreAlloc( + TI_HANDLE OsContext, + int section, + UINT32 Size + ) +{ + struct os_mem_block *blk; + __u32 total_size = Size + sizeof(struct os_mem_block) + sizeof(__u32); + +#ifdef TI_MEM_ALLOC_TRACE + os_printf("MTT:%s:%d ::os_memoryPreAlloc(0x%p, %lu) : %lu\n",__FUNCTION__, __LINE__,OsContext,Size,total_size); +#endif + if( total_size < Size ) { /* Dm: Security fix */ + return NULL; + } + + blk = (struct os_mem_block *)wifi_kernel_prealloc( section, total_size ); + if( !blk ) { + return os_memoryAlloc(OsContext, Size); + } + blk->f_free = (os_free)os_memoryPreFree; + + os_profile (OsContext, 4, total_size); + + /*list_add(&blk->blk_list, &drv->mem_blocks);*/ + blk->size = Size; + blk->signature = MEM_BLOCK_START; + *(__u32 *)((unsigned char *)blk + total_size - sizeof(__u32)) = MEM_BLOCK_END; + return (PVOID)((char *)blk + sizeof(struct os_mem_block)); +} + /**************************************************************************************** * os_memoryCAlloc() @@ -158,30 +213,28 @@ os_memoryCAlloc( UINT32 Size ) { - PVOID pAllocatedMem; - ULONG MemSize; + PVOID pAllocatedMem; + ULONG MemSize; #ifdef TI_MEM_ALLOC_TRACE - os_printf("MTT:%s:%d ::os_memoryCAlloc(0x%p, %lu, %lu) : %lu\n",__FUNCTION__,__LINE__,OsContext,Number,Size,Number*Size); + os_printf("MTT:%s:%d ::os_memoryCAlloc(0x%p, %lu, %lu) : %lu\n",__FUNCTION__,__LINE__,OsContext,Number,Size,Number*Size); #endif - MemSize = Number * Size; + MemSize = Number * Size; - if( (Number > 0) && (Size >= (0xFFFFFFFFUL / Number)) ) { /* Dm: Security fix */ - return NULL; - } + if( (Number > 0) && (Size >= (0xFFFFFFFFUL / Number)) ) { /* Dm: Security fix */ + return NULL; + } - pAllocatedMem = os_memoryAlloc(OsContext, MemSize); + pAllocatedMem = os_memoryAlloc(OsContext, MemSize); - if(!pAllocatedMem) - return NULL; + if(!pAllocatedMem) + return NULL; - memset(pAllocatedMem,0,MemSize); + memset(pAllocatedMem,0,MemSize); - return pAllocatedMem; + return pAllocatedMem; } - - /**************************************************************************************** * os_memoryFree() ****************************************************************************************