changeset 351:fd015570cacc

os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 11 May 2014 20:34:43 +0000
parents 5bc6a8f8b4a8
children 39b5b18e26b2
files gsm-fw/gpf/osl/os_com_fl.c
diffstat 1 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_com_fl.c	Thu May 08 07:55:06 2014 +0000
+++ b/gsm-fw/gpf/osl/os_com_fl.c	Sun May 11 20:34:43 2014 +0000
@@ -142,3 +142,64 @@
 	p++;
 	return(OS_OK);
 }
+
+GLOBAL unsigned char *
+os_FindSuspendingQueue(unsigned int *tcb)
+{
+	USHORT i;
+	SM_SUSPEND *susp, *susp2;
+
+	for (i = 1; i <= MaxCommunications; i++) {
+		if (!ComTable[i].Name[0])
+			continue;
+		if (susp = ComTable[i].FreeSemCB.sm_suspension_list) {
+			if (susp->sm_suspended_task == (NU_TASK*)tcb)
+				return(ComTable[i].FreeSemCB.sm_name + 1);
+			susp = (SM_SUSPEND *) susp->sm_suspend_link.cs_next;
+			for (susp2 = susp; ; ) {
+				if (susp2->sm_suspended_task == (NU_TASK*)tcb)
+					return(ComTable[i].FreeSemCB.sm_name+1);
+				susp2 = (SM_SUSPEND *)
+						susp2->sm_suspend_link.cs_next;
+				if (susp2 == susp)
+					break;
+			}
+		}
+		if (susp = ComTable[i].UsedSemCB.sm_suspension_list) {
+			if (susp->sm_suspended_task == (NU_TASK*)tcb)
+				return(ComTable[i].UsedSemCB.sm_name + 1);
+			susp = (SM_SUSPEND *) susp->sm_suspend_link.cs_next;
+			for (susp2 = susp; ; ) {
+				if (susp2->sm_suspended_task == (NU_TASK*)tcb)
+					return(ComTable[i].UsedSemCB.sm_name+1);
+				susp2 = (SM_SUSPEND *)
+						susp2->sm_suspend_link.cs_next;
+				if (susp2 == susp)
+					break;
+			}
+		}
+	}
+	return(0);
+}
+
+GLOBAL LONG
+os_DestroyQueue(OS_HANDLE TaskHandle, OS_HANDLE ComHandle)
+{
+	STATUS sts;
+
+	sts = NU_Obtain_Semaphore(&ComSemCB, NU_SUSPEND);
+	if (NU_Delete_Semaphore(&ComTable[ComHandle].FreeSemCB) != NU_SUCCESS) {
+return_error:	if (sts == NU_SUCCESS)
+			NU_Release_Semaphore(&ComSemCB);
+		return(OS_ERROR);
+	}
+	if (NU_Delete_Semaphore(&ComTable[ComHandle].UsedSemCB) != NU_SUCCESS)
+		goto return_error;
+	if (os_DeallocateMemory(TaskHandle, ComTable[ComHandle].QueueData)
+			== OS_ERROR)
+		goto return_error;
+	ComTable[ComHandle].Name[0] = 0;
+	if (sts == NU_SUCCESS)
+		NU_Release_Semaphore(&ComSemCB);
+	return(OS_OK);
+}