Fix the FSDs to use the INIT_SECTION-style and add the alloc_text-s required for...
[reactos.git] / reactos / drivers / filesystems / cdfs / cdfs.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2002, 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: drivers/filesystems/cdfs/cdfs.c
23 * PURPOSE: CDROM (ISO 9660) filesystem driver
24 * PROGRAMMER: Art Yerkes
25 * Eric Kohl
26 */
27
28 /* INCLUDES *****************************************************************/
29
30 #include "cdfs.h"
31
32 #define NDEBUG
33 #include <debug.h>
34
35 #if defined(ALLOC_PRAGMA)
36 #pragma alloc_text(INIT, DriverEntry)
37 #endif
38
39 /* GLOBALS ******************************************************************/
40
41 PCDFS_GLOBAL_DATA CdfsGlobalData;
42
43
44 /* FUNCTIONS ****************************************************************/
45
46 INIT_SECTION
47 NTSTATUS NTAPI
48 DriverEntry(PDRIVER_OBJECT DriverObject,
49 PUNICODE_STRING RegistryPath)
50 /*
51 * FUNCTION: Called by the system to initialize the driver
52 * ARGUMENTS:
53 * DriverObject = object describing this driver
54 * RegistryPath = path to our configuration entries
55 * RETURNS: Success or failure
56 */
57 {
58 PDEVICE_OBJECT DeviceObject;
59 NTSTATUS Status;
60 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Cdfs");
61
62 UNREFERENCED_PARAMETER(RegistryPath);
63
64 DPRINT("CDFS 0.0.3\n");
65
66 Status = IoCreateDevice(DriverObject,
67 sizeof(CDFS_GLOBAL_DATA),
68 &DeviceName,
69 FILE_DEVICE_CD_ROM_FILE_SYSTEM,
70 0,
71 FALSE,
72 &DeviceObject);
73 if (!NT_SUCCESS(Status))
74 {
75 return(Status);
76 }
77
78 /* Initialize global data */
79 CdfsGlobalData = DeviceObject->DeviceExtension;
80 RtlZeroMemory(CdfsGlobalData,
81 sizeof(CDFS_GLOBAL_DATA));
82 CdfsGlobalData->DriverObject = DriverObject;
83 CdfsGlobalData->DeviceObject = DeviceObject;
84
85 /* Initialize driver data */
86 DeviceObject->Flags = DO_DIRECT_IO;
87 DriverObject->MajorFunction[IRP_MJ_CLOSE] = CdfsFsdDispatch;
88 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = CdfsFsdDispatch;
89 DriverObject->MajorFunction[IRP_MJ_CREATE] = CdfsFsdDispatch;
90 DriverObject->MajorFunction[IRP_MJ_READ] = CdfsFsdDispatch;
91 DriverObject->MajorFunction[IRP_MJ_WRITE] = CdfsFsdDispatch;
92 DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = CdfsFsdDispatch;
93 DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = CdfsFsdDispatch;
94 DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = CdfsFsdDispatch;
95 DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = CdfsFsdDispatch;
96 DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = CdfsFsdDispatch;
97 DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = CdfsFsdDispatch;
98 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CdfsFsdDispatch;
99
100 CdfsGlobalData->FastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
101 CdfsGlobalData->FastIoDispatch.FastIoCheckIfPossible = CdfsFastIoCheckIfPossible;
102 CdfsGlobalData->FastIoDispatch.FastIoRead = CdfsFastIoRead;
103 CdfsGlobalData->FastIoDispatch.FastIoWrite = CdfsFastIoWrite;
104 DriverObject->FastIoDispatch = &CdfsGlobalData->FastIoDispatch;
105
106 /* Initialize lookaside list for IRP contexts */
107 ExInitializeNPagedLookasideList(&CdfsGlobalData->IrpContextLookasideList,
108 NULL, NULL, 0, sizeof(CDFS_IRP_CONTEXT), 'PRIC', 0);
109
110 DriverObject->DriverUnload = NULL;
111
112 /* Cache manager */
113 CdfsGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = CdfsAcquireForLazyWrite;
114 CdfsGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = CdfsReleaseFromLazyWrite;
115 CdfsGlobalData->CacheMgrCallbacks.AcquireForReadAhead = CdfsAcquireForLazyWrite;
116 CdfsGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = CdfsReleaseFromLazyWrite;
117
118 DeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM;
119
120 IoRegisterFileSystem(DeviceObject);
121 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
122
123 return(STATUS_SUCCESS);
124 }
125
126