ReactOS  0.4.15-dev-1397-g19779b3
mmc.c File Reference
#include "stddef.h"
#include "string.h"
#include "ntddk.h"
#include "ntddstor.h"
#include "cdrom.h"
#include "mmc.h"
#include "scratch.h"
Include dependency graph for mmc.c:

Go to the source code of this file.

Functions

 _IRQL_requires_max_ (APC_LEVEL)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL)
 

Function Documentation

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 56 of file mmc.c.

76 {
77  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
78  PCDROM_DATA cddata = &(deviceExtension->DeviceAdditionalData);
79  PCDROM_MMC_EXTENSION mmcData = &cddata->Mmc;
80 
81  PAGED_CODE();
82 
83  if (mmcData->CapabilitiesIrp)
84  {
85  IoFreeIrp(mmcData->CapabilitiesIrp);
86  mmcData->CapabilitiesIrp = NULL;
87  }
88  if (mmcData->CapabilitiesMdl)
89  {
90  IoFreeMdl(mmcData->CapabilitiesMdl);
91  mmcData->CapabilitiesMdl = NULL;
92  }
93  if (mmcData->CapabilitiesBuffer)
94  {
95  ExFreePool(mmcData->CapabilitiesBuffer);
96  mmcData->CapabilitiesBuffer = NULL;
97  }
98  if (mmcData->CapabilitiesRequest)
99  {
100  WdfObjectDelete(mmcData->CapabilitiesRequest);
101  mmcData->CapabilitiesRequest = NULL;
102  }
103  mmcData->CapabilitiesBufferSize = 0;
104  mmcData->IsMmc = FALSE;
105  mmcData->WriteAllowed = FALSE;
106 
107  return;
108 }
PMDL CapabilitiesMdl
Definition: cdrom.h:270
BOOLEAN WriteAllowed
Definition: cdrom.h:250
CDROM_DATA DeviceAdditionalData
Definition: cdrom.h:598
WDFREQUEST CapabilitiesRequest
Definition: cdrom.h:265
#define FALSE
Definition: types.h:117
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ULONG CapabilitiesBufferSize
Definition: cdrom.h:269
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define NULL
Definition: types.h:112
CDROM_MMC_EXTENSION Mmc
Definition: cdrom.h:341
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
PIRP CapabilitiesIrp
Definition: cdrom.h:264
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PAGED_CODE()

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 111 of file mmc.c.

131 {
133  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
134  PCDROM_DATA cddata = &(deviceExtension->DeviceAdditionalData);
135  PCDROM_MMC_EXTENSION mmcData = &(cddata->Mmc);
136  WDF_OBJECT_ATTRIBUTES attributes = {0};
137 
138  PAGED_CODE();
139 
140  NT_ASSERT(mmcData->CapabilitiesBuffer == NULL);
141  NT_ASSERT(mmcData->CapabilitiesBufferSize == 0);
142 
143  // allocate the buffer and set the buffer size.
144  // retrieve drive configuration information.
145  status = DeviceGetConfigurationWithAlloc(Device,
146  &mmcData->CapabilitiesBuffer,
147  &mmcData->CapabilitiesBufferSize,
150  if (!NT_SUCCESS(status))
151  {
152  NT_ASSERT(mmcData->CapabilitiesBuffer == NULL);
153  NT_ASSERT(mmcData->CapabilitiesBufferSize == 0);
154  return status;
155  }
156 
157  NT_ASSERT(mmcData->CapabilitiesBuffer != NULL);
158  NT_ASSERT(mmcData->CapabilitiesBufferSize != 0);
159 
160  // Create an MDL over the new Buffer (allocated by DeviceGetConfiguration)
161  mmcData->CapabilitiesMdl = IoAllocateMdl(mmcData->CapabilitiesBuffer,
162  mmcData->CapabilitiesBufferSize,
163  FALSE, FALSE, NULL);
164  if (mmcData->CapabilitiesMdl == NULL)
165  {
166  ExFreePool(mmcData->CapabilitiesBuffer);
167  mmcData->CapabilitiesBuffer = NULL;
168  mmcData->CapabilitiesBufferSize = 0;
170  }
171 
172  // Create an IRP from which we will create a WDFREQUEST
173  mmcData->CapabilitiesIrp = IoAllocateIrp(deviceExtension->DeviceObject->StackSize + 1, FALSE);
174  if (mmcData->CapabilitiesIrp == NULL)
175  {
176  IoFreeMdl(mmcData->CapabilitiesMdl);
177  mmcData->CapabilitiesMdl = NULL;
178  ExFreePool(mmcData->CapabilitiesBuffer);
179  mmcData->CapabilitiesBuffer = NULL;
180  mmcData->CapabilitiesBufferSize = 0;
182  }
183 
184  // create WDF request object
187  status = WdfRequestCreateFromIrp(&attributes,
188  mmcData->CapabilitiesIrp,
189  FALSE,
190  &mmcData->CapabilitiesRequest);
191  if (!NT_SUCCESS(status))
192  {
193  return status;
194  }
195 
196  return STATUS_SUCCESS;
197 }
PMDL CapabilitiesMdl
Definition: cdrom.h:270
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
CDROM_DATA DeviceAdditionalData
Definition: cdrom.h:598
LONG NTSTATUS
Definition: precomp.h:26
WDFREQUEST CapabilitiesRequest
Definition: cdrom.h:265
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
Definition: wdfobject.h:170
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_ALL
Definition: ntddmmc.h:15
ULONG CapabilitiesBufferSize
Definition: cdrom.h:269
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
#define NULL
Definition: types.h:112
CDROM_MMC_EXTENSION Mmc
Definition: cdrom.h:341
PDEVICE_OBJECT DeviceObject
Definition: cdrom.h:493
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
#define STATUS_SUCCESS
Definition: shellext.h:65
PIRP CapabilitiesIrp
Definition: cdrom.h:264
static SERVICE_STATUS status
Definition: service.c:31
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PAGED_CODE()
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97