FreeCalypso > hg > freecalypso-sw
view 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 source
/* * This C module is a reconstruction based on the disassembly of * osx.obj in osx_na7_db.lib from the Leonardo package. */ /* reconstructed set of included headers from COFF symtab: */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "typedefs.h" #include "vsi.h" #include "cust_os.h" int osx_config = 2; int _caller; T_OSX_REGISTER _osx_registry[7]; void int_osx_send_sig(int caller, unsigned long opc, void *signal_ptr, int queue_handle) { T_QMSG Message; int status; TRACE_ASSERT(queue_handle != 0); Message.MsgType = MSG_SIGNAL; Message.Msg.Signal.SigOPC = opc; Message.Msg.Signal.SigBuffer = signal_ptr; Message.Msg.Signal.SigLen = sizeof(xSignalHeaderRec); status = vsi_c_send(caller, queue_handle, &Message FILE_LINE_MACRO); TRACE_ASSERT(status == VSI_OK); } void osx_send_sig(unsigned long opc, void *signal_ptr, T_ENUM_OS_QUEUE queue_type) { int caller, queue_handle; caller = _osx_registry[queue_type].caller; queue_handle = _osx_registry[queue_type].queue_handle; TRACE_ASSERT(queue_handle != 0); int_osx_send_sig(caller, opc, signal_ptr, queue_handle); } void int_osx_free_prim(int caller, xSignalHeaderRec *prim_ptr) { vsi_c_free(caller, (T_VOID_STRUCT **) &prim_ptr FILE_LINE_MACRO); } void int_osx_send_prim(int caller, xSignalHeaderRec *prim_ptr, int queue_handle) { T_QMSG Message; int status; if (osx_config & 1 && prim_ptr->SignalCode == 0x7D) { vsi_c_free(caller, (T_VOID_STRUCT **) &prim_ptr FILE_LINE_MACRO); return; } TRACE_ASSERT(queue_handle != 0); Message.MsgType = MSG_PRIMITIVE; Message.Msg.Primitive.Prim = (T_VOID_STRUCT *) prim_ptr; Message.Msg.Primitive.PrimLen = sizeof(xSignalHeaderRec); status = vsi_c_send(caller, queue_handle, &Message FILE_LINE_MACRO); TRACE_ASSERT(status == VSI_OK); } void osx_send_prim(xSignalHeaderRec *prim_ptr, T_ENUM_OS_QUEUE queue_type) { 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); } }