Fix wifi for public cupcake by bringing forward two patches that got missed:
authorSan Mehat <san@google.com>
Sat, 20 Dec 2008 19:19:26 +0000 (11:19 -0800)
committerSan Mehat <san@google.com>
Sat, 20 Dec 2008 19:32:45 +0000 (11:32 -0800)
- Add kernel pre-alloc support
- Minor cleanups

Signed-off-by: San Mehat <san@google.com>
sta_dk_4_0_4_32/common/src/utils/memMngrEx.c
sta_dk_4_0_4_32/pform/common/inc/osApi.h
sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h
sta_dk_4_0_4_32/pform/linux/src/esta_drv.c
sta_dk_4_0_4_32/pform/linux/src/osmemapi.c

index e399080..954f406 100644 (file)
@@ -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);
index 41696ab..ae3edea 100644 (file)
@@ -150,6 +150,13 @@ os_memoryAlloc(
     UINT32 Size
     );
 
+PVOID
+os_memoryPreAlloc(
+    TI_HANDLE OsContext,
+    int section,
+    UINT32 Size
+    );
+
 PVOID
 os_memoryCAlloc(
     TI_HANDLE OsContext,
index b181124..a1d27c9 100644 (file)
 #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 <linux/platform_device.h>
-#include <mach/msm_wifi.h>
+#include <linux/wifi_tiwlan.h>
 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
index 6cb428a..8999333 100644 (file)
@@ -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 )
 {
index e7e658d..18d5620 100644 (file)
@@ -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()                                 
  ****************************************************************************************