]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/sys/dev/rr232x/him.h
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / 6 / sys / dev / rr232x / him.h
1 #include <dev/rr232x/rr232x_config.h>
2 /*
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
7  * are met:
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.
13  *
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
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 #ifndef _HPT_HIM_H_
29 #define _HPT_HIM_H_
30
31 #define VERMAGIC_HIM 34
32
33 #if defined(__cplusplus)
34 extern "C" {
35 #endif
36
37 #include <dev/rr232x/list.h>
38
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)
42
43 typedef struct _PCI_ID
44 {
45         HPT_U16 vid;
46         HPT_U16 did;
47         HPT_U32 subsys;
48         HPT_U8  rev;
49         HPT_U8  nbase;
50         HPT_U16 reserve;
51 }
52 PCI_ID;
53
54 typedef struct _PCI_ADDRESS
55 {
56         HPT_U8 tree;
57         HPT_U8 bus;
58         HPT_U8 device;
59         HPT_U8 function;
60 }
61 PCI_ADDRESS;
62
63 typedef struct _HIM_ADAPTER_CONFIG
64 {
65         PCI_ADDRESS pci_addr;
66         PCI_ID  pci_id;
67
68         HPT_U8  max_devices;
69         HPT_U8  max_sg_descriptors;
70
71         HPT_U8  bDevsPerBus;
72         HPT_U8  first_on_slot;
73
74         HPT_U8  bChipType;
75         HPT_U8  bChipIntrNum;
76         HPT_U8  bChipFlags;
77         HPT_U8  bNumBuses;
78
79         HPT_U8  szVendorID[36];
80         HPT_U8  szProductID[36];
81 }
82 HIM_ADAPTER_CONFIG, *PHIM_ADAPTER_CONFIG;
83
84 typedef struct _HIM_CHANNEL_CONFIG
85 {
86         HPT_U32 io_port;
87         HPT_U32 ctl_port;
88 } HIM_CHANNEL_CONFIG, *PHIM_CHANNEL_CONFIG;
89
90 typedef struct _HIM_DEVICE_FLAGS
91 {
92         HPT_U32 df_atapi                :1;   
93         HPT_U32 df_removable_drive              :1;
94         HPT_U32 df_on_line              :1;   
95         HPT_U32 df_reduce_mode          :1;   
96         HPT_U32 df_sata                 :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;
109
110 #pragma pack(1)
111 typedef struct _IDENTIFY_DATA2 {
112     HPT_U16 GeneralConfiguration;
113     HPT_U16 NumberOfCylinders;
114     HPT_U16 Reserved1;
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];
121     HPT_U16 BufferType;
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;
130     HPT_U16 Reserved2;
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;
147     HPT_U8  Reserved4;
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;
157 }
158 #ifdef __GNUC__
159 __attribute__((packed))
160 #endif
161 IDENTIFY_DATA2, *PIDENTIFY_DATA2;
162 #pragma pack()
163
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
171
172 typedef struct __HPT601_INFO {
173         HPT_U16 ValidFields;        
174         HPT_U16 DeviceId;                       
175         HPT_U16 Temperature;        
176         HPT_U16 FanStatus;          
177         HPT_U16 BeeperControl;          
178         HPT_U16 LED1Control;            
179         HPT_U16 LED2Control;            
180         HPT_U16 PowerStatus;            
181 } _HPT601_INFO, *_PHPT601_INFO;
182
183 typedef struct _HIM_DEVICE_CONFIG
184 {
185         HPT_U64 capacity;
186
187         DEVICE_FLAGS flags;
188
189         HPT_U8  path_id;
190         HPT_U8  target_id;
191         HPT_U8  max_queue_depth;
192         HPT_U8  spin_up_mode;
193
194         HPT_U8  reserved;
195         HPT_U8  transfer_mode;        
196         HPT_U8  bMaxShowMode;         
197         HPT_U8  bDeUsable_Mode;       
198
199         HPT_U16 max_sectors_per_cmd;
200
201         PIDENTIFY_DATA2 pIdentifyData;
202
203         _HPT601_INFO chip601;
204 }
205 HIM_DEVICE_CONFIG, *PHIM_DEVICE_CONFIG;
206
207
208 #define _DIT_MODE                       0
209 #define _DIT_601                        1
210 #define _DIT_READ_AHEAD         2
211 #define _DIT_WRITE_CACHE        3
212 #define _DIT_TCQ                        4
213 #define _DIT_NCQ                        5
214 #define _DIT_BEEP_OFF           6
215 #define _DIT_SPIN_UP_MODE   7
216
217 #define SPIN_UP_MODE_NOSUPPORT 0
218 #define SPIN_UP_MODE_FULL      1
219 #define SPIN_UP_MODE_STANDBY   2
220
221 struct tcq_control {
222         HPT_U8 enable;
223         HPT_U8 depth;
224 };
225
226 struct ncq_control {
227         HPT_U8 enable;
228         HPT_U8 depth;
229 };
230
231 typedef struct _HIM_ALTERABLE_DEV_INFO{
232         HPT_U8 type;
233         union {
234                 HPT_U8 mode;
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;
241                 void * adapter;
242                 HPT_U8 spin_up_mode;
243         }u;
244 } HIM_ALTERABLE_DEV_INFO, *PHIM_ALTERABLE_DEV_INFO;
245
246 struct _COMMAND;
247 struct _IOCTL_ARG;
248
249 typedef void (*PROBE_CALLBACK)(void *arg, void *dev, int index);
250
251 typedef struct _HIM {
252         char *name;
253         struct _HIM *next;
254         HPT_U8  max_sg_descriptors;
255         #define _HIM_INTERFACE(_type, _fn, _args) _type (* _fn) _args;
256         #include <dev/rr232x/himfuncs.h>
257 }
258 HIM, *PHIM;
259
260
261 #pragma pack(1)
262 #ifdef SG_FLAG_EOT
263 #error "don't use SG_FLAG_EOT with _SG.eot. clean the code!"
264 #endif
265
266 typedef struct _SG {
267         HPT_U32 size;
268         HPT_UINT eot; 
269         union {
270                 HPT_U8 FAR * _logical; 
271                 BUS_ADDRESS bus;
272         }
273         addr;
274 }
275 SG, *PSG;
276 #pragma pack()
277
278 typedef struct _AtaCommand
279 {
280     HPT_U64     Lba;          
281     HPT_U16     nSectors;     
282     HPT_U16     pad;
283 } AtaComm, *PAtaComm;
284
285 typedef struct _PassthroughCmd {
286         HPT_U8     bFeaturesReg;     
287         HPT_U8     bSectorCountReg;  
288         HPT_U8     bLbaLowReg;       
289         HPT_U8     bLbaMidReg;       
290         HPT_U8     bLbaHighReg;      
291         HPT_U8     bDriveHeadReg;    
292         HPT_U8     bCommandReg;      
293         HPT_U8     nSectors;         
294         HPT_U8    *pDataBuffer;      
295 }
296 PassthroughCmd;
297
298
299 #define CTRL_CMD_REBUILD 1
300 #define CTRL_CMD_VERIFY  2
301 #define CTRL_CMD_INIT    3
302
303
304 typedef struct _R5ControlCmd {
305         HPT_U64  StripeLine;  
306         HPT_U16 Offset;       
307         HPT_U8  Command;      
308         HPT_U8  reserve1;
309 }
310 R5ControlCmd, *PR5ControlCmd;
311
312 typedef struct _HPT_ADDRESS
313 {
314         HPT_U8 * logical;
315         BUS_ADDRESS bus;
316 }
317 HPT_ADDRESS;
318
319
320 typedef struct ctl_pages {
321         HPT_ADDRESS *pages;
322         HPT_UINT        page_size; 
323         HPT_UINT        npages;
324         HPT_U8          min_sg_descriptors; 
325 } CONTROL_PAGES, *PCONTROL_PAGES;
326
327 typedef struct _R1ControlCmd {
328         HPT_U64  Lba;
329         HPT_U16 nSectors;
330         HPT_U8  Command;      /* CTRL_CMD_XXX */
331         HPT_U8  reserve1;
332         PCONTROL_PAGES ctl_pages;  
333 }
334 R1ControlCmd, *PR1ControlCmd;
335
336 typedef void (*TQ_PROC)(void *arg);
337
338 struct tq_item {
339         TQ_PROC proc;
340         void *arg;
341         struct tq_item *next;
342 };
343
344 #define INIT_TQ_ITEM(t, p, a) \
345         do { (t)->proc = p; (t)->arg = a; (t)->next = 0; } while (0)
346
347 typedef struct _COMMAND
348 {
349         
350         struct _VBUS * vbus;
351
352         struct freelist *grplist; 
353         HPT_UINT grpcnt; 
354         HPT_UINT freecnt; 
355
356         
357         struct list_head q_link;
358         struct tq_item done_dpc;
359
360         HPT_UINT extsize;   
361     void *ext;
362
363         
364
365         void *target;      
366         void *priv;        
367         HPT_UPTR priv2;    
368
369         int priority;
370         struct lock_request *owned_lock; 
371         struct lock_request *lock_req;   
372
373     union{
374         /* Ide Command */
375         AtaComm Ide;
376         PassthroughCmd Passthrough;
377         /* Atapi Command */
378         HPT_U8 Atapi[12];
379                 /* Control command */
380                 R5ControlCmd R5Control;
381                 R1ControlCmd R1Control;
382         } uCmd;
383
384         HPT_U8 type; /* CMD_TYPE_* */
385
386         struct {
387                 HPT_U8  physical_sg: 1;
388                 HPT_U8  data_in: 1;
389                 HPT_U8  data_out: 1;
390                 HPT_U8  transform : 1;
391                 HPT_U8  hard_flush: 2; 
392         } flags;
393
394     /* return status */
395     HPT_U8      Result;
396         /* retry count */
397         HPT_U8  RetryCount;
398
399         
400         PSG psg;
401
402         
403         int  (*buildsgl)(struct _COMMAND *cmd, PSG psg, int logical);
404         void (*done)(struct _COMMAND *cmd);
405 }
406 COMMAND, *PCOMMAND;
407
408 /* command types */
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
414
415 /* flush command flags */
416 #define   CF_HARD_FLUSH_CACHE   1
417 #define   CF_HARD_FLUSH_STANDBY 2
418
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 
436
437 #if defined(__cplusplus)
438 }
439 #endif
440 #endif