a1cc008d3e7a2534ab674ea156e33d1af1f39481
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/lpc_x.h
5 * PURPOSE: Intenral Inlined Functions for Local Procedure Call
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
10 // Gets the message type, removing the kernel-mode flag
12 #define LpcpGetMessageType(x) \
13 ((x)->u2.s2.Type &~ LPC_KERNELMODE_MESSAGE)
16 // Waits on an LPC semaphore for a receive operation
18 #define LpcpReceiveWait(s, w) \
20 LPCTRACE(LPC_REPLY_DEBUG, "Wait: %p\n", s); \
21 Status = KeWaitForSingleObject(s, \
26 LPCTRACE(LPC_REPLY_DEBUG, "Wait done: %lx\n", Status); \
30 // Waits on an LPC semaphore for a reply operation
32 #define LpcpReplyWait(s, w) \
34 LPCTRACE(LPC_SEND_DEBUG, "Wait: %p\n", s); \
35 Status = KeWaitForSingleObject(s, \
40 LPCTRACE(LPC_SEND_DEBUG, "Wait done: %lx\n", Status); \
41 if (Status == STATUS_USER_APC) \
43 /* We were preempted by an APC */ \
44 if (KeReadStateSemaphore(s)) \
46 /* It's still signaled, so wait on it */ \
47 KeWaitForSingleObject(s, \
52 Status = STATUS_SUCCESS; \
58 // Waits on an LPC semaphore for a connect operation
60 #define LpcpConnectWait(s, w) \
62 LPCTRACE(LPC_CONNECT_DEBUG, "Wait: %p\n", s); \
63 Status = KeWaitForSingleObject(s, \
68 LPCTRACE(LPC_CONNECT_DEBUG, "Wait done: %lx\n", Status);\
69 if (Status == STATUS_USER_APC) \
71 /* We were preempted by an APC */ \
72 if (KeReadStateSemaphore(s)) \
74 /* It's still signaled, so wait on it */ \
75 KeWaitForSingleObject(s, \
80 Status = STATUS_SUCCESS; \
86 // Releases an LPC Semaphore to complete a wait
88 #define LpcpCompleteWait(s) \
90 /* Release the semaphore */ \
91 LPCTRACE(LPC_SEND_DEBUG, "Release: %p\n", s); \
92 KeReleaseSemaphore(s, 1, 1, FALSE); \
96 // Allocates a new message
100 LpcpAllocateFromPortZone(VOID
)
102 PLPCP_MESSAGE Message
;
104 /* Allocate a message from the port zone while holding the lock */
105 KeAcquireGuardedMutex(&LpcpLock
);
106 Message
= ExAllocateFromPagedLookasideList(&LpcpMessagesLookaside
);
109 /* Fail, and let caller cleanup */
110 KeReleaseGuardedMutex(&LpcpLock
);
115 InitializeListHead(&Message
->Entry
);
116 Message
->RepliedToThread
= NULL
;
117 Message
->Request
.u2
.ZeroInit
= 0;
119 /* Release the lock */
120 KeReleaseGuardedMutex(&LpcpLock
);