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
200 HPT_U32 logical_sector_size;
206 HPT_U8 max_queue_depth;
210 HPT_U8 transfer_mode;
212 HPT_U8 bDeUsable_Mode;
214 HPT_U16 max_sectors_per_cmd;
216 PIDENTIFY_DATA pIdentifyData;
219 HPT_U8 fixed_path_id; /*equals to phy id */
221 HIM_DEVICE_CONFIG, *PHIM_DEVICE_CONFIG;
226 #define _DIT_READ_AHEAD 2
227 #define _DIT_WRITE_CACHE 3
230 #define _DIT_BEEP_OFF 6
231 #define _DIT_SPIN_UP_MODE 7
232 #define _DIT_IDLE_STANDBY 8
233 #define _DIT_IDENTIFY 9
235 #define SPIN_UP_MODE_NOSUPPORT 0
236 #define SPIN_UP_MODE_FULL 1
237 #define SPIN_UP_MODE_STANDBY 2
249 typedef struct _HIM_ALTERABLE_DEV_INFO{
253 HPT_U8 enable_read_ahead;
254 HPT_U8 enable_read_cache;
255 HPT_U8 enable_write_cache;
256 struct tcq_control tcq;
257 struct ncq_control ncq;
260 HPT_U8 idle_standby_timeout;
261 HPT_U8 identify_indicator;
263 } HIM_ALTERABLE_DEV_INFO, *PHIM_ALTERABLE_DEV_INFO;
268 typedef void (*PROBE_CALLBACK)(void *arg, void *dev, int index);
270 typedef struct _HIM {
273 HPT_UINT max_sg_descriptors;
274 #define _HIM_INTERFACE(_type, _fn, _args) _type (* _fn) _args;
275 #include <dev/hptnr/himfuncs.h>
282 #error "don't use SG_FLAG_EOT with _SG.eot. clean the code!"
289 HPT_U8 FAR * _logical;
297 typedef struct _AtaCommand
302 } AtaComm, *PAtaComm;
304 #define ATA_CMD_NOP 0x0
306 #define ATA_CMD_SET_FEATURES 0xef
307 #define ATA_CMD_FLUSH 0xE7
308 #define ATA_CMD_VERIFY 0x40
309 #define ATA_CMD_STANDBY 0xe2
310 #define ATA_CMD_READ_MULTI 0xC4
311 #define ATA_CMD_READ_MULTI_EXT 0x29
312 #define ATA_CMD_WRITE_MULTI 0xC5
313 #define ATA_CMD_WRITE_MULTI_EXT 0x39
314 #define ATA_CMD_WRITE_MULTI_FUA_EXT 0xCE
316 #define ATA_CMD_READ_DMA 0xc8 /* IDE DMA read command */
317 #define ATA_CMD_WRITE_DMA 0xca /* IDE DMA write command */
318 #define ATA_CMD_READ_DMA_EXT 0x25
319 #define ATA_CMD_READ_QUEUE_EXT 0x26
320 #define ATA_CMD_READ_MAX_ADDR 0x27
321 #define ATA_CMD_READ_EXT 0x24
322 #define ATA_CMD_VERIFY_EXT 0x42
323 #define ATA_CMD_WRITE_DMA_EXT 0x35
324 #define ATA_CMD_WRITE_QUEUE_EXT 0x36
325 #define ATA_CMD_WRITE_EXT 0x34
327 #define ATA_SET_FEATURES_XFER 0x3
328 #define ATA_SECTOR_SIZE 512
330 typedef struct _PassthroughCmd {
331 HPT_U16 bFeaturesReg;
332 HPT_U16 bSectorCountReg;
336 HPT_U8 bDriveHeadReg;
343 typedef struct _ScsiComm {
355 #define CTRL_CMD_REBUILD 1
356 #define CTRL_CMD_VERIFY 2
357 #define CTRL_CMD_INIT 3
360 typedef struct _R5ControlCmd {
366 R5ControlCmd, *PR5ControlCmd;
368 typedef struct _HPT_ADDRESS
376 typedef struct ctl_pages {
380 HPT_UINT min_sg_descriptors;
381 } CONTROL_PAGES, *PCONTROL_PAGES;
383 typedef struct _R1ControlCmd {
388 PCONTROL_PAGES ctl_pages;
390 R1ControlCmd, *PR1ControlCmd;
392 typedef void (*TQ_PROC)(void *arg);
397 struct tq_item *next;
400 #define INIT_TQ_ITEM(t, p, a) \
401 do { (t)->proc = p; (t)->arg = a; (t)->next = 0; } while (0)
403 typedef struct _COMMAND
408 struct freelist *grplist;
412 struct list_head q_link;
413 struct tq_item done_dpc;
425 struct lock_request *owned_lock;
426 struct lock_request *lock_req;
427 void (*dtor)(struct _COMMAND *, void *);
432 PassthroughCmd Passthrough;
434 R5ControlCmd R5Control;
435 R1ControlCmd R1Control;
438 HPT_U8 type; /* CMD_TYPE_* */
441 HPT_U8 physical_sg: 1;
444 HPT_U8 transform : 1;
445 HPT_U8 hard_flush: 2;
459 int (*buildsgl)(struct _COMMAND *cmd, PSG psg, int logical);
460 void (*done)(struct _COMMAND *cmd);
465 #define CMD_TYPE_IO 0
466 #define CMD_TYPE_CONTROL 1
467 #define CMD_TYPE_ATAPI 2
468 #define CMD_TYPE_SCSI CMD_TYPE_ATAPI
469 #define CMD_TYPE_PASSTHROUGH 3
470 #define CMD_TYPE_FLUSH 4
471 #define CMD_TYPE_IO_INDIRECT 0x80
473 /* flush command flags */
474 #define CF_HARD_FLUSH_CACHE 1
475 #define CF_HARD_FLUSH_STANDBY 2
477 /* command return values */
478 #define RETURN_PENDING 0
479 #define RETURN_SUCCESS 1
480 #define RETURN_BAD_DEVICE 2
481 #define RETURN_BAD_PARAMETER 3
482 #define RETURN_WRITE_NO_DRQ 4
483 #define RETURN_DEVICE_BUSY 5
484 #define RETURN_INVALID_REQUEST 6
485 #define RETURN_SELECTION_TIMEOUT 7
486 #define RETURN_IDE_ERROR 8
487 #define RETURN_NEED_LOGICAL_SG 9
488 #define RETURN_NEED_PHYSICAL_SG 10
489 #define RETURN_RETRY 11
490 #define RETURN_DATA_ERROR 12
491 #define RETURN_BUS_RESET 13
492 #define RETURN_BAD_TRANSFER_LENGTH 14
493 #define RETURN_INSUFFICIENT_MEMORY 15
494 #define RETURN_SECTOR_ERROR 16
495 #define RETURN_NEED_SPINUP 17
497 #if defined(__cplusplus)