FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/gpf/osl/os_com_ir.c @ 951:eb27543ce18e
c139explore: elementary operation commands lcdcmd and lcdpix added
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Wed, 04 Nov 2015 03:03:38 +0000 |
parents | 28a2965df6aa |
children |
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 } |
363
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
60 |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
61 GLOBAL LONG |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
62 os_ReceiveFromQueue(OS_HANDLE TaskHandle, OS_HANDLE ComHandle, |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
63 OS_QDATA *Msg, ULONG Timeout) |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
64 { |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
65 T_QDATA_ELEMENT *pElem; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
66 UNSIGNED c_time; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
67 int ret; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
68 USHORT i; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
69 T_QUEUE *pQueue; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
70 T_OS_COM_TABLE_ENTRY *pTable; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
71 |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
72 pTable = ComTable + ComHandle; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
73 if (!pTable->Name[0]) |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
74 return(OS_ERROR); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
75 pTable->current_msg.type = 0; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
76 ret = ObtainSemaphoreCB(&pTable->UsedSemCB, Timeout, 0); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
77 if (ret == OS_ERROR || ret == OS_TIMEOUT) |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
78 return(ret); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
79 TCT_System_Protect(); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
80 for (i = OS_MAX_PRIORITY; i >= OS_MIN_PRIORITY; i--) { |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
81 pQueue = &pTable->Queue[i - OS_MIN_PRIORITY]; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
82 if (pQueue->pWrite != pQueue->pRead) |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
83 break; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
84 } |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
85 if (i < OS_MIN_PRIORITY) { |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
86 TCT_System_Unprotect(); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
87 ReleaseSemaphoreCB(&pTable->FreeSemCB); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
88 return(OS_ERROR); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
89 } |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
90 bcopy(*pQueue->pRead, Msg, sizeof(OS_QDATA)); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
91 pElem = (T_QDATA_ELEMENT *)*pQueue->pRead++; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
92 pElem->Data.data16 = 0; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
93 pElem->pNext = pTable->pFreeElement; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
94 pTable->pFreeElement = pElem; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
95 if (pQueue->pRead - pQueue->pStart >= pTable->Entries + 1) |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
96 pQueue->pRead = pQueue->pStart; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
97 pTable->current_msg.type = Msg->data16; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
98 pTable->current_msg.opc = Msg->data32; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
99 c_time = NU_Retrieve_Clock(); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
100 pTable->current_msg.time = SYSTEM_TICKS_TO_TIME(c_time); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
101 pTable->current_msg.ptr = Msg->ptr; |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
102 TCT_System_Unprotect(); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
103 ReleaseSemaphoreCB(&pTable->FreeSemCB); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
104 return(OS_OK); |
28a2965df6aa
OSL: os_ReceiveFromQueue() reconstructed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
362
diff
changeset
|
105 } |