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