2011-06-17 11:04:45 +00:00
|
|
|
/*
|
2013-08-06 01:12:08 +00:00
|
|
|
* PROJECT: ReactOS Drivers
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: drivers/sac/driver/dispatch.c
|
|
|
|
* PURPOSE: Driver for the Server Administration Console (SAC) for EMS
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
2011-06-17 11:04:45 +00:00
|
|
|
*/
|
|
|
|
|
2013-10-13 19:40:34 +00:00
|
|
|
/* INCLUDES *******************************************************************/
|
2011-06-17 11:04:45 +00:00
|
|
|
|
|
|
|
#include "sacdrv.h"
|
|
|
|
|
2013-10-13 19:40:34 +00:00
|
|
|
/* GLOBALS ********************************************************************/
|
2011-06-17 11:04:45 +00:00
|
|
|
|
2013-08-18 17:47:19 +00:00
|
|
|
LONG TimerDpcCount;
|
|
|
|
|
2013-10-13 19:40:34 +00:00
|
|
|
/* FUNCTIONS ******************************************************************/
|
2011-06-17 11:04:45 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2013-08-06 01:12:08 +00:00
|
|
|
DispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp)
|
2011-06-17 11:04:45 +00:00
|
|
|
{
|
2013-08-06 01:12:08 +00:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2011-06-17 11:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2013-08-06 01:12:08 +00:00
|
|
|
NTAPI
|
|
|
|
DispatchShutdownControl(IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp)
|
2011-06-17 11:04:45 +00:00
|
|
|
{
|
2013-08-06 01:12:08 +00:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2011-06-17 11:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2013-08-06 01:12:08 +00:00
|
|
|
NTAPI
|
|
|
|
DispatchCreate(IN PSAC_DEVICE_EXTENSION DeviceExtension,
|
|
|
|
IN PIRP Irp)
|
2011-06-17 11:04:45 +00:00
|
|
|
{
|
2013-08-06 01:12:08 +00:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2011-06-17 11:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2013-08-06 01:12:08 +00:00
|
|
|
NTAPI
|
|
|
|
DispatchClose(IN PSAC_DEVICE_EXTENSION DeviceExtension,
|
|
|
|
IN PIRP Irp)
|
2011-06-17 11:04:45 +00:00
|
|
|
{
|
2013-08-06 01:12:08 +00:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2011-06-17 11:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
2013-08-06 01:12:08 +00:00
|
|
|
NTAPI
|
|
|
|
Dispatch(IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PIRP Irp)
|
2011-06-17 11:04:45 +00:00
|
|
|
{
|
2013-08-06 01:12:08 +00:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2011-06-17 11:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2013-08-06 01:12:08 +00:00
|
|
|
NTAPI
|
|
|
|
TimerDpcRoutine(IN PKDPC Dpc,
|
|
|
|
IN PVOID DeferredContext,
|
|
|
|
IN PVOID SystemArgument1,
|
|
|
|
IN PVOID SystemArgument2)
|
2011-06-17 11:04:45 +00:00
|
|
|
{
|
2013-08-18 17:47:19 +00:00
|
|
|
HEADLESS_RSP_GET_BYTE ByteValue;
|
2018-04-23 09:27:49 +00:00
|
|
|
SIZE_T ValueSize;
|
2013-08-18 17:47:19 +00:00
|
|
|
BOOLEAN GotChar;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PSAC_DEVICE_EXTENSION SacExtension;
|
|
|
|
|
|
|
|
/* Update our counter */
|
|
|
|
_InterlockedExchangeAdd(&TimerDpcCount, 1);
|
|
|
|
|
|
|
|
/* Set defaults and loop for new characters */
|
|
|
|
GotChar = FALSE;
|
|
|
|
ValueSize = sizeof(ByteValue);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* Ask the kernel for a byte */
|
|
|
|
Status = HeadlessDispatch(HeadlessCmdGetByte,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
&ByteValue,
|
|
|
|
&ValueSize);
|
|
|
|
|
|
|
|
/* Break out if there's nothing interesting */
|
|
|
|
if (!NT_SUCCESS(Status)) break;
|
|
|
|
if (!ByteValue.Value) break;
|
2011-06-17 11:04:45 +00:00
|
|
|
|
2013-08-18 17:47:19 +00:00
|
|
|
/* Update the serial port buffer */
|
|
|
|
SerialPortBuffer[SerialPortProducerIndex] = ByteValue.Value;
|
|
|
|
GotChar = TRUE;
|
|
|
|
|
|
|
|
/* Update the index, let it roll-over if needed */
|
|
|
|
_InterlockedExchange(&SerialPortProducerIndex,
|
|
|
|
(SerialPortProducerIndex + 1) &
|
|
|
|
(SAC_SERIAL_PORT_BUFFER_SIZE - 1));
|
|
|
|
} while (ByteValue.Value);
|
|
|
|
|
|
|
|
/* Did we get anything */
|
|
|
|
if (GotChar)
|
|
|
|
{
|
|
|
|
/* Signal the worker thread that there is work to do */
|
|
|
|
SacExtension = DeferredContext;
|
|
|
|
KeSetEvent(&SacExtension->Event, SacExtension->PriorityBoost, FALSE);
|
|
|
|
}
|
2011-06-17 11:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2013-08-06 01:12:08 +00:00
|
|
|
NTAPI
|
|
|
|
UnloadHandler(IN PDRIVER_OBJECT DriverObject)
|
2011-06-17 11:04:45 +00:00
|
|
|
{
|
2013-08-06 01:12:08 +00:00
|
|
|
PDEVICE_OBJECT DeviceObject, NextDevice;
|
|
|
|
SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC UnloadHandler: Entering.\n");
|
|
|
|
|
2016-11-13 15:31:39 +00:00
|
|
|
/* Go over every device part of the driver */
|
2013-08-06 01:12:08 +00:00
|
|
|
DeviceObject = DriverObject->DeviceObject;
|
|
|
|
while (DeviceObject)
|
|
|
|
{
|
|
|
|
/* Free and delete the information about this device */
|
|
|
|
NextDevice = DeviceObject->NextDevice;
|
|
|
|
FreeDeviceData(DeviceObject);
|
|
|
|
IoDeleteDevice(DeviceObject);
|
|
|
|
|
|
|
|
/* Move on to the next one */
|
|
|
|
DeviceObject = NextDevice;
|
|
|
|
}
|
2011-06-17 11:04:45 +00:00
|
|
|
|
2013-08-06 01:12:08 +00:00
|
|
|
/* Free the driver data and exit */
|
|
|
|
FreeGlobalData();
|
|
|
|
SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC UnloadHandler: Exiting.\n");
|
2011-06-17 11:04:45 +00:00
|
|
|
}
|