1 /* $Id: port.c,v 1.20 2004/10/31 20:27:08 ea Exp $
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 ExPortType
= NULL
;
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 ExPortType
= ExAllocatePoolWithTag(NonPagedPool
,sizeof(OBJECT_TYPE
),TAG_OBJECT_TYPE
);
42 RtlRosInitUnicodeStringFromLiteral(&ExPortType
->TypeName
,L
"Port");
44 ExPortType
->Tag
= TAG('L', 'P', 'R', 'T');
45 ExPortType
->MaxObjects
= ULONG_MAX
;
46 ExPortType
->MaxHandles
= ULONG_MAX
;
47 ExPortType
->TotalObjects
= 0;
48 ExPortType
->TotalHandles
= 0;
49 ExPortType
->PagedPoolCharge
= 0;
50 ExPortType
->NonpagedPoolCharge
= sizeof(EPORT
);
51 ExPortType
->Mapping
= &ExpPortMapping
;
52 ExPortType
->Dump
= NULL
;
53 ExPortType
->Open
= NULL
;
54 ExPortType
->Close
= NiClosePort
;
55 ExPortType
->Delete
= NiDeletePort
;
56 ExPortType
->Parse
= NULL
;
57 ExPortType
->Security
= NULL
;
58 ExPortType
->QueryName
= NULL
;
59 ExPortType
->OkayToClose
= NULL
;
60 ExPortType
->Create
= NiCreatePort
;
61 ExPortType
->DuplicationNotify
= NULL
;
63 ObpCreateTypeObject(ExPortType
);
65 LpcpNextMessageId
= 0;
67 ExInitializeFastMutex (& LpcpLock
);
69 return(STATUS_SUCCESS
);
73 /**********************************************************************
78 * Initialize the EPORT object attributes. The Port
79 * object enters the inactive state.
82 * Port Pointer to an EPORT object to initialize.
83 * Type connect (RQST), or communication port (COMM)
84 * Parent OPTIONAL connect port a communication port
88 * STATUS_SUCCESS if initialization succedeed. An error code
92 NiInitializePort (IN OUT PEPORT Port
,
94 IN PEPORT Parent OPTIONAL
)
96 if ((Type
!= EPORT_TYPE_SERVER_RQST_PORT
) &&
97 (Type
!= EPORT_TYPE_SERVER_COMM_PORT
) &&
98 (Type
!= EPORT_TYPE_CLIENT_COMM_PORT
))
100 return STATUS_INVALID_PARAMETER_2
;
102 memset (Port
, 0, sizeof(EPORT
));
103 KeInitializeSpinLock (& Port
->Lock
);
104 KeInitializeSemaphore( &Port
->Semaphore
, 0, LONG_MAX
);
105 Port
->RequestPort
= Parent
;
106 Port
->OtherPort
= NULL
;
107 Port
->QueueLength
= 0;
108 Port
->ConnectQueueLength
= 0;
110 Port
->State
= EPORT_INACTIVE
;
111 InitializeListHead (& Port
->QueueListHead
);
112 InitializeListHead (& Port
->ConnectQueueListHead
);
114 return (STATUS_SUCCESS
);
118 /* MISCELLANEA SYSTEM SERVICES */
121 /**********************************************************************
123 * NtImpersonateClientOfPort/2
134 NtImpersonateClientOfPort (HANDLE PortHandle
,
135 PLPC_MESSAGE ClientMessage
)
138 return(STATUS_NOT_IMPLEMENTED
);