aboutsummaryrefslogtreecommitdiff
path: root/sysutils/smartmontools-devel/files/patch-os_freebsd.h
blob: f4d397fffc29e80905d77836bdafe502ee9cfbd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
--- os_freebsd.h.orig	Sun Sep  5 09:16:07 2004
+++ os_freebsd.h	Sat Aug  6 21:08:54 2005
@@ -261,6 +261,262 @@
 
 #endif
 
+#ifdef  HAVE_SYS_TW_OSL_IOCTL_H
+#include <sys/tw_osl_ioctl.h>
+#else
+/*
+ * Following cut out of tw_osl_types.h
+ *
+ */
+
+typedef void			TW_VOID;
+typedef char			TW_INT8;
+typedef unsigned char		TW_UINT8;
+typedef short			TW_INT16;
+typedef unsigned short		TW_UINT16;
+typedef int			TW_INT32;
+typedef unsigned int		TW_UINT32;
+typedef long long		TW_INT64;
+typedef unsigned long long	TW_UINT64;
+
+/*
+ * Following cut out of tw_cl_share.h
+ *
+ */
+
+#pragma pack(1)
+
+struct tw_cl_event_packet {
+	TW_UINT32	sequence_id;
+	TW_UINT32	time_stamp_sec;
+	TW_UINT16	aen_code;
+	TW_UINT8	severity;
+	TW_UINT8	retrieved;
+	TW_UINT8	repeat_count;
+	TW_UINT8	parameter_len;
+	TW_UINT8	parameter_data[98];
+	TW_UINT32	event_src;
+	TW_UINT8	severity_str[20];
+};
+
+#pragma pack()
+
+/*
+ * Following cut out of tw_cl_fwif.h
+ *
+ */
+
+#define TWA_FW_CMD_ATA_PASSTHROUGH		0x11
+
+#define TWA_SENSE_DATA_LENGTH		18
+
+#pragma pack(1)
+/* 7000 structures. */
+struct tw_cl_command_init_connect {
+	TW_UINT8	res1__opcode;	/* 3:5 */
+	TW_UINT8	size;
+	TW_UINT8	request_id;
+	TW_UINT8	res2;
+	TW_UINT8	status;
+	TW_UINT8	flags;
+	TW_UINT16	message_credits;
+	TW_UINT32	features;
+	TW_UINT16	fw_srl;
+	TW_UINT16	fw_arch_id;
+	TW_UINT16	fw_branch;
+	TW_UINT16	fw_build;
+	TW_UINT32	result;
+};
+
+
+/* Structure for downloading firmware onto the controller. */
+struct tw_cl_command_download_firmware {
+	TW_UINT8	sgl_off__opcode;/* 3:5 */
+	TW_UINT8	size;
+	TW_UINT8	request_id;
+	TW_UINT8	unit;
+	TW_UINT8	status;
+	TW_UINT8	flags;
+	TW_UINT16	param;
+	TW_UINT8	sgl[1];
+};
+
+
+/* Structure for hard resetting the controller. */
+struct tw_cl_command_reset_firmware {
+	TW_UINT8	res1__opcode;	/* 3:5 */
+	TW_UINT8	size;
+	TW_UINT8	request_id;
+	TW_UINT8	unit;
+	TW_UINT8	status;
+	TW_UINT8	flags;
+	TW_UINT8	res2;
+	TW_UINT8	param;
+};
+
+
+/* Structure for sending get/set param commands. */
+struct tw_cl_command_param {
+	TW_UINT8	sgl_off__opcode;/* 3:5 */
+	TW_UINT8	size;
+	TW_UINT8	request_id;
+	TW_UINT8	host_id__unit;	/* 4:4 */
+	TW_UINT8	status;
+	TW_UINT8	flags;
+	TW_UINT16	param_count;
+	TW_UINT8	sgl[1];
+};
+
+
+/* Generic command packet. */
+struct tw_cl_command_generic {
+	TW_UINT8	sgl_off__opcode;/* 3:5 */
+	TW_UINT8	size;
+	TW_UINT8	request_id;
+	TW_UINT8	host_id__unit;	/* 4:4 */
+	TW_UINT8	status;
+	TW_UINT8	flags;
+	TW_UINT16	count;	/* block cnt, parameter cnt, message credits */
+};
+
+
+/* Command packet header. */
+struct tw_cl_command_header {
+	TW_UINT8	sense_data[TWA_SENSE_DATA_LENGTH];
+	struct {
+		TW_INT8		reserved[4];
+		TW_UINT16	error;
+		TW_UINT8	padding;
+		TW_UINT8	res__severity;	/* 5:3 */
+	} status_block;
+	TW_UINT8	err_specific_desc[98];
+	struct {
+		TW_UINT8	size_header;
+		TW_UINT16	reserved;
+		TW_UINT8	size_sense;
+	} header_desc;
+};
+
+
+/* 7000 Command packet. */
+union tw_cl_command_7k {
+	struct tw_cl_command_init_connect	init_connect;
+	struct tw_cl_command_download_firmware	download_fw;
+	struct tw_cl_command_reset_firmware	reset_fw;
+	struct tw_cl_command_param		param;
+	struct tw_cl_command_generic		generic;
+	TW_UINT8	padding[1024 - sizeof(struct tw_cl_command_header)];
+};
+
+
+/* 9000 Command Packet. */
+struct tw_cl_command_9k {
+	TW_UINT8	res__opcode;	/* 3:5 */
+	TW_UINT8	unit;
+	TW_UINT16	lun_l4__req_id;	/* 4:12 */
+	TW_UINT8	status;
+	TW_UINT8	sgl_offset; /* offset (in bytes) to sg_list, from the
+					end of sgl_entries */
+	TW_UINT16	lun_h4__sgl_entries;
+	TW_UINT8	cdb[16];
+	TW_UINT8	sg_list[872];/* total struct size =
+					1024-sizeof(cmd_hdr) */
+};
+
+
+/* Full command packet. */
+struct tw_cl_command_packet {
+	struct tw_cl_command_header	cmd_hdr;
+	union {
+		union tw_cl_command_7k	cmd_pkt_7k;
+		struct tw_cl_command_9k cmd_pkt_9k;
+	} command;
+};
+
+#pragma pack()
+
+/*
+ * Following cut out of tw_cl_ioctl.h
+ *
+ */
+
+#pragma pack(1)
+
+/* Structure used to handle GET/RELEASE LOCK ioctls. */
+struct tw_cl_lock_packet {
+	TW_UINT32	timeout_msec;
+	TW_UINT32	time_remaining_msec;
+	TW_UINT32	force_flag;
+};
+
+
+/* Structure used to handle GET COMPATIBILITY INFO ioctl. */
+struct tw_cl_compatibility_packet {
+	TW_UINT8	driver_version[32];/* driver version */
+	TW_UINT16	working_srl;	/* driver & firmware negotiated srl */
+	TW_UINT16	working_branch;	/* branch # of the firmware that the
+					driver is compatible with */
+	TW_UINT16	working_build;	/* build # of the firmware that the
+					driver is compatible with */
+};
+
+
+/* Driver understandable part of the ioctl packet built by the API. */
+struct tw_cl_driver_packet {
+	TW_UINT32	control_code;
+	TW_UINT32	status;
+	TW_UINT32	unique_id;
+	TW_UINT32	sequence_id;
+	TW_UINT32	os_status;
+	TW_UINT32	buffer_length;
+};
+
+#pragma pack()
+
+/*
+ * Following cut out of tw_osl_ioctl.h
+ *
+ */
+
+#pragma pack(1)
+/*
+ * We need the structure below to ensure that the first byte of
+ * data_buf is not overwritten by the kernel, after we return
+ * from the ioctl call.  Note that cmd_pkt has been reduced
+ * to an array of 1024 bytes even though it's actually 2048 bytes
+ * in size.  This is because, we don't expect requests from user
+ * land requiring 2048 (273 sg elements) byte cmd pkts.
+ */
+typedef struct tw_osli_ioctl_no_data_buf {
+	struct tw_cl_driver_packet	driver_pkt;
+	TW_VOID				*pdata; /* points to data_buf */
+	TW_INT8				padding[488 - sizeof(TW_VOID *)];
+	struct tw_cl_command_packet	cmd_pkt;
+} TW_OSLI_IOCTL_NO_DATA_BUF;
+
+#pragma pack()
+
+#define TW_OSL_IOCTL_FIRMWARE_PASS_THROUGH		\
+	_IOWR('T', 202, TW_OSLI_IOCTL_NO_DATA_BUF)
+
+#pragma pack(1)
+
+typedef struct tw_osli_ioctl_with_payload {
+	struct tw_cl_driver_packet	driver_pkt;
+	TW_INT8				padding[488];
+	struct tw_cl_command_packet	cmd_pkt;
+	union {
+		struct tw_cl_event_packet		event_pkt;
+		struct tw_cl_lock_packet		lock_pkt;
+		struct tw_cl_compatibility_packet	compat_pkt;
+		TW_INT8					data_buf[1];
+	} payload;
+} TW_OSLI_IOCTL_WITH_PAYLOAD;
+
+#pragma pack()
+
+#endif
+
 /* 
    The following definitions/macros/prototypes are used for three
    different interfaces, referred to as "the three cases" below.