annotate gsm-fw/gpf/osl/os_com_ir.c @ 362:03d034db09fa

OSL: os_SendToQueue() reconstructed
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 28 May 2014 19:54:10 +0000
parents 4a92b7261e23
children 28a2965df6aa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
355
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module is a reconstruction based on the disassembly of
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * os_com.obj in frame_na7_db_ir.lib from the Leonardo package.
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 /* set of included headers from COFF symtab: */
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "gpfconf.h" /* FreeCalypso addition */
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "../../nucleus/nucleus.h"
362
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
11 #include "../../nucleus/tc_extr.h" /* not seen in original, but needed */
355
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "typedefs.h"
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "os.h"
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "gdi.h"
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "os_types.h"
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 #include "os_glob.h"
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 extern T_OS_COM_TABLE_ENTRY ComTable[];
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 extern unsigned os_tick_to_time_multiplier;
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 extern int ObtainSemaphoreCB(NU_SEMAPHORE *SemCB, ULONG Timeout,
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 USHORT wait_check);
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 extern int ReleaseSemaphoreCB(NU_SEMAPHORE *SemCB);
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 GLOBAL LONG
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 os_SendToQueue(OS_HANDLE TaskHandle, OS_HANDLE ComHandle, USHORT Priority,
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 ULONG Suspend, OS_QDATA *Msg)
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 {
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 T_OS_COM_TABLE_ENTRY *pTable;
362
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
30 T_QDATA_ELEMENT *elem;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
31 T_QUEUE *queue;
355
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 int ret;
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 NU_SEMAPHORE *CBPtr;
362
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
34 USHORT watmark;
355
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35
362
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
36 if (ComHandle <= 0 || ComHandle > MaxCommunications)
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
37 return(OS_INVALID_QUEUE);
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
38 pTable = ComTable + ComHandle;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
39 if (!pTable->Name[0])
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
40 return(OS_INVALID_QUEUE);
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
41 CBPtr = &pTable->FreeSemCB;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
42 ret = ObtainSemaphoreCB(CBPtr, Suspend, 1);
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
43 if (ret == OS_ERROR || ret == OS_TIMEOUT)
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
44 return(ret);
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
45 TCT_System_Protect();
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
46 elem = pTable->pFreeElement;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
47 pTable->pFreeElement = elem->pNext;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
48 bcopy(Msg, &elem->Data, sizeof(OS_QDATA));
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
49 queue = &pTable->Queue[Priority - OS_MIN_PRIORITY];
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
50 *queue->pWrite++ = &elem->Data;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
51 if (queue->pWrite - queue->pStart >= pTable->Entries + 1)
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
52 queue->pWrite = queue->pStart;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
53 watmark = pTable->Entries - CBPtr->sm_semaphore_count;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
54 if (pTable->MaxUsed < watmark)
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
55 pTable->MaxUsed = watmark;
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
56 TCT_System_Unprotect();
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
57 ReleaseSemaphoreCB(&pTable->UsedSemCB);
03d034db09fa OSL: os_SendToQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 355
diff changeset
58 return(ret);
355
4a92b7261e23 OSL reconstruction: os_com_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 }