1 /* $Id: him.h,v 1.57 2011/02/21 06:03:21 zsf Exp $ */
3 * Copyright (C) 2004-2005 HighPoint Technologies, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <dev/hptnr/hptnr_config.h>
33 #define VERMAGIC_HIM 55
35 #if defined(__cplusplus)
39 #include <dev/hptnr/list.h>
41 #define SECTOR_TO_BYTE_SHIFT 9
42 #define SECTOR_TO_BYTE(x) ((HPT_U32)(x) << SECTOR_TO_BYTE_SHIFT)
43 #define BYTE_TO_SECTOR(x) ((x)>>SECTOR_TO_BYTE_SHIFT)
45 typedef struct _PCI_ID
56 typedef struct _PCI_ADDRESS
65 typedef struct _HIM_ADAPTER_CONFIG
72 HPT_U8 bProbeInInitializing:1;
74 HPT_U8 bSpinupOneDevEachTime:1;
77 HPT_U8 bSGPIOPartSupport:1;
79 HPT_U8 bNeedSASIdleTimer:1;
90 HPT_U8 szVendorID[36];
91 HPT_U8 szProductID[36];
101 HIM_ADAPTER_CONFIG, *PHIM_ADAPTER_CONFIG;
103 typedef struct _HIM_CHANNEL_CONFIG
107 } HIM_CHANNEL_CONFIG, *PHIM_CHANNEL_CONFIG;
109 typedef struct _HIM_DEVICE_FLAGS
111 HPT_UINT df_atapi :1;
112 HPT_UINT df_removable_drive :1;
113 HPT_UINT df_on_line :1;
114 HPT_UINT df_reduce_mode :1;
116 HPT_UINT df_on_pm_port :1;
117 HPT_UINT df_support_read_ahead :1;
118 HPT_UINT df_read_ahead_enabled :1;
119 HPT_UINT df_support_write_cache :1;
120 HPT_UINT df_write_cache_enabled :1;
121 HPT_UINT df_cdrom_device :1;
122 HPT_UINT df_tape_device :1;
123 HPT_UINT df_support_tcq :1;
124 HPT_UINT df_tcq_enabled :1;
125 HPT_UINT df_support_ncq :1;
126 HPT_UINT df_ncq_enabled :1;
128 HPT_UINT df_in_enclosure :1;
130 } DEVICE_FLAGS, *PDEVICE_FLAGS;
133 typedef struct _IDENTIFY_DATA {
134 HPT_U16 GeneralConfiguration;
135 HPT_U16 NumberOfCylinders;
137 HPT_U16 NumberOfHeads;
138 HPT_U16 UnformattedBytesPerTrack;
139 HPT_U16 UnformattedBytesPerSector;
140 HPT_U8 SasAddress[8];
141 HPT_U16 SerialNumber[10];
143 HPT_U16 BufferSectorSize;
144 HPT_U16 NumberOfEccBytes;
145 HPT_U16 FirmwareRevision[4];
146 HPT_U16 ModelNumber[20];
147 HPT_U8 MaximumBlockTransfer;
148 HPT_U8 VendorUnique2;
149 HPT_U16 DoubleWordIo;
150 HPT_U16 Capabilities;
152 HPT_U8 VendorUnique3;
153 HPT_U8 PioCycleTimingMode;
154 HPT_U8 VendorUnique4;
155 HPT_U8 DmaCycleTimingMode;
156 HPT_U16 TranslationFieldsValid;
157 HPT_U16 NumberOfCurrentCylinders;
158 HPT_U16 NumberOfCurrentHeads;
159 HPT_U16 CurrentSectorsPerTrack;
160 HPT_U32 CurrentSectorCapacity;
161 HPT_U16 CurrentMultiSectorSetting;
162 HPT_U32 UserAddressableSectors;
163 HPT_U8 SingleWordDMASupport;
164 HPT_U8 SingleWordDMAActive;
165 HPT_U8 MultiWordDMASupport;
166 HPT_U8 MultiWordDMAActive;
167 HPT_U8 AdvancedPIOModes;
169 HPT_U16 MinimumMWXferCycleTime;
170 HPT_U16 RecommendedMWXferCycleTime;
171 HPT_U16 MinimumPIOCycleTime;
172 HPT_U16 MinimumPIOCycleTimeIORDY;
173 HPT_U16 Reserved5[2];
174 HPT_U16 ReleaseTimeOverlapped;
175 HPT_U16 ReleaseTimeServiceCommand;
176 HPT_U16 MajorRevision;
177 HPT_U16 MinorRevision;
178 HPT_U16 MaxQueueDepth;
179 HPT_U16 SataCapability;
180 HPT_U16 Reserved6[9];
181 HPT_U16 CommandSupport;
182 HPT_U16 CommandEnable;
183 HPT_U16 UtralDmaMode;
184 HPT_U16 Reserved7[11];
186 HPT_U32 Lba48BitHigh;
187 HPT_U16 Reserved8[23];
188 HPT_U16 SpecialFunctionsEnabled;
189 HPT_U16 Reserved9[128];
192 __attribute__((packed))
194 IDENTIFY_DATA, *PIDENTIFY_DATA;
197 typedef struct _HIM_DEVICE_CONFIG
205 HPT_U8 max_queue_depth;
209 HPT_U8 transfer_mode;
211 HPT_U8 bDeUsable_Mode;
213 HPT_U16 max_sectors_per_cmd;
215 PIDENTIFY_DATA pIdentifyData;
218 HPT_U8 fixed_path_id; /*equals to phy id */
220 HIM_DEVICE_CONFIG, *PHIM_DEVICE_CONFIG;
225 #define _DIT_READ_AHEAD 2
226 #define _DIT_WRITE_CACHE 3
229 #define _DIT_BEEP_OFF 6
230 #define _DIT_SPIN_UP_MODE 7
231 #define _DIT_IDLE_STANDBY 8
232 #define _DIT_IDENTIFY 9
234 #define SPIN_UP_MODE_NOSUPPORT 0
235 #define SPIN_UP_MODE_FULL 1
236 #define SPIN_UP_MODE_STANDBY 2
248 typedef struct _HIM_ALTERABLE_DEV_INFO{
252 HPT_U8 enable_read_ahead;
253 HPT_U8 enable_read_cache;
254 HPT_U8 enable_write_cache;
255 struct tcq_control tcq;
256 struct ncq_control ncq;
259 HPT_U8 idle_standby_timeout;
260 HPT_U8 identify_indicator;
262 } HIM_ALTERABLE_DEV_INFO, *PHIM_ALTERABLE_DEV_INFO;
267 typedef void (*PROBE_CALLBACK)(void *arg, void *dev, int index);
269 typedef struct _HIM {
272 HPT_UINT max_sg_descriptors;
273 #define _HIM_INTERFACE(_type, _fn, _args) _type (* _fn) _args;
274 #include <dev/hptnr/himfuncs.h>
281 #error "don't use SG_FLAG_EOT with _SG.eot. clean the code!"
288 HPT_U8 FAR * _logical;
296 typedef struct _AtaCommand
301 } AtaComm, *PAtaComm;
303 #define ATA_CMD_NOP 0x0
305 #define ATA_CMD_SET_FEATURES 0xef
306 #define ATA_CMD_FLUSH 0xE7
307 #define ATA_CMD_VERIFY 0x40
308 #define ATA_CMD_STANDBY 0xe2
309 #define ATA_CMD_READ_MULTI 0xC4
310 #define ATA_CMD_READ_MULTI_EXT 0x29
311 #define ATA_CMD_WRITE_MULTI 0xC5
312 #define ATA_CMD_WRITE_MULTI_EXT 0x39
313 #define ATA_CMD_WRITE_MULTI_FUA_EXT 0xCE
315 #define ATA_CMD_READ_DMA 0xc8 /* IDE DMA read command */
316 #define ATA_CMD_WRITE_DMA 0xca /* IDE DMA write command */
317 #define ATA_CMD_READ_DMA_EXT 0x25
318 #define ATA_CMD_READ_QUEUE_EXT 0x26
319 #define ATA_CMD_READ_MAX_ADDR 0x27
320 #define ATA_CMD_READ_EXT 0x24
321 #define ATA_CMD_VERIFY_EXT 0x42
322 #define ATA_CMD_WRITE_DMA_EXT 0x35
323 #define ATA_CMD_WRITE_QUEUE_EXT 0x36
324 #define ATA_CMD_WRITE_EXT 0x34
326 #define ATA_SET_FEATURES_XFER 0x3
327 #define ATA_SECTOR_SIZE 512
329 typedef struct _PassthroughCmd {
330 HPT_U16 bFeaturesReg;
331 HPT_U16 bSectorCountReg;
335 HPT_U8 bDriveHeadReg;
342 typedef struct _ScsiComm {
354 #define CTRL_CMD_REBUILD 1
355 #define CTRL_CMD_VERIFY 2
356 #define CTRL_CMD_INIT 3
359 typedef struct _R5ControlCmd {
365 R5ControlCmd, *PR5ControlCmd;
367 typedef struct _HPT_ADDRESS
375 typedef struct ctl_pages {
379 HPT_UINT min_sg_descriptors;
380 } CONTROL_PAGES, *PCONTROL_PAGES;
382 typedef struct _R1ControlCmd {
387 PCONTROL_PAGES ctl_pages;
389 R1ControlCmd, *PR1ControlCmd;
391 typedef void (*TQ_PROC)(void *arg);
396 struct tq_item *next;
399 #define INIT_TQ_ITEM(t, p, a) \
400 do { (t)->proc = p; (t)->arg = a; (t)->next = 0; } while (0)
402 typedef struct _COMMAND
407 struct freelist *grplist;
411 struct list_head q_link;
412 struct tq_item done_dpc;
424 struct lock_request *owned_lock;
425 struct lock_request *lock_req;
426 void (*dtor)(struct _COMMAND *, void *);
431 PassthroughCmd Passthrough;
433 R5ControlCmd R5Control;
434 R1ControlCmd R1Control;
437 HPT_U8 type; /* CMD_TYPE_* */
440 HPT_U8 physical_sg: 1;
443 HPT_U8 transform : 1;
444 HPT_U8 hard_flush: 2;
458 int (*buildsgl)(struct _COMMAND *cmd, PSG psg, int logical);
459 void (*done)(struct _COMMAND *cmd);
464 #define CMD_TYPE_IO 0
465 #define CMD_TYPE_CONTROL 1
466 #define CMD_TYPE_ATAPI 2
467 #define CMD_TYPE_SCSI CMD_TYPE_ATAPI
468 #define CMD_TYPE_PASSTHROUGH 3
469 #define CMD_TYPE_FLUSH 4
470 #define CMD_TYPE_IO_INDIRECT 0x80
472 /* flush command flags */
473 #define CF_HARD_FLUSH_CACHE 1
474 #define CF_HARD_FLUSH_STANDBY 2
476 /* command return values */
477 #define RETURN_PENDING 0
478 #define RETURN_SUCCESS 1
479 #define RETURN_BAD_DEVICE 2
480 #define RETURN_BAD_PARAMETER 3
481 #define RETURN_WRITE_NO_DRQ 4
482 #define RETURN_DEVICE_BUSY 5
483 #define RETURN_INVALID_REQUEST 6
484 #define RETURN_SELECTION_TIMEOUT 7
485 #define RETURN_IDE_ERROR 8
486 #define RETURN_NEED_LOGICAL_SG 9
487 #define RETURN_NEED_PHYSICAL_SG 10
488 #define RETURN_RETRY 11
489 #define RETURN_DATA_ERROR 12
490 #define RETURN_BUS_RESET 13
491 #define RETURN_BAD_TRANSFER_LENGTH 14
492 #define RETURN_INSUFFICIENT_MEMORY 15
493 #define RETURN_SECTOR_ERROR 16
494 #define RETURN_NEED_SPINUP 17
496 #if defined(__cplusplus)