2 * PROJECT: ReactOS Drivers
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/sac/driver/init.c
5 * PURPOSE: Driver for the Server Administration Console (SAC) for EMS
6 * PROGRAMMERS: ReactOS Portable Systems Group
9 /* INCLUDES *******************************************************************/
13 /* FUNCTIONS ******************************************************************/
17 DriverEntry(IN PDRIVER_OBJECT DriverObject
,
18 IN PUNICODE_STRING RegistryPath
)
20 HEADLESS_RSP_QUERY_INFO HeadlessInformation
;
21 ULONG InfoSize
= sizeof(HeadlessInformation
);
23 UNICODE_STRING DriverName
;
24 PDEVICE_OBJECT DeviceObject
;
25 PSAC_DEVICE_EXTENSION DeviceExtension
;
27 SAC_DBG(SAC_DBG_ENTRY_EXIT
, "Entering.\n");
29 /* Check if EMS is enabled in the kernel */
30 HeadlessDispatch(HeadlessCmdQueryInformation
,
35 if ((HeadlessInformation
.Serial
.TerminalType
!= HeadlessUndefinedPortType
) &&
36 ((HeadlessInformation
.Serial
.TerminalType
!= HeadlessSerialPort
) ||
37 (HeadlessInformation
.Serial
.TerminalAttached
)))
39 /* It is, so create the device */
40 RtlInitUnicodeString(&DriverName
, L
"\\Device\\SAC");
41 Status
= IoCreateDevice(DriverObject
,
42 sizeof(SAC_DEVICE_EXTENSION
),
45 FILE_DEVICE_SECURE_OPEN
,
48 if (NT_SUCCESS(Status
))
50 /* Setup the device extension */
51 DeviceExtension
= DeviceObject
->DeviceExtension
;
52 DeviceExtension
->Initialized
= FALSE
;
54 /* Initialize the driver object */
55 RtlFillMemoryUlong(DriverObject
->MajorFunction
,
56 RTL_NUMBER_OF(DriverObject
->MajorFunction
),
58 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = DispatchDeviceControl
;
59 DriverObject
->MajorFunction
[IRP_MJ_SHUTDOWN
] = DispatchShutdownControl
;
60 DriverObject
->FastIoDispatch
= NULL
;
61 DriverObject
->DriverUnload
= UnloadHandler
;
63 /* Initialize driver data */
64 if (InitializeGlobalData(RegistryPath
, DriverObject
))
66 /* Initialize device data */
67 if (InitializeDeviceData(DeviceObject
))
69 /* We're all good, register a shutdown notification */
70 IoRegisterShutdownNotification(DeviceObject
);
75 /* One of the initializations failed, bail out */
76 Status
= STATUS_INSUFFICIENT_RESOURCES
;
80 /* Print a debug statement if enabled */
81 SAC_DBG(SAC_DBG_INIT
, "unable to create device object: %X\n", Status
);
84 /* Free any data we may have allocated and exit with failure */
86 SAC_DBG(SAC_DBG_ENTRY_EXIT
, "Exiting with status 0x%x\n", Status
);
90 /* EMS is not enabled */
91 return STATUS_PORT_DISCONNECTED
;