annotate gsm-fw/gpf/osl/os_sem_fl.c @ 497:f11f7cb7c353

osx.c: osx_send_prim() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 01 Jul 2014 13:21:41 +0000
parents 03b6377d61db
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
441
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module is a reconstruction based on the disassembly of
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * os_sem.obj in frame_na7_db_fl.lib from the Leonardo package.
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 /* set of included headers from COFF symtab: */
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "gpfconf.h" /* FreeCalypso addition */
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "../../nucleus/nucleus.h"
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "typedefs.h"
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "os.h"
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "gdi.h"
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "os_types.h"
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "os_glob.h"
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 extern T_OS_SEM_TABLE_ENTRY SemTable[];
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 static NU_SEMAPHORE SemSemCB;
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 static int
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 os_GetSemaphoreEntry(USHORT Index, OS_HANDLE *Handle)
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 {
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 static USHORT Idx;
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 if (Index == FIRST_ENTRY)
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 Idx = 0;
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 if (Index == FIRST_ENTRY || Index == NEXT_ENTRY) {
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 for (;;) {
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 Idx++;
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 if (Idx > MaxSemaphores)
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 return(OS_ERROR);
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 if (SemTable[Idx].Name[0])
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 break;
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 }
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 } else
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 Idx = Index;
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 if (Idx > MaxSemaphores)
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 return(OS_ERROR);
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 if (SemTable[Idx].Name[0]) {
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 *Handle = Idx;
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 return(OS_OK);
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 } else
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 return(OS_ERROR);
b23743555ca8 OSL: os_sem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 }
442
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
46
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
47 GLOBAL LONG
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
48 os_SemaphoreInformation(USHORT Index, char *Buffer)
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
49 {
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
50 OS_HANDLE Handle;
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
51 OPTION SuspendType;
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
52 UNSIGNED Current, TasksWaiting;
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
53 NU_TASK *First;
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
54 CHAR Name[NU_MAX_NAME];
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
55
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
56 if (os_GetSemaphoreEntry(Index, &Handle) < 0)
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
57 return(OS_ERROR);
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
58 if (NU_Semaphore_Information(&SemTable[Handle].SemCB, Name, &Current,
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
59 &SuspendType, &TasksWaiting, &First)
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
60 != NU_SUCCESS)
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
61 return(OS_ERROR);
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
62 sprintf(Buffer, "Semname:%s Count:%ld Suspend:%d Waiting:%ld", Name,
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
63 Current, SuspendType, TasksWaiting);
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
64 return(OS_OK);
0dbc1795ff42 os_sem_fl.c: os_SemaphoreInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 441
diff changeset
65 }
443
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
66
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
67 GLOBAL LONG
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
68 os_SemInit(void)
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
69 {
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
70 USHORT i;
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
71
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
72 if (NU_Create_Semaphore(&SemSemCB, "SEMSEM", 1, NU_PRIORITY)
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
73 != NU_SUCCESS)
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
74 return(OS_ERROR);
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
75 for (i = 1; i <= MaxSemaphores; i++)
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
76 bzero(&SemTable[i], sizeof(T_OS_SEM_TABLE_ENTRY));
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
77 return(OS_OK);
42f9e12a9ced os_sem_fl.c: os_SemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 442
diff changeset
78 }
444
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
79
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
80 GLOBAL LONG
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
81 os_ResetSemaphore(OS_HANDLE TaskHandle, OS_HANDLE SemHandle,
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
82 USHORT init_counter)
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
83 {
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
84 STATUS sts;
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
85
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
86 sts = NU_Obtain_Semaphore(&SemSemCB, NU_SUSPEND);
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
87 if (!SemTable[SemHandle].Name[0]) {
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
88 error_out: if (sts == NU_SUCCESS)
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
89 NU_Release_Semaphore(&SemSemCB);
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
90 return(OS_ERROR);
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
91 }
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
92 if (NU_Reset_Semaphore(&SemTable[SemHandle].SemCB, init_counter)
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
93 != NU_SUCCESS)
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
94 goto error_out;
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
95 if (sts == NU_SUCCESS)
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
96 NU_Release_Semaphore(&SemSemCB);
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
97 return(OS_OK);
caeff442faf1 os_sem_fl.c: os_ResetSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 443
diff changeset
98 }
445
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
99
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
100 GLOBAL LONG
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
101 os_QuerySemaphore(OS_HANDLE TaskHandle, OS_HANDLE SemHandle, USHORT *Count)
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
102 {
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
103 OPTION SuspendType;
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
104 UNSIGNED SemCount, TasksWaiting;
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
105 NU_TASK *First;
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
106 CHAR Name[NU_MAX_NAME];
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
107
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
108 if (NU_Semaphore_Information(&SemTable[SemHandle].SemCB, Name,
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
109 &SemCount, &SuspendType, &TasksWaiting,
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
110 &First) != NU_SUCCESS)
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
111 return(OS_ERROR);
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
112 *Count = SemCount;
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
113 return(OS_OK);
9eeeef3ff7db os_sem_fl.c: os_QuerySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 444
diff changeset
114 }
446
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
115
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
116 GLOBAL LONG
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
117 os_OpenSemaphore(OS_HANDLE TaskHandle, char *Name, OS_HANDLE *SemHandle)
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
118 {
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
119 USHORT i;
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
120
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
121 for (i = 1; i <= MaxSemaphores; i++) {
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
122 if (!SemTable[i].Name[0])
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
123 continue;
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
124 if (strncmp(Name, SemTable[i].Name, RESOURCE_NAMELEN-1))
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
125 continue;
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
126 *SemHandle = i;
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
127 return(OS_OK);
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
128 }
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
129 return(OS_ERROR);
57f8e2b747c4 os_sem_fl.c: os_OpenSemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 445
diff changeset
130 }
447
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
131
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
132 GLOBAL unsigned char *
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
133 os_FindSuspendingSema(unsigned int *tcb)
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
134 {
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
135 USHORT i;
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
136 SM_SUSPEND *susp, *susp_loopchk;
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
137
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
138 for (i = 1; i <= MaxSemaphores; i++) {
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
139 if (!SemTable[i].Name[0])
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
140 continue;
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
141 susp = SemTable[i].SemCB.sm_suspension_list;
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
142 if (!susp)
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
143 continue;
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
144 if (susp->sm_suspended_task == (NU_TASK *)tcb)
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
145 return(SemTable[i].SemCB.sm_name);
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
146 susp = (SM_SUSPEND *)susp->sm_suspend_link.cs_next;
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
147 for (susp_loopchk = susp; susp != susp_loopchk;
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
148 susp = (SM_SUSPEND *)susp->sm_suspend_link.cs_next)
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
149 if (susp->sm_suspended_task == (NU_TASK *)tcb)
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
150 return(SemTable[i].SemCB.sm_name);
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
151 }
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
152 return(0);
b55882290007 os_sem_fl.c: os_FindSuspendingSema() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 446
diff changeset
153 }
448
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
154
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
155 GLOBAL LONG
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
156 os_DestroySemaphore(OS_HANDLE TaskHandle, OS_HANDLE SemHandle)
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
157 {
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
158 STATUS sts;
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
159
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
160 sts = NU_Obtain_Semaphore(&SemSemCB, NU_SUSPEND);
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
161 if (!SemTable[SemHandle].Name[0]) {
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
162 error_out: if (sts == NU_SUCCESS)
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
163 NU_Release_Semaphore(&SemSemCB);
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
164 return(OS_ERROR);
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
165 }
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
166 if (NU_Delete_Semaphore(&SemTable[SemHandle].SemCB) != NU_SUCCESS)
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
167 goto error_out;
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
168 SemTable[SemHandle].Name[0] = 0;
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
169 if (sts == NU_SUCCESS)
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
170 NU_Release_Semaphore(&SemSemCB);
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
171 return(OS_OK);
fd1729fd979e os_sem_fl.c: os_DestroySemaphore() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 447
diff changeset
172 }
449
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
173
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
174 GLOBAL LONG
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
175 os_CreateSemaphore(OS_HANDLE TaskHandle, char *Name, USHORT Count,
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
176 OS_HANDLE *SemHandle, OS_HANDLE MemPoolHandle)
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
177 {
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
178 USHORT i;
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
179 STATUS sts;
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
180
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
181 if (os_OpenSemaphore(TaskHandle, Name, SemHandle) == OS_OK)
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
182 return(OS_ERROR);
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
183 sts = NU_Obtain_Semaphore(&SemSemCB, NU_SUSPEND);
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
184 for (i = 1; i <= MaxSemaphores; i++) {
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
185 if (SemTable[i].Name[0])
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
186 continue;
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
187 if (NU_Create_Semaphore(&SemTable[i].SemCB, Name, Count,
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
188 NU_PRIORITY) != NU_SUCCESS)
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
189 break;
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
190 strncpy(SemTable[i].Name, Name, RESOURCE_NAMELEN);
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
191 SemTable[i].Name[RESOURCE_NAMELEN-1] = 0;
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
192 *SemHandle = i;
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
193 if (sts == NU_SUCCESS)
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
194 NU_Release_Semaphore(&SemSemCB);
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
195 return(OS_OK);
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
196 }
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
197 if (sts == NU_SUCCESS)
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
198 NU_Release_Semaphore(&SemSemCB);
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
199 return(OS_ERROR);
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
200 }
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
201
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
202 GLOBAL LONG
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
203 os_CloseSemaphore(OS_HANDLE TaskHandle, OS_HANDLE SemHandle)
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
204 {
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
205 return(OS_OK);
03b6377d61db OSL: os_sem_fl.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 448
diff changeset
206 }