ReactOS 0.4.16-dev-329-g9223134
channel.c File Reference
#include "sacdrv.h"
Include dependency graph for channel.c:

Go to the source code of this file.

Functions

BOOLEAN NTAPI ChannelIsValidType (IN SAC_CHANNEL_TYPE ChannelType)
 
BOOLEAN NTAPI ChannelIsEqual (IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ID ChannelId)
 
NTSTATUS NTAPI ChannelDereferenceHandles (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelDestroy (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelOWrite (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize)
 
NTSTATUS NTAPI ChannelOFlush (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelIWrite (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize)
 
NTSTATUS NTAPI ChannelIRead (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, IN OUT PULONG ResultBufferSize)
 
WCHAR NTAPI ChannelIReadLast (IN PSAC_CHANNEL Channel)
 
ULONG NTAPI ChannelIBufferLength (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelSetRedrawEvent (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelSetLockEvent (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelClearRedrawEvent (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelHasRedrawEvent (IN PSAC_CHANNEL Channel, OUT PBOOLEAN Present)
 
NTSTATUS NTAPI ChannelGetStatus (IN PSAC_CHANNEL Channel, OUT PSAC_CHANNEL_STATUS ChannelStatus)
 
NTSTATUS NTAPI ChannelSetStatus (IN PSAC_CHANNEL Channel, IN SAC_CHANNEL_STATUS ChannelStatus)
 
BOOLEAN NTAPI ChannelIsActive (IN PSAC_CHANNEL Channel)
 
BOOLEAN NTAPI ChannelIsClosed (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelGetName (IN PSAC_CHANNEL Channel, OUT PWCHAR *Name)
 
NTSTATUS NTAPI ChannelSetName (IN PSAC_CHANNEL Channel, IN PWCHAR Name)
 
NTSTATUS NTAPI ChannelGetDescription (IN PSAC_CHANNEL Channel, IN PWCHAR *Description)
 
NTSTATUS NTAPI ChannelSetDescription (IN PSAC_CHANNEL Channel, IN PWCHAR Description)
 
NTSTATUS NTAPI ChannelGetApplicationType (IN PSAC_CHANNEL Channel, OUT PGUID ApplicationType)
 
NTSTATUS NTAPI ChannelInitializeVTable (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelCreate (IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ATTRIBUTES Attributes, IN SAC_CHANNEL_ID ChannelId)
 
NTSTATUS NTAPI ChannelClose (IN PSAC_CHANNEL Channel)
 

Function Documentation

◆ ChannelClearRedrawEvent()

NTSTATUS NTAPI ChannelClearRedrawEvent ( IN PSAC_CHANNEL  Channel)

Definition at line 198 of file channel.c.

199{
201
202 /* Clear the event */
203 ChannelClearEvent(Channel, RedrawEvent);
204 return Status;
205}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
#define ChannelClearEvent(Channel, x)
Definition: sacdrv.h:114

Referenced by ConMgrSetCurrentChannel().

◆ ChannelClose()

NTSTATUS NTAPI ChannelClose ( IN PSAC_CHANNEL  Channel)

Definition at line 558 of file channel.c.

559{
561 CHECK_PARAMETER(Channel);
562
563 /* Set the channel inactive */
564 ChannelSetStatus(Channel, Inactive);
565
566 /* Set the close event */
567 if (Channel->Flags & SAC_CHANNEL_FLAG_CLOSE_EVENT)
568 {
569 ChannelSetEvent(Channel, CloseEvent);
570 }
571
572 /* Close all the handles */
574 return Status;
575}
NTSTATUS NTAPI ChannelDereferenceHandles(IN PSAC_CHANNEL Channel)
Definition: channel.c:35
NTSTATUS NTAPI ChannelSetStatus(IN PSAC_CHANNEL Channel, IN SAC_CHANNEL_STATUS ChannelStatus)
Definition: channel.c:236
#define SAC_CHANNEL_FLAG_CLOSE_EVENT
Definition: sacdrv.h:170
#define ChannelSetEvent(Channel, x)
Definition: sacdrv.h:99
#define CHECK_PARAMETER(x)
Definition: sacdrv.h:54
@ Inactive
Definition: sacdrv.h:287

Referenced by ChanMgrCloseChannel(), and ConMgrShutdown().

◆ ChannelCreate()

NTSTATUS NTAPI ChannelCreate ( IN PSAC_CHANNEL  Channel,
IN PSAC_CHANNEL_ATTRIBUTES  Attributes,
IN SAC_CHANNEL_ID  ChannelId 
)

Definition at line 457 of file channel.c.

460{
462 CHECK_PARAMETER1(Channel);
464
465 /* If a close event is being passed in, it must exist, and vice-versa */
467 {
468 CHECK_PARAMETER(Attributes->CloseEvent != NULL);
469 }
470 else
471 {
472 CHECK_PARAMETER(Attributes->CloseEvent == NULL);
473 }
474
475 /* If a new data event is being passed in, it must exist, and vice-versa */
477 {
478 CHECK_PARAMETER(Attributes->HasNewDataEvent != NULL);
479 }
480 else
481 {
482 CHECK_PARAMETER(Attributes->HasNewDataEvent == NULL);
483 }
484
485 /* If a lock event is being passed in, it must exist, and vice-versa */
487 {
488 CHECK_PARAMETER(Attributes->LockEvent != NULL);
489 }
490 else
491 {
492 CHECK_PARAMETER(Attributes->LockEvent == NULL);
493 }
494
495 /* If a redraw event is being passed in, it must exist, and vice-versa */
497 {
498 CHECK_PARAMETER(Attributes->RedrawEvent != NULL);
499 }
500 else
501 {
502 CHECK_PARAMETER(Attributes->RedrawEvent == NULL);
503 }
504
505 /* Initialize the channel structure */
506 RtlZeroMemory(Channel, sizeof(SAC_CHANNEL));
507 Channel->ChannelId = ChannelId;
508 Channel->ChannelType = Attributes->ChannelType;
509 Channel->Flags = Attributes->Flag;
511 {
512 Channel->ApplicationType = Attributes->ChannelId;
513 }
514
515 /* Initialize all the locks and events */
516 SacInitializeLock(&Channel->ChannelAttributeLock);
517 SacInitializeLock(&Channel->ChannelOBufferLock);
518 SacInitializeLock(&Channel->ChannelIBufferLock);
519 ChannelInitializeEvent(Channel, Attributes, CloseEvent);
520 ChannelInitializeEvent(Channel, Attributes, HasNewDataEvent);
521 ChannelInitializeEvent(Channel, Attributes, LockEvent);
522 ChannelInitializeEvent(Channel, Attributes, RedrawEvent);
523
524 /* Set the name and description */
525 ChannelSetName(Channel, Attributes->NameBuffer);
526 ChannelSetDescription(Channel, Attributes->DescriptionBuffer);
527
528 /* Initialize the function table for the type of channel this is */
530 if (!NT_SUCCESS(Status))
531 {
532 /* This is critical */
533 SAC_DBG(SAC_DBG_INIT, "SAC Create Channel :: Failed to initialize vtable\n");
534 goto FailChannel;
535 }
536
537 /* Now call the channel specific type constructor */
538 Status = Channel->ChannelCreate(Channel);
539 if (!NT_SUCCESS(Status))
540 {
541 /* This is critical */
542 SAC_DBG(SAC_DBG_INIT, "SAC Create Channel :: Failed channel specific initialization\n");
543 goto FailChannel;
544 }
545
546 /* Finally, mark the channel as active */
547 ChannelSetStatus(Channel, Active);
548 return STATUS_SUCCESS;
549
550FailChannel:
551 /* Destroy the channel and return the failure code */
552 Channel->ChannelDestroy(Channel);
553 return Status;
554}
NTSTATUS NTAPI ChannelSetName(IN PSAC_CHANNEL Channel, IN PWCHAR Name)
Definition: channel.c:322
NTSTATUS NTAPI ChannelSetDescription(IN PSAC_CHANNEL Channel, IN PWCHAR Description)
Definition: channel.c:368
NTSTATUS NTAPI ChannelInitializeVTable(IN PSAC_CHANNEL Channel)
Definition: channel.c:405
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
#define SAC_CHANNEL_FLAG_LOCK_EVENT
Definition: sacdrv.h:172
#define SAC_CHANNEL_FLAG_REDRAW_EVENT
Definition: sacdrv.h:173
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
FORCEINLINE VOID SacInitializeLock(IN PSAC_CHANNEL_LOCK Lock)
Definition: sacdrv.h:1252
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT
Definition: sacdrv.h:171
#define ChannelInitializeEvent(Channel, Attributes, x)
Definition: sacdrv.h:70
#define SAC_CHANNEL_FLAG_APPLICATION
Definition: sacdrv.h:174
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_In_ ULONG _In_ BOOLEAN Active
Definition: potypes.h:561

Referenced by ChanMgrCreateChannel().

◆ ChannelDereferenceHandles()

NTSTATUS NTAPI ChannelDereferenceHandles ( IN PSAC_CHANNEL  Channel)

Definition at line 35 of file channel.c.

36{
37 CHECK_PARAMETER(Channel);
38
39 /* Clear the data event */
40 if (Channel->HasNewDataEvent)
41 {
43 HasNewDataEvent,
45 }
46
47 /* Clear the close event */
48 if (Channel->CloseEvent)
49 {
51 CloseEvent,
53 }
54
55 /* Clear the lock event */
56 if (Channel->LockEvent)
57 {
59 LockEvent,
61 }
62
63 /* Clear the redraw event */
64 if (Channel->RedrawEvent)
65 {
67 RedrawEvent,
69 }
70
71 /* All done */
72 return STATUS_SUCCESS;
73}
#define ChannelUninitializeEvent(Channel, x, f)
Definition: sacdrv.h:85

Referenced by ChannelClose(), and ChannelDestroy().

◆ ChannelDestroy()

NTSTATUS NTAPI ChannelDestroy ( IN PSAC_CHANNEL  Channel)

Definition at line 77 of file channel.c.

78{
79 CHECK_PARAMETER(Channel);
80
81 /* Same thing as dereferencing all the handles */
82 return ChannelDereferenceHandles(Channel);
83}

Referenced by RawChannelDestroy(), and VTUTF8ChannelDestroy().

◆ ChannelGetApplicationType()

NTSTATUS NTAPI ChannelGetApplicationType ( IN PSAC_CHANNEL  Channel,
OUT PGUID  ApplicationType 
)

Definition at line 389 of file channel.c.

391{
392 CHECK_PARAMETER1(Channel);
393
394 /* Read the application type GUID */
395 ChannelLockAttributes(Channel);
396 *ApplicationType = Channel->ApplicationType;
398
399 /* Always return success */
400 return STATUS_SUCCESS;
401}
#define ChannelLockAttributes(x)
Definition: sacdrv.h:1336
#define ChannelUnlockAttributes(x)
Definition: sacdrv.h:1337

◆ ChannelGetDescription()

NTSTATUS NTAPI ChannelGetDescription ( IN PSAC_CHANNEL  Channel,
IN PWCHAR Description 
)

Definition at line 343 of file channel.c.

345{
346 CHECK_PARAMETER1(Channel);
348
349 /* Allocate space to hold the description */
350 *Description = SacAllocatePool(sizeof(Channel->DescriptionBuffer), GLOBAL_BLOCK_TAG);
352
353 /* Lock the attributes while we copy the name */
354 ChannelLockAttributes(Channel);
355
356 /* Copy the name and null-terminate it */
357 ASSERT(((wcslen(Channel->DescriptionBuffer) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_DESCRIPTION_SIZE + 1) * sizeof(WCHAR)));
358 wcsncpy(*Description, Channel->DescriptionBuffer, RTL_NUMBER_OF(Channel->DescriptionBuffer)); // bug
360
361 /* Release the lock and return */
363 return STATUS_SUCCESS;
364}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static const WCHAR Description[]
Definition: oid.c:1266
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ASSERT(a)
Definition: mode.c:44
#define UNICODE_NULL
#define SAC_CHANNEL_DESCRIPTION_SIZE
Definition: sacdrv.h:153
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
#define CHECK_ALLOCATION(x)
Definition: sacdrv.h:64
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:142
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ ChannelGetName()

NTSTATUS NTAPI ChannelGetName ( IN PSAC_CHANNEL  Channel,
OUT PWCHAR Name 
)

Definition at line 297 of file channel.c.

299{
300 CHECK_PARAMETER1(Channel);
302
303 /* Allocate space to hold the name */
304 *Name = SacAllocatePool(sizeof(Channel->NameBuffer), GLOBAL_BLOCK_TAG);
306
307 /* Lock the attributes while we copy the name */
308 ChannelLockAttributes(Channel);
309
310 /* Copy the name and null-terminate it */
311 ASSERT(((wcslen(Channel->NameBuffer) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_NAME_SIZE + 1) * sizeof(WCHAR)));
312 wcsncpy(*Name, Channel->NameBuffer, RTL_NUMBER_OF(Channel->NameBuffer)); // bug
314
315 /* Release the lock and return */
317 return STATUS_SUCCESS;
318}
#define SAC_CHANNEL_NAME_SIZE
Definition: sacdrv.h:152

Referenced by ChanMgrGetChannelByName().

◆ ChannelGetStatus()

NTSTATUS NTAPI ChannelGetStatus ( IN PSAC_CHANNEL  Channel,
OUT PSAC_CHANNEL_STATUS  ChannelStatus 
)

Definition at line 222 of file channel.c.

224{
225 CHECK_PARAMETER1(Channel);
226
227 /* Read the status while holding the attribute lock */
228 ChannelLockAttributes(Channel);
229 *ChannelStatus = Channel->ChannelStatus;
231 return STATUS_SUCCESS;
232}

Referenced by ChannelIsActive(), and ChannelIsClosed().

◆ ChannelHasRedrawEvent()

NTSTATUS NTAPI ChannelHasRedrawEvent ( IN PSAC_CHANNEL  Channel,
OUT PBOOLEAN  Present 
)

Definition at line 209 of file channel.c.

211{
212 CHECK_PARAMETER1(Channel);
213 CHECK_PARAMETER2(Present);
214
215 /* Return if the flag is set */
216 *Present = Channel->Flags & SAC_CHANNEL_FLAG_REDRAW_EVENT;
217 return STATUS_SUCCESS;
218}

Referenced by ConMgrDisplayCurrentChannel(), and ConMgrSetCurrentChannel().

◆ ChannelIBufferLength()

ULONG NTAPI ChannelIBufferLength ( IN PSAC_CHANNEL  Channel)

Definition at line 163 of file channel.c.

164{
166
167 /* Get the input buffer length while holding the lock */
168 ChannelLockOBuffer(Channel);
169 Length = Channel->ChannelInputBufferLength(Channel);
170 ChannelUnlockOBuffer(Channel);
171 return Length;
172}
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define ChannelLockOBuffer(x)
Definition: sacdrv.h:1332
#define ChannelUnlockOBuffer(x)
Definition: sacdrv.h:1333
uint32_t ULONG
Definition: typedefs.h:59

Referenced by ConMgrSerialPortConsumer().

◆ ChannelInitializeVTable()

NTSTATUS NTAPI ChannelInitializeVTable ( IN PSAC_CHANNEL  Channel)

Definition at line 405 of file channel.c.

406{
407 /* What kind of channel is this? */
408 switch (Channel->ChannelType)
409 {
410 case VtUtf8:
411 /* Setup the calls for a VT-UTF8 channel */
412 Channel->ChannelCreate = VTUTF8ChannelCreate;
413 Channel->ChannelDestroy = VTUTF8ChannelDestroy;
414 Channel->ChannelOutputFlush = VTUTF8ChannelOFlush;
415 Channel->ChannelOutputEcho = VTUTF8ChannelOEcho;
416 Channel->ChannelOutputWrite = VTUTF8ChannelOWrite;
417 Channel->ChannelOutputRead = VTUTF8ChannelORead;
418 Channel->ChannelInputWrite = VTUTF8ChannelIWrite;
419 Channel->ChannelInputRead = VTUTF8ChannelIRead;
420 Channel->ChannelInputReadLast = VTUTF8ChannelIReadLast;
421 Channel->ChannelInputBufferIsFull = VTUTF8ChannelIBufferIsFull;
422 Channel->ChannelInputBufferLength = VTUTF8ChannelIBufferLength;
423 break;
424
425 case Cmd:
426 /* FIXME: TODO */
427 ASSERT(FALSE);
429
430 case Raw:
431
432 /* Setup the calls for a raw channel */
433 Channel->ChannelCreate = RawChannelCreate;
434 Channel->ChannelDestroy = RawChannelDestroy;
435 Channel->ChannelOutputFlush = RawChannelOFlush;
436 Channel->ChannelOutputEcho = RawChannelOEcho;
437 Channel->ChannelOutputWrite = RawChannelOWrite;
438 Channel->ChannelOutputRead = RawChannelORead;
439 Channel->ChannelInputWrite = RawChannelIWrite;
440 Channel->ChannelInputRead = RawChannelIRead;
441 Channel->ChannelInputReadLast = RawChannelIReadLast;
442 Channel->ChannelInputBufferIsFull = RawChannelIBufferIsFull;
443 Channel->ChannelInputBufferLength = RawChannelIBufferLength;
444 break;
445
446 default:
447 /* Unsupported channel type */
449 }
450
451 /* If we got here, the channel was supported */
452 return STATUS_SUCCESS;
453}
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define FALSE
Definition: types.h:117
ULONG NTAPI RawChannelIBufferLength(IN PSAC_CHANNEL Channel)
Definition: rawchan.c:310
NTSTATUS NTAPI RawChannelIRead(IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, IN PULONG ReturnBufferSize)
Definition: rawchan.c:246
NTSTATUS NTAPI RawChannelOWrite(IN PSAC_CHANNEL Channel, IN PCHAR String, IN ULONG Length)
Definition: rawchan.c:195
NTSTATUS NTAPI RawChannelDestroy(IN PSAC_CHANNEL Channel)
Definition: rawchan.c:39
NTSTATUS NTAPI RawChannelOEcho(IN PSAC_CHANNEL Channel, IN PCHAR String, IN ULONG Length)
Definition: rawchan.c:115
WCHAR NTAPI RawChannelIReadLast(IN PSAC_CHANNEL Channel)
Definition: rawchan.c:320
NTSTATUS NTAPI RawChannelCreate(IN PSAC_CHANNEL Channel)
Definition: rawchan.c:17
NTSTATUS NTAPI RawChannelIWrite(IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize)
Definition: rawchan.c:343
NTSTATUS NTAPI RawChannelIBufferIsFull(IN PSAC_CHANNEL Channel, OUT PBOOLEAN BufferStatus)
Definition: rawchan.c:297
NTSTATUS NTAPI RawChannelORead(IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, OUT PULONG ByteCount)
Definition: rawchan.c:58
NTSTATUS NTAPI RawChannelOFlush(IN PSAC_CHANNEL Channel)
Definition: rawchan.c:172
NTSTATUS NTAPI VTUTF8ChannelOEcho(IN PSAC_CHANNEL Channel, IN PCHAR String, IN ULONG Length)
Definition: vtutf8chan.c:1077
NTSTATUS NTAPI VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
Definition: vtutf8chan.c:725
NTSTATUS NTAPI VTUTF8ChannelIWrite(IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize)
Definition: vtutf8chan.c:1339
NTSTATUS NTAPI VTUTF8ChannelORead(IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, OUT PULONG ByteCount)
Definition: vtutf8chan.c:714
NTSTATUS NTAPI VTUTF8ChannelCreate(IN PSAC_CHANNEL Channel)
Definition: vtutf8chan.c:677
@ Cmd
Definition: sacdrv.h:278
@ Raw
Definition: sacdrv.h:279
@ VtUtf8
Definition: sacdrv.h:277
NTSTATUS NTAPI VTUTF8ChannelIBufferIsFull(IN PSAC_CHANNEL Channel, OUT PBOOLEAN BufferStatus)
Definition: vtutf8chan.c:1291
ULONG NTAPI VTUTF8ChannelIBufferLength(IN PSAC_CHANNEL Channel)
Definition: vtutf8chan.c:1303
NTSTATUS NTAPI VTUTF8ChannelOWrite(IN PSAC_CHANNEL Channel, IN PCHAR String, IN ULONG Length)
Definition: vtutf8chan.c:1167
NTSTATUS NTAPI VTUTF8ChannelIRead(IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, IN PULONG ReturnBufferSize)
Definition: vtutf8chan.c:1234
WCHAR NTAPI VTUTF8ChannelIReadLast(IN PSAC_CHANNEL Channel)
Definition: vtutf8chan.c:1313
NTSTATUS NTAPI VTUTF8ChannelDestroy(IN PSAC_CHANNEL Channel)
Definition: vtutf8chan.c:702
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by ChannelCreate().

◆ ChannelIRead()

NTSTATUS NTAPI ChannelIRead ( IN PSAC_CHANNEL  Channel,
IN PCHAR  Buffer,
IN ULONG  BufferSize,
IN OUT PULONG  ResultBufferSize 
)

Definition at line 131 of file channel.c.

135{
137
138 /* Read the input buffer while holding the lock */
139 ChannelLockIBuffer(Channel);
140 Status = Channel->ChannelInputRead(Channel,
141 Buffer,
143 ResultBufferSize);
144 ChannelUnlockIBuffer(Channel);
145 return Status;
146}
Definition: bufpool.h:45
#define ChannelLockIBuffer(x)
Definition: sacdrv.h:1334
#define ChannelUnlockIBuffer(x)
Definition: sacdrv.h:1335
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by ConMgrSerialPortConsumer().

◆ ChannelIReadLast()

WCHAR NTAPI ChannelIReadLast ( IN PSAC_CHANNEL  Channel)

Definition at line 150 of file channel.c.

151{
152 WCHAR LastChar;
153
154 /* Read the last character while holding the lock */
155 ChannelLockIBuffer(Channel);
156 LastChar = Channel->ChannelInputReadLast(Channel);
157 ChannelUnlockIBuffer(Channel);
158 return LastChar;
159}

Referenced by ConMgrSerialPortConsumer().

◆ ChannelIsActive()

BOOLEAN NTAPI ChannelIsActive ( IN PSAC_CHANNEL  Channel)

Definition at line 250 of file channel.c.

251{
252 SAC_CHANNEL_STATUS ChannelStatus;
254
255 /* Get the status */
256 if (!NT_SUCCESS(ChannelGetStatus(Channel, &ChannelStatus)))
257 {
258 /* We couldn't even do that, assume it's inactive */
259 IsActive = FALSE;
260 }
261 else
262 {
263 /* Check if the status shows activity */
264 IsActive = (ChannelStatus == Active);
265 }
266
267 /* Return the state */
268 return IsActive;
269}
unsigned char BOOLEAN
_In_ BOOLEAN IsActive
Definition: cdrom.h:1427
NTSTATUS NTAPI ChannelGetStatus(IN PSAC_CHANNEL Channel, OUT PSAC_CHANNEL_STATUS ChannelStatus)
Definition: channel.c:222
enum _SAC_CHANNEL_STATUS SAC_CHANNEL_STATUS

Referenced by ChanMgrCloseChannel(), ChanMgrGetChannelCount(), ChanMgrGetNextActiveChannel(), ChanMgrReleaseChannel(), and ChannelDereferenceToZeroByIndex().

◆ ChannelIsClosed()

BOOLEAN NTAPI ChannelIsClosed ( IN PSAC_CHANNEL  Channel)

Definition at line 273 of file channel.c.

274{
275 SAC_CHANNEL_STATUS ChannelStatus;
276 BOOLEAN IsClosed;
277
278 /* Get the status */
279 if (!NT_SUCCESS(ChannelGetStatus(Channel, &ChannelStatus)))
280 {
281 /* We couldn't even do that, assume it's inactive */
282 IsClosed = FALSE;
283 }
284 else
285 {
286 /* Check if the status shows activity */
287 IsClosed = ((ChannelStatus == Inactive) &&
288 (Channel->ChannelHasNewOBufferData));
289 }
290
291 /* Return the state */
292 return IsClosed;
293}

◆ ChannelIsEqual()

BOOLEAN NTAPI ChannelIsEqual ( IN PSAC_CHANNEL  Channel,
IN PSAC_CHANNEL_ID  ChannelId 
)

Definition at line 25 of file channel.c.

27{
28 /* Check if the GUIDs match */
29 return IsEqualGUIDAligned(&Channel->ChannelId.ChannelGuid,
30 &ChannelId->ChannelGuid);
31}
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

Referenced by ChanMgrGetByHandle(), and ConMgrIsWriteEnabled().

◆ ChannelIsValidType()

BOOLEAN NTAPI ChannelIsValidType ( IN SAC_CHANNEL_TYPE  ChannelType)

Definition at line 17 of file channel.c.

18{
19 /* Check if the type is valid */
20 return ((ChannelType >= VtUtf8) && (ChannelType <= Raw));
21}

◆ ChannelIWrite()

NTSTATUS NTAPI ChannelIWrite ( IN PSAC_CHANNEL  Channel,
IN PCHAR  Buffer,
IN ULONG  BufferSize 
)

Definition at line 116 of file channel.c.

119{
121
122 /* Write into the input buffer while holding the lock */
123 ChannelLockIBuffer(Channel);
124 Status = Channel->ChannelInputWrite(Channel, Buffer, BufferSize);
125 ChannelUnlockIBuffer(Channel);
126 return Status;
127}

Referenced by ConMgrSerialPortConsumer().

◆ ChannelOFlush()

NTSTATUS NTAPI ChannelOFlush ( IN PSAC_CHANNEL  Channel)

Definition at line 103 of file channel.c.

104{
106
107 /* While holding the output lock, flush to the output buffer */
108 ChannelLockOBuffer(Channel);
109 Status = Channel->ChannelOutputFlush(Channel);
110 ChannelUnlockOBuffer(Channel);
111 return Status;
112}

Referenced by ConMgrDisplayCurrentChannel().

◆ ChannelOWrite()

NTSTATUS NTAPI ChannelOWrite ( IN PSAC_CHANNEL  Channel,
IN PCHAR  Buffer,
IN ULONG  BufferSize 
)

Definition at line 87 of file channel.c.

90{
93
94 /* While holding the output lock, write to the output buffer */
95 ChannelLockOBuffer(Channel);
96 Status = Channel->ChannelOutputWrite(Channel, Buffer, BufferSize);
97 ChannelUnlockOBuffer(Channel);
98 return Status;
99}
#define SAC_OBUFFER_SIZE
Definition: sacdrv.h:151
#define CHECK_PARAMETER3(x)
Definition: sacdrv.h:60

Referenced by SacPutString().

◆ ChannelSetDescription()

NTSTATUS NTAPI ChannelSetDescription ( IN PSAC_CHANNEL  Channel,
IN PWCHAR  Description 
)

Definition at line 368 of file channel.c.

370{
371 CHECK_PARAMETER1(Channel);
373
374 /* Lock the attributes while we copy the name */
375 ChannelLockAttributes(Channel);
376
377 /* Copy the name and null-terminate it */
378 ASSERT(((wcslen(Description) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_NAME_SIZE + 1) * sizeof(WCHAR)));
379 wcsncpy(Channel->DescriptionBuffer, Description, RTL_NUMBER_OF(Channel->DescriptionBuffer)); // bug
380 Channel->DescriptionBuffer[SAC_CHANNEL_DESCRIPTION_SIZE] = UNICODE_NULL;
381
382 /* Release the lock and return */
384 return STATUS_SUCCESS;
385}

Referenced by ChannelCreate().

◆ ChannelSetLockEvent()

NTSTATUS NTAPI ChannelSetLockEvent ( IN PSAC_CHANNEL  Channel)

Definition at line 187 of file channel.c.

188{
190
191 /* Set the event */
192 ChannelSetEvent(Channel, LockEvent);
193 return Status;
194}

◆ ChannelSetName()

NTSTATUS NTAPI ChannelSetName ( IN PSAC_CHANNEL  Channel,
IN PWCHAR  Name 
)

Definition at line 322 of file channel.c.

324{
325 CHECK_PARAMETER1(Channel);
327
328 /* Lock the attributes while we copy the name */
329 ChannelLockAttributes(Channel);
330
331 /* Copy the name and null-terminate it */
332 ASSERT(((wcslen(Name) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_NAME_SIZE + 1) * sizeof(WCHAR)));
333 wcsncpy(Channel->NameBuffer, Name, RTL_NUMBER_OF(Channel->NameBuffer)); // bug
334 Channel->NameBuffer[SAC_CHANNEL_NAME_SIZE] = UNICODE_NULL;
335
336 /* Release the lock and return */
338 return STATUS_SUCCESS;
339}

Referenced by ChannelCreate().

◆ ChannelSetRedrawEvent()

NTSTATUS NTAPI ChannelSetRedrawEvent ( IN PSAC_CHANNEL  Channel)

Definition at line 176 of file channel.c.

177{
179
180 /* Set the event */
181 ChannelSetEvent(Channel, RedrawEvent);
182 return Status;
183}

Referenced by ConMgrDisplayCurrentChannel().

◆ ChannelSetStatus()

NTSTATUS NTAPI ChannelSetStatus ( IN PSAC_CHANNEL  Channel,
IN SAC_CHANNEL_STATUS  ChannelStatus 
)

Definition at line 236 of file channel.c.

238{
239 CHECK_PARAMETER1(Channel);
240
241 /* Read the status while holding the attribute lock */
242 ChannelLockAttributes(Channel);
243 Channel->ChannelStatus = ChannelStatus;
245 return STATUS_SUCCESS;
246}

Referenced by ChannelClose(), and ChannelCreate().