changeset 439:c2da9dd01f85

OSL: os_mem_ir.c done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 22 Jun 2014 22:10:03 +0000
parents 0eb7c6389717
children 631d273bb65e
files gsm-fw/gpf/osl/os_mem_ir.c
diffstat 1 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_mem_ir.c	Sun Jun 22 21:07:51 2014 +0000
+++ b/gsm-fw/gpf/osl/os_mem_ir.c	Sun Jun 22 22:10:03 2014 +0000
@@ -59,3 +59,49 @@
 		return(OS_ERROR);
 	return(OS_OK);
 }
+
+GLOBAL LONG
+os_AllocatePartition(OS_HANDLE TaskHandle, T_VOID_STRUCT **Buffer, ULONG Size,
+		     ULONG Suspend, OS_HANDLE GroupHandle)
+{
+	T_OS_PART_POOL *pool, *requested_pool;
+	ULONG nu_suspend;
+	STATUS sts;
+	int ret;
+
+	for (pool = PartGrpTable[GroupHandle].grp_head; pool;
+	     pool = pool->next)
+		if (Size <= pool->size)
+			break;
+	if (!pool)
+		return(OS_ERROR);
+	requested_pool = pool;
+	ret = OS_OK;
+	nu_suspend = NU_NO_SUSPEND;
+try_alloc:
+	sts = NU_Allocate_Partition(&pool->pcb, (VOID **) Buffer, nu_suspend);
+	switch (sts) {
+	case NU_SUCCESS:
+		return(ret);
+	case NU_TIMEOUT:
+	case NU_INVALID_SUSPEND:
+		*Buffer = 0;
+		return(OS_TIMEOUT);
+	case NU_NO_PARTITION:
+		pool = pool->next;
+		if (pool) {
+			ret = OS_ALLOCATED_BIGGER;
+			goto try_alloc;
+		}
+		pool = requested_pool;
+		if (Suspend) {
+			nu_suspend = Suspend;
+			ret = OS_WAITED;
+			goto try_alloc;
+		}
+		return(OS_TIMEOUT);
+	default:
+		*Buffer = 0;
+		return(OS_ERROR);
+	}
+}