annotate gsm-fw/gpf/osx/osx.c @ 500:5293cac7f423

osx.c: osx_free_prim() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 01 Jul 2014 18:24:00 +0000
parents 4d2c0430851a
children da8248e23aca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
491
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module is a reconstruction based on the disassembly of
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * osx.obj in osx_na7_db.lib from the Leonardo package.
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 /* reconstructed set of included headers from COFF symtab: */
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdlib.h>
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "typedefs.h"
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "vsi.h"
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "cust_os.h"
886cd11bc45f OSX reconstruction started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
492
517cde3e238e osx.c: global data done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 491
diff changeset
14 int osx_config = 2;
517cde3e238e osx.c: global data done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 491
diff changeset
15 int _caller;
517cde3e238e osx.c: global data done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 491
diff changeset
16 T_OSX_REGISTER _osx_registry[7];
493
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
17
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
18 void
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
19 int_osx_send_sig(int caller, unsigned long opc, void *signal_ptr,
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
20 int queue_handle)
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
21 {
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
22 T_QMSG Message;
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
23 int status;
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
24
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
25 TRACE_ASSERT(queue_handle != 0);
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
26 Message.MsgType = MSG_SIGNAL;
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
27 Message.Msg.Signal.SigOPC = opc;
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
28 Message.Msg.Signal.SigBuffer = signal_ptr;
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
29 Message.Msg.Signal.SigLen = sizeof(xSignalHeaderRec);
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
30 status = vsi_c_send(caller, queue_handle, &Message FILE_LINE_MACRO);
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
31 TRACE_ASSERT(status == VSI_OK);
4775ba17ba05 osx.c: int_osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 492
diff changeset
32 }
494
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
33
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
34 void
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
35 osx_send_sig(unsigned long opc, void *signal_ptr, T_ENUM_OS_QUEUE queue_type)
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
36 {
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
37 int caller, queue_handle;
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
38
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
39 caller = _osx_registry[queue_type].caller;
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
40 queue_handle = _osx_registry[queue_type].queue_handle;
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
41 TRACE_ASSERT(queue_handle != 0);
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
42 int_osx_send_sig(caller, opc, signal_ptr, queue_handle);
a8799459110c osx.c: osx_send_sig() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 493
diff changeset
43 }
495
34303faf4620 osx.c: int_osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 494
diff changeset
44
34303faf4620 osx.c: int_osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 494
diff changeset
45 void
34303faf4620 osx.c: int_osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 494
diff changeset
46 int_osx_free_prim(int caller, xSignalHeaderRec *prim_ptr)
34303faf4620 osx.c: int_osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 494
diff changeset
47 {
34303faf4620 osx.c: int_osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 494
diff changeset
48 vsi_c_free(caller, (T_VOID_STRUCT **) &prim_ptr FILE_LINE_MACRO);
34303faf4620 osx.c: int_osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 494
diff changeset
49 }
496
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
50
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
51 void
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
52 int_osx_send_prim(int caller, xSignalHeaderRec *prim_ptr, int queue_handle)
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
53 {
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
54 T_QMSG Message;
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
55 int status;
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
56
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
57 if (osx_config & 1 && prim_ptr->SignalCode == 0x7D) {
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
58 vsi_c_free(caller, (T_VOID_STRUCT **) &prim_ptr
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
59 FILE_LINE_MACRO);
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
60 return;
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
61 }
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
62 TRACE_ASSERT(queue_handle != 0);
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
63 Message.MsgType = MSG_PRIMITIVE;
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
64 Message.Msg.Primitive.Prim = (T_VOID_STRUCT *) prim_ptr;
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
65 Message.Msg.Primitive.PrimLen = sizeof(xSignalHeaderRec);
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
66 status = vsi_c_send(caller, queue_handle, &Message FILE_LINE_MACRO);
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
67 TRACE_ASSERT(status == VSI_OK);
2c16b554d142 osx.c: int_osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 495
diff changeset
68 }
497
f11f7cb7c353 osx.c: osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 496
diff changeset
69
f11f7cb7c353 osx.c: osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 496
diff changeset
70 void
f11f7cb7c353 osx.c: osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 496
diff changeset
71 osx_send_prim(xSignalHeaderRec *prim_ptr, T_ENUM_OS_QUEUE queue_type)
f11f7cb7c353 osx.c: osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 496
diff changeset
72 {
f11f7cb7c353 osx.c: osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 496
diff changeset
73 int_osx_send_prim(_osx_registry[queue_type].caller, prim_ptr,
f11f7cb7c353 osx.c: osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 496
diff changeset
74 _osx_registry[queue_type].queue_handle);
f11f7cb7c353 osx.c: osx_send_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 496
diff changeset
75 }
498
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
76
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
77 xSignalHeaderRec *
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
78 int_osx_receive_prim(int caller, int queue_handle)
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
79 {
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
80 T_QMSG Message;
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
81 unsigned opc, len;
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
82 xSignalHeaderRec *message;
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
83 int status;
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
84
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
85 TRACE_ASSERT(queue_handle != OSX_ERROR);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
86 for (;;) {
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
87 status = vsi_c_await(caller, queue_handle, &Message,
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
88 0xFFFFFFFF);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
89 TRACE_ASSERT(status == VSI_OK);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
90 /*
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
91 * Disassembly reveals that the original code expects
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
92 * the received message to be a primitive, rather than
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
93 * a signal or a timeout. If one of the latter comes
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
94 * in, the original code would go haywire. Hence the
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
95 * following TRACE_ASSERT is a FreeCalypso addition.
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
96 */
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
97 TRACE_ASSERT(Message.MsgType == MSG_PRIMITIVE);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
98 message = (xSignalHeaderRec *) Message.Msg.Primitive.Prim;
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
99 opc = message->SignalCode & 0xFFFF;
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
100 if (opc == 11 && osx_config & 2)
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
101 len = *(unsigned *)(message + 1);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
102 else
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
103 len = sizeof(xSignalHeaderRec);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
104 message->SigP = (DummyStruct *)((char *)message + len);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
105 if (opc != 0x8000)
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
106 return(message);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
107 vsi_c_primitive(caller, message);
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
108 }
0be71d13b6e7 osx.c: int_osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 497
diff changeset
109 }
499
4d2c0430851a osx.c: osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 498
diff changeset
110
4d2c0430851a osx.c: osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 498
diff changeset
111 xSignalHeaderRec *
4d2c0430851a osx.c: osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 498
diff changeset
112 osx_receive_prim(T_ENUM_OS_QUEUE queue_type)
4d2c0430851a osx.c: osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 498
diff changeset
113 {
4d2c0430851a osx.c: osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 498
diff changeset
114 return int_osx_receive_prim(_osx_registry[queue_type].caller,
4d2c0430851a osx.c: osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 498
diff changeset
115 _osx_registry[queue_type].queue_handle);
4d2c0430851a osx.c: osx_receive_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 498
diff changeset
116 }
500
5293cac7f423 osx.c: osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 499
diff changeset
117
5293cac7f423 osx.c: osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 499
diff changeset
118 void
5293cac7f423 osx.c: osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 499
diff changeset
119 osx_free_prim(xSignalHeaderRec *prim_ptr)
5293cac7f423 osx.c: osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 499
diff changeset
120 {
5293cac7f423 osx.c: osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 499
diff changeset
121 vsi_c_free(_caller, (T_VOID_STRUCT **) &prim_ptr FILE_LINE_MACRO);
5293cac7f423 osx.c: osx_free_prim() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 499
diff changeset
122 }