1 #include <dev/rr232x/rr232x_config.h>
3 * $Id: him.h,v 1.34 2006/02/21 06:11:19 gmm Exp $
4 * Copyright (C) 2004-2005 HighPoint Technologies, Inc. All rights reserved.
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
31 #define VERMAGIC_HIM 34
33 #if defined(__cplusplus)
37 #include <dev/rr232x/list.h>
39 #define SECTOR_TO_BYTE_SHIFT 9
40 #define SECTOR_TO_BYTE(x) ((HPT_U32)(x) << SECTOR_TO_BYTE_SHIFT)
41 #define BYTE_TO_SECTOR(x) ((x)>>SECTOR_TO_BYTE_SHIFT)
43 typedef struct _PCI_ID
54 typedef struct _PCI_ADDRESS
63 typedef struct _HIM_ADAPTER_CONFIG
69 HPT_U8 max_sg_descriptors;
79 HPT_U8 szVendorID[36];
80 HPT_U8 szProductID[36];
82 HIM_ADAPTER_CONFIG, *PHIM_ADAPTER_CONFIG;
84 typedef struct _HIM_CHANNEL_CONFIG
88 } HIM_CHANNEL_CONFIG, *PHIM_CHANNEL_CONFIG;
90 typedef struct _HIM_DEVICE_FLAGS
93 HPT_U32 df_removable_drive :1;
94 HPT_U32 df_on_line :1;
95 HPT_U32 df_reduce_mode :1;
97 HPT_U32 df_with_601 :1;
98 HPT_U32 df_support_read_ahead :1;
99 HPT_U32 df_read_ahead_enabled :1;
100 HPT_U32 df_support_write_cache :1;
101 HPT_U32 df_write_cache_enabled :1;
102 HPT_U32 df_cdrom_device :1;
103 HPT_U32 df_tape_device :1;
104 HPT_U32 df_support_tcq :1;
105 HPT_U32 df_tcq_enabled :1;
106 HPT_U32 df_support_ncq :1;
107 HPT_U32 df_ncq_enabled :1;
108 } DEVICE_FLAGS, *PDEVICE_FLAGS;
111 typedef struct _IDENTIFY_DATA2 {
112 HPT_U16 GeneralConfiguration;
113 HPT_U16 NumberOfCylinders;
115 HPT_U16 NumberOfHeads;
116 HPT_U16 UnformattedBytesPerTrack;
117 HPT_U16 UnformattedBytesPerSector;
118 HPT_U16 SectorsPerTrack;
119 HPT_U16 VendorUnique1[3];
120 HPT_U16 SerialNumber[10];
122 HPT_U16 BufferSectorSize;
123 HPT_U16 NumberOfEccBytes;
124 HPT_U16 FirmwareRevision[4];
125 HPT_U16 ModelNumber[20];
126 HPT_U8 MaximumBlockTransfer;
127 HPT_U8 VendorUnique2;
128 HPT_U16 DoubleWordIo;
129 HPT_U16 Capabilities;
131 HPT_U8 VendorUnique3;
132 HPT_U8 PioCycleTimingMode;
133 HPT_U8 VendorUnique4;
134 HPT_U8 DmaCycleTimingMode;
135 HPT_U16 TranslationFieldsValid;
136 HPT_U16 NumberOfCurrentCylinders;
137 HPT_U16 NumberOfCurrentHeads;
138 HPT_U16 CurrentSectorsPerTrack;
139 HPT_U32 CurrentSectorCapacity;
140 HPT_U16 CurrentMultiSectorSetting;
141 HPT_U32 UserAddressableSectors;
142 HPT_U8 SingleWordDMASupport;
143 HPT_U8 SingleWordDMAActive;
144 HPT_U8 MultiWordDMASupport;
145 HPT_U8 MultiWordDMAActive;
146 HPT_U8 AdvancedPIOModes;
148 HPT_U16 MinimumMWXferCycleTime;
149 HPT_U16 RecommendedMWXferCycleTime;
150 HPT_U16 MinimumPIOCycleTime;
151 HPT_U16 MinimumPIOCycleTimeIORDY;
152 HPT_U16 Reserved5[2];
153 HPT_U16 ReleaseTimeOverlapped;
154 HPT_U16 ReleaseTimeServiceCommand;
155 HPT_U16 MajorRevision;
156 HPT_U16 MinorRevision;
159 __attribute__((packed))
161 IDENTIFY_DATA2, *PIDENTIFY_DATA2;
164 #define _HPT601_INFO_DEVICEID 1
165 #define _HPT601_INFO_TEMPERATURE 2
166 #define _HPT601_INFO_FANSTATUS 4
167 #define _HPT601_INFO_BEEPERCONTROL 8
168 #define _HPT601_INFO_LED1CONTROL 0x10
169 #define _HPT601_INFO_LED2CONTROL 0x20
170 #define _HPT601_INFO_POWERSTATUS 0x40
172 typedef struct __HPT601_INFO {
177 HPT_U16 BeeperControl;
181 } _HPT601_INFO, *_PHPT601_INFO;
183 typedef struct _HIM_DEVICE_CONFIG
191 HPT_U8 max_queue_depth;
195 HPT_U8 transfer_mode;
197 HPT_U8 bDeUsable_Mode;
199 HPT_U16 max_sectors_per_cmd;
201 PIDENTIFY_DATA2 pIdentifyData;
203 _HPT601_INFO chip601;
205 HIM_DEVICE_CONFIG, *PHIM_DEVICE_CONFIG;
210 #define _DIT_READ_AHEAD 2
211 #define _DIT_WRITE_CACHE 3
214 #define _DIT_BEEP_OFF 6
215 #define _DIT_SPIN_UP_MODE 7
217 #define SPIN_UP_MODE_NOSUPPORT 0
218 #define SPIN_UP_MODE_FULL 1
219 #define SPIN_UP_MODE_STANDBY 2
231 typedef struct _HIM_ALTERABLE_DEV_INFO{
235 HPT_U8 enable_read_ahead;
236 HPT_U8 enable_read_cache;
237 HPT_U8 enable_write_cache;
238 struct tcq_control tcq;
239 struct ncq_control ncq;
240 _HPT601_INFO chip601;
244 } HIM_ALTERABLE_DEV_INFO, *PHIM_ALTERABLE_DEV_INFO;
249 typedef void (*PROBE_CALLBACK)(void *arg, void *dev, int index);
251 typedef struct _HIM {
254 HPT_U8 max_sg_descriptors;
255 #define _HIM_INTERFACE(_type, _fn, _args) _type (* _fn) _args;
256 #include <dev/rr232x/himfuncs.h>
263 #error "don't use SG_FLAG_EOT with _SG.eot. clean the code!"
270 HPT_U8 FAR * _logical;
278 typedef struct _AtaCommand
283 } AtaComm, *PAtaComm;
285 typedef struct _PassthroughCmd {
287 HPT_U8 bSectorCountReg;
291 HPT_U8 bDriveHeadReg;
299 #define CTRL_CMD_REBUILD 1
300 #define CTRL_CMD_VERIFY 2
301 #define CTRL_CMD_INIT 3
304 typedef struct _R5ControlCmd {
310 R5ControlCmd, *PR5ControlCmd;
312 typedef struct _HPT_ADDRESS
320 typedef struct ctl_pages {
324 HPT_U8 min_sg_descriptors;
325 } CONTROL_PAGES, *PCONTROL_PAGES;
327 typedef struct _R1ControlCmd {
330 HPT_U8 Command; /* CTRL_CMD_XXX */
332 PCONTROL_PAGES ctl_pages;
334 R1ControlCmd, *PR1ControlCmd;
336 typedef void (*TQ_PROC)(void *arg);
341 struct tq_item *next;
344 #define INIT_TQ_ITEM(t, p, a) \
345 do { (t)->proc = p; (t)->arg = a; (t)->next = 0; } while (0)
347 typedef struct _COMMAND
352 struct freelist *grplist;
357 struct list_head q_link;
358 struct tq_item done_dpc;
370 struct lock_request *owned_lock;
371 struct lock_request *lock_req;
376 PassthroughCmd Passthrough;
379 /* Control command */
380 R5ControlCmd R5Control;
381 R1ControlCmd R1Control;
384 HPT_U8 type; /* CMD_TYPE_* */
387 HPT_U8 physical_sg: 1;
390 HPT_U8 transform : 1;
391 HPT_U8 hard_flush: 2;
403 int (*buildsgl)(struct _COMMAND *cmd, PSG psg, int logical);
404 void (*done)(struct _COMMAND *cmd);
409 #define CMD_TYPE_IO 0
410 #define CMD_TYPE_CONTROL 1
411 #define CMD_TYPE_ATAPI 2
412 #define CMD_TYPE_PASSTHROUGH 3
413 #define CMD_TYPE_FLUSH 4
415 /* flush command flags */
416 #define CF_HARD_FLUSH_CACHE 1
417 #define CF_HARD_FLUSH_STANDBY 2
419 /* command return values */
420 #define RETURN_PENDING 0
421 #define RETURN_SUCCESS 1
422 #define RETURN_BAD_DEVICE 2
423 #define RETURN_BAD_PARAMETER 3
424 #define RETURN_WRITE_NO_DRQ 4
425 #define RETURN_DEVICE_BUSY 5
426 #define RETURN_INVALID_REQUEST 6
427 #define RETURN_SELECTION_TIMEOUT 7
428 #define RETURN_IDE_ERROR 8
429 #define RETURN_NEED_LOGICAL_SG 9
430 #define RETURN_NEED_PHYSICAL_SG 10
431 #define RETURN_RETRY 11
432 #define RETURN_DATA_ERROR 12
433 #define RETURN_BUS_RESET 13
434 #define RETURN_BAD_TRANSFER_LENGTH 14
435 #define RETURN_INSUFFICIENT_MEMORY 15
437 #if defined(__cplusplus)