1
2 #ifndef _LINUX_HDREG_H
3 #define _LINUX_HDREG_H
4
5 #include <linux/types.h>
6
7
8
9
10
11 #define HDIO_DRIVE_CMD_HDR_SIZE (4 * sizeof(__u8))
12 #define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(__u8))
13 #define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(__u8))
14
15 #define IDE_DRIVE_TASK_NO_DATA 0
16 #ifndef __KERNEL__
17 #define IDE_DRIVE_TASK_INVALID -1
18 #define IDE_DRIVE_TASK_SET_XFER 1
19 #define IDE_DRIVE_TASK_IN 2
20 #define IDE_DRIVE_TASK_OUT 3
21 #endif
22 #define IDE_DRIVE_TASK_RAW_WRITE 4
23
24
25
26
27 #define IDE_TASKFILE_STD_IN_FLAGS 0xFE
28 #define IDE_HOB_STD_IN_FLAGS 0x3C
29 #ifndef __KERNEL__
30 #define IDE_TASKFILE_STD_OUT_FLAGS 0xFE
31 #define IDE_HOB_STD_OUT_FLAGS 0x3C
32
33 typedef unsigned char task_ioreg_t;
34 typedef unsigned long sata_ioreg_t;
35 #endif
36
37 typedef union ide_reg_valid_s {
38 unsigned all : 16;
39 struct {
40 unsigned data : 1;
41 unsigned error_feature : 1;
42 unsigned sector : 1;
43 unsigned nsector : 1;
44 unsigned lcyl : 1;
45 unsigned hcyl : 1;
46 unsigned select : 1;
47 unsigned status_command : 1;
48
49 unsigned data_hob : 1;
50 unsigned error_feature_hob : 1;
51 unsigned sector_hob : 1;
52 unsigned nsector_hob : 1;
53 unsigned lcyl_hob : 1;
54 unsigned hcyl_hob : 1;
55 unsigned select_hob : 1;
56 unsigned control_hob : 1;
57 } b;
58 } ide_reg_valid_t;
59
60 typedef struct ide_task_request_s {
61 __u8 io_ports[8];
62 __u8 hob_ports[8];
63 ide_reg_valid_t out_flags;
64 ide_reg_valid_t in_flags;
65 int data_phase;
66 int req_cmd;
67 unsigned long out_size;
68 unsigned long in_size;
69 } ide_task_request_t;
70
71 typedef struct ide_ioctl_request_s {
72 ide_task_request_t *task_request;
73 unsigned char *out_buffer;
74 unsigned char *in_buffer;
75 } ide_ioctl_request_t;
76
77 struct hd_drive_cmd_hdr {
78 __u8 command;
79 __u8 sector_number;
80 __u8 feature;
81 __u8 sector_count;
82 };
83
84 #ifndef __KERNEL__
85 typedef struct hd_drive_task_hdr {
86 __u8 data;
87 __u8 feature;
88 __u8 sector_count;
89 __u8 sector_number;
90 __u8 low_cylinder;
91 __u8 high_cylinder;
92 __u8 device_head;
93 __u8 command;
94 } task_struct_t;
95
96 typedef struct hd_drive_hob_hdr {
97 __u8 data;
98 __u8 feature;
99 __u8 sector_count;
100 __u8 sector_number;
101 __u8 low_cylinder;
102 __u8 high_cylinder;
103 __u8 device_head;
104 __u8 control;
105 } hob_struct_t;
106 #endif
107
108 #define TASKFILE_NO_DATA 0x0000
109
110 #define TASKFILE_IN 0x0001
111 #define TASKFILE_MULTI_IN 0x0002
112
113 #define TASKFILE_OUT 0x0004
114 #define TASKFILE_MULTI_OUT 0x0008
115 #define TASKFILE_IN_OUT 0x0010
116
117 #define TASKFILE_IN_DMA 0x0020
118 #define TASKFILE_OUT_DMA 0x0040
119 #define TASKFILE_IN_DMAQ 0x0080
120 #define TASKFILE_OUT_DMAQ 0x0100
121
122 #ifndef __KERNEL__
123 #define TASKFILE_P_IN 0x0200
124 #define TASKFILE_P_OUT 0x0400
125 #define TASKFILE_P_IN_DMA 0x0800
126 #define TASKFILE_P_OUT_DMA 0x1000
127 #define TASKFILE_P_IN_DMAQ 0x2000
128 #define TASKFILE_P_OUT_DMAQ 0x4000
129 #define TASKFILE_48 0x8000
130 #define TASKFILE_INVALID 0x7fff
131 #endif
132
133 #ifndef __KERNEL__
134
135 #define WIN_NOP 0x00
136
137
138
139 #define CFA_REQ_EXT_ERROR_CODE 0x03
140
141
142
143 #define WIN_SRST 0x08
144 #define WIN_DEVICE_RESET 0x08
145
146
147
148 #define WIN_RECAL 0x10
149 #define WIN_RESTORE WIN_RECAL
150
151
152
153 #define WIN_READ 0x20
154 #define WIN_READ_ONCE 0x21
155 #define WIN_READ_LONG 0x22
156 #define WIN_READ_LONG_ONCE 0x23
157 #define WIN_READ_EXT 0x24
158 #define WIN_READDMA_EXT 0x25
159 #define WIN_READDMA_QUEUED_EXT 0x26
160 #define WIN_READ_NATIVE_MAX_EXT 0x27
161
162
163
164 #define WIN_MULTREAD_EXT 0x29
165
166
167
168 #define WIN_WRITE 0x30
169 #define WIN_WRITE_ONCE 0x31
170 #define WIN_WRITE_LONG 0x32
171 #define WIN_WRITE_LONG_ONCE 0x33
172 #define WIN_WRITE_EXT 0x34
173 #define WIN_WRITEDMA_EXT 0x35
174 #define WIN_WRITEDMA_QUEUED_EXT 0x36
175 #define WIN_SET_MAX_EXT 0x37
176 #define CFA_WRITE_SECT_WO_ERASE 0x38
177 #define WIN_MULTWRITE_EXT 0x39
178
179
180
181 #define WIN_WRITE_VERIFY 0x3C
182
183
184
185 #define WIN_VERIFY 0x40
186 #define WIN_VERIFY_ONCE 0x41
187 #define WIN_VERIFY_EXT 0x42
188
189
190
191 #define WIN_FORMAT 0x50
192
193
194
195 #define WIN_INIT 0x60
196
197
198
199 #define WIN_SEEK 0x70
200
201 #define CFA_TRANSLATE_SECTOR 0x87
202 #define WIN_DIAGNOSE 0x90
203 #define WIN_SPECIFY 0x91
204 #define WIN_DOWNLOAD_MICROCODE 0x92
205 #define WIN_STANDBYNOW2 0x94
206 #define WIN_STANDBY2 0x96
207 #define WIN_SETIDLE2 0x97
208 #define WIN_CHECKPOWERMODE2 0x98
209 #define WIN_SLEEPNOW2 0x99
210
211
212
213 #define WIN_PACKETCMD 0xA0
214 #define WIN_PIDENTIFY 0xA1
215 #define WIN_QUEUED_SERVICE 0xA2
216 #define WIN_SMART 0xB0
217 #define CFA_ERASE_SECTORS 0xC0
218 #define WIN_MULTREAD 0xC4
219 #define WIN_MULTWRITE 0xC5
220 #define WIN_SETMULT 0xC6
221 #define WIN_READDMA_QUEUED 0xC7
222 #define WIN_READDMA 0xC8
223 #define WIN_READDMA_ONCE 0xC9
224 #define WIN_WRITEDMA 0xCA
225 #define WIN_WRITEDMA_ONCE 0xCB
226 #define WIN_WRITEDMA_QUEUED 0xCC
227 #define CFA_WRITE_MULTI_WO_ERASE 0xCD
228 #define WIN_GETMEDIASTATUS 0xDA
229 #define WIN_ACKMEDIACHANGE 0xDB
230 #define WIN_POSTBOOT 0xDC
231 #define WIN_PREBOOT 0xDD
232 #define WIN_DOORLOCK 0xDE
233 #define WIN_DOORUNLOCK 0xDF
234 #define WIN_STANDBYNOW1 0xE0
235 #define WIN_IDLEIMMEDIATE 0xE1
236 #define WIN_STANDBY 0xE2
237 #define WIN_SETIDLE1 0xE3
238 #define WIN_READ_BUFFER 0xE4
239 #define WIN_CHECKPOWERMODE1 0xE5
240 #define WIN_SLEEPNOW1 0xE6
241 #define WIN_FLUSH_CACHE 0xE7
242 #define WIN_WRITE_BUFFER 0xE8
243 #define WIN_WRITE_SAME 0xE9
244
245 #define WIN_FLUSH_CACHE_EXT 0xEA
246 #define WIN_IDENTIFY 0xEC
247 #define WIN_MEDIAEJECT 0xED
248 #define WIN_IDENTIFY_DMA 0xEE
249 #define WIN_SETFEATURES 0xEF
250 #define EXABYTE_ENABLE_NEST 0xF0
251 #define WIN_SECURITY_SET_PASS 0xF1
252 #define WIN_SECURITY_UNLOCK 0xF2
253 #define WIN_SECURITY_ERASE_PREPARE 0xF3
254 #define WIN_SECURITY_ERASE_UNIT 0xF4
255 #define WIN_SECURITY_FREEZE_LOCK 0xF5
256 #define WIN_SECURITY_DISABLE 0xF6
257 #define WIN_READ_NATIVE_MAX 0xF8
258 #define WIN_SET_MAX 0xF9
259 #define DISABLE_SEAGATE 0xFB
260
261
262
263 #define SMART_READ_VALUES 0xD0
264 #define SMART_READ_THRESHOLDS 0xD1
265 #define SMART_AUTOSAVE 0xD2
266 #define SMART_SAVE 0xD3
267 #define SMART_IMMEDIATE_OFFLINE 0xD4
268 #define SMART_READ_LOG_SECTOR 0xD5
269 #define SMART_WRITE_LOG_SECTOR 0xD6
270 #define SMART_WRITE_THRESHOLDS 0xD7
271 #define SMART_ENABLE 0xD8
272 #define SMART_DISABLE 0xD9
273 #define SMART_STATUS 0xDA
274 #define SMART_AUTO_OFFLINE 0xDB
275
276
277
278 #define SMART_LCYL_PASS 0x4F
279 #define SMART_HCYL_PASS 0xC2
280
281
282 #define SETFEATURES_EN_8BIT 0x01
283 #define SETFEATURES_EN_WCACHE 0x02
284 #define SETFEATURES_DIS_DEFECT 0x04
285 #define SETFEATURES_EN_APM 0x05
286 #define SETFEATURES_EN_SAME_R 0x22
287 #define SETFEATURES_DIS_MSN 0x31
288 #define SETFEATURES_DIS_RETRY 0x33
289 #define SETFEATURES_EN_AAM 0x42
290 #define SETFEATURES_RW_LONG 0x44
291 #define SETFEATURES_SET_CACHE 0x54
292 #define SETFEATURES_DIS_RLA 0x55
293 #define SETFEATURES_EN_RI 0x5D
294 #define SETFEATURES_EN_SI 0x5E
295 #define SETFEATURES_DIS_RPOD 0x66
296 #define SETFEATURES_DIS_ECC 0x77
297 #define SETFEATURES_DIS_8BIT 0x81
298 #define SETFEATURES_DIS_WCACHE 0x82
299 #define SETFEATURES_EN_DEFECT 0x84
300 #define SETFEATURES_DIS_APM 0x85
301 #define SETFEATURES_EN_ECC 0x88
302 #define SETFEATURES_EN_MSN 0x95
303 #define SETFEATURES_EN_RETRY 0x99
304 #define SETFEATURES_EN_RLA 0xAA
305 #define SETFEATURES_PREFETCH 0xAB
306 #define SETFEATURES_EN_REST 0xAC
307 #define SETFEATURES_4B_RW_LONG 0xBB
308 #define SETFEATURES_DIS_AAM 0xC2
309 #define SETFEATURES_EN_RPOD 0xCC
310 #define SETFEATURES_DIS_RI 0xDD
311 #define SETFEATURES_EN_SAME_M 0xDD
312 #define SETFEATURES_DIS_SI 0xDE
313
314
315
316 #define SECURITY_SET_PASSWORD 0xBA
317 #define SECURITY_UNLOCK 0xBB
318 #define SECURITY_ERASE_PREPARE 0xBC
319 #define SECURITY_ERASE_UNIT 0xBD
320 #define SECURITY_FREEZE_LOCK 0xBE
321 #define SECURITY_DISABLE_PASSWORD 0xBF
322 #endif
323
324 struct hd_geometry {
325 unsigned char heads;
326 unsigned char sectors;
327 unsigned short cylinders;
328 unsigned long start;
329 };
330
331
332 #define HDIO_GETGEO 0x0301
333 #define HDIO_GET_UNMASKINTR 0x0302
334 #define HDIO_GET_MULTCOUNT 0x0304
335 #define HDIO_GET_QDMA 0x0305
336
337 #define HDIO_SET_XFER 0x0306
338
339 #define HDIO_OBSOLETE_IDENTITY 0x0307
340 #define HDIO_GET_KEEPSETTINGS 0x0308
341 #define HDIO_GET_32BIT 0x0309
342 #define HDIO_GET_NOWERR 0x030a
343 #define HDIO_GET_DMA 0x030b
344 #define HDIO_GET_NICE 0x030c
345 #define HDIO_GET_IDENTITY 0x030d
346 #define HDIO_GET_WCACHE 0x030e
347 #define HDIO_GET_ACOUSTIC 0x030f
348 #define HDIO_GET_ADDRESS 0x0310
349
350 #define HDIO_GET_BUSSTATE 0x031a
351 #define HDIO_TRISTATE_HWIF 0x031b
352 #define HDIO_DRIVE_RESET 0x031c
353 #define HDIO_DRIVE_TASKFILE 0x031d
354 #define HDIO_DRIVE_TASK 0x031e
355 #define HDIO_DRIVE_CMD 0x031f
356 #define HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK
357
358
359 #define HDIO_SET_MULTCOUNT 0x0321
360 #define HDIO_SET_UNMASKINTR 0x0322
361 #define HDIO_SET_KEEPSETTINGS 0x0323
362 #define HDIO_SET_32BIT 0x0324
363 #define HDIO_SET_NOWERR 0x0325
364 #define HDIO_SET_DMA 0x0326
365 #define HDIO_SET_PIO_MODE 0x0327
366 #ifndef __KERNEL__
367 #define HDIO_SCAN_HWIF 0x0328
368 #define HDIO_UNREGISTER_HWIF 0x032a
369 #endif
370 #define HDIO_SET_NICE 0x0329
371 #define HDIO_SET_WCACHE 0x032b
372 #define HDIO_SET_ACOUSTIC 0x032c
373 #define HDIO_SET_BUSSTATE 0x032d
374 #define HDIO_SET_QDMA 0x032e
375 #define HDIO_SET_ADDRESS 0x032f
376
377
378 enum {
379 BUSSTATE_OFF = 0,
380 BUSSTATE_ON,
381 BUSSTATE_TRISTATE
382 };
383
384
385
386
387
388
389
390 #define __NEW_HD_DRIVE_ID
391
392 #ifndef __KERNEL__
393
394
395
396
397
398
399 struct hd_driveid {
400 unsigned short config;
401 unsigned short cyls;
402 unsigned short reserved2;
403 unsigned short heads;
404 unsigned short track_bytes;
405 unsigned short sector_bytes;
406 unsigned short sectors;
407 unsigned short vendor0;
408 unsigned short vendor1;
409 unsigned short vendor2;
410 unsigned char serial_no[20];
411 unsigned short buf_type;
412 unsigned short buf_size;
413
414
415 unsigned short ecc_bytes;
416 unsigned char fw_rev[8];
417 unsigned char model[40];
418 unsigned char max_multsect;
419 unsigned char vendor3;
420 unsigned short dword_io;
421 unsigned char vendor4;
422 unsigned char capability;
423
424
425
426
427
428 unsigned short reserved50;
429 unsigned char vendor5;
430 unsigned char tPIO;
431 unsigned char vendor6;
432 unsigned char tDMA;
433 unsigned short field_valid;
434
435
436
437
438 unsigned short cur_cyls;
439 unsigned short cur_heads;
440 unsigned short cur_sectors;
441 unsigned short cur_capacity0;
442 unsigned short cur_capacity1;
443 unsigned char multsect;
444 unsigned char multsect_valid;
445 unsigned int lba_capacity;
446 unsigned short dma_1word;
447 unsigned short dma_mword;
448 unsigned short eide_pio_modes;
449 unsigned short eide_dma_min;
450 unsigned short eide_dma_time;
451 unsigned short eide_pio;
452 unsigned short eide_pio_iordy;
453 unsigned short words69_70[2];
454
455
456 unsigned short words71_74[4];
457
458
459 unsigned short queue_depth;
460
461
462
463 unsigned short words76_79[4];
464 unsigned short major_rev_num;
465 unsigned short minor_rev_num;
466 unsigned short command_set_1;
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484 unsigned short command_set_2;
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502 unsigned short cfsse;
503
504
505
506
507
508
509
510
511
512
513
514 unsigned short cfs_enable_1;
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533 unsigned short cfs_enable_2;
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552 unsigned short csf_default;
553
554
555
556
557
558
559
560
561
562
563
564 unsigned short dma_ultra;
565 unsigned short trseuc;
566 unsigned short trsEuc;
567 unsigned short CurAPMvalues;
568 unsigned short mprc;
569 unsigned short hw_config;
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587 unsigned short acoustic;
588
589
590
591 unsigned short msrqs;
592 unsigned short sxfert;
593 unsigned short sal;
594 unsigned int spg;
595 unsigned long long lba_capacity_2;
596 unsigned short words104_125[22];
597 unsigned short last_lun;
598 unsigned short word127;
599
600
601
602
603
604
605
606 unsigned short dlf;
607
608
609
610
611
612
613
614
615
616
617
618 unsigned short csfo;
619
620
621
622
623
624
625
626 unsigned short words130_155[26];
627 unsigned short word156;
628 unsigned short words157_159[3];
629 unsigned short cfa_power;
630
631
632
633
634
635
636 unsigned short words161_175[15];
637 unsigned short words176_205[30];
638 unsigned short words206_254[49];
639 unsigned short integrity_word;
640
641
642
643 };
644 #endif
645
646
647
648
649
650
651 #define IDE_NICE_DSC_OVERLAP (0)
652 #define IDE_NICE_ATAPI_OVERLAP (1)
653 #define IDE_NICE_1 (3)
654 #ifndef __KERNEL__
655 #define IDE_NICE_0 (2)
656 #define IDE_NICE_2 (4)
657 #endif
658
659 #endif