diff gsm-fw/gpf/osl/os_mem_fl.c @ 371:8df6f38d2f3a

os_mem_fl.c: os_PartitionInformation() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 30 May 2014 19:50:24 +0000
parents 37e19cbbbc8d
children 47391b5c15ff
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_mem_fl.c	Fri May 30 08:18:21 2014 +0000
+++ b/gsm-fw/gpf/osl/os_mem_fl.c	Fri May 30 19:50:24 2014 +0000
@@ -23,8 +23,6 @@
 
 static USHORT NumOfMemoryPools;
 static USHORT Idx;
-static T_OS_PART_POOL *part_pool;
-static int grp_hndl;
 static NU_SEMAPHORE MemSemCB;
 static NU_MEMORY_POOL mem_pool_head;
 
@@ -35,3 +33,59 @@
 	os_int_pool_handle = int_pool_handle;
 	return(OS_OK);
 }
+
+static int
+os_GetPartitionPoolEntry(USHORT Index, T_OS_PART_POOL **pool)
+{
+	static T_OS_PART_POOL *part_pool;
+	static int grp_hndl;
+
+	switch (Index) {
+	case FIRST_ENTRY:
+		grp_hndl = 0;
+		*pool = part_pool = PartGrpTable[0].grp_head;
+		return(OS_OK);
+	case NEXT_ENTRY:
+		if (part_pool->next) {
+			*pool = part_pool = part_pool->next;
+			return(OS_OK);
+		}
+		grp_hndl++;
+		if (PartGrpTable[grp_hndl].grp_head) {
+			*pool = part_pool = PartGrpTable[grp_hndl].grp_head;
+			return(OS_OK);
+		} else
+			return(OS_ERROR);
+	default:
+		return(OS_ERROR);
+	}
+}
+
+GLOBAL LONG
+os_PartitionInformation(USHORT Handle, char *Buffer)
+{
+	T_OS_PART_POOL *pool;
+	OPTION SuspendType;
+	UNSIGNED PoolSize;
+	UNSIGNED PartitionSize;
+	UNSIGNED Available;
+	UNSIGNED Waiting;
+	UNSIGNED Allocated;
+	VOID *pStartAddress;
+	NU_TASK *First;
+	CHAR Name[8];
+
+	if (os_GetPartitionPoolEntry(Handle, &pool) == OS_ERROR)
+		return(OS_ERROR);
+	if (NU_Partition_Pool_Information(&pool->pcb, Name, &pStartAddress,
+					  &PoolSize, &PartitionSize, &Available,
+					  &Allocated, &SuspendType, &Waiting,
+					  &First)
+			!= NU_SUCCESS)
+		return(OS_ERROR);
+	sprintf(Buffer,
+		"Name:%s Addr:%lx PoolSize:%ld PartSize:%ld Free:%ld Used:%ld",
+		Name, (UNSIGNED) pStartAddress, PoolSize, PartitionSize,
+		Available, Allocated);
+	return(OS_OK);
+}