1c2c66affSColin Finck /*
2c2c66affSColin Finck * PROJECT: ReactOS Drivers
3c2c66affSColin Finck * LICENSE: BSD - See COPYING.ARM in the top level directory
4c2c66affSColin Finck * FILE: drivers/sac/driver/dispatch.c
5c2c66affSColin Finck * PURPOSE: Driver for the Server Administration Console (SAC) for EMS
6c2c66affSColin Finck * PROGRAMMERS: ReactOS Portable Systems Group
7c2c66affSColin Finck */
8c2c66affSColin Finck
9c2c66affSColin Finck /* INCLUDES *******************************************************************/
10c2c66affSColin Finck
11c2c66affSColin Finck #include "sacdrv.h"
12c2c66affSColin Finck
13c2c66affSColin Finck /* GLOBALS ********************************************************************/
14c2c66affSColin Finck
15c2c66affSColin Finck LONG TimerDpcCount;
16c2c66affSColin Finck
17c2c66affSColin Finck /* FUNCTIONS ******************************************************************/
18c2c66affSColin Finck
19c2c66affSColin Finck NTSTATUS
20c2c66affSColin Finck NTAPI
DispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)21c2c66affSColin Finck DispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject,
22c2c66affSColin Finck IN PIRP Irp)
23c2c66affSColin Finck {
24c2c66affSColin Finck return STATUS_NOT_IMPLEMENTED;
25c2c66affSColin Finck }
26c2c66affSColin Finck
27c2c66affSColin Finck NTSTATUS
28c2c66affSColin Finck NTAPI
DispatchShutdownControl(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)29c2c66affSColin Finck DispatchShutdownControl(IN PDEVICE_OBJECT DeviceObject,
30c2c66affSColin Finck IN PIRP Irp)
31c2c66affSColin Finck {
32c2c66affSColin Finck return STATUS_NOT_IMPLEMENTED;
33c2c66affSColin Finck }
34c2c66affSColin Finck
35c2c66affSColin Finck NTSTATUS
36c2c66affSColin Finck NTAPI
DispatchCreate(IN PSAC_DEVICE_EXTENSION DeviceExtension,IN PIRP Irp)37c2c66affSColin Finck DispatchCreate(IN PSAC_DEVICE_EXTENSION DeviceExtension,
38c2c66affSColin Finck IN PIRP Irp)
39c2c66affSColin Finck {
40c2c66affSColin Finck return STATUS_NOT_IMPLEMENTED;
41c2c66affSColin Finck }
42c2c66affSColin Finck
43c2c66affSColin Finck NTSTATUS
44c2c66affSColin Finck NTAPI
DispatchClose(IN PSAC_DEVICE_EXTENSION DeviceExtension,IN PIRP Irp)45c2c66affSColin Finck DispatchClose(IN PSAC_DEVICE_EXTENSION DeviceExtension,
46c2c66affSColin Finck IN PIRP Irp)
47c2c66affSColin Finck {
48c2c66affSColin Finck return STATUS_NOT_IMPLEMENTED;
49c2c66affSColin Finck }
50c2c66affSColin Finck
51c2c66affSColin Finck NTSTATUS
52c2c66affSColin Finck NTAPI
Dispatch(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)53c2c66affSColin Finck Dispatch(IN PDEVICE_OBJECT DeviceObject,
54c2c66affSColin Finck IN PIRP Irp)
55c2c66affSColin Finck {
56c2c66affSColin Finck return STATUS_NOT_IMPLEMENTED;
57c2c66affSColin Finck }
58c2c66affSColin Finck
59c2c66affSColin Finck VOID
60c2c66affSColin Finck NTAPI
TimerDpcRoutine(IN PKDPC Dpc,IN PVOID DeferredContext,IN PVOID SystemArgument1,IN PVOID SystemArgument2)61c2c66affSColin Finck TimerDpcRoutine(IN PKDPC Dpc,
62c2c66affSColin Finck IN PVOID DeferredContext,
63c2c66affSColin Finck IN PVOID SystemArgument1,
64c2c66affSColin Finck IN PVOID SystemArgument2)
65c2c66affSColin Finck {
66c2c66affSColin Finck HEADLESS_RSP_GET_BYTE ByteValue;
67*9e066abeSTimo Kreuzer SIZE_T ValueSize;
68c2c66affSColin Finck BOOLEAN GotChar;
69c2c66affSColin Finck NTSTATUS Status;
70c2c66affSColin Finck PSAC_DEVICE_EXTENSION SacExtension;
71c2c66affSColin Finck
72c2c66affSColin Finck /* Update our counter */
73c2c66affSColin Finck _InterlockedExchangeAdd(&TimerDpcCount, 1);
74c2c66affSColin Finck
75c2c66affSColin Finck /* Set defaults and loop for new characters */
76c2c66affSColin Finck GotChar = FALSE;
77c2c66affSColin Finck ValueSize = sizeof(ByteValue);
78c2c66affSColin Finck do
79c2c66affSColin Finck {
80c2c66affSColin Finck /* Ask the kernel for a byte */
81c2c66affSColin Finck Status = HeadlessDispatch(HeadlessCmdGetByte,
82c2c66affSColin Finck NULL,
83c2c66affSColin Finck 0,
84c2c66affSColin Finck &ByteValue,
85c2c66affSColin Finck &ValueSize);
86c2c66affSColin Finck
87c2c66affSColin Finck /* Break out if there's nothing interesting */
88c2c66affSColin Finck if (!NT_SUCCESS(Status)) break;
89c2c66affSColin Finck if (!ByteValue.Value) break;
90c2c66affSColin Finck
91c2c66affSColin Finck /* Update the serial port buffer */
92c2c66affSColin Finck SerialPortBuffer[SerialPortProducerIndex] = ByteValue.Value;
93c2c66affSColin Finck GotChar = TRUE;
94c2c66affSColin Finck
95c2c66affSColin Finck /* Update the index, let it roll-over if needed */
96c2c66affSColin Finck _InterlockedExchange(&SerialPortProducerIndex,
97c2c66affSColin Finck (SerialPortProducerIndex + 1) &
98c2c66affSColin Finck (SAC_SERIAL_PORT_BUFFER_SIZE - 1));
99c2c66affSColin Finck } while (ByteValue.Value);
100c2c66affSColin Finck
101c2c66affSColin Finck /* Did we get anything */
102c2c66affSColin Finck if (GotChar)
103c2c66affSColin Finck {
104c2c66affSColin Finck /* Signal the worker thread that there is work to do */
105c2c66affSColin Finck SacExtension = DeferredContext;
106c2c66affSColin Finck KeSetEvent(&SacExtension->Event, SacExtension->PriorityBoost, FALSE);
107c2c66affSColin Finck }
108c2c66affSColin Finck }
109c2c66affSColin Finck
110c2c66affSColin Finck VOID
111c2c66affSColin Finck NTAPI
UnloadHandler(IN PDRIVER_OBJECT DriverObject)112c2c66affSColin Finck UnloadHandler(IN PDRIVER_OBJECT DriverObject)
113c2c66affSColin Finck {
114c2c66affSColin Finck PDEVICE_OBJECT DeviceObject, NextDevice;
115c2c66affSColin Finck SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC UnloadHandler: Entering.\n");
116c2c66affSColin Finck
117c2c66affSColin Finck /* Go over every device part of the driver */
118c2c66affSColin Finck DeviceObject = DriverObject->DeviceObject;
119c2c66affSColin Finck while (DeviceObject)
120c2c66affSColin Finck {
121c2c66affSColin Finck /* Free and delete the information about this device */
122c2c66affSColin Finck NextDevice = DeviceObject->NextDevice;
123c2c66affSColin Finck FreeDeviceData(DeviceObject);
124c2c66affSColin Finck IoDeleteDevice(DeviceObject);
125c2c66affSColin Finck
126c2c66affSColin Finck /* Move on to the next one */
127c2c66affSColin Finck DeviceObject = NextDevice;
128c2c66affSColin Finck }
129c2c66affSColin Finck
130c2c66affSColin Finck /* Free the driver data and exit */
131c2c66affSColin Finck FreeGlobalData();
132c2c66affSColin Finck SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC UnloadHandler: Exiting.\n");
133c2c66affSColin Finck }
134