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