changeset 372:47391b5c15ff

os_mem_fl.c: os_MemoryInformation() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 01 Jun 2014 00:09:52 +0000
parents 8df6f38d2f3a
children 5f7d723b9343
files gsm-fw/gpf/osl/os_mem_fl.c
diffstat 1 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_mem_fl.c	Fri May 30 19:50:24 2014 +0000
+++ b/gsm-fw/gpf/osl/os_mem_fl.c	Sun Jun 01 00:09:52 2014 +0000
@@ -22,7 +22,6 @@
 OS_HANDLE os_int_pool_handle;
 
 static USHORT NumOfMemoryPools;
-static USHORT Idx;
 static NU_SEMAPHORE MemSemCB;
 static NU_MEMORY_POOL mem_pool_head;
 
@@ -89,3 +88,49 @@
 		Available, Allocated);
 	return(OS_OK);
 }
+
+static int
+os_GetMemoryPoolEntry(USHORT Index, OS_HANDLE *Handle)
+{
+	static USHORT Idx;
+
+	switch (Index) {
+	case FIRST_ENTRY:
+		Idx = 0;
+		break;
+	case NEXT_ENTRY:
+		Idx++;
+		break;
+	default:
+		Idx = Index;
+	}
+	if (Idx == NumOfMemoryPools)
+		return(OS_ERROR);
+	*Handle = Idx;
+	return(OS_OK);
+}
+
+GLOBAL LONG
+os_MemoryInformation(USHORT Index, char *Buffer)
+{
+	OS_HANDLE Handle;
+	OPTION SuspendType;
+	UNSIGNED Size, Min, Available, Waiting;
+	VOID *pStartAddress;
+	NU_TASK *First;
+	CHAR Name[8];
+
+	if (os_GetMemoryPoolEntry(Index, &Handle) == OS_ERROR)
+		return(OS_ERROR);
+	if (NU_Memory_Pool_Information(MemPoolTable[Handle].pcb, Name,
+					&pStartAddress, &Size, &Min,
+					&Available, &SuspendType, &Waiting,
+					&First)
+			!= NU_SUCCESS)
+		return(OS_ERROR);
+	sprintf(Buffer,
+		"Heapname:%s Addr:%lx Size:%ld Min:%ld Free:%ld Suspend:%d",
+		Name, (UNSIGNED) pStartAddress, Size, Min, Available,
+		SuspendType);
+	return(OS_OK);
+}