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