diff options
| author | Adonais Romero González <[email protected]> | 2018-05-16 13:47:23 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-05-16 13:47:23 -0700 |
| commit | df271b80bdbb556707d9b4af1b06151ded561884 (patch) | |
| tree | 4480c45b7d3e61a68f5c8a5ec76b9c1a03945178 | |
| parent | b70753ddbecd36aa99114541ee2f258f60530beb (diff) | |
| parent | 84561afca9acdd6af4f22c24e50561d74b431354 (diff) | |
Merge pull request #246 from NeoAdonis/remove-ramdisk-sdiomars
Remove sdiomars & ramdisk samples
| -rw-r--r-- | sd/sdiomars/README.md | 32 | ||||
| -rw-r--r-- | sd/sdiomars/mars.c | 1124 | ||||
| -rw-r--r-- | sd/sdiomars/mars.h | 200 | ||||
| -rw-r--r-- | sd/sdiomars/mars.inx | bin | 4166 -> 0 bytes | |||
| -rw-r--r-- | sd/sdiomars/mars.vcxproj | 179 | ||||
| -rw-r--r-- | sd/sdiomars/mars.vcxproj.Filters | 31 | ||||
| -rw-r--r-- | sd/sdiomars/ntddmars.h | 113 | ||||
| -rw-r--r-- | sd/sdiomars/sd-sdiomars.yaml | 10 | ||||
| -rw-r--r-- | sd/sdiomars/sdiomars.sln | 28 | ||||
| -rw-r--r-- | storage/ramdisk/README.md | 103 | ||||
| -rw-r--r-- | storage/ramdisk/ramdisk.sln | 28 | ||||
| -rw-r--r-- | storage/ramdisk/src/WdfRamdisk.vcxproj | 153 | ||||
| -rw-r--r-- | storage/ramdisk/src/WdfRamdisk.vcxproj.Filters | 34 | ||||
| -rw-r--r-- | storage/ramdisk/src/forward_progress.c | 347 | ||||
| -rw-r--r-- | storage/ramdisk/src/forward_progress.h | 52 | ||||
| -rw-r--r-- | storage/ramdisk/src/ramdisk.c | 898 | ||||
| -rw-r--r-- | storage/ramdisk/src/ramdisk.h | 196 | ||||
| -rw-r--r-- | storage/ramdisk/src/ramdisk.inx | bin | 5378 -> 0 bytes | |||
| -rw-r--r-- | storage/ramdisk/src/ramdisk.rc | 11 | ||||
| -rw-r--r-- | storage/ramdisk/storage-ramdisk.yaml | 10 |
20 files changed, 0 insertions, 3549 deletions
diff --git a/sd/sdiomars/README.md b/sd/sdiomars/README.md deleted file mode 100644 index 2f248936..00000000 --- a/sd/sdiomars/README.md +++ /dev/null @@ -1,32 +0,0 @@ -<!--- - name: SDIO Driver - platform: KMDF - language: cpp - category: Storage - description: A functional KMDF Secure Digital (SD) IO driver for use with a generic mars development board. - samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=617953 ----> - - -Storage SDIO Driver -=================== - -This is a sample for a functional Secure Digital (SD) IO driver. The driver is written using the Kernel Mode Driver Framework. It is a driver for a generic mars development board that implements the SDIO protocol without additional functionality. - -## Universal Windows Driver Compliant -This sample builds a Universal Windows Driver. It uses only APIs and DDIs that are included in OneCoreUAP. - -The mars board driver exemplifies several different functions that are essential for writing an SDIO driver that leverages KDMF and the SDBUS API. It will show how to: - -- Install and start an SDIO device. - -- Release an SDIO device. - -- Perform data transfers. - -- Alter the settings that the SDIO device uses to communicate with the SD Host Controller. - -For more information, see [Secure Digital (SD) Card Drivers](http://msdn.microsoft.com/en-us/library/windows/hardware/ff537945). - -**Note** This sample provides an example of a minimal driver. Neither the driver nor the sample programs are intended for use in a production environment. Rather, they are intended for educational purposes and as a skeleton driver. - diff --git a/sd/sdiomars/mars.c b/sd/sdiomars/mars.c deleted file mode 100644 index a6225fcc..00000000 --- a/sd/sdiomars/mars.c +++ /dev/null @@ -1,1124 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - -Module Name: - - Mars.c - -Abstract: -Environment: - - kernel - -Notes: - - -Revision History: - - ---*/ -#include "mars.h" - -#ifdef ALLOC_PRAGMA - #pragma alloc_text (INIT, DriverEntry) - #pragma alloc_text (PAGE, MarsEvtDeviceAdd) - #pragma alloc_text (PAGE, MarsEvtIoDeviceControl) -#endif - - -BOOLEAN NoisyMode = FALSE; - - -NTSTATUS -DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath - ) -/*++ - -Routine Description: - - Installable driver initialization entry point. - This entry point is called directly by the I/O system. - -Arguments: - - DriverObject - pointer to the driver object - - RegistryPath - pointer to a unicode string representing the path, - to driver-specific key in the registry. - -Return Value: - - STATUS_SUCCESS if successful, - STATUS_UNSUCCESSFUL otherwise. - ---*/ -{ - - NTSTATUS status = STATUS_SUCCESS; - WDF_DRIVER_CONFIG config; - - WDF_DRIVER_CONFIG_INIT(&config, - MarsEvtDeviceAdd - ); - - status = WdfDriverCreate(DriverObject, - RegistryPath, - WDF_NO_OBJECT_ATTRIBUTES, - &config, - WDF_NO_HANDLE - ); - - return status; -} - - -NTSTATUS -MarsEvtDeviceAdd( - IN WDFDRIVER Driver, - IN PWDFDEVICE_INIT DeviceInit - ) -/*++ -Routine Description: - - EvtDeviceAdd is called by the framework in response to AddDevice - call from the PnP manager. - -Arguments: - - Driver - Handle to a framework driver object created in DriverEntry - - DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure. - -Return Value: - - NTSTATUS - ---*/ -{ - NTSTATUS status = STATUS_SUCCESS; - PFDO_DATA fdoData; - WDF_IO_QUEUE_CONFIG queueConfig; - WDF_OBJECT_ATTRIBUTES fdoAttributes; - WDFDEVICE device; - WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks; - SDBUS_INTERFACE_PARAMETERS interfaceParameters = {0}; - - UNREFERENCED_PARAMETER(Driver); - - PAGED_CODE(); - - WdfDeviceInitSetPowerPageable(DeviceInit); - - WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered); - - WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks); - - // - // Register PNP callbacks. - // - pnpPowerCallbacks.EvtDevicePrepareHardware = MarsEvtDevicePrepareHardware; - pnpPowerCallbacks.EvtDeviceReleaseHardware = MarsEvtDeviceReleaseHardware; - - WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks); - - WDF_OBJECT_ATTRIBUTES_INIT(&fdoAttributes); - WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&fdoAttributes, FDO_DATA); - - status = WdfDeviceCreate(&DeviceInit, &fdoAttributes, &device); - if (!NT_SUCCESS(status)) { - return status; - } - - fdoData = MarsFdoGetData(device); //Gets device context - - // - // Open an interface to the SD bus driver - // - status = SdBusOpenInterface(WdfDeviceWdmGetPhysicalDevice (device), - &fdoData->BusInterface, - sizeof(SDBUS_INTERFACE_STANDARD), - SDBUS_INTERFACE_VERSION); - - if (!NT_SUCCESS(status)) { - return status; - } - - interfaceParameters.Size = sizeof(SDBUS_INTERFACE_PARAMETERS); - interfaceParameters.TargetObject = WdfDeviceWdmGetAttachedDevice(device); - interfaceParameters.DeviceGeneratesInterrupts = TRUE; //change to true eventually - interfaceParameters.CallbackRoutine = MarsEventCallback; - interfaceParameters.CallbackRoutineContext = fdoData; - - status = STATUS_UNSUCCESSFUL; - if (fdoData->BusInterface.InitializeInterface) { - status = (fdoData->BusInterface.InitializeInterface)(fdoData->BusInterface.Context, - &interfaceParameters); - } - - if (!NT_SUCCESS(status)) { - return status; - } - - // - // Register New device - // - - status = WdfDeviceCreateDeviceInterface(device, - (LPGUID) &GUID_DEVINTERFACE_MARS, - NULL - ); - if (!NT_SUCCESS(status)) { - return status; - } - - fdoData->WdfDevice = device; - - WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchSequential); - - queueConfig.EvtIoRead = MarsEvtIoRead; - queueConfig.EvtIoWrite = MarsEvtIoWrite; - queueConfig.EvtIoDeviceControl = MarsEvtIoDeviceControl; - - status = WdfIoQueueCreate(device, - &queueConfig, - WDF_NO_OBJECT_ATTRIBUTES, - &fdoData->IoctlQueue - ); - - return status; -} - -NTSTATUS -MarsEvtDevicePrepareHardware( - WDFDEVICE Device, - WDFCMRESLIST Resources, - WDFCMRESLIST ResourcesTranslated - ) -/*++ - -Routine Description: - - EvtDevicePrepareHardware event callback performs operations that are necessary - to make the driver's device operational. The framework calls the driver's - EvtDeviceStart callback when the PnP manager sends an IRP_MN_START_DEVICE - request to the driver stack. - -Arguments: - - Device - Handle to a framework device object. - - Resources - Handle to a collection of framework resource objects. - This collection identifies the raw (bus-relative) hardware - resources that have been assigned to the device. - - ResourcesTranslated - Handle to a collection of framework resource objects. - This collection identifies the translated (system-physical) - hardware resources that have been assigned to the device. - The resources appear from the CPU's point of view. - Use this list of resources to map I/O space and - device-accessible memory into virtual address space - -Return Value: - - WDF status code - ---*/ -{ - NTSTATUS status = STATUS_SUCCESS; - USHORT maxBlockLength; - USHORT hostBlockLength; - PFDO_DATA fdoData; - - UNREFERENCED_PARAMETER(Resources); - UNREFERENCED_PARAMETER(ResourcesTranslated); - - fdoData = MarsFdoGetData(Device); - - // - // Get the function number - // - - status = SdioGetProperty(Device, - SDP_FUNCTION_NUMBER, - &fdoData->FunctionNumber, - sizeof(fdoData->FunctionNumber)); - - if (!NT_SUCCESS(status)) { - return status; - } - - fdoData->FunctionFocus = fdoData->FunctionNumber; - - - // - // Get the SD bus driver version - // - - fdoData->DriverVersion = SDBUS_DRIVER_VERSION_1; - - SdioGetProperty(Device, - SDP_BUS_DRIVER_VERSION, - &fdoData->DriverVersion, - sizeof(fdoData->DriverVersion)); - - if (fdoData->DriverVersion < SDBUS_DRIVER_VERSION_2) { - fdoData->BlockMode = 0; - } else { - fdoData->BlockMode = 1; - } - - - // - // Get the host buffer block size - // - - status = SdioGetProperty(Device, - SDP_HOST_BLOCK_LENGTH, - &hostBlockLength, - sizeof(hostBlockLength)); - - if (!NT_SUCCESS(status)) { - return status; - } - - maxBlockLength = 128; // just a value for testing - - if (hostBlockLength < maxBlockLength) { - maxBlockLength = hostBlockLength; - - } - - // - // set the block count since the MARS board may not have any - // tuples in its FLASH - // - - status = SdioSetProperty(Device, - SDP_FUNCTION_BLOCK_LENGTH, - &maxBlockLength, - sizeof(maxBlockLength)); - - return status; -} - - -NTSTATUS -MarsEvtDeviceReleaseHardware( - IN WDFDEVICE Device, - IN WDFCMRESLIST ResourcesTranslated - ) -/*++ - -Routine Description: - - EvtDeviceReleaseHardware is called by the framework whenever the PnP manager - is revoking ownership of our resources. This may be in response to either - IRP_MN_STOP_DEVICE or IRP_MN_REMOVE_DEVICE. The callback is made before - passing down the IRP to the lower driver. - - In this callback, do anything necessary to free those resources. - -Arguments: - - Device - Handle to a framework device object. - - ResourcesTranslated - Handle to a collection of framework resource objects. - This collection identifies the translated (system-physical) - hardware resources that have been assigned to the device. - The resources appear from the CPU's point of view. - Use this list of resources to map I/O space and - device-accessible memory into virtual address space - -Return Value: - - NTSTATUS - Failures will be logged, but not acted on. - ---*/ -{ - PFDO_DATA fdoData; - - UNREFERENCED_PARAMETER(ResourcesTranslated); - - fdoData = MarsFdoGetData(Device); - - if (fdoData->BusInterface.InterfaceDereference) { - - (fdoData->BusInterface.InterfaceDereference)(fdoData->BusInterface.Context); - fdoData->BusInterface.InterfaceDereference = NULL; - - } - - return STATUS_SUCCESS; -} - -// -// Io events callbacks. -// -VOID -MarsEvtIoDeviceControl( - IN WDFQUEUE Queue, - IN WDFREQUEST Request, - IN size_t OutputBufferLength, - IN size_t InputBufferLength, - IN ULONG IoControlCode - ) -/*++ - -Routine Description: - - This event is called when the framework receives IRP_MJ_DEVICE_CONTROL - requests from the system. - -Arguments: - - Queue - Handle to the framework queue object that is associated - with the I/O request. - Request - Handle to a framework request object. - - OutputBufferLength - length of the request's output buffer, - if an output buffer is available. - InputBufferLength - length of the request's input buffer, - if an input buffer is available. - - IoControlCode - the driver-defined or system-defined I/O control code - (IOCTL) that is associated with the request. -Return Value: - - VOID - ---*/ -{ - PFDO_DATA fdoData = NULL; - WDFDEVICE device; - NTSTATUS status = STATUS_SUCCESS; - PVOID inBuffer = NULL, outBuffer = NULL; - size_t bytesReturned = 0; - size_t size = 0; - - PAGED_CODE(); - - //DbgPrint(("Started MarsEvtIODeviceControl\n")); - - device = WdfIoQueueGetDevice(Queue); - fdoData = MarsFdoGetData(device); //Gets device context - - // - // Get the ioctl input & output buffers - // - if (InputBufferLength != 0) { - status = WdfRequestRetrieveInputBuffer(Request, - InputBufferLength, - &inBuffer, - &size); - - if (!NT_SUCCESS(status)) { - WdfRequestComplete(Request, status); - return; - } - } - - if (OutputBufferLength != 0) { - status = WdfRequestRetrieveOutputBuffer(Request, - OutputBufferLength, - &outBuffer, - &size); - if (!NT_SUCCESS(status)) { - WdfRequestComplete(Request, status); - return; - } - } - - switch (IoControlCode) { - - case IOCTL_MARS_GET_DRIVER_VERSION: - - if (OutputBufferLength < sizeof(USHORT)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - *(PUSHORT)outBuffer = fdoData->DriverVersion; - bytesReturned = sizeof(USHORT); - break; - - - case IOCTL_MARS_GET_FUNCTION_NUMBER: - - if (OutputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - *(PUCHAR)outBuffer = fdoData->FunctionNumber; - bytesReturned = sizeof(UCHAR); - break; - - - case IOCTL_MARS_GET_FUNCTION_FOCUS: - - if (OutputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - *(PUCHAR)outBuffer = fdoData->FunctionFocus; - bytesReturned = sizeof(UCHAR); - break; - - - case IOCTL_MARS_SET_FUNCTION_FOCUS: - - if (InputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - fdoData->FunctionFocus = *(PUCHAR)inBuffer; - break; - - - //--------------------------------------------------- - // - // SDP_BUS_WIDTH - // - //--------------------------------------------------- - - case IOCTL_MARS_GET_BUS_WIDTH: - - if (OutputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - status = SdioGetProperty(device, SDP_BUS_WIDTH, - outBuffer, sizeof(UCHAR)); - - if (NT_SUCCESS(status)) { - bytesReturned = sizeof(UCHAR); - } - break; - - - case IOCTL_MARS_SET_BUS_WIDTH: - - if (InputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - status = SdioSetProperty(device, SDP_BUS_WIDTH, - inBuffer, sizeof(UCHAR)); - break; - - - //--------------------------------------------------- - // - // SDP_BUS_CLOCK - // - //--------------------------------------------------- - - case IOCTL_MARS_GET_BUS_CLOCK: - - if (OutputBufferLength < sizeof(ULONG)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - status = SdioGetProperty(device, SDP_BUS_CLOCK, - outBuffer, sizeof(ULONG)); - - if (NT_SUCCESS(status)) { - bytesReturned = sizeof(ULONG); - } - break; - - - case IOCTL_MARS_SET_BUS_CLOCK: - - if (InputBufferLength < sizeof(ULONG)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - status = SdioSetProperty(device, SDP_BUS_CLOCK, - inBuffer, sizeof(ULONG)); - break; - - - //--------------------------------------------------- - // - // SDP_FUNCTION_BLOCK_LENGTH - // - //--------------------------------------------------- - - - case IOCTL_MARS_GET_BLOCKLEN: - - if (OutputBufferLength < sizeof(USHORT)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - status = SdioGetProperty(device, SDP_FUNCTION_BLOCK_LENGTH, - outBuffer, sizeof(SHORT)); - - if (NT_SUCCESS(status)) { - bytesReturned = sizeof(USHORT); - } - break; - - - case IOCTL_MARS_SET_BLOCKLEN: - - if (InputBufferLength < sizeof(USHORT)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - status = SdioSetProperty(device, SDP_FUNCTION_BLOCK_LENGTH, - inBuffer, sizeof(SHORT)); - break; - - - //--------------------------------------------------- - // - // SDP_FN0_BLOCK_LENGTH - // - //--------------------------------------------------- - - - case IOCTL_MARS_GET_FN0_BLOCKLEN: - - if (OutputBufferLength < sizeof(USHORT)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - status = SdioGetProperty(device, SDP_FN0_BLOCK_LENGTH, - outBuffer, sizeof(SHORT)); - - if (NT_SUCCESS(status)) { - bytesReturned = sizeof(USHORT); - } - break; - - - case IOCTL_MARS_SET_FN0_BLOCKLEN: - - if (InputBufferLength < sizeof(USHORT)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - status = SdioSetProperty(device, SDP_FN0_BLOCK_LENGTH, - inBuffer, sizeof(SHORT)); - break; - - - //--------------------------------------------------- - // - // SDP_BUS_INTERFACE_CONTROL - // - //--------------------------------------------------- - - - case IOCTL_MARS_GET_BUS_INTERFACE_CONTROL: - - if (OutputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - status = SdioGetProperty(device, SDP_BUS_INTERFACE_CONTROL, - outBuffer, sizeof(UCHAR)); - - if (NT_SUCCESS(status)) { - bytesReturned = sizeof(UCHAR); - } - break; - - - case IOCTL_MARS_SET_BUS_INTERFACE_CONTROL: - - if (InputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - status = SdioSetProperty(device, SDP_BUS_INTERFACE_CONTROL, - inBuffer, sizeof(UCHAR)); - break; - - - //--------------------------------------------------- - // - // SDP_FUNCTION_INT_ENABLE - // - //--------------------------------------------------- - - - case IOCTL_MARS_GET_INT_ENABLE: - - if (OutputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - status = SdioGetProperty(device, SDP_FUNCTION_INT_ENABLE, - outBuffer, sizeof(UCHAR)); - - if (NT_SUCCESS(status)) { - bytesReturned = sizeof(UCHAR); - } - break; - - - case IOCTL_MARS_SET_INT_ENABLE: - - if (InputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - status = SdioSetProperty(device, SDP_FUNCTION_INT_ENABLE, - inBuffer, sizeof(UCHAR)); - break; - - - //--------------------------------------------------- - // - // READ/WRITE BYTE - // - //--------------------------------------------------- - - - case IOCTL_MARS_READ_BYTE: - - if ((InputBufferLength < sizeof(ULONG)) || (OutputBufferLength < sizeof(UCHAR))) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - status = SdioReadWriteByte(device, - fdoData->FunctionFocus, - (PUCHAR)outBuffer, - *(PULONG)inBuffer, - FALSE); - - if (NT_SUCCESS(status)) { - bytesReturned = sizeof(UCHAR); - } - - break; - - - case IOCTL_MARS_WRITE_BYTE: - - if ((InputBufferLength < sizeof(ULONG)*2)) {//||(OutputBufferLength < sizeof(UCHAR))) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - // BUGBUG: check for output buffer length - - status = SdioReadWriteByte(device, - fdoData->FunctionFocus, - (PUCHAR)(&((PULONG)inBuffer)[1]), - *(PULONG)inBuffer, - TRUE); - - // BUGBUG: Return the right size - - if (NT_SUCCESS(status)) { - bytesReturned = sizeof(UCHAR); - } - - - break; - - - //--------------------------------------------------- - // - // Mode settings - // - //--------------------------------------------------- - - case IOCTL_MARS_SET_TRANSFER_MODE: - - bytesReturned = 0; - - break; - - case IOCTL_MARS_TOGGLE_MODE: - - if (OutputBufferLength < sizeof(UCHAR)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - if (fdoData->DriverVersion < SDBUS_DRIVER_VERSION_2) { - status = STATUS_INVALID_DEVICE_REQUEST; - break; - } - - fdoData->BlockMode = fdoData->BlockMode ? 0 : 1; - *(PUCHAR)outBuffer = fdoData->BlockMode; - bytesReturned = sizeof(UCHAR); - break; - - - case IOCTL_MARS_TOGGLE_NOISY: - - if (OutputBufferLength < sizeof(BOOLEAN)) { - status = STATUS_BUFFER_TOO_SMALL; - break; - } - - NoisyMode = NoisyMode ? 0 : 1; - *(PBOOLEAN)outBuffer = NoisyMode; - bytesReturned = sizeof(BOOLEAN); - - if (NoisyMode) { - KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "MARS: Noisy mode\n")); - } else { - KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "MARS: Quiet mode\n")); - } - break; - - - default: - NT_ASSERTMSG("Invalid IOCTL request\n", FALSE); - - status = STATUS_INVALID_DEVICE_REQUEST; - } - - WdfRequestCompleteWithInformation(Request, status, bytesReturned); - return; -} - -VOID -MarsEvtIoRead ( - WDFQUEUE Queue, - WDFREQUEST Request, - size_t Length - ) -/*++ - -Routine Description: - - This event is called when the framework receives IRP_MJ_READ requests. - -Arguments: - - Queue - Handle to the framework queue object that is associated with the - I/O request. - Request - Handle to a framework request object. - - Lenght - Length of the data buffer associated with the request. - The default property of the queue is to not dispatch - zero lenght read & write requests to the driver and - complete is with status success. So we will never get - a zero length request. - -Return Value: - - None. - ---*/ -{ - WDFDEVICE device; - PFDO_DATA fdoData; - PMDL mdlAddress; - WDF_REQUEST_PARAMETERS parameters; - NTSTATUS status; - ULONG bytesRead; - - device = WdfIoQueueGetDevice(Queue); - fdoData = MarsFdoGetData(device); - - status = WdfRequestRetrieveOutputWdmMdl(Request,&mdlAddress); - if (!NT_SUCCESS(status)) { - WdfRequestComplete(Request, status); - return; - } - - WDF_REQUEST_PARAMETERS_INIT(¶meters); - WdfRequestGetParameters(Request, ¶meters); - - status = SdioReadWriteBuffer(device, - fdoData->FunctionFocus, - mdlAddress, - (ULONG)parameters.Parameters.Read.DeviceOffset, - (ULONG)parameters.Parameters.Read.Length, - FALSE, - &bytesRead); - - WdfRequestCompleteWithInformation(Request, status, bytesRead); - - return; -} - -VOID -MarsEvtIoWrite ( - WDFQUEUE Queue, - WDFREQUEST Request, - size_t Length - ) -/*++ - -Routine Description: - - Called by the framework as soon as it receive a write IRP. - If the device is not ready, fail the request. Otherwise - get scatter-gather list for this request and send the - packet to the hardware for DMA. - -Arguments: - - Queue - Handle to the framework queue object that is associated - with the I/O request. - Request - Handle to a framework request object. - - Length - Length of the IO operation - The default property of the queue is to not dispatch - zero lenght read & write requests to the driver and - complete is with status success. So we will never get - a zero length request. - -Return Value: - - ---*/ -{ - WDFDEVICE device; - PFDO_DATA fdoData; - PMDL mdlAddress; - WDF_REQUEST_PARAMETERS parameters; - NTSTATUS status; - ULONG bytesRead; - - device = WdfIoQueueGetDevice(Queue); - fdoData = MarsFdoGetData(device); - - status = WdfRequestRetrieveInputWdmMdl(Request,&mdlAddress); - if (!NT_SUCCESS(status)) { - WdfRequestComplete(Request, status); - return; - } - - WDF_REQUEST_PARAMETERS_INIT(¶meters); - WdfRequestGetParameters(Request, ¶meters); - - status = SdioReadWriteBuffer(device, - fdoData->FunctionFocus, - mdlAddress, - (ULONG)parameters.Parameters.Read.DeviceOffset, - (ULONG)parameters.Parameters.Read.Length, - TRUE, - &bytesRead); - - WdfRequestCompleteWithInformation(Request, status, bytesRead); - return; -} - -VOID -MarsEventCallback( - IN PVOID Context, - IN ULONG InterruptType - ) -/*++ - -Routine Description: - - This routine is called by the SD bus driver when a card interrupt is - detected. It will launch the EventWorker routine which reads the data from - the card. - -Arguments: - - Context, interrupt type are defined in the SDBUS api - -Return Values: - - none - ---*/ -{ - PFDO_DATA fdoData = (PFDO_DATA) Context; - static ULONG intCount = 0; - - if (NoisyMode) { - KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "MARS: got card interrupt %d\n", - intCount++)); - } - - - (fdoData->BusInterface.AcknowledgeInterrupt)(fdoData->BusInterface.Context); - -} - -NTSTATUS -SdioReadWriteBuffer( - IN WDFDEVICE Device, - IN ULONG Function, - IN PMDL Mdl, - IN ULONG Address, - IN ULONG Length, - IN BOOLEAN WriteToDevice, - OUT PULONG BytesRead - ) -{ - PFDO_DATA fdoData; - SDBUS_REQUEST_PACKET sdrp; - SD_RW_EXTENDED_ARGUMENT extendedArgument; - NTSTATUS status; - const SDCMD_DESCRIPTOR ReadIoExtendedDesc = - {SDCMD_IO_RW_EXTENDED, SDCC_STANDARD, SDTD_READ, SDTT_SINGLE_BLOCK, SDRT_5}; - - const SDCMD_DESCRIPTOR WriteIoExtendedDesc = - {SDCMD_IO_RW_EXTENDED, SDCC_STANDARD, SDTD_WRITE, SDTT_SINGLE_BLOCK, SDRT_5}; - - //PAGED_CODE(); - - fdoData = MarsFdoGetData(Device); - - RtlZeroMemory(&sdrp, sizeof(SDBUS_REQUEST_PACKET)); - - sdrp.RequestFunction = SDRF_DEVICE_COMMAND; - sdrp.Parameters.DeviceCommand.Mdl = Mdl; - - extendedArgument.u.AsULONG = 0; - extendedArgument.u.bits.Function = Function; - extendedArgument.u.bits.OpCode = 1; // increment address - extendedArgument.u.bits.BlockMode = fdoData->BlockMode; - extendedArgument.u.bits.Address = Address; - - if (WriteToDevice) { - extendedArgument.u.bits.WriteToDevice = 1; - sdrp.Parameters.DeviceCommand.CmdDesc = WriteIoExtendedDesc; - } else { - sdrp.Parameters.DeviceCommand.CmdDesc = ReadIoExtendedDesc; - } - - if (fdoData->BlockMode == 1) { - sdrp.Parameters.DeviceCommand.CmdDesc.TransferType = SDTT_MULTI_BLOCK_NO_CMD12; - } - - - sdrp.Parameters.DeviceCommand.Argument = extendedArgument.u.AsULONG; - sdrp.Parameters.DeviceCommand.Length = Length; - - // - // Send the IO request down to the bus driver - // - - status = SdBusSubmitRequest(fdoData->BusInterface.Context, &sdrp); - *BytesRead = (ULONG)sdrp.Information; - return status; - -} - -NTSTATUS -SdioReadWriteByte( - IN WDFDEVICE Device, - IN ULONG Function, - IN PUCHAR Data, - IN ULONG Address, - IN BOOLEAN WriteToDevice - ) -/*++ - - ---*/ - -{ - PFDO_DATA fdoData; - NTSTATUS status; - SDBUS_REQUEST_PACKET sdrp; - SD_RW_DIRECT_ARGUMENT directArgument; - - const SDCMD_DESCRIPTOR ReadIoDirectDesc = - {SDCMD_IO_RW_DIRECT, SDCC_STANDARD, SDTD_READ, SDTT_CMD_ONLY, SDRT_5}; - - const SDCMD_DESCRIPTOR WriteIoDirectDesc = - {SDCMD_IO_RW_DIRECT, SDCC_STANDARD, SDTD_WRITE, SDTT_CMD_ONLY, SDRT_5}; - - // - // get an SD request packet - // - - fdoData = MarsFdoGetData(Device); - - RtlZeroMemory(&sdrp, sizeof(SDBUS_REQUEST_PACKET)); - - sdrp.RequestFunction = SDRF_DEVICE_COMMAND; - - directArgument.u.AsULONG = 0; - directArgument.u.bits.Function = Function; - directArgument.u.bits.Address = Address; - - - if (WriteToDevice) { - directArgument.u.bits.WriteToDevice = 1; - directArgument.u.bits.Data = *Data; - sdrp.Parameters.DeviceCommand.CmdDesc = WriteIoDirectDesc; - } else { - sdrp.Parameters.DeviceCommand.CmdDesc = ReadIoDirectDesc; - } - - sdrp.Parameters.DeviceCommand.Argument = directArgument.u.AsULONG; - - // - // Send the IO request down to the bus driver - // - - status = SdBusSubmitRequest(fdoData->BusInterface.Context, &sdrp); - - if (NT_SUCCESS(status) && !WriteToDevice) { - *Data = sdrp.ResponseData.AsUCHAR[0]; - } - - return status; -} - -NTSTATUS -SdioGetProperty( - IN WDFDEVICE Device, - IN SDBUS_PROPERTY Property, - IN PVOID Buffer, - IN ULONG Length - ) -{ - PFDO_DATA fdoData; - SDBUS_REQUEST_PACKET sdrp; - - fdoData = MarsFdoGetData(Device); - RtlZeroMemory(&sdrp, sizeof(SDBUS_REQUEST_PACKET)); - - sdrp.RequestFunction = SDRF_GET_PROPERTY; - sdrp.Parameters.GetSetProperty.Property = Property; - sdrp.Parameters.GetSetProperty.Buffer = Buffer; - sdrp.Parameters.GetSetProperty.Length = Length; - - return SdBusSubmitRequest(fdoData->BusInterface.Context, &sdrp); -} - - -NTSTATUS -SdioSetProperty( - IN WDFDEVICE Device, - IN SDBUS_PROPERTY Property, - IN PVOID Buffer, - IN ULONG Length - ) -{ - PFDO_DATA fdoData; - SDBUS_REQUEST_PACKET sdrp; - - fdoData = MarsFdoGetData(Device); - - RtlZeroMemory(&sdrp, sizeof(SDBUS_REQUEST_PACKET)); - - sdrp.RequestFunction = SDRF_SET_PROPERTY; - sdrp.Parameters.GetSetProperty.Property = Property; - sdrp.Parameters.GetSetProperty.Buffer = Buffer; - sdrp.Parameters.GetSetProperty.Length = Length; - - return SdBusSubmitRequest(fdoData->BusInterface.Context, &sdrp); -} - diff --git a/sd/sdiomars/mars.h b/sd/sdiomars/mars.h deleted file mode 100644 index b9baed39..00000000 --- a/sd/sdiomars/mars.h +++ /dev/null @@ -1,200 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Mars.h - -Abstract: - - Mars.h defines the data types used in the different stages of the function - driver. - -Environment: - - Kernel mode - ---*/ - - -#if !defined(_MARS_H_) -#define _MARS_H_ - -#include <ntddk.h> -#include <wdf.h> -#include <initguid.h> // required for GUID definitions -// -// Disables few warnings so that we can build our driver with MSC W4 level. -// Disable warning C4057; X differs in indirection to slightly different base types from Y -// Disable warning C4100: unreferenced formal parameter -// -#pragma warning(disable:4100 4057) - -#include <ntddsd.h> -#include <ntddmars.h> - -#define MARS_POOL_TAG (ULONG) 'sraM' - - -// -// The FDO_DATA structure describes the Mars sample function driver's device -// extension. The device extension is where all per-device-instance information -// is kept. -// -typedef struct _FDO_DATA { - - WDFDEVICE WdfDevice; - - WDFQUEUE IoctlQueue; - // - // Context for SD BUS api - // - SDBUS_INTERFACE_STANDARD BusInterface; - // - // Driver version - // - USHORT DriverVersion; - // - // Function number on SD card - // - UCHAR FunctionNumber; - - // - // Target function for I/O transactions (not necessarily our function#) - // - UCHAR FunctionFocus; - - // - // Send data transactions in byte mode (0) or block mode (1) - // - UCHAR BlockMode; -} FDO_DATA, *PFDO_DATA; - -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(FDO_DATA, MarsFdoGetData) - - -// -// Declare the function prototypes for all of the function driver's routines in all -// the stages of the function driver. -// - -DRIVER_INITIALIZE DriverEntry; - -EVT_WDF_DRIVER_DEVICE_ADD MarsEvtDeviceAdd; -/* -NTSTATUS -MarsEvtDeviceAdd( - IN WDFDRIVER Driver, - IN PWDFDEVICE_INIT DeviceInit - ); -*/ - -EVT_WDF_DEVICE_PREPARE_HARDWARE MarsEvtDevicePrepareHardware; -/* -NTSTATUS -MarsEvtDevicePrepareHardware( - WDFDEVICE Device, - WDFCMRESLIST Resources, - WDFCMRESLIST ResourcesTranslated - ); -*/ - -EVT_WDF_DEVICE_RELEASE_HARDWARE MarsEvtDeviceReleaseHardware; -/* -NTSTATUS -MarsEvtDeviceReleaseHardware( - IN WDFDEVICE Device, - IN WDFCMRESLIST ResourcesTranslated - ); -*/ - - -// -// Io events callbacks. -// - -EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL MarsEvtIoDeviceControl; -/* -VOID -MarsEvtIoDeviceControl( - IN WDFQUEUE Queue, - IN WDFREQUEST Request, - IN size_t OutputBufferLength, - IN size_t InputBufferLength, - IN ULONG IoControlCode - ); -*/ - -EVT_WDF_IO_QUEUE_IO_READ MarsEvtIoRead; -/* -VOID -MarsEvtIoRead ( - WDFQUEUE Queue, - WDFREQUEST Request, - size_t Length - ); -*/ - -EVT_WDF_IO_QUEUE_IO_WRITE MarsEvtIoWrite; -/* -VOID -MarsEvtIoWrite ( - WDFQUEUE Queue, - WDFREQUEST Request, - size_t Length - ); -*/ - -SDBUS_CALLBACK_ROUTINE MarsEventCallback; -/* -VOID -MarsEventCallback( - IN PVOID Context, - IN ULONG InterruptType - ); -*/ - -NTSTATUS -SdioReadWriteBuffer( - IN WDFDEVICE Device, - IN ULONG Function, - IN PMDL Mdl, - IN ULONG Address, - IN ULONG Length, - IN BOOLEAN WriteToDevice, - OUT PULONG BytesRead - ); - -NTSTATUS -SdioReadWriteByte( - IN WDFDEVICE Device, - IN ULONG Function, - IN PUCHAR Data, - IN ULONG Address, - IN BOOLEAN WriteToDevice - ); - -NTSTATUS -SdioGetProperty( - IN WDFDEVICE Device, - IN SDBUS_PROPERTY Property, - IN PVOID Buffer, - IN ULONG Length - ); - -NTSTATUS -SdioSetProperty( - IN WDFDEVICE Device, - IN SDBUS_PROPERTY Property, - IN PVOID Buffer, - IN ULONG Length - ); -#endif // _MARS_H_ - - diff --git a/sd/sdiomars/mars.inx b/sd/sdiomars/mars.inx Binary files differdeleted file mode 100644 index 773ff95e..00000000 --- a/sd/sdiomars/mars.inx +++ /dev/null diff --git a/sd/sdiomars/mars.vcxproj b/sd/sdiomars/mars.vcxproj deleted file mode 100644 index 21ca54ce..00000000 --- a/sd/sdiomars/mars.vcxproj +++ /dev/null @@ -1,179 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{EC43E875-56F0-402F-A42A-52D725108F56}</ProjectGuid> - <RootNamespace>$(MSBuildProjectName)</RootNamespace> - <KMDF_VERSION_MAJOR>1</KMDF_VERSION_MAJOR> - <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration> - <Platform Condition="'$(Platform)' == ''">Win32</Platform> - <SampleGuid>{CF2C68BB-DD38-4252-8833-F6612F4AF2C5}</SampleGuid> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>Driver</ConfigurationType> - </PropertyGroup> - <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>Driver</ConfigurationType> - </PropertyGroup> - <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>Driver</ConfigurationType> - </PropertyGroup> - <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>Driver</ConfigurationType> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <PropertyGroup> - <OutDir>$(IntDir)</OutDir> - </PropertyGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> - <ItemGroup Label="WrappedTaskItems"> - <Inf Include=".\mars.inx"> - <Architecture>$(InfArch)</Architecture> - <SpecifyArchitecture>true</SpecifyArchitecture> - <TimeStamp>1.0.0.5054</TimeStamp> - <SpecifyDriverVerDirectiveVersion>true</SpecifyDriverVerDirectiveVersion> - <CopyOutput>.\$(IntDir)\mars.inf</CopyOutput> - </Inf> - </ItemGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <TargetName>mars</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <TargetName>mars</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <TargetName>mars</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <TargetName>mars</TargetName> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Link> - <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\sdbus.lib;$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies> - </Link> - <ResourceCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - </ResourceCompile> - <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - <ExceptionHandling> - </ExceptionHandling> - </ClCompile> - <Midl> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - </Midl> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <Link> - <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\sdbus.lib;$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies> - </Link> - <ResourceCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - </ResourceCompile> - <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - <ExceptionHandling> - </ExceptionHandling> - </ClCompile> - <Midl> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - </Midl> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Link> - <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\sdbus.lib;$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies> - </Link> - <ResourceCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - </ResourceCompile> - <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - <ExceptionHandling> - </ExceptionHandling> - </ClCompile> - <Midl> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - </Midl> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Link> - <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\sdbus.lib;$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies> - </Link> - <ResourceCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - </ResourceCompile> - <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - <ExceptionHandling> - </ExceptionHandling> - </ClCompile> - <Midl> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);.</AdditionalIncludeDirectories> - </Midl> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="mars.c" /> - </ItemGroup> - <ItemGroup> - <Inf Exclude="@(Inf)" Include="*.inf" /> - <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" /> - </ItemGroup> - <ItemGroup> - <None Exclude="@(None)" Include="*.txt;*.htm;*.html" /> - <None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" /> - <None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" /> - </ItemGroup> - <ItemGroup> - <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> -</Project> diff --git a/sd/sdiomars/mars.vcxproj.Filters b/sd/sdiomars/mars.vcxproj.Filters deleted file mode 100644 index 689eb659..00000000 --- a/sd/sdiomars/mars.vcxproj.Filters +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Source Files"> - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions> - <UniqueIdentifier>{A0B01610-7348-4D47-8415-CBCFEB7024C9}</UniqueIdentifier> - </Filter> - <Filter Include="Header Files"> - <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> - <UniqueIdentifier>{4861BC04-1F15-46A0-B2DE-28D21B74ECB3}</UniqueIdentifier> - </Filter> - <Filter Include="Resource Files"> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions> - <UniqueIdentifier>{34886BF6-4425-4ABE-AED6-105D0167B275}</UniqueIdentifier> - </Filter> - <Filter Include="Driver Files"> - <Extensions>inf;inv;inx;mof;mc;</Extensions> - <UniqueIdentifier>{9EDC37D6-4A7F-4722-81F4-86129D5BF8CD}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <Inf Include=".\mars.inx"> - <Filter>Driver Files</Filter> - </Inf> - </ItemGroup> - <ItemGroup> - <ClCompile Include="mars.c"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/sd/sdiomars/ntddmars.h b/sd/sdiomars/ntddmars.h deleted file mode 100644 index d62c4f56..00000000 --- a/sd/sdiomars/ntddmars.h +++ /dev/null @@ -1,113 +0,0 @@ -/*++ -Copyright (c) 1990-2000 Microsoft Corporation All Rights Reserved - -Module Name: - - ntddmars.h - -Abstract: - - This module contains the common declarations shared by driver - and user applications. - -Environment: - - user and kernel -Notes: - - -Revision History: - - ---*/ - - -// -// Define an Interface Guid for the mars device class. -// - -DEFINE_GUID (GUID_DEVINTERFACE_MARS, - 0xf00896ba, 0x23a8, 0x41f1, 0x80, 0xed, 0xda, 0xd9, 0x81, 0x7a, 0xd7, 0x29); - - -// -// GUID definition are required to be outside of header inclusion pragma to avoid -// error during precompiled headers. -// - -#ifndef __NTDDMARS_H -#define __NTDDMARS_H - - -#define FILE_DEVICE_MARS FILE_DEVICE_CONTROLLER - -#define IOCTL_MARS_GET_DRIVER_VERSION \ - CTL_CODE( FILE_DEVICE_MARS, 0x780, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_MARS_GET_FUNCTION_NUMBER \ - CTL_CODE( FILE_DEVICE_MARS, 0x781, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_MARS_GET_FUNCTION_FOCUS \ - CTL_CODE( FILE_DEVICE_MARS, 0x782, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_MARS_SET_FUNCTION_FOCUS \ - CTL_CODE( FILE_DEVICE_MARS, 0x783, METHOD_BUFFERED, FILE_WRITE_ACCESS) - - - -#define IOCTL_MARS_GET_BUS_WIDTH \ - CTL_CODE( FILE_DEVICE_MARS, 0x784, METHOD_BUFFERED, FILE_WRITE_ACCESS) -#define IOCTL_MARS_SET_BUS_WIDTH \ - CTL_CODE( FILE_DEVICE_MARS, 0x785, METHOD_BUFFERED, FILE_WRITE_ACCESS) - - -#define IOCTL_MARS_GET_BUS_CLOCK \ - CTL_CODE( FILE_DEVICE_MARS, 0x786, METHOD_BUFFERED, FILE_WRITE_ACCESS) -#define IOCTL_MARS_SET_BUS_CLOCK \ - CTL_CODE( FILE_DEVICE_MARS, 0x787, METHOD_BUFFERED, FILE_WRITE_ACCESS) - - -#define IOCTL_MARS_GET_BLOCKLEN \ - CTL_CODE( FILE_DEVICE_MARS, 0x788, METHOD_BUFFERED, FILE_WRITE_ACCESS) -#define IOCTL_MARS_SET_BLOCKLEN \ - CTL_CODE( FILE_DEVICE_MARS, 0x789, METHOD_BUFFERED, FILE_WRITE_ACCESS) - - -#define IOCTL_MARS_GET_FN0_BLOCKLEN \ - CTL_CODE( FILE_DEVICE_MARS, 0x78a, METHOD_BUFFERED, FILE_WRITE_ACCESS) -#define IOCTL_MARS_SET_FN0_BLOCKLEN \ - CTL_CODE( FILE_DEVICE_MARS, 0x78b, METHOD_BUFFERED, FILE_WRITE_ACCESS) - - -#define IOCTL_MARS_GET_BUS_INTERFACE_CONTROL \ - CTL_CODE( FILE_DEVICE_MARS, 0x78c, METHOD_BUFFERED, FILE_WRITE_ACCESS) -#define IOCTL_MARS_SET_BUS_INTERFACE_CONTROL \ - CTL_CODE( FILE_DEVICE_MARS, 0x78d, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_MARS_GET_INT_ENABLE \ - CTL_CODE( FILE_DEVICE_MARS, 0x78e, METHOD_BUFFERED, FILE_WRITE_ACCESS) -#define IOCTL_MARS_SET_INT_ENABLE \ - CTL_CODE( FILE_DEVICE_MARS, 0x78f, METHOD_BUFFERED, FILE_WRITE_ACCESS) - - - -#define IOCTL_MARS_READ_BYTE \ - CTL_CODE( FILE_DEVICE_MARS, 0x7b0, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_MARS_WRITE_BYTE \ - CTL_CODE( FILE_DEVICE_MARS, 0x7b1, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_MARS_SET_TRANSFER_MODE \ - CTL_CODE( FILE_DEVICE_MARS, 0x7b2, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_MARS_TOGGLE_MODE \ - CTL_CODE( FILE_DEVICE_MARS, 0x7b3, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_MARS_TOGGLE_NOISY \ - CTL_CODE( FILE_DEVICE_MARS, 0x7b4, METHOD_BUFFERED, FILE_WRITE_ACCESS) - - -#endif - - - diff --git a/sd/sdiomars/sd-sdiomars.yaml b/sd/sdiomars/sd-sdiomars.yaml deleted file mode 100644 index 97ebb630..00000000 --- a/sd/sdiomars/sd-sdiomars.yaml +++ /dev/null @@ -1,10 +0,0 @@ -### YamlMime:Sample -sample: -- name: SDIO Driver - description: A functional KMDF Secure Digital (SD) IO driver for use with a generic mars development board. - generateZip: true - author: windows-driver-samples - languages: - - cpp - technologies: - - windows diff --git a/sd/sdiomars/sdiomars.sln b/sd/sdiomars/sdiomars.sln deleted file mode 100644 index 943d4707..00000000 --- a/sd/sdiomars/sdiomars.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 -MinimumVisualStudioVersion = 12.0 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mars", "mars.vcxproj", "{EC43E875-56F0-402F-A42A-52D725108F56}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EC43E875-56F0-402F-A42A-52D725108F56}.Debug|Win32.ActiveCfg = Debug|Win32 - {EC43E875-56F0-402F-A42A-52D725108F56}.Debug|Win32.Build.0 = Debug|Win32 - {EC43E875-56F0-402F-A42A-52D725108F56}.Release|Win32.ActiveCfg = Release|Win32 - {EC43E875-56F0-402F-A42A-52D725108F56}.Release|Win32.Build.0 = Release|Win32 - {EC43E875-56F0-402F-A42A-52D725108F56}.Debug|x64.ActiveCfg = Debug|x64 - {EC43E875-56F0-402F-A42A-52D725108F56}.Debug|x64.Build.0 = Debug|x64 - {EC43E875-56F0-402F-A42A-52D725108F56}.Release|x64.ActiveCfg = Release|x64 - {EC43E875-56F0-402F-A42A-52D725108F56}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/storage/ramdisk/README.md b/storage/ramdisk/README.md deleted file mode 100644 index 83e0bae1..00000000 --- a/storage/ramdisk/README.md +++ /dev/null @@ -1,103 +0,0 @@ -<!--- - name: RAMDisk Storage Driver Sample - platform: KMDF - language: cpp - category: Storage - description: Demonstrates how to write a RAM disk software-only function driver using KMDF. - samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=617988 ----> - - -RAMDisk Storage Driver Sample -============================= - -The RAMDisk storage driver sample demonstrates how to write a software only function driver using the Kernel Mode Driver Framework (KMDF). This driver creates a RAM disk drive.The RAM disk can be used like any other disk, but the contents of the disk will be lost when the computer is shut down. - -Build the sample ----------------- - -### Open the driver solution in Visual Studio ### - -In Visual Studio, open the solution file, ramdisk.sln, and locate Solution Explorer (if this is not already open, choose **Solution Explorer** from the **View** menu). In Solution Explorer, you can see one solution that has two projects. There is a driver project named **WdfRamdisk** and a package project named **package** (lower case). - -### Set the configuration and platform in Visual Studio - -In Visual Studio, in Solution Explorer, right click **Solution 'ramdisk'(2 projects)**, and choose **Configuration Manager**. Set the configuration and the platform. Make sure that the configuration and platform are the same for both the driver project and the package project. Do not check the **Deploy** boxes. Here are some examples of configuration and platform settings. - -### Build the sample using Visual Studio ### - -In Visual Studio, on the **Build** menu, choose **Build Solution**. - -For more information about using Visual Studio to build a driver package, see [Building a Driver](http://msdn.microsoft.com/en-us/library/windows/hardware/ff554644). - -### Locate the built driver package ### - -In File Explorer, navigate to the folder that contains your built driver package. The location of this folder varies depending on what you set for configuration and platform. The package contains these files: - -File | Description ------| ----------- -Kmdfsamples.cat | A signed catalog file, which serves as the signature for the entire package. -Ramdisk.inf | An information (INF) file that contains information needed to install the driver. -WdfCoinstaller010xx.dll | The coinstaller for version 1.xx of KMDF. -WdfRamdisk.sys | The driver file. - -Run the sample --------------- - -The computer where you install the driver is called the *target computer* or the *test computer*. Typically this is a separate computer from where you develop and build the driver package. The computer where you develop and build the driver is called the *host computer*. - -The process of moving the driver package to the target computer and installing the driver is called *deploying the driver*. You can deploy RAMDisk sample driver automatically or manually. - -###Automatic deployment ### - -Before you automatically deploy a driver, you must provision the target computer. For instructions, see [Configuring a Computer for Driver Deployment, Testing, and Debugging](http://msdn.microsoft.com/en-us/library/windows/hardware/). - -1. On the host computer, in Visual Studio, in Solution Explorer, right click **package** (lower case), and choose **Properties**. Navigate to **Configuration Properties \> Driver Install \> Deployment**. -2. Check **Enable deployment**, and check **Remove previous driver versions before deployment**. For **Target Computer Name**, select the name of a target computer that you provisioned previously. Select **Hardware ID Driver Update**, and enter **Ramdisk** for the hardware ID. Click **OK**. -3. On the **Build** menu, choose **Deploy Package** or **Build Solution**. - -### Manual deployment ### - -Before you manually deploy a driver, you must turn on test signing and install a certificate on the target computer. You also need to copy the [DevCon](http://msdn.microsoft.com/en-us/library/windows/hardware/ff544707) tool to the target computer. For instructions, see [Preparing a Computer for Manual Driver Deployment](http://msdn.microsoft.com/en-us/library/windows/hardware/dn265571). - -1. Copy all of the files in your driver package to a folder on the target computer (for example, c:\\RamdiskStorageDriverPackage). -2. On the target computer, open a Command Prompt window as Administrator. Navigate to your driver package folder, and enter the following command: - - **Devcon install ramdisk.inf Ramdisk** - -### View the installed driver in Device Manager ### - -On the target computer, in a Command Prompt window, enter **devmgmt** to open Device Manager. In Device Manager, on the **View** menu, choose **Devices by type**. In the device tree, locate **WDF Sample RAM disk Driver** (for example, this might be under the **Sample Device** node). - -The RAM disk sample is a root enumerated software driver. To see this in Device Manager, choose **Devices by connection** from the **View** menu. Locate **WDF Sample RAM disk Driver** as a child of the root node of the device tree. - -### Save a file on the RAM disk ### - -On the target computer, open a Command Prompt window as Administrator. Enter **R:** to switch to the RAM disk drive. In your Command Prompt window, enter **notepad** to open Notepad. Type some text in your notepad document, and then save the document on the R drive. In your Command Prompt window, enter **dir** to verify that the file was saved. - -### View Ramdisk entries in the Registry ### - - -The INF file in the RAM disk driver package specifies parameters that get saved in the registry. On the target computer, open the registry editor (Regedit.exe). In the registry editor, locate the Parameters key for the Ramdisk service. For example, - -**HKLM**\\**SYSTEM**\\**CurrentControlSet**\\**Services**\\**Ramdisk**\\**Parameters** - -The registry key has these entries: - -Parameter | Value | Description -----------------|---------|------------ -DiskSize |0x100000 |The size, in bytes, of the RAM disk drive. -DriveLetter |R: |The driver letter associated with the RAM disk drive. -RootDirEntries |0x200 |The number of entries in the root directory.</td> - -Using MSBuild -------------- - -As an alternative to building the RAMDisk Storage Driver sample in Visual Studio, you can build it in a Visual Studio Command Prompt window. In Visual Studio, on the **Tools** menu, choose **Visual Studio Command Prompt**. In the Visual Studio Command Prompt window, navigate to the folder that has the solution file, ramdisk.sln. Use the [MSBuild](http://go.microsoft.com/fwlink/p/?linkID=262804) command to build the solution. Here are some examples: - -**msbuild /p:configuration="Debug" /p:platform="x64" ramdisk.sln** - -**msbuild /p:configuration="Release" /p:platform="Win32" ramdisk.sln** - -For more information about using [MSBuild](http://go.microsoft.com/fwlink/p/?linkID=262804) to build a driver package, see [Building a Driver](http://msdn.microsoft.com/en-us/library/windows/hardware/ff554644). - diff --git a/storage/ramdisk/ramdisk.sln b/storage/ramdisk/ramdisk.sln deleted file mode 100644 index ca8409b5..00000000 --- a/storage/ramdisk/ramdisk.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 -MinimumVisualStudioVersion = 12.0 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WdfRamdisk", "src\WdfRamdisk.vcxproj", "{68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}.Debug|Win32.ActiveCfg = Debug|Win32 - {68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}.Debug|Win32.Build.0 = Debug|Win32 - {68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}.Release|Win32.ActiveCfg = Release|Win32 - {68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}.Release|Win32.Build.0 = Release|Win32 - {68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}.Debug|x64.ActiveCfg = Debug|x64 - {68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}.Debug|x64.Build.0 = Debug|x64 - {68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}.Release|x64.ActiveCfg = Release|x64 - {68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/storage/ramdisk/src/WdfRamdisk.vcxproj b/storage/ramdisk/src/WdfRamdisk.vcxproj deleted file mode 100644 index 70a054f1..00000000 --- a/storage/ramdisk/src/WdfRamdisk.vcxproj +++ /dev/null @@ -1,153 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{68CDA2C2-2417-4963-9AEF-CB1B9FEF6069}</ProjectGuid> - <RootNamespace>$(MSBuildProjectName)</RootNamespace> - <KMDF_VERSION_MAJOR>1</KMDF_VERSION_MAJOR> - <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration> - <Platform Condition="'$(Platform)' == ''">Win32</Platform> - <SampleGuid>{D76D15E5-06FE-43C8-A0E5-988E71FD53AB}</SampleGuid> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>Driver</ConfigurationType> - </PropertyGroup> - <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>Driver</ConfigurationType> - </PropertyGroup> - <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>False</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>Driver</ConfigurationType> - </PropertyGroup> - <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <TargetVersion>Windows10</TargetVersion> - <UseDebugLibraries>True</UseDebugLibraries> - <DriverTargetPlatform>Universal</DriverTargetPlatform> - <DriverType>KMDF</DriverType> - <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> - <ConfigurationType>Driver</ConfigurationType> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <PropertyGroup> - <OutDir>$(IntDir)</OutDir> - </PropertyGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" /> - </ImportGroup> - <ItemGroup Label="WrappedTaskItems" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <TargetName>WdfRamdisk</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <TargetName>WdfRamdisk</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <TargetName>WdfRamdisk</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <TargetName>WdfRamdisk</TargetName> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <TreatWarningAsError>true</TreatWarningAsError> - <WarningLevel>Level4</WarningLevel> - <ExceptionHandling> - </ExceptionHandling> - </ClCompile> - <Link> - <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <TreatWarningAsError>true</TreatWarningAsError> - <WarningLevel>Level4</WarningLevel> - <ExceptionHandling> - </ExceptionHandling> - </ClCompile> - <Link> - <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <TreatWarningAsError>true</TreatWarningAsError> - <WarningLevel>Level4</WarningLevel> - <ExceptionHandling> - </ExceptionHandling> - </ClCompile> - <Link> - <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <TreatWarningAsError>true</TreatWarningAsError> - <WarningLevel>Level4</WarningLevel> - <ExceptionHandling> - </ExceptionHandling> - </ClCompile> - <Link> - <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="forward_progress.c" /> - <ClCompile Include="ramdisk.c" /> - <ResourceCompile Include="ramdisk.rc" /> - </ItemGroup> - <ItemGroup> - <Inf Exclude="@(Inf)" Include="*.inx" /> - <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" /> - </ItemGroup> - <ItemGroup> - <None Exclude="@(None)" Include="*.txt;*.htm;*.html" /> - <None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" /> - <None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" /> - </ItemGroup> - <ItemGroup> - <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> -</Project>
\ No newline at end of file diff --git a/storage/ramdisk/src/WdfRamdisk.vcxproj.Filters b/storage/ramdisk/src/WdfRamdisk.vcxproj.Filters deleted file mode 100644 index b5fde5b1..00000000 --- a/storage/ramdisk/src/WdfRamdisk.vcxproj.Filters +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Source Files"> - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions> - <UniqueIdentifier>{961D42E9-6D94-4E93-8D32-CF1C674B07B6}</UniqueIdentifier> - </Filter> - <Filter Include="Header Files"> - <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> - <UniqueIdentifier>{D22FB3CB-1355-4386-84BE-230FFB99DCFE}</UniqueIdentifier> - </Filter> - <Filter Include="Resource Files"> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions> - <UniqueIdentifier>{28C48AF7-BB6E-4F6A-922D-9BF76BC2AC8A}</UniqueIdentifier> - </Filter> - <Filter Include="Driver Files"> - <Extensions>inf;inv;inx;mof;mc;</Extensions> - <UniqueIdentifier>{576E635F-EBBD-4ECA-8F75-D27C53603644}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClCompile Include="forward_progress.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="ramdisk.c"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="ramdisk.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/storage/ramdisk/src/forward_progress.c b/storage/ramdisk/src/forward_progress.c deleted file mode 100644 index a7c29c7a..00000000 --- a/storage/ramdisk/src/forward_progress.c +++ /dev/null @@ -1,347 +0,0 @@ - -/*++ - -Copyright (c) 1990-2000 Microsoft Corporation - -Module Name: - - forwardprogress.c - -Abstract: - - Show the forward progress feature - - - ---*/ - -// -// NOTE: Forward progress was added in v1.9 -// - -#if KMDF_VERSION_MINOR >= 9 - -#include "ramdisk.h" - -VOID -EvtForwardProgressRequestDestroy( - WDFOBJECT Request - ) - -/*++ - -Routine Description: - - This event is called when the request memory is about to be freed. - Reserved requests get deleted only when the queue gets deleted. - - -Arguments: - - Request - Handle to a framework request object. - - -Return Value: - - VOID - ---*/ -{ - PFWD_PROGRESS_REQUEST_CONTEXT fwdReqContext; - - fwdReqContext = GetForwardProgressRequestContext(Request); -} - -VOID -EvtForwardProgressRequestCleanup( - WDFOBJECT Request - ) - -/*++ - -Routine Description: - - This event is called when the reserved request is about to be deleted. - NOTE: In case of reserved request this callback doesn't get called after the - I/O is done but only when the request is about to be deleted. - -Arguments: - - Request - Handle to a framework request object. - - -Return Value: - - VOID - ---*/ -{ - PFWD_PROGRESS_REQUEST_CONTEXT reqContext; - - reqContext = GetForwardProgressRequestContext(Request); - - // - // Cleanup any resources allocated earlier for reserved requests here. - // -} - - -NTSTATUS -AllocateAdditionalRequestContext( - _In_ WDFREQUEST Request - ) - -/*++ - -Routine Description: - Allocate resources used by request. - Set the EvtCleanupCallback and EvtDestroyCallback - to show the lifetime of a Reserved request. - -Arguments: - - Request - Handle to a framework request object. - -Return Value: - - - NTSTATUS - ---*/ -{ - WDF_OBJECT_ATTRIBUTES requestContextAttributes; - PFWD_PROGRESS_REQUEST_CONTEXT reqContext; - NTSTATUS status; - - WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&requestContextAttributes, - FWD_PROGRESS_REQUEST_CONTEXT); - requestContextAttributes.EvtCleanupCallback = EvtForwardProgressRequestCleanup; - requestContextAttributes.EvtDestroyCallback = EvtForwardProgressRequestDestroy; - status = WdfObjectAllocateContext(Request, - &requestContextAttributes, - &reqContext); - - return status; -} - - -WDF_IO_FORWARD_PROGRESS_ACTION -EvtIoWdmIrpForForwardProgress( - _In_ WDFQUEUE Queue, - _In_ PIRP Irp - ) - -/*++ - -Routine Description: - A driver's EvtIoWdmIrpForForwardProgress callback function is used for - examining an IRP and tell the framework whether to use a reserved - request object for the IRP or to fail the I/O request by completing - it with an error status value. - -Arguments: - - Queue - Handle to the framework queue object that is associated with the - I/O request. - - Irp - -Return Value: - - WDF_IO_FORWARD_PROGRESS_ACTION - WdfIoForwardProgressActionFailRequest is returned it causes - the Framework to fail the IRP. - WdfIoForwardProgressActionUseReservedRequest is returned it causes - the framework to use a reserved request to handle the IRP. ---*/ -{ - PIO_STACK_LOCATION irpStack; - WDF_IO_FORWARD_PROGRESS_ACTION action; - - UNREFERENCED_PARAMETER(Queue); - - irpStack = IoGetCurrentIrpStackLocation(Irp); - switch (irpStack->MajorFunction) { - case IRP_MJ_READ: - case IRP_MJ_WRITE: - case IRP_MJ_DEVICE_CONTROL: - case IRP_MJ_INTERNAL_DEVICE_CONTROL: - - // - // Use reserved request for reads, writes, IOCTL's - // - action = WdfIoForwardProgressActionUseReservedRequest; - break; - - default: - // - // Just for demonstration of the available actions fail the - // other I/O IRP's - // - action = WdfIoForwardProgressActionFailRequest; - break; - } - - return action; -} - -NTSTATUS -EvtIoAllocateResourcesForReservedRequest( - _In_ WDFQUEUE Queue, - _In_ WDFREQUEST Request - ) - -/*++ - -Routine Description: - - A driver's EvtIoAllocateResourcesForReservedRequest callback function - allocates and stores request-specific resources for request objects that - the framework is reserving for low-memory situations. - - NOTE: You can't call WdfRequestGetIoQueue for Reserved requests - Use the Queue handle passed in. - - -Arguments: - - Queue - Handle to the framework queue object that is associated with the - I/O request. - - Request - Handle to a framework request object. - - -Return Value: - - NTSTATUS - ---*/ -{ - NTSTATUS status; - PFWD_PROGRESS_REQUEST_CONTEXT fwdReqContext; - - UNREFERENCED_PARAMETER(Queue); - - status = STATUS_SUCCESS; - ASSERT(WdfRequestIsReserved(Request)); - - // - // Allocate all resources needed for the request here. If you need to - // pre-allocate memory or any other resource do it in this callback and - // store it in the context. - // - status = AllocateAdditionalRequestContext(Request); - if (NT_SUCCESS(status)) { - - fwdReqContext = GetForwardProgressRequestContext(Request); - } - - return status; -} - -NTSTATUS -EvtIoAllocateResources( - _In_ WDFQUEUE Queue, - _In_ WDFREQUEST Request - ) - -/*++ - -Routine Description: - - This event is called for the driver to allocate request - resources for immediate use (unlike reserved requests which is for use under - low memory). - It is called immediately after the framework has received an IRP and created - a request object for the IRP. - - -Arguments: - - Queue - Handle to the framework queue object that is associated with the - I/O request. - - Request - Handle to a framework request object. - - -Return Value: - - NTSTATUS - ---*/ -{ - NTSTATUS status; - PFWD_PROGRESS_REQUEST_CONTEXT fwdReqContext; - - UNREFERENCED_PARAMETER(Queue); - status = STATUS_SUCCESS; - - // - // Allocate all resources needed for the request here and store it in the request - // context. - // - fwdReqContext = GetForwardProgressRequestContext(Request); - - return status; -} - -NTSTATUS -SetForwardProgressOnQueue( - _In_ WDFQUEUE Queue - ) - -/*++ - -Routine Description: - Set forward progress on the top level( handles one of the major I/O IRP) - queue we created. - The default is always a top level queue or if the queue was configured - with WdfDeviceConfigureRequestDispatching. - -Arguments: - - Queue - Handle to the framework queue object that is associated with the - I/O request. - - -Return Value: - - NTSTATUS - ---*/ -{ - - WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY forwardProgressPolicy; - NTSTATUS status; - - // - // The policy is configurable by the user. In the code segment below - // WdfIoForwardProgressReservedPolicyUseExamine - // is demonstrated. If your driver supports paging I/O you should select - // WdfIoForwardProgressReservedPolicyPagingIO. - // MAX_RESERVED_REQUESTS should be adjusted depending on the number of parallel - // requests the driver wants to handle under low memory conditions. It may - // require some hit and trial to get the right number. - // - WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY_EXAMINE_INIT( - &forwardProgressPolicy, - MAX_RESERVED_REQUESTS, - EvtIoWdmIrpForForwardProgress - ); - - forwardProgressPolicy.EvtIoAllocateResourcesForReservedRequest = - EvtIoAllocateResourcesForReservedRequest; - forwardProgressPolicy.EvtIoAllocateRequestResources = EvtIoAllocateResources; - - status = WdfIoQueueAssignForwardProgressPolicy(Queue, - &forwardProgressPolicy - ); - if (!NT_SUCCESS(status)) { - KdPrint(("Error WdfIoQueueAssignForwardProgressPolicy 0x%x\n",status)); - return status; - } - - return status; -} - -#endif - diff --git a/storage/ramdisk/src/forward_progress.h b/storage/ramdisk/src/forward_progress.h deleted file mode 100644 index 00bb6aa6..00000000 --- a/storage/ramdisk/src/forward_progress.h +++ /dev/null @@ -1,52 +0,0 @@ -/*++ - -Copyright (c) 1990-2000 Microsoft Corporation - -Module Name: - - forward_progress.h - -Abstract: - - This is the driver object header for forward progress - - -Environment: - - kernel mode only - -Revision History: - ---*/ - -#pragma once - -// -// NOTE: Forward progress was added in v1.9 -// - -#if KMDF_VERSION_MINOR >= 9 - -EVT_WDF_OBJECT_CONTEXT_CLEANUP EvtForwardProgressRequestCleanup; -EVT_WDF_OBJECT_CONTEXT_DESTROY EvtForwardProgressRequestDestroy; -EVT_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS EvtIoWdmIrpForForwardProgress; -EVT_WDF_IO_ALLOCATE_RESOURCES_FOR_RESERVED_REQUEST EvtIoAllocateResourcesForReservedRequest; -EVT_WDF_IO_ALLOCATE_REQUEST_RESOURCES EvtIoAllocateResources; - -#define MAX_RESERVED_REQUESTS 8 -#define MEMORY_SIZE 0x100 - -typedef struct _FWD_PROGRESS_REQUEST_CONTEXT { - WDFMEMORY Memory; -} FWD_PROGRESS_REQUEST_CONTEXT, *PFWD_PROGRESS_REQUEST_CONTEXT; - -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(FWD_PROGRESS_REQUEST_CONTEXT, GetForwardProgressRequestContext) - - -NTSTATUS -SetForwardProgressOnQueue( - _In_ WDFQUEUE Queue - ); - -#endif - diff --git a/storage/ramdisk/src/ramdisk.c b/storage/ramdisk/src/ramdisk.c deleted file mode 100644 index 5411f3a9..00000000 --- a/storage/ramdisk/src/ramdisk.c +++ /dev/null @@ -1,898 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - Ramdisk.c - -Abstract: - - This is the Ramdisk sample driver. This version of the driver has been - modified to support the driver frameworks. This driver basically creates - a nonpaged pool and exposes that as a storage media. User can - find the device in the disk manager and format the media to use - as FAT or NTFS volume. - -Environment: - - Kernel mode only. - ---*/ - -#include "ramdisk.h" - -#ifdef ALLOC_PRAGMA -#pragma alloc_text(INIT, DriverEntry) -#pragma alloc_text(PAGE, RamDiskEvtDeviceAdd) -#pragma alloc_text(PAGE, RamDiskEvtDeviceContextCleanup) -#pragma alloc_text(PAGE, RamDiskQueryDiskRegParameters) -#pragma alloc_text(PAGE, RamDiskFormatDisk) -#endif - -NTSTATUS -DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath - ) - -/*++ - -Routine Description: - - Installable driver initialization entry point. - This entry point is called directly by the I/O system. - -Arguments: - - DriverObject - pointer to the driver object - - RegistryPath - pointer to a unicode string representing the path - to driver-specific key in the registry - -Return Value: - - STATUS_SUCCESS if successful. - ---*/ - -{ - WDF_DRIVER_CONFIG config; - - KdPrint(("Windows Ramdisk Driver - Driver Framework Edition.\n")); - - - WDF_DRIVER_CONFIG_INIT( &config, RamDiskEvtDeviceAdd ); - - return WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE); -} - -VOID -RamDiskEvtIoRead( - IN WDFQUEUE Queue, - IN WDFREQUEST Request, - IN size_t Length - ) -/*++ - -Routine Description: - - This event is called when the framework receives IRP_MJ_READ request. - -Arguments: - - Queue - Handle to the framework queue object that is associated with the - I/O request. - - Request - Handle to a framework request object. - - Length - Length of the data buffer associated with the request. - The default property of the queue is to not dispatch - zero length read & write requests to the driver and - complete is with status success. So we will never get - a zero length request. - -Return Value: - - VOID - ---*/ -{ - PDEVICE_EXTENSION devExt = QueueGetExtension(Queue)->DeviceExtension; - NTSTATUS Status = STATUS_INVALID_PARAMETER; - WDF_REQUEST_PARAMETERS Parameters; - LARGE_INTEGER ByteOffset; - WDFMEMORY hMemory; - - _Analysis_assume_(Length > 0); - - WDF_REQUEST_PARAMETERS_INIT(&Parameters); - WdfRequestGetParameters(Request, &Parameters); - - ByteOffset.QuadPart = Parameters.Parameters.Read.DeviceOffset; - - if (RamDiskCheckParameters(devExt, ByteOffset, Length)) { - - Status = WdfRequestRetrieveOutputMemory(Request, &hMemory); - if(NT_SUCCESS(Status)){ - - Status = WdfMemoryCopyFromBuffer(hMemory, // Destination - 0, // Offset into the destination - devExt->DiskImage + ByteOffset.LowPart, // source - Length); - } - } - - WdfRequestCompleteWithInformation(Request, Status, (ULONG_PTR)Length); -} - -VOID -RamDiskEvtIoWrite( - IN WDFQUEUE Queue, - IN WDFREQUEST Request, - IN size_t Length - ) - -/*++ - -Routine Description: - - This event is invoked when the framework receives IRP_MJ_WRITE request. - -Arguments: - - Queue - Handle to the framework queue object that is associated with the - I/O request. - - Request - Handle to a framework request object. - - Length - Length of the data buffer associated with the request. - The default property of the queue is to not dispatch - zero length read & write requests to the driver and - complete is with status success. So we will never get - a zero length request. - -Return Value: - - VOID - ---*/ -{ - PDEVICE_EXTENSION devExt = QueueGetExtension(Queue)->DeviceExtension; - NTSTATUS Status = STATUS_INVALID_PARAMETER; - WDF_REQUEST_PARAMETERS Parameters; - LARGE_INTEGER ByteOffset; - WDFMEMORY hMemory; - - _Analysis_assume_(Length > 0); - - WDF_REQUEST_PARAMETERS_INIT(&Parameters); - WdfRequestGetParameters(Request, &Parameters); - - ByteOffset.QuadPart = Parameters.Parameters.Write.DeviceOffset; - - if (RamDiskCheckParameters(devExt, ByteOffset, Length)) { - - Status = WdfRequestRetrieveInputMemory(Request, &hMemory); - if(NT_SUCCESS(Status)){ - - Status = WdfMemoryCopyToBuffer(hMemory, // Source - 0, // offset in Source memory where the copy has to start - devExt->DiskImage + ByteOffset.LowPart, // destination - Length); - } - - } - - WdfRequestCompleteWithInformation(Request, Status, (ULONG_PTR)Length); -} - -VOID -RamDiskEvtIoDeviceControl( - IN WDFQUEUE Queue, - IN WDFREQUEST Request, - IN size_t OutputBufferLength, - IN size_t InputBufferLength, - IN ULONG IoControlCode - ) -/*++ - -Routine Description: - - This event is called when the framework receives IRP_MJ_DEVICE_CONTROL - requests from the system. - -Arguments: - - Queue - Handle to the framework queue object that is associated - with the I/O request. - Request - Handle to a framework request object. - - OutputBufferLength - length of the request's output buffer, - if an output buffer is available. - InputBufferLength - length of the request's input buffer, - if an input buffer is available. - - IoControlCode - the driver-defined or system-defined I/O control code - (IOCTL) that is associated with the request. - - -Return Value: - - VOID - ---*/ -{ - NTSTATUS Status = STATUS_INVALID_DEVICE_REQUEST; - ULONG_PTR information = 0; - size_t bufSize; - PDEVICE_EXTENSION devExt = QueueGetExtension(Queue)->DeviceExtension; - - UNREFERENCED_PARAMETER(OutputBufferLength); - UNREFERENCED_PARAMETER(InputBufferLength); - - switch (IoControlCode) { - case IOCTL_DISK_GET_PARTITION_INFO: { - - PPARTITION_INFORMATION outputBuffer; - PBOOT_SECTOR bootSector = (PBOOT_SECTOR) devExt->DiskImage; - - information = sizeof(PARTITION_INFORMATION); - - Status = WdfRequestRetrieveOutputBuffer(Request, sizeof(PARTITION_INFORMATION), &outputBuffer, &bufSize); - if(NT_SUCCESS(Status) ) { - - outputBuffer->PartitionType = - (bootSector->bsFileSystemType[4] == '6') ? PARTITION_FAT_16 : PARTITION_FAT_12; - - outputBuffer->BootIndicator = FALSE; - outputBuffer->RecognizedPartition = TRUE; - outputBuffer->RewritePartition = FALSE; - outputBuffer->StartingOffset.QuadPart = 0; - outputBuffer->PartitionLength.QuadPart = devExt->DiskRegInfo.DiskSize; - outputBuffer->HiddenSectors = (ULONG) (1L); - outputBuffer->PartitionNumber = (ULONG) (-1L); - - Status = STATUS_SUCCESS; - } - } - break; - - case IOCTL_DISK_GET_DRIVE_GEOMETRY: { - - PDISK_GEOMETRY outputBuffer; - - // - // Return the drive geometry for the ram disk. Note that - // we return values which were made up to suit the disk size. - // - information = sizeof(DISK_GEOMETRY); - - Status = WdfRequestRetrieveOutputBuffer(Request, sizeof(DISK_GEOMETRY), &outputBuffer, &bufSize); - if(NT_SUCCESS(Status) && - bufSize >= sizeof(DISK_GEOMETRY)) { - - RtlCopyMemory(outputBuffer, &(devExt->DiskGeometry), sizeof(DISK_GEOMETRY)); - Status = STATUS_SUCCESS; - } - } - break; - - case IOCTL_DISK_CHECK_VERIFY: - case IOCTL_DISK_IS_WRITABLE: - - // - // Return status success - // - - Status = STATUS_SUCCESS; - break; - } - - WdfRequestCompleteWithInformation(Request, Status, information); -} - -VOID -RamDiskEvtDeviceContextCleanup( - IN WDFOBJECT Device - ) -/*++ - -Routine Description: - - EvtDeviceContextCleanup event callback cleans up anything done in - EvtDeviceAdd, except those things that are automatically cleaned - up by the Framework. - - In the case of this sample, everything is automatically handled. In a - driver derived from this sample, it's quite likely that this function could - be deleted. - -Arguments: - - Device - Handle to a framework device object. - -Return Value: - - VOID - ---*/ -{ - PDEVICE_EXTENSION pDeviceExtension = DeviceGetExtension(Device); - - PAGED_CODE(); - - if(pDeviceExtension->DiskImage) { - ExFreePool(pDeviceExtension->DiskImage); - } -} - -NTSTATUS -RamDiskEvtDeviceAdd( - IN WDFDRIVER Driver, - IN PWDFDEVICE_INIT DeviceInit - ) -/*++ -Routine Description: - - EvtDeviceAdd is called by the framework in response to AddDevice - call from the PnP manager. We create and initialize a device object to - represent a new instance of the device. - -Arguments: - - Driver - Handle to a framework driver object created in DriverEntry - - DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure. - -Return Value: - - NTSTATUS - ---*/ -{ - WDF_OBJECT_ATTRIBUTES deviceAttributes; - NTSTATUS status; - WDFDEVICE device; - WDF_OBJECT_ATTRIBUTES queueAttributes; - WDF_IO_QUEUE_CONFIG ioQueueConfig; - PDEVICE_EXTENSION pDeviceExtension; - PQUEUE_EXTENSION pQueueContext = NULL; - WDFQUEUE queue; - DECLARE_CONST_UNICODE_STRING(ntDeviceName, NT_DEVICE_NAME); - - PAGED_CODE(); - - UNREFERENCED_PARAMETER(Driver); - - // - // Storage drivers have to name their FDOs. Since we are not unique'fying - // the device name, we wouldn't be able to install more than one instance - // of this ramdisk driver. - // - status = WdfDeviceInitAssignName(DeviceInit, &ntDeviceName); - if (!NT_SUCCESS(status)) { - return status; - } - - WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_DISK); - WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoDirect); - WdfDeviceInitSetExclusive(DeviceInit, FALSE); - - // - // Since this is a pure software only driver, there is no need to register - // any PNP/Power event callbacks. Framework will respond to these - // events appropriately. - // - WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&deviceAttributes, DEVICE_EXTENSION); - deviceAttributes.EvtCleanupCallback = RamDiskEvtDeviceContextCleanup; - - status = WdfDeviceCreate(&DeviceInit, &deviceAttributes, &device); - if (!NT_SUCCESS(status)) { - return status; - } - - // - // Now that the WDF device object has been created, set up any context - // that it requires. - // - - pDeviceExtension = DeviceGetExtension(device); - - // - // Configure a default queue so that requests that are not - // configure-fowarded using WdfDeviceConfigureRequestDispatching to goto - // other queues get dispatched here. - // - WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE ( - &ioQueueConfig, - WdfIoQueueDispatchSequential - ); - - ioQueueConfig.EvtIoDeviceControl = RamDiskEvtIoDeviceControl; - ioQueueConfig.EvtIoRead = RamDiskEvtIoRead; - ioQueueConfig.EvtIoWrite = RamDiskEvtIoWrite; - - WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&queueAttributes, QUEUE_EXTENSION); - - // - // By default, Static Driver Verifier (SDV) displays a warning if it - // doesn't find the EvtIoStop callback on a power-managed queue. - // The 'assume' below causes SDV to suppress this warning. If the driver - // has not explicitly set PowerManaged to WdfFalse, the framework creates - // power-managed queues when the device is not a filter driver. Normally - // the EvtIoStop is required for power-managed queues, but for this driver - // it is not needed b/c the driver doesn't hold on to the requests or - // forward them to other drivers. This driver completes the requests - // directly in the queue's handlers. If the EvtIoStop callback is not - // implemented, the framework waits for all driver-owned requests to be - // done before moving in the Dx/sleep states or before removing the - // device, which is the correct behavior for this type of driver. - // If the requests were taking an indeterminate amount of time to complete, - // or if the driver forwarded the requests to a lower driver/another stack, - // the queue should have an EvtIoStop/EvtIoResume. - // - __analysis_assume(ioQueueConfig.EvtIoStop != 0); - status = WdfIoQueueCreate( device, - &ioQueueConfig, - &queueAttributes, - &queue ); - __analysis_assume(ioQueueConfig.EvtIoStop == 0); - if (!NT_SUCCESS(status)) { - return status; - } - - // Context is the Queue handle - pQueueContext = QueueGetExtension(queue); - - // - // Set the context for our default queue as our device extension. - // - pQueueContext->DeviceExtension = pDeviceExtension; - -#if KMDF_VERSION_MINOR >= 9 - - // - // Enable forward progress on the queue we just created. - // NOTE: If you are planning to use this code without forward progress, - // comment out the call to SetForwardProgressOnQueue below. - // - status = SetForwardProgressOnQueue(queue); - if (!NT_SUCCESS(status)) { - return status; - } - -#endif - - // - // Now do any RAM-Disk specific initialization - // - pDeviceExtension->DiskRegInfo.DriveLetter.Buffer = - (PWSTR) &pDeviceExtension->DriveLetterBuffer; - pDeviceExtension->DiskRegInfo.DriveLetter.MaximumLength = - sizeof(pDeviceExtension->DriveLetterBuffer); - - // - // Get the disk parameters from the registry - // - RamDiskQueryDiskRegParameters( - WdfDriverGetRegistryPath(WdfDeviceGetDriver(device)), - &pDeviceExtension->DiskRegInfo - ); - - // - // Allocate memory for the disk image. - // - pDeviceExtension->DiskImage = ExAllocatePoolWithTag( - NonPagedPoolNx, - pDeviceExtension->DiskRegInfo.DiskSize, - RAMDISK_TAG - ); - - if (pDeviceExtension->DiskImage) { - - UNICODE_STRING deviceName; - UNICODE_STRING win32Name; - - RamDiskFormatDisk(pDeviceExtension); - - status = STATUS_SUCCESS; - - // - // Now try to create a symbolic link for the drive letter. - // - RtlInitUnicodeString(&win32Name, DOS_DEVICE_NAME); - RtlInitUnicodeString(&deviceName, NT_DEVICE_NAME); - - pDeviceExtension->SymbolicLink.Buffer = (PWSTR) - &pDeviceExtension->DosDeviceNameBuffer; - pDeviceExtension->SymbolicLink.MaximumLength = - sizeof(pDeviceExtension->DosDeviceNameBuffer); - pDeviceExtension->SymbolicLink.Length = win32Name.Length; - - RtlCopyUnicodeString(&pDeviceExtension->SymbolicLink, &win32Name); - RtlAppendUnicodeStringToString(&pDeviceExtension->SymbolicLink, - &pDeviceExtension->DiskRegInfo.DriveLetter); - - status = WdfDeviceCreateSymbolicLink(device, - &pDeviceExtension->SymbolicLink); - } - - return status; -} - -VOID -RamDiskQueryDiskRegParameters( - _In_ PWSTR RegistryPath, - _In_ PDISK_INFO DiskRegInfo - ) - -/*++ - -Routine Description: - - This routine is called from the DriverEntry to get the debug - parameters from the registry. If the registry query fails, then - default values are used. - -Arguments: - - RegistryPath - Points the service path to get the registry parameters - -Return Value: - - None - ---*/ - -{ - - RTL_QUERY_REGISTRY_TABLE rtlQueryRegTbl[5 + 1]; // Need 1 for NULL - NTSTATUS Status; - DISK_INFO defDiskRegInfo; - - PAGED_CODE(); - - ASSERT(RegistryPath != NULL); - - // Set the default values - - defDiskRegInfo.DiskSize = DEFAULT_DISK_SIZE; - defDiskRegInfo.RootDirEntries = DEFAULT_ROOT_DIR_ENTRIES; - defDiskRegInfo.SectorsPerCluster = DEFAULT_SECTORS_PER_CLUSTER; - - RtlInitUnicodeString(&defDiskRegInfo.DriveLetter, DEFAULT_DRIVE_LETTER); - - RtlZeroMemory(rtlQueryRegTbl, sizeof(rtlQueryRegTbl)); - - // - // Setup the query table - // - - rtlQueryRegTbl[0].Flags = RTL_QUERY_REGISTRY_SUBKEY; - rtlQueryRegTbl[0].Name = L"Parameters"; - rtlQueryRegTbl[0].EntryContext = NULL; - rtlQueryRegTbl[0].DefaultType = (ULONG_PTR)NULL; - rtlQueryRegTbl[0].DefaultData = NULL; - rtlQueryRegTbl[0].DefaultLength = (ULONG_PTR)NULL; - - // - // Disk paramters - // - - rtlQueryRegTbl[1].Flags = RTL_QUERY_REGISTRY_DIRECT; - rtlQueryRegTbl[1].Name = L"DiskSize"; - rtlQueryRegTbl[1].EntryContext = &DiskRegInfo->DiskSize; - rtlQueryRegTbl[1].DefaultType = REG_DWORD; - rtlQueryRegTbl[1].DefaultData = &defDiskRegInfo.DiskSize; - rtlQueryRegTbl[1].DefaultLength = sizeof(ULONG); - - rtlQueryRegTbl[2].Flags = RTL_QUERY_REGISTRY_DIRECT; - rtlQueryRegTbl[2].Name = L"RootDirEntries"; - rtlQueryRegTbl[2].EntryContext = &DiskRegInfo->RootDirEntries; - rtlQueryRegTbl[2].DefaultType = REG_DWORD; - rtlQueryRegTbl[2].DefaultData = &defDiskRegInfo.RootDirEntries; - rtlQueryRegTbl[2].DefaultLength = sizeof(ULONG); - - rtlQueryRegTbl[3].Flags = RTL_QUERY_REGISTRY_DIRECT; - rtlQueryRegTbl[3].Name = L"SectorsPerCluster"; - rtlQueryRegTbl[3].EntryContext = &DiskRegInfo->SectorsPerCluster; - rtlQueryRegTbl[3].DefaultType = REG_DWORD; - rtlQueryRegTbl[3].DefaultData = &defDiskRegInfo.SectorsPerCluster; - rtlQueryRegTbl[3].DefaultLength = sizeof(ULONG); - - rtlQueryRegTbl[4].Flags = RTL_QUERY_REGISTRY_DIRECT; - rtlQueryRegTbl[4].Name = L"DriveLetter"; - rtlQueryRegTbl[4].EntryContext = &DiskRegInfo->DriveLetter; - rtlQueryRegTbl[4].DefaultType = REG_SZ; - rtlQueryRegTbl[4].DefaultData = defDiskRegInfo.DriveLetter.Buffer; - rtlQueryRegTbl[4].DefaultLength = 0; - - - Status = RtlQueryRegistryValues( - RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, - RegistryPath, - rtlQueryRegTbl, - NULL, - NULL - ); - - if (NT_SUCCESS(Status) == FALSE) { - - DiskRegInfo->DiskSize = defDiskRegInfo.DiskSize; - DiskRegInfo->RootDirEntries = defDiskRegInfo.RootDirEntries; - DiskRegInfo->SectorsPerCluster = defDiskRegInfo.SectorsPerCluster; - RtlCopyUnicodeString(&DiskRegInfo->DriveLetter, &defDiskRegInfo.DriveLetter); - } - - KdPrint(("DiskSize = 0x%lx\n", DiskRegInfo->DiskSize)); - KdPrint(("RootDirEntries = 0x%lx\n", DiskRegInfo->RootDirEntries)); - KdPrint(("SectorsPerCluster = 0x%lx\n", DiskRegInfo->SectorsPerCluster)); - KdPrint(("DriveLetter = %wZ\n", &(DiskRegInfo->DriveLetter))); - - return; -} - -NTSTATUS -RamDiskFormatDisk( - IN PDEVICE_EXTENSION devExt - ) - -/*++ - -Routine Description: - - This routine formats the new disk. - - -Arguments: - - DeviceObject - Supplies a pointer to the device object that represents - the device whose capacity is to be read. - -Return Value: - - status is returned. - ---*/ -{ - - PBOOT_SECTOR bootSector = (PBOOT_SECTOR) devExt->DiskImage; - PUCHAR firstFatSector; - ULONG rootDirEntries; - ULONG sectorsPerCluster; - USHORT fatType; // Type FAT 12 or 16 - USHORT fatEntries; // Number of cluster entries in FAT - USHORT fatSectorCnt; // Number of sectors for FAT - PDIR_ENTRY rootDir; // Pointer to first entry in root dir - - PAGED_CODE(); - ASSERT(sizeof(BOOT_SECTOR) == 512); - ASSERT(devExt->DiskImage != NULL); - - RtlZeroMemory(devExt->DiskImage, devExt->DiskRegInfo.DiskSize); - - devExt->DiskGeometry.BytesPerSector = 512; - devExt->DiskGeometry.SectorsPerTrack = 32; // Using Ramdisk value - devExt->DiskGeometry.TracksPerCylinder = 2; // Using Ramdisk value - - // - // Calculate number of cylinders. - // - - devExt->DiskGeometry.Cylinders.QuadPart = devExt->DiskRegInfo.DiskSize / 512 / 32 / 2; - - // - // Our media type is RAMDISK_MEDIA_TYPE - // - - devExt->DiskGeometry.MediaType = RAMDISK_MEDIA_TYPE; - - KdPrint(( - "Cylinders: %I64d\n TracksPerCylinder: %lu\n SectorsPerTrack: %lu\n BytesPerSector: %lu\n", - devExt->DiskGeometry.Cylinders.QuadPart, devExt->DiskGeometry.TracksPerCylinder, - devExt->DiskGeometry.SectorsPerTrack, devExt->DiskGeometry.BytesPerSector - )); - - rootDirEntries = devExt->DiskRegInfo.RootDirEntries; - sectorsPerCluster = devExt->DiskRegInfo.SectorsPerCluster; - - // - // Round Root Directory entries up if necessary - // - - if (rootDirEntries & (DIR_ENTRIES_PER_SECTOR - 1)) { - - rootDirEntries = - (rootDirEntries + (DIR_ENTRIES_PER_SECTOR - 1)) & - ~ (DIR_ENTRIES_PER_SECTOR - 1); - } - - KdPrint(( - "Root dir entries: %lu\n Sectors/cluster: %lu\n", - rootDirEntries, sectorsPerCluster - )); - - // - // We need to have the 0xeb and 0x90 since this is one of the - // checks the file system recognizer uses - // - - bootSector->bsJump[0] = 0xeb; - bootSector->bsJump[1] = 0x3c; - bootSector->bsJump[2] = 0x90; - - // - // Set OemName to "RajuRam " - // NOTE: Fill all 8 characters, eg. sizeof(bootSector->bsOemName); - // - bootSector->bsOemName[0] = 'R'; - bootSector->bsOemName[1] = 'a'; - bootSector->bsOemName[2] = 'j'; - bootSector->bsOemName[3] = 'u'; - bootSector->bsOemName[4] = 'R'; - bootSector->bsOemName[5] = 'a'; - bootSector->bsOemName[6] = 'm'; - bootSector->bsOemName[7] = ' '; - - bootSector->bsBytesPerSec = (SHORT)devExt->DiskGeometry.BytesPerSector; - bootSector->bsResSectors = 1; - bootSector->bsFATs = 1; - bootSector->bsRootDirEnts = (USHORT)rootDirEntries; - - bootSector->bsSectors = (USHORT)(devExt->DiskRegInfo.DiskSize / - devExt->DiskGeometry.BytesPerSector); - bootSector->bsMedia = (UCHAR)devExt->DiskGeometry.MediaType; - bootSector->bsSecPerClus = (UCHAR)sectorsPerCluster; - - // - // Calculate number of sectors required for FAT - // - - fatEntries = - (bootSector->bsSectors - bootSector->bsResSectors - - bootSector->bsRootDirEnts / DIR_ENTRIES_PER_SECTOR) / - bootSector->bsSecPerClus + 2; - - // - // Choose between 12 and 16 bit FAT based on number of clusters we - // need to map - // - - if (fatEntries > 4087) { - fatType = 16; - fatSectorCnt = (fatEntries * 2 + 511) / 512; - fatEntries = fatEntries + fatSectorCnt; - fatSectorCnt = (fatEntries * 2 + 511) / 512; - } - else { - fatType = 12; - fatSectorCnt = (((fatEntries * 3 + 1) / 2) + 511) / 512; - fatEntries = fatEntries + fatSectorCnt; - fatSectorCnt = (((fatEntries * 3 + 1) / 2) + 511) / 512; - } - - bootSector->bsFATsecs = fatSectorCnt; - bootSector->bsSecPerTrack = (USHORT)devExt->DiskGeometry.SectorsPerTrack; - bootSector->bsHeads = (USHORT)devExt->DiskGeometry.TracksPerCylinder; - bootSector->bsBootSignature = 0x29; - bootSector->bsVolumeID = 0x12345678; - - // - // Set Label to "RamDisk " - // NOTE: Fill all 11 characters, eg. sizeof(bootSector->bsLabel); - // - bootSector->bsLabel[0] = 'R'; - bootSector->bsLabel[1] = 'a'; - bootSector->bsLabel[2] = 'm'; - bootSector->bsLabel[3] = 'D'; - bootSector->bsLabel[4] = 'i'; - bootSector->bsLabel[5] = 's'; - bootSector->bsLabel[6] = 'k'; - bootSector->bsLabel[7] = ' '; - bootSector->bsLabel[8] = ' '; - bootSector->bsLabel[9] = ' '; - bootSector->bsLabel[10] = ' '; - - // - // Set FileSystemType to "FAT1? " - // NOTE: Fill all 8 characters, eg. sizeof(bootSector->bsFileSystemType); - // - bootSector->bsFileSystemType[0] = 'F'; - bootSector->bsFileSystemType[1] = 'A'; - bootSector->bsFileSystemType[2] = 'T'; - bootSector->bsFileSystemType[3] = '1'; - bootSector->bsFileSystemType[4] = '?'; - bootSector->bsFileSystemType[5] = ' '; - bootSector->bsFileSystemType[6] = ' '; - bootSector->bsFileSystemType[7] = ' '; - - bootSector->bsFileSystemType[4] = ( fatType == 16 ) ? '6' : '2'; - - bootSector->bsSig2[0] = 0x55; - bootSector->bsSig2[1] = 0xAA; - - // - // The FAT is located immediately following the boot sector. - // - - firstFatSector = (PUCHAR)(bootSector + 1); - firstFatSector[0] = (UCHAR)devExt->DiskGeometry.MediaType; - firstFatSector[1] = 0xFF; - firstFatSector[2] = 0xFF; - - if (fatType == 16) { - firstFatSector[3] = 0xFF; - } - - // - // The Root Directory follows the FAT - // - rootDir = (PDIR_ENTRY)(bootSector + 1 + fatSectorCnt); - - // - // Set device name to "MS-RAMDR" - // NOTE: Fill all 8 characters, eg. sizeof(rootDir->deName); - // - rootDir->deName[0] = 'M'; - rootDir->deName[1] = 'S'; - rootDir->deName[2] = '-'; - rootDir->deName[3] = 'R'; - rootDir->deName[4] = 'A'; - rootDir->deName[5] = 'M'; - rootDir->deName[6] = 'D'; - rootDir->deName[7] = 'R'; - - // - // Set device extension name to "IVE" - // NOTE: Fill all 3 characters, eg. sizeof(rootDir->deExtension); - // - rootDir->deExtension[0] = 'I'; - rootDir->deExtension[1] = 'V'; - rootDir->deExtension[2] = 'E'; - - rootDir->deAttributes = DIR_ATTR_VOLUME; - - return STATUS_SUCCESS; -} - -BOOLEAN -RamDiskCheckParameters( - IN PDEVICE_EXTENSION devExt, - IN LARGE_INTEGER ByteOffset, - IN size_t Length - ) - -{ - // - // Check for invalid parameters. It is an error for the starting offset - // + length to go past the end of the buffer, or for the length to - // not be a proper multiple of the sector size. - // - // Others are possible, but we don't check them since we trust the - // file system. - // - - if( devExt->DiskRegInfo.DiskSize < Length || - ByteOffset.QuadPart < 0 || // QuadPart is signed so check for negative values - ((ULONGLONG)ByteOffset.QuadPart > (devExt->DiskRegInfo.DiskSize - Length)) || - (Length & (devExt->DiskGeometry.BytesPerSector - 1))) { - - // - // Do not give an I/O boost for parameter errors. - // - - KdPrint(( - "Error invalid parameter\n" - "ByteOffset: %I64x\n" - "Length: %lu\n", - ByteOffset.QuadPart, - Length - )); - - return FALSE; - } - - return TRUE; -} - diff --git a/storage/ramdisk/src/ramdisk.h b/storage/ramdisk/src/ramdisk.h deleted file mode 100644 index 764e1094..00000000 --- a/storage/ramdisk/src/ramdisk.h +++ /dev/null @@ -1,196 +0,0 @@ -/*++ - -Copyright (c) 1990-2003 Microsoft Corporation, All Rights Reserved - -Module Name: - - ramdisk.h - -Abstract: - - This file includes data declarations for the Ram Disk driver for NT. - -Environment: - - Kernel mode only. - ---*/ - -#ifndef _RAMDISK_H_ -#define _RAMDISK_H_ - -#pragma warning(disable:4201) // nameless struct/union warning - -#include <ntddk.h> -#include <ntdddisk.h> - -#pragma warning(default:4201) - -#include <wdf.h> -#define NTSTRSAFE_LIB -#include <ntstrsafe.h> -#include "forward_progress.h" - -#define NT_DEVICE_NAME L"\\Device\\Ramdisk" -#define DOS_DEVICE_NAME L"\\DosDevices\\" - -#define RAMDISK_TAG 'DmaR' // "RamD" -#define DOS_DEVNAME_LENGTH (sizeof(DOS_DEVICE_NAME)+sizeof(WCHAR)*10) -#define DRIVE_LETTER_LENGTH (sizeof(WCHAR)*10) - -#define DRIVE_LETTER_BUFFER_SIZE 10 -#define DOS_DEVNAME_BUFFER_SIZE (sizeof(DOS_DEVICE_NAME) / 2) + 10 - -#define RAMDISK_MEDIA_TYPE 0xF8 -#define DIR_ENTRIES_PER_SECTOR 16 - -#define DEFAULT_DISK_SIZE (1024*1024) // 1 MB -#define DEFAULT_ROOT_DIR_ENTRIES 512 -#define DEFAULT_SECTORS_PER_CLUSTER 2 -#define DEFAULT_DRIVE_LETTER L"Z:" - -typedef struct _DISK_INFO { - ULONG DiskSize; // Ramdisk size in bytes - ULONG RootDirEntries; // No. of root directory entries - ULONG SectorsPerCluster; // Sectors per cluster - UNICODE_STRING DriveLetter; // Drive letter to be used -} DISK_INFO, *PDISK_INFO; - -typedef struct _DEVICE_EXTENSION { - PUCHAR DiskImage; // Pointer to beginning of disk image - DISK_GEOMETRY DiskGeometry; // Drive parameters built by Ramdisk - DISK_INFO DiskRegInfo; // Disk parameters from the registry - UNICODE_STRING SymbolicLink; // Dos symbolic name; Drive letter - WCHAR DriveLetterBuffer[DRIVE_LETTER_BUFFER_SIZE]; - WCHAR DosDeviceNameBuffer[DOS_DEVNAME_BUFFER_SIZE]; -} DEVICE_EXTENSION, *PDEVICE_EXTENSION; - -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_EXTENSION, DeviceGetExtension) - -typedef struct _QUEUE_EXTENSION { - PDEVICE_EXTENSION DeviceExtension; -} QUEUE_EXTENSION, *PQUEUE_EXTENSION; - -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(QUEUE_EXTENSION, QueueGetExtension) - -#pragma pack(1) - -typedef struct _BOOT_SECTOR -{ - UCHAR bsJump[3]; // x86 jmp instruction, checked by FS - CCHAR bsOemName[8]; // OEM name of formatter - USHORT bsBytesPerSec; // Bytes per Sector - UCHAR bsSecPerClus; // Sectors per Cluster - USHORT bsResSectors; // Reserved Sectors - UCHAR bsFATs; // Number of FATs - we always use 1 - USHORT bsRootDirEnts; // Number of Root Dir Entries - USHORT bsSectors; // Number of Sectors - UCHAR bsMedia; // Media type - we use RAMDISK_MEDIA_TYPE - USHORT bsFATsecs; // Number of FAT sectors - USHORT bsSecPerTrack; // Sectors per Track - we use 32 - USHORT bsHeads; // Number of Heads - we use 2 - ULONG bsHiddenSecs; // Hidden Sectors - we set to 0 - ULONG bsHugeSectors; // Number of Sectors if > 32 MB size - UCHAR bsDriveNumber; // Drive Number - not used - UCHAR bsReserved1; // Reserved - UCHAR bsBootSignature; // New Format Boot Signature - 0x29 - ULONG bsVolumeID; // VolumeID - set to 0x12345678 - CCHAR bsLabel[11]; // Label - set to RamDisk - CCHAR bsFileSystemType[8];// File System Type - FAT12 or FAT16 - CCHAR bsReserved2[448]; // Reserved - UCHAR bsSig2[2]; // Originial Boot Signature - 0x55, 0xAA -} BOOT_SECTOR, *PBOOT_SECTOR; - -typedef struct _DIR_ENTRY -{ - UCHAR deName[8]; // File Name - UCHAR deExtension[3]; // File Extension - UCHAR deAttributes; // File Attributes - UCHAR deReserved; // Reserved - USHORT deTime; // File Time - USHORT deDate; // File Date - USHORT deStartCluster; // First Cluster of file - ULONG deFileSize; // File Length -} DIR_ENTRY, *PDIR_ENTRY; - -#pragma pack() - -// -// Directory Entry Attributes -// - -#define DIR_ATTR_READONLY 0x01 -#define DIR_ATTR_HIDDEN 0x02 -#define DIR_ATTR_SYSTEM 0x04 -#define DIR_ATTR_VOLUME 0x08 -#define DIR_ATTR_DIRECTORY 0x10 -#define DIR_ATTR_ARCHIVE 0x20 - -DRIVER_INITIALIZE DriverEntry; - -#if KMDF_VERSION_MINOR >= 7 - -EVT_WDF_DRIVER_DEVICE_ADD RamDiskEvtDeviceAdd; -EVT_WDF_DEVICE_CONTEXT_CLEANUP RamDiskEvtDeviceContextCleanup; -EVT_WDF_IO_QUEUE_IO_READ RamDiskEvtIoRead; -EVT_WDF_IO_QUEUE_IO_WRITE RamDiskEvtIoWrite; -EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL RamDiskEvtIoDeviceControl; - -#else - -NTSTATUS -RamDiskEvtDeviceAdd( - IN WDFDRIVER Driver, - IN PWDFDEVICE_INIT DeviceInit - ); - -VOID -RamDiskEvtDeviceContextCleanup( - IN WDFOBJECT Device - ); - -VOID -RamDiskEvtIoRead( - IN WDFQUEUE Queue, - IN WDFREQUEST Request, - IN size_t Length - ); - -VOID -RamDiskEvtIoWrite( - IN WDFQUEUE Queue, - IN WDFREQUEST Request, - IN size_t Length - ); - -VOID -RamDiskEvtIoDeviceControl( - IN WDFQUEUE Queue, - IN WDFREQUEST Request, - IN size_t OutputBufferLength, - IN size_t InputBufferLength, - IN ULONG IoControlCode - ); - -#endif - -VOID -RamDiskQueryDiskRegParameters( - _In_ PWSTR RegistryPath, - _In_ PDISK_INFO DiskRegInfo - ); - -NTSTATUS -RamDiskFormatDisk( - IN PDEVICE_EXTENSION DeviceExtension - ); - -BOOLEAN -RamDiskCheckParameters( - IN PDEVICE_EXTENSION devExt, - IN LARGE_INTEGER ByteOffset, - IN size_t Length - ); - -#endif // _RAMDISK_H_ - diff --git a/storage/ramdisk/src/ramdisk.inx b/storage/ramdisk/src/ramdisk.inx Binary files differdeleted file mode 100644 index b3de10f9..00000000 --- a/storage/ramdisk/src/ramdisk.inx +++ /dev/null diff --git a/storage/ramdisk/src/ramdisk.rc b/storage/ramdisk/src/ramdisk.rc deleted file mode 100644 index 1d0ded22..00000000 --- a/storage/ramdisk/src/ramdisk.rc +++ /dev/null @@ -1,11 +0,0 @@ -#include <windows.h> - -#include <ntverp.h> - -#define VER_FILETYPE VFT_DLL -#define VER_FILESUBTYPE VFT2_UNKNOWN -#define VER_FILEDESCRIPTION_STR "Driver Frameworks Ramdisk Driver" -#define VER_INTERNALNAME_STR "ramdisk.sys" -#define VER_ORIGINALFILENAME_STR "ramdisk.sys" - -#include "common.ver" diff --git a/storage/ramdisk/storage-ramdisk.yaml b/storage/ramdisk/storage-ramdisk.yaml deleted file mode 100644 index 438434ae..00000000 --- a/storage/ramdisk/storage-ramdisk.yaml +++ /dev/null @@ -1,10 +0,0 @@ -### YamlMime:Sample -sample: -- name: RAMDisk Storage Driver Sample - description: Demonstrates how to write a RAM disk software-only function driver using KMDF. - generateZip: true - author: windows-driver-samples - languages: - - cpp - technologies: - - windows |
