2 * Copyright (c) HighPoint Technologies, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <dev/hptrr/hptrr_config.h>
30 * $Id: him.h,v 1.47 2007/12/17 08:55:49 gmm Exp $
31 * Copyright (C) 2004-2005 HighPoint Technologies, Inc. All rights reserved.
36 #define VERMAGIC_HIM 46
38 #if defined(__cplusplus)
42 #include <dev/hptrr/list.h>
44 #define SECTOR_TO_BYTE_SHIFT 9
45 #define SECTOR_TO_BYTE(x) ((HPT_U32)(x) << SECTOR_TO_BYTE_SHIFT)
46 #define BYTE_TO_SECTOR(x) ((x)>>SECTOR_TO_BYTE_SHIFT)
48 typedef struct _PCI_ID
59 typedef struct _PCI_ADDRESS
68 typedef struct _HIM_ADAPTER_CONFIG
84 HPT_U8 szVendorID[36];
85 HPT_U8 szProductID[36];
87 HIM_ADAPTER_CONFIG, *PHIM_ADAPTER_CONFIG;
89 typedef struct _HIM_CHANNEL_CONFIG
93 } HIM_CHANNEL_CONFIG, *PHIM_CHANNEL_CONFIG;
95 typedef struct _HIM_DEVICE_FLAGS
98 HPT_UINT df_removable_drive :1;
99 HPT_UINT df_on_line :1;
100 HPT_UINT df_reduce_mode :1;
102 HPT_UINT df_on_pm_port :1;
103 HPT_UINT df_support_read_ahead :1;
104 HPT_UINT df_read_ahead_enabled :1;
105 HPT_UINT df_support_write_cache :1;
106 HPT_UINT df_write_cache_enabled :1;
107 HPT_UINT df_cdrom_device :1;
108 HPT_UINT df_tape_device :1;
109 HPT_UINT df_support_tcq :1;
110 HPT_UINT df_tcq_enabled :1;
111 HPT_UINT df_support_ncq :1;
112 HPT_UINT df_ncq_enabled :1;
114 } DEVICE_FLAGS, *PDEVICE_FLAGS;
117 typedef struct _IDENTIFY_DATA2 {
118 HPT_U16 GeneralConfiguration;
119 HPT_U16 NumberOfCylinders;
121 HPT_U16 NumberOfHeads;
122 HPT_U16 UnformattedBytesPerTrack;
123 HPT_U16 UnformattedBytesPerSector;
124 HPT_U16 SectorsPerTrack;
125 HPT_U16 VendorUnique1[3];
126 HPT_U16 SerialNumber[10];
128 HPT_U16 BufferSectorSize;
129 HPT_U16 NumberOfEccBytes;
130 HPT_U16 FirmwareRevision[4];
131 HPT_U16 ModelNumber[20];
132 HPT_U8 MaximumBlockTransfer;
133 HPT_U8 VendorUnique2;
134 HPT_U16 DoubleWordIo;
135 HPT_U16 Capabilities;
137 HPT_U8 VendorUnique3;
138 HPT_U8 PioCycleTimingMode;
139 HPT_U8 VendorUnique4;
140 HPT_U8 DmaCycleTimingMode;
141 HPT_U16 TranslationFieldsValid;
142 HPT_U16 NumberOfCurrentCylinders;
143 HPT_U16 NumberOfCurrentHeads;
144 HPT_U16 CurrentSectorsPerTrack;
145 HPT_U32 CurrentSectorCapacity;
146 HPT_U16 CurrentMultiSectorSetting;
147 HPT_U32 UserAddressableSectors;
148 HPT_U8 SingleWordDMASupport;
149 HPT_U8 SingleWordDMAActive;
150 HPT_U8 MultiWordDMASupport;
151 HPT_U8 MultiWordDMAActive;
152 HPT_U8 AdvancedPIOModes;
154 HPT_U16 MinimumMWXferCycleTime;
155 HPT_U16 RecommendedMWXferCycleTime;
156 HPT_U16 MinimumPIOCycleTime;
157 HPT_U16 MinimumPIOCycleTimeIORDY;
158 HPT_U16 Reserved5[2];
159 HPT_U16 ReleaseTimeOverlapped;
160 HPT_U16 ReleaseTimeServiceCommand;
161 HPT_U16 MajorRevision;
162 HPT_U16 MinorRevision;
165 __attribute__((packed))
167 IDENTIFY_DATA2, *PIDENTIFY_DATA2;
170 typedef struct _HIM_DEVICE_CONFIG
178 HPT_U8 max_queue_depth;
182 HPT_U8 transfer_mode;
184 HPT_U8 bDeUsable_Mode;
186 HPT_U16 max_sectors_per_cmd;
188 PIDENTIFY_DATA2 pIdentifyData;
191 HIM_DEVICE_CONFIG, *PHIM_DEVICE_CONFIG;
196 #define _DIT_READ_AHEAD 2
197 #define _DIT_WRITE_CACHE 3
200 #define _DIT_BEEP_OFF 6
201 #define _DIT_SPIN_UP_MODE 7
202 #define _DIT_IDLE_STANDBY 8
203 #define _DIT_IDENTIFY 9
205 #define SPIN_UP_MODE_NOSUPPORT 0
206 #define SPIN_UP_MODE_FULL 1
207 #define SPIN_UP_MODE_STANDBY 2
219 typedef struct _HIM_ALTERABLE_DEV_INFO{
223 HPT_U8 enable_read_ahead;
224 HPT_U8 enable_read_cache;
225 HPT_U8 enable_write_cache;
226 struct tcq_control tcq;
227 struct ncq_control ncq;
230 HPT_U8 idle_standby_timeout;
231 HPT_U8 identify_indicator;
233 } HIM_ALTERABLE_DEV_INFO, *PHIM_ALTERABLE_DEV_INFO;
238 typedef void (*PROBE_CALLBACK)(void *arg, void *dev, int index);
240 typedef struct _HIM {
243 HPT_UINT max_sg_descriptors;
244 #define _HIM_INTERFACE(_type, _fn, _args) _type (* _fn) _args;
245 #include <dev/hptrr/himfuncs.h>
252 #error "don't use SG_FLAG_EOT with _SG.eot. clean the code!"
259 HPT_U8 FAR * _logical;
267 typedef struct _AtaCommand
272 } AtaComm, *PAtaComm;
274 #define ATA_CMD_SET_FEATURES 0xef
275 #define ATA_CMD_FLUSH 0xE7
276 #define ATA_CMD_VERIFY 0x40
277 #define ATA_CMD_STANDBY 0xe2
278 #define ATA_CMD_READ_MULTI 0xC4
279 #define ATA_CMD_READ_MULTI_EXT 0x29
280 #define ATA_CMD_WRITE_MULTI 0xC5
281 #define ATA_CMD_WRITE_MULTI_EXT 0x39
282 #define ATA_CMD_WRITE_MULTI_FUA_EXT 0xCE
284 #define ATA_SET_FEATURES_XFER 0x3
285 #define ATA_SECTOR_SIZE 512
287 typedef struct _PassthroughCmd {
288 HPT_U16 bFeaturesReg;
289 HPT_U16 bSectorCountReg;
293 HPT_U8 bDriveHeadReg;
300 typedef struct _ScsiComm {
312 #define CTRL_CMD_REBUILD 1
313 #define CTRL_CMD_VERIFY 2
314 #define CTRL_CMD_INIT 3
317 typedef struct _R5ControlCmd {
323 R5ControlCmd, *PR5ControlCmd;
325 typedef struct _HPT_ADDRESS
333 typedef struct ctl_pages {
337 HPT_UINT min_sg_descriptors;
338 } CONTROL_PAGES, *PCONTROL_PAGES;
340 typedef struct _R1ControlCmd {
343 HPT_U8 Command; /* CTRL_CMD_XXX */
345 PCONTROL_PAGES ctl_pages;
347 R1ControlCmd, *PR1ControlCmd;
349 typedef void (*TQ_PROC)(void *arg);
354 struct tq_item *next;
357 #define INIT_TQ_ITEM(t, p, a) \
358 do { (t)->proc = p; (t)->arg = a; (t)->next = 0; } while (0)
360 typedef struct _COMMAND
365 struct freelist *grplist;
369 struct list_head q_link;
370 struct tq_item done_dpc;
382 struct lock_request *owned_lock;
383 struct lock_request *lock_req;
384 void (*dtor)(struct _COMMAND *, void *);
389 PassthroughCmd Passthrough;
391 R5ControlCmd R5Control;
392 R1ControlCmd R1Control;
395 HPT_U8 type; /* CMD_TYPE_* */
398 HPT_U8 physical_sg: 1;
401 HPT_U8 transform : 1;
402 HPT_U8 hard_flush: 2;
416 int (*buildsgl)(struct _COMMAND *cmd, PSG psg, int logical);
417 void (*done)(struct _COMMAND *cmd);
422 #define CMD_TYPE_IO 0
423 #define CMD_TYPE_CONTROL 1
424 #define CMD_TYPE_ATAPI 2
425 #define CMD_TYPE_SCSI CMD_TYPE_ATAPI
426 #define CMD_TYPE_PASSTHROUGH 3
427 #define CMD_TYPE_FLUSH 4
429 /* flush command flags */
430 #define CF_HARD_FLUSH_CACHE 1
431 #define CF_HARD_FLUSH_STANDBY 2
433 /* command return values */
434 #define RETURN_PENDING 0
435 #define RETURN_SUCCESS 1
436 #define RETURN_BAD_DEVICE 2
437 #define RETURN_BAD_PARAMETER 3
438 #define RETURN_WRITE_NO_DRQ 4
439 #define RETURN_DEVICE_BUSY 5
440 #define RETURN_INVALID_REQUEST 6
441 #define RETURN_SELECTION_TIMEOUT 7
442 #define RETURN_IDE_ERROR 8
443 #define RETURN_NEED_LOGICAL_SG 9
444 #define RETURN_NEED_PHYSICAL_SG 10
445 #define RETURN_RETRY 11
446 #define RETURN_DATA_ERROR 12
447 #define RETURN_BUS_RESET 13
448 #define RETURN_BAD_TRANSFER_LENGTH 14
449 #define RETURN_INSUFFICIENT_MEMORY 15
450 #define RETURN_SECTOR_ERROR 16
452 #if defined(__cplusplus)