mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:05:49 +00:00
[SPTILIB] Introduce SPTI static library for storage drivers (#8209)
Add a SCSI and ATA passthrough support helper library for direct use from low-level storage drivers. Tested with: CDRoller, CloneCD, Magic ISO NOTE: Vbox seems to lack support for CD/DVD burning; tested on real hardware. CORE-10191 CORE-16452 CORE-14788 CORE-18241 CORE-17256 CORE-13866
This commit is contained in:
parent
5bd84f6f71
commit
b558596409
12 changed files with 1285 additions and 14 deletions
7
sdk/lib/drivers/sptilib/CMakeLists.txt
Normal file
7
sdk/lib/drivers/sptilib/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
list(APPEND SOURCE
|
||||
sptilib.c)
|
||||
|
||||
add_library(sptilib ${SOURCE})
|
||||
target_link_libraries(sptilib PRIVATE ${PSEH_LIB})
|
||||
add_dependencies(sptilib xdk)
|
1008
sdk/lib/drivers/sptilib/sptilib.c
Normal file
1008
sdk/lib/drivers/sptilib/sptilib.c
Normal file
File diff suppressed because it is too large
Load diff
85
sdk/lib/drivers/sptilib/sptilib.h
Normal file
85
sdk/lib/drivers/sptilib/sptilib.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Storage Stack
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: Public header of the ATA and SCSI Pass Through Interface for storage drivers
|
||||
* COPYRIGHT: Copyright 2025 Dmitry Borisov <di.sean@protonmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* ATA Protocol field definitions for the ATA passthrough commands
|
||||
* (SCSIOP_ATA_PASSTHROUGH12 and SCSIOP_ATA_PASSTHROUGH16).
|
||||
*/
|
||||
/*@{*/
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_HARDWARE_RESET 0x0
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_SOFTWARE_RESET 0x1
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_NON_DATA 0x3
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_PIO_DATA_IN 0x4
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_PIO_DATA_OUT 0x5
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_DMA 0x6
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_DEVICE_DIAG 0x8
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_DEVICE_RESET 0x9
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_UDMA_DATA_IN 0xA
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_UDMA_DATA_OUT 0xB
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_NCQ 0xC
|
||||
#define ATA_PASSTHROUGH_PROTOCOL_RETURN_RESPONSE 0xF
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Additional sense code for the successfully completed ATA passthrough commands
|
||||
* with check condition enabled.
|
||||
*/
|
||||
#define SCSI_SENSEQ_ATA_PASS_THROUGH_INFORMATION_AVAILABLE 0x1D
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Handler for the IOCTL_ATA_PASS_THROUGH and IOCTL_ATA_PASS_THROUGH_DIRECT requests.
|
||||
*
|
||||
* @param[in] DeviceObject
|
||||
* PDO device object.
|
||||
*
|
||||
* @param[in,out] Irp
|
||||
* Pointer to the IOCTL request.
|
||||
*
|
||||
* @param[in] MaximumTransferLength
|
||||
* Maximum size of data transfer for a device.
|
||||
*
|
||||
* @param[in] MaximumPhysicalPages
|
||||
* Maximum number of physical pages per data transfer for a device.
|
||||
*
|
||||
* @return Status.
|
||||
*/
|
||||
CODE_SEG("PAGE")
|
||||
NTSTATUS
|
||||
SptiHandleAtaPassthru(
|
||||
_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp,
|
||||
_In_ ULONG MaximumTransferLength,
|
||||
_In_ ULONG MaximumPhysicalPages);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Handler for the IOCTL_SCSI_PASS_THROUGH and IOCTL_SCSI_PASS_THROUGH_DIRECT requests.
|
||||
*
|
||||
* @param[in] DeviceObject
|
||||
* PDO device object.
|
||||
*
|
||||
* @param[in,out] Irp
|
||||
* Pointer to the IOCTL request.
|
||||
*
|
||||
* @param[in] MaximumTransferLength
|
||||
* Maximum size of data transfer for a device.
|
||||
*
|
||||
* @param[in] MaximumPhysicalPages
|
||||
* Maximum number of physical pages per data transfer for a device.
|
||||
*
|
||||
* @return Status.
|
||||
*/
|
||||
CODE_SEG("PAGE")
|
||||
NTSTATUS
|
||||
SptiHandleScsiPassthru(
|
||||
_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp,
|
||||
_In_ ULONG MaximumTransferLength,
|
||||
_In_ ULONG MaximumPhysicalPages);
|
35
sdk/lib/drivers/sptilib/sptilibp.h
Normal file
35
sdk/lib/drivers/sptilib/sptilibp.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Storage Stack
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: Private header of the ATA and SCSI Pass Through Interface for storage drivers
|
||||
* COPYRIGHT: Copyright 2025 Dmitry Borisov <di.sean@protonmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SPTI allocation tag.
|
||||
*/
|
||||
#define TAG_SPTI 'ITPS'
|
||||
|
||||
/**
|
||||
* Timeouts to wait for a request to be completed, in seconds.
|
||||
*/
|
||||
/*@{*/
|
||||
#define PASSTHROUGH_CMD_TIMEOUT_MIN_SEC 1
|
||||
#define PASSTHROUGH_CMD_TIMEOUT_MAX_SEC (30 * 60 * 60) // 30 hours
|
||||
/*@}*/
|
||||
|
||||
#define GET_IOCTL(IoStack) ((IoStack)->Parameters.DeviceIoControl.IoControlCode)
|
||||
|
||||
typedef union _PASSTHROUGH_DATA
|
||||
{
|
||||
PVOID Buffer;
|
||||
ULONG_PTR BufferOffset;
|
||||
} PASSTHROUGH_DATA, *PPASSTHROUGH_DATA;
|
||||
|
||||
typedef struct _PASSTHROUGH_IRP_CONTEXT
|
||||
{
|
||||
SCSI_REQUEST_BLOCK Srb;
|
||||
PIRP Irp;
|
||||
} PASSTHROUGH_IRP_CONTEXT, *PPASSTHROUGH_IRP_CONTEXT;
|
Loading…
Add table
Add a link
Reference in a new issue