diff gsm-fw/gpf/osx/osx.c @ 498:0be71d13b6e7

osx.c: int_osx_receive_prim() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 01 Jul 2014 18:12:50 +0000
parents f11f7cb7c353
children 4d2c0430851a
line wrap: on
line diff
--- a/gsm-fw/gpf/osx/osx.c	Tue Jul 01 13:21:41 2014 +0000
+++ b/gsm-fw/gpf/osx/osx.c	Tue Jul 01 18:12:50 2014 +0000
@@ -73,3 +73,37 @@
 	int_osx_send_prim(_osx_registry[queue_type].caller, prim_ptr,
 			  _osx_registry[queue_type].queue_handle);
 }
+
+xSignalHeaderRec *
+int_osx_receive_prim(int caller, int queue_handle)
+{
+	T_QMSG Message;
+	unsigned opc, len;
+	xSignalHeaderRec *message;
+	int status;
+
+	TRACE_ASSERT(queue_handle != OSX_ERROR);
+	for (;;) {
+		status = vsi_c_await(caller, queue_handle, &Message,
+					0xFFFFFFFF);
+		TRACE_ASSERT(status == VSI_OK);
+		/*
+		 * Disassembly reveals that the original code expects
+		 * the received message to be a primitive, rather than
+		 * a signal or a timeout.  If one of the latter comes
+		 * in, the original code would go haywire.  Hence the
+		 * following TRACE_ASSERT is a FreeCalypso addition.
+		 */
+		TRACE_ASSERT(Message.MsgType == MSG_PRIMITIVE);
+		message = (xSignalHeaderRec *) Message.Msg.Primitive.Prim;
+		opc = message->SignalCode & 0xFFFF;
+		if (opc == 11 && osx_config & 2)
+			len = *(unsigned *)(message + 1);
+		else
+			len = sizeof(xSignalHeaderRec);
+		message->SigP = (DummyStruct *)((char *)message + len);
+		if (opc != 0x8000)
+			return(message);
+		vsi_c_primitive(caller, message);
+	}
+}