]>
Commit | Line | Data |
---|---|---|
d2e702cf GI |
1 | /* aacraid.h |
2 | * Copyright (C) 2014 Raghava Aditya <Raghava.Aditya@pmcs.com> | |
293b5ab8 | 3 | * Copyright (C) 2015 Nidhi Malhotra <Nidhi.Malhotra@pmcs.com> |
d2e702cf GI |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2, or (at your option) | |
8 | * any later version. | |
9 | * | |
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/>. | |
12 | * | |
13 | */ | |
14 | ||
15 | // Check windows | |
293b5ab8 JD |
16 | #if defined(_WIN32) || defined(_WIN64) |
17 | #ifdef _WIN64 | |
d2e702cf GI |
18 | #define ENVIRONMENT64 |
19 | #else | |
20 | #define ENVIRONMENT32 | |
21 | #endif | |
22 | #endif | |
23 | ||
24 | // Check GCC | |
25 | #if __GNUC__ | |
26 | #if __x86_64__ || __ppc64__ | |
27 | #define ENVIRONMENT64 | |
28 | #else | |
29 | #define ENVIRONMENT32 | |
30 | #endif | |
31 | #endif | |
32 | ||
33 | #define METHOD_BUFFERED 0 | |
34 | #define METHOD_NEITHER 3 | |
35 | ||
293b5ab8 JD |
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 | |
43 | #else | |
d2e702cf GI |
44 | #define CTL_CODE(function, method) ((4<< 16) | ((function) << 2) | (method) ) |
45 | ||
46 | #define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED) | |
293b5ab8 | 47 | #endif |
d2e702cf GI |
48 | #define SRB_FUNCTION_EXECUTE_SCSI 0X00 |
49 | ||
50 | #define SRB_DataIn 0x0040 | |
51 | #define SRB_DataOut 0x0080 | |
52 | #define SRB_NoDataXfer 0x0000 | |
53 | ||
54 | typedef struct { | |
55 | uint32_t lo32; | |
56 | uint32_t hi32; | |
57 | } address64; | |
58 | ||
59 | typedef struct { | |
60 | address64 addr64; | |
61 | uint32_t length; /* Length. */ | |
62 | } user_sgentry64; | |
63 | ||
64 | typedef struct { | |
65 | uint32_t addr32; | |
66 | uint32_t length; | |
67 | } user_sgentry32; | |
68 | ||
69 | typedef struct { | |
70 | uint32_t count; | |
71 | user_sgentry64 sg64[1]; | |
72 | } user_sgmap64; | |
73 | ||
74 | typedef struct { | |
75 | uint32_t count; | |
76 | user_sgentry32 sg32[1]; | |
77 | } user_sgmap32; | |
78 | ||
293b5ab8 JD |
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 | |
100 | union { | |
101 | ULONG InternalStatus; // offset 2c | |
102 | ULONG QueueSortKey; // offset 2c | |
103 | }; | |
104 | ||
105 | #if defined(_WIN64) | |
106 | // | |
107 | // Force PVOID alignment of Cdb | |
108 | // | |
109 | ULONG Reserved; | |
110 | #endif | |
111 | ||
112 | UCHAR Cdb[16]; // offset 30 | |
113 | } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK; | |
114 | ||
115 | #define SCSI_REQUEST_BLOCK_SIZE sizeof(SCSI_REQUEST_BLOCK) | |
116 | ||
117 | #else | |
d2e702cf GI |
118 | typedef struct { |
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 | |
123 | uint32_t timeout; | |
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 | |
130 | } user_aac_srb64; | |
131 | ||
132 | typedef struct { | |
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 | |
137 | uint32_t timeout; | |
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 | |
144 | } user_aac_srb32; | |
145 | ||
146 | typedef struct { | |
147 | uint32_t status; | |
148 | uint32_t srb_status; | |
149 | uint32_t scsi_status; | |
150 | uint32_t data_xfer_length; | |
151 | uint32_t sense_data_size; | |
152 | uint8_t sense_data[30]; | |
153 | } user_aac_reply; | |
293b5ab8 | 154 | #endif |