1 | /* $Id: OS2KSEM.h,v 1.3 2000-12-11 06:53:49 bird Exp $
|
---|
2 | *
|
---|
3 | * OS/2 kernel Semaphore functions.
|
---|
4 | *
|
---|
5 | * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
6 | *
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 |
|
---|
12 | #ifndef _OS2KSEM_h_
|
---|
13 | #define _OS2KSEM_h_
|
---|
14 |
|
---|
15 | /*******************************************************************************
|
---|
16 | * Defined Constants And Macros *
|
---|
17 | *******************************************************************************/
|
---|
18 | #define KSEM_INDEFINITE_WAIT -1UL
|
---|
19 | #define KSEM_IMMEDIATE_RETURN 0UL
|
---|
20 |
|
---|
21 | /*
|
---|
22 | * Semaphore type. ( Used with the generic KSEM routines. )
|
---|
23 | */
|
---|
24 | #define KSEM_EVENT 0
|
---|
25 | #define KSEM_MUTEX 1
|
---|
26 | #define KSEM_SHARED 2
|
---|
27 |
|
---|
28 | /*
|
---|
29 | * Sempahore flags. (according to SG24-4640-00)
|
---|
30 | */
|
---|
31 | #define KSEM_DEFAULT 0
|
---|
32 | #define KSEM_NOINTERRUPT 1
|
---|
33 | #define KSEM_WRITE 2
|
---|
34 | #define KSEM_DISPLAYID 4
|
---|
35 | #define KSEM_NOBLOCKED 8
|
---|
36 |
|
---|
37 |
|
---|
38 | /*******************************************************************************
|
---|
39 | * Structures and Typedefs *
|
---|
40 | *******************************************************************************/
|
---|
41 | /* (This is according to SG24-4640-00.) */
|
---|
42 |
|
---|
43 | typedef struct _KSEMSHR
|
---|
44 | {
|
---|
45 | /**
|
---|
46 | * Astrict 16 is byte while retail 12 is bytes.
|
---|
47 | * We'll reserve 20 bytes just to be sure!.
|
---|
48 | */
|
---|
49 | char achDummy[20];
|
---|
50 |
|
---|
51 | struct
|
---|
52 | {
|
---|
53 | char ks_achSignature[4];
|
---|
54 | char ks_bFlags;
|
---|
55 | char ks_bType;
|
---|
56 | unsigned short ks_Owner;
|
---|
57 | unsigned short ks_cusPendingWriters;
|
---|
58 | unsigned short ks_cusNest;
|
---|
59 | unsigned short ks_cusReaders;
|
---|
60 | unsigned short ks_cusPendingReaders;
|
---|
61 | } debug;
|
---|
62 |
|
---|
63 | struct
|
---|
64 | {
|
---|
65 | char ks_bFlags;
|
---|
66 | char ks_bType;
|
---|
67 | unsigned short ks_Owner;
|
---|
68 | unsigned short ks_cusPendingWriters;
|
---|
69 | unsigned short ks_cusNest;
|
---|
70 | unsigned short ks_cusReaders;
|
---|
71 | unsigned short ks_cusPendingReaders;
|
---|
72 | } release;
|
---|
73 |
|
---|
74 | } KSEMSHR,
|
---|
75 | *PKSEMSHR,
|
---|
76 | *HKSEMSHR; /* Handle to kernel shared semphore. */
|
---|
77 | typedef HKSEMSHR * PHKSEMSHR;
|
---|
78 |
|
---|
79 |
|
---|
80 | typedef union _KSEMMTX
|
---|
81 | {
|
---|
82 | /**
|
---|
83 | * Astrict is 12 byte while retail is 8 bytes.
|
---|
84 | * We'll reserve 20 bytes just to be sure!
|
---|
85 | */
|
---|
86 | char achDummy[20];
|
---|
87 |
|
---|
88 | struct
|
---|
89 | {
|
---|
90 | char ksem_achSignature[4];
|
---|
91 | char ksem_bFlags;
|
---|
92 | char ksem_bType;
|
---|
93 | unsigned short ksem_Owner;
|
---|
94 | unsigned short ksem_cusPendingWriters;
|
---|
95 | unsigned short ksem_cusNest;
|
---|
96 | }debug;
|
---|
97 | struct
|
---|
98 | {
|
---|
99 | char ksem_bFlags;
|
---|
100 | char ksem_bType;
|
---|
101 | unsigned short ksem_Owner;
|
---|
102 | unsigned short ksem_cusPendingWriters;
|
---|
103 | unsigned short ksem_cusNest;
|
---|
104 | } release;
|
---|
105 | } KSEMMTX,
|
---|
106 | *PKSEMMTX,
|
---|
107 | *HKSEMMTX; /* Handle to kernel mutex semaphore. */
|
---|
108 | typedef HKSEMMTX * PHKSEMMTX;
|
---|
109 |
|
---|
110 |
|
---|
111 | typedef struct _KSEMEVT
|
---|
112 | {
|
---|
113 | /**
|
---|
114 | * Astrict is 16 byte while retail is 12 bytes.
|
---|
115 | * We'll reserve 20 bytes just to be sure!
|
---|
116 | */
|
---|
117 | char achDummy[20];
|
---|
118 |
|
---|
119 | struct
|
---|
120 | {
|
---|
121 | char kse_achSignature[4];
|
---|
122 | char kse_bFlags;
|
---|
123 | char kse_bType;
|
---|
124 | unsigned short kse_Owner;
|
---|
125 | unsigned short kse_cusPendingWriters;
|
---|
126 | } debug;
|
---|
127 |
|
---|
128 | struct
|
---|
129 | {
|
---|
130 | char kse_bFlags;
|
---|
131 | char kse_bType;
|
---|
132 | unsigned short kse_Owner;
|
---|
133 | unsigned short kse_cusPendingWriters;
|
---|
134 | } release;
|
---|
135 |
|
---|
136 | } KSEMEVT,
|
---|
137 | *PKSEMEVT,
|
---|
138 | *HKSEMEVT; /* Handle to kernel event sempahore. */
|
---|
139 | typedef HKSEMEVT * PHKSEMEVT;
|
---|
140 |
|
---|
141 |
|
---|
142 | typedef union _KSEM
|
---|
143 | {
|
---|
144 | KSEMSHR shr;
|
---|
145 | KSEMMTX mtx;
|
---|
146 | KSEMEVT evt;
|
---|
147 | } KSEM, *PKSEM, *HKSEM; /* Generic kernel semaphore handle. */
|
---|
148 | typedef HKSEM * PHKSEM;
|
---|
149 |
|
---|
150 |
|
---|
151 | /*******************************************************************************
|
---|
152 | * Exported Functions *
|
---|
153 | *******************************************************************************/
|
---|
154 | /*
|
---|
155 | * Mutex semaphores.
|
---|
156 | */
|
---|
157 | extern ULONG KRNLCALL KSEMRequestMutex(HKSEMMTX hkmtx, ULONG ulTimeout);
|
---|
158 | extern VOID KRNLCALL KSEMReleaseMutex(HKSEMMTX hkmtx);
|
---|
159 | extern ULONG KRNLCALL KSEMQueryMutex(HKSEMMTX hkmtx, PUSHORT pcusNest);
|
---|
160 |
|
---|
161 |
|
---|
162 | #if 0
|
---|
163 | /*
|
---|
164 | * Event semaphores.
|
---|
165 | */
|
---|
166 | extern VOID KRNLCALL KSEMResetEvent(HKEV hkevent);
|
---|
167 | extern VOID KRNLCALL KSEMPostEvent(HKEV hkevent);
|
---|
168 | extern ULONG KRNLCALL KSEMWaitEvent(HKEV hkevent);
|
---|
169 | #endif
|
---|
170 |
|
---|
171 | /*
|
---|
172 | * Some other KSEM prefixed functions - parameters's not that obvious...
|
---|
173 | */
|
---|
174 | #if 0
|
---|
175 | extern ULONG KRNLCALL KSEMAlloc(PHKSEM phksem, ULONG p1, ULONG p2);
|
---|
176 | extern ULONG KRNLCALL KSEMCreate(PHKSEM phksem, ULONG type);
|
---|
177 | extern ULONG KRNLCALL KSEMRequestExclusive(HKSEM hksem, ULONG );
|
---|
178 | extern ULONG KRNLCALL KSEMRequestShared(HKSEM hksem, ULONG);
|
---|
179 | extern VOID KRNLCALL KSEMDestroy(HKSEM hksem);
|
---|
180 | #endif
|
---|
181 | extern VOID KRNLCALL KSEMInit(PKSEM pksem, ULONG fulType, ULONG fulFlags);
|
---|
182 | #if 0
|
---|
183 | extern VOID KRNLCALL KSEMQuery(HKSEM hksem, ULONG p2)
|
---|
184 | extern VOID KRNLCALL KSEMRelease(HKSEM hksem);
|
---|
185 | #endif
|
---|
186 | #endif
|
---|
187 |
|
---|