]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - aacraid.h
import smartmontools 7.0
[mirror_smartmontools-debian.git] / aacraid.h
CommitLineData
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 4 *
ff28b140 5 * SPDX-License-Identifier: GPL-2.0-or-later
d2e702cf
GI
6 */
7
8// Check windows
293b5ab8
JD
9#if defined(_WIN32) || defined(_WIN64)
10#ifdef _WIN64
d2e702cf
GI
11 #define ENVIRONMENT64
12#else
13 #define ENVIRONMENT32
14#endif
15#endif
16
17// Check GCC
18#if __GNUC__
19#if __x86_64__ || __ppc64__
20 #define ENVIRONMENT64
21#else
22 #define ENVIRONMENT32
23#endif
24#endif
25
26#define METHOD_BUFFERED 0
27#define METHOD_NEITHER 3
28
293b5ab8
JD
29#if defined(_WIN32) || defined(_WIN64)
30#define FSAMPCTL_SCSI_BASE IOCTL_SCSI_BASE
31#define ARCIOCTL_SEND_RAW_SRB CTL_CODE(FSAMPCTL_SCSI_BASE, 2201, METHOD_BUFFERED, FILE_ANY_ACCESS)
32#define AACRAID_SAS_SIGNATURE "ARCSAS"
33#define SRB_FLAGS_DATA_IN 0x00000040
34#define SRB_FLAGS_DATA_OUT 0x00000080
35#define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000
36#else
d2e702cf
GI
37#define CTL_CODE(function, method) ((4<< 16) | ((function) << 2) | (method) )
38
39#define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED)
293b5ab8 40#endif
d2e702cf
GI
41#define SRB_FUNCTION_EXECUTE_SCSI 0X00
42
43#define SRB_DataIn 0x0040
44#define SRB_DataOut 0x0080
45#define SRB_NoDataXfer 0x0000
46
47typedef struct {
48 uint32_t lo32;
49 uint32_t hi32;
50 } address64;
51
52typedef struct {
53 address64 addr64;
54 uint32_t length; /* Length. */
55 } user_sgentry64;
56
57typedef struct {
58 uint32_t addr32;
59 uint32_t length;
60 } user_sgentry32;
61
62typedef struct {
63 uint32_t count;
64 user_sgentry64 sg64[1];
65 } user_sgmap64;
66
67typedef struct {
68 uint32_t count;
69 user_sgentry32 sg32[1];
70 } user_sgmap32;
71
293b5ab8
JD
72#if defined(_WIN32) || defined(_WIN64)
73typedef struct _SCSI_REQUEST_BLOCK {
74 USHORT Length; // offset 0
75 UCHAR Function; // offset 2
76 UCHAR SrbStatus; // offset 3
77 UCHAR ScsiStatus; // offset 4
78 UCHAR PathId; // offset 5
79 UCHAR TargetId; // offset 6
80 UCHAR Lun; // offset 7
81 UCHAR QueueTag; // offset 8
82 UCHAR QueueAction; // offset 9
83 UCHAR CdbLength; // offset a
84 UCHAR SenseInfoBufferLength; // offset b
85 ULONG SrbFlags; // offset c
86 ULONG DataTransferLength; // offset 10
87 ULONG TimeOutValue; // offset 14
88 PVOID DataBuffer; // offset 18
89 PVOID SenseInfoBuffer; // offset 1c
90 struct _SCSI_REQUEST_BLOCK *NextSrb; // offset 20
91 PVOID OriginalRequest; // offset 24
92 PVOID SrbExtension; // offset 28
93 union {
94 ULONG InternalStatus; // offset 2c
95 ULONG QueueSortKey; // offset 2c
96 };
97
98#if defined(_WIN64)
99 //
100 // Force PVOID alignment of Cdb
101 //
102 ULONG Reserved;
103#endif
104
105 UCHAR Cdb[16]; // offset 30
106} SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
107
108#define SCSI_REQUEST_BLOCK_SIZE sizeof(SCSI_REQUEST_BLOCK)
109
110#else
d2e702cf
GI
111typedef struct {
112 uint32_t function; //SRB_FUNCTION_EXECUTE_SCSI 0x00
113 uint32_t channel; //bus
114 uint32_t id; //use the ID number this is wrong
115 uint32_t lun; //Logical unit number
116 uint32_t timeout;
117 uint32_t flags; //Interesting stuff I must say
118 uint32_t count; // Data xfer size
119 uint32_t retry_limit; // We shall see
120 uint32_t cdb_size; // Length of CDB
121 uint8_t cdb[16]; // The actual cdb command
122 user_sgmap64 sg64; // pDatabuffer and address of Databuffer
123 } user_aac_srb64;
124
125typedef struct {
126 uint32_t function; //SRB_FUNCTION_EXECUTE_SCSI 0x00
127 uint32_t channel; //bus
128 uint32_t id; //use the ID number this is wrong
129 uint32_t lun; //Logical unit number
130 uint32_t timeout;
131 uint32_t flags; //Interesting stuff I must say
132 uint32_t count; // Data xfer size
133 uint32_t retry_limit; // We shall see
134 uint32_t cdb_size; // Length of CDB
135 uint8_t cdb[16]; // The actual cdb command
136 user_sgmap32 sg32; // pDatabuffer and address of Databuffer
137 } user_aac_srb32;
138
139typedef struct {
140 uint32_t status;
141 uint32_t srb_status;
142 uint32_t scsi_status;
143 uint32_t data_xfer_length;
144 uint32_t sense_data_size;
145 uint8_t sense_data[30];
146 } user_aac_reply;
293b5ab8 147#endif