FreeCalypso > hg > freecalypso-sw
changeset 399:d26a9e3de626
OSL: os_mem_fl.c done
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 15 Jun 2014 00:47:06 +0000 |
parents | 2dc9f34e3036 |
children | f027c6fbe37e |
files | gsm-fw/gpf/osl/os_mem_fl.c |
diffstat | 1 files changed, 31 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_mem_fl.c Fri Jun 13 22:12:05 2014 +0000 +++ b/gsm-fw/gpf/osl/os_mem_fl.c Sun Jun 15 00:47:06 2014 +0000 @@ -386,8 +386,37 @@ ULONG PoolSize, OS_HANDLE *PoolHandle) { STATUS sts; + USHORT i; sts = NU_Obtain_Semaphore(&MemSemCB, NU_SUSPEND); - - + for (i = 0; i < NumOfMemoryPools; i++) + if (!strncmp(Name, MemPoolTable[i].name, RESOURCE_NAMELEN-1)) { + *PoolHandle = i; + if (sts == NU_SUCCESS) + NU_Release_Semaphore(&MemSemCB); + return(OS_OK); + } + if (i >= MaxMemoryPools) { +release_sem_return_err: + if (sts == NU_SUCCESS) + NU_Release_Semaphore(&MemSemCB); + return(OS_ERROR); + } + if (i) { + if (os_AllocateMemory(OS_NOTASK, + (T_VOID_STRUCT **) &MemPoolTable[i].pcb, + sizeof(NU_MEMORY_POOL), OS_NO_SUSPEND, + os_ext_pool_handle) != OS_OK) + goto release_sem_return_err; + } + if (NU_Create_Memory_Pool(MemPoolTable[i].pcb, Name, Addr, PoolSize, + 4, NU_FIFO) != NU_SUCCESS) + goto release_sem_return_err; + strncpy(MemPoolTable[i].name, Name, RESOURCE_NAMELEN); + MemPoolTable[i].name[RESOURCE_NAMELEN-1] = 0; + *PoolHandle = i; + NumOfMemoryPools++; + if (sts == NU_SUCCESS) + NU_Release_Semaphore(&MemSemCB); + return(OS_OK); }