FreeCalypso > hg > freecalypso-sw
changeset 397:f5b9c6d63718
os_mem_fl.c: os_CreatePartitionPool() done
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 13 Jun 2014 19:44:27 +0000 |
parents | c82d093a2b89 |
children | 2dc9f34e3036 |
files | gsm-fw/gpf/osl/os_mem_fl.c |
diffstat | 1 files changed, 73 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_mem_fl.c Fri Jun 13 00:55:36 2014 +0000 +++ b/gsm-fw/gpf/osl/os_mem_fl.c Fri Jun 13 19:44:27 2014 +0000 @@ -293,3 +293,76 @@ } } } + +GLOBAL LONG +os_CreatePartitionPool(OS_HANDLE TaskHandle, char *GroupName, void *Addr, + USHORT Num, ULONG Size, OS_HANDLE *GroupHandle) +{ + STATUS sts; + T_OS_PART_POOL *part_group_head, *opool, *npool; + USHORT part_group; + USHORT i, j; + char PoolName[8], *cp; + + sts = NU_Obtain_Semaphore(&MemSemCB, NU_SUSPEND); + j = 0; + part_group = 0; + part_group_head = 0; + for (i = 0; i <= MaxPoolGroups; i++) { + if (!PartGrpTable[i].grp_head || !PartGrpTable[i].name[0]) { + part_group = i; + break; + } + if (!strncmp(GroupName, PartGrpTable[i].name, + RESOURCE_NAMELEN - 1)) { + part_group_head = PartGrpTable[i].grp_head; + part_group = i; + opool = part_group_head; + j++; + while (opool->next) { + opool = opool->next; + j++; + } + break; + } + } + if (part_group > MaxPoolGroups) { +release_sem_return_err: + if (sts == NU_SUCCESS) + NU_Release_Semaphore(&MemSemCB); + return(OS_ERROR); + } + if (!part_group_head) { + strncpy(PartGrpTable[part_group].name, GroupName, + RESOURCE_NAMELEN); + PartGrpTable[part_group].name[RESOURCE_NAMELEN-1] = 0; + } + if (os_AllocateMemory(OS_NOTASK, (T_VOID_STRUCT **) &npool, + sizeof(T_OS_PART_POOL), OS_NO_SUSPEND, + os_ext_pool_handle) != OS_OK) + goto release_sem_return_err; + sprintf(PoolName, "POOL%1d%1d", part_group + 1, j); + Size &= ~3; + npool->pool_mem = Addr; + if (NU_Create_Partition_Pool(&npool->pcb, PoolName, npool->pool_mem, + POOL_SIZE(Num, Size), Size + 4, NU_FIFO) + != NU_SUCCESS) + goto release_sem_return_err; + if (!part_group_head) + PartGrpTable[part_group].grp_head = npool; + else + opool->next = npool; + npool->size = Size; + npool->next = 0; + *GroupHandle = part_group; + cp = (char *) npool->pool_mem; + if (PoolBorder[part_group].Start >= cp) + PoolBorder[part_group].Start = cp; + cp += POOL_SIZE(Num, Size); + if (PoolBorder[part_group].End < cp) + PoolBorder[part_group].End = cp; + os_InitPartitionCheck(npool); + if (sts == NU_SUCCESS) + NU_Release_Semaphore(&MemSemCB); + return(OS_OK); +}