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