annotate gsm-fw/gpf/osl/os_com_fl.c @ 567:528fa901ae79

L1: l1_pwmgr.c compiles with stripped-down version of l1_pwmgr.h
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 08 Aug 2014 07:35:35 +0000
parents 658b141a1600
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
349
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module is a reconstruction based on the disassembly of
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * os_com.obj in frame_na7_db_fl.lib from the Leonardo package.
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 /* set of included headers from COFF symtab: */
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "gpfconf.h" /* FreeCalypso addition */
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "../../nucleus/nucleus.h"
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "typedefs.h"
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "os.h"
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "gdi.h"
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "os_types.h"
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "os_glob.h"
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 extern T_OS_COM_TABLE_ENTRY ComTable[];
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 static NU_SEMAPHORE ComSemCB;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 static int
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 os_GetQueueEntry(USHORT Index, OS_HANDLE *Handle)
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 {
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 static USHORT Idx;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 if (Index == FIRST_ENTRY)
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 Idx = 0;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 if (Index == FIRST_ENTRY || Index == NEXT_ENTRY) {
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 while (++Idx <= MaxCommunications && !ComTable[Idx].Name[0])
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 ;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 } else
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 Idx = Index;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 if (Idx <= MaxCommunications && ComTable[Idx].Name[0]) {
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 *Handle = Idx;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 return(0);
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 } else
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 return(-1);
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 }
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 GLOBAL LONG
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 os_QueueInformation(USHORT Index, char *Buffer)
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 {
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 OS_HANDLE Handle;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 T_OS_COM_TABLE_ENTRY *ent;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 UNSIGNED Used;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 OPTION SuspendType;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 UNSIGNED TasksWaiting;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 NU_TASK *First;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 CHAR Name[NU_MAX_NAME];
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 if (os_GetQueueEntry(Index, &Handle) < 0)
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 return(OS_ERROR);
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 ent = ComTable + Handle;
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 if (NU_Semaphore_Information(&ent->UsedSemCB, Name, &Used, &SuspendType,
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 &TasksWaiting, &First) != NU_SUCCESS)
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 return(OS_ERROR);
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 sprintf(Buffer, "Name:%s Startadr:%lx Entries:%d Used:%ld MaxUsed:%d",
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 ent->Name, (ULONG)ent->pQueueMemory, ent->Entries, (LONG)Used,
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 ent->MaxUsed);
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 return(OS_OK);
a163da322bc5 OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 }
350
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
62
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
63 GLOBAL LONG
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
64 os_OpenQueue(OS_HANDLE TaskHandle, char *Name, OS_HANDLE *ComHandle)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
65 {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
66 USHORT i;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
67
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
68 if (!Name)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
69 return(OS_ERROR);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
70 for (i = 1; i <= MaxCommunications; i++)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
71 if (ComTable[i].Name[0] &&
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
72 !strncmp(ComTable[i].Name, Name, RESOURCE_NAMELEN - 1)) {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
73 *ComHandle = i;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
74 return(OS_OK);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
75 }
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
76 return(OS_ERROR);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
77 }
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
78
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
79 GLOBAL LONG
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
80 os_GetQueueState(OS_HANDLE Caller, OS_HANDLE Handle, ULONG *Used, ULONG *Free)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
81 {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
82 if (ComTable[Handle].Name[0]) {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
83 *Used = ComTable[Handle].UsedSemCB.sm_semaphore_count;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
84 *Free = ComTable[Handle].FreeSemCB.sm_semaphore_count;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
85 return(OS_OK);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
86 } else
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
87 return(OS_ERROR);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
88 }
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
89
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
90 GLOBAL LONG
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
91 os_GetQueueName(OS_HANDLE Caller, OS_HANDLE ComHandle, char *Name)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
92 {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
93 if (ComHandle > MaxCommunications)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
94 return(OS_ERROR);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
95 if (!ComTable[ComHandle].Name[0])
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
96 return(OS_ERROR);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
97 strcpy(Name, ComTable[ComHandle].Name);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
98 return(OS_OK);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
99 }
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
100
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
101 GLOBAL LONG
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
102 os_GetQueueHandle(OS_HANDLE Caller, char *Name, OS_HANDLE *ComHandle)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
103 {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
104 USHORT i;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
105
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
106 for (i = 1; i <= MaxCommunications; i++)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
107 if (ComTable[i].Name[0] &&
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
108 !strncmp(Name, ComTable[i].Name, RESOURCE_NAMELEN - 1)) {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
109 *ComHandle = i;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
110 return(OS_OK);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
111 }
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
112 return(OS_ERROR);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
113 }
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
114
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
115 GLOBAL LONG
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
116 os_GetQueueData(OS_HANDLE Caller, OS_HANDLE Handle, USHORT Index, USHORT *Type,
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
117 ULONG *opc, ULONG *ptr, ULONG *time)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
118 {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
119 static USHORT entry;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
120 static T_QDATA_ELEMENT *p;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
121
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
122 if (!ComTable[Handle].Name[0])
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
123 return(OS_ERROR);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
124 if (Index == FIRST_ENTRY) {
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
125 *Type = ComTable[Handle].current_msg.type;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
126 *opc = ComTable[Handle].current_msg.opc;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
127 *time = ComTable[Handle].current_msg.time;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
128 *ptr = (ULONG) ComTable[Handle].current_msg.ptr;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
129 p = ComTable[Handle].pQueueMemory;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
130 entry = 0;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
131 return(OS_OK);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
132 }
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
133 if (entry >= ComTable[Handle].Entries)
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
134 return(OS_ERROR);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
135 entry++;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
136 *Type = p->Data.data16;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
137 *ptr = (ULONG) p->Data.ptr;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
138 *opc = p->Data.data32;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
139 *time = p->Data.time;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
140 p++;
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
141 return(OS_OK);
5bc6a8f8b4a8 OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 349
diff changeset
142 }
351
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
143
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
144 GLOBAL unsigned char *
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
145 os_FindSuspendingQueue(unsigned int *tcb)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
146 {
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
147 USHORT i;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
148 SM_SUSPEND *susp, *susp2;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
149
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
150 for (i = 1; i <= MaxCommunications; i++) {
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
151 if (!ComTable[i].Name[0])
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
152 continue;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
153 if (susp = ComTable[i].FreeSemCB.sm_suspension_list) {
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
154 if (susp->sm_suspended_task == (NU_TASK*)tcb)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
155 return(ComTable[i].FreeSemCB.sm_name + 1);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
156 susp = (SM_SUSPEND *) susp->sm_suspend_link.cs_next;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
157 for (susp2 = susp; ; ) {
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
158 if (susp2->sm_suspended_task == (NU_TASK*)tcb)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
159 return(ComTable[i].FreeSemCB.sm_name+1);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
160 susp2 = (SM_SUSPEND *)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
161 susp2->sm_suspend_link.cs_next;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
162 if (susp2 == susp)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
163 break;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
164 }
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
165 }
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
166 if (susp = ComTable[i].UsedSemCB.sm_suspension_list) {
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
167 if (susp->sm_suspended_task == (NU_TASK*)tcb)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
168 return(ComTable[i].UsedSemCB.sm_name + 1);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
169 susp = (SM_SUSPEND *) susp->sm_suspend_link.cs_next;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
170 for (susp2 = susp; ; ) {
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
171 if (susp2->sm_suspended_task == (NU_TASK*)tcb)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
172 return(ComTable[i].UsedSemCB.sm_name+1);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
173 susp2 = (SM_SUSPEND *)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
174 susp2->sm_suspend_link.cs_next;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
175 if (susp2 == susp)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
176 break;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
177 }
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
178 }
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
179 }
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
180 return(0);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
181 }
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
182
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
183 GLOBAL LONG
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
184 os_DestroyQueue(OS_HANDLE TaskHandle, OS_HANDLE ComHandle)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
185 {
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
186 STATUS sts;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
187
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
188 sts = NU_Obtain_Semaphore(&ComSemCB, NU_SUSPEND);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
189 if (NU_Delete_Semaphore(&ComTable[ComHandle].FreeSemCB) != NU_SUCCESS) {
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
190 return_error: if (sts == NU_SUCCESS)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
191 NU_Release_Semaphore(&ComSemCB);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
192 return(OS_ERROR);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
193 }
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
194 if (NU_Delete_Semaphore(&ComTable[ComHandle].UsedSemCB) != NU_SUCCESS)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
195 goto return_error;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
196 if (os_DeallocateMemory(TaskHandle, ComTable[ComHandle].QueueData)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
197 == OS_ERROR)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
198 goto return_error;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
199 ComTable[ComHandle].Name[0] = 0;
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
200 if (sts == NU_SUCCESS)
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
201 NU_Release_Semaphore(&ComSemCB);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
202 return(OS_OK);
fd015570cacc os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 350
diff changeset
203 }
352
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
204
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
205 static short
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
206 InitQueueMemory(OS_HANDLE TaskHandle, OS_HANDLE ComHandle, USHORT Entries,
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
207 OS_HANDLE MemPoolHandle)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
208 {
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
209 T_QDATA_ELEMENT *pElem;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
210 OS_QDATA **ptrs;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
211 USHORT i;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
212
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
213 if (os_AllocateMemory(TaskHandle, &ComTable[ComHandle].QueueData,
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
214 sizeof(T_QDATA_ELEMENT) * Entries +
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
215 sizeof(OS_QDATA *) * (Entries + 1)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
216 * OS_MAX_PRIORITY,
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
217 0, MemPoolHandle) == OS_TIMEOUT)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
218 return(OS_ERROR);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
219 pElem = (T_QDATA_ELEMENT *) ComTable[ComHandle].QueueData;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
220 ComTable[ComHandle].pQueueMemory = pElem;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
221 ComTable[ComHandle].pFreeElement = pElem;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
222 for (i = 0; i < Entries; i++) {
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
223 if (i < Entries - 1)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
224 pElem->pNext = pElem + 1;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
225 else
473
658b141a1600 os_com_fl.c: small buglet in the reconstruction
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 354
diff changeset
226 pElem->pNext = 0;
352
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
227 pElem++;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
228 }
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
229 ptrs = (OS_QDATA **) pElem;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
230 for (i = 0; i < OS_MAX_PRIORITY; i++) {
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
231 ComTable[ComHandle].Queue[i].pStart = ptrs;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
232 ComTable[ComHandle].Queue[i].pRead = ptrs;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
233 ComTable[ComHandle].Queue[i].pWrite = ptrs;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
234 ptrs += Entries + 1;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
235 }
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
236 return(OS_OK);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
237 }
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
238
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
239 GLOBAL LONG
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
240 os_CreateQueue(OS_HANDLE TaskHandle, OS_HANDLE ComHandle, char *Name,
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
241 USHORT Entries, OS_HANDLE *ActHandle, OS_HANDLE MemPoolHandle)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
242 {
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
243 STATUS sts;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
244 OS_HANDLE i;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
245 char Buffer[RESOURCE_NAMELEN + 1];
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
246
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
247 if (os_OpenQueue(TaskHandle, Name, ActHandle) == OS_OK)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
248 return(OS_ERROR);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
249 if (!Entries)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
250 return(OS_ERROR);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
251 sts = NU_Obtain_Semaphore(&ComSemCB, NU_SUSPEND);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
252 if (!ComHandle) {
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
253 for (i = 1; i <= MaxCommunications; i++)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
254 if (!ComTable[i].Name[0])
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
255 goto good_slot;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
256 release_sem_error:
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
257 if (sts == NU_SUCCESS)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
258 NU_Release_Semaphore(&ComSemCB);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
259 return(OS_ERROR);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
260 } else {
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
261 i = ComHandle;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
262 if (i > MaxCommunications)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
263 goto release_sem_error;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
264 if (ComTable[i].Name[0])
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
265 goto release_sem_error;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
266 }
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
267 good_slot:
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
268 if (InitQueueMemory(TaskHandle, i, Entries, MemPoolHandle) == OS_ERROR)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
269 goto release_sem_error;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
270 strncpy(Buffer + 1, Name, RESOURCE_NAMELEN - 1);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
271 Buffer[RESOURCE_NAMELEN] = 0;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
272 Buffer[0] = 'U';
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
273 if (NU_Create_Semaphore(&ComTable[i].UsedSemCB, Buffer, 0, NU_PRIORITY)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
274 != NU_SUCCESS)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
275 goto release_sem_error;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
276 Buffer[0] = 'F';
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
277 if (NU_Create_Semaphore(&ComTable[i].FreeSemCB, Buffer, Entries,
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
278 NU_PRIORITY) != NU_SUCCESS)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
279 goto release_sem_error;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
280 strncpy(ComTable[i].Name, Name, RESOURCE_NAMELEN);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
281 ComTable[i].Name[RESOURCE_NAMELEN-1] = 0;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
282 *ActHandle = i;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
283 ComTable[i].Entries = Entries;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
284 ComTable[i].MaxUsed = 0;
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
285 if (sts == NU_SUCCESS)
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
286 NU_Release_Semaphore(&ComSemCB);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
287 return(OS_OK);
39b5b18e26b2 os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 351
diff changeset
288 }
353
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
289
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
290 GLOBAL LONG
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
291 os_ComInit(void)
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
292 {
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
293 USHORT i;
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
294
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
295 if (NU_Create_Semaphore(&ComSemCB, "COMSEM", 1, NU_PRIORITY)
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
296 != NU_SUCCESS)
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
297 return(OS_ERROR);
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
298 for (i = 1; i <= MaxCommunications; i++)
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
299 bzero(&ComTable[i], sizeof(T_OS_COM_TABLE_ENTRY));
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
300 return(OS_OK);
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
301 }
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
302
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
303 GLOBAL LONG
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
304 os_CloseQueue(OS_HANDLE TaskHandle, OS_HANDLE ComHandle)
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
305 {
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
306 return(OS_OK);
ee4eb0eacfaf OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 352
diff changeset
307 }