2 * Copyright (C) 2014 Raghava Aditya <Raghava.Aditya@pmcs.com>
3 * Copyright (C) 2015 Nidhi Malhotra <Nidhi.Malhotra@pmcs.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * You should have received a copy of the GNU General Public License
11 * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
16 #if defined(_WIN32) || defined(_WIN64)
26 #if __x86_64__ || __ppc64__
33 #define METHOD_BUFFERED 0
34 #define METHOD_NEITHER 3
36 #if defined(_WIN32) || defined(_WIN64)
37 #define FSAMPCTL_SCSI_BASE IOCTL_SCSI_BASE
38 #define ARCIOCTL_SEND_RAW_SRB CTL_CODE(FSAMPCTL_SCSI_BASE, 2201, METHOD_BUFFERED, FILE_ANY_ACCESS)
39 #define AACRAID_SAS_SIGNATURE "ARCSAS"
40 #define SRB_FLAGS_DATA_IN 0x00000040
41 #define SRB_FLAGS_DATA_OUT 0x00000080
42 #define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000
44 #define CTL_CODE(function, method) ((4<< 16) | ((function) << 2) | (method) )
46 #define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED)
48 #define SRB_FUNCTION_EXECUTE_SCSI 0X00
50 #define SRB_DataIn 0x0040
51 #define SRB_DataOut 0x0080
52 #define SRB_NoDataXfer 0x0000
61 uint32_t length
; /* Length. */
71 user_sgentry64 sg64
[1];
76 user_sgentry32 sg32
[1];
79 #if defined(_WIN32) || defined(_WIN64)
80 typedef struct _SCSI_REQUEST_BLOCK
{
81 USHORT Length
; // offset 0
82 UCHAR Function
; // offset 2
83 UCHAR SrbStatus
; // offset 3
84 UCHAR ScsiStatus
; // offset 4
85 UCHAR PathId
; // offset 5
86 UCHAR TargetId
; // offset 6
87 UCHAR Lun
; // offset 7
88 UCHAR QueueTag
; // offset 8
89 UCHAR QueueAction
; // offset 9
90 UCHAR CdbLength
; // offset a
91 UCHAR SenseInfoBufferLength
; // offset b
92 ULONG SrbFlags
; // offset c
93 ULONG DataTransferLength
; // offset 10
94 ULONG TimeOutValue
; // offset 14
95 PVOID DataBuffer
; // offset 18
96 PVOID SenseInfoBuffer
; // offset 1c
97 struct _SCSI_REQUEST_BLOCK
*NextSrb
; // offset 20
98 PVOID OriginalRequest
; // offset 24
99 PVOID SrbExtension
; // offset 28
101 ULONG InternalStatus
; // offset 2c
102 ULONG QueueSortKey
; // offset 2c
107 // Force PVOID alignment of Cdb
112 UCHAR Cdb
[16]; // offset 30
113 } SCSI_REQUEST_BLOCK
, *PSCSI_REQUEST_BLOCK
;
115 #define SCSI_REQUEST_BLOCK_SIZE sizeof(SCSI_REQUEST_BLOCK)
119 uint32_t function
; //SRB_FUNCTION_EXECUTE_SCSI 0x00
120 uint32_t channel
; //bus
121 uint32_t id
; //use the ID number this is wrong
122 uint32_t lun
; //Logical unit number
124 uint32_t flags
; //Interesting stuff I must say
125 uint32_t count
; // Data xfer size
126 uint32_t retry_limit
; // We shall see
127 uint32_t cdb_size
; // Length of CDB
128 uint8_t cdb
[16]; // The actual cdb command
129 user_sgmap64 sg64
; // pDatabuffer and address of Databuffer
133 uint32_t function
; //SRB_FUNCTION_EXECUTE_SCSI 0x00
134 uint32_t channel
; //bus
135 uint32_t id
; //use the ID number this is wrong
136 uint32_t lun
; //Logical unit number
138 uint32_t flags
; //Interesting stuff I must say
139 uint32_t count
; // Data xfer size
140 uint32_t retry_limit
; // We shall see
141 uint32_t cdb_size
; // Length of CDB
142 uint8_t cdb
[16]; // The actual cdb command
143 user_sgmap32 sg32
; // pDatabuffer and address of Databuffer
149 uint32_t scsi_status
;
150 uint32_t data_xfer_length
;
151 uint32_t sense_data_size
;
152 uint8_t sense_data
[30];