FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/gpf/osl/os_com_fl.c @ 353:ee4eb0eacfaf
OSL: os_com_fl.c done
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 12 May 2014 00:14:39 +0000 |
parents | 39b5b18e26b2 |
children | 92742d8f3e56 |
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 typedef unsigned char u_char; |
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 extern T_OS_COM_TABLE_ENTRY ComTable[]; |
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 NU_SEMAPHORE ComSemCB; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 static int |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 os_GetQueueEntry(USHORT Index, OS_HANDLE *Handle) |
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 static USHORT Idx; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 if (Index == FIRST_ENTRY) |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 Idx = 0; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 if (Index == FIRST_ENTRY || Index == NEXT_ENTRY) { |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 while (++Idx <= MaxCommunications && !ComTable[Idx].Name[0]) |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 ; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } else |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 Idx = Index; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 if (Idx <= MaxCommunications && ComTable[Idx].Name[0]) { |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 *Handle = Idx; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 return(0); |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 } else |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 return(-1); |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 } |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 GLOBAL LONG |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 os_QueueInformation(USHORT Index, char *Buffer) |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 { |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 OS_HANDLE Handle; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 T_OS_COM_TABLE_ENTRY *ent; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 UNSIGNED Used; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 OPTION SuspendType; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 UNSIGNED TasksWaiting; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 NU_TASK *First; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 CHAR Name[NU_MAX_NAME]; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 if (os_GetQueueEntry(Index, &Handle) < 0) |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 return(OS_ERROR); |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 ent = ComTable + Handle; |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 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
|
57 &TasksWaiting, &First) != NU_SUCCESS) |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 return(OS_ERROR); |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 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
|
60 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
|
61 ent->MaxUsed); |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 return(OS_OK); |
a163da322bc5
OSL: os_com_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 } |
350
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
64 |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
65 GLOBAL LONG |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
66 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
|
67 { |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
68 USHORT i; |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
69 |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
70 if (!Name) |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
71 return(OS_ERROR); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
72 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
|
73 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
|
74 !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
|
75 *ComHandle = i; |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
76 return(OS_OK); |
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 return(OS_ERROR); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
79 } |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
80 |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
81 GLOBAL LONG |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
82 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
|
83 { |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
84 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
|
85 *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
|
86 *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
|
87 return(OS_OK); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
88 } else |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
89 return(OS_ERROR); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
90 } |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
91 |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
92 GLOBAL LONG |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
93 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
|
94 { |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
95 if (ComHandle > MaxCommunications) |
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 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
|
98 return(OS_ERROR); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
99 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
|
100 return(OS_OK); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
101 } |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
102 |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
103 GLOBAL LONG |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
104 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
|
105 { |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
106 USHORT i; |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
107 |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
108 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
|
109 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
|
110 !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
|
111 *ComHandle = i; |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
112 return(OS_OK); |
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 return(OS_ERROR); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
115 } |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
116 |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
117 GLOBAL LONG |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
118 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
|
119 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
|
120 { |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
121 static USHORT entry; |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
122 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
|
123 |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
124 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
|
125 return(OS_ERROR); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
126 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
|
127 *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
|
128 *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
|
129 *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
|
130 *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
|
131 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
|
132 entry = 0; |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
133 return(OS_OK); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
134 } |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
135 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
|
136 return(OS_ERROR); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
137 entry++; |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
138 *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
|
139 *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
|
140 *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
|
141 *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
|
142 p++; |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
143 return(OS_OK); |
5bc6a8f8b4a8
OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
349
diff
changeset
|
144 } |
351
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
145 |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
146 GLOBAL unsigned char * |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
147 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
|
148 { |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
149 USHORT i; |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
150 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
|
151 |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
152 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
|
153 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
|
154 continue; |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
155 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
|
156 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
|
157 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
|
158 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
|
159 for (susp2 = susp; ; ) { |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
160 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
|
161 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
|
162 susp2 = (SM_SUSPEND *) |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
163 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
|
164 if (susp2 == susp) |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
165 break; |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
166 } |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
167 } |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
168 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
|
169 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
|
170 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
|
171 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
|
172 for (susp2 = susp; ; ) { |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
173 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
|
174 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
|
175 susp2 = (SM_SUSPEND *) |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
176 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
|
177 if (susp2 == susp) |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
178 break; |
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 } |
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 return(0); |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
183 } |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
184 |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
185 GLOBAL LONG |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
186 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
|
187 { |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
188 STATUS sts; |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
189 |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 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
|
194 return(OS_ERROR); |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
195 } |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
196 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
|
197 goto return_error; |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
198 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
|
199 == OS_ERROR) |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
200 goto return_error; |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 return(OS_OK); |
fd015570cacc
os_com_fl.c: os_FindSuspendingQueue() and os_DestroyQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
350
diff
changeset
|
205 } |
352
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
206 |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
207 static short |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
208 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
|
209 OS_HANDLE MemPoolHandle) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
210 { |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
211 T_QDATA_ELEMENT *pElem; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
212 OS_QDATA **ptrs; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
213 USHORT i; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
214 |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
215 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
|
216 sizeof(T_QDATA_ELEMENT) * Entries + |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
217 sizeof(OS_QDATA *) * (Entries + 1) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
218 * OS_MAX_PRIORITY, |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
219 0, MemPoolHandle) == OS_TIMEOUT) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
220 return(OS_ERROR); |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
221 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
|
222 ComTable[ComHandle].pQueueMemory = pElem; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
223 ComTable[ComHandle].pFreeElement = pElem; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
224 for (i = 0; i < Entries; i++) { |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
225 if (i < Entries - 1) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
226 pElem->pNext = pElem + 1; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
227 else |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
228 pElem->pNext = pElem; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
229 pElem++; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
230 } |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
231 ptrs = (OS_QDATA **) pElem; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
232 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
|
233 ComTable[ComHandle].Queue[i].pStart = ptrs; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
234 ComTable[ComHandle].Queue[i].pRead = ptrs; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
235 ComTable[ComHandle].Queue[i].pWrite = ptrs; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
236 ptrs += Entries + 1; |
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 return(OS_OK); |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
239 } |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
240 |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
241 GLOBAL LONG |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
242 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
|
243 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
|
244 { |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
245 STATUS sts; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
246 OS_HANDLE i; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
247 char Buffer[RESOURCE_NAMELEN + 1]; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
248 |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
249 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
|
250 return(OS_ERROR); |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
251 if (!Entries) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
252 return(OS_ERROR); |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
253 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
|
254 if (!ComHandle) { |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
255 for (i = 1; i <= MaxCommunications; i++) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
256 if (!ComTable[i].Name[0]) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
257 goto good_slot; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
258 release_sem_error: |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
259 if (sts == NU_SUCCESS) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
260 NU_Release_Semaphore(&ComSemCB); |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
261 return(OS_ERROR); |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
262 } else { |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
263 i = ComHandle; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
264 if (i > MaxCommunications) |
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 if (ComTable[i].Name[0]) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
267 goto release_sem_error; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
268 } |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
269 good_slot: |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
270 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
|
271 goto release_sem_error; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
272 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
|
273 Buffer[RESOURCE_NAMELEN] = 0; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
274 Buffer[0] = 'U'; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
275 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
|
276 != NU_SUCCESS) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
277 goto release_sem_error; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
278 Buffer[0] = 'F'; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
279 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
|
280 NU_PRIORITY) != NU_SUCCESS) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
281 goto release_sem_error; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
282 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
|
283 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
|
284 *ActHandle = i; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
285 ComTable[i].Entries = Entries; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
286 ComTable[i].MaxUsed = 0; |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
287 if (sts == NU_SUCCESS) |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
288 NU_Release_Semaphore(&ComSemCB); |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
289 return(OS_OK); |
39b5b18e26b2
os_com_fl.c: os_CreateQueue() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
351
diff
changeset
|
290 } |
353
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
291 |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
292 GLOBAL LONG |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
293 os_ComInit(void) |
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 USHORT i; |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
296 |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
297 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
|
298 != NU_SUCCESS) |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
299 return(OS_ERROR); |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
300 for (i = 1; i <= MaxCommunications; i++) |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
301 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
|
302 return(OS_OK); |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
303 } |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
304 |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
305 GLOBAL LONG |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
306 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
|
307 { |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
308 return(OS_OK); |
ee4eb0eacfaf
OSL: os_com_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
352
diff
changeset
|
309 } |