Normalize private symbols in LPC, plus minor changes/adds.
[reactos.git] / reactos / ntoskrnl / lpc / port.c
1 /* $Id: port.c,v 1.20 2004/10/31 20:27:08 ea Exp $
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 ExPortType = NULL;
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 NiInitPort (VOID)
39 {
40 ExPortType = ExAllocatePoolWithTag(NonPagedPool,sizeof(OBJECT_TYPE),TAG_OBJECT_TYPE);
41
42 RtlRosInitUnicodeStringFromLiteral(&ExPortType->TypeName,L"Port");
43
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;
62
63 ObpCreateTypeObject(ExPortType);
64
65 LpcpNextMessageId = 0;
66
67 ExInitializeFastMutex (& LpcpLock);
68
69 return(STATUS_SUCCESS);
70 }
71
72
73 /**********************************************************************
74 * NAME INTERNAL
75 * NiInitializePort/3
76 *
77 * DESCRIPTION
78 * Initialize the EPORT object attributes. The Port
79 * object enters the inactive state.
80 *
81 * ARGUMENTS
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
85 * is created from
86 *
87 * RETURN VALUE
88 * STATUS_SUCCESS if initialization succedeed. An error code
89 * otherwise.
90 */
91 NTSTATUS STDCALL
92 NiInitializePort (IN OUT PEPORT Port,
93 IN USHORT Type,
94 IN PEPORT Parent OPTIONAL)
95 {
96 if ((Type != EPORT_TYPE_SERVER_RQST_PORT) &&
97 (Type != EPORT_TYPE_SERVER_COMM_PORT) &&
98 (Type != EPORT_TYPE_CLIENT_COMM_PORT))
99 {
100 return STATUS_INVALID_PARAMETER_2;
101 }
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;
109 Port->Type = Type;
110 Port->State = EPORT_INACTIVE;
111 InitializeListHead (& Port->QueueListHead);
112 InitializeListHead (& Port->ConnectQueueListHead);
113
114 return (STATUS_SUCCESS);
115 }
116
117
118 /* MISCELLANEA SYSTEM SERVICES */
119
120
121 /**********************************************************************
122 * NAME SYSTEM
123 * NtImpersonateClientOfPort/2
124 *
125 * DESCRIPTION
126 *
127 * ARGUMENTS
128 * PortHandle,
129 * ClientMessage
130 *
131 * RETURN VALUE
132 */
133 NTSTATUS STDCALL
134 NtImpersonateClientOfPort (HANDLE PortHandle,
135 PLPC_MESSAGE ClientMessage)
136 {
137 UNIMPLEMENTED;
138 return(STATUS_NOT_IMPLEMENTED);
139 }
140
141 /* EOF */