3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/lpc/port.c
6 * PURPOSE: Communication mechanism
7 * PROGRAMMER: David Welch (welch@cwcom.net)
12 * ntoskrnl/nt/port.c moved in ntoskrnl/lpc/port.c
15 /* INCLUDES *****************************************************************/
19 #include <internal/debug.h>
22 /* GLOBALS *******************************************************************/
24 POBJECT_TYPE LpcPortObjectType
= 0;
25 ULONG LpcpNextMessageId
= 0; /* 0 is not a valid ID */
26 FAST_MUTEX LpcpLock
; /* global internal sync in LPC facility */
28 static GENERIC_MAPPING ExpPortMapping
= {
30 STANDARD_RIGHTS_WRITE
,
34 /* FUNCTIONS *****************************************************************/
37 NTSTATUS INIT_FUNCTION
40 /* Allocate Memory for the LPC Object */
41 LpcPortObjectType
= ExAllocatePool(NonPagedPool
, sizeof(OBJECT_TYPE
));
42 RtlZeroMemory (LpcPortObjectType
, sizeof (OBJECT_TYPE
));
44 RtlRosInitUnicodeStringFromLiteral(&LpcPortObjectType
->TypeName
,L
"Port");
46 LpcPortObjectType
->Tag
= TAG('L', 'P', 'R', 'T');
47 LpcPortObjectType
->PeakObjects
= 0;
48 LpcPortObjectType
->PeakHandles
= 0;
49 LpcPortObjectType
->TotalObjects
= 0;
50 LpcPortObjectType
->TotalHandles
= 0;
51 LpcPortObjectType
->PagedPoolCharge
= 0;
52 LpcPortObjectType
->NonpagedPoolCharge
= sizeof(EPORT
);
53 LpcPortObjectType
->Mapping
= &ExpPortMapping
;
54 LpcPortObjectType
->Dump
= NULL
;
55 LpcPortObjectType
->Open
= NULL
;
56 LpcPortObjectType
->Close
= NiClosePort
;
57 LpcPortObjectType
->Delete
= NiDeletePort
;
58 LpcPortObjectType
->Parse
= NULL
;
59 LpcPortObjectType
->Security
= NULL
;
60 LpcPortObjectType
->QueryName
= NULL
;
61 LpcPortObjectType
->OkayToClose
= NULL
;
62 LpcPortObjectType
->Create
= NiCreatePort
;
63 LpcPortObjectType
->DuplicationNotify
= NULL
;
65 ObpCreateTypeObject(LpcPortObjectType
);
67 LpcpNextMessageId
= 0;
69 ExInitializeFastMutex (& LpcpLock
);
71 return(STATUS_SUCCESS
);
75 /**********************************************************************
80 * Initialize the EPORT object attributes. The Port
81 * object enters the inactive state.
84 * Port Pointer to an EPORT object to initialize.
85 * Type connect (RQST), or communication port (COMM)
86 * Parent OPTIONAL connect port a communication port
90 * STATUS_SUCCESS if initialization succedeed. An error code
94 LpcpInitializePort (IN OUT PEPORT Port
,
96 IN PEPORT Parent OPTIONAL
)
98 if ((Type
!= EPORT_TYPE_SERVER_RQST_PORT
) &&
99 (Type
!= EPORT_TYPE_SERVER_COMM_PORT
) &&
100 (Type
!= EPORT_TYPE_CLIENT_COMM_PORT
))
102 return STATUS_INVALID_PARAMETER_2
;
104 memset (Port
, 0, sizeof(EPORT
));
105 KeInitializeSpinLock (& Port
->Lock
);
106 KeInitializeSemaphore( &Port
->Semaphore
, 0, LONG_MAX
);
107 Port
->RequestPort
= Parent
;
108 Port
->OtherPort
= NULL
;
109 Port
->QueueLength
= 0;
110 Port
->ConnectQueueLength
= 0;
112 Port
->State
= EPORT_INACTIVE
;
113 InitializeListHead (& Port
->QueueListHead
);
114 InitializeListHead (& Port
->ConnectQueueListHead
);
116 return (STATUS_SUCCESS
);
120 /* MISCELLANEA SYSTEM SERVICES */
123 /**********************************************************************
125 * NtImpersonateClientOfPort/2
136 NtImpersonateClientOfPort (HANDLE PortHandle
,
137 PLPC_MESSAGE ClientMessage
)
140 return(STATUS_NOT_IMPLEMENTED
);