Remove /nt directory
[reactos.git] / reactos / ntoskrnl / lpc / port.c
1 /* $Id$
2 *
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)
8 * UPDATE HISTORY:
9 * Created 22/05/98
10 *
11 * 2000-06-04 (ea)
12 * ntoskrnl/nt/port.c moved in ntoskrnl/lpc/port.c
13 */
14
15 /* INCLUDES *****************************************************************/
16
17 #include <ntoskrnl.h>
18 #define NDEBUG
19 #include <internal/debug.h>
20
21
22 /* GLOBALS *******************************************************************/
23
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 */
27
28 static GENERIC_MAPPING ExpPortMapping = {
29 STANDARD_RIGHTS_READ,
30 STANDARD_RIGHTS_WRITE,
31 0,
32 PORT_ALL_ACCESS};
33
34 /* FUNCTIONS *****************************************************************/
35
36
37 NTSTATUS INIT_FUNCTION
38 LpcpInitSystem (VOID)
39 {
40 /* Allocate Memory for the LPC Object */
41 LpcPortObjectType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE));
42 RtlZeroMemory (LpcPortObjectType, sizeof (OBJECT_TYPE));
43
44 RtlRosInitUnicodeStringFromLiteral(&LpcPortObjectType->TypeName,L"Port");
45
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;
64
65 ObpCreateTypeObject(LpcPortObjectType);
66
67 LpcpNextMessageId = 0;
68
69 ExInitializeFastMutex (& LpcpLock);
70
71 return(STATUS_SUCCESS);
72 }
73
74
75 /**********************************************************************
76 * NAME INTERNAL
77 * NiInitializePort/3
78 *
79 * DESCRIPTION
80 * Initialize the EPORT object attributes. The Port
81 * object enters the inactive state.
82 *
83 * ARGUMENTS
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
87 * is created from
88 *
89 * RETURN VALUE
90 * STATUS_SUCCESS if initialization succedeed. An error code
91 * otherwise.
92 */
93 NTSTATUS STDCALL
94 LpcpInitializePort (IN OUT PEPORT Port,
95 IN USHORT Type,
96 IN PEPORT Parent OPTIONAL)
97 {
98 if ((Type != EPORT_TYPE_SERVER_RQST_PORT) &&
99 (Type != EPORT_TYPE_SERVER_COMM_PORT) &&
100 (Type != EPORT_TYPE_CLIENT_COMM_PORT))
101 {
102 return STATUS_INVALID_PARAMETER_2;
103 }
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;
111 Port->Type = Type;
112 Port->State = EPORT_INACTIVE;
113 InitializeListHead (& Port->QueueListHead);
114 InitializeListHead (& Port->ConnectQueueListHead);
115
116 return (STATUS_SUCCESS);
117 }
118
119
120 /* MISCELLANEA SYSTEM SERVICES */
121
122
123 /**********************************************************************
124 * NAME SYSTEM
125 * NtImpersonateClientOfPort/2
126 *
127 * DESCRIPTION
128 *
129 * ARGUMENTS
130 * PortHandle,
131 * ClientMessage
132 *
133 * RETURN VALUE
134 */
135 NTSTATUS STDCALL
136 NtImpersonateClientOfPort (HANDLE PortHandle,
137 PLPC_MESSAGE ClientMessage)
138 {
139 UNIMPLEMENTED;
140 return(STATUS_NOT_IMPLEMENTED);
141 }
142
143 /* EOF */