blob: 4f047cc87c6639ae205377e7803b96e63eab1ce2 [file] [log] [blame]
Matthew Wilcox01fbfe02007-09-09 08:56:40 -06001#define DRV_NAME "advansys"
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -04002#define ASC_VERSION "3.4" /* AdvanSys Driver Version */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4/*
5 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
6 *
7 * Copyright (c) 1995-2000 Advanced System Products, Inc.
8 * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -04009 * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * All Rights Reserved.
11 *
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040012 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 */
17
18/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
20 * changed its name to ConnectCom Solutions, Inc.
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040021 * On June 18, 2001 Initio Corp. acquired ConnectCom's SCSI assets
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 */
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/string.h>
26#include <linux/kernel.h>
27#include <linux/types.h>
28#include <linux/ioport.h>
29#include <linux/interrupt.h>
30#include <linux/delay.h>
31#include <linux/slab.h>
32#include <linux/mm.h>
33#include <linux/proc_fs.h>
34#include <linux/init.h>
35#include <linux/blkdev.h>
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060036#include <linux/isa.h>
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060037#include <linux/eisa.h>
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040038#include <linux/pci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/spinlock.h>
40#include <linux/dma-mapping.h>
41
42#include <asm/io.h>
43#include <asm/system.h>
44#include <asm/dma.h>
45
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040046#include <scsi/scsi_cmnd.h>
47#include <scsi/scsi_device.h>
48#include <scsi/scsi_tcq.h>
49#include <scsi/scsi.h>
50#include <scsi/scsi_host.h>
51
Matthew Wilcox4bd6d7f2007-07-30 08:41:03 -060052/* FIXME:
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 *
Matthew Wilcox4bd6d7f2007-07-30 08:41:03 -060054 * 1. Although all of the necessary command mapping places have the
55 * appropriate dma_map.. APIs, the driver still processes its internal
56 * queue using bus_to_virt() and virt_to_bus() which are illegal under
57 * the API. The entire queue processing structure will need to be
58 * altered to fix this.
59 * 2. Need to add memory mapping workaround. Test the memory mapping.
60 * If it doesn't work revert to I/O port access. Can a test be done
61 * safely?
62 * 3. Handle an interrupt not working. Keep an interrupt counter in
63 * the interrupt handler. In the timeout function if the interrupt
64 * has not occurred then print a message and run in polled mode.
65 * 4. Need to add support for target mode commands, cf. CAM XPT.
66 * 5. check DMA mapping functions for failure
Matthew Wilcox349d2c42007-09-09 08:56:34 -060067 * 6. Use scsi_transport_spi
68 * 7. advansys_info is not safe against multiple simultaneous callers
69 * 8. Kill boardp->id
70 * 9. Add module_param to override ISA/VLB ioport array
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 */
72#warning this driver is still not properly converted to the DMA API
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074/* Enable driver /proc statistics. */
75#define ADVANSYS_STATS
76
77/* Enable driver tracing. */
78/* #define ADVANSYS_DEBUG */
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#define ASC_LIB_VERSION_MAJOR 1
81#define ASC_LIB_VERSION_MINOR 24
82#define ASC_LIB_SERIAL_NUMBER 123
83
84/*
85 * Portable Data Types
86 *
87 * Any instance where a 32-bit long or pointer type is assumed
88 * for precision or HW defined structures, the following define
89 * types must be used. In Linux the char, short, and int types
90 * are all consistent at 8, 16, and 32 bits respectively. Pointers
91 * and long types are 64 bits on Alpha and UltraSPARC.
92 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -040093#define ASC_PADDR __u32 /* Physical/Bus address data type. */
94#define ASC_VADDR __u32 /* Virtual address data type. */
95#define ASC_DCNT __u32 /* Unsigned Data count type. */
96#define ASC_SDCNT __s32 /* Signed Data count type. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
98/*
99 * These macros are used to convert a virtual address to a
100 * 32-bit value. This currently can be used on Linux Alpha
101 * which uses 64-bit virtual address but a 32-bit bus address.
102 * This is likely to break in the future, but doing this now
103 * will give us time to change the HW and FW to handle 64-bit
104 * addresses.
105 */
106#define ASC_VADDR_TO_U32 virt_to_bus
107#define ASC_U32_TO_VADDR bus_to_virt
108
109typedef unsigned char uchar;
110
111#ifndef TRUE
112#define TRUE (1)
113#endif
114#ifndef FALSE
115#define FALSE (0)
116#endif
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118#define ERR (-1)
119#define UW_ERR (uint)(0xFFFF)
120#define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Dave Jones2672ea82006-08-02 17:11:49 -0400122#define PCI_VENDOR_ID_ASP 0x10cd
123#define PCI_DEVICE_ID_ASP_1200A 0x1100
124#define PCI_DEVICE_ID_ASP_ABP940 0x1200
125#define PCI_DEVICE_ID_ASP_ABP940U 0x1300
126#define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
127#define PCI_DEVICE_ID_38C0800_REV1 0x2500
128#define PCI_DEVICE_ID_38C1600_REV1 0x2700
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130/*
131 * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
132 * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
133 * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
134 * SRB structure.
135 */
136#define CC_VERY_LONG_SG_LIST 0
137#define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
138
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400139#define PortAddr unsigned short /* port address size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140#define inp(port) inb(port)
141#define outp(port, byte) outb((byte), (port))
142
143#define inpw(port) inw(port)
144#define outpw(port, word) outw((word), (port))
145
146#define ASC_MAX_SG_QUEUE 7
147#define ASC_MAX_SG_LIST 255
148
149#define ASC_CS_TYPE unsigned short
150
151#define ASC_IS_ISA (0x0001)
152#define ASC_IS_ISAPNP (0x0081)
153#define ASC_IS_EISA (0x0002)
154#define ASC_IS_PCI (0x0004)
155#define ASC_IS_PCI_ULTRA (0x0104)
156#define ASC_IS_PCMCIA (0x0008)
157#define ASC_IS_MCA (0x0020)
158#define ASC_IS_VL (0x0040)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#define ASC_IS_WIDESCSI_16 (0x0100)
160#define ASC_IS_WIDESCSI_32 (0x0200)
161#define ASC_IS_BIG_ENDIAN (0x8000)
Matthew Wilcox95c9f162007-09-09 08:56:39 -0600162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163#define ASC_CHIP_MIN_VER_VL (0x01)
164#define ASC_CHIP_MAX_VER_VL (0x07)
165#define ASC_CHIP_MIN_VER_PCI (0x09)
166#define ASC_CHIP_MAX_VER_PCI (0x0F)
167#define ASC_CHIP_VER_PCI_BIT (0x08)
168#define ASC_CHIP_MIN_VER_ISA (0x11)
169#define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
170#define ASC_CHIP_MAX_VER_ISA (0x27)
171#define ASC_CHIP_VER_ISA_BIT (0x30)
172#define ASC_CHIP_VER_ISAPNP_BIT (0x20)
173#define ASC_CHIP_VER_ASYN_BUG (0x21)
174#define ASC_CHIP_VER_PCI 0x08
175#define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
176#define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
177#define ASC_CHIP_MIN_VER_EISA (0x41)
178#define ASC_CHIP_MAX_VER_EISA (0x47)
179#define ASC_CHIP_VER_EISA_BIT (0x40)
180#define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181#define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182#define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183#define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185#define ASC_SCSI_ID_BITS 3
186#define ASC_SCSI_TIX_TYPE uchar
187#define ASC_ALL_DEVICE_BIT_SET 0xFF
188#define ASC_SCSI_BIT_ID_TYPE uchar
189#define ASC_MAX_TID 7
190#define ASC_MAX_LUN 7
191#define ASC_SCSI_WIDTH_BIT_SET 0xFF
192#define ASC_MAX_SENSE_LEN 32
193#define ASC_MIN_SENSE_LEN 14
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194#define ASC_SCSI_RESET_HOLD_TIME_US 60
195
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196/*
Matthew Wilcoxf05ec592007-09-09 08:56:36 -0600197 * Narrow boards only support 12-byte commands, while wide boards
198 * extend to 16-byte commands.
199 */
200#define ASC_MAX_CDB_LEN 12
201#define ADV_MAX_CDB_LEN 16
202
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203#define MS_SDTR_LEN 0x03
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204#define MS_WDTR_LEN 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206#define ASC_SG_LIST_PER_Q 7
207#define QS_FREE 0x00
208#define QS_READY 0x01
209#define QS_DISC1 0x02
210#define QS_DISC2 0x04
211#define QS_BUSY 0x08
212#define QS_ABORTED 0x40
213#define QS_DONE 0x80
214#define QC_NO_CALLBACK 0x01
215#define QC_SG_SWAP_QUEUE 0x02
216#define QC_SG_HEAD 0x04
217#define QC_DATA_IN 0x08
218#define QC_DATA_OUT 0x10
219#define QC_URGENT 0x20
220#define QC_MSG_OUT 0x40
221#define QC_REQ_SENSE 0x80
222#define QCSG_SG_XFER_LIST 0x02
223#define QCSG_SG_XFER_MORE 0x04
224#define QCSG_SG_XFER_END 0x08
225#define QD_IN_PROGRESS 0x00
226#define QD_NO_ERROR 0x01
227#define QD_ABORTED_BY_HOST 0x02
228#define QD_WITH_ERROR 0x04
229#define QD_INVALID_REQUEST 0x80
230#define QD_INVALID_HOST_NUM 0x81
231#define QD_INVALID_DEVICE 0x82
232#define QD_ERR_INTERNAL 0xFF
233#define QHSTA_NO_ERROR 0x00
234#define QHSTA_M_SEL_TIMEOUT 0x11
235#define QHSTA_M_DATA_OVER_RUN 0x12
236#define QHSTA_M_DATA_UNDER_RUN 0x12
237#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
238#define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
239#define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
240#define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
241#define QHSTA_D_HOST_ABORT_FAILED 0x23
242#define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
243#define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
244#define QHSTA_D_ASPI_NO_BUF_POOL 0x26
245#define QHSTA_M_WTM_TIMEOUT 0x41
246#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
247#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
248#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
249#define QHSTA_M_TARGET_STATUS_BUSY 0x45
250#define QHSTA_M_BAD_TAG_CODE 0x46
251#define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
252#define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
253#define QHSTA_D_LRAM_CMP_ERROR 0x81
254#define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
255#define ASC_FLAG_SCSIQ_REQ 0x01
256#define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
257#define ASC_FLAG_BIOS_ASYNC_IO 0x04
258#define ASC_FLAG_SRB_LINEAR_ADDR 0x08
259#define ASC_FLAG_WIN16 0x10
260#define ASC_FLAG_WIN32 0x20
261#define ASC_FLAG_ISA_OVER_16MB 0x40
262#define ASC_FLAG_DOS_VM_CALLBACK 0x80
263#define ASC_TAG_FLAG_EXTRA_BYTES 0x10
264#define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
265#define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
266#define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
267#define ASC_SCSIQ_CPY_BEG 4
268#define ASC_SCSIQ_SGHD_CPY_BEG 2
269#define ASC_SCSIQ_B_FWD 0
270#define ASC_SCSIQ_B_BWD 1
271#define ASC_SCSIQ_B_STATUS 2
272#define ASC_SCSIQ_B_QNO 3
273#define ASC_SCSIQ_B_CNTL 4
274#define ASC_SCSIQ_B_SG_QUEUE_CNT 5
275#define ASC_SCSIQ_D_DATA_ADDR 8
276#define ASC_SCSIQ_D_DATA_CNT 12
277#define ASC_SCSIQ_B_SENSE_LEN 20
278#define ASC_SCSIQ_DONE_INFO_BEG 22
279#define ASC_SCSIQ_D_SRBPTR 22
280#define ASC_SCSIQ_B_TARGET_IX 26
281#define ASC_SCSIQ_B_CDB_LEN 28
282#define ASC_SCSIQ_B_TAG_CODE 29
283#define ASC_SCSIQ_W_VM_ID 30
284#define ASC_SCSIQ_DONE_STATUS 32
285#define ASC_SCSIQ_HOST_STATUS 33
286#define ASC_SCSIQ_SCSI_STATUS 34
287#define ASC_SCSIQ_CDB_BEG 36
288#define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
289#define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
290#define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
291#define ASC_SCSIQ_B_SG_WK_QP 49
292#define ASC_SCSIQ_B_SG_WK_IX 50
293#define ASC_SCSIQ_W_ALT_DC1 52
294#define ASC_SCSIQ_B_LIST_CNT 6
295#define ASC_SCSIQ_B_CUR_LIST_CNT 7
296#define ASC_SGQ_B_SG_CNTL 4
297#define ASC_SGQ_B_SG_HEAD_QP 5
298#define ASC_SGQ_B_SG_LIST_CNT 6
299#define ASC_SGQ_B_SG_CUR_LIST_CNT 7
300#define ASC_SGQ_LIST_BEG 8
301#define ASC_DEF_SCSI1_QNG 4
302#define ASC_MAX_SCSI1_QNG 4
303#define ASC_DEF_SCSI2_QNG 16
304#define ASC_MAX_SCSI2_QNG 32
305#define ASC_TAG_CODE_MASK 0x23
306#define ASC_STOP_REQ_RISC_STOP 0x01
307#define ASC_STOP_ACK_RISC_STOP 0x03
308#define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
309#define ASC_STOP_CLEAN_UP_DISC_Q 0x20
310#define ASC_STOP_HOST_REQ_RISC_HALT 0x40
311#define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
312#define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
313#define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
314#define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
315#define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
316#define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
317#define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
318
319typedef struct asc_scsiq_1 {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400320 uchar status;
321 uchar q_no;
322 uchar cntl;
323 uchar sg_queue_cnt;
324 uchar target_id;
325 uchar target_lun;
326 ASC_PADDR data_addr;
327 ASC_DCNT data_cnt;
328 ASC_PADDR sense_addr;
329 uchar sense_len;
330 uchar extra_bytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331} ASC_SCSIQ_1;
332
333typedef struct asc_scsiq_2 {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400334 ASC_VADDR srb_ptr;
335 uchar target_ix;
336 uchar flag;
337 uchar cdb_len;
338 uchar tag_code;
339 ushort vm_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340} ASC_SCSIQ_2;
341
342typedef struct asc_scsiq_3 {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400343 uchar done_stat;
344 uchar host_stat;
345 uchar scsi_stat;
346 uchar scsi_msg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347} ASC_SCSIQ_3;
348
349typedef struct asc_scsiq_4 {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400350 uchar cdb[ASC_MAX_CDB_LEN];
351 uchar y_first_sg_list_qp;
352 uchar y_working_sg_qp;
353 uchar y_working_sg_ix;
354 uchar y_res;
355 ushort x_req_count;
356 ushort x_reconnect_rtn;
357 ASC_PADDR x_saved_data_addr;
358 ASC_DCNT x_saved_data_cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359} ASC_SCSIQ_4;
360
361typedef struct asc_q_done_info {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400362 ASC_SCSIQ_2 d2;
363 ASC_SCSIQ_3 d3;
364 uchar q_status;
365 uchar q_no;
366 uchar cntl;
367 uchar sense_len;
368 uchar extra_bytes;
369 uchar res;
370 ASC_DCNT remain_bytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371} ASC_QDONE_INFO;
372
373typedef struct asc_sg_list {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400374 ASC_PADDR addr;
375 ASC_DCNT bytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376} ASC_SG_LIST;
377
378typedef struct asc_sg_head {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400379 ushort entry_cnt;
380 ushort queue_cnt;
381 ushort entry_to_copy;
382 ushort res;
383 ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384} ASC_SG_HEAD;
385
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386typedef struct asc_scsi_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400387 ASC_SCSIQ_1 q1;
388 ASC_SCSIQ_2 q2;
389 uchar *cdbptr;
390 ASC_SG_HEAD *sg_head;
391 ushort remain_sg_entry_cnt;
392 ushort next_sg_index;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393} ASC_SCSI_Q;
394
395typedef struct asc_scsi_req_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400396 ASC_SCSIQ_1 r1;
397 ASC_SCSIQ_2 r2;
398 uchar *cdbptr;
399 ASC_SG_HEAD *sg_head;
400 uchar *sense_ptr;
401 ASC_SCSIQ_3 r3;
402 uchar cdb[ASC_MAX_CDB_LEN];
403 uchar sense[ASC_MIN_SENSE_LEN];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404} ASC_SCSI_REQ_Q;
405
406typedef struct asc_scsi_bios_req_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400407 ASC_SCSIQ_1 r1;
408 ASC_SCSIQ_2 r2;
409 uchar *cdbptr;
410 ASC_SG_HEAD *sg_head;
411 uchar *sense_ptr;
412 ASC_SCSIQ_3 r3;
413 uchar cdb[ASC_MAX_CDB_LEN];
414 uchar sense[ASC_MIN_SENSE_LEN];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415} ASC_SCSI_BIOS_REQ_Q;
416
417typedef struct asc_risc_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400418 uchar fwd;
419 uchar bwd;
420 ASC_SCSIQ_1 i1;
421 ASC_SCSIQ_2 i2;
422 ASC_SCSIQ_3 i3;
423 ASC_SCSIQ_4 i4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424} ASC_RISC_Q;
425
426typedef struct asc_sg_list_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400427 uchar seq_no;
428 uchar q_no;
429 uchar cntl;
430 uchar sg_head_qp;
431 uchar sg_list_cnt;
432 uchar sg_cur_list_cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433} ASC_SG_LIST_Q;
434
435typedef struct asc_risc_sg_list_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400436 uchar fwd;
437 uchar bwd;
438 ASC_SG_LIST_Q sg;
439 ASC_SG_LIST sg_list[7];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440} ASC_RISC_SG_LIST_Q;
441
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442#define ASCQ_ERR_Q_STATUS 0x0D
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443#define ASCQ_ERR_CUR_QNG 0x17
444#define ASCQ_ERR_SG_Q_LINKS 0x18
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445#define ASCQ_ERR_ISR_RE_ENTRY 0x1A
446#define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
447#define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
449/*
450 * Warning code values are set in ASC_DVC_VAR 'warn_code'.
451 */
452#define ASC_WARN_NO_ERROR 0x0000
453#define ASC_WARN_IO_PORT_ROTATE 0x0001
454#define ASC_WARN_EEPROM_CHKSUM 0x0002
455#define ASC_WARN_IRQ_MODIFIED 0x0004
456#define ASC_WARN_AUTO_CONFIG 0x0008
457#define ASC_WARN_CMD_QNG_CONFLICT 0x0010
458#define ASC_WARN_EEPROM_RECOVER 0x0020
459#define ASC_WARN_CFG_MSW_RECOVER 0x0040
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460
461/*
462 * Error code values are set in ASC_DVC_VAR 'err_code'.
463 */
464#define ASC_IERR_WRITE_EEPROM 0x0001
465#define ASC_IERR_MCODE_CHKSUM 0x0002
466#define ASC_IERR_SET_PC_ADDR 0x0004
467#define ASC_IERR_START_STOP_CHIP 0x0008
468#define ASC_IERR_IRQ_NO 0x0010
469#define ASC_IERR_SET_IRQ_NO 0x0020
470#define ASC_IERR_CHIP_VERSION 0x0040
471#define ASC_IERR_SET_SCSI_ID 0x0080
472#define ASC_IERR_GET_PHY_ADDR 0x0100
473#define ASC_IERR_BAD_SIGNATURE 0x0200
474#define ASC_IERR_NO_BUS_TYPE 0x0400
475#define ASC_IERR_SCAM 0x0800
476#define ASC_IERR_SET_SDTR 0x1000
477#define ASC_IERR_RW_LRAM 0x8000
478
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479#define ASC_MAX_IRQ_NO 15
480#define ASC_MIN_IRQ_NO 10
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481#define ASC_DEF_MAX_TOTAL_QNG (0xF0)
482#define ASC_MIN_TAG_Q_PER_DVC (0x04)
Matthew Wilcox95c9f162007-09-09 08:56:39 -0600483#define ASC_MIN_FREE_Q (0x02)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484#define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
485#define ASC_MAX_TOTAL_QNG 240
486#define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
487#define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
488#define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
489#define ASC_MAX_INRAM_TAG_QNG 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490#define ASC_IOADR_GAP 0x10
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491#define ASC_MAX_SYN_XFER_NO 16
492#define ASC_SYN_MAX_OFFSET 0x0F
493#define ASC_DEF_SDTR_OFFSET 0x0F
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494#define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
495#define SYN_XFER_NS_0 25
496#define SYN_XFER_NS_1 30
497#define SYN_XFER_NS_2 35
498#define SYN_XFER_NS_3 40
499#define SYN_XFER_NS_4 50
500#define SYN_XFER_NS_5 60
501#define SYN_XFER_NS_6 70
502#define SYN_XFER_NS_7 85
503#define SYN_ULTRA_XFER_NS_0 12
504#define SYN_ULTRA_XFER_NS_1 19
505#define SYN_ULTRA_XFER_NS_2 25
506#define SYN_ULTRA_XFER_NS_3 32
507#define SYN_ULTRA_XFER_NS_4 38
508#define SYN_ULTRA_XFER_NS_5 44
509#define SYN_ULTRA_XFER_NS_6 50
510#define SYN_ULTRA_XFER_NS_7 57
511#define SYN_ULTRA_XFER_NS_8 63
512#define SYN_ULTRA_XFER_NS_9 69
513#define SYN_ULTRA_XFER_NS_10 75
514#define SYN_ULTRA_XFER_NS_11 82
515#define SYN_ULTRA_XFER_NS_12 88
516#define SYN_ULTRA_XFER_NS_13 94
517#define SYN_ULTRA_XFER_NS_14 100
518#define SYN_ULTRA_XFER_NS_15 107
519
520typedef struct ext_msg {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400521 uchar msg_type;
522 uchar msg_len;
523 uchar msg_req;
524 union {
525 struct {
526 uchar sdtr_xfer_period;
527 uchar sdtr_req_ack_offset;
528 } sdtr;
529 struct {
530 uchar wdtr_width;
531 } wdtr;
532 struct {
533 uchar mdp_b3;
534 uchar mdp_b2;
535 uchar mdp_b1;
536 uchar mdp_b0;
537 } mdp;
538 } u_ext_msg;
539 uchar res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540} EXT_MSG;
541
542#define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
543#define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
544#define wdtr_width u_ext_msg.wdtr.wdtr_width
545#define mdp_b3 u_ext_msg.mdp_b3
546#define mdp_b2 u_ext_msg.mdp_b2
547#define mdp_b1 u_ext_msg.mdp_b1
548#define mdp_b0 u_ext_msg.mdp_b0
549
550typedef struct asc_dvc_cfg {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400551 ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
552 ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
553 ASC_SCSI_BIT_ID_TYPE disc_enable;
554 ASC_SCSI_BIT_ID_TYPE sdtr_enable;
555 uchar chip_scsi_id;
556 uchar isa_dma_speed;
557 uchar isa_dma_channel;
558 uchar chip_version;
559 ushort lib_serial_no;
560 ushort lib_version;
561 ushort mcode_date;
562 ushort mcode_version;
563 uchar max_tag_qng[ASC_MAX_TID + 1];
564 uchar *overrun_buf;
565 uchar sdtr_period_offset[ASC_MAX_TID + 1];
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400566 uchar adapter_info[6];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567} ASC_DVC_CFG;
568
569#define ASC_DEF_DVC_CNTL 0xFFFF
570#define ASC_DEF_CHIP_SCSI_ID 7
571#define ASC_DEF_ISA_DMA_SPEED 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572#define ASC_INIT_STATE_BEG_GET_CFG 0x0001
573#define ASC_INIT_STATE_END_GET_CFG 0x0002
574#define ASC_INIT_STATE_BEG_SET_CFG 0x0004
575#define ASC_INIT_STATE_END_SET_CFG 0x0008
576#define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
577#define ASC_INIT_STATE_END_LOAD_MC 0x0020
578#define ASC_INIT_STATE_BEG_INQUIRY 0x0040
579#define ASC_INIT_STATE_END_INQUIRY 0x0080
580#define ASC_INIT_RESET_SCSI_DONE 0x0100
581#define ASC_INIT_STATE_WITHOUT_EEP 0x8000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582#define ASC_BUG_FIX_IF_NOT_DWB 0x0001
583#define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
584#define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
585#define ASC_MIN_TAGGED_CMD 7
586#define ASC_MAX_SCSI_RESET_WAIT 30
587
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400588struct asc_dvc_var; /* Forward Declaration. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590typedef struct asc_dvc_var {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400591 PortAddr iop_base;
592 ushort err_code;
593 ushort dvc_cntl;
594 ushort bug_fix_cntl;
595 ushort bus_type;
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400596 ASC_SCSI_BIT_ID_TYPE init_sdtr;
597 ASC_SCSI_BIT_ID_TYPE sdtr_done;
598 ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
599 ASC_SCSI_BIT_ID_TYPE unit_not_ready;
600 ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
601 ASC_SCSI_BIT_ID_TYPE start_motor;
602 uchar scsi_reset_wait;
603 uchar chip_no;
604 char is_in_int;
605 uchar max_total_qng;
606 uchar cur_total_qng;
607 uchar in_critical_cnt;
608 uchar irq_no;
609 uchar last_q_shortage;
610 ushort init_state;
611 uchar cur_dvc_qng[ASC_MAX_TID + 1];
612 uchar max_dvc_qng[ASC_MAX_TID + 1];
613 ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
614 ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
615 uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
616 ASC_DVC_CFG *cfg;
617 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
618 char redo_scam;
619 ushort res2;
620 uchar dos_int13_table[ASC_MAX_TID + 1];
621 ASC_DCNT max_dma_count;
622 ASC_SCSI_BIT_ID_TYPE no_scam;
623 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
624 uchar max_sdtr_index;
625 uchar host_init_sdtr_index;
626 struct asc_board *drv_ptr;
627 ASC_DCNT uc_break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628} ASC_DVC_VAR;
629
630typedef struct asc_dvc_inq_info {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400631 uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632} ASC_DVC_INQ_INFO;
633
634typedef struct asc_cap_info {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400635 ASC_DCNT lba;
636 ASC_DCNT blk_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637} ASC_CAP_INFO;
638
639typedef struct asc_cap_info_array {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400640 ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641} ASC_CAP_INFO_ARRAY;
642
643#define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
644#define ASC_MCNTL_NULL_TARGET (ushort)0x0002
645#define ASC_CNTL_INITIATOR (ushort)0x0001
646#define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
647#define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
648#define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
649#define ASC_CNTL_NO_SCAM (ushort)0x0010
650#define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
651#define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
652#define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
653#define ASC_CNTL_RESET_SCSI (ushort)0x0200
654#define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
655#define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
656#define ASC_CNTL_SCSI_PARITY (ushort)0x1000
657#define ASC_CNTL_BURST_MODE (ushort)0x2000
658#define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
659#define ASC_EEP_DVC_CFG_BEG_VL 2
660#define ASC_EEP_MAX_DVC_ADDR_VL 15
661#define ASC_EEP_DVC_CFG_BEG 32
662#define ASC_EEP_MAX_DVC_ADDR 45
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663#define ASC_EEP_MAX_RETRY 20
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664
665/*
666 * These macros keep the chip SCSI id and ISA DMA speed
667 * bitfields in board order. C bitfields aren't portable
668 * between big and little-endian platforms so they are
669 * not used.
670 */
671
672#define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
673#define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
674#define ASC_EEP_SET_CHIP_ID(cfg, sid) \
675 ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
676#define ASC_EEP_SET_DMA_SPD(cfg, spd) \
677 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
678
679typedef struct asceep_config {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400680 ushort cfg_lsw;
681 ushort cfg_msw;
682 uchar init_sdtr;
683 uchar disc_enable;
684 uchar use_cmd_qng;
685 uchar start_motor;
686 uchar max_total_qng;
687 uchar max_tag_qng;
688 uchar bios_scan;
689 uchar power_up_wait;
690 uchar no_scam;
691 uchar id_speed; /* low order 4 bits is chip scsi id */
692 /* high order 4 bits is isa dma speed */
693 uchar dos_int13_table[ASC_MAX_TID + 1];
694 uchar adapter_info[6];
695 ushort cntl;
696 ushort chksum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697} ASCEEP_CONFIG;
698
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699#define ASC_EEP_CMD_READ 0x80
700#define ASC_EEP_CMD_WRITE 0x40
701#define ASC_EEP_CMD_WRITE_ABLE 0x30
702#define ASC_EEP_CMD_WRITE_DISABLE 0x00
703#define ASC_OVERRUN_BSIZE 0x00000048UL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704#define ASCV_MSGOUT_BEG 0x0000
705#define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
706#define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
707#define ASCV_BREAK_SAVED_CODE (ushort)0x0006
708#define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
709#define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
710#define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
711#define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
712#define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
713#define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
714#define ASCV_BREAK_ADDR (ushort)0x0028
715#define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
716#define ASCV_BREAK_CONTROL (ushort)0x002C
717#define ASCV_BREAK_HIT_COUNT (ushort)0x002E
718
719#define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
720#define ASCV_MCODE_CHKSUM_W (ushort)0x0032
721#define ASCV_MCODE_SIZE_W (ushort)0x0034
722#define ASCV_STOP_CODE_B (ushort)0x0036
723#define ASCV_DVC_ERR_CODE_B (ushort)0x0037
724#define ASCV_OVERRUN_PADDR_D (ushort)0x0038
725#define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
726#define ASCV_HALTCODE_W (ushort)0x0040
727#define ASCV_CHKSUM_W (ushort)0x0042
728#define ASCV_MC_DATE_W (ushort)0x0044
729#define ASCV_MC_VER_W (ushort)0x0046
730#define ASCV_NEXTRDY_B (ushort)0x0048
731#define ASCV_DONENEXT_B (ushort)0x0049
732#define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
733#define ASCV_SCSIBUSY_B (ushort)0x004B
734#define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
735#define ASCV_CURCDB_B (ushort)0x004D
736#define ASCV_RCLUN_B (ushort)0x004E
737#define ASCV_BUSY_QHEAD_B (ushort)0x004F
738#define ASCV_DISC1_QHEAD_B (ushort)0x0050
739#define ASCV_DISC_ENABLE_B (ushort)0x0052
740#define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
741#define ASCV_HOSTSCSI_ID_B (ushort)0x0055
742#define ASCV_MCODE_CNTL_B (ushort)0x0056
743#define ASCV_NULL_TARGET_B (ushort)0x0057
744#define ASCV_FREE_Q_HEAD_W (ushort)0x0058
745#define ASCV_DONE_Q_TAIL_W (ushort)0x005A
746#define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
747#define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
748#define ASCV_HOST_FLAG_B (ushort)0x005D
749#define ASCV_TOTAL_READY_Q_B (ushort)0x0064
750#define ASCV_VER_SERIAL_B (ushort)0x0065
751#define ASCV_HALTCODE_SAVED_W (ushort)0x0066
752#define ASCV_WTM_FLAG_B (ushort)0x0068
753#define ASCV_RISC_FLAG_B (ushort)0x006A
754#define ASCV_REQ_SG_LIST_QP (ushort)0x006B
755#define ASC_HOST_FLAG_IN_ISR 0x01
756#define ASC_HOST_FLAG_ACK_INT 0x02
757#define ASC_RISC_FLAG_GEN_INT 0x01
758#define ASC_RISC_FLAG_REQ_SG_LIST 0x02
759#define IOP_CTRL (0x0F)
760#define IOP_STATUS (0x0E)
761#define IOP_INT_ACK IOP_STATUS
762#define IOP_REG_IFC (0x0D)
763#define IOP_SYN_OFFSET (0x0B)
764#define IOP_EXTRA_CONTROL (0x0D)
765#define IOP_REG_PC (0x0C)
766#define IOP_RAM_ADDR (0x0A)
767#define IOP_RAM_DATA (0x08)
768#define IOP_EEP_DATA (0x06)
769#define IOP_EEP_CMD (0x07)
770#define IOP_VERSION (0x03)
771#define IOP_CONFIG_HIGH (0x04)
772#define IOP_CONFIG_LOW (0x02)
773#define IOP_SIG_BYTE (0x01)
774#define IOP_SIG_WORD (0x00)
775#define IOP_REG_DC1 (0x0E)
776#define IOP_REG_DC0 (0x0C)
777#define IOP_REG_SB (0x0B)
778#define IOP_REG_DA1 (0x0A)
779#define IOP_REG_DA0 (0x08)
780#define IOP_REG_SC (0x09)
781#define IOP_DMA_SPEED (0x07)
782#define IOP_REG_FLAG (0x07)
783#define IOP_FIFO_H (0x06)
784#define IOP_FIFO_L (0x04)
785#define IOP_REG_ID (0x05)
786#define IOP_REG_QP (0x03)
787#define IOP_REG_IH (0x02)
788#define IOP_REG_IX (0x01)
789#define IOP_REG_AX (0x00)
790#define IFC_REG_LOCK (0x00)
791#define IFC_REG_UNLOCK (0x09)
792#define IFC_WR_EN_FILTER (0x10)
793#define IFC_RD_NO_EEPROM (0x10)
794#define IFC_SLEW_RATE (0x20)
795#define IFC_ACT_NEG (0x40)
796#define IFC_INP_FILTER (0x80)
797#define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
798#define SC_SEL (uchar)(0x80)
799#define SC_BSY (uchar)(0x40)
800#define SC_ACK (uchar)(0x20)
801#define SC_REQ (uchar)(0x10)
802#define SC_ATN (uchar)(0x08)
803#define SC_IO (uchar)(0x04)
804#define SC_CD (uchar)(0x02)
805#define SC_MSG (uchar)(0x01)
806#define SEC_SCSI_CTL (uchar)(0x80)
807#define SEC_ACTIVE_NEGATE (uchar)(0x40)
808#define SEC_SLEW_RATE (uchar)(0x20)
809#define SEC_ENABLE_FILTER (uchar)(0x10)
810#define ASC_HALT_EXTMSG_IN (ushort)0x8000
811#define ASC_HALT_CHK_CONDITION (ushort)0x8100
812#define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
813#define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
814#define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
815#define ASC_HALT_SDTR_REJECTED (ushort)0x4000
816#define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
817#define ASC_MAX_QNO 0xF8
818#define ASC_DATA_SEC_BEG (ushort)0x0080
819#define ASC_DATA_SEC_END (ushort)0x0080
820#define ASC_CODE_SEC_BEG (ushort)0x0080
821#define ASC_CODE_SEC_END (ushort)0x0080
822#define ASC_QADR_BEG (0x4000)
823#define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
824#define ASC_QADR_END (ushort)0x7FFF
825#define ASC_QLAST_ADR (ushort)0x7FC0
826#define ASC_QBLK_SIZE 0x40
827#define ASC_BIOS_DATA_QBEG 0xF8
828#define ASC_MIN_ACTIVE_QNO 0x01
829#define ASC_QLINK_END 0xFF
830#define ASC_EEPROM_WORDS 0x10
831#define ASC_MAX_MGS_LEN 0x10
832#define ASC_BIOS_ADDR_DEF 0xDC00
833#define ASC_BIOS_SIZE 0x3800
834#define ASC_BIOS_RAM_OFF 0x3800
835#define ASC_BIOS_RAM_SIZE 0x800
836#define ASC_BIOS_MIN_ADDR 0xC000
837#define ASC_BIOS_MAX_ADDR 0xEC00
838#define ASC_BIOS_BANK_SIZE 0x0400
839#define ASC_MCODE_START_ADDR 0x0080
840#define ASC_CFG0_HOST_INT_ON 0x0020
841#define ASC_CFG0_BIOS_ON 0x0040
842#define ASC_CFG0_VERA_BURST_ON 0x0080
843#define ASC_CFG0_SCSI_PARITY_ON 0x0800
844#define ASC_CFG1_SCSI_TARGET_ON 0x0080
845#define ASC_CFG1_LRAM_8BITS_ON 0x0800
846#define ASC_CFG_MSW_CLR_MASK 0x3080
847#define CSW_TEST1 (ASC_CS_TYPE)0x8000
848#define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
849#define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
850#define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
851#define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
852#define CSW_TEST2 (ASC_CS_TYPE)0x0400
853#define CSW_TEST3 (ASC_CS_TYPE)0x0200
854#define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
855#define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
856#define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
857#define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
858#define CSW_HALTED (ASC_CS_TYPE)0x0010
859#define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
860#define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
861#define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
862#define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
863#define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
864#define CIW_INT_ACK (ASC_CS_TYPE)0x0100
865#define CIW_TEST1 (ASC_CS_TYPE)0x0200
866#define CIW_TEST2 (ASC_CS_TYPE)0x0400
867#define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
868#define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
869#define CC_CHIP_RESET (uchar)0x80
870#define CC_SCSI_RESET (uchar)0x40
871#define CC_HALT (uchar)0x20
872#define CC_SINGLE_STEP (uchar)0x10
873#define CC_DMA_ABLE (uchar)0x08
874#define CC_TEST (uchar)0x04
875#define CC_BANK_ONE (uchar)0x02
876#define CC_DIAG (uchar)0x01
877#define ASC_1000_ID0W 0x04C1
878#define ASC_1000_ID0W_FIX 0x00C1
879#define ASC_1000_ID1B 0x25
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880#define ASC_EISA_REV_IOP_MASK (0x0C83)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881#define ASC_EISA_CFG_IOP_MASK (0x0C86)
882#define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883#define INS_HALTINT (ushort)0x6281
884#define INS_HALT (ushort)0x6280
885#define INS_SINT (ushort)0x6200
886#define INS_RFLAG_WTM (ushort)0x7380
887#define ASC_MC_SAVE_CODE_WSIZE 0x500
888#define ASC_MC_SAVE_DATA_WSIZE 0x40
889
890typedef struct asc_mc_saved {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400891 ushort data[ASC_MC_SAVE_DATA_WSIZE];
892 ushort code[ASC_MC_SAVE_CODE_WSIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893} ASC_MC_SAVED;
894
895#define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
896#define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
897#define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
898#define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
899#define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
900#define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
901#define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
902#define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
903#define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
904#define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
Matthew Wilcox51219352007-10-02 21:55:22 -0400905#define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
906#define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
907#define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
908#define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909#define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
910#define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
911#define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
912#define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
913#define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
914#define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
915#define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
916#define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
917#define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
918#define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
919#define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
920#define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
921#define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
922#define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
923#define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
924#define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
925#define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
926#define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
927#define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
928#define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
929#define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
930#define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
931#define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
932#define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
933#define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
934#define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
935#define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
936#define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
937#define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
938#define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
939#define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
940#define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
941#define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
942#define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
943#define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
944#define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
945#define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
946#define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
947#define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
948#define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
949#define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
950#define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
951#define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
952#define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
953#define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
954#define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
955#define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
956#define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
957#define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
958#define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
959#define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
960#define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
961#define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
962#define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
963
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964#define ADV_LIB_VERSION_MAJOR 5
965#define ADV_LIB_VERSION_MINOR 14
966
967/*
968 * Define Adv Library required special types.
969 */
970
971/*
972 * Portable Data Types
973 *
974 * Any instance where a 32-bit long or pointer type is assumed
975 * for precision or HW defined structures, the following define
976 * types must be used. In Linux the char, short, and int types
977 * are all consistent at 8, 16, and 32 bits respectively. Pointers
978 * and long types are 64 bits on Alpha and UltraSPARC.
979 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400980#define ADV_PADDR __u32 /* Physical address data type. */
981#define ADV_VADDR __u32 /* Virtual address data type. */
982#define ADV_DCNT __u32 /* Unsigned Data count type. */
983#define ADV_SDCNT __s32 /* Signed Data count type. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984
985/*
986 * These macros are used to convert a virtual address to a
987 * 32-bit value. This currently can be used on Linux Alpha
988 * which uses 64-bit virtual address but a 32-bit bus address.
989 * This is likely to break in the future, but doing this now
990 * will give us time to change the HW and FW to handle 64-bit
991 * addresses.
992 */
993#define ADV_VADDR_TO_U32 virt_to_bus
994#define ADV_U32_TO_VADDR bus_to_virt
995
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400996#define AdvPortAddr void __iomem * /* Virtual memory address size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997
998/*
999 * Define Adv Library required memory access macros.
1000 */
1001#define ADV_MEM_READB(addr) readb(addr)
1002#define ADV_MEM_READW(addr) readw(addr)
1003#define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
1004#define ADV_MEM_WRITEW(addr, word) writew(word, addr)
1005#define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
1006
1007#define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
1008
1009/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 * Define total number of simultaneous maximum element scatter-gather
1011 * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
1012 * maximum number of outstanding commands per wide host adapter. Each
1013 * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
1014 * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
1015 * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
1016 * structures or 255 scatter-gather elements.
1017 *
1018 */
1019#define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
1020
1021/*
1022 * Define Adv Library required maximum number of scatter-gather
1023 * elements per request.
1024 */
1025#define ADV_MAX_SG_LIST 255
1026
1027/* Number of SG blocks needed. */
1028#define ADV_NUM_SG_BLOCK \
1029 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
1030
1031/* Total contiguous memory needed for SG blocks. */
1032#define ADV_SG_TOTAL_MEM_SIZE \
1033 (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
1034
1035#define ADV_PAGE_SIZE PAGE_SIZE
1036
1037#define ADV_NUM_PAGE_CROSSING \
1038 ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
1039
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040#define ADV_EEP_DVC_CFG_BEGIN (0x00)
1041#define ADV_EEP_DVC_CFG_END (0x15)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001042#define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043#define ADV_EEP_MAX_WORD_ADDR (0x1E)
1044
1045#define ADV_EEP_DELAY_MS 100
1046
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001047#define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
1048#define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049/*
1050 * For the ASC3550 Bit 13 is Termination Polarity control bit.
1051 * For later ICs Bit 13 controls whether the CIS (Card Information
1052 * Service Section) is loaded from EEPROM.
1053 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001054#define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
1055#define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056/*
1057 * ASC38C1600 Bit 11
1058 *
1059 * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
1060 * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
1061 * Function 0 will specify INT B.
1062 *
1063 * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
1064 * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
1065 * Function 1 will specify INT A.
1066 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001067#define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001069typedef struct adveep_3550_config {
1070 /* Word Offset, Description */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001072 ushort cfg_lsw; /* 00 power up initialization */
1073 /* bit 13 set - Term Polarity Control */
1074 /* bit 14 set - BIOS Enable */
1075 /* bit 15 set - Big Endian Mode */
1076 ushort cfg_msw; /* 01 unused */
1077 ushort disc_enable; /* 02 disconnect enable */
1078 ushort wdtr_able; /* 03 Wide DTR able */
1079 ushort sdtr_able; /* 04 Synchronous DTR able */
1080 ushort start_motor; /* 05 send start up motor */
1081 ushort tagqng_able; /* 06 tag queuing able */
1082 ushort bios_scan; /* 07 BIOS device control */
1083 ushort scam_tolerant; /* 08 no scam */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001085 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1086 uchar bios_boot_delay; /* power up wait */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001088 uchar scsi_reset_delay; /* 10 reset delay */
1089 uchar bios_id_lun; /* first boot device scsi id & lun */
1090 /* high nibble is lun */
1091 /* low nibble is scsi id */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001093 uchar termination; /* 11 0 - automatic */
1094 /* 1 - low off / high off */
1095 /* 2 - low off / high on */
1096 /* 3 - low on / high on */
1097 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001099 uchar reserved1; /* reserved byte (not used) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001101 ushort bios_ctrl; /* 12 BIOS control bits */
1102 /* bit 0 BIOS don't act as initiator. */
1103 /* bit 1 BIOS > 1 GB support */
1104 /* bit 2 BIOS > 2 Disk Support */
1105 /* bit 3 BIOS don't support removables */
1106 /* bit 4 BIOS support bootable CD */
1107 /* bit 5 BIOS scan enabled */
1108 /* bit 6 BIOS support multiple LUNs */
1109 /* bit 7 BIOS display of message */
1110 /* bit 8 SCAM disabled */
1111 /* bit 9 Reset SCSI bus during init. */
1112 /* bit 10 */
1113 /* bit 11 No verbose initialization. */
1114 /* bit 12 SCSI parity enabled */
1115 /* bit 13 */
1116 /* bit 14 */
1117 /* bit 15 */
1118 ushort ultra_able; /* 13 ULTRA speed able */
1119 ushort reserved2; /* 14 reserved */
1120 uchar max_host_qng; /* 15 maximum host queuing */
1121 uchar max_dvc_qng; /* maximum per device queuing */
1122 ushort dvc_cntl; /* 16 control bit for driver */
1123 ushort bug_fix; /* 17 control bit for bug fix */
1124 ushort serial_number_word1; /* 18 Board serial number word 1 */
1125 ushort serial_number_word2; /* 19 Board serial number word 2 */
1126 ushort serial_number_word3; /* 20 Board serial number word 3 */
1127 ushort check_sum; /* 21 EEP check sum */
1128 uchar oem_name[16]; /* 22 OEM name */
1129 ushort dvc_err_code; /* 30 last device driver error code */
1130 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1131 ushort adv_err_addr; /* 32 last uc error address */
1132 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1133 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1134 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1135 ushort num_of_err; /* 36 number of error */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136} ADVEEP_3550_CONFIG;
1137
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001138typedef struct adveep_38C0800_config {
1139 /* Word Offset, Description */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001141 ushort cfg_lsw; /* 00 power up initialization */
1142 /* bit 13 set - Load CIS */
1143 /* bit 14 set - BIOS Enable */
1144 /* bit 15 set - Big Endian Mode */
1145 ushort cfg_msw; /* 01 unused */
1146 ushort disc_enable; /* 02 disconnect enable */
1147 ushort wdtr_able; /* 03 Wide DTR able */
1148 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
1149 ushort start_motor; /* 05 send start up motor */
1150 ushort tagqng_able; /* 06 tag queuing able */
1151 ushort bios_scan; /* 07 BIOS device control */
1152 ushort scam_tolerant; /* 08 no scam */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001154 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1155 uchar bios_boot_delay; /* power up wait */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001157 uchar scsi_reset_delay; /* 10 reset delay */
1158 uchar bios_id_lun; /* first boot device scsi id & lun */
1159 /* high nibble is lun */
1160 /* low nibble is scsi id */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001162 uchar termination_se; /* 11 0 - automatic */
1163 /* 1 - low off / high off */
1164 /* 2 - low off / high on */
1165 /* 3 - low on / high on */
1166 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001168 uchar termination_lvd; /* 11 0 - automatic */
1169 /* 1 - low off / high off */
1170 /* 2 - low off / high on */
1171 /* 3 - low on / high on */
1172 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001174 ushort bios_ctrl; /* 12 BIOS control bits */
1175 /* bit 0 BIOS don't act as initiator. */
1176 /* bit 1 BIOS > 1 GB support */
1177 /* bit 2 BIOS > 2 Disk Support */
1178 /* bit 3 BIOS don't support removables */
1179 /* bit 4 BIOS support bootable CD */
1180 /* bit 5 BIOS scan enabled */
1181 /* bit 6 BIOS support multiple LUNs */
1182 /* bit 7 BIOS display of message */
1183 /* bit 8 SCAM disabled */
1184 /* bit 9 Reset SCSI bus during init. */
1185 /* bit 10 */
1186 /* bit 11 No verbose initialization. */
1187 /* bit 12 SCSI parity enabled */
1188 /* bit 13 */
1189 /* bit 14 */
1190 /* bit 15 */
1191 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
1192 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
1193 uchar max_host_qng; /* 15 maximum host queueing */
1194 uchar max_dvc_qng; /* maximum per device queuing */
1195 ushort dvc_cntl; /* 16 control bit for driver */
1196 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
1197 ushort serial_number_word1; /* 18 Board serial number word 1 */
1198 ushort serial_number_word2; /* 19 Board serial number word 2 */
1199 ushort serial_number_word3; /* 20 Board serial number word 3 */
1200 ushort check_sum; /* 21 EEP check sum */
1201 uchar oem_name[16]; /* 22 OEM name */
1202 ushort dvc_err_code; /* 30 last device driver error code */
1203 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1204 ushort adv_err_addr; /* 32 last uc error address */
1205 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1206 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1207 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1208 ushort reserved36; /* 36 reserved */
1209 ushort reserved37; /* 37 reserved */
1210 ushort reserved38; /* 38 reserved */
1211 ushort reserved39; /* 39 reserved */
1212 ushort reserved40; /* 40 reserved */
1213 ushort reserved41; /* 41 reserved */
1214 ushort reserved42; /* 42 reserved */
1215 ushort reserved43; /* 43 reserved */
1216 ushort reserved44; /* 44 reserved */
1217 ushort reserved45; /* 45 reserved */
1218 ushort reserved46; /* 46 reserved */
1219 ushort reserved47; /* 47 reserved */
1220 ushort reserved48; /* 48 reserved */
1221 ushort reserved49; /* 49 reserved */
1222 ushort reserved50; /* 50 reserved */
1223 ushort reserved51; /* 51 reserved */
1224 ushort reserved52; /* 52 reserved */
1225 ushort reserved53; /* 53 reserved */
1226 ushort reserved54; /* 54 reserved */
1227 ushort reserved55; /* 55 reserved */
1228 ushort cisptr_lsw; /* 56 CIS PTR LSW */
1229 ushort cisprt_msw; /* 57 CIS PTR MSW */
1230 ushort subsysvid; /* 58 SubSystem Vendor ID */
1231 ushort subsysid; /* 59 SubSystem ID */
1232 ushort reserved60; /* 60 reserved */
1233 ushort reserved61; /* 61 reserved */
1234 ushort reserved62; /* 62 reserved */
1235 ushort reserved63; /* 63 reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236} ADVEEP_38C0800_CONFIG;
1237
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001238typedef struct adveep_38C1600_config {
1239 /* Word Offset, Description */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001241 ushort cfg_lsw; /* 00 power up initialization */
1242 /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
1243 /* clear - Func. 0 INTA, Func. 1 INTB */
1244 /* bit 13 set - Load CIS */
1245 /* bit 14 set - BIOS Enable */
1246 /* bit 15 set - Big Endian Mode */
1247 ushort cfg_msw; /* 01 unused */
1248 ushort disc_enable; /* 02 disconnect enable */
1249 ushort wdtr_able; /* 03 Wide DTR able */
1250 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
1251 ushort start_motor; /* 05 send start up motor */
1252 ushort tagqng_able; /* 06 tag queuing able */
1253 ushort bios_scan; /* 07 BIOS device control */
1254 ushort scam_tolerant; /* 08 no scam */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001256 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1257 uchar bios_boot_delay; /* power up wait */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001259 uchar scsi_reset_delay; /* 10 reset delay */
1260 uchar bios_id_lun; /* first boot device scsi id & lun */
1261 /* high nibble is lun */
1262 /* low nibble is scsi id */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001264 uchar termination_se; /* 11 0 - automatic */
1265 /* 1 - low off / high off */
1266 /* 2 - low off / high on */
1267 /* 3 - low on / high on */
1268 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001270 uchar termination_lvd; /* 11 0 - automatic */
1271 /* 1 - low off / high off */
1272 /* 2 - low off / high on */
1273 /* 3 - low on / high on */
1274 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001276 ushort bios_ctrl; /* 12 BIOS control bits */
1277 /* bit 0 BIOS don't act as initiator. */
1278 /* bit 1 BIOS > 1 GB support */
1279 /* bit 2 BIOS > 2 Disk Support */
1280 /* bit 3 BIOS don't support removables */
1281 /* bit 4 BIOS support bootable CD */
1282 /* bit 5 BIOS scan enabled */
1283 /* bit 6 BIOS support multiple LUNs */
1284 /* bit 7 BIOS display of message */
1285 /* bit 8 SCAM disabled */
1286 /* bit 9 Reset SCSI bus during init. */
1287 /* bit 10 Basic Integrity Checking disabled */
1288 /* bit 11 No verbose initialization. */
1289 /* bit 12 SCSI parity enabled */
1290 /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
1291 /* bit 14 */
1292 /* bit 15 */
1293 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
1294 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
1295 uchar max_host_qng; /* 15 maximum host queueing */
1296 uchar max_dvc_qng; /* maximum per device queuing */
1297 ushort dvc_cntl; /* 16 control bit for driver */
1298 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
1299 ushort serial_number_word1; /* 18 Board serial number word 1 */
1300 ushort serial_number_word2; /* 19 Board serial number word 2 */
1301 ushort serial_number_word3; /* 20 Board serial number word 3 */
1302 ushort check_sum; /* 21 EEP check sum */
1303 uchar oem_name[16]; /* 22 OEM name */
1304 ushort dvc_err_code; /* 30 last device driver error code */
1305 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1306 ushort adv_err_addr; /* 32 last uc error address */
1307 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1308 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1309 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1310 ushort reserved36; /* 36 reserved */
1311 ushort reserved37; /* 37 reserved */
1312 ushort reserved38; /* 38 reserved */
1313 ushort reserved39; /* 39 reserved */
1314 ushort reserved40; /* 40 reserved */
1315 ushort reserved41; /* 41 reserved */
1316 ushort reserved42; /* 42 reserved */
1317 ushort reserved43; /* 43 reserved */
1318 ushort reserved44; /* 44 reserved */
1319 ushort reserved45; /* 45 reserved */
1320 ushort reserved46; /* 46 reserved */
1321 ushort reserved47; /* 47 reserved */
1322 ushort reserved48; /* 48 reserved */
1323 ushort reserved49; /* 49 reserved */
1324 ushort reserved50; /* 50 reserved */
1325 ushort reserved51; /* 51 reserved */
1326 ushort reserved52; /* 52 reserved */
1327 ushort reserved53; /* 53 reserved */
1328 ushort reserved54; /* 54 reserved */
1329 ushort reserved55; /* 55 reserved */
1330 ushort cisptr_lsw; /* 56 CIS PTR LSW */
1331 ushort cisprt_msw; /* 57 CIS PTR MSW */
1332 ushort subsysvid; /* 58 SubSystem Vendor ID */
1333 ushort subsysid; /* 59 SubSystem ID */
1334 ushort reserved60; /* 60 reserved */
1335 ushort reserved61; /* 61 reserved */
1336 ushort reserved62; /* 62 reserved */
1337 ushort reserved63; /* 63 reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338} ADVEEP_38C1600_CONFIG;
1339
1340/*
1341 * EEPROM Commands
1342 */
1343#define ASC_EEP_CMD_DONE 0x0200
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344
1345/* bios_ctrl */
1346#define BIOS_CTRL_BIOS 0x0001
1347#define BIOS_CTRL_EXTENDED_XLAT 0x0002
1348#define BIOS_CTRL_GT_2_DISK 0x0004
1349#define BIOS_CTRL_BIOS_REMOVABLE 0x0008
1350#define BIOS_CTRL_BOOTABLE_CD 0x0010
1351#define BIOS_CTRL_MULTIPLE_LUN 0x0040
1352#define BIOS_CTRL_DISPLAY_MSG 0x0080
1353#define BIOS_CTRL_NO_SCAM 0x0100
1354#define BIOS_CTRL_RESET_SCSI_BUS 0x0200
1355#define BIOS_CTRL_INIT_VERBOSE 0x0800
1356#define BIOS_CTRL_SCSI_PARITY 0x1000
1357#define BIOS_CTRL_AIPP_DIS 0x2000
1358
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001359#define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001361#define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362
1363/*
1364 * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
1365 * a special 16K Adv Library and Microcode version. After the issue is
1366 * resolved, should restore 32K support.
1367 *
1368 * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
1369 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001370#define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371
1372/*
1373 * Byte I/O register address from base of 'iop_base'.
1374 */
1375#define IOPB_INTR_STATUS_REG 0x00
1376#define IOPB_CHIP_ID_1 0x01
1377#define IOPB_INTR_ENABLES 0x02
1378#define IOPB_CHIP_TYPE_REV 0x03
1379#define IOPB_RES_ADDR_4 0x04
1380#define IOPB_RES_ADDR_5 0x05
1381#define IOPB_RAM_DATA 0x06
1382#define IOPB_RES_ADDR_7 0x07
1383#define IOPB_FLAG_REG 0x08
1384#define IOPB_RES_ADDR_9 0x09
1385#define IOPB_RISC_CSR 0x0A
1386#define IOPB_RES_ADDR_B 0x0B
1387#define IOPB_RES_ADDR_C 0x0C
1388#define IOPB_RES_ADDR_D 0x0D
1389#define IOPB_SOFT_OVER_WR 0x0E
1390#define IOPB_RES_ADDR_F 0x0F
1391#define IOPB_MEM_CFG 0x10
1392#define IOPB_RES_ADDR_11 0x11
1393#define IOPB_GPIO_DATA 0x12
1394#define IOPB_RES_ADDR_13 0x13
1395#define IOPB_FLASH_PAGE 0x14
1396#define IOPB_RES_ADDR_15 0x15
1397#define IOPB_GPIO_CNTL 0x16
1398#define IOPB_RES_ADDR_17 0x17
1399#define IOPB_FLASH_DATA 0x18
1400#define IOPB_RES_ADDR_19 0x19
1401#define IOPB_RES_ADDR_1A 0x1A
1402#define IOPB_RES_ADDR_1B 0x1B
1403#define IOPB_RES_ADDR_1C 0x1C
1404#define IOPB_RES_ADDR_1D 0x1D
1405#define IOPB_RES_ADDR_1E 0x1E
1406#define IOPB_RES_ADDR_1F 0x1F
1407#define IOPB_DMA_CFG0 0x20
1408#define IOPB_DMA_CFG1 0x21
1409#define IOPB_TICKLE 0x22
1410#define IOPB_DMA_REG_WR 0x23
1411#define IOPB_SDMA_STATUS 0x24
1412#define IOPB_SCSI_BYTE_CNT 0x25
1413#define IOPB_HOST_BYTE_CNT 0x26
1414#define IOPB_BYTE_LEFT_TO_XFER 0x27
1415#define IOPB_BYTE_TO_XFER_0 0x28
1416#define IOPB_BYTE_TO_XFER_1 0x29
1417#define IOPB_BYTE_TO_XFER_2 0x2A
1418#define IOPB_BYTE_TO_XFER_3 0x2B
1419#define IOPB_ACC_GRP 0x2C
1420#define IOPB_RES_ADDR_2D 0x2D
1421#define IOPB_DEV_ID 0x2E
1422#define IOPB_RES_ADDR_2F 0x2F
1423#define IOPB_SCSI_DATA 0x30
1424#define IOPB_RES_ADDR_31 0x31
1425#define IOPB_RES_ADDR_32 0x32
1426#define IOPB_SCSI_DATA_HSHK 0x33
1427#define IOPB_SCSI_CTRL 0x34
1428#define IOPB_RES_ADDR_35 0x35
1429#define IOPB_RES_ADDR_36 0x36
1430#define IOPB_RES_ADDR_37 0x37
1431#define IOPB_RAM_BIST 0x38
1432#define IOPB_PLL_TEST 0x39
1433#define IOPB_PCI_INT_CFG 0x3A
1434#define IOPB_RES_ADDR_3B 0x3B
1435#define IOPB_RFIFO_CNT 0x3C
1436#define IOPB_RES_ADDR_3D 0x3D
1437#define IOPB_RES_ADDR_3E 0x3E
1438#define IOPB_RES_ADDR_3F 0x3F
1439
1440/*
1441 * Word I/O register address from base of 'iop_base'.
1442 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001443#define IOPW_CHIP_ID_0 0x00 /* CID0 */
1444#define IOPW_CTRL_REG 0x02 /* CC */
1445#define IOPW_RAM_ADDR 0x04 /* LA */
1446#define IOPW_RAM_DATA 0x06 /* LD */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447#define IOPW_RES_ADDR_08 0x08
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001448#define IOPW_RISC_CSR 0x0A /* CSR */
1449#define IOPW_SCSI_CFG0 0x0C /* CFG0 */
1450#define IOPW_SCSI_CFG1 0x0E /* CFG1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451#define IOPW_RES_ADDR_10 0x10
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001452#define IOPW_SEL_MASK 0x12 /* SM */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453#define IOPW_RES_ADDR_14 0x14
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001454#define IOPW_FLASH_ADDR 0x16 /* FA */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455#define IOPW_RES_ADDR_18 0x18
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001456#define IOPW_EE_CMD 0x1A /* EC */
1457#define IOPW_EE_DATA 0x1C /* ED */
1458#define IOPW_SFIFO_CNT 0x1E /* SFC */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459#define IOPW_RES_ADDR_20 0x20
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001460#define IOPW_Q_BASE 0x22 /* QB */
1461#define IOPW_QP 0x24 /* QP */
1462#define IOPW_IX 0x26 /* IX */
1463#define IOPW_SP 0x28 /* SP */
1464#define IOPW_PC 0x2A /* PC */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465#define IOPW_RES_ADDR_2C 0x2C
1466#define IOPW_RES_ADDR_2E 0x2E
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001467#define IOPW_SCSI_DATA 0x30 /* SD */
1468#define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
1469#define IOPW_SCSI_CTRL 0x34 /* SC */
1470#define IOPW_HSHK_CFG 0x36 /* HCFG */
1471#define IOPW_SXFR_STATUS 0x36 /* SXS */
1472#define IOPW_SXFR_CNTL 0x38 /* SXL */
1473#define IOPW_SXFR_CNTH 0x3A /* SXH */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474#define IOPW_RES_ADDR_3C 0x3C
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001475#define IOPW_RFIFO_DATA 0x3E /* RFD */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476
1477/*
1478 * Doubleword I/O register address from base of 'iop_base'.
1479 */
1480#define IOPDW_RES_ADDR_0 0x00
1481#define IOPDW_RAM_DATA 0x04
1482#define IOPDW_RES_ADDR_8 0x08
1483#define IOPDW_RES_ADDR_C 0x0C
1484#define IOPDW_RES_ADDR_10 0x10
1485#define IOPDW_COMMA 0x14
1486#define IOPDW_COMMB 0x18
1487#define IOPDW_RES_ADDR_1C 0x1C
1488#define IOPDW_SDMA_ADDR0 0x20
1489#define IOPDW_SDMA_ADDR1 0x24
1490#define IOPDW_SDMA_COUNT 0x28
1491#define IOPDW_SDMA_ERROR 0x2C
1492#define IOPDW_RDMA_ADDR0 0x30
1493#define IOPDW_RDMA_ADDR1 0x34
1494#define IOPDW_RDMA_COUNT 0x38
1495#define IOPDW_RDMA_ERROR 0x3C
1496
1497#define ADV_CHIP_ID_BYTE 0x25
1498#define ADV_CHIP_ID_WORD 0x04C1
1499
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500#define ADV_INTR_ENABLE_HOST_INTR 0x01
1501#define ADV_INTR_ENABLE_SEL_INTR 0x02
1502#define ADV_INTR_ENABLE_DPR_INTR 0x04
1503#define ADV_INTR_ENABLE_RTA_INTR 0x08
1504#define ADV_INTR_ENABLE_RMA_INTR 0x10
1505#define ADV_INTR_ENABLE_RST_INTR 0x20
1506#define ADV_INTR_ENABLE_DPE_INTR 0x40
1507#define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
1508
1509#define ADV_INTR_STATUS_INTRA 0x01
1510#define ADV_INTR_STATUS_INTRB 0x02
1511#define ADV_INTR_STATUS_INTRC 0x04
1512
1513#define ADV_RISC_CSR_STOP (0x0000)
1514#define ADV_RISC_TEST_COND (0x2000)
1515#define ADV_RISC_CSR_RUN (0x4000)
1516#define ADV_RISC_CSR_SINGLE_STEP (0x8000)
1517
1518#define ADV_CTRL_REG_HOST_INTR 0x0100
1519#define ADV_CTRL_REG_SEL_INTR 0x0200
1520#define ADV_CTRL_REG_DPR_INTR 0x0400
1521#define ADV_CTRL_REG_RTA_INTR 0x0800
1522#define ADV_CTRL_REG_RMA_INTR 0x1000
1523#define ADV_CTRL_REG_RES_BIT14 0x2000
1524#define ADV_CTRL_REG_DPE_INTR 0x4000
1525#define ADV_CTRL_REG_POWER_DONE 0x8000
1526#define ADV_CTRL_REG_ANY_INTR 0xFF00
1527
1528#define ADV_CTRL_REG_CMD_RESET 0x00C6
1529#define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
1530#define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
1531#define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
1532#define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
1533
1534#define ADV_TICKLE_NOP 0x00
1535#define ADV_TICKLE_A 0x01
1536#define ADV_TICKLE_B 0x02
1537#define ADV_TICKLE_C 0x03
1538
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539#define AdvIsIntPending(port) \
1540 (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
1541
1542/*
1543 * SCSI_CFG0 Register bit definitions
1544 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001545#define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
1546#define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
1547#define EVEN_PARITY 0x1000 /* Select Even Parity */
1548#define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
1549#define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
1550#define PRIM_MODE 0x0100 /* Primitive SCSI mode */
1551#define SCAM_EN 0x0080 /* Enable SCAM selection */
1552#define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
1553#define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
1554#define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
1555#define OUR_ID 0x000F /* SCSI ID */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556
1557/*
1558 * SCSI_CFG1 Register bit definitions
1559 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001560#define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
1561#define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
1562#define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
1563#define FILTER_SEL 0x0C00 /* Filter Period Selection */
1564#define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
1565#define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
1566#define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
1567#define ACTIVE_DBL 0x0200 /* Disable Active Negation */
1568#define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
1569#define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
1570#define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
1571#define TERM_CTL 0x0030 /* External SCSI Termination Bits */
1572#define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
1573#define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
1574#define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575
1576/*
1577 * Addendum for ASC-38C0800 Chip
1578 *
1579 * The ASC-38C1600 Chip uses the same definitions except that the
1580 * bus mode override bits [12:10] have been moved to byte register
1581 * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
1582 * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
1583 * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
1584 * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
1585 * and [1:0]. Bits [14], [7:6], [3:2] are unused.
1586 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001587#define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
1588#define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
1589#define HVD 0x1000 /* HVD Device Detect */
1590#define LVD 0x0800 /* LVD Device Detect */
1591#define SE 0x0400 /* SE Device Detect */
1592#define TERM_LVD 0x00C0 /* LVD Termination Bits */
1593#define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
1594#define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
1595#define TERM_SE 0x0030 /* SE Termination Bits */
1596#define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
1597#define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
1598#define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
1599#define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
1600#define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
1601#define C_DET_SE 0x0003 /* SE Cable Detect Bits */
1602#define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
1603#define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604
1605#define CABLE_ILLEGAL_A 0x7
1606 /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
1607
1608#define CABLE_ILLEGAL_B 0xB
1609 /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
1610
1611/*
1612 * MEM_CFG Register bit definitions
1613 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001614#define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
1615#define FAST_EE_CLK 0x20 /* Diagnostic Bit */
1616#define RAM_SZ 0x1C /* Specify size of RAM to RISC */
1617#define RAM_SZ_2KB 0x00 /* 2 KB */
1618#define RAM_SZ_4KB 0x04 /* 4 KB */
1619#define RAM_SZ_8KB 0x08 /* 8 KB */
1620#define RAM_SZ_16KB 0x0C /* 16 KB */
1621#define RAM_SZ_32KB 0x10 /* 32 KB */
1622#define RAM_SZ_64KB 0x14 /* 64 KB */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623
1624/*
1625 * DMA_CFG0 Register bit definitions
1626 *
1627 * This register is only accessible to the host.
1628 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001629#define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
1630#define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
1631#define FIFO_THRESH_16B 0x00 /* 16 bytes */
1632#define FIFO_THRESH_32B 0x20 /* 32 bytes */
1633#define FIFO_THRESH_48B 0x30 /* 48 bytes */
1634#define FIFO_THRESH_64B 0x40 /* 64 bytes */
1635#define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
1636#define FIFO_THRESH_96B 0x60 /* 96 bytes */
1637#define FIFO_THRESH_112B 0x70 /* 112 bytes */
1638#define START_CTL 0x0C /* DMA start conditions */
1639#define START_CTL_TH 0x00 /* Wait threshold level (default) */
1640#define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
1641#define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
1642#define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
1643#define READ_CMD 0x03 /* Memory Read Method */
1644#define READ_CMD_MR 0x00 /* Memory Read */
1645#define READ_CMD_MRL 0x02 /* Memory Read Long */
1646#define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001647
1648/*
1649 * ASC-38C0800 RAM BIST Register bit definitions
1650 */
1651#define RAM_TEST_MODE 0x80
1652#define PRE_TEST_MODE 0x40
1653#define NORMAL_MODE 0x00
1654#define RAM_TEST_DONE 0x10
1655#define RAM_TEST_STATUS 0x0F
1656#define RAM_TEST_HOST_ERROR 0x08
1657#define RAM_TEST_INTRAM_ERROR 0x04
1658#define RAM_TEST_RISC_ERROR 0x02
1659#define RAM_TEST_SCSI_ERROR 0x01
1660#define RAM_TEST_SUCCESS 0x00
1661#define PRE_TEST_VALUE 0x05
1662#define NORMAL_VALUE 0x00
1663
1664/*
1665 * ASC38C1600 Definitions
1666 *
1667 * IOPB_PCI_INT_CFG Bit Field Definitions
1668 */
1669
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001670#define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001671
1672/*
1673 * Bit 1 can be set to change the interrupt for the Function to operate in
1674 * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
1675 * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
1676 * mode, otherwise the operating mode is undefined.
1677 */
1678#define TOTEMPOLE 0x02
1679
1680/*
1681 * Bit 0 can be used to change the Int Pin for the Function. The value is
1682 * 0 by default for both Functions with Function 0 using INT A and Function
1683 * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
1684 * INT A is used.
1685 *
1686 * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
1687 * value specified in the PCI Configuration Space.
1688 */
1689#define INTAB 0x01
1690
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691/*
1692 * Adv Library Status Definitions
1693 */
1694#define ADV_TRUE 1
1695#define ADV_FALSE 0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696#define ADV_SUCCESS 1
1697#define ADV_BUSY 0
1698#define ADV_ERROR (-1)
1699
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700/*
1701 * ADV_DVC_VAR 'warn_code' values
1702 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001703#define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
1704#define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
1705#define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001706#define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001708#define ADV_MAX_TID 15 /* max. target identifier */
1709#define ADV_MAX_LUN 7 /* max. logical unit number */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710
1711/*
1712 * Error code values are set in ADV_DVC_VAR 'err_code'.
1713 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001714#define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
1715#define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
1716#define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
1717#define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
1718#define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
1719#define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
1720#define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
1721#define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
1722#define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
1723#define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
1724#define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
1725#define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
1726#define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
1727#define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728
1729/*
1730 * Fixed locations of microcode operating variables.
1731 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001732#define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
1733#define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
1734#define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
1735#define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
1736#define ASC_MC_VERSION_NUM 0x003A /* microcode number */
1737#define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
1738#define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
1739#define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
1740#define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
1741#define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
1742#define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
1743#define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
1744#define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745#define ASC_MC_CHIP_TYPE 0x009A
1746#define ASC_MC_INTRB_CODE 0x009B
1747#define ASC_MC_WDTR_ABLE 0x009C
1748#define ASC_MC_SDTR_ABLE 0x009E
1749#define ASC_MC_TAGQNG_ABLE 0x00A0
1750#define ASC_MC_DISC_ENABLE 0x00A2
1751#define ASC_MC_IDLE_CMD_STATUS 0x00A4
1752#define ASC_MC_IDLE_CMD 0x00A6
1753#define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
1754#define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
1755#define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
1756#define ASC_MC_DEFAULT_MEM_CFG 0x00B0
1757#define ASC_MC_DEFAULT_SEL_MASK 0x00B2
1758#define ASC_MC_SDTR_DONE 0x00B6
1759#define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
1760#define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
1761#define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001762#define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763#define ASC_MC_WDTR_DONE 0x0124
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001764#define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765#define ASC_MC_ICQ 0x0160
1766#define ASC_MC_IRQ 0x0164
1767#define ASC_MC_PPR_ABLE 0x017A
1768
1769/*
1770 * BIOS LRAM variable absolute offsets.
1771 */
1772#define BIOS_CODESEG 0x54
1773#define BIOS_CODELEN 0x56
1774#define BIOS_SIGNATURE 0x58
1775#define BIOS_VERSION 0x5A
1776
1777/*
1778 * Microcode Control Flags
1779 *
1780 * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
1781 * and handled by the microcode.
1782 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001783#define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
1784#define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785
1786/*
1787 * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
1788 */
1789#define HSHK_CFG_WIDE_XFR 0x8000
1790#define HSHK_CFG_RATE 0x0F00
1791#define HSHK_CFG_OFFSET 0x001F
1792
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001793#define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
1794#define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
1795#define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
1796#define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001797
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001798#define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
1799#define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
1800#define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
1801#define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
1802#define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001804#define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
1805#define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
1806#define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
1807#define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
1808#define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001809/*
1810 * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
1811 * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
1812 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001813#define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
1814#define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815
1816/*
1817 * All fields here are accessed by the board microcode and need to be
1818 * little-endian.
1819 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001820typedef struct adv_carr_t {
1821 ADV_VADDR carr_va; /* Carrier Virtual Address */
1822 ADV_PADDR carr_pa; /* Carrier Physical Address */
1823 ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
1824 /*
1825 * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
1826 *
1827 * next_vpa [3:1] Reserved Bits
1828 * next_vpa [0] Done Flag set in Response Queue.
1829 */
1830 ADV_VADDR next_vpa;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831} ADV_CARR_T;
1832
1833/*
1834 * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
1835 */
1836#define ASC_NEXT_VPA_MASK 0xFFFFFFF0
1837
1838#define ASC_RQ_DONE 0x00000001
1839#define ASC_RQ_GOOD 0x00000002
1840#define ASC_CQ_STOPPER 0x00000000
1841
1842#define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
1843
1844#define ADV_CARRIER_NUM_PAGE_CROSSING \
1845 (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
1846 (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
1847
1848#define ADV_CARRIER_BUFSIZE \
1849 ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
1850
1851/*
1852 * ASC_SCSI_REQ_Q 'a_flag' definitions
1853 *
1854 * The Adv Library should limit use to the lower nibble (4 bits) of
1855 * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
1856 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001857#define ADV_POLL_REQUEST 0x01 /* poll for request completion */
1858#define ADV_SCSIQ_DONE 0x02 /* request done */
1859#define ADV_DONT_RETRY 0x08 /* don't do retry */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001861#define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
1862#define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
1863#define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001864
1865/*
1866 * Adapter temporary configuration structure
1867 *
1868 * This structure can be discarded after initialization. Don't add
1869 * fields here needed after initialization.
1870 *
1871 * Field naming convention:
1872 *
1873 * *_enable indicates the field enables or disables a feature. The
1874 * value of the field is never reset.
1875 */
1876typedef struct adv_dvc_cfg {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001877 ushort disc_enable; /* enable disconnection */
1878 uchar chip_version; /* chip version */
1879 uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
1880 ushort lib_version; /* Adv Library version number */
1881 ushort control_flag; /* Microcode Control Flag */
1882 ushort mcode_date; /* Microcode date */
1883 ushort mcode_version; /* Microcode version */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001884 ushort serial1; /* EEPROM serial number word 1 */
1885 ushort serial2; /* EEPROM serial number word 2 */
1886 ushort serial3; /* EEPROM serial number word 3 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887} ADV_DVC_CFG;
1888
1889struct adv_dvc_var;
1890struct adv_scsi_req_q;
1891
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892/*
1893 * Adapter operation variable structure.
1894 *
1895 * One structure is required per host adapter.
1896 *
1897 * Field naming convention:
1898 *
1899 * *_able indicates both whether a feature should be enabled or disabled
1900 * and whether a device isi capable of the feature. At initialization
1901 * this field may be set, but later if a device is found to be incapable
1902 * of the feature, the field is cleared.
1903 */
1904typedef struct adv_dvc_var {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001905 AdvPortAddr iop_base; /* I/O port address */
1906 ushort err_code; /* fatal error code */
1907 ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001908 ushort wdtr_able; /* try WDTR for a device */
1909 ushort sdtr_able; /* try SDTR for a device */
1910 ushort ultra_able; /* try SDTR Ultra speed for a device */
1911 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
1912 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
1913 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
1914 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
1915 ushort tagqng_able; /* try tagged queuing with a device */
1916 ushort ppr_able; /* PPR message capable per TID bitmask. */
1917 uchar max_dvc_qng; /* maximum number of tagged commands per device */
1918 ushort start_motor; /* start motor command allowed */
1919 uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
1920 uchar chip_no; /* should be assigned by caller */
1921 uchar max_host_qng; /* maximum number of Q'ed command allowed */
1922 uchar irq_no; /* IRQ number */
1923 ushort no_scam; /* scam_tolerant of EEPROM */
1924 struct asc_board *drv_ptr; /* driver pointer to private structure */
1925 uchar chip_scsi_id; /* chip SCSI target ID */
1926 uchar chip_type;
1927 uchar bist_err_code;
1928 ADV_CARR_T *carrier_buf;
1929 ADV_CARR_T *carr_freelist; /* Carrier free list. */
1930 ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
1931 ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
1932 ushort carr_pending_cnt; /* Count of pending carriers. */
1933 /*
1934 * Note: The following fields will not be used after initialization. The
1935 * driver may discard the buffer after initialization is done.
1936 */
1937 ADV_DVC_CFG *cfg; /* temporary configuration structure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938} ADV_DVC_VAR;
1939
1940#define NO_OF_SG_PER_BLOCK 15
1941
1942typedef struct asc_sg_block {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001943 uchar reserved1;
1944 uchar reserved2;
1945 uchar reserved3;
1946 uchar sg_cnt; /* Valid entries in block. */
1947 ADV_PADDR sg_ptr; /* Pointer to next sg block. */
1948 struct {
1949 ADV_PADDR sg_addr; /* SG element address. */
1950 ADV_DCNT sg_count; /* SG element count. */
1951 } sg_list[NO_OF_SG_PER_BLOCK];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952} ADV_SG_BLOCK;
1953
1954/*
1955 * ADV_SCSI_REQ_Q - microcode request structure
1956 *
1957 * All fields in this structure up to byte 60 are used by the microcode.
1958 * The microcode makes assumptions about the size and ordering of fields
1959 * in this structure. Do not change the structure definition here without
1960 * coordinating the change with the microcode.
1961 *
1962 * All fields accessed by microcode must be maintained in little_endian
1963 * order.
1964 */
1965typedef struct adv_scsi_req_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001966 uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
1967 uchar target_cmd;
1968 uchar target_id; /* Device target identifier. */
1969 uchar target_lun; /* Device target logical unit number. */
1970 ADV_PADDR data_addr; /* Data buffer physical address. */
1971 ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
1972 ADV_PADDR sense_addr;
1973 ADV_PADDR carr_pa;
1974 uchar mflag;
1975 uchar sense_len;
1976 uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
1977 uchar scsi_cntl;
1978 uchar done_status; /* Completion status. */
1979 uchar scsi_status; /* SCSI status byte. */
1980 uchar host_status; /* Ucode host status. */
1981 uchar sg_working_ix;
1982 uchar cdb[12]; /* SCSI CDB bytes 0-11. */
1983 ADV_PADDR sg_real_addr; /* SG list physical address. */
1984 ADV_PADDR scsiq_rptr;
1985 uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
1986 ADV_VADDR scsiq_ptr;
1987 ADV_VADDR carr_va;
1988 /*
1989 * End of microcode structure - 60 bytes. The rest of the structure
1990 * is used by the Adv Library and ignored by the microcode.
1991 */
1992 ADV_VADDR srb_ptr;
1993 ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
1994 char *vdata_addr; /* Data buffer virtual address. */
1995 uchar a_flag;
1996 uchar pad[2]; /* Pad out to a word boundary. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997} ADV_SCSI_REQ_Q;
1998
1999/*
2000 * Microcode idle loop commands
2001 */
2002#define IDLE_CMD_COMPLETED 0
2003#define IDLE_CMD_STOP_CHIP 0x0001
2004#define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
2005#define IDLE_CMD_SEND_INT 0x0004
2006#define IDLE_CMD_ABORT 0x0008
2007#define IDLE_CMD_DEVICE_RESET 0x0010
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002008#define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
2009#define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010#define IDLE_CMD_SCSIREQ 0x0080
2011
2012#define IDLE_CMD_STATUS_SUCCESS 0x0001
2013#define IDLE_CMD_STATUS_FAILURE 0x0002
2014
2015/*
2016 * AdvSendIdleCmd() flag definitions.
2017 */
2018#define ADV_NOWAIT 0x01
2019
2020/*
2021 * Wait loop time out values.
2022 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002023#define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
2024#define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002025#define SCSI_MAX_RETRY 10 /* retry count */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002027#define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
2028#define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
2029#define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
2030#define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002032#define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034/* Read byte from a register. */
2035#define AdvReadByteRegister(iop_base, reg_off) \
2036 (ADV_MEM_READB((iop_base) + (reg_off)))
2037
2038/* Write byte to a register. */
2039#define AdvWriteByteRegister(iop_base, reg_off, byte) \
2040 (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
2041
2042/* Read word (2 bytes) from a register. */
2043#define AdvReadWordRegister(iop_base, reg_off) \
2044 (ADV_MEM_READW((iop_base) + (reg_off)))
2045
2046/* Write word (2 bytes) to a register. */
2047#define AdvWriteWordRegister(iop_base, reg_off, word) \
2048 (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
2049
2050/* Write dword (4 bytes) to a register. */
2051#define AdvWriteDWordRegister(iop_base, reg_off, dword) \
2052 (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
2053
2054/* Read byte from LRAM. */
2055#define AdvReadByteLram(iop_base, addr, byte) \
2056do { \
2057 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
2058 (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
2059} while (0)
2060
2061/* Write byte to LRAM. */
2062#define AdvWriteByteLram(iop_base, addr, byte) \
2063 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2064 ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
2065
2066/* Read word (2 bytes) from LRAM. */
2067#define AdvReadWordLram(iop_base, addr, word) \
2068do { \
2069 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
2070 (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
2071} while (0)
2072
2073/* Write word (2 bytes) to LRAM. */
2074#define AdvWriteWordLram(iop_base, addr, word) \
2075 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2076 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
2077
2078/* Write little-endian double word (4 bytes) to LRAM */
2079/* Because of unspecified C language ordering don't use auto-increment. */
2080#define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
2081 ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2082 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
2083 cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
2084 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
2085 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
2086 cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
2087
2088/* Read word (2 bytes) from LRAM assuming that the address is already set. */
2089#define AdvReadWordAutoIncLram(iop_base) \
2090 (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
2091
2092/* Write word (2 bytes) to LRAM assuming that the address is already set. */
2093#define AdvWriteWordAutoIncLram(iop_base, word) \
2094 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
2095
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096/*
2097 * Define macro to check for Condor signature.
2098 *
2099 * Evaluate to ADV_TRUE if a Condor chip is found the specified port
2100 * address 'iop_base'. Otherwise evalue to ADV_FALSE.
2101 */
2102#define AdvFindSignature(iop_base) \
2103 (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
2104 ADV_CHIP_ID_BYTE) && \
2105 (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
2106 ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
2107
2108/*
2109 * Define macro to Return the version number of the chip at 'iop_base'.
2110 *
2111 * The second parameter 'bus_type' is currently unused.
2112 */
2113#define AdvGetChipVersion(iop_base, bus_type) \
2114 AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
2115
2116/*
2117 * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
2118 * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
2119 *
2120 * If the request has not yet been sent to the device it will simply be
2121 * aborted from RISC memory. If the request is disconnected it will be
2122 * aborted on reselection by sending an Abort Message to the target ID.
2123 *
2124 * Return value:
2125 * ADV_TRUE(1) - Queue was successfully aborted.
2126 * ADV_FALSE(0) - Queue was not found on the active queue list.
2127 */
2128#define AdvAbortQueue(asc_dvc, scsiq) \
2129 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
2130 (ADV_DCNT) (scsiq))
2131
2132/*
2133 * Send a Bus Device Reset Message to the specified target ID.
2134 *
2135 * All outstanding commands will be purged if sending the
2136 * Bus Device Reset Message is successful.
2137 *
2138 * Return Value:
2139 * ADV_TRUE(1) - All requests on the target are purged.
2140 * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
2141 * are not purged.
2142 */
2143#define AdvResetDevice(asc_dvc, target_id) \
2144 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
2145 (ADV_DCNT) (target_id))
2146
2147/*
2148 * SCSI Wide Type definition.
2149 */
2150#define ADV_SCSI_BIT_ID_TYPE ushort
2151
2152/*
2153 * AdvInitScsiTarget() 'cntl_flag' options.
2154 */
2155#define ADV_SCAN_LUN 0x01
2156#define ADV_CAPINFO_NOLUN 0x02
2157
2158/*
2159 * Convert target id to target id bit mask.
2160 */
2161#define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
2162
2163/*
2164 * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
2165 */
2166
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002167#define QD_NO_STATUS 0x00 /* Request not completed yet. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002168#define QD_NO_ERROR 0x01
2169#define QD_ABORTED_BY_HOST 0x02
2170#define QD_WITH_ERROR 0x04
2171
2172#define QHSTA_NO_ERROR 0x00
2173#define QHSTA_M_SEL_TIMEOUT 0x11
2174#define QHSTA_M_DATA_OVER_RUN 0x12
2175#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
2176#define QHSTA_M_QUEUE_ABORTED 0x15
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002177#define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
2178#define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
2179#define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
2180#define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
2181#define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
2182#define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
2183#define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184/* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002185#define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
2186#define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
2187#define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
2188#define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
2189#define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
2190#define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
2191#define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
2192#define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193#define QHSTA_M_WTM_TIMEOUT 0x41
2194#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
2195#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
2196#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002197#define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
2198#define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
2199#define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200
2201/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 * DvcGetPhyAddr() flag arguments
2203 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002204#define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
2205#define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
2206#define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
2207#define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
2208#define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
2209#define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210
2211/* Return the address that is aligned at the next doubleword >= to 'addr'. */
2212#define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
2213#define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
2214#define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
2215
2216/*
2217 * Total contiguous memory needed for driver SG blocks.
2218 *
2219 * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
2220 * number of scatter-gather elements the driver supports in a
2221 * single request.
2222 */
2223
2224#define ADV_SG_LIST_MAX_BYTE_SIZE \
2225 (sizeof(ADV_SG_BLOCK) * \
2226 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
2227
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228/* Reference Scsi_Host hostdata */
2229#define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
2230
2231/* asc_board_t flags */
2232#define ASC_HOST_IN_RESET 0x01
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002233#define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234#define ASC_SELECT_QUEUE_DEPTHS 0x08
2235
2236#define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
2237#define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
2238
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002239#define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002241#define ASC_INFO_SIZE 128 /* advansys_info() line size */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002242
2243#ifdef CONFIG_PROC_FS
2244/* /proc/scsi/advansys/[0...] related definitions */
2245#define ASC_PRTBUF_SIZE 2048
2246#define ASC_PRTLINE_SIZE 160
2247
2248#define ASC_PRT_NEXT() \
2249 if (cp) { \
2250 totlen += len; \
2251 leftlen -= len; \
2252 if (leftlen == 0) { \
2253 return totlen; \
2254 } \
2255 cp += len; \
2256 }
2257#endif /* CONFIG_PROC_FS */
2258
2259/* Asc Library return codes */
2260#define ASC_TRUE 1
2261#define ASC_FALSE 0
2262#define ASC_NOERROR 1
2263#define ASC_BUSY 0
2264#define ASC_ERROR (-1)
2265
2266/* struct scsi_cmnd function return codes */
2267#define STATUS_BYTE(byte) (byte)
2268#define MSG_BYTE(byte) ((byte) << 8)
2269#define HOST_BYTE(byte) ((byte) << 16)
2270#define DRIVER_BYTE(byte) ((byte) << 24)
2271
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272#ifndef ADVANSYS_STATS
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002273#define ASC_STATS(shost, counter)
2274#define ASC_STATS_ADD(shost, counter, count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275#else /* ADVANSYS_STATS */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002276#define ASC_STATS(shost, counter) \
2277 (ASC_BOARDP(shost)->asc_stats.counter++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002279#define ASC_STATS_ADD(shost, counter, count) \
2280 (ASC_BOARDP(shost)->asc_stats.counter += (count))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281#endif /* ADVANSYS_STATS */
2282
2283#define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
2284
2285/* If the result wraps when calculating tenths, return 0. */
2286#define ASC_TENTHS(num, den) \
2287 (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
2288 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
2289
2290/*
2291 * Display a message to the console.
2292 */
2293#define ASC_PRINT(s) \
2294 { \
2295 printk("advansys: "); \
2296 printk(s); \
2297 }
2298
2299#define ASC_PRINT1(s, a1) \
2300 { \
2301 printk("advansys: "); \
2302 printk((s), (a1)); \
2303 }
2304
2305#define ASC_PRINT2(s, a1, a2) \
2306 { \
2307 printk("advansys: "); \
2308 printk((s), (a1), (a2)); \
2309 }
2310
2311#define ASC_PRINT3(s, a1, a2, a3) \
2312 { \
2313 printk("advansys: "); \
2314 printk((s), (a1), (a2), (a3)); \
2315 }
2316
2317#define ASC_PRINT4(s, a1, a2, a3, a4) \
2318 { \
2319 printk("advansys: "); \
2320 printk((s), (a1), (a2), (a3), (a4)); \
2321 }
2322
Linus Torvalds1da177e2005-04-16 15:20:36 -07002323#ifndef ADVANSYS_DEBUG
2324
2325#define ASC_DBG(lvl, s)
2326#define ASC_DBG1(lvl, s, a1)
2327#define ASC_DBG2(lvl, s, a1, a2)
2328#define ASC_DBG3(lvl, s, a1, a2, a3)
2329#define ASC_DBG4(lvl, s, a1, a2, a3, a4)
2330#define ASC_DBG_PRT_SCSI_HOST(lvl, s)
2331#define ASC_DBG_PRT_SCSI_CMND(lvl, s)
2332#define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
2333#define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
2334#define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
2335#define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
2336#define ASC_DBG_PRT_HEX(lvl, name, start, length)
2337#define ASC_DBG_PRT_CDB(lvl, cdb, len)
2338#define ASC_DBG_PRT_SENSE(lvl, sense, len)
2339#define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
2340
2341#else /* ADVANSYS_DEBUG */
2342
2343/*
2344 * Debugging Message Levels:
2345 * 0: Errors Only
2346 * 1: High-Level Tracing
2347 * 2-N: Verbose Tracing
2348 */
2349
2350#define ASC_DBG(lvl, s) \
2351 { \
2352 if (asc_dbglvl >= (lvl)) { \
2353 printk(s); \
2354 } \
2355 }
2356
2357#define ASC_DBG1(lvl, s, a1) \
2358 { \
2359 if (asc_dbglvl >= (lvl)) { \
2360 printk((s), (a1)); \
2361 } \
2362 }
2363
2364#define ASC_DBG2(lvl, s, a1, a2) \
2365 { \
2366 if (asc_dbglvl >= (lvl)) { \
2367 printk((s), (a1), (a2)); \
2368 } \
2369 }
2370
2371#define ASC_DBG3(lvl, s, a1, a2, a3) \
2372 { \
2373 if (asc_dbglvl >= (lvl)) { \
2374 printk((s), (a1), (a2), (a3)); \
2375 } \
2376 }
2377
2378#define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
2379 { \
2380 if (asc_dbglvl >= (lvl)) { \
2381 printk((s), (a1), (a2), (a3), (a4)); \
2382 } \
2383 }
2384
2385#define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
2386 { \
2387 if (asc_dbglvl >= (lvl)) { \
2388 asc_prt_scsi_host(s); \
2389 } \
2390 }
2391
2392#define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
2393 { \
2394 if (asc_dbglvl >= (lvl)) { \
2395 asc_prt_scsi_cmnd(s); \
2396 } \
2397 }
2398
2399#define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
2400 { \
2401 if (asc_dbglvl >= (lvl)) { \
2402 asc_prt_asc_scsi_q(scsiqp); \
2403 } \
2404 }
2405
2406#define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
2407 { \
2408 if (asc_dbglvl >= (lvl)) { \
2409 asc_prt_asc_qdone_info(qdone); \
2410 } \
2411 }
2412
2413#define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
2414 { \
2415 if (asc_dbglvl >= (lvl)) { \
2416 asc_prt_adv_scsi_req_q(scsiqp); \
2417 } \
2418 }
2419
2420#define ASC_DBG_PRT_HEX(lvl, name, start, length) \
2421 { \
2422 if (asc_dbglvl >= (lvl)) { \
2423 asc_prt_hex((name), (start), (length)); \
2424 } \
2425 }
2426
2427#define ASC_DBG_PRT_CDB(lvl, cdb, len) \
2428 ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
2429
2430#define ASC_DBG_PRT_SENSE(lvl, sense, len) \
2431 ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
2432
2433#define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
2434 ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
2435#endif /* ADVANSYS_DEBUG */
2436
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437#ifdef ADVANSYS_STATS
2438
2439/* Per board statistics structure */
2440struct asc_stats {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002441 /* Driver Entrypoint Statistics */
2442 ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
2443 ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
2444 ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
2445 ADV_DCNT interrupt; /* # advansys_interrupt() calls */
2446 ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
2447 ADV_DCNT done; /* # calls to request's scsi_done function */
2448 ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
2449 ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
2450 ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
2451 /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
2452 ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
2453 ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
2454 ADV_DCNT exe_error; /* # ASC_ERROR returns. */
2455 ADV_DCNT exe_unknown; /* # unknown returns. */
2456 /* Data Transfer Statistics */
2457 ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
2458 ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
2459 ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
2460 ADV_DCNT sg_elem; /* # scatter-gather elements */
2461 ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462};
2463#endif /* ADVANSYS_STATS */
2464
2465/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466 * Adv Library Request Structures
2467 *
2468 * The following two structures are used to process Wide Board requests.
2469 *
2470 * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
2471 * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
2472 * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
2473 * Mid-Level SCSI request structure.
2474 *
2475 * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
2476 * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
2477 * up to 255 scatter-gather elements may be used per request or
2478 * ADV_SCSI_REQ_Q.
2479 *
2480 * Both structures must be 32 byte aligned.
2481 */
2482typedef struct adv_sgblk {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002483 ADV_SG_BLOCK sg_block; /* Sgblock structure. */
2484 uchar align[32]; /* Sgblock structure padding. */
2485 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486} adv_sgblk_t;
2487
2488typedef struct adv_req {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002489 ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
2490 uchar align[32]; /* Request structure padding. */
2491 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
2492 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
2493 struct adv_req *next_reqp; /* Next Request Structure. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494} adv_req_t;
2495
2496/*
2497 * Structure allocated for each board.
2498 *
Matthew Wilcox8dfb5372007-07-30 09:08:34 -06002499 * This structure is allocated by scsi_host_alloc() at the end
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 * of the 'Scsi_Host' structure starting at the 'hostdata'
2501 * field. It is guaranteed to be allocated from DMA-able memory.
2502 */
2503typedef struct asc_board {
Matthew Wilcox394dbf32007-07-26 11:56:40 -04002504 struct device *dev;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002505 int id; /* Board Id */
2506 uint flags; /* Board flags */
2507 union {
2508 ASC_DVC_VAR asc_dvc_var; /* Narrow board */
2509 ADV_DVC_VAR adv_dvc_var; /* Wide board */
2510 } dvc_var;
2511 union {
2512 ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
2513 ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
2514 } dvc_cfg;
2515 ushort asc_n_io_port; /* Number I/O ports. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002516 ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
2517 struct scsi_device *device[ADV_MAX_TID + 1]; /* Mid-Level Scsi Device */
2518 ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
2519 ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
2520 ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
2521 union {
2522 ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
2523 ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
2524 ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
2525 ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
2526 } eep_config;
2527 ulong last_reset; /* Saved last reset time */
2528 spinlock_t lock; /* Board spinlock */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002529 /* /proc/scsi/advansys/[0...] */
2530 char *prtbuf; /* /proc print buffer */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002531#ifdef ADVANSYS_STATS
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002532 struct asc_stats asc_stats; /* Board statistics */
2533#endif /* ADVANSYS_STATS */
2534 /*
2535 * The following fields are used only for Narrow Boards.
2536 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002537 uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
2538 /*
2539 * The following fields are used only for Wide Boards.
2540 */
2541 void __iomem *ioremap_addr; /* I/O Memory remap address. */
2542 ushort ioport; /* I/O Port address. */
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -06002543 ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002544 adv_req_t *orig_reqp; /* adv_req_t memory block. */
2545 adv_req_t *adv_reqp; /* Request structures. */
2546 adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
2547 ushort bios_signature; /* BIOS Signature. */
2548 ushort bios_version; /* BIOS Version. */
2549 ushort bios_codeseg; /* BIOS Code Segment. */
2550 ushort bios_codelen; /* BIOS Code Segment Length. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551} asc_board_t;
2552
Matthew Wilcox13ac2d92007-07-30 08:10:23 -06002553#define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
2554 dvc_var.adv_dvc_var)
2555#define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
2556
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557/* Number of boards detected in system. */
Matthew Wilcox78e77d82007-07-29 21:46:15 -06002558static int asc_board_count;
2559
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560/* Overrun buffer used by all narrow boards. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002561static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562
2563/*
2564 * Global structures required to issue a command.
2565 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002566static ASC_SCSI_Q asc_scsi_q = { {0} };
2567static ASC_SG_HEAD asc_sg_head = { 0 };
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569#ifdef ADVANSYS_DEBUG
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002570static int asc_dbglvl = 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572/*
Matthew Wilcox51219352007-10-02 21:55:22 -04002573 * asc_prt_scsi_host()
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574 */
Matthew Wilcox51219352007-10-02 21:55:22 -04002575static void asc_prt_scsi_host(struct Scsi_Host *s)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002577 asc_board_t *boardp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002578
Matthew Wilcox51219352007-10-02 21:55:22 -04002579 boardp = ASC_BOARDP(s);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580
Matthew Wilcox51219352007-10-02 21:55:22 -04002581 printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
2582 printk(" host_busy %u, host_no %d, last_reset %d,\n",
2583 s->host_busy, s->host_no, (unsigned)s->last_reset);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584
Matthew Wilcox51219352007-10-02 21:55:22 -04002585 printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
2586 (ulong)s->base, (ulong)s->io_port, s->irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587
Matthew Wilcox51219352007-10-02 21:55:22 -04002588 printk(" dma_channel %d, this_id %d, can_queue %d,\n",
2589 s->dma_channel, s->this_id, s->can_queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590
Matthew Wilcox51219352007-10-02 21:55:22 -04002591 printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
2592 s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002594 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox51219352007-10-02 21:55:22 -04002595 asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
2596 asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002597 } else {
Matthew Wilcox51219352007-10-02 21:55:22 -04002598 asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
2599 asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002600 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601}
Matthew Wilcox51219352007-10-02 21:55:22 -04002602
2603/*
2604 * asc_prt_scsi_cmnd()
2605 */
2606static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
2607{
2608 printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
2609
2610 printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
2611 (ulong)s->device->host, (ulong)s->device, s->device->id,
2612 s->device->lun, s->device->channel);
2613
2614 asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
2615
2616 printk("sc_data_direction %u, resid %d\n",
2617 s->sc_data_direction, s->resid);
2618
2619 printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
2620
2621 printk(" serial_number 0x%x, retries %d, allowed %d\n",
2622 (unsigned)s->serial_number, s->retries, s->allowed);
2623
2624 printk(" timeout_per_command %d\n", s->timeout_per_command);
2625
2626 printk(" scsi_done 0x%p, done 0x%p, host_scribble 0x%p, result 0x%x\n",
2627 s->scsi_done, s->done, s->host_scribble, s->result);
2628
2629 printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
2630}
2631
2632/*
2633 * asc_prt_asc_dvc_var()
2634 */
2635static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
2636{
2637 printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
2638
2639 printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
2640 "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
2641
2642 printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
2643 (unsigned)h->init_sdtr);
2644
2645 printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
2646 "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
2647 (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
2648 (unsigned)h->chip_no);
2649
2650 printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
2651 "%u,\n", (unsigned)h->queue_full_or_busy,
2652 (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
2653
2654 printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
2655 "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
2656 (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
2657 (unsigned)h->in_critical_cnt);
2658
2659 printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
2660 "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
2661 (unsigned)h->init_state, (unsigned)h->no_scam,
2662 (unsigned)h->pci_fix_asyn_xfer);
2663
2664 printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
2665}
2666
2667/*
2668 * asc_prt_asc_dvc_cfg()
2669 */
2670static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
2671{
2672 printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
2673
2674 printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
2675 h->can_tagged_qng, h->cmd_qng_enabled);
2676 printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
2677 h->disc_enable, h->sdtr_enable);
2678
2679 printk
2680 (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
2681 h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
2682 h->chip_version);
2683
2684 printk
2685 (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
2686 to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
2687 h->mcode_date);
2688
2689 printk(" mcode_version %d, overrun_buf 0x%lx\n",
2690 h->mcode_version, (ulong)h->overrun_buf);
2691}
2692
2693/*
2694 * asc_prt_asc_scsi_q()
2695 */
2696static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
2697{
2698 ASC_SG_HEAD *sgp;
2699 int i;
2700
2701 printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
2702
2703 printk
2704 (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
2705 q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
2706 q->q2.tag_code);
2707
2708 printk
2709 (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
2710 (ulong)le32_to_cpu(q->q1.data_addr),
2711 (ulong)le32_to_cpu(q->q1.data_cnt),
2712 (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
2713
2714 printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
2715 (ulong)q->cdbptr, q->q2.cdb_len,
2716 (ulong)q->sg_head, q->q1.sg_queue_cnt);
2717
2718 if (q->sg_head) {
2719 sgp = q->sg_head;
2720 printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
2721 printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
2722 sgp->queue_cnt);
2723 for (i = 0; i < sgp->entry_cnt; i++) {
2724 printk(" [%u]: addr 0x%lx, bytes %lu\n",
2725 i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
2726 (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
2727 }
2728
2729 }
2730}
2731
2732/*
2733 * asc_prt_asc_qdone_info()
2734 */
2735static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
2736{
2737 printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
2738 printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
2739 (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
2740 q->d2.tag_code);
2741 printk
2742 (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
2743 q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
2744}
2745
2746/*
2747 * asc_prt_adv_dvc_var()
2748 *
2749 * Display an ADV_DVC_VAR structure.
2750 */
2751static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
2752{
2753 printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
2754
2755 printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
2756 (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
2757
2758 printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
2759 (ulong)h->isr_callback, (unsigned)h->sdtr_able,
2760 (unsigned)h->wdtr_able);
2761
2762 printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
2763 (unsigned)h->start_motor,
2764 (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
2765
2766 printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
2767 (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
2768 (ulong)h->carr_freelist);
2769
2770 printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
2771 (ulong)h->icq_sp, (ulong)h->irq_sp);
2772
2773 printk(" no_scam 0x%x, tagqng_able 0x%x\n",
2774 (unsigned)h->no_scam, (unsigned)h->tagqng_able);
2775
2776 printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
2777 (unsigned)h->chip_scsi_id, (ulong)h->cfg);
2778}
2779
2780/*
2781 * asc_prt_adv_dvc_cfg()
2782 *
2783 * Display an ADV_DVC_CFG structure.
2784 */
2785static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
2786{
2787 printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
2788
2789 printk(" disc_enable 0x%x, termination 0x%x\n",
2790 h->disc_enable, h->termination);
2791
2792 printk(" chip_version 0x%x, mcode_date 0x%x\n",
2793 h->chip_version, h->mcode_date);
2794
2795 printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
2796 h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
2797
2798 printk(" control_flag 0x%x\n", h->control_flag);
2799}
2800
2801/*
2802 * asc_prt_adv_scsi_req_q()
2803 *
2804 * Display an ADV_SCSI_REQ_Q structure.
2805 */
2806static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
2807{
2808 int sg_blk_cnt;
2809 struct asc_sg_block *sg_ptr;
2810
2811 printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
2812
2813 printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
2814 q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
2815
2816 printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
2817 q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
2818
2819 printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
2820 (ulong)le32_to_cpu(q->data_cnt),
2821 (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
2822
2823 printk
2824 (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
2825 q->cdb_len, q->done_status, q->host_status, q->scsi_status);
2826
2827 printk(" sg_working_ix 0x%x, target_cmd %u\n",
2828 q->sg_working_ix, q->target_cmd);
2829
2830 printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
2831 (ulong)le32_to_cpu(q->scsiq_rptr),
2832 (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
2833
2834 /* Display the request's ADV_SG_BLOCK structures. */
2835 if (q->sg_list_ptr != NULL) {
2836 sg_blk_cnt = 0;
2837 while (1) {
2838 /*
2839 * 'sg_ptr' is a physical address. Convert it to a virtual
2840 * address by indexing 'sg_blk_cnt' into the virtual address
2841 * array 'sg_list_ptr'.
2842 *
2843 * XXX - Assumes all SG physical blocks are virtually contiguous.
2844 */
2845 sg_ptr =
2846 &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
2847 asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
2848 if (sg_ptr->sg_ptr == 0) {
2849 break;
2850 }
2851 sg_blk_cnt++;
2852 }
2853 }
2854}
2855
2856/*
2857 * asc_prt_adv_sgblock()
2858 *
2859 * Display an ADV_SG_BLOCK structure.
2860 */
2861static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
2862{
2863 int i;
2864
2865 printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
2866 (ulong)b, sgblockno);
2867 printk(" sg_cnt %u, sg_ptr 0x%lx\n",
2868 b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
2869 BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
2870 if (b->sg_ptr != 0)
2871 BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
2872 for (i = 0; i < b->sg_cnt; i++) {
2873 printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
2874 i, (ulong)b->sg_list[i].sg_addr,
2875 (ulong)b->sg_list[i].sg_count);
2876 }
2877}
2878
2879/*
2880 * asc_prt_hex()
2881 *
2882 * Print hexadecimal output in 4 byte groupings 32 bytes
2883 * or 8 double-words per line.
2884 */
2885static void asc_prt_hex(char *f, uchar *s, int l)
2886{
2887 int i;
2888 int j;
2889 int k;
2890 int m;
2891
2892 printk("%s: (%d bytes)\n", f, l);
2893
2894 for (i = 0; i < l; i += 32) {
2895
2896 /* Display a maximum of 8 double-words per line. */
2897 if ((k = (l - i) / 4) >= 8) {
2898 k = 8;
2899 m = 0;
2900 } else {
2901 m = (l - i) % 4;
2902 }
2903
2904 for (j = 0; j < k; j++) {
2905 printk(" %2.2X%2.2X%2.2X%2.2X",
2906 (unsigned)s[i + (j * 4)],
2907 (unsigned)s[i + (j * 4) + 1],
2908 (unsigned)s[i + (j * 4) + 2],
2909 (unsigned)s[i + (j * 4) + 3]);
2910 }
2911
2912 switch (m) {
2913 case 0:
2914 default:
2915 break;
2916 case 1:
2917 printk(" %2.2X", (unsigned)s[i + (j * 4)]);
2918 break;
2919 case 2:
2920 printk(" %2.2X%2.2X",
2921 (unsigned)s[i + (j * 4)],
2922 (unsigned)s[i + (j * 4) + 1]);
2923 break;
2924 case 3:
2925 printk(" %2.2X%2.2X%2.2X",
2926 (unsigned)s[i + (j * 4) + 1],
2927 (unsigned)s[i + (j * 4) + 2],
2928 (unsigned)s[i + (j * 4) + 3]);
2929 break;
2930 }
2931
2932 printk("\n");
2933 }
2934}
2935#endif /* ADVANSYS_DEBUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936
2937/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938 * advansys_info()
2939 *
2940 * Return suitable for printing on the console with the argument
2941 * adapter's configuration information.
2942 *
2943 * Note: The information line should not exceed ASC_INFO_SIZE bytes,
2944 * otherwise the static 'info' array will be overrun.
2945 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002946static const char *advansys_info(struct Scsi_Host *shost)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002948 static char info[ASC_INFO_SIZE];
2949 asc_board_t *boardp;
2950 ASC_DVC_VAR *asc_dvc_varp;
2951 ADV_DVC_VAR *adv_dvc_varp;
2952 char *busname;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002953 char *widename = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002954
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002955 boardp = ASC_BOARDP(shost);
2956 if (ASC_NARROW_BOARD(boardp)) {
2957 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
2958 ASC_DBG(1, "advansys_info: begin\n");
2959 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
2960 if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
2961 ASC_IS_ISAPNP) {
2962 busname = "ISA PnP";
2963 } else {
2964 busname = "ISA";
2965 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002966 sprintf(info,
2967 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
2968 ASC_VERSION, busname,
2969 (ulong)shost->io_port,
Matthew Wilcox4a2d31c2007-07-26 11:55:34 -04002970 (ulong)shost->io_port + ASC_IOADR_GAP - 1,
2971 shost->irq, shost->dma_channel);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002972 } else {
2973 if (asc_dvc_varp->bus_type & ASC_IS_VL) {
2974 busname = "VL";
2975 } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
2976 busname = "EISA";
2977 } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
2978 if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
2979 == ASC_IS_PCI_ULTRA) {
2980 busname = "PCI Ultra";
2981 } else {
2982 busname = "PCI";
2983 }
2984 } else {
2985 busname = "?";
Matthew Wilcoxecec1942007-07-30 08:08:22 -06002986 ASC_PRINT2("advansys_info: board %d: unknown "
2987 "bus type %d\n", boardp->id,
2988 asc_dvc_varp->bus_type);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002989 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002990 sprintf(info,
2991 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
Matthew Wilcoxecec1942007-07-30 08:08:22 -06002992 ASC_VERSION, busname, (ulong)shost->io_port,
Matthew Wilcox4a2d31c2007-07-26 11:55:34 -04002993 (ulong)shost->io_port + ASC_IOADR_GAP - 1,
2994 shost->irq);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002995 }
2996 } else {
2997 /*
2998 * Wide Adapter Information
2999 *
3000 * Memory-mapped I/O is used instead of I/O space to access
3001 * the adapter, but display the I/O Port range. The Memory
3002 * I/O address is displayed through the driver /proc file.
3003 */
3004 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
3005 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003006 widename = "Ultra-Wide";
3007 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003008 widename = "Ultra2-Wide";
3009 } else {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003010 widename = "Ultra3-Wide";
3011 }
3012 sprintf(info,
3013 "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
3014 ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
Matthew Wilcox4a2d31c2007-07-26 11:55:34 -04003015 (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, shost->irq);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003016 }
Matthew Wilcoxb009bef62007-09-09 08:56:38 -06003017 BUG_ON(strlen(info) >= ASC_INFO_SIZE);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003018 ASC_DBG(1, "advansys_info: end\n");
3019 return info;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020}
3021
Matthew Wilcox51219352007-10-02 21:55:22 -04003022#ifdef CONFIG_PROC_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023/*
Matthew Wilcox51219352007-10-02 21:55:22 -04003024 * asc_prt_line()
Linus Torvalds1da177e2005-04-16 15:20:36 -07003025 *
Matthew Wilcox51219352007-10-02 21:55:22 -04003026 * If 'cp' is NULL print to the console, otherwise print to a buffer.
3027 *
3028 * Return 0 if printing to the console, otherwise return the number of
3029 * bytes written to the buffer.
3030 *
3031 * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
3032 * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003033 */
Matthew Wilcox51219352007-10-02 21:55:22 -04003034static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003035{
Matthew Wilcox51219352007-10-02 21:55:22 -04003036 va_list args;
3037 int ret;
3038 char s[ASC_PRTLINE_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -07003039
Matthew Wilcox51219352007-10-02 21:55:22 -04003040 va_start(args, fmt);
3041 ret = vsprintf(s, fmt, args);
3042 BUG_ON(ret >= ASC_PRTLINE_SIZE);
3043 if (buf == NULL) {
3044 (void)printk(s);
3045 ret = 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003046 } else {
Matthew Wilcox51219352007-10-02 21:55:22 -04003047 ret = min(buflen, ret);
3048 memcpy(buf, s, ret);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003049 }
Matthew Wilcox51219352007-10-02 21:55:22 -04003050 va_end(args);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003051 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003052}
3053
3054/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003055 * asc_prt_board_devices()
3056 *
3057 * Print driver information for devices attached to the board.
3058 *
3059 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3060 * cf. asc_prt_line().
3061 *
3062 * Return the number of characters copied into 'cp'. No more than
3063 * 'cplen' characters will be copied to 'cp'.
3064 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003065static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003066{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003067 asc_board_t *boardp;
3068 int leftlen;
3069 int totlen;
3070 int len;
3071 int chip_scsi_id;
3072 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003073
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003074 boardp = ASC_BOARDP(shost);
3075 leftlen = cplen;
3076 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003078 len = asc_prt_line(cp, leftlen,
3079 "\nDevice Information for AdvanSys SCSI Host %d:\n",
3080 shost->host_no);
3081 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003082
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003083 if (ASC_NARROW_BOARD(boardp)) {
3084 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
3085 } else {
3086 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
3087 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003088
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003089 len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
3090 ASC_PRT_NEXT();
3091 for (i = 0; i <= ADV_MAX_TID; i++) {
3092 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
3093 len = asc_prt_line(cp, leftlen, " %X,", i);
3094 ASC_PRT_NEXT();
3095 }
3096 }
3097 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
3098 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003099
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003100 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003101}
3102
3103/*
3104 * Display Wide Board BIOS Information.
3105 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003106static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003108 asc_board_t *boardp;
3109 int leftlen;
3110 int totlen;
3111 int len;
3112 ushort major, minor, letter;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003113
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003114 boardp = ASC_BOARDP(shost);
3115 leftlen = cplen;
3116 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003117
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003118 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
3119 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003120
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003121 /*
3122 * If the BIOS saved a valid signature, then fill in
3123 * the BIOS code segment base address.
3124 */
3125 if (boardp->bios_signature != 0x55AA) {
3126 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
3127 ASC_PRT_NEXT();
3128 len = asc_prt_line(cp, leftlen,
3129 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
3130 ASC_PRT_NEXT();
3131 len = asc_prt_line(cp, leftlen,
3132 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
3133 ASC_PRT_NEXT();
3134 } else {
3135 major = (boardp->bios_version >> 12) & 0xF;
3136 minor = (boardp->bios_version >> 8) & 0xF;
3137 letter = (boardp->bios_version & 0xFF);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003138
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003139 len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
3140 major, minor,
3141 letter >= 26 ? '?' : letter + 'A');
3142 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003143
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003144 /*
3145 * Current available ROM BIOS release is 3.1I for UW
3146 * and 3.2I for U2W. This code doesn't differentiate
3147 * UW and U2W boards.
3148 */
3149 if (major < 3 || (major <= 3 && minor < 1) ||
3150 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
3151 len = asc_prt_line(cp, leftlen,
3152 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
3153 ASC_PRT_NEXT();
3154 len = asc_prt_line(cp, leftlen,
3155 "ftp://ftp.connectcom.net/pub\n");
3156 ASC_PRT_NEXT();
3157 }
3158 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003159
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003160 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003161}
3162
3163/*
3164 * Add serial number to information bar if signature AAh
3165 * is found in at bit 15-9 (7 bits) of word 1.
3166 *
3167 * Serial Number consists fo 12 alpha-numeric digits.
3168 *
3169 * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
3170 * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
3171 * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
3172 * 5 - Product revision (A-J) Word0: " "
3173 *
3174 * Signature Word1: 15-9 (7 bits)
3175 * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
3176 * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
3177 *
3178 * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
3179 *
3180 * Note 1: Only production cards will have a serial number.
3181 *
3182 * Note 2: Signature is most significant 7 bits (0xFE).
3183 *
3184 * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
3185 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003186static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003187{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003188 ushort w, num;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003189
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003190 if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
3191 return ASC_FALSE;
3192 } else {
3193 /*
3194 * First word - 6 digits.
3195 */
3196 w = serialnum[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -07003197
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003198 /* Product type - 1st digit. */
3199 if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
3200 /* Product type is P=Prototype */
3201 *cp += 0x8;
3202 }
3203 cp++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003204
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003205 /* Manufacturing location - 2nd digit. */
3206 *cp++ = 'A' + ((w & 0x1C00) >> 10);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003207
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003208 /* Product ID - 3rd, 4th digits. */
3209 num = w & 0x3FF;
3210 *cp++ = '0' + (num / 100);
3211 num %= 100;
3212 *cp++ = '0' + (num / 10);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003213
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003214 /* Product revision - 5th digit. */
3215 *cp++ = 'A' + (num % 10);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003216
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003217 /*
3218 * Second word
3219 */
3220 w = serialnum[1];
Linus Torvalds1da177e2005-04-16 15:20:36 -07003221
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003222 /*
3223 * Year - 6th digit.
3224 *
3225 * If bit 15 of third word is set, then the
3226 * last digit of the year is greater than 7.
3227 */
3228 if (serialnum[2] & 0x8000) {
3229 *cp++ = '8' + ((w & 0x1C0) >> 6);
3230 } else {
3231 *cp++ = '0' + ((w & 0x1C0) >> 6);
3232 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003233
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003234 /* Week of year - 7th, 8th digits. */
3235 num = w & 0x003F;
3236 *cp++ = '0' + num / 10;
3237 num %= 10;
3238 *cp++ = '0' + num;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003239
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003240 /*
3241 * Third word
3242 */
3243 w = serialnum[2] & 0x7FFF;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003244
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003245 /* Serial number - 9th digit. */
3246 *cp++ = 'A' + (w / 1000);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003247
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003248 /* 10th, 11th, 12th digits. */
3249 num = w % 1000;
3250 *cp++ = '0' + num / 100;
3251 num %= 100;
3252 *cp++ = '0' + num / 10;
3253 num %= 10;
3254 *cp++ = '0' + num;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003255
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003256 *cp = '\0'; /* Null Terminate the string. */
3257 return ASC_TRUE;
3258 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003259}
3260
3261/*
3262 * asc_prt_asc_board_eeprom()
3263 *
3264 * Print board EEPROM configuration.
3265 *
3266 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3267 * cf. asc_prt_line().
3268 *
3269 * Return the number of characters copied into 'cp'. No more than
3270 * 'cplen' characters will be copied to 'cp'.
3271 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003272static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003273{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003274 asc_board_t *boardp;
3275 ASC_DVC_VAR *asc_dvc_varp;
3276 int leftlen;
3277 int totlen;
3278 int len;
3279 ASCEEP_CONFIG *ep;
3280 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003281#ifdef CONFIG_ISA
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003282 int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
Linus Torvalds1da177e2005-04-16 15:20:36 -07003283#endif /* CONFIG_ISA */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003284 uchar serialstr[13];
Linus Torvalds1da177e2005-04-16 15:20:36 -07003285
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003286 boardp = ASC_BOARDP(shost);
3287 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
3288 ep = &boardp->eep_config.asc_eep;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003289
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003290 leftlen = cplen;
3291 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003292
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003293 len = asc_prt_line(cp, leftlen,
3294 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3295 shost->host_no);
3296 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003297
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003298 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
3299 == ASC_TRUE) {
3300 len =
3301 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
3302 serialstr);
3303 ASC_PRT_NEXT();
3304 } else {
3305 if (ep->adapter_info[5] == 0xBB) {
3306 len = asc_prt_line(cp, leftlen,
3307 " Default Settings Used for EEPROM-less Adapter.\n");
3308 ASC_PRT_NEXT();
3309 } else {
3310 len = asc_prt_line(cp, leftlen,
3311 " Serial Number Signature Not Present.\n");
3312 ASC_PRT_NEXT();
3313 }
3314 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003315
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003316 len = asc_prt_line(cp, leftlen,
3317 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3318 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
3319 ep->max_tag_qng);
3320 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003321
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003322 len = asc_prt_line(cp, leftlen,
3323 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
3324 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003326 len = asc_prt_line(cp, leftlen, " Target ID: ");
3327 ASC_PRT_NEXT();
3328 for (i = 0; i <= ASC_MAX_TID; i++) {
3329 len = asc_prt_line(cp, leftlen, " %d", i);
3330 ASC_PRT_NEXT();
3331 }
3332 len = asc_prt_line(cp, leftlen, "\n");
3333 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003335 len = asc_prt_line(cp, leftlen, " Disconnects: ");
3336 ASC_PRT_NEXT();
3337 for (i = 0; i <= ASC_MAX_TID; i++) {
3338 len = asc_prt_line(cp, leftlen, " %c",
3339 (ep->
3340 disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3341 'N');
3342 ASC_PRT_NEXT();
3343 }
3344 len = asc_prt_line(cp, leftlen, "\n");
3345 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003346
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003347 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
3348 ASC_PRT_NEXT();
3349 for (i = 0; i <= ASC_MAX_TID; i++) {
3350 len = asc_prt_line(cp, leftlen, " %c",
3351 (ep->
3352 use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3353 'N');
3354 ASC_PRT_NEXT();
3355 }
3356 len = asc_prt_line(cp, leftlen, "\n");
3357 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003358
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003359 len = asc_prt_line(cp, leftlen, " Start Motor: ");
3360 ASC_PRT_NEXT();
3361 for (i = 0; i <= ASC_MAX_TID; i++) {
3362 len = asc_prt_line(cp, leftlen, " %c",
3363 (ep->
3364 start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3365 'N');
3366 ASC_PRT_NEXT();
3367 }
3368 len = asc_prt_line(cp, leftlen, "\n");
3369 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003370
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003371 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3372 ASC_PRT_NEXT();
3373 for (i = 0; i <= ASC_MAX_TID; i++) {
3374 len = asc_prt_line(cp, leftlen, " %c",
3375 (ep->
3376 init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3377 'N');
3378 ASC_PRT_NEXT();
3379 }
3380 len = asc_prt_line(cp, leftlen, "\n");
3381 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003382
3383#ifdef CONFIG_ISA
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003384 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
3385 len = asc_prt_line(cp, leftlen,
3386 " Host ISA DMA speed: %d MB/S\n",
3387 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
3388 ASC_PRT_NEXT();
3389 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003390#endif /* CONFIG_ISA */
3391
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003392 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393}
3394
3395/*
3396 * asc_prt_adv_board_eeprom()
3397 *
3398 * Print board EEPROM configuration.
3399 *
3400 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3401 * cf. asc_prt_line().
3402 *
3403 * Return the number of characters copied into 'cp'. No more than
3404 * 'cplen' characters will be copied to 'cp'.
3405 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003406static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003407{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003408 asc_board_t *boardp;
3409 ADV_DVC_VAR *adv_dvc_varp;
3410 int leftlen;
3411 int totlen;
3412 int len;
3413 int i;
3414 char *termstr;
3415 uchar serialstr[13];
3416 ADVEEP_3550_CONFIG *ep_3550 = NULL;
3417 ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
3418 ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
3419 ushort word;
3420 ushort *wordp;
3421 ushort sdtr_speed = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003422
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003423 boardp = ASC_BOARDP(shost);
3424 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
3425 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3426 ep_3550 = &boardp->eep_config.adv_3550_eep;
3427 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3428 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
3429 } else {
3430 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
3431 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003433 leftlen = cplen;
3434 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003435
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003436 len = asc_prt_line(cp, leftlen,
3437 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3438 shost->host_no);
3439 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003440
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003441 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3442 wordp = &ep_3550->serial_number_word1;
3443 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3444 wordp = &ep_38C0800->serial_number_word1;
3445 } else {
3446 wordp = &ep_38C1600->serial_number_word1;
3447 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003448
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003449 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
3450 len =
3451 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
3452 serialstr);
3453 ASC_PRT_NEXT();
3454 } else {
3455 len = asc_prt_line(cp, leftlen,
3456 " Serial Number Signature Not Present.\n");
3457 ASC_PRT_NEXT();
3458 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003459
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003460 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3461 len = asc_prt_line(cp, leftlen,
3462 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3463 ep_3550->adapter_scsi_id,
3464 ep_3550->max_host_qng, ep_3550->max_dvc_qng);
3465 ASC_PRT_NEXT();
3466 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3467 len = asc_prt_line(cp, leftlen,
3468 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3469 ep_38C0800->adapter_scsi_id,
3470 ep_38C0800->max_host_qng,
3471 ep_38C0800->max_dvc_qng);
3472 ASC_PRT_NEXT();
3473 } else {
3474 len = asc_prt_line(cp, leftlen,
3475 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3476 ep_38C1600->adapter_scsi_id,
3477 ep_38C1600->max_host_qng,
3478 ep_38C1600->max_dvc_qng);
3479 ASC_PRT_NEXT();
3480 }
3481 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3482 word = ep_3550->termination;
3483 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3484 word = ep_38C0800->termination_lvd;
3485 } else {
3486 word = ep_38C1600->termination_lvd;
3487 }
3488 switch (word) {
3489 case 1:
3490 termstr = "Low Off/High Off";
3491 break;
3492 case 2:
3493 termstr = "Low Off/High On";
3494 break;
3495 case 3:
3496 termstr = "Low On/High On";
3497 break;
3498 default:
3499 case 0:
3500 termstr = "Automatic";
3501 break;
3502 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003504 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3505 len = asc_prt_line(cp, leftlen,
3506 " termination: %u (%s), bios_ctrl: 0x%x\n",
3507 ep_3550->termination, termstr,
3508 ep_3550->bios_ctrl);
3509 ASC_PRT_NEXT();
3510 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3511 len = asc_prt_line(cp, leftlen,
3512 " termination: %u (%s), bios_ctrl: 0x%x\n",
3513 ep_38C0800->termination_lvd, termstr,
3514 ep_38C0800->bios_ctrl);
3515 ASC_PRT_NEXT();
3516 } else {
3517 len = asc_prt_line(cp, leftlen,
3518 " termination: %u (%s), bios_ctrl: 0x%x\n",
3519 ep_38C1600->termination_lvd, termstr,
3520 ep_38C1600->bios_ctrl);
3521 ASC_PRT_NEXT();
3522 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003523
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003524 len = asc_prt_line(cp, leftlen, " Target ID: ");
3525 ASC_PRT_NEXT();
3526 for (i = 0; i <= ADV_MAX_TID; i++) {
3527 len = asc_prt_line(cp, leftlen, " %X", i);
3528 ASC_PRT_NEXT();
3529 }
3530 len = asc_prt_line(cp, leftlen, "\n");
3531 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003532
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003533 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3534 word = ep_3550->disc_enable;
3535 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3536 word = ep_38C0800->disc_enable;
3537 } else {
3538 word = ep_38C1600->disc_enable;
3539 }
3540 len = asc_prt_line(cp, leftlen, " Disconnects: ");
3541 ASC_PRT_NEXT();
3542 for (i = 0; i <= ADV_MAX_TID; i++) {
3543 len = asc_prt_line(cp, leftlen, " %c",
3544 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3545 ASC_PRT_NEXT();
3546 }
3547 len = asc_prt_line(cp, leftlen, "\n");
3548 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003549
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003550 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3551 word = ep_3550->tagqng_able;
3552 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3553 word = ep_38C0800->tagqng_able;
3554 } else {
3555 word = ep_38C1600->tagqng_able;
3556 }
3557 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
3558 ASC_PRT_NEXT();
3559 for (i = 0; i <= ADV_MAX_TID; i++) {
3560 len = asc_prt_line(cp, leftlen, " %c",
3561 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3562 ASC_PRT_NEXT();
3563 }
3564 len = asc_prt_line(cp, leftlen, "\n");
3565 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003566
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003567 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3568 word = ep_3550->start_motor;
3569 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3570 word = ep_38C0800->start_motor;
3571 } else {
3572 word = ep_38C1600->start_motor;
3573 }
3574 len = asc_prt_line(cp, leftlen, " Start Motor: ");
3575 ASC_PRT_NEXT();
3576 for (i = 0; i <= ADV_MAX_TID; i++) {
3577 len = asc_prt_line(cp, leftlen, " %c",
3578 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3579 ASC_PRT_NEXT();
3580 }
3581 len = asc_prt_line(cp, leftlen, "\n");
3582 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003583
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003584 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3585 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3586 ASC_PRT_NEXT();
3587 for (i = 0; i <= ADV_MAX_TID; i++) {
3588 len = asc_prt_line(cp, leftlen, " %c",
3589 (ep_3550->
3590 sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
3591 'Y' : 'N');
3592 ASC_PRT_NEXT();
3593 }
3594 len = asc_prt_line(cp, leftlen, "\n");
3595 ASC_PRT_NEXT();
3596 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003597
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003598 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3599 len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
3600 ASC_PRT_NEXT();
3601 for (i = 0; i <= ADV_MAX_TID; i++) {
3602 len = asc_prt_line(cp, leftlen, " %c",
3603 (ep_3550->
3604 ultra_able & ADV_TID_TO_TIDMASK(i))
3605 ? 'Y' : 'N');
3606 ASC_PRT_NEXT();
3607 }
3608 len = asc_prt_line(cp, leftlen, "\n");
3609 ASC_PRT_NEXT();
3610 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003611
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003612 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3613 word = ep_3550->wdtr_able;
3614 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3615 word = ep_38C0800->wdtr_able;
3616 } else {
3617 word = ep_38C1600->wdtr_able;
3618 }
3619 len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
3620 ASC_PRT_NEXT();
3621 for (i = 0; i <= ADV_MAX_TID; i++) {
3622 len = asc_prt_line(cp, leftlen, " %c",
3623 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3624 ASC_PRT_NEXT();
3625 }
3626 len = asc_prt_line(cp, leftlen, "\n");
3627 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003629 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
3630 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
3631 len = asc_prt_line(cp, leftlen,
3632 " Synchronous Transfer Speed (Mhz):\n ");
3633 ASC_PRT_NEXT();
3634 for (i = 0; i <= ADV_MAX_TID; i++) {
3635 char *speed_str;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003636
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003637 if (i == 0) {
3638 sdtr_speed = adv_dvc_varp->sdtr_speed1;
3639 } else if (i == 4) {
3640 sdtr_speed = adv_dvc_varp->sdtr_speed2;
3641 } else if (i == 8) {
3642 sdtr_speed = adv_dvc_varp->sdtr_speed3;
3643 } else if (i == 12) {
3644 sdtr_speed = adv_dvc_varp->sdtr_speed4;
3645 }
3646 switch (sdtr_speed & ADV_MAX_TID) {
3647 case 0:
3648 speed_str = "Off";
3649 break;
3650 case 1:
3651 speed_str = " 5";
3652 break;
3653 case 2:
3654 speed_str = " 10";
3655 break;
3656 case 3:
3657 speed_str = " 20";
3658 break;
3659 case 4:
3660 speed_str = " 40";
3661 break;
3662 case 5:
3663 speed_str = " 80";
3664 break;
3665 default:
3666 speed_str = "Unk";
3667 break;
3668 }
3669 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
3670 ASC_PRT_NEXT();
3671 if (i == 7) {
3672 len = asc_prt_line(cp, leftlen, "\n ");
3673 ASC_PRT_NEXT();
3674 }
3675 sdtr_speed >>= 4;
3676 }
3677 len = asc_prt_line(cp, leftlen, "\n");
3678 ASC_PRT_NEXT();
3679 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003680
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003681 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003682}
3683
3684/*
3685 * asc_prt_driver_conf()
3686 *
3687 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3688 * cf. asc_prt_line().
3689 *
3690 * Return the number of characters copied into 'cp'. No more than
3691 * 'cplen' characters will be copied to 'cp'.
3692 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003693static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003694{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003695 asc_board_t *boardp;
3696 int leftlen;
3697 int totlen;
3698 int len;
3699 int chip_scsi_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003700
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003701 boardp = ASC_BOARDP(shost);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003702
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003703 leftlen = cplen;
3704 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003706 len = asc_prt_line(cp, leftlen,
3707 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
3708 shost->host_no);
3709 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003710
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003711 len = asc_prt_line(cp, leftlen,
3712 " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
3713 shost->host_busy, shost->last_reset, shost->max_id,
3714 shost->max_lun, shost->max_channel);
3715 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003716
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003717 len = asc_prt_line(cp, leftlen,
3718 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
3719 shost->unique_id, shost->can_queue, shost->this_id,
3720 shost->sg_tablesize, shost->cmd_per_lun);
3721 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003722
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003723 len = asc_prt_line(cp, leftlen,
3724 " unchecked_isa_dma %d, use_clustering %d\n",
3725 shost->unchecked_isa_dma, shost->use_clustering);
3726 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003727
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003728 len = asc_prt_line(cp, leftlen,
3729 " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
3730 boardp->flags, boardp->last_reset, jiffies,
3731 boardp->asc_n_io_port);
3732 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003733
Matthew Wilcox4a2d31c2007-07-26 11:55:34 -04003734 len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003735 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003736
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003737 if (ASC_NARROW_BOARD(boardp)) {
3738 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
3739 } else {
3740 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
3741 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003742
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003743 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003744}
3745
3746/*
3747 * asc_prt_asc_board_info()
3748 *
3749 * Print dynamic board configuration information.
3750 *
3751 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3752 * cf. asc_prt_line().
3753 *
3754 * Return the number of characters copied into 'cp'. No more than
3755 * 'cplen' characters will be copied to 'cp'.
3756 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003757static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003758{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003759 asc_board_t *boardp;
3760 int chip_scsi_id;
3761 int leftlen;
3762 int totlen;
3763 int len;
3764 ASC_DVC_VAR *v;
3765 ASC_DVC_CFG *c;
3766 int i;
3767 int renegotiate = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003768
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003769 boardp = ASC_BOARDP(shost);
3770 v = &boardp->dvc_var.asc_dvc_var;
3771 c = &boardp->dvc_cfg.asc_dvc_cfg;
3772 chip_scsi_id = c->chip_scsi_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003773
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003774 leftlen = cplen;
3775 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003776
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003777 len = asc_prt_line(cp, leftlen,
3778 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3779 shost->host_no);
3780 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003781
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003782 len = asc_prt_line(cp, leftlen,
3783 " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
3784 c->chip_version, c->lib_version, c->lib_serial_no,
3785 c->mcode_date);
3786 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003787
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003788 len = asc_prt_line(cp, leftlen,
3789 " mcode_version 0x%x, err_code %u\n",
3790 c->mcode_version, v->err_code);
3791 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003792
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003793 /* Current number of commands waiting for the host. */
3794 len = asc_prt_line(cp, leftlen,
3795 " Total Command Pending: %d\n", v->cur_total_qng);
3796 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003797
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003798 len = asc_prt_line(cp, leftlen, " Command Queuing:");
3799 ASC_PRT_NEXT();
3800 for (i = 0; i <= ASC_MAX_TID; i++) {
3801 if ((chip_scsi_id == i) ||
3802 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3803 continue;
3804 }
3805 len = asc_prt_line(cp, leftlen, " %X:%c",
3806 i,
3807 (v->
3808 use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
3809 'Y' : 'N');
3810 ASC_PRT_NEXT();
3811 }
3812 len = asc_prt_line(cp, leftlen, "\n");
3813 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003814
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003815 /* Current number of commands waiting for a device. */
3816 len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
3817 ASC_PRT_NEXT();
3818 for (i = 0; i <= ASC_MAX_TID; i++) {
3819 if ((chip_scsi_id == i) ||
3820 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3821 continue;
3822 }
3823 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
3824 ASC_PRT_NEXT();
3825 }
3826 len = asc_prt_line(cp, leftlen, "\n");
3827 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003828
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003829 /* Current limit on number of commands that can be sent to a device. */
3830 len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
3831 ASC_PRT_NEXT();
3832 for (i = 0; i <= ASC_MAX_TID; i++) {
3833 if ((chip_scsi_id == i) ||
3834 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3835 continue;
3836 }
3837 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
3838 ASC_PRT_NEXT();
3839 }
3840 len = asc_prt_line(cp, leftlen, "\n");
3841 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003842
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003843 /* Indicate whether the device has returned queue full status. */
3844 len = asc_prt_line(cp, leftlen, " Command Queue Full:");
3845 ASC_PRT_NEXT();
3846 for (i = 0; i <= ASC_MAX_TID; i++) {
3847 if ((chip_scsi_id == i) ||
3848 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3849 continue;
3850 }
3851 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
3852 len = asc_prt_line(cp, leftlen, " %X:Y-%d",
3853 i, boardp->queue_full_cnt[i]);
3854 } else {
3855 len = asc_prt_line(cp, leftlen, " %X:N", i);
3856 }
3857 ASC_PRT_NEXT();
3858 }
3859 len = asc_prt_line(cp, leftlen, "\n");
3860 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003861
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003862 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3863 ASC_PRT_NEXT();
3864 for (i = 0; i <= ASC_MAX_TID; i++) {
3865 if ((chip_scsi_id == i) ||
3866 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3867 continue;
3868 }
3869 len = asc_prt_line(cp, leftlen, " %X:%c",
3870 i,
3871 (v->
3872 sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3873 'N');
3874 ASC_PRT_NEXT();
3875 }
3876 len = asc_prt_line(cp, leftlen, "\n");
3877 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003878
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003879 for (i = 0; i <= ASC_MAX_TID; i++) {
3880 uchar syn_period_ix;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003881
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003882 if ((chip_scsi_id == i) ||
3883 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
3884 ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
3885 continue;
3886 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003887
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003888 len = asc_prt_line(cp, leftlen, " %X:", i);
3889 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003890
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003891 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
3892 len = asc_prt_line(cp, leftlen, " Asynchronous");
3893 ASC_PRT_NEXT();
3894 } else {
3895 syn_period_ix =
3896 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
3897 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003898
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003899 len = asc_prt_line(cp, leftlen,
3900 " Transfer Period Factor: %d (%d.%d Mhz),",
3901 v->sdtr_period_tbl[syn_period_ix],
3902 250 /
3903 v->sdtr_period_tbl[syn_period_ix],
3904 ASC_TENTHS(250,
3905 v->
3906 sdtr_period_tbl
3907 [syn_period_ix]));
3908 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003909
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003910 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
3911 boardp->
3912 sdtr_data[i] & ASC_SYN_MAX_OFFSET);
3913 ASC_PRT_NEXT();
3914 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003915
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003916 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3917 len = asc_prt_line(cp, leftlen, "*\n");
3918 renegotiate = 1;
3919 } else {
3920 len = asc_prt_line(cp, leftlen, "\n");
3921 }
3922 ASC_PRT_NEXT();
3923 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003924
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003925 if (renegotiate) {
3926 len = asc_prt_line(cp, leftlen,
3927 " * = Re-negotiation pending before next command.\n");
3928 ASC_PRT_NEXT();
3929 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003930
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003931 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003932}
3933
3934/*
3935 * asc_prt_adv_board_info()
3936 *
3937 * Print dynamic board configuration information.
3938 *
3939 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3940 * cf. asc_prt_line().
3941 *
3942 * Return the number of characters copied into 'cp'. No more than
3943 * 'cplen' characters will be copied to 'cp'.
3944 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003945static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003946{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003947 asc_board_t *boardp;
3948 int leftlen;
3949 int totlen;
3950 int len;
3951 int i;
3952 ADV_DVC_VAR *v;
3953 ADV_DVC_CFG *c;
3954 AdvPortAddr iop_base;
3955 ushort chip_scsi_id;
3956 ushort lramword;
3957 uchar lrambyte;
3958 ushort tagqng_able;
3959 ushort sdtr_able, wdtr_able;
3960 ushort wdtr_done, sdtr_done;
3961 ushort period = 0;
3962 int renegotiate = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003963
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003964 boardp = ASC_BOARDP(shost);
3965 v = &boardp->dvc_var.adv_dvc_var;
3966 c = &boardp->dvc_cfg.adv_dvc_cfg;
3967 iop_base = v->iop_base;
3968 chip_scsi_id = v->chip_scsi_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003969
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003970 leftlen = cplen;
3971 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003973 len = asc_prt_line(cp, leftlen,
3974 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3975 shost->host_no);
3976 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003977
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003978 len = asc_prt_line(cp, leftlen,
3979 " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
3980 v->iop_base,
3981 AdvReadWordRegister(iop_base,
3982 IOPW_SCSI_CFG1) & CABLE_DETECT,
3983 v->err_code);
3984 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003985
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003986 len = asc_prt_line(cp, leftlen,
3987 " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
3988 c->chip_version, c->lib_version, c->mcode_date,
3989 c->mcode_version);
3990 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003991
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003992 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
3993 len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
3994 ASC_PRT_NEXT();
3995 for (i = 0; i <= ADV_MAX_TID; i++) {
3996 if ((chip_scsi_id == i) ||
3997 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3998 continue;
3999 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004000
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004001 len = asc_prt_line(cp, leftlen, " %X:%c",
4002 i,
4003 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
4004 'N');
4005 ASC_PRT_NEXT();
4006 }
4007 len = asc_prt_line(cp, leftlen, "\n");
4008 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004009
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004010 len = asc_prt_line(cp, leftlen, " Queue Limit:");
4011 ASC_PRT_NEXT();
4012 for (i = 0; i <= ADV_MAX_TID; i++) {
4013 if ((chip_scsi_id == i) ||
4014 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
4015 continue;
4016 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004017
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004018 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
4019 lrambyte);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004020
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004021 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
4022 ASC_PRT_NEXT();
4023 }
4024 len = asc_prt_line(cp, leftlen, "\n");
4025 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004026
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004027 len = asc_prt_line(cp, leftlen, " Command Pending:");
4028 ASC_PRT_NEXT();
4029 for (i = 0; i <= ADV_MAX_TID; i++) {
4030 if ((chip_scsi_id == i) ||
4031 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
4032 continue;
4033 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004034
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004035 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
4036 lrambyte);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004037
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004038 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
4039 ASC_PRT_NEXT();
4040 }
4041 len = asc_prt_line(cp, leftlen, "\n");
4042 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004043
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004044 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
4045 len = asc_prt_line(cp, leftlen, " Wide Enabled:");
4046 ASC_PRT_NEXT();
4047 for (i = 0; i <= ADV_MAX_TID; i++) {
4048 if ((chip_scsi_id == i) ||
4049 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
4050 continue;
4051 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004052
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004053 len = asc_prt_line(cp, leftlen, " %X:%c",
4054 i,
4055 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
4056 'N');
4057 ASC_PRT_NEXT();
4058 }
4059 len = asc_prt_line(cp, leftlen, "\n");
4060 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004061
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004062 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
4063 len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
4064 ASC_PRT_NEXT();
4065 for (i = 0; i <= ADV_MAX_TID; i++) {
4066 if ((chip_scsi_id == i) ||
4067 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
4068 continue;
4069 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004070
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004071 AdvReadWordLram(iop_base,
4072 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
4073 lramword);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004074
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004075 len = asc_prt_line(cp, leftlen, " %X:%d",
4076 i, (lramword & 0x8000) ? 16 : 8);
4077 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004078
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004079 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
4080 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
4081 len = asc_prt_line(cp, leftlen, "*");
4082 ASC_PRT_NEXT();
4083 renegotiate = 1;
4084 }
4085 }
4086 len = asc_prt_line(cp, leftlen, "\n");
4087 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004088
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004089 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
4090 len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
4091 ASC_PRT_NEXT();
4092 for (i = 0; i <= ADV_MAX_TID; i++) {
4093 if ((chip_scsi_id == i) ||
4094 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
4095 continue;
4096 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004097
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004098 len = asc_prt_line(cp, leftlen, " %X:%c",
4099 i,
4100 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
4101 'N');
4102 ASC_PRT_NEXT();
4103 }
4104 len = asc_prt_line(cp, leftlen, "\n");
4105 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004106
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004107 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
4108 for (i = 0; i <= ADV_MAX_TID; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004109
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004110 AdvReadWordLram(iop_base,
4111 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
4112 lramword);
4113 lramword &= ~0x8000;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004114
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004115 if ((chip_scsi_id == i) ||
4116 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
4117 ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
4118 continue;
4119 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004120
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004121 len = asc_prt_line(cp, leftlen, " %X:", i);
4122 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004123
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004124 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
4125 len = asc_prt_line(cp, leftlen, " Asynchronous");
4126 ASC_PRT_NEXT();
4127 } else {
4128 len =
4129 asc_prt_line(cp, leftlen,
4130 " Transfer Period Factor: ");
4131 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004132
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004133 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
4134 len =
4135 asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
4136 ASC_PRT_NEXT();
4137 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
4138 len =
4139 asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
4140 ASC_PRT_NEXT();
4141 } else { /* 20 Mhz or below. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004142
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004143 period = (((lramword >> 8) * 25) + 50) / 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004144
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004145 if (period == 0) { /* Should never happen. */
4146 len =
4147 asc_prt_line(cp, leftlen,
4148 "%d (? Mhz), ");
4149 ASC_PRT_NEXT();
4150 } else {
4151 len = asc_prt_line(cp, leftlen,
4152 "%d (%d.%d Mhz),",
4153 period, 250 / period,
4154 ASC_TENTHS(250,
4155 period));
4156 ASC_PRT_NEXT();
4157 }
4158 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004159
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004160 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
4161 lramword & 0x1F);
4162 ASC_PRT_NEXT();
4163 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004164
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004165 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
4166 len = asc_prt_line(cp, leftlen, "*\n");
4167 renegotiate = 1;
4168 } else {
4169 len = asc_prt_line(cp, leftlen, "\n");
4170 }
4171 ASC_PRT_NEXT();
4172 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004173
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004174 if (renegotiate) {
4175 len = asc_prt_line(cp, leftlen,
4176 " * = Re-negotiation pending before next command.\n");
4177 ASC_PRT_NEXT();
4178 }
4179
4180 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004181}
4182
4183/*
4184 * asc_proc_copy()
4185 *
4186 * Copy proc information to a read buffer taking into account the current
4187 * read offset in the file and the remaining space in the read buffer.
4188 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004189static int
Linus Torvalds1da177e2005-04-16 15:20:36 -07004190asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004191 char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004192{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004193 int cnt = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004194
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004195 ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
4196 (unsigned)offset, (unsigned)advoffset, cplen);
4197 if (offset <= advoffset) {
4198 /* Read offset below current offset, copy everything. */
4199 cnt = min(cplen, leftlen);
4200 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
4201 (ulong)curbuf, (ulong)cp, cnt);
4202 memcpy(curbuf, cp, cnt);
4203 } else if (offset < advoffset + cplen) {
4204 /* Read offset within current range, partial copy. */
4205 cnt = (advoffset + cplen) - offset;
4206 cp = (cp + cplen) - cnt;
4207 cnt = min(cnt, leftlen);
4208 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
4209 (ulong)curbuf, (ulong)cp, cnt);
4210 memcpy(curbuf, cp, cnt);
4211 }
4212 return cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004213}
4214
Linus Torvalds1da177e2005-04-16 15:20:36 -07004215#ifdef ADVANSYS_STATS
Linus Torvalds1da177e2005-04-16 15:20:36 -07004216/*
4217 * asc_prt_board_stats()
4218 *
4219 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
4220 * cf. asc_prt_line().
4221 *
4222 * Return the number of characters copied into 'cp'. No more than
4223 * 'cplen' characters will be copied to 'cp'.
4224 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004225static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004226{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004227 int leftlen;
4228 int totlen;
4229 int len;
4230 struct asc_stats *s;
4231 asc_board_t *boardp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004232
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004233 leftlen = cplen;
4234 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004235
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004236 boardp = ASC_BOARDP(shost);
4237 s = &boardp->asc_stats;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004238
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004239 len = asc_prt_line(cp, leftlen,
4240 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
4241 shost->host_no);
4242 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004243
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004244 len = asc_prt_line(cp, leftlen,
4245 " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
4246 s->queuecommand, s->reset, s->biosparam,
4247 s->interrupt);
4248 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004249
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004250 len = asc_prt_line(cp, leftlen,
4251 " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
4252 s->callback, s->done, s->build_error,
4253 s->adv_build_noreq, s->adv_build_nosg);
4254 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004255
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004256 len = asc_prt_line(cp, leftlen,
4257 " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
4258 s->exe_noerror, s->exe_busy, s->exe_error,
4259 s->exe_unknown);
4260 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004261
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004262 /*
4263 * Display data transfer statistics.
4264 */
4265 if (s->cont_cnt > 0) {
4266 len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
4267 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004268
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004269 len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
4270 s->cont_xfer / 2,
4271 ASC_TENTHS(s->cont_xfer, 2));
4272 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004273
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004274 /* Contiguous transfer average size */
4275 len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
4276 (s->cont_xfer / 2) / s->cont_cnt,
4277 ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
4278 ASC_PRT_NEXT();
4279 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004280
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004281 if (s->sg_cnt > 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004282
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004283 len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
4284 s->sg_cnt, s->sg_elem);
4285 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004286
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004287 len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
4288 s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
4289 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004290
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004291 /* Scatter gather transfer statistics */
4292 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
4293 s->sg_elem / s->sg_cnt,
4294 ASC_TENTHS(s->sg_elem, s->sg_cnt));
4295 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004296
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004297 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
4298 (s->sg_xfer / 2) / s->sg_elem,
4299 ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
4300 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004301
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004302 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
4303 (s->sg_xfer / 2) / s->sg_cnt,
4304 ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
4305 ASC_PRT_NEXT();
4306 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004307
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004308 /*
4309 * Display request queuing statistics.
4310 */
4311 len = asc_prt_line(cp, leftlen,
4312 " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
4313 HZ);
4314 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004315
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004316 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004317}
Linus Torvalds1da177e2005-04-16 15:20:36 -07004318#endif /* ADVANSYS_STATS */
4319
Linus Torvalds1da177e2005-04-16 15:20:36 -07004320/*
Matthew Wilcox51219352007-10-02 21:55:22 -04004321 * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
4322 *
4323 * *buffer: I/O buffer
4324 * **start: if inout == FALSE pointer into buffer where user read should start
4325 * offset: current offset into a /proc/scsi/advansys/[0...] file
4326 * length: length of buffer
4327 * hostno: Scsi_Host host_no
4328 * inout: TRUE - user is writing; FALSE - user is reading
4329 *
4330 * Return the number of bytes read from or written to a
4331 * /proc/scsi/advansys/[0...] file.
4332 *
4333 * Note: This function uses the per board buffer 'prtbuf' which is
4334 * allocated when the board is initialized in advansys_detect(). The
4335 * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
4336 * used to write to the buffer. The way asc_proc_copy() is written
4337 * if 'prtbuf' is too small it will not be overwritten. Instead the
4338 * user just won't get all the available statistics.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004339 */
Matthew Wilcox51219352007-10-02 21:55:22 -04004340static int
4341advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
4342 off_t offset, int length, int inout)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004343{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004344 asc_board_t *boardp;
Matthew Wilcox51219352007-10-02 21:55:22 -04004345 char *cp;
4346 int cplen;
4347 int cnt;
4348 int totcnt;
4349 int leftlen;
4350 char *curbuf;
4351 off_t advoffset;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004352
Matthew Wilcox51219352007-10-02 21:55:22 -04004353 ASC_DBG(1, "advansys_proc_info: begin\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07004354
Matthew Wilcox51219352007-10-02 21:55:22 -04004355 /*
4356 * User write not supported.
4357 */
4358 if (inout == TRUE) {
4359 return (-ENOSYS);
4360 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004361
Matthew Wilcox51219352007-10-02 21:55:22 -04004362 /*
4363 * User read of /proc/scsi/advansys/[0...] file.
4364 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004365
Matthew Wilcox51219352007-10-02 21:55:22 -04004366 boardp = ASC_BOARDP(shost);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004367
Matthew Wilcox51219352007-10-02 21:55:22 -04004368 /* Copy read data starting at the beginning of the buffer. */
4369 *start = buffer;
4370 curbuf = buffer;
4371 advoffset = 0;
4372 totcnt = 0;
4373 leftlen = length;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004374
Matthew Wilcox51219352007-10-02 21:55:22 -04004375 /*
4376 * Get board configuration information.
4377 *
4378 * advansys_info() returns the board string from its own static buffer.
4379 */
4380 cp = (char *)advansys_info(shost);
4381 strcat(cp, "\n");
4382 cplen = strlen(cp);
4383 /* Copy board information. */
4384 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4385 totcnt += cnt;
4386 leftlen -= cnt;
4387 if (leftlen == 0) {
4388 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4389 return totcnt;
4390 }
4391 advoffset += cplen;
4392 curbuf += cnt;
4393
4394 /*
4395 * Display Wide Board BIOS Information.
4396 */
4397 if (ASC_WIDE_BOARD(boardp)) {
4398 cp = boardp->prtbuf;
4399 cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
4400 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4401 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4402 cplen);
4403 totcnt += cnt;
4404 leftlen -= cnt;
4405 if (leftlen == 0) {
4406 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4407 return totcnt;
4408 }
4409 advoffset += cplen;
4410 curbuf += cnt;
4411 }
4412
4413 /*
4414 * Display driver information for each device attached to the board.
4415 */
4416 cp = boardp->prtbuf;
4417 cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
4418 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4419 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4420 totcnt += cnt;
4421 leftlen -= cnt;
4422 if (leftlen == 0) {
4423 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4424 return totcnt;
4425 }
4426 advoffset += cplen;
4427 curbuf += cnt;
4428
4429 /*
4430 * Display EEPROM configuration for the board.
4431 */
4432 cp = boardp->prtbuf;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004433 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox51219352007-10-02 21:55:22 -04004434 cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004435 } else {
Matthew Wilcox51219352007-10-02 21:55:22 -04004436 cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004437 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004438 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4439 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4440 totcnt += cnt;
4441 leftlen -= cnt;
4442 if (leftlen == 0) {
4443 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4444 return totcnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004445 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004446 advoffset += cplen;
4447 curbuf += cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004448
Matthew Wilcox51219352007-10-02 21:55:22 -04004449 /*
4450 * Display driver configuration and information for the board.
4451 */
4452 cp = boardp->prtbuf;
4453 cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
4454 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4455 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4456 totcnt += cnt;
4457 leftlen -= cnt;
4458 if (leftlen == 0) {
4459 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4460 return totcnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004461 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004462 advoffset += cplen;
4463 curbuf += cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004464
Matthew Wilcox51219352007-10-02 21:55:22 -04004465#ifdef ADVANSYS_STATS
4466 /*
4467 * Display driver statistics for the board.
4468 */
4469 cp = boardp->prtbuf;
4470 cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
4471 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4472 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4473 totcnt += cnt;
4474 leftlen -= cnt;
4475 if (leftlen == 0) {
4476 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4477 return totcnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004478 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004479 advoffset += cplen;
4480 curbuf += cnt;
4481#endif /* ADVANSYS_STATS */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004482
Matthew Wilcox51219352007-10-02 21:55:22 -04004483 /*
4484 * Display Asc Library dynamic configuration information
4485 * for the board.
4486 */
4487 cp = boardp->prtbuf;
4488 if (ASC_NARROW_BOARD(boardp)) {
4489 cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
4490 } else {
4491 cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004492 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004493 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4494 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4495 totcnt += cnt;
4496 leftlen -= cnt;
4497 if (leftlen == 0) {
4498 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4499 return totcnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004500 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004501 advoffset += cplen;
4502 curbuf += cnt;
4503
4504 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4505
4506 return totcnt;
4507}
4508#endif /* CONFIG_PROC_FS */
4509
4510static void asc_scsi_done(struct scsi_cmnd *scp)
4511{
4512 struct asc_board *boardp = ASC_BOARDP(scp->device->host);
4513
4514 if (scp->use_sg)
4515 dma_unmap_sg(boardp->dev,
4516 (struct scatterlist *)scp->request_buffer,
4517 scp->use_sg, scp->sc_data_direction);
4518 else if (scp->request_bufflen)
4519 dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
4520 scp->request_bufflen, scp->sc_data_direction);
4521
4522 ASC_STATS(scp->device->host, done);
4523
4524 scp->scsi_done(scp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004525}
4526
Matthew Wilcox51219352007-10-02 21:55:22 -04004527static void AscSetBank(PortAddr iop_base, uchar bank)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004528{
Matthew Wilcox51219352007-10-02 21:55:22 -04004529 uchar val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004530
Matthew Wilcox51219352007-10-02 21:55:22 -04004531 val = AscGetChipControl(iop_base) &
4532 (~
4533 (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
4534 CC_CHIP_RESET));
4535 if (bank == 1) {
4536 val |= CC_BANK_ONE;
4537 } else if (bank == 2) {
4538 val |= CC_DIAG | CC_BANK_ONE;
4539 } else {
4540 val &= ~CC_BANK_ONE;
4541 }
4542 AscSetChipControl(iop_base, val);
4543 return;
4544}
4545
4546static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
4547{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004548 AscSetBank(iop_base, 1);
Matthew Wilcox51219352007-10-02 21:55:22 -04004549 AscWriteChipIH(iop_base, ins_code);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004550 AscSetBank(iop_base, 0);
Matthew Wilcox51219352007-10-02 21:55:22 -04004551 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004552}
4553
Matthew Wilcox51219352007-10-02 21:55:22 -04004554static int AscStartChip(PortAddr iop_base)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004555{
Matthew Wilcox51219352007-10-02 21:55:22 -04004556 AscSetChipControl(iop_base, 0);
4557 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
4558 return (0);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004559 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004560 return (1);
4561}
4562
4563static int AscStopChip(PortAddr iop_base)
4564{
4565 uchar cc_val;
4566
4567 cc_val =
4568 AscGetChipControl(iop_base) &
4569 (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
4570 AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
4571 AscSetChipIH(iop_base, INS_HALT);
4572 AscSetChipIH(iop_base, INS_RFLAG_WTM);
4573 if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
4574 return (0);
4575 }
4576 return (1);
4577}
4578
4579static int AscIsChipHalted(PortAddr iop_base)
4580{
4581 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
4582 if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
4583 return (1);
4584 }
4585 }
4586 return (0);
4587}
4588
4589static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
4590{
4591 PortAddr iop_base;
4592 int i = 10;
4593
4594 iop_base = asc_dvc->iop_base;
4595 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
4596 && (i-- > 0)) {
4597 mdelay(100);
4598 }
4599 AscStopChip(iop_base);
4600 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
4601 udelay(60);
4602 AscSetChipIH(iop_base, INS_RFLAG_WTM);
4603 AscSetChipIH(iop_base, INS_HALT);
4604 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
4605 AscSetChipControl(iop_base, CC_HALT);
4606 mdelay(200);
4607 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
4608 AscSetChipStatus(iop_base, 0);
4609 return (AscIsChipHalted(iop_base));
4610}
4611
4612static int AscFindSignature(PortAddr iop_base)
4613{
4614 ushort sig_word;
4615
4616 ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
4617 iop_base, AscGetChipSignatureByte(iop_base));
4618 if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
4619 ASC_DBG2(1,
4620 "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
4621 iop_base, AscGetChipSignatureWord(iop_base));
4622 sig_word = AscGetChipSignatureWord(iop_base);
4623 if ((sig_word == (ushort)ASC_1000_ID0W) ||
4624 (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
4625 return (1);
4626 }
4627 }
4628 return (0);
4629}
4630
4631static void AscEnableInterrupt(PortAddr iop_base)
4632{
4633 ushort cfg;
4634
4635 cfg = AscGetChipCfgLsw(iop_base);
4636 AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
4637 return;
4638}
4639
4640static void AscDisableInterrupt(PortAddr iop_base)
4641{
4642 ushort cfg;
4643
4644 cfg = AscGetChipCfgLsw(iop_base);
4645 AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
4646 return;
4647}
4648
4649static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
4650{
4651 unsigned char byte_data;
4652 unsigned short word_data;
4653
4654 if (isodd_word(addr)) {
4655 AscSetChipLramAddr(iop_base, addr - 1);
4656 word_data = AscGetChipLramData(iop_base);
4657 byte_data = (word_data >> 8) & 0xFF;
4658 } else {
4659 AscSetChipLramAddr(iop_base, addr);
4660 word_data = AscGetChipLramData(iop_base);
4661 byte_data = word_data & 0xFF;
4662 }
4663 return byte_data;
4664}
4665
4666static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
4667{
4668 ushort word_data;
4669
4670 AscSetChipLramAddr(iop_base, addr);
4671 word_data = AscGetChipLramData(iop_base);
4672 return (word_data);
4673}
4674
4675#if CC_VERY_LONG_SG_LIST
4676static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
4677{
4678 ushort val_low, val_high;
4679 ASC_DCNT dword_data;
4680
4681 AscSetChipLramAddr(iop_base, addr);
4682 val_low = AscGetChipLramData(iop_base);
4683 val_high = AscGetChipLramData(iop_base);
4684 dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
4685 return (dword_data);
4686}
4687#endif /* CC_VERY_LONG_SG_LIST */
4688
4689static void
4690AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
4691{
4692 int i;
4693
4694 AscSetChipLramAddr(iop_base, s_addr);
4695 for (i = 0; i < words; i++) {
4696 AscSetChipLramData(iop_base, set_wval);
4697 }
4698}
4699
4700static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
4701{
4702 AscSetChipLramAddr(iop_base, addr);
4703 AscSetChipLramData(iop_base, word_val);
4704 return;
4705}
4706
4707static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
4708{
4709 ushort word_data;
4710
4711 if (isodd_word(addr)) {
4712 addr--;
4713 word_data = AscReadLramWord(iop_base, addr);
4714 word_data &= 0x00FF;
4715 word_data |= (((ushort)byte_val << 8) & 0xFF00);
4716 } else {
4717 word_data = AscReadLramWord(iop_base, addr);
4718 word_data &= 0xFF00;
4719 word_data |= ((ushort)byte_val & 0x00FF);
4720 }
4721 AscWriteLramWord(iop_base, addr, word_data);
4722 return;
4723}
4724
4725/*
4726 * Copy 2 bytes to LRAM.
4727 *
4728 * The source data is assumed to be in little-endian order in memory
4729 * and is maintained in little-endian order when written to LRAM.
4730 */
4731static void
4732AscMemWordCopyPtrToLram(PortAddr iop_base,
4733 ushort s_addr, uchar *s_buffer, int words)
4734{
4735 int i;
4736
4737 AscSetChipLramAddr(iop_base, s_addr);
4738 for (i = 0; i < 2 * words; i += 2) {
4739 /*
4740 * On a little-endian system the second argument below
4741 * produces a little-endian ushort which is written to
4742 * LRAM in little-endian order. On a big-endian system
4743 * the second argument produces a big-endian ushort which
4744 * is "transparently" byte-swapped by outpw() and written
4745 * in little-endian order to LRAM.
4746 */
4747 outpw(iop_base + IOP_RAM_DATA,
4748 ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
4749 }
4750 return;
4751}
4752
4753/*
4754 * Copy 4 bytes to LRAM.
4755 *
4756 * The source data is assumed to be in little-endian order in memory
4757 * and is maintained in little-endian order when writen to LRAM.
4758 */
4759static void
4760AscMemDWordCopyPtrToLram(PortAddr iop_base,
4761 ushort s_addr, uchar *s_buffer, int dwords)
4762{
4763 int i;
4764
4765 AscSetChipLramAddr(iop_base, s_addr);
4766 for (i = 0; i < 4 * dwords; i += 4) {
4767 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
4768 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
4769 }
4770 return;
4771}
4772
4773/*
4774 * Copy 2 bytes from LRAM.
4775 *
4776 * The source data is assumed to be in little-endian order in LRAM
4777 * and is maintained in little-endian order when written to memory.
4778 */
4779static void
4780AscMemWordCopyPtrFromLram(PortAddr iop_base,
4781 ushort s_addr, uchar *d_buffer, int words)
4782{
4783 int i;
4784 ushort word;
4785
4786 AscSetChipLramAddr(iop_base, s_addr);
4787 for (i = 0; i < 2 * words; i += 2) {
4788 word = inpw(iop_base + IOP_RAM_DATA);
4789 d_buffer[i] = word & 0xff;
4790 d_buffer[i + 1] = (word >> 8) & 0xff;
4791 }
4792 return;
4793}
4794
4795static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
4796{
4797 ASC_DCNT sum;
4798 int i;
4799
4800 sum = 0L;
4801 for (i = 0; i < words; i++, s_addr += 2) {
4802 sum += AscReadLramWord(iop_base, s_addr);
4803 }
4804 return (sum);
4805}
4806
4807static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
4808{
4809 uchar i;
4810 ushort s_addr;
4811 PortAddr iop_base;
4812 ushort warn_code;
4813
4814 iop_base = asc_dvc->iop_base;
4815 warn_code = 0;
4816 AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
4817 (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
4818 64) >> 1));
4819 i = ASC_MIN_ACTIVE_QNO;
4820 s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
4821 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4822 (uchar)(i + 1));
4823 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4824 (uchar)(asc_dvc->max_total_qng));
4825 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4826 (uchar)i);
4827 i++;
4828 s_addr += ASC_QBLK_SIZE;
4829 for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
4830 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4831 (uchar)(i + 1));
4832 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4833 (uchar)(i - 1));
4834 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4835 (uchar)i);
4836 }
4837 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4838 (uchar)ASC_QLINK_END);
4839 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4840 (uchar)(asc_dvc->max_total_qng - 1));
4841 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4842 (uchar)asc_dvc->max_total_qng);
4843 i++;
4844 s_addr += ASC_QBLK_SIZE;
4845 for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
4846 i++, s_addr += ASC_QBLK_SIZE) {
4847 AscWriteLramByte(iop_base,
4848 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
4849 AscWriteLramByte(iop_base,
4850 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
4851 AscWriteLramByte(iop_base,
4852 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
4853 }
4854 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004855}
4856
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004857static ASC_DCNT
4858AscLoadMicroCode(PortAddr iop_base,
4859 ushort s_addr, uchar *mcode_buf, ushort mcode_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004860{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004861 ASC_DCNT chksum;
4862 ushort mcode_word_size;
4863 ushort mcode_chksum;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004864
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004865 /* Write the microcode buffer starting at LRAM address 0. */
4866 mcode_word_size = (ushort)(mcode_size >> 1);
4867 AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
4868 AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004869
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004870 chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
4871 ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
4872 mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
4873 (ushort)ASC_CODE_SEC_BEG,
4874 (ushort)((mcode_size -
4875 s_addr - (ushort)
4876 ASC_CODE_SEC_BEG) /
4877 2));
4878 ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
4879 (ulong)mcode_chksum);
4880 AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
4881 AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
4882 return (chksum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004883}
4884
Linus Torvalds1da177e2005-04-16 15:20:36 -07004885/* Microcode buffer is kept after initialization for error recovery. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004886static uchar _asc_mcode_buf[] = {
4887 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004888 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004889 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004890 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004891 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4892 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
4893 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4894 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004895 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004896 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
4897 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
4898 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004899 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004900 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
4901 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
4902 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004903 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004904 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
4905 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
4906 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004907 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004908 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
4909 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
4910 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004911 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004912 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
4913 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
4914 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004915 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004916 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
4917 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
4918 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004919 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004920 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
4921 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
4922 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004923 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004924 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
4925 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
4926 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004927 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004928 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
4929 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
4930 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004931 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004932 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
4933 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
4934 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004935 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004936 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
4937 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
4938 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004939 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004940 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
4941 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
4942 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004943 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004944 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
4945 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
4946 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004947 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004948 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
4949 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
4950 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004951 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004952 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
4953 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
4954 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004955 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004956 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
4957 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
4958 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004959 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004960 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
4961 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
4962 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004963 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004964 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
4965 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
4966 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004967 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004968 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
4969 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
4970 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004971 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004972 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
4973 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
4974 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004975 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004976 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
4977 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
4978 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004979 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004980 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
4981 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
4982 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004983 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004984 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
4985 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
4986 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004987 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004988 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
4989 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
4990 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004991 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004992 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
4993 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
4994 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004995 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004996 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
4997 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
4998 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004999 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005000 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
5001 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
5002 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005003 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005004 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
5005 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
5006 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005007 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005008 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
5009 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
5010 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005011 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005012 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
5013 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
5014 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005015 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005016 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
5017 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
5018 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005019 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005020 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
5021 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
5022 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005023 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005024 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
5025 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
5026 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005027 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005028 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
5029 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
5030 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005031 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005032 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
5033 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
5034 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005035 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005036 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
5037 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
5038 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005039 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005040 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
5041 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
5042 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005043 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005044 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
5045 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
5046 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005047 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005048 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
5049 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
5050 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005051 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005052 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
5053 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
5054 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005055 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005056 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
5057 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
5058 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005059 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005060 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
5061 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
5062 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005063 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005064 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
5065 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
5066 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005067 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005068 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
5069 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
5070 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005071 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005072 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
5073 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
5074 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005075 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005076 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
5077 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
5078 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
Linus Torvalds1da177e2005-04-16 15:20:36 -07005079};
5080
Matthew Wilcox51219352007-10-02 21:55:22 -04005081static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005082static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005083
Linus Torvalds1da177e2005-04-16 15:20:36 -07005084/* Microcode buffer is kept after initialization for error recovery. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005085static unsigned char _adv_asc3550_buf[] = {
5086 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005087 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
5088 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
5089 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005090 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005091 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
5092 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
5093 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005094 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005095 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
5096 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
5097 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005098 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005099 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
5100 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
5101 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005102 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005103 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
5104 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
5105 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005106 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005107 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
5108 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
5109 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005110 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005111 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
5112 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
5113 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005114 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005115 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
5116 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
5117 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005118 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005119 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
5120 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
5121 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005122 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005123 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
5124 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
5125 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005126 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005127 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
5128 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
5129 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005130 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005131 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
5132 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
5133 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005134 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005135 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
5136 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
5137 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005138 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005139 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
5140 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
5141 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005142 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005143 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
5144 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
5145 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005146 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005147 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
5148 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
5149 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005150 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005151 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
5152 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
5153 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005154 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005155 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
5156 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
5157 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005158 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005159 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
5160 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
5161 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005162 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005163 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
5164 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
5165 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005166 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005167 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
5168 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
5169 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005170 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005171 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
5172 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
5173 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005174 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005175 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
5176 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
5177 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005178 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005179 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
5180 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
5181 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005182 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005183 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
5184 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
5185 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005186 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005187 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
5188 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
5189 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005190 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005191 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
5192 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
5193 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005194 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005195 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
5196 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
5197 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005198 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005199 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
5200 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
5201 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005202 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005203 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
5204 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
5205 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005206 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005207 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
5208 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
5209 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005210 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005211 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
5212 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
5213 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005214 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005215 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
5216 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
5217 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005218 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005219 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
5220 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
5221 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005222 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005223 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
5224 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
5225 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005226 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005227 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
5228 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
5229 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005230 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005231 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
5232 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
5233 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005234 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005235 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
5236 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
5237 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005238 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005239 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
5240 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
5241 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005242 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005243 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
5244 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
5245 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005246 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005247 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
5248 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
5249 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005250 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005251 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
5252 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
5253 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005254 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005255 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
5256 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
5257 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005258 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005259 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
5260 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
5261 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005262 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005263 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
5264 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
5265 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005266 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005267 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
5268 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
5269 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005270 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005271 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
5272 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
5273 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005274 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005275 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
5276 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
5277 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005278 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005279 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
5280 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
5281 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005282 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005283 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
5284 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
5285 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005286 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005287 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
5288 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
5289 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005290 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005291 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
5292 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
5293 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005294 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005295 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
5296 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
5297 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005298 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005299 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
5300 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
5301 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005302 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005303 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
5304 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
5305 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005306 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005307 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
5308 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
5309 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005310 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005311 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
5312 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
5313 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005314 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005315 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
5316 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
5317 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005318 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005319 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
5320 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
5321 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005322 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005323 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
5324 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
5325 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005326 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005327 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
5328 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
5329 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005330 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005331 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
5332 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
5333 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005334 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005335 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
5336 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
5337 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005338 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005339 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
5340 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
5341 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005342 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005343 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
5344 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
5345 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005346 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005347 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
5348 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
5349 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005350 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005351 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
5352 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
5353 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005354 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005355 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
5356 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
5357 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005358 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005359 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
5360 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
5361 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005362 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005363 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
5364 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
5365 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005366 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005367 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
5368 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
5369 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005370 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005371 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
5372 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
5373 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005374 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005375 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
5376 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
5377 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005378 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005379 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
5380 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
5381 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005382 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005383 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
5384 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
5385 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005386 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005387 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
5388 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
5389 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005390 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005391 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
5392 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
5393 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005394 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005395 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
5396 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
5397 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005398 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005399 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
5400 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
5401 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005402 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005403 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
5404 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
5405 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005406 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005407 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
5408 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
5409 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005410 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005411 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
5412 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
5413 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005414 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005415 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
5416 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
5417 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005418 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005419 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
5420 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
5421 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005422 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005423 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
5424 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
5425 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005426 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005427 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
5428 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
5429 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005430 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005431 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
5432 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
5433 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005434 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005435 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
5436 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
5437 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005438 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005439 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
5440 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
5441 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005442 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005443 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
5444 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
5445 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005446 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005447 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
5448 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
5449 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005450 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005451 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
5452 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
5453 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005454 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005455 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
5456 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
5457 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005458 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005459 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
5460 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
5461 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005462 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005463 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
5464 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
5465 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005466 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005467 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
5468 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
5469 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005470 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005471 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
5472 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
5473 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005474 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005475 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
5476 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
5477 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005478 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005479 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
5480 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
5481 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005482 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005483 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
5484 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
5485 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005486 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005487 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
5488 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
5489 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005490 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005491 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
5492 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
5493 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005494 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005495 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
5496 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
5497 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005498 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005499 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
5500 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
5501 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005502 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005503 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
5504 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07005505};
5506
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005507static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
5508static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005509
5510/* Microcode buffer is kept after initialization for error recovery. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005511static unsigned char _adv_asc38C0800_buf[] = {
5512 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005513 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
5514 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
5515 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005516 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005517 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
5518 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
5519 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005520 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005521 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
5522 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
5523 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005524 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005525 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
5526 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
5527 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005528 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005529 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
5530 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
5531 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005532 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005533 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
5534 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
5535 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005536 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005537 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
5538 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
5539 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005540 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005541 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
5542 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
5543 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005544 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005545 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
5546 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
5547 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005548 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005549 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
5550 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
5551 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005552 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005553 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
5554 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
5555 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005556 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005557 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
5558 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
5559 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005560 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005561 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
5562 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
5563 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005564 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005565 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
5566 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
5567 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005568 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005569 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
5570 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
5571 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005572 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005573 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
5574 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
5575 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005576 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005577 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
5578 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
5579 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005580 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005581 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
5582 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
5583 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005584 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005585 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
5586 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
5587 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005588 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005589 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
5590 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
5591 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005592 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005593 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
5594 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
5595 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005596 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005597 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
5598 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
5599 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005600 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005601 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
5602 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
5603 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005604 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005605 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
5606 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
5607 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005608 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005609 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
5610 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
5611 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005612 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005613 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
5614 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
5615 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005616 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005617 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
5618 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
5619 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005620 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005621 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
5622 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
5623 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005624 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005625 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
5626 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
5627 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005628 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005629 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
5630 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
5631 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005632 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005633 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
5634 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
5635 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005636 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005637 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
5638 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
5639 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005640 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005641 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
5642 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
5643 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005644 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005645 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
5646 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
5647 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005648 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005649 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
5650 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
5651 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005652 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005653 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
5654 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
5655 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005656 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005657 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
5658 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
5659 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005660 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005661 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
5662 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
5663 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005664 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005665 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
5666 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
5667 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005668 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005669 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
5670 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
5671 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005672 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005673 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
5674 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
5675 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005676 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005677 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
5678 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
5679 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005680 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005681 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
5682 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
5683 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005684 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005685 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
5686 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
5687 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005688 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005689 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
5690 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
5691 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005692 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005693 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
5694 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
5695 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005696 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005697 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
5698 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
5699 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005700 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005701 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
5702 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
5703 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005704 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005705 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
5706 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
5707 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005708 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005709 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
5710 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
5711 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005712 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005713 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
5714 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
5715 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005716 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005717 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
5718 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
5719 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005720 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005721 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
5722 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
5723 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005724 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005725 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
5726 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
5727 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005728 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005729 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
5730 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
5731 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005732 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005733 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
5734 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
5735 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005736 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005737 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
5738 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
5739 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005740 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005741 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
5742 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
5743 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005744 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005745 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
5746 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
5747 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005748 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005749 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
5750 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
5751 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005752 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005753 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
5754 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
5755 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005756 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005757 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
5758 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
5759 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005760 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005761 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
5762 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
5763 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005764 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005765 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
5766 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
5767 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005768 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005769 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
5770 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
5771 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005772 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005773 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
5774 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
5775 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005776 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005777 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
5778 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
5779 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005780 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005781 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
5782 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
5783 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005784 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005785 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
5786 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
5787 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005788 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005789 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
5790 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
5791 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005792 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005793 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
5794 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
5795 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005796 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005797 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
5798 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
5799 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005800 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005801 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
5802 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
5803 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005804 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005805 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
5806 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
5807 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005808 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005809 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
5810 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
5811 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005812 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005813 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
5814 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
5815 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005816 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005817 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
5818 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
5819 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005820 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005821 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
5822 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
5823 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005824 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005825 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
5826 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
5827 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005828 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005829 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
5830 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
5831 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005832 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005833 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
5834 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
5835 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005836 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005837 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
5838 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
5839 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005840 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005841 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
5842 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
5843 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005844 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005845 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
5846 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
5847 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005848 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005849 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
5850 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
5851 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005852 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005853 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
5854 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
5855 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005856 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005857 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
5858 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
5859 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005860 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005861 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
5862 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
5863 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005864 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005865 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
5866 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
5867 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005868 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005869 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
5870 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
5871 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005872 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005873 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
5874 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
5875 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005876 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005877 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
5878 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
5879 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005880 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005881 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
5882 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
5883 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005884 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005885 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
5886 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
5887 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005888 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005889 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
5890 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
5891 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005892 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005893 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
5894 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
5895 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005896 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005897 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
5898 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
5899 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005900 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005901 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
5902 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
5903 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005904 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005905 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
5906 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
5907 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005908 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005909 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
5910 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
5911 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005912 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005913 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
5914 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
5915 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005916 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005917 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
5918 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
5919 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005920 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005921 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
5922 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
5923 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005924 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005925 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
5926 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
5927 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005928 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005929 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
5930 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
5931 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005932 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005933 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
5934 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
5935 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005936 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005937 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
5938 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
5939 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005940 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005941 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
5942 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
5943 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005944 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005945 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
5946 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
5947 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005948 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005949 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
5950 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
5951 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005952 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005953 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
5954 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
5955 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005956 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07005957};
5958
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005959static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
5960static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005961
5962/* Microcode buffer is kept after initialization for error recovery. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005963static unsigned char _adv_asc38C1600_buf[] = {
5964 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005965 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
5966 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
5967 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005968 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005969 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
5970 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
5971 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005972 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005973 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
5974 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
5975 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005976 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005977 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
5978 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
5979 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005980 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005981 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
5982 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
5983 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005984 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005985 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
5986 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
5987 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005988 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005989 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
5990 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
5991 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005992 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005993 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
5994 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
5995 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005996 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005997 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
5998 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
5999 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006000 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006001 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
6002 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
6003 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006004 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006005 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
6006 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
6007 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006008 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006009 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
6010 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
6011 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006012 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006013 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
6014 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
6015 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006016 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006017 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
6018 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
6019 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006020 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006021 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
6022 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
6023 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006024 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006025 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
6026 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
6027 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006028 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006029 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
6030 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
6031 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006032 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006033 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
6034 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
6035 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006036 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006037 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
6038 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
6039 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006040 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006041 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
6042 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
6043 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006044 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006045 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
6046 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
6047 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006048 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006049 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
6050 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
6051 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006052 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006053 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
6054 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
6055 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006056 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006057 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
6058 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
6059 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006060 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006061 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
6062 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
6063 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006064 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006065 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
6066 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
6067 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006068 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006069 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
6070 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
6071 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006072 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006073 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
6074 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
6075 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006076 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006077 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
6078 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
6079 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006080 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006081 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
6082 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
6083 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006084 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006085 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
6086 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
6087 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006088 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006089 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
6090 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
6091 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006092 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006093 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
6094 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
6095 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006096 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006097 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
6098 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
6099 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006100 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006101 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
6102 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
6103 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006104 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006105 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
6106 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
6107 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006108 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006109 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
6110 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
6111 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006112 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006113 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
6114 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
6115 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006116 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006117 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
6118 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
6119 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006120 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006121 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
6122 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
6123 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006124 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006125 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
6126 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
6127 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006128 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006129 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
6130 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
6131 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006132 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006133 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
6134 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
6135 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006136 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006137 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
6138 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
6139 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006140 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006141 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
6142 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
6143 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006144 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006145 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
6146 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
6147 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006148 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006149 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
6150 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
6151 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006152 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006153 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
6154 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
6155 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006156 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006157 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
6158 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
6159 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006160 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006161 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
6162 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
6163 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006164 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006165 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
6166 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
6167 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006168 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006169 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
6170 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
6171 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006172 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006173 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
6174 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
6175 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006176 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006177 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
6178 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
6179 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006180 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006181 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
6182 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
6183 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006184 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006185 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
6186 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
6187 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006188 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006189 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
6190 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
6191 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006192 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006193 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
6194 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
6195 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006196 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006197 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
6198 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
6199 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006200 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006201 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
6202 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
6203 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006204 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006205 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
6206 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
6207 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006208 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006209 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
6210 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
6211 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006212 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006213 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
6214 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
6215 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006216 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006217 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
6218 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
6219 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006220 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006221 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
6222 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
6223 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006224 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006225 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
6226 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
6227 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006228 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006229 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
6230 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
6231 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006232 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006233 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
6234 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
6235 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006236 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006237 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
6238 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
6239 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006240 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006241 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
6242 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
6243 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006244 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006245 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
6246 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
6247 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006248 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006249 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
6250 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
6251 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006252 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006253 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
6254 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
6255 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006256 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006257 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
6258 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
6259 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006260 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006261 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
6262 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
6263 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006264 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006265 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
6266 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
6267 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006268 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006269 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
6270 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
6271 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006272 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006273 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
6274 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
6275 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006276 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006277 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
6278 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
6279 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006280 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006281 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
6282 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
6283 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006284 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006285 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
6286 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
6287 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006288 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006289 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
6290 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
6291 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006292 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006293 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
6294 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
6295 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006296 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006297 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
6298 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
6299 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006300 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006301 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
6302 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
6303 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006304 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006305 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
6306 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
6307 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006308 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006309 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
6310 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
6311 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006312 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006313 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
6314 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
6315 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006316 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006317 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
6318 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
6319 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006320 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006321 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
6322 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
6323 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006324 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006325 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
6326 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
6327 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006328 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006329 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
6330 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
6331 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006332 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006333 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
6334 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
6335 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006336 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006337 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
6338 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
6339 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006340 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006341 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
6342 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
6343 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006344 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006345 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
6346 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
6347 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006348 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006349 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
6350 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
6351 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006352 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006353 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
6354 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
6355 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006356 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006357 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
6358 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
6359 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006360 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006361 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
6362 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
6363 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006364 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006365 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
6366 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
6367 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006368 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006369 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
6370 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
6371 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006372 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006373 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
6374 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
6375 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006376 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006377 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
6378 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
6379 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006380 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006381 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
6382 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
6383 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006384 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006385 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
6386 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
6387 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006388 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006389 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
6390 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
6391 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006392 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006393 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
6394 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
6395 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006396 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006397 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
6398 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
6399 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006400 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006401 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
6402 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
6403 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006404 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006405 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
6406 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
6407 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006408 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006409 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
6410 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
6411 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006412 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006413 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
6414 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
6415 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006416 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006417 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
6418 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
6419 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006420 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006421 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
6422 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
6423 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006424 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006425 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
6426 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
6427 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006428 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006429 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
6430 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
6431 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006432 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006433 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
6434 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
6435 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006436 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006437 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
6438 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
6439 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006440 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006441 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
6442 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
6443 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006444 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006445 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
6446 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
6447 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006448 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006449 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
6450 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
6451 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006452 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006453 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
6454 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
6455 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006456 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006457 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
6458 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
6459 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006460 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006461 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
6462 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
6463 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006464 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006465 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
6466 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
6467 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006468 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006469 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
6470 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
6471 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006472 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006473 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
6474 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
6475 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006476 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006477 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
6478 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
6479 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006480 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006481 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
6482 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
6483 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006484 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006485 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
6486 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
6487 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006488 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006489 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
6490 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
6491 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07006492};
6493
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006494static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
6495static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006496
Matthew Wilcox51219352007-10-02 21:55:22 -04006497static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07006498{
Matthew Wilcox51219352007-10-02 21:55:22 -04006499 PortAddr iop_base;
6500 int i;
6501 ushort lram_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006502
Matthew Wilcox51219352007-10-02 21:55:22 -04006503 iop_base = asc_dvc->iop_base;
6504 AscPutRiscVarFreeQHead(iop_base, 1);
6505 AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
6506 AscPutVarFreeQHead(iop_base, 1);
6507 AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
6508 AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
6509 (uchar)((int)asc_dvc->max_total_qng + 1));
6510 AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
6511 (uchar)((int)asc_dvc->max_total_qng + 2));
6512 AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
6513 asc_dvc->max_total_qng);
6514 AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
6515 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
6516 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
6517 AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
6518 AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
6519 AscPutQDoneInProgress(iop_base, 0);
6520 lram_addr = ASC_QADR_BEG;
6521 for (i = 0; i < 32; i++, lram_addr += 2) {
6522 AscWriteLramWord(iop_base, lram_addr, 0);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006523 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006524}
6525
Matthew Wilcox51219352007-10-02 21:55:22 -04006526static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006527{
Matthew Wilcox51219352007-10-02 21:55:22 -04006528 int i;
6529 ushort warn_code;
6530 PortAddr iop_base;
6531 ASC_PADDR phy_addr;
6532 ASC_DCNT phy_size;
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006533
Matthew Wilcox51219352007-10-02 21:55:22 -04006534 iop_base = asc_dvc->iop_base;
6535 warn_code = 0;
6536 for (i = 0; i <= ASC_MAX_TID; i++) {
6537 AscPutMCodeInitSDTRAtID(iop_base, i,
6538 asc_dvc->cfg->sdtr_period_offset[i]);
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006539 }
6540
Matthew Wilcox51219352007-10-02 21:55:22 -04006541 AscInitQLinkVar(asc_dvc);
6542 AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
6543 asc_dvc->cfg->disc_enable);
6544 AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
6545 ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006546
Matthew Wilcox51219352007-10-02 21:55:22 -04006547 /* Align overrun buffer on an 8 byte boundary. */
6548 phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
6549 phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
6550 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
6551 (uchar *)&phy_addr, 1);
6552 phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
6553 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
6554 (uchar *)&phy_size, 1);
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006555
Matthew Wilcox51219352007-10-02 21:55:22 -04006556 asc_dvc->cfg->mcode_date =
6557 AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
6558 asc_dvc->cfg->mcode_version =
6559 AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006560
Matthew Wilcox51219352007-10-02 21:55:22 -04006561 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
6562 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
6563 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
6564 return warn_code;
6565 }
6566 if (AscStartChip(iop_base) != 1) {
6567 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
6568 return warn_code;
6569 }
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006570
Matthew Wilcox51219352007-10-02 21:55:22 -04006571 return warn_code;
6572}
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006573
Matthew Wilcox51219352007-10-02 21:55:22 -04006574static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
6575{
6576 ushort warn_code;
6577 PortAddr iop_base;
6578
6579 iop_base = asc_dvc->iop_base;
6580 warn_code = 0;
6581 if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
6582 !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
6583 AscResetChipAndScsiBus(asc_dvc);
6584 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
6585 }
6586 asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
6587 if (asc_dvc->err_code != 0)
6588 return UW_ERR;
6589 if (!AscFindSignature(asc_dvc->iop_base)) {
6590 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
6591 return warn_code;
6592 }
6593 AscDisableInterrupt(iop_base);
6594 warn_code |= AscInitLram(asc_dvc);
6595 if (asc_dvc->err_code != 0)
6596 return UW_ERR;
6597 ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
6598 (ulong)_asc_mcode_chksum);
6599 if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
6600 _asc_mcode_size) != _asc_mcode_chksum) {
6601 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
6602 return warn_code;
6603 }
6604 warn_code |= AscInitMicroCodeVar(asc_dvc);
6605 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
6606 AscEnableInterrupt(iop_base);
6607 return warn_code;
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006608}
6609
Linus Torvalds1da177e2005-04-16 15:20:36 -07006610/*
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06006611 * Load the Microcode
6612 *
6613 * Write the microcode image to RISC memory starting at address 0.
6614 *
6615 * The microcode is stored compressed in the following format:
6616 *
6617 * 254 word (508 byte) table indexed by byte code followed
6618 * by the following byte codes:
6619 *
6620 * 1-Byte Code:
6621 * 00: Emit word 0 in table.
6622 * 01: Emit word 1 in table.
6623 * .
6624 * FD: Emit word 253 in table.
6625 *
6626 * Multi-Byte Code:
6627 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
6628 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
6629 *
6630 * Returns 0 or an error if the checksum doesn't match
6631 */
6632static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
6633 int memsize, int chksum)
6634{
6635 int i, j, end, len = 0;
6636 ADV_DCNT sum;
6637
6638 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
6639
6640 for (i = 253 * 2; i < size; i++) {
6641 if (buf[i] == 0xff) {
6642 unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
6643 for (j = 0; j < buf[i + 1]; j++) {
6644 AdvWriteWordAutoIncLram(iop_base, word);
6645 len += 2;
6646 }
6647 i += 3;
6648 } else if (buf[i] == 0xfe) {
6649 unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
6650 AdvWriteWordAutoIncLram(iop_base, word);
6651 i += 2;
6652 len += 2;
6653 } else {
6654 unsigned char off = buf[i] * 2;
6655 unsigned short word = (buf[off + 1] << 8) | buf[off];
6656 AdvWriteWordAutoIncLram(iop_base, word);
6657 len += 2;
6658 }
6659 }
6660
6661 end = len;
6662
6663 while (len < memsize) {
6664 AdvWriteWordAutoIncLram(iop_base, 0);
6665 len += 2;
6666 }
6667
6668 /* Verify the microcode checksum. */
6669 sum = 0;
6670 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
6671
6672 for (len = 0; len < end; len += 2) {
6673 sum += AdvReadWordAutoIncLram(iop_base);
6674 }
6675
6676 if (sum != chksum)
6677 return ASC_IERR_MCODE_CHKSUM;
6678
6679 return 0;
6680}
6681
6682/*
Matthew Wilcox51219352007-10-02 21:55:22 -04006683 * DvcGetPhyAddr()
6684 *
6685 * Return the physical address of 'vaddr' and set '*lenp' to the
6686 * number of physically contiguous bytes that follow 'vaddr'.
6687 * 'flag' indicates the type of structure whose physical address
6688 * is being translated.
6689 *
6690 * Note: Because Linux currently doesn't page the kernel and all
6691 * kernel buffers are physically contiguous, leave '*lenp' unchanged.
6692 */
6693ADV_PADDR
6694DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
6695 uchar *vaddr, ADV_SDCNT *lenp, int flag)
6696{
6697 ADV_PADDR paddr = virt_to_bus(vaddr);
6698
6699 ASC_DBG4(4, "DvcGetPhyAddr: vaddr 0x%p, lenp 0x%p *lenp %lu, paddr 0x%lx\n",
6700 vaddr, lenp, (ulong)*((ulong *)lenp), (ulong)paddr);
6701
6702 return paddr;
6703}
6704
6705static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
6706{
6707 ADV_CARR_T *carrp;
6708 ADV_SDCNT buf_size;
6709 ADV_PADDR carr_paddr;
6710
6711 BUG_ON(!asc_dvc->carrier_buf);
6712
6713 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
6714 asc_dvc->carr_freelist = NULL;
6715 if (carrp == asc_dvc->carrier_buf) {
6716 buf_size = ADV_CARRIER_BUFSIZE;
6717 } else {
6718 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
6719 }
6720
6721 do {
6722 /* Get physical address of the carrier 'carrp'. */
6723 ADV_DCNT contig_len = sizeof(ADV_CARR_T);
6724 carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
6725 (uchar *)carrp,
6726 (ADV_SDCNT *)&contig_len,
6727 ADV_IS_CARRIER_FLAG));
6728
6729 buf_size -= sizeof(ADV_CARR_T);
6730
6731 /*
6732 * If the current carrier is not physically contiguous, then
6733 * maybe there was a page crossing. Try the next carrier
6734 * aligned start address.
6735 */
6736 if (contig_len < sizeof(ADV_CARR_T)) {
6737 carrp++;
6738 continue;
6739 }
6740
6741 carrp->carr_pa = carr_paddr;
6742 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
6743
6744 /*
6745 * Insert the carrier at the beginning of the freelist.
6746 */
6747 carrp->next_vpa =
6748 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
6749 asc_dvc->carr_freelist = carrp;
6750
6751 carrp++;
6752 } while (buf_size > 0);
6753}
6754
6755/*
6756 * Send an idle command to the chip and wait for completion.
6757 *
6758 * Command completion is polled for once per microsecond.
6759 *
6760 * The function can be called from anywhere including an interrupt handler.
6761 * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
6762 * functions to prevent reentrancy.
6763 *
6764 * Return Values:
6765 * ADV_TRUE - command completed successfully
6766 * ADV_FALSE - command failed
6767 * ADV_ERROR - command timed out
6768 */
6769static int
6770AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
6771 ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
6772{
6773 int result;
6774 ADV_DCNT i, j;
6775 AdvPortAddr iop_base;
6776
6777 iop_base = asc_dvc->iop_base;
6778
6779 /*
6780 * Clear the idle command status which is set by the microcode
6781 * to a non-zero value to indicate when the command is completed.
6782 * The non-zero result is one of the IDLE_CMD_STATUS_* values
6783 */
6784 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
6785
6786 /*
6787 * Write the idle command value after the idle command parameter
6788 * has been written to avoid a race condition. If the order is not
6789 * followed, the microcode may process the idle command before the
6790 * parameters have been written to LRAM.
6791 */
6792 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
6793 cpu_to_le32(idle_cmd_parameter));
6794 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
6795
6796 /*
6797 * Tickle the RISC to tell it to process the idle command.
6798 */
6799 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
6800 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
6801 /*
6802 * Clear the tickle value. In the ASC-3550 the RISC flag
6803 * command 'clr_tickle_b' does not work unless the host
6804 * value is cleared.
6805 */
6806 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
6807 }
6808
6809 /* Wait for up to 100 millisecond for the idle command to timeout. */
6810 for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
6811 /* Poll once each microsecond for command completion. */
6812 for (j = 0; j < SCSI_US_PER_MSEC; j++) {
6813 AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
6814 result);
6815 if (result != 0)
6816 return result;
6817 udelay(1);
6818 }
6819 }
6820
6821 BUG(); /* The idle command should never timeout. */
6822 return ADV_ERROR;
6823}
6824
6825/*
6826 * Reset SCSI Bus and purge all outstanding requests.
6827 *
6828 * Return Value:
6829 * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
6830 * ADV_FALSE(0) - Microcode command failed.
6831 * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
6832 * may be hung which requires driver recovery.
6833 */
6834static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
6835{
6836 int status;
6837
6838 /*
6839 * Send the SCSI Bus Reset idle start idle command which asserts
6840 * the SCSI Bus Reset signal.
6841 */
6842 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
6843 if (status != ADV_TRUE) {
6844 return status;
6845 }
6846
6847 /*
6848 * Delay for the specified SCSI Bus Reset hold time.
6849 *
6850 * The hold time delay is done on the host because the RISC has no
6851 * microsecond accurate timer.
6852 */
6853 udelay(ASC_SCSI_RESET_HOLD_TIME_US);
6854
6855 /*
6856 * Send the SCSI Bus Reset end idle command which de-asserts
6857 * the SCSI Bus Reset signal and purges any pending requests.
6858 */
6859 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
6860 if (status != ADV_TRUE) {
6861 return status;
6862 }
6863
6864 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
6865
6866 return status;
6867}
6868
6869/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006870 * Initialize the ASC-3550.
6871 *
6872 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
6873 *
6874 * For a non-fatal error return a warning code. If there are no warnings
6875 * then 0 is returned.
6876 *
6877 * Needed after initialization for error recovery.
6878 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006879static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07006880{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006881 AdvPortAddr iop_base;
6882 ushort warn_code;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006883 int begin_addr;
6884 int end_addr;
6885 ushort code_sum;
6886 int word;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006887 int i;
6888 ushort scsi_cfg1;
6889 uchar tid;
6890 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
6891 ushort wdtr_able = 0, sdtr_able, tagqng_able;
6892 uchar max_cmd[ADV_MAX_TID + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -07006893
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006894 /* If there is already an error, don't continue. */
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06006895 if (asc_dvc->err_code != 0)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006896 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006897
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006898 /*
6899 * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
6900 */
6901 if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06006902 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006903 return ADV_ERROR;
6904 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006905
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006906 warn_code = 0;
6907 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006908
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006909 /*
6910 * Save the RISC memory BIOS region before writing the microcode.
6911 * The BIOS may already be loaded and using its RISC LRAM region
6912 * so its region must be saved and restored.
6913 *
6914 * Note: This code makes the assumption, which is currently true,
6915 * that a chip reset does not clear RISC LRAM.
6916 */
6917 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
6918 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
6919 bios_mem[i]);
6920 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006921
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006922 /*
6923 * Save current per TID negotiated values.
6924 */
6925 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
6926 ushort bios_version, major, minor;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006927
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006928 bios_version =
6929 bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
6930 major = (bios_version >> 12) & 0xF;
6931 minor = (bios_version >> 8) & 0xF;
6932 if (major < 3 || (major == 3 && minor == 1)) {
6933 /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
6934 AdvReadWordLram(iop_base, 0x120, wdtr_able);
6935 } else {
6936 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
6937 }
6938 }
6939 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
6940 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
6941 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
6942 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
6943 max_cmd[tid]);
6944 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006945
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06006946 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
6947 _adv_asc3550_size, ADV_3550_MEMSIZE,
6948 _adv_asc3550_chksum);
6949 if (asc_dvc->err_code)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006950 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006951
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006952 /*
6953 * Restore the RISC memory BIOS region.
6954 */
6955 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
6956 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
6957 bios_mem[i]);
6958 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006959
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006960 /*
6961 * Calculate and write the microcode code checksum to the microcode
6962 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
6963 */
6964 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
6965 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
6966 code_sum = 0;
6967 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
6968 for (word = begin_addr; word < end_addr; word += 2) {
6969 code_sum += AdvReadWordAutoIncLram(iop_base);
6970 }
6971 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006972
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006973 /*
6974 * Read and save microcode version and date.
6975 */
6976 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
6977 asc_dvc->cfg->mcode_date);
6978 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
6979 asc_dvc->cfg->mcode_version);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006980
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006981 /*
6982 * Set the chip type to indicate the ASC3550.
6983 */
6984 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006985
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006986 /*
6987 * If the PCI Configuration Command Register "Parity Error Response
6988 * Control" Bit was clear (0), then set the microcode variable
6989 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
6990 * to ignore DMA parity errors.
6991 */
6992 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
6993 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
6994 word |= CONTROL_FLAG_IGNORE_PERR;
6995 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
6996 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006997
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006998 /*
6999 * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
7000 * threshold of 128 bytes. This register is only accessible to the host.
7001 */
7002 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
7003 START_CTL_EMFU | READ_CMD_MRM);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007004
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007005 /*
7006 * Microcode operating variables for WDTR, SDTR, and command tag
Matthew Wilcox47d853c2007-07-26 11:41:33 -04007007 * queuing will be set in slave_configure() based on what a
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007008 * device reports it is capable of in Inquiry byte 7.
7009 *
7010 * If SCSI Bus Resets have been disabled, then directly set
7011 * SDTR and WDTR from the EEPROM configuration. This will allow
7012 * the BIOS and warm boot to work without a SCSI bus hang on
7013 * the Inquiry caused by host and target mismatched DTR values.
7014 * Without the SCSI Bus Reset, before an Inquiry a device can't
7015 * be assumed to be in Asynchronous, Narrow mode.
7016 */
7017 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
7018 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
7019 asc_dvc->wdtr_able);
7020 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
7021 asc_dvc->sdtr_able);
7022 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007023
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007024 /*
7025 * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
7026 * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
7027 * bitmask. These values determine the maximum SDTR speed negotiated
7028 * with a device.
7029 *
7030 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
7031 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
7032 * without determining here whether the device supports SDTR.
7033 *
7034 * 4-bit speed SDTR speed name
7035 * =========== ===============
7036 * 0000b (0x0) SDTR disabled
7037 * 0001b (0x1) 5 Mhz
7038 * 0010b (0x2) 10 Mhz
7039 * 0011b (0x3) 20 Mhz (Ultra)
7040 * 0100b (0x4) 40 Mhz (LVD/Ultra2)
7041 * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
7042 * 0110b (0x6) Undefined
7043 * .
7044 * 1111b (0xF) Undefined
7045 */
7046 word = 0;
7047 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7048 if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
7049 /* Set Ultra speed for TID 'tid'. */
7050 word |= (0x3 << (4 * (tid % 4)));
7051 } else {
7052 /* Set Fast speed for TID 'tid'. */
7053 word |= (0x2 << (4 * (tid % 4)));
7054 }
7055 if (tid == 3) { /* Check if done with sdtr_speed1. */
7056 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
7057 word = 0;
7058 } else if (tid == 7) { /* Check if done with sdtr_speed2. */
7059 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
7060 word = 0;
7061 } else if (tid == 11) { /* Check if done with sdtr_speed3. */
7062 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
7063 word = 0;
7064 } else if (tid == 15) { /* Check if done with sdtr_speed4. */
7065 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
7066 /* End of loop. */
7067 }
7068 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007069
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007070 /*
7071 * Set microcode operating variable for the disconnect per TID bitmask.
7072 */
7073 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
7074 asc_dvc->cfg->disc_enable);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007075
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007076 /*
7077 * Set SCSI_CFG0 Microcode Default Value.
7078 *
7079 * The microcode will set the SCSI_CFG0 register using this value
7080 * after it is started below.
7081 */
7082 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
7083 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
7084 asc_dvc->chip_scsi_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007085
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007086 /*
7087 * Determine SCSI_CFG1 Microcode Default Value.
7088 *
7089 * The microcode will set the SCSI_CFG1 register using this value
7090 * after it is started below.
7091 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007092
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007093 /* Read current SCSI_CFG1 Register value. */
7094 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007095
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007096 /*
7097 * If all three connectors are in use, return an error.
7098 */
7099 if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
7100 (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
7101 asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
7102 return ADV_ERROR;
7103 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007104
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007105 /*
7106 * If the internal narrow cable is reversed all of the SCSI_CTRL
7107 * register signals will be set. Check for and return an error if
7108 * this condition is found.
7109 */
7110 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
7111 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
7112 return ADV_ERROR;
7113 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007114
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007115 /*
7116 * If this is a differential board and a single-ended device
7117 * is attached to one of the connectors, return an error.
7118 */
7119 if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
7120 asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
7121 return ADV_ERROR;
7122 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007123
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007124 /*
7125 * If automatic termination control is enabled, then set the
7126 * termination value based on a table listed in a_condor.h.
7127 *
7128 * If manual termination was specified with an EEPROM setting
7129 * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
7130 * is ready to be 'ored' into SCSI_CFG1.
7131 */
7132 if (asc_dvc->cfg->termination == 0) {
7133 /*
7134 * The software always controls termination by setting TERM_CTL_SEL.
7135 * If TERM_CTL_SEL were set to 0, the hardware would set termination.
7136 */
7137 asc_dvc->cfg->termination |= TERM_CTL_SEL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007138
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007139 switch (scsi_cfg1 & CABLE_DETECT) {
7140 /* TERM_CTL_H: on, TERM_CTL_L: on */
7141 case 0x3:
7142 case 0x7:
7143 case 0xB:
7144 case 0xD:
7145 case 0xE:
7146 case 0xF:
7147 asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
7148 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007149
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007150 /* TERM_CTL_H: on, TERM_CTL_L: off */
7151 case 0x1:
7152 case 0x5:
7153 case 0x9:
7154 case 0xA:
7155 case 0xC:
7156 asc_dvc->cfg->termination |= TERM_CTL_H;
7157 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007158
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007159 /* TERM_CTL_H: off, TERM_CTL_L: off */
7160 case 0x2:
7161 case 0x6:
7162 break;
7163 }
7164 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007165
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007166 /*
7167 * Clear any set TERM_CTL_H and TERM_CTL_L bits.
7168 */
7169 scsi_cfg1 &= ~TERM_CTL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007170
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007171 /*
7172 * Invert the TERM_CTL_H and TERM_CTL_L bits and then
7173 * set 'scsi_cfg1'. The TERM_POL bit does not need to be
7174 * referenced, because the hardware internally inverts
7175 * the Termination High and Low bits if TERM_POL is set.
7176 */
7177 scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007178
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007179 /*
7180 * Set SCSI_CFG1 Microcode Default Value
7181 *
7182 * Set filter value and possibly modified termination control
7183 * bits in the Microcode SCSI_CFG1 Register Value.
7184 *
7185 * The microcode will set the SCSI_CFG1 register using this value
7186 * after it is started below.
7187 */
7188 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
7189 FLTR_DISABLE | scsi_cfg1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007190
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007191 /*
7192 * Set MEM_CFG Microcode Default Value
7193 *
7194 * The microcode will set the MEM_CFG register using this value
7195 * after it is started below.
7196 *
7197 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
7198 * are defined.
7199 *
7200 * ASC-3550 has 8KB internal memory.
7201 */
7202 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
7203 BIOS_EN | RAM_SZ_8KB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007204
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007205 /*
7206 * Set SEL_MASK Microcode Default Value
7207 *
7208 * The microcode will set the SEL_MASK register using this value
7209 * after it is started below.
7210 */
7211 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
7212 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007213
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06007214 AdvBuildCarrierFreelist(asc_dvc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007215
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007216 /*
7217 * Set-up the Host->RISC Initiator Command Queue (ICQ).
7218 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007219
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007220 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
7221 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7222 return ADV_ERROR;
7223 }
7224 asc_dvc->carr_freelist = (ADV_CARR_T *)
7225 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007226
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007227 /*
7228 * The first command issued will be placed in the stopper carrier.
7229 */
7230 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007231
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007232 /*
7233 * Set RISC ICQ physical address start value.
7234 */
7235 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007236
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007237 /*
7238 * Set-up the RISC->Host Initiator Response Queue (IRQ).
7239 */
7240 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
7241 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7242 return ADV_ERROR;
7243 }
7244 asc_dvc->carr_freelist = (ADV_CARR_T *)
7245 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007246
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007247 /*
7248 * The first command completed by the RISC will be placed in
7249 * the stopper.
7250 *
7251 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
7252 * completed the RISC will set the ASC_RQ_STOPPER bit.
7253 */
7254 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007255
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007256 /*
7257 * Set RISC IRQ physical address start value.
7258 */
7259 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
7260 asc_dvc->carr_pending_cnt = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007261
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007262 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
7263 (ADV_INTR_ENABLE_HOST_INTR |
7264 ADV_INTR_ENABLE_GLOBAL_INTR));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007265
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007266 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
7267 AdvWriteWordRegister(iop_base, IOPW_PC, word);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007268
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007269 /* finally, finally, gentlemen, start your engine */
7270 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007271
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007272 /*
7273 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
7274 * Resets should be performed. The RISC has to be running
7275 * to issue a SCSI Bus Reset.
7276 */
7277 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
7278 /*
7279 * If the BIOS Signature is present in memory, restore the
7280 * BIOS Handshake Configuration Table and do not perform
7281 * a SCSI Bus Reset.
7282 */
7283 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
7284 0x55AA) {
7285 /*
7286 * Restore per TID negotiated values.
7287 */
7288 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7289 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7290 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
7291 tagqng_able);
7292 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7293 AdvWriteByteLram(iop_base,
7294 ASC_MC_NUMBER_OF_MAX_CMD + tid,
7295 max_cmd[tid]);
7296 }
7297 } else {
7298 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
7299 warn_code = ASC_WARN_BUSRESET_ERROR;
7300 }
7301 }
7302 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007303
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007304 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007305}
7306
7307/*
7308 * Initialize the ASC-38C0800.
7309 *
7310 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
7311 *
7312 * For a non-fatal error return a warning code. If there are no warnings
7313 * then 0 is returned.
7314 *
7315 * Needed after initialization for error recovery.
7316 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007317static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007318{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007319 AdvPortAddr iop_base;
7320 ushort warn_code;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007321 int begin_addr;
7322 int end_addr;
7323 ushort code_sum;
7324 int word;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007325 int i;
7326 ushort scsi_cfg1;
7327 uchar byte;
7328 uchar tid;
7329 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
7330 ushort wdtr_able, sdtr_able, tagqng_able;
7331 uchar max_cmd[ADV_MAX_TID + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -07007332
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007333 /* If there is already an error, don't continue. */
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007334 if (asc_dvc->err_code != 0)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007335 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007336
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007337 /*
7338 * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
7339 */
7340 if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
7341 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
7342 return ADV_ERROR;
7343 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007344
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007345 warn_code = 0;
7346 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007347
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007348 /*
7349 * Save the RISC memory BIOS region before writing the microcode.
7350 * The BIOS may already be loaded and using its RISC LRAM region
7351 * so its region must be saved and restored.
7352 *
7353 * Note: This code makes the assumption, which is currently true,
7354 * that a chip reset does not clear RISC LRAM.
7355 */
7356 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7357 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7358 bios_mem[i]);
7359 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007360
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007361 /*
7362 * Save current per TID negotiated values.
7363 */
7364 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7365 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7366 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
7367 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7368 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
7369 max_cmd[tid]);
7370 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007371
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007372 /*
7373 * RAM BIST (RAM Built-In Self Test)
7374 *
7375 * Address : I/O base + offset 0x38h register (byte).
7376 * Function: Bit 7-6(RW) : RAM mode
7377 * Normal Mode : 0x00
7378 * Pre-test Mode : 0x40
7379 * RAM Test Mode : 0x80
7380 * Bit 5 : unused
7381 * Bit 4(RO) : Done bit
7382 * Bit 3-0(RO) : Status
7383 * Host Error : 0x08
7384 * Int_RAM Error : 0x04
7385 * RISC Error : 0x02
7386 * SCSI Error : 0x01
7387 * No Error : 0x00
7388 *
7389 * Note: RAM BIST code should be put right here, before loading the
7390 * microcode and after saving the RISC memory BIOS region.
7391 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007392
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007393 /*
7394 * LRAM Pre-test
7395 *
7396 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
7397 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
7398 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
7399 * to NORMAL_MODE, return an error too.
7400 */
7401 for (i = 0; i < 2; i++) {
7402 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
Matthew Wilcoxb009bef62007-09-09 08:56:38 -06007403 mdelay(10); /* Wait for 10ms before reading back. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007404 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7405 if ((byte & RAM_TEST_DONE) == 0
7406 || (byte & 0x0F) != PRE_TEST_VALUE) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007407 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007408 return ADV_ERROR;
7409 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007410
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007411 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
Matthew Wilcoxb009bef62007-09-09 08:56:38 -06007412 mdelay(10); /* Wait for 10ms before reading back. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007413 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
7414 != NORMAL_VALUE) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007415 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007416 return ADV_ERROR;
7417 }
7418 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007419
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007420 /*
7421 * LRAM Test - It takes about 1.5 ms to run through the test.
7422 *
7423 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
7424 * If Done bit not set or Status not 0, save register byte, set the
7425 * err_code, and return an error.
7426 */
7427 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
Matthew Wilcoxb009bef62007-09-09 08:56:38 -06007428 mdelay(10); /* Wait for 10ms before checking status. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007429
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007430 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7431 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
7432 /* Get here if Done bit not set or Status not 0. */
7433 asc_dvc->bist_err_code = byte; /* for BIOS display message */
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007434 asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007435 return ADV_ERROR;
7436 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007437
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007438 /* We need to reset back to normal mode after LRAM test passes. */
7439 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007440
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007441 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
7442 _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
7443 _adv_asc38C0800_chksum);
7444 if (asc_dvc->err_code)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007445 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007446
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007447 /*
7448 * Restore the RISC memory BIOS region.
7449 */
7450 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7451 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7452 bios_mem[i]);
7453 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007454
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007455 /*
7456 * Calculate and write the microcode code checksum to the microcode
7457 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
7458 */
7459 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
7460 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
7461 code_sum = 0;
7462 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
7463 for (word = begin_addr; word < end_addr; word += 2) {
7464 code_sum += AdvReadWordAutoIncLram(iop_base);
7465 }
7466 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007467
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007468 /*
7469 * Read microcode version and date.
7470 */
7471 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
7472 asc_dvc->cfg->mcode_date);
7473 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
7474 asc_dvc->cfg->mcode_version);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007475
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007476 /*
7477 * Set the chip type to indicate the ASC38C0800.
7478 */
7479 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007480
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007481 /*
7482 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
7483 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
7484 * cable detection and then we are able to read C_DET[3:0].
7485 *
7486 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
7487 * Microcode Default Value' section below.
7488 */
7489 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
7490 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
7491 scsi_cfg1 | DIS_TERM_DRV);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007492
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007493 /*
7494 * If the PCI Configuration Command Register "Parity Error Response
7495 * Control" Bit was clear (0), then set the microcode variable
7496 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
7497 * to ignore DMA parity errors.
7498 */
7499 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
7500 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7501 word |= CONTROL_FLAG_IGNORE_PERR;
7502 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7503 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007504
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007505 /*
7506 * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
7507 * bits for the default FIFO threshold.
7508 *
7509 * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
7510 *
7511 * For DMA Errata #4 set the BC_THRESH_ENB bit.
7512 */
7513 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
7514 BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
7515 READ_CMD_MRM);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007516
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007517 /*
7518 * Microcode operating variables for WDTR, SDTR, and command tag
Matthew Wilcox47d853c2007-07-26 11:41:33 -04007519 * queuing will be set in slave_configure() based on what a
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007520 * device reports it is capable of in Inquiry byte 7.
7521 *
7522 * If SCSI Bus Resets have been disabled, then directly set
7523 * SDTR and WDTR from the EEPROM configuration. This will allow
7524 * the BIOS and warm boot to work without a SCSI bus hang on
7525 * the Inquiry caused by host and target mismatched DTR values.
7526 * Without the SCSI Bus Reset, before an Inquiry a device can't
7527 * be assumed to be in Asynchronous, Narrow mode.
7528 */
7529 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
7530 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
7531 asc_dvc->wdtr_able);
7532 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
7533 asc_dvc->sdtr_able);
7534 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007535
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007536 /*
7537 * Set microcode operating variables for DISC and SDTR_SPEED1,
7538 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
7539 * configuration values.
7540 *
7541 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
7542 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
7543 * without determining here whether the device supports SDTR.
7544 */
7545 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
7546 asc_dvc->cfg->disc_enable);
7547 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
7548 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
7549 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
7550 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007551
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007552 /*
7553 * Set SCSI_CFG0 Microcode Default Value.
7554 *
7555 * The microcode will set the SCSI_CFG0 register using this value
7556 * after it is started below.
7557 */
7558 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
7559 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
7560 asc_dvc->chip_scsi_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007561
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007562 /*
7563 * Determine SCSI_CFG1 Microcode Default Value.
7564 *
7565 * The microcode will set the SCSI_CFG1 register using this value
7566 * after it is started below.
7567 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007568
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007569 /* Read current SCSI_CFG1 Register value. */
7570 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007571
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007572 /*
7573 * If the internal narrow cable is reversed all of the SCSI_CTRL
7574 * register signals will be set. Check for and return an error if
7575 * this condition is found.
7576 */
7577 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
7578 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
7579 return ADV_ERROR;
7580 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007581
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007582 /*
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007583 * All kind of combinations of devices attached to one of four
7584 * connectors are acceptable except HVD device attached. For example,
7585 * LVD device can be attached to SE connector while SE device attached
7586 * to LVD connector. If LVD device attached to SE connector, it only
7587 * runs up to Ultra speed.
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007588 *
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007589 * If an HVD device is attached to one of LVD connectors, return an
7590 * error. However, there is no way to detect HVD device attached to
7591 * SE connectors.
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007592 */
7593 if (scsi_cfg1 & HVD) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007594 asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007595 return ADV_ERROR;
7596 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007597
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007598 /*
7599 * If either SE or LVD automatic termination control is enabled, then
7600 * set the termination value based on a table listed in a_condor.h.
7601 *
7602 * If manual termination was specified with an EEPROM setting then
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007603 * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
7604 * to be 'ored' into SCSI_CFG1.
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007605 */
7606 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
7607 /* SE automatic termination control is enabled. */
7608 switch (scsi_cfg1 & C_DET_SE) {
7609 /* TERM_SE_HI: on, TERM_SE_LO: on */
7610 case 0x1:
7611 case 0x2:
7612 case 0x3:
7613 asc_dvc->cfg->termination |= TERM_SE;
7614 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007615
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007616 /* TERM_SE_HI: on, TERM_SE_LO: off */
7617 case 0x0:
7618 asc_dvc->cfg->termination |= TERM_SE_HI;
7619 break;
7620 }
7621 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007622
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007623 if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
7624 /* LVD automatic termination control is enabled. */
7625 switch (scsi_cfg1 & C_DET_LVD) {
7626 /* TERM_LVD_HI: on, TERM_LVD_LO: on */
7627 case 0x4:
7628 case 0x8:
7629 case 0xC:
7630 asc_dvc->cfg->termination |= TERM_LVD;
7631 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007632
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007633 /* TERM_LVD_HI: off, TERM_LVD_LO: off */
7634 case 0x0:
7635 break;
7636 }
7637 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007638
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007639 /*
7640 * Clear any set TERM_SE and TERM_LVD bits.
7641 */
7642 scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007643
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007644 /*
7645 * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
7646 */
7647 scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007648
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007649 /*
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007650 * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
7651 * bits and set possibly modified termination control bits in the
7652 * Microcode SCSI_CFG1 Register Value.
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007653 */
7654 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007655
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007656 /*
7657 * Set SCSI_CFG1 Microcode Default Value
7658 *
7659 * Set possibly modified termination control and reset DIS_TERM_DRV
7660 * bits in the Microcode SCSI_CFG1 Register Value.
7661 *
7662 * The microcode will set the SCSI_CFG1 register using this value
7663 * after it is started below.
7664 */
7665 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007666
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007667 /*
7668 * Set MEM_CFG Microcode Default Value
7669 *
7670 * The microcode will set the MEM_CFG register using this value
7671 * after it is started below.
7672 *
7673 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
7674 * are defined.
7675 *
7676 * ASC-38C0800 has 16KB internal memory.
7677 */
7678 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
7679 BIOS_EN | RAM_SZ_16KB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007680
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007681 /*
7682 * Set SEL_MASK Microcode Default Value
7683 *
7684 * The microcode will set the SEL_MASK register using this value
7685 * after it is started below.
7686 */
7687 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
7688 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007689
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06007690 AdvBuildCarrierFreelist(asc_dvc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007691
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007692 /*
7693 * Set-up the Host->RISC Initiator Command Queue (ICQ).
7694 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007695
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007696 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
7697 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7698 return ADV_ERROR;
7699 }
7700 asc_dvc->carr_freelist = (ADV_CARR_T *)
7701 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007702
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007703 /*
7704 * The first command issued will be placed in the stopper carrier.
7705 */
7706 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007707
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007708 /*
7709 * Set RISC ICQ physical address start value.
7710 * carr_pa is LE, must be native before write
7711 */
7712 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007713
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007714 /*
7715 * Set-up the RISC->Host Initiator Response Queue (IRQ).
7716 */
7717 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
7718 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7719 return ADV_ERROR;
7720 }
7721 asc_dvc->carr_freelist = (ADV_CARR_T *)
7722 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007723
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007724 /*
7725 * The first command completed by the RISC will be placed in
7726 * the stopper.
7727 *
7728 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
7729 * completed the RISC will set the ASC_RQ_STOPPER bit.
7730 */
7731 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007732
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007733 /*
7734 * Set RISC IRQ physical address start value.
7735 *
7736 * carr_pa is LE, must be native before write *
7737 */
7738 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
7739 asc_dvc->carr_pending_cnt = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007740
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007741 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
7742 (ADV_INTR_ENABLE_HOST_INTR |
7743 ADV_INTR_ENABLE_GLOBAL_INTR));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007744
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007745 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
7746 AdvWriteWordRegister(iop_base, IOPW_PC, word);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007747
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007748 /* finally, finally, gentlemen, start your engine */
7749 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007750
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007751 /*
7752 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
7753 * Resets should be performed. The RISC has to be running
7754 * to issue a SCSI Bus Reset.
7755 */
7756 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
7757 /*
7758 * If the BIOS Signature is present in memory, restore the
7759 * BIOS Handshake Configuration Table and do not perform
7760 * a SCSI Bus Reset.
7761 */
7762 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
7763 0x55AA) {
7764 /*
7765 * Restore per TID negotiated values.
7766 */
7767 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7768 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7769 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
7770 tagqng_able);
7771 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7772 AdvWriteByteLram(iop_base,
7773 ASC_MC_NUMBER_OF_MAX_CMD + tid,
7774 max_cmd[tid]);
7775 }
7776 } else {
7777 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
7778 warn_code = ASC_WARN_BUSRESET_ERROR;
7779 }
7780 }
7781 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007782
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007783 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007784}
7785
7786/*
7787 * Initialize the ASC-38C1600.
7788 *
7789 * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
7790 *
7791 * For a non-fatal error return a warning code. If there are no warnings
7792 * then 0 is returned.
7793 *
7794 * Needed after initialization for error recovery.
7795 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007796static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007797{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007798 AdvPortAddr iop_base;
7799 ushort warn_code;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007800 int begin_addr;
7801 int end_addr;
7802 ushort code_sum;
7803 long word;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007804 int i;
7805 ushort scsi_cfg1;
7806 uchar byte;
7807 uchar tid;
7808 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
7809 ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
7810 uchar max_cmd[ASC_MAX_TID + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -07007811
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007812 /* If there is already an error, don't continue. */
7813 if (asc_dvc->err_code != 0) {
7814 return ADV_ERROR;
7815 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007816
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007817 /*
7818 * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
7819 */
7820 if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
7821 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
7822 return ADV_ERROR;
7823 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007824
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007825 warn_code = 0;
7826 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007827
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007828 /*
7829 * Save the RISC memory BIOS region before writing the microcode.
7830 * The BIOS may already be loaded and using its RISC LRAM region
7831 * so its region must be saved and restored.
7832 *
7833 * Note: This code makes the assumption, which is currently true,
7834 * that a chip reset does not clear RISC LRAM.
7835 */
7836 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7837 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7838 bios_mem[i]);
7839 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007840
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007841 /*
7842 * Save current per TID negotiated values.
7843 */
7844 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7845 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7846 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
7847 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
7848 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
7849 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
7850 max_cmd[tid]);
7851 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007852
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007853 /*
7854 * RAM BIST (Built-In Self Test)
7855 *
7856 * Address : I/O base + offset 0x38h register (byte).
7857 * Function: Bit 7-6(RW) : RAM mode
7858 * Normal Mode : 0x00
7859 * Pre-test Mode : 0x40
7860 * RAM Test Mode : 0x80
7861 * Bit 5 : unused
7862 * Bit 4(RO) : Done bit
7863 * Bit 3-0(RO) : Status
7864 * Host Error : 0x08
7865 * Int_RAM Error : 0x04
7866 * RISC Error : 0x02
7867 * SCSI Error : 0x01
7868 * No Error : 0x00
7869 *
7870 * Note: RAM BIST code should be put right here, before loading the
7871 * microcode and after saving the RISC memory BIOS region.
7872 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007873
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007874 /*
7875 * LRAM Pre-test
7876 *
7877 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
7878 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
7879 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
7880 * to NORMAL_MODE, return an error too.
7881 */
7882 for (i = 0; i < 2; i++) {
7883 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
Matthew Wilcoxb009bef62007-09-09 08:56:38 -06007884 mdelay(10); /* Wait for 10ms before reading back. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007885 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7886 if ((byte & RAM_TEST_DONE) == 0
7887 || (byte & 0x0F) != PRE_TEST_VALUE) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007888 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007889 return ADV_ERROR;
7890 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007891
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007892 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
Matthew Wilcoxb009bef62007-09-09 08:56:38 -06007893 mdelay(10); /* Wait for 10ms before reading back. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007894 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
7895 != NORMAL_VALUE) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007896 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007897 return ADV_ERROR;
7898 }
7899 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007900
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007901 /*
7902 * LRAM Test - It takes about 1.5 ms to run through the test.
7903 *
7904 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
7905 * If Done bit not set or Status not 0, save register byte, set the
7906 * err_code, and return an error.
7907 */
7908 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
Matthew Wilcoxb009bef62007-09-09 08:56:38 -06007909 mdelay(10); /* Wait for 10ms before checking status. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007910
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007911 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7912 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
7913 /* Get here if Done bit not set or Status not 0. */
7914 asc_dvc->bist_err_code = byte; /* for BIOS display message */
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007915 asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007916 return ADV_ERROR;
7917 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007918
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007919 /* We need to reset back to normal mode after LRAM test passes. */
7920 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007921
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007922 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
7923 _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
7924 _adv_asc38C1600_chksum);
7925 if (asc_dvc->err_code)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007926 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007927
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007928 /*
7929 * Restore the RISC memory BIOS region.
7930 */
7931 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7932 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7933 bios_mem[i]);
7934 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007935
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007936 /*
7937 * Calculate and write the microcode code checksum to the microcode
7938 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
7939 */
7940 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
7941 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
7942 code_sum = 0;
7943 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
7944 for (word = begin_addr; word < end_addr; word += 2) {
7945 code_sum += AdvReadWordAutoIncLram(iop_base);
7946 }
7947 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007948
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007949 /*
7950 * Read microcode version and date.
7951 */
7952 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
7953 asc_dvc->cfg->mcode_date);
7954 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
7955 asc_dvc->cfg->mcode_version);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007956
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007957 /*
7958 * Set the chip type to indicate the ASC38C1600.
7959 */
7960 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007961
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007962 /*
7963 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
7964 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
7965 * cable detection and then we are able to read C_DET[3:0].
7966 *
7967 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
7968 * Microcode Default Value' section below.
7969 */
7970 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
7971 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
7972 scsi_cfg1 | DIS_TERM_DRV);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007973
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007974 /*
7975 * If the PCI Configuration Command Register "Parity Error Response
7976 * Control" Bit was clear (0), then set the microcode variable
7977 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
7978 * to ignore DMA parity errors.
7979 */
7980 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
7981 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7982 word |= CONTROL_FLAG_IGNORE_PERR;
7983 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7984 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007985
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007986 /*
7987 * If the BIOS control flag AIPP (Asynchronous Information
7988 * Phase Protection) disable bit is not set, then set the firmware
7989 * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
7990 * AIPP checking and encoding.
7991 */
7992 if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
7993 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7994 word |= CONTROL_FLAG_ENABLE_AIPP;
7995 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7996 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007997
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007998 /*
7999 * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
8000 * and START_CTL_TH [3:2].
8001 */
8002 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
8003 FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008004
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008005 /*
8006 * Microcode operating variables for WDTR, SDTR, and command tag
Matthew Wilcox47d853c2007-07-26 11:41:33 -04008007 * queuing will be set in slave_configure() based on what a
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008008 * device reports it is capable of in Inquiry byte 7.
8009 *
8010 * If SCSI Bus Resets have been disabled, then directly set
8011 * SDTR and WDTR from the EEPROM configuration. This will allow
8012 * the BIOS and warm boot to work without a SCSI bus hang on
8013 * the Inquiry caused by host and target mismatched DTR values.
8014 * Without the SCSI Bus Reset, before an Inquiry a device can't
8015 * be assumed to be in Asynchronous, Narrow mode.
8016 */
8017 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
8018 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
8019 asc_dvc->wdtr_able);
8020 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
8021 asc_dvc->sdtr_able);
8022 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07008023
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008024 /*
8025 * Set microcode operating variables for DISC and SDTR_SPEED1,
8026 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
8027 * configuration values.
8028 *
8029 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
8030 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
8031 * without determining here whether the device supports SDTR.
8032 */
8033 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
8034 asc_dvc->cfg->disc_enable);
8035 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
8036 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
8037 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
8038 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008039
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008040 /*
8041 * Set SCSI_CFG0 Microcode Default Value.
8042 *
8043 * The microcode will set the SCSI_CFG0 register using this value
8044 * after it is started below.
8045 */
8046 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
8047 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
8048 asc_dvc->chip_scsi_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008049
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008050 /*
8051 * Calculate SCSI_CFG1 Microcode Default Value.
8052 *
8053 * The microcode will set the SCSI_CFG1 register using this value
8054 * after it is started below.
8055 *
8056 * Each ASC-38C1600 function has only two cable detect bits.
8057 * The bus mode override bits are in IOPB_SOFT_OVER_WR.
8058 */
8059 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008060
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008061 /*
8062 * If the cable is reversed all of the SCSI_CTRL register signals
8063 * will be set. Check for and return an error if this condition is
8064 * found.
8065 */
8066 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
8067 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
8068 return ADV_ERROR;
8069 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07008070
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008071 /*
8072 * Each ASC-38C1600 function has two connectors. Only an HVD device
8073 * can not be connected to either connector. An LVD device or SE device
8074 * may be connected to either connecor. If an SE device is connected,
8075 * then at most Ultra speed (20 Mhz) can be used on both connectors.
8076 *
8077 * If an HVD device is attached, return an error.
8078 */
8079 if (scsi_cfg1 & HVD) {
8080 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
8081 return ADV_ERROR;
8082 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07008083
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008084 /*
8085 * Each function in the ASC-38C1600 uses only the SE cable detect and
8086 * termination because there are two connectors for each function. Each
8087 * function may use either LVD or SE mode. Corresponding the SE automatic
8088 * termination control EEPROM bits are used for each function. Each
8089 * function has its own EEPROM. If SE automatic control is enabled for
8090 * the function, then set the termination value based on a table listed
8091 * in a_condor.h.
8092 *
8093 * If manual termination is specified in the EEPROM for the function,
8094 * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
8095 * ready to be 'ored' into SCSI_CFG1.
8096 */
8097 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
Matthew Wilcox13ac2d92007-07-30 08:10:23 -06008098 struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008099 /* SE automatic termination control is enabled. */
8100 switch (scsi_cfg1 & C_DET_SE) {
8101 /* TERM_SE_HI: on, TERM_SE_LO: on */
8102 case 0x1:
8103 case 0x2:
8104 case 0x3:
8105 asc_dvc->cfg->termination |= TERM_SE;
8106 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07008107
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008108 case 0x0:
Matthew Wilcox13ac2d92007-07-30 08:10:23 -06008109 if (PCI_FUNC(pdev->devfn) == 0) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008110 /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
8111 } else {
8112 /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
8113 asc_dvc->cfg->termination |= TERM_SE_HI;
8114 }
8115 break;
8116 }
8117 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07008118
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008119 /*
8120 * Clear any set TERM_SE bits.
8121 */
8122 scsi_cfg1 &= ~TERM_SE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07008123
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008124 /*
8125 * Invert the TERM_SE bits and then set 'scsi_cfg1'.
8126 */
8127 scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008128
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008129 /*
8130 * Clear Big Endian and Terminator Polarity bits and set possibly
8131 * modified termination control bits in the Microcode SCSI_CFG1
8132 * Register Value.
8133 *
8134 * Big Endian bit is not used even on big endian machines.
8135 */
8136 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008137
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008138 /*
8139 * Set SCSI_CFG1 Microcode Default Value
8140 *
8141 * Set possibly modified termination control bits in the Microcode
8142 * SCSI_CFG1 Register Value.
8143 *
8144 * The microcode will set the SCSI_CFG1 register using this value
8145 * after it is started below.
8146 */
8147 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008148
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008149 /*
8150 * Set MEM_CFG Microcode Default Value
8151 *
8152 * The microcode will set the MEM_CFG register using this value
8153 * after it is started below.
8154 *
8155 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
8156 * are defined.
8157 *
8158 * ASC-38C1600 has 32KB internal memory.
8159 *
8160 * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
8161 * out a special 16K Adv Library and Microcode version. After the issue
8162 * resolved, we should turn back to the 32K support. Both a_condor.h and
8163 * mcode.sas files also need to be updated.
8164 *
8165 * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
8166 * BIOS_EN | RAM_SZ_32KB);
8167 */
8168 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
8169 BIOS_EN | RAM_SZ_16KB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008170
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008171 /*
8172 * Set SEL_MASK Microcode Default Value
8173 *
8174 * The microcode will set the SEL_MASK register using this value
8175 * after it is started below.
8176 */
8177 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
8178 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -07008179
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06008180 AdvBuildCarrierFreelist(asc_dvc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008181
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008182 /*
8183 * Set-up the Host->RISC Initiator Command Queue (ICQ).
8184 */
8185 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
8186 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
8187 return ADV_ERROR;
8188 }
8189 asc_dvc->carr_freelist = (ADV_CARR_T *)
8190 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07008191
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008192 /*
8193 * The first command issued will be placed in the stopper carrier.
8194 */
8195 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008196
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008197 /*
8198 * Set RISC ICQ physical address start value. Initialize the
8199 * COMMA register to the same value otherwise the RISC will
8200 * prematurely detect a command is available.
8201 */
8202 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
8203 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
8204 le32_to_cpu(asc_dvc->icq_sp->carr_pa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07008205
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008206 /*
8207 * Set-up the RISC->Host Initiator Response Queue (IRQ).
8208 */
8209 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
8210 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
8211 return ADV_ERROR;
8212 }
8213 asc_dvc->carr_freelist = (ADV_CARR_T *)
8214 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07008215
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008216 /*
8217 * The first command completed by the RISC will be placed in
8218 * the stopper.
8219 *
8220 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
8221 * completed the RISC will set the ASC_RQ_STOPPER bit.
8222 */
8223 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008224
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008225 /*
8226 * Set RISC IRQ physical address start value.
8227 */
8228 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
8229 asc_dvc->carr_pending_cnt = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07008230
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008231 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
8232 (ADV_INTR_ENABLE_HOST_INTR |
8233 ADV_INTR_ENABLE_GLOBAL_INTR));
8234 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
8235 AdvWriteWordRegister(iop_base, IOPW_PC, word);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008236
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008237 /* finally, finally, gentlemen, start your engine */
8238 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07008239
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008240 /*
8241 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
8242 * Resets should be performed. The RISC has to be running
8243 * to issue a SCSI Bus Reset.
8244 */
8245 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
8246 /*
8247 * If the BIOS Signature is present in memory, restore the
8248 * per TID microcode operating variables.
8249 */
8250 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
8251 0x55AA) {
8252 /*
8253 * Restore per TID negotiated values.
8254 */
8255 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8256 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8257 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
8258 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
8259 tagqng_able);
8260 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
8261 AdvWriteByteLram(iop_base,
8262 ASC_MC_NUMBER_OF_MAX_CMD + tid,
8263 max_cmd[tid]);
8264 }
8265 } else {
8266 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
8267 warn_code = ASC_WARN_BUSRESET_ERROR;
8268 }
8269 }
8270 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07008271
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008272 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07008273}
8274
8275/*
Matthew Wilcox51219352007-10-02 21:55:22 -04008276 * Reset chip and SCSI Bus.
8277 *
8278 * Return Value:
8279 * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
8280 * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
8281 */
8282static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
8283{
8284 int status;
8285 ushort wdtr_able, sdtr_able, tagqng_able;
8286 ushort ppr_able = 0;
8287 uchar tid, max_cmd[ADV_MAX_TID + 1];
8288 AdvPortAddr iop_base;
8289 ushort bios_sig;
8290
8291 iop_base = asc_dvc->iop_base;
8292
8293 /*
8294 * Save current per TID negotiated values.
8295 */
8296 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8297 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8298 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8299 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
8300 }
8301 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
8302 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
8303 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
8304 max_cmd[tid]);
8305 }
8306
8307 /*
8308 * Force the AdvInitAsc3550/38C0800Driver() function to
8309 * perform a SCSI Bus Reset by clearing the BIOS signature word.
8310 * The initialization functions assumes a SCSI Bus Reset is not
8311 * needed if the BIOS signature word is present.
8312 */
8313 AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
8314 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
8315
8316 /*
8317 * Stop chip and reset it.
8318 */
8319 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
8320 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
8321 mdelay(100);
8322 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
8323 ADV_CTRL_REG_CMD_WR_IO_REG);
8324
8325 /*
8326 * Reset Adv Library error code, if any, and try
8327 * re-initializing the chip.
8328 */
8329 asc_dvc->err_code = 0;
8330 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8331 status = AdvInitAsc38C1600Driver(asc_dvc);
8332 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
8333 status = AdvInitAsc38C0800Driver(asc_dvc);
8334 } else {
8335 status = AdvInitAsc3550Driver(asc_dvc);
8336 }
8337
8338 /* Translate initialization return value to status value. */
8339 if (status == 0) {
8340 status = ADV_TRUE;
8341 } else {
8342 status = ADV_FALSE;
8343 }
8344
8345 /*
8346 * Restore the BIOS signature word.
8347 */
8348 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
8349
8350 /*
8351 * Restore per TID negotiated values.
8352 */
8353 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8354 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8355 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8356 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
8357 }
8358 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
8359 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
8360 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
8361 max_cmd[tid]);
8362 }
8363
8364 return status;
8365}
8366
8367/*
8368 * adv_async_callback() - Adv Library asynchronous event callback function.
8369 */
8370static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
8371{
8372 switch (code) {
8373 case ADV_ASYNC_SCSI_BUS_RESET_DET:
8374 /*
8375 * The firmware detected a SCSI Bus reset.
8376 */
8377 ASC_DBG(0,
8378 "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
8379 break;
8380
8381 case ADV_ASYNC_RDMA_FAILURE:
8382 /*
8383 * Handle RDMA failure by resetting the SCSI Bus and
8384 * possibly the chip if it is unresponsive. Log the error
8385 * with a unique code.
8386 */
8387 ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
8388 AdvResetChipAndSB(adv_dvc_varp);
8389 break;
8390
8391 case ADV_HOST_SCSI_BUS_RESET:
8392 /*
8393 * Host generated SCSI bus reset occurred.
8394 */
8395 ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
8396 break;
8397
8398 default:
8399 ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
8400 break;
8401 }
8402}
8403
8404/*
8405 * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
8406 *
8407 * Callback function for the Wide SCSI Adv Library.
8408 */
8409static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
8410{
8411 asc_board_t *boardp;
8412 adv_req_t *reqp;
8413 adv_sgblk_t *sgblkp;
8414 struct scsi_cmnd *scp;
8415 struct Scsi_Host *shost;
8416 ADV_DCNT resid_cnt;
8417
8418 ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
8419 (ulong)adv_dvc_varp, (ulong)scsiqp);
8420 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
8421
8422 /*
8423 * Get the adv_req_t structure for the command that has been
8424 * completed. The adv_req_t structure actually contains the
8425 * completed ADV_SCSI_REQ_Q structure.
8426 */
8427 reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
8428 ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
8429 if (reqp == NULL) {
8430 ASC_PRINT("adv_isr_callback: reqp is NULL\n");
8431 return;
8432 }
8433
8434 /*
8435 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
8436 * command that has been completed.
8437 *
8438 * Note: The adv_req_t request structure and adv_sgblk_t structure,
8439 * if any, are dropped, because a board structure pointer can not be
8440 * determined.
8441 */
8442 scp = reqp->cmndp;
8443 ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
8444 if (scp == NULL) {
8445 ASC_PRINT
8446 ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
8447 return;
8448 }
8449 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
8450
8451 shost = scp->device->host;
8452 ASC_STATS(shost, callback);
8453 ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
8454
8455 boardp = ASC_BOARDP(shost);
8456 BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
8457
8458 /*
8459 * 'done_status' contains the command's ending status.
8460 */
8461 switch (scsiqp->done_status) {
8462 case QD_NO_ERROR:
8463 ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
8464 scp->result = 0;
8465
8466 /*
8467 * Check for an underrun condition.
8468 *
8469 * If there was no error and an underrun condition, then
8470 * then return the number of underrun bytes.
8471 */
8472 resid_cnt = le32_to_cpu(scsiqp->data_cnt);
8473 if (scp->request_bufflen != 0 && resid_cnt != 0 &&
8474 resid_cnt <= scp->request_bufflen) {
8475 ASC_DBG1(1,
8476 "adv_isr_callback: underrun condition %lu bytes\n",
8477 (ulong)resid_cnt);
8478 scp->resid = resid_cnt;
8479 }
8480 break;
8481
8482 case QD_WITH_ERROR:
8483 ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
8484 switch (scsiqp->host_status) {
8485 case QHSTA_NO_ERROR:
8486 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
8487 ASC_DBG(2,
8488 "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
8489 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
8490 sizeof(scp->sense_buffer));
8491 /*
8492 * Note: The 'status_byte()' macro used by
8493 * target drivers defined in scsi.h shifts the
8494 * status byte returned by host drivers right
8495 * by 1 bit. This is why target drivers also
8496 * use right shifted status byte definitions.
8497 * For instance target drivers use
8498 * CHECK_CONDITION, defined to 0x1, instead of
8499 * the SCSI defined check condition value of
8500 * 0x2. Host drivers are supposed to return
8501 * the status byte as it is defined by SCSI.
8502 */
8503 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
8504 STATUS_BYTE(scsiqp->scsi_status);
8505 } else {
8506 scp->result = STATUS_BYTE(scsiqp->scsi_status);
8507 }
8508 break;
8509
8510 default:
8511 /* Some other QHSTA error occurred. */
8512 ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
8513 scsiqp->host_status);
8514 scp->result = HOST_BYTE(DID_BAD_TARGET);
8515 break;
8516 }
8517 break;
8518
8519 case QD_ABORTED_BY_HOST:
8520 ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
8521 scp->result =
8522 HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
8523 break;
8524
8525 default:
8526 ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
8527 scsiqp->done_status);
8528 scp->result =
8529 HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
8530 break;
8531 }
8532
8533 /*
8534 * If the 'init_tidmask' bit isn't already set for the target and the
8535 * current request finished normally, then set the bit for the target
8536 * to indicate that a device is present.
8537 */
8538 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
8539 scsiqp->done_status == QD_NO_ERROR &&
8540 scsiqp->host_status == QHSTA_NO_ERROR) {
8541 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
8542 }
8543
8544 asc_scsi_done(scp);
8545
8546 /*
8547 * Free all 'adv_sgblk_t' structures allocated for the request.
8548 */
8549 while ((sgblkp = reqp->sgblkp) != NULL) {
8550 /* Remove 'sgblkp' from the request list. */
8551 reqp->sgblkp = sgblkp->next_sgblkp;
8552
8553 /* Add 'sgblkp' to the board free list. */
8554 sgblkp->next_sgblkp = boardp->adv_sgblkp;
8555 boardp->adv_sgblkp = sgblkp;
8556 }
8557
8558 /*
8559 * Free the adv_req_t structure used with the command by adding
8560 * it back to the board free list.
8561 */
8562 reqp->next_reqp = boardp->adv_reqp;
8563 boardp->adv_reqp = reqp;
8564
8565 ASC_DBG(1, "adv_isr_callback: done\n");
8566
8567 return;
8568}
8569
8570/*
8571 * Adv Library Interrupt Service Routine
8572 *
8573 * This function is called by a driver's interrupt service routine.
8574 * The function disables and re-enables interrupts.
8575 *
8576 * When a microcode idle command is completed, the ADV_DVC_VAR
8577 * 'idle_cmd_done' field is set to ADV_TRUE.
8578 *
8579 * Note: AdvISR() can be called when interrupts are disabled or even
8580 * when there is no hardware interrupt condition present. It will
8581 * always check for completed idle commands and microcode requests.
8582 * This is an important feature that shouldn't be changed because it
8583 * allows commands to be completed from polling mode loops.
8584 *
8585 * Return:
8586 * ADV_TRUE(1) - interrupt was pending
8587 * ADV_FALSE(0) - no interrupt was pending
8588 */
8589static int AdvISR(ADV_DVC_VAR *asc_dvc)
8590{
8591 AdvPortAddr iop_base;
8592 uchar int_stat;
8593 ushort target_bit;
8594 ADV_CARR_T *free_carrp;
8595 ADV_VADDR irq_next_vpa;
8596 ADV_SCSI_REQ_Q *scsiq;
8597
8598 iop_base = asc_dvc->iop_base;
8599
8600 /* Reading the register clears the interrupt. */
8601 int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
8602
8603 if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
8604 ADV_INTR_STATUS_INTRC)) == 0) {
8605 return ADV_FALSE;
8606 }
8607
8608 /*
8609 * Notify the driver of an asynchronous microcode condition by
8610 * calling the adv_async_callback function. The function
8611 * is passed the microcode ASC_MC_INTRB_CODE byte value.
8612 */
8613 if (int_stat & ADV_INTR_STATUS_INTRB) {
8614 uchar intrb_code;
8615
8616 AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
8617
8618 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
8619 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
8620 if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
8621 asc_dvc->carr_pending_cnt != 0) {
8622 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
8623 ADV_TICKLE_A);
8624 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
8625 AdvWriteByteRegister(iop_base,
8626 IOPB_TICKLE,
8627 ADV_TICKLE_NOP);
8628 }
8629 }
8630 }
8631
8632 adv_async_callback(asc_dvc, intrb_code);
8633 }
8634
8635 /*
8636 * Check if the IRQ stopper carrier contains a completed request.
8637 */
8638 while (((irq_next_vpa =
8639 le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
8640 /*
8641 * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
8642 * The RISC will have set 'areq_vpa' to a virtual address.
8643 *
8644 * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
8645 * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
8646 * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
8647 * in AdvExeScsiQueue().
8648 */
8649 scsiq = (ADV_SCSI_REQ_Q *)
8650 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
8651
8652 /*
8653 * Request finished with good status and the queue was not
8654 * DMAed to host memory by the firmware. Set all status fields
8655 * to indicate good status.
8656 */
8657 if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
8658 scsiq->done_status = QD_NO_ERROR;
8659 scsiq->host_status = scsiq->scsi_status = 0;
8660 scsiq->data_cnt = 0L;
8661 }
8662
8663 /*
8664 * Advance the stopper pointer to the next carrier
8665 * ignoring the lower four bits. Free the previous
8666 * stopper carrier.
8667 */
8668 free_carrp = asc_dvc->irq_sp;
8669 asc_dvc->irq_sp = (ADV_CARR_T *)
8670 ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
8671
8672 free_carrp->next_vpa =
8673 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
8674 asc_dvc->carr_freelist = free_carrp;
8675 asc_dvc->carr_pending_cnt--;
8676
8677 target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
8678
8679 /*
8680 * Clear request microcode control flag.
8681 */
8682 scsiq->cntl = 0;
8683
8684 /*
8685 * Notify the driver of the completed request by passing
8686 * the ADV_SCSI_REQ_Q pointer to its callback function.
8687 */
8688 scsiq->a_flag |= ADV_SCSIQ_DONE;
8689 adv_isr_callback(asc_dvc, scsiq);
8690 /*
8691 * Note: After the driver callback function is called, 'scsiq'
8692 * can no longer be referenced.
8693 *
8694 * Fall through and continue processing other completed
8695 * requests...
8696 */
8697 }
8698 return ADV_TRUE;
8699}
8700
8701static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
8702{
8703 if (asc_dvc->err_code == 0) {
8704 asc_dvc->err_code = err_code;
8705 AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
8706 err_code);
8707 }
8708 return err_code;
8709}
8710
8711static void AscAckInterrupt(PortAddr iop_base)
8712{
8713 uchar host_flag;
8714 uchar risc_flag;
8715 ushort loop;
8716
8717 loop = 0;
8718 do {
8719 risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
8720 if (loop++ > 0x7FFF) {
8721 break;
8722 }
8723 } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
8724 host_flag =
8725 AscReadLramByte(iop_base,
8726 ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
8727 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
8728 (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
8729 AscSetChipStatus(iop_base, CIW_INT_ACK);
8730 loop = 0;
8731 while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
8732 AscSetChipStatus(iop_base, CIW_INT_ACK);
8733 if (loop++ > 3) {
8734 break;
8735 }
8736 }
8737 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
8738 return;
8739}
8740
8741static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
8742{
8743 uchar *period_table;
8744 int max_index;
8745 int min_index;
8746 int i;
8747
8748 period_table = asc_dvc->sdtr_period_tbl;
8749 max_index = (int)asc_dvc->max_sdtr_index;
8750 min_index = (int)asc_dvc->host_init_sdtr_index;
8751 if ((syn_time <= period_table[max_index])) {
8752 for (i = min_index; i < (max_index - 1); i++) {
8753 if (syn_time <= period_table[i]) {
8754 return (uchar)i;
8755 }
8756 }
8757 return (uchar)max_index;
8758 } else {
8759 return (uchar)(max_index + 1);
8760 }
8761}
8762
8763static uchar
8764AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
8765{
8766 EXT_MSG sdtr_buf;
8767 uchar sdtr_period_index;
8768 PortAddr iop_base;
8769
8770 iop_base = asc_dvc->iop_base;
8771 sdtr_buf.msg_type = EXTENDED_MESSAGE;
8772 sdtr_buf.msg_len = MS_SDTR_LEN;
8773 sdtr_buf.msg_req = EXTENDED_SDTR;
8774 sdtr_buf.xfer_period = sdtr_period;
8775 sdtr_offset &= ASC_SYN_MAX_OFFSET;
8776 sdtr_buf.req_ack_offset = sdtr_offset;
8777 sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
8778 if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
8779 AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
8780 (uchar *)&sdtr_buf,
8781 sizeof(EXT_MSG) >> 1);
8782 return ((sdtr_period_index << 4) | sdtr_offset);
8783 } else {
8784 sdtr_buf.req_ack_offset = 0;
8785 AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
8786 (uchar *)&sdtr_buf,
8787 sizeof(EXT_MSG) >> 1);
8788 return 0;
8789 }
8790}
8791
8792static uchar
8793AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
8794{
8795 uchar byte;
8796 uchar sdtr_period_ix;
8797
8798 sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
8799 if (sdtr_period_ix > asc_dvc->max_sdtr_index) {
8800 return 0xFF;
8801 }
8802 byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
8803 return byte;
8804}
8805
8806static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
8807{
8808 ASC_SCSI_BIT_ID_TYPE org_id;
8809 int i;
8810 int sta = TRUE;
8811
8812 AscSetBank(iop_base, 1);
8813 org_id = AscReadChipDvcID(iop_base);
8814 for (i = 0; i <= ASC_MAX_TID; i++) {
8815 if (org_id == (0x01 << i))
8816 break;
8817 }
8818 org_id = (ASC_SCSI_BIT_ID_TYPE) i;
8819 AscWriteChipDvcID(iop_base, id);
8820 if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
8821 AscSetBank(iop_base, 0);
8822 AscSetChipSyn(iop_base, sdtr_data);
8823 if (AscGetChipSyn(iop_base) != sdtr_data) {
8824 sta = FALSE;
8825 }
8826 } else {
8827 sta = FALSE;
8828 }
8829 AscSetBank(iop_base, 1);
8830 AscWriteChipDvcID(iop_base, org_id);
8831 AscSetBank(iop_base, 0);
8832 return (sta);
8833}
8834
8835static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
8836{
8837 AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
8838 AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
8839}
8840
8841static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
8842{
8843 EXT_MSG ext_msg;
8844 EXT_MSG out_msg;
8845 ushort halt_q_addr;
8846 int sdtr_accept;
8847 ushort int_halt_code;
8848 ASC_SCSI_BIT_ID_TYPE scsi_busy;
8849 ASC_SCSI_BIT_ID_TYPE target_id;
8850 PortAddr iop_base;
8851 uchar tag_code;
8852 uchar q_status;
8853 uchar halt_qp;
8854 uchar sdtr_data;
8855 uchar target_ix;
8856 uchar q_cntl, tid_no;
8857 uchar cur_dvc_qng;
8858 uchar asyn_sdtr;
8859 uchar scsi_status;
8860 asc_board_t *boardp;
8861
8862 BUG_ON(!asc_dvc->drv_ptr);
8863 boardp = asc_dvc->drv_ptr;
8864
8865 iop_base = asc_dvc->iop_base;
8866 int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
8867
8868 halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
8869 halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
8870 target_ix = AscReadLramByte(iop_base,
8871 (ushort)(halt_q_addr +
8872 (ushort)ASC_SCSIQ_B_TARGET_IX));
8873 q_cntl = AscReadLramByte(iop_base,
8874 (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
8875 tid_no = ASC_TIX_TO_TID(target_ix);
8876 target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
8877 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8878 asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
8879 } else {
8880 asyn_sdtr = 0;
8881 }
8882 if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
8883 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8884 AscSetChipSDTR(iop_base, 0, tid_no);
8885 boardp->sdtr_data[tid_no] = 0;
8886 }
8887 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8888 return (0);
8889 } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
8890 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8891 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8892 boardp->sdtr_data[tid_no] = asyn_sdtr;
8893 }
8894 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8895 return (0);
8896 } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
8897 AscMemWordCopyPtrFromLram(iop_base,
8898 ASCV_MSGIN_BEG,
8899 (uchar *)&ext_msg,
8900 sizeof(EXT_MSG) >> 1);
8901
8902 if (ext_msg.msg_type == EXTENDED_MESSAGE &&
8903 ext_msg.msg_req == EXTENDED_SDTR &&
8904 ext_msg.msg_len == MS_SDTR_LEN) {
8905 sdtr_accept = TRUE;
8906 if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
8907
8908 sdtr_accept = FALSE;
8909 ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
8910 }
8911 if ((ext_msg.xfer_period <
8912 asc_dvc->sdtr_period_tbl[asc_dvc->
8913 host_init_sdtr_index])
8914 || (ext_msg.xfer_period >
8915 asc_dvc->sdtr_period_tbl[asc_dvc->
8916 max_sdtr_index])) {
8917 sdtr_accept = FALSE;
8918 ext_msg.xfer_period =
8919 asc_dvc->sdtr_period_tbl[asc_dvc->
8920 host_init_sdtr_index];
8921 }
8922 if (sdtr_accept) {
8923 sdtr_data =
8924 AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
8925 ext_msg.req_ack_offset);
8926 if ((sdtr_data == 0xFF)) {
8927
8928 q_cntl |= QC_MSG_OUT;
8929 asc_dvc->init_sdtr &= ~target_id;
8930 asc_dvc->sdtr_done &= ~target_id;
8931 AscSetChipSDTR(iop_base, asyn_sdtr,
8932 tid_no);
8933 boardp->sdtr_data[tid_no] = asyn_sdtr;
8934 }
8935 }
8936 if (ext_msg.req_ack_offset == 0) {
8937
8938 q_cntl &= ~QC_MSG_OUT;
8939 asc_dvc->init_sdtr &= ~target_id;
8940 asc_dvc->sdtr_done &= ~target_id;
8941 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8942 } else {
8943 if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
8944
8945 q_cntl &= ~QC_MSG_OUT;
8946 asc_dvc->sdtr_done |= target_id;
8947 asc_dvc->init_sdtr |= target_id;
8948 asc_dvc->pci_fix_asyn_xfer &=
8949 ~target_id;
8950 sdtr_data =
8951 AscCalSDTRData(asc_dvc,
8952 ext_msg.xfer_period,
8953 ext_msg.
8954 req_ack_offset);
8955 AscSetChipSDTR(iop_base, sdtr_data,
8956 tid_no);
8957 boardp->sdtr_data[tid_no] = sdtr_data;
8958 } else {
8959
8960 q_cntl |= QC_MSG_OUT;
8961 AscMsgOutSDTR(asc_dvc,
8962 ext_msg.xfer_period,
8963 ext_msg.req_ack_offset);
8964 asc_dvc->pci_fix_asyn_xfer &=
8965 ~target_id;
8966 sdtr_data =
8967 AscCalSDTRData(asc_dvc,
8968 ext_msg.xfer_period,
8969 ext_msg.
8970 req_ack_offset);
8971 AscSetChipSDTR(iop_base, sdtr_data,
8972 tid_no);
8973 boardp->sdtr_data[tid_no] = sdtr_data;
8974 asc_dvc->sdtr_done |= target_id;
8975 asc_dvc->init_sdtr |= target_id;
8976 }
8977 }
8978
8979 AscWriteLramByte(iop_base,
8980 (ushort)(halt_q_addr +
8981 (ushort)ASC_SCSIQ_B_CNTL),
8982 q_cntl);
8983 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8984 return (0);
8985 } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
8986 ext_msg.msg_req == EXTENDED_WDTR &&
8987 ext_msg.msg_len == MS_WDTR_LEN) {
8988
8989 ext_msg.wdtr_width = 0;
8990 AscMemWordCopyPtrToLram(iop_base,
8991 ASCV_MSGOUT_BEG,
8992 (uchar *)&ext_msg,
8993 sizeof(EXT_MSG) >> 1);
8994 q_cntl |= QC_MSG_OUT;
8995 AscWriteLramByte(iop_base,
8996 (ushort)(halt_q_addr +
8997 (ushort)ASC_SCSIQ_B_CNTL),
8998 q_cntl);
8999 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9000 return (0);
9001 } else {
9002
9003 ext_msg.msg_type = MESSAGE_REJECT;
9004 AscMemWordCopyPtrToLram(iop_base,
9005 ASCV_MSGOUT_BEG,
9006 (uchar *)&ext_msg,
9007 sizeof(EXT_MSG) >> 1);
9008 q_cntl |= QC_MSG_OUT;
9009 AscWriteLramByte(iop_base,
9010 (ushort)(halt_q_addr +
9011 (ushort)ASC_SCSIQ_B_CNTL),
9012 q_cntl);
9013 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9014 return (0);
9015 }
9016 } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
9017
9018 q_cntl |= QC_REQ_SENSE;
9019
9020 if ((asc_dvc->init_sdtr & target_id) != 0) {
9021
9022 asc_dvc->sdtr_done &= ~target_id;
9023
9024 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
9025 q_cntl |= QC_MSG_OUT;
9026 AscMsgOutSDTR(asc_dvc,
9027 asc_dvc->
9028 sdtr_period_tbl[(sdtr_data >> 4) &
9029 (uchar)(asc_dvc->
9030 max_sdtr_index -
9031 1)],
9032 (uchar)(sdtr_data & (uchar)
9033 ASC_SYN_MAX_OFFSET));
9034 }
9035
9036 AscWriteLramByte(iop_base,
9037 (ushort)(halt_q_addr +
9038 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
9039
9040 tag_code = AscReadLramByte(iop_base,
9041 (ushort)(halt_q_addr + (ushort)
9042 ASC_SCSIQ_B_TAG_CODE));
9043 tag_code &= 0xDC;
9044 if ((asc_dvc->pci_fix_asyn_xfer & target_id)
9045 && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
9046 ) {
9047
9048 tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
9049 | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
9050
9051 }
9052 AscWriteLramByte(iop_base,
9053 (ushort)(halt_q_addr +
9054 (ushort)ASC_SCSIQ_B_TAG_CODE),
9055 tag_code);
9056
9057 q_status = AscReadLramByte(iop_base,
9058 (ushort)(halt_q_addr + (ushort)
9059 ASC_SCSIQ_B_STATUS));
9060 q_status |= (QS_READY | QS_BUSY);
9061 AscWriteLramByte(iop_base,
9062 (ushort)(halt_q_addr +
9063 (ushort)ASC_SCSIQ_B_STATUS),
9064 q_status);
9065
9066 scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
9067 scsi_busy &= ~target_id;
9068 AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
9069
9070 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9071 return (0);
9072 } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
9073
9074 AscMemWordCopyPtrFromLram(iop_base,
9075 ASCV_MSGOUT_BEG,
9076 (uchar *)&out_msg,
9077 sizeof(EXT_MSG) >> 1);
9078
9079 if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
9080 (out_msg.msg_len == MS_SDTR_LEN) &&
9081 (out_msg.msg_req == EXTENDED_SDTR)) {
9082
9083 asc_dvc->init_sdtr &= ~target_id;
9084 asc_dvc->sdtr_done &= ~target_id;
9085 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
9086 boardp->sdtr_data[tid_no] = asyn_sdtr;
9087 }
9088 q_cntl &= ~QC_MSG_OUT;
9089 AscWriteLramByte(iop_base,
9090 (ushort)(halt_q_addr +
9091 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
9092 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9093 return (0);
9094 } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
9095
9096 scsi_status = AscReadLramByte(iop_base,
9097 (ushort)((ushort)halt_q_addr +
9098 (ushort)
9099 ASC_SCSIQ_SCSI_STATUS));
9100 cur_dvc_qng =
9101 AscReadLramByte(iop_base,
9102 (ushort)((ushort)ASC_QADR_BEG +
9103 (ushort)target_ix));
9104 if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
9105
9106 scsi_busy = AscReadLramByte(iop_base,
9107 (ushort)ASCV_SCSIBUSY_B);
9108 scsi_busy |= target_id;
9109 AscWriteLramByte(iop_base,
9110 (ushort)ASCV_SCSIBUSY_B, scsi_busy);
9111 asc_dvc->queue_full_or_busy |= target_id;
9112
9113 if (scsi_status == SAM_STAT_TASK_SET_FULL) {
9114 if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
9115 cur_dvc_qng -= 1;
9116 asc_dvc->max_dvc_qng[tid_no] =
9117 cur_dvc_qng;
9118
9119 AscWriteLramByte(iop_base,
9120 (ushort)((ushort)
9121 ASCV_MAX_DVC_QNG_BEG
9122 + (ushort)
9123 tid_no),
9124 cur_dvc_qng);
9125
9126 /*
9127 * Set the device queue depth to the
9128 * number of active requests when the
9129 * QUEUE FULL condition was encountered.
9130 */
9131 boardp->queue_full |= target_id;
9132 boardp->queue_full_cnt[tid_no] =
9133 cur_dvc_qng;
9134 }
9135 }
9136 }
9137 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9138 return (0);
9139 }
9140#if CC_VERY_LONG_SG_LIST
9141 else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
9142 uchar q_no;
9143 ushort q_addr;
9144 uchar sg_wk_q_no;
9145 uchar first_sg_wk_q_no;
9146 ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
9147 ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
9148 ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
9149 ushort sg_list_dwords;
9150 ushort sg_entry_cnt;
9151 uchar next_qp;
9152 int i;
9153
9154 q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
9155 if (q_no == ASC_QLINK_END)
9156 return 0;
9157
9158 q_addr = ASC_QNO_TO_QADDR(q_no);
9159
9160 /*
9161 * Convert the request's SRB pointer to a host ASC_SCSI_REQ
9162 * structure pointer using a macro provided by the driver.
9163 * The ASC_SCSI_REQ pointer provides a pointer to the
9164 * host ASC_SG_HEAD structure.
9165 */
9166 /* Read request's SRB pointer. */
9167 scsiq = (ASC_SCSI_Q *)
9168 ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
9169 (ushort)
9170 (q_addr +
9171 ASC_SCSIQ_D_SRBPTR))));
9172
9173 /*
9174 * Get request's first and working SG queue.
9175 */
9176 sg_wk_q_no = AscReadLramByte(iop_base,
9177 (ushort)(q_addr +
9178 ASC_SCSIQ_B_SG_WK_QP));
9179
9180 first_sg_wk_q_no = AscReadLramByte(iop_base,
9181 (ushort)(q_addr +
9182 ASC_SCSIQ_B_FIRST_SG_WK_QP));
9183
9184 /*
9185 * Reset request's working SG queue back to the
9186 * first SG queue.
9187 */
9188 AscWriteLramByte(iop_base,
9189 (ushort)(q_addr +
9190 (ushort)ASC_SCSIQ_B_SG_WK_QP),
9191 first_sg_wk_q_no);
9192
9193 sg_head = scsiq->sg_head;
9194
9195 /*
9196 * Set sg_entry_cnt to the number of SG elements
9197 * that will be completed on this interrupt.
9198 *
9199 * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
9200 * SG elements. The data_cnt and data_addr fields which
9201 * add 1 to the SG element capacity are not used when
9202 * restarting SG handling after a halt.
9203 */
9204 if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
9205 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
9206
9207 /*
9208 * Keep track of remaining number of SG elements that
9209 * will need to be handled on the next interrupt.
9210 */
9211 scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
9212 } else {
9213 sg_entry_cnt = scsiq->remain_sg_entry_cnt;
9214 scsiq->remain_sg_entry_cnt = 0;
9215 }
9216
9217 /*
9218 * Copy SG elements into the list of allocated SG queues.
9219 *
9220 * Last index completed is saved in scsiq->next_sg_index.
9221 */
9222 next_qp = first_sg_wk_q_no;
9223 q_addr = ASC_QNO_TO_QADDR(next_qp);
9224 scsi_sg_q.sg_head_qp = q_no;
9225 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
9226 for (i = 0; i < sg_head->queue_cnt; i++) {
9227 scsi_sg_q.seq_no = i + 1;
9228 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
9229 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
9230 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
9231 /*
9232 * After very first SG queue RISC FW uses next
9233 * SG queue first element then checks sg_list_cnt
9234 * against zero and then decrements, so set
9235 * sg_list_cnt 1 less than number of SG elements
9236 * in each SG queue.
9237 */
9238 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
9239 scsi_sg_q.sg_cur_list_cnt =
9240 ASC_SG_LIST_PER_Q - 1;
9241 } else {
9242 /*
9243 * This is the last SG queue in the list of
9244 * allocated SG queues. If there are more
9245 * SG elements than will fit in the allocated
9246 * queues, then set the QCSG_SG_XFER_MORE flag.
9247 */
9248 if (scsiq->remain_sg_entry_cnt != 0) {
9249 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
9250 } else {
9251 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
9252 }
9253 /* equals sg_entry_cnt * 2 */
9254 sg_list_dwords = sg_entry_cnt << 1;
9255 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
9256 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
9257 sg_entry_cnt = 0;
9258 }
9259
9260 scsi_sg_q.q_no = next_qp;
9261 AscMemWordCopyPtrToLram(iop_base,
9262 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
9263 (uchar *)&scsi_sg_q,
9264 sizeof(ASC_SG_LIST_Q) >> 1);
9265
9266 AscMemDWordCopyPtrToLram(iop_base,
9267 q_addr + ASC_SGQ_LIST_BEG,
9268 (uchar *)&sg_head->
9269 sg_list[scsiq->next_sg_index],
9270 sg_list_dwords);
9271
9272 scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
9273
9274 /*
9275 * If the just completed SG queue contained the
9276 * last SG element, then no more SG queues need
9277 * to be written.
9278 */
9279 if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
9280 break;
9281 }
9282
9283 next_qp = AscReadLramByte(iop_base,
9284 (ushort)(q_addr +
9285 ASC_SCSIQ_B_FWD));
9286 q_addr = ASC_QNO_TO_QADDR(next_qp);
9287 }
9288
9289 /*
9290 * Clear the halt condition so the RISC will be restarted
9291 * after the return.
9292 */
9293 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9294 return (0);
9295 }
9296#endif /* CC_VERY_LONG_SG_LIST */
9297 return (0);
9298}
9299
9300/*
9301 * void
9302 * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
9303 *
9304 * Calling/Exit State:
9305 * none
9306 *
9307 * Description:
9308 * Input an ASC_QDONE_INFO structure from the chip
9309 */
9310static void
9311DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
9312{
9313 int i;
9314 ushort word;
9315
9316 AscSetChipLramAddr(iop_base, s_addr);
9317 for (i = 0; i < 2 * words; i += 2) {
9318 if (i == 10) {
9319 continue;
9320 }
9321 word = inpw(iop_base + IOP_RAM_DATA);
9322 inbuf[i] = word & 0xff;
9323 inbuf[i + 1] = (word >> 8) & 0xff;
9324 }
9325 ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
9326}
9327
9328static uchar
9329_AscCopyLramScsiDoneQ(PortAddr iop_base,
9330 ushort q_addr,
9331 ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
9332{
9333 ushort _val;
9334 uchar sg_queue_cnt;
9335
9336 DvcGetQinfo(iop_base,
9337 q_addr + ASC_SCSIQ_DONE_INFO_BEG,
9338 (uchar *)scsiq,
9339 (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
9340
9341 _val = AscReadLramWord(iop_base,
9342 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
9343 scsiq->q_status = (uchar)_val;
9344 scsiq->q_no = (uchar)(_val >> 8);
9345 _val = AscReadLramWord(iop_base,
9346 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
9347 scsiq->cntl = (uchar)_val;
9348 sg_queue_cnt = (uchar)(_val >> 8);
9349 _val = AscReadLramWord(iop_base,
9350 (ushort)(q_addr +
9351 (ushort)ASC_SCSIQ_B_SENSE_LEN));
9352 scsiq->sense_len = (uchar)_val;
9353 scsiq->extra_bytes = (uchar)(_val >> 8);
9354
9355 /*
9356 * Read high word of remain bytes from alternate location.
9357 */
9358 scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
9359 (ushort)(q_addr +
9360 (ushort)
9361 ASC_SCSIQ_W_ALT_DC1)))
9362 << 16);
9363 /*
9364 * Read low word of remain bytes from original location.
9365 */
9366 scsiq->remain_bytes += AscReadLramWord(iop_base,
9367 (ushort)(q_addr + (ushort)
9368 ASC_SCSIQ_DW_REMAIN_XFER_CNT));
9369
9370 scsiq->remain_bytes &= max_dma_count;
9371 return sg_queue_cnt;
9372}
9373
9374/*
9375 * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
9376 *
9377 * Interrupt callback function for the Narrow SCSI Asc Library.
9378 */
9379static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
9380{
9381 asc_board_t *boardp;
9382 struct scsi_cmnd *scp;
9383 struct Scsi_Host *shost;
9384
9385 ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
9386 (ulong)asc_dvc_varp, (ulong)qdonep);
9387 ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
9388
9389 /*
9390 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
9391 * command that has been completed.
9392 */
9393 scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
9394 ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
9395
9396 if (scp == NULL) {
9397 ASC_PRINT("asc_isr_callback: scp is NULL\n");
9398 return;
9399 }
9400 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
9401
9402 shost = scp->device->host;
9403 ASC_STATS(shost, callback);
9404 ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
9405
9406 boardp = ASC_BOARDP(shost);
9407 BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
9408
9409 /*
9410 * 'qdonep' contains the command's ending status.
9411 */
9412 switch (qdonep->d3.done_stat) {
9413 case QD_NO_ERROR:
9414 ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
9415 scp->result = 0;
9416
9417 /*
9418 * Check for an underrun condition.
9419 *
9420 * If there was no error and an underrun condition, then
9421 * return the number of underrun bytes.
9422 */
9423 if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
9424 qdonep->remain_bytes <= scp->request_bufflen) {
9425 ASC_DBG1(1,
9426 "asc_isr_callback: underrun condition %u bytes\n",
9427 (unsigned)qdonep->remain_bytes);
9428 scp->resid = qdonep->remain_bytes;
9429 }
9430 break;
9431
9432 case QD_WITH_ERROR:
9433 ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
9434 switch (qdonep->d3.host_stat) {
9435 case QHSTA_NO_ERROR:
9436 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
9437 ASC_DBG(2,
9438 "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
9439 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
9440 sizeof(scp->sense_buffer));
9441 /*
9442 * Note: The 'status_byte()' macro used by
9443 * target drivers defined in scsi.h shifts the
9444 * status byte returned by host drivers right
9445 * by 1 bit. This is why target drivers also
9446 * use right shifted status byte definitions.
9447 * For instance target drivers use
9448 * CHECK_CONDITION, defined to 0x1, instead of
9449 * the SCSI defined check condition value of
9450 * 0x2. Host drivers are supposed to return
9451 * the status byte as it is defined by SCSI.
9452 */
9453 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
9454 STATUS_BYTE(qdonep->d3.scsi_stat);
9455 } else {
9456 scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
9457 }
9458 break;
9459
9460 default:
9461 /* QHSTA error occurred */
9462 ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
9463 qdonep->d3.host_stat);
9464 scp->result = HOST_BYTE(DID_BAD_TARGET);
9465 break;
9466 }
9467 break;
9468
9469 case QD_ABORTED_BY_HOST:
9470 ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
9471 scp->result =
9472 HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
9473 scsi_msg) |
9474 STATUS_BYTE(qdonep->d3.scsi_stat);
9475 break;
9476
9477 default:
9478 ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
9479 qdonep->d3.done_stat);
9480 scp->result =
9481 HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
9482 scsi_msg) |
9483 STATUS_BYTE(qdonep->d3.scsi_stat);
9484 break;
9485 }
9486
9487 /*
9488 * If the 'init_tidmask' bit isn't already set for the target and the
9489 * current request finished normally, then set the bit for the target
9490 * to indicate that a device is present.
9491 */
9492 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
9493 qdonep->d3.done_stat == QD_NO_ERROR &&
9494 qdonep->d3.host_stat == QHSTA_NO_ERROR) {
9495 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
9496 }
9497
9498 asc_scsi_done(scp);
9499
9500 return;
9501}
9502
9503static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
9504{
9505 uchar next_qp;
9506 uchar n_q_used;
9507 uchar sg_list_qp;
9508 uchar sg_queue_cnt;
9509 uchar q_cnt;
9510 uchar done_q_tail;
9511 uchar tid_no;
9512 ASC_SCSI_BIT_ID_TYPE scsi_busy;
9513 ASC_SCSI_BIT_ID_TYPE target_id;
9514 PortAddr iop_base;
9515 ushort q_addr;
9516 ushort sg_q_addr;
9517 uchar cur_target_qng;
9518 ASC_QDONE_INFO scsiq_buf;
9519 ASC_QDONE_INFO *scsiq;
9520 int false_overrun;
9521
9522 iop_base = asc_dvc->iop_base;
9523 n_q_used = 1;
9524 scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
9525 done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
9526 q_addr = ASC_QNO_TO_QADDR(done_q_tail);
9527 next_qp = AscReadLramByte(iop_base,
9528 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
9529 if (next_qp != ASC_QLINK_END) {
9530 AscPutVarDoneQTail(iop_base, next_qp);
9531 q_addr = ASC_QNO_TO_QADDR(next_qp);
9532 sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
9533 asc_dvc->max_dma_count);
9534 AscWriteLramByte(iop_base,
9535 (ushort)(q_addr +
9536 (ushort)ASC_SCSIQ_B_STATUS),
9537 (uchar)(scsiq->
9538 q_status & (uchar)~(QS_READY |
9539 QS_ABORTED)));
9540 tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
9541 target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
9542 if ((scsiq->cntl & QC_SG_HEAD) != 0) {
9543 sg_q_addr = q_addr;
9544 sg_list_qp = next_qp;
9545 for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
9546 sg_list_qp = AscReadLramByte(iop_base,
9547 (ushort)(sg_q_addr
9548 + (ushort)
9549 ASC_SCSIQ_B_FWD));
9550 sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
9551 if (sg_list_qp == ASC_QLINK_END) {
9552 AscSetLibErrorCode(asc_dvc,
9553 ASCQ_ERR_SG_Q_LINKS);
9554 scsiq->d3.done_stat = QD_WITH_ERROR;
9555 scsiq->d3.host_stat =
9556 QHSTA_D_QDONE_SG_LIST_CORRUPTED;
9557 goto FATAL_ERR_QDONE;
9558 }
9559 AscWriteLramByte(iop_base,
9560 (ushort)(sg_q_addr + (ushort)
9561 ASC_SCSIQ_B_STATUS),
9562 QS_FREE);
9563 }
9564 n_q_used = sg_queue_cnt + 1;
9565 AscPutVarDoneQTail(iop_base, sg_list_qp);
9566 }
9567 if (asc_dvc->queue_full_or_busy & target_id) {
9568 cur_target_qng = AscReadLramByte(iop_base,
9569 (ushort)((ushort)
9570 ASC_QADR_BEG
9571 + (ushort)
9572 scsiq->d2.
9573 target_ix));
9574 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
9575 scsi_busy = AscReadLramByte(iop_base, (ushort)
9576 ASCV_SCSIBUSY_B);
9577 scsi_busy &= ~target_id;
9578 AscWriteLramByte(iop_base,
9579 (ushort)ASCV_SCSIBUSY_B,
9580 scsi_busy);
9581 asc_dvc->queue_full_or_busy &= ~target_id;
9582 }
9583 }
9584 if (asc_dvc->cur_total_qng >= n_q_used) {
9585 asc_dvc->cur_total_qng -= n_q_used;
9586 if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
9587 asc_dvc->cur_dvc_qng[tid_no]--;
9588 }
9589 } else {
9590 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
9591 scsiq->d3.done_stat = QD_WITH_ERROR;
9592 goto FATAL_ERR_QDONE;
9593 }
9594 if ((scsiq->d2.srb_ptr == 0UL) ||
9595 ((scsiq->q_status & QS_ABORTED) != 0)) {
9596 return (0x11);
9597 } else if (scsiq->q_status == QS_DONE) {
9598 false_overrun = FALSE;
9599 if (scsiq->extra_bytes != 0) {
9600 scsiq->remain_bytes +=
9601 (ADV_DCNT)scsiq->extra_bytes;
9602 }
9603 if (scsiq->d3.done_stat == QD_WITH_ERROR) {
9604 if (scsiq->d3.host_stat ==
9605 QHSTA_M_DATA_OVER_RUN) {
9606 if ((scsiq->
9607 cntl & (QC_DATA_IN | QC_DATA_OUT))
9608 == 0) {
9609 scsiq->d3.done_stat =
9610 QD_NO_ERROR;
9611 scsiq->d3.host_stat =
9612 QHSTA_NO_ERROR;
9613 } else if (false_overrun) {
9614 scsiq->d3.done_stat =
9615 QD_NO_ERROR;
9616 scsiq->d3.host_stat =
9617 QHSTA_NO_ERROR;
9618 }
9619 } else if (scsiq->d3.host_stat ==
9620 QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
9621 AscStopChip(iop_base);
9622 AscSetChipControl(iop_base,
9623 (uchar)(CC_SCSI_RESET
9624 | CC_HALT));
9625 udelay(60);
9626 AscSetChipControl(iop_base, CC_HALT);
9627 AscSetChipStatus(iop_base,
9628 CIW_CLR_SCSI_RESET_INT);
9629 AscSetChipStatus(iop_base, 0);
9630 AscSetChipControl(iop_base, 0);
9631 }
9632 }
9633 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
9634 asc_isr_callback(asc_dvc, scsiq);
9635 } else {
9636 if ((AscReadLramByte(iop_base,
9637 (ushort)(q_addr + (ushort)
9638 ASC_SCSIQ_CDB_BEG))
9639 == START_STOP)) {
9640 asc_dvc->unit_not_ready &= ~target_id;
9641 if (scsiq->d3.done_stat != QD_NO_ERROR) {
9642 asc_dvc->start_motor &=
9643 ~target_id;
9644 }
9645 }
9646 }
9647 return (1);
9648 } else {
9649 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
9650 FATAL_ERR_QDONE:
9651 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
9652 asc_isr_callback(asc_dvc, scsiq);
9653 }
9654 return (0x80);
9655 }
9656 }
9657 return (0);
9658}
9659
9660static int AscISR(ASC_DVC_VAR *asc_dvc)
9661{
9662 ASC_CS_TYPE chipstat;
9663 PortAddr iop_base;
9664 ushort saved_ram_addr;
9665 uchar ctrl_reg;
9666 uchar saved_ctrl_reg;
9667 int int_pending;
9668 int status;
9669 uchar host_flag;
9670
9671 iop_base = asc_dvc->iop_base;
9672 int_pending = FALSE;
9673
9674 if (AscIsIntPending(iop_base) == 0)
9675 return int_pending;
9676
9677 if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
9678 return ERR;
9679 }
9680 if (asc_dvc->in_critical_cnt != 0) {
9681 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
9682 return ERR;
9683 }
9684 if (asc_dvc->is_in_int) {
9685 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
9686 return ERR;
9687 }
9688 asc_dvc->is_in_int = TRUE;
9689 ctrl_reg = AscGetChipControl(iop_base);
9690 saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
9691 CC_SINGLE_STEP | CC_DIAG | CC_TEST));
9692 chipstat = AscGetChipStatus(iop_base);
9693 if (chipstat & CSW_SCSI_RESET_LATCH) {
9694 if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
9695 int i = 10;
9696 int_pending = TRUE;
9697 asc_dvc->sdtr_done = 0;
9698 saved_ctrl_reg &= (uchar)(~CC_HALT);
9699 while ((AscGetChipStatus(iop_base) &
9700 CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
9701 mdelay(100);
9702 }
9703 AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
9704 AscSetChipControl(iop_base, CC_HALT);
9705 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
9706 AscSetChipStatus(iop_base, 0);
9707 chipstat = AscGetChipStatus(iop_base);
9708 }
9709 }
9710 saved_ram_addr = AscGetChipLramAddr(iop_base);
9711 host_flag = AscReadLramByte(iop_base,
9712 ASCV_HOST_FLAG_B) &
9713 (uchar)(~ASC_HOST_FLAG_IN_ISR);
9714 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
9715 (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
9716 if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
9717 AscAckInterrupt(iop_base);
9718 int_pending = TRUE;
9719 if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
9720 if (AscIsrChipHalted(asc_dvc) == ERR) {
9721 goto ISR_REPORT_QDONE_FATAL_ERROR;
9722 } else {
9723 saved_ctrl_reg &= (uchar)(~CC_HALT);
9724 }
9725 } else {
9726 ISR_REPORT_QDONE_FATAL_ERROR:
9727 if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
9728 while (((status =
9729 AscIsrQDone(asc_dvc)) & 0x01) != 0) {
9730 }
9731 } else {
9732 do {
9733 if ((status =
9734 AscIsrQDone(asc_dvc)) == 1) {
9735 break;
9736 }
9737 } while (status == 0x11);
9738 }
9739 if ((status & 0x80) != 0)
9740 int_pending = ERR;
9741 }
9742 }
9743 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
9744 AscSetChipLramAddr(iop_base, saved_ram_addr);
9745 AscSetChipControl(iop_base, saved_ctrl_reg);
9746 asc_dvc->is_in_int = FALSE;
9747 return int_pending;
9748}
9749
9750/*
9751 * advansys_reset()
9752 *
9753 * Reset the bus associated with the command 'scp'.
9754 *
9755 * This function runs its own thread. Interrupts must be blocked but
9756 * sleeping is allowed and no locking other than for host structures is
9757 * required. Returns SUCCESS or FAILED.
9758 */
9759static int advansys_reset(struct scsi_cmnd *scp)
9760{
9761 struct Scsi_Host *shost;
9762 asc_board_t *boardp;
9763 ASC_DVC_VAR *asc_dvc_varp;
9764 ADV_DVC_VAR *adv_dvc_varp;
9765 ulong flags;
9766 int status;
9767 int ret = SUCCESS;
9768
9769 ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
9770
9771#ifdef ADVANSYS_STATS
9772 if (scp->device->host != NULL) {
9773 ASC_STATS(scp->device->host, reset);
9774 }
9775#endif /* ADVANSYS_STATS */
9776
9777 if ((shost = scp->device->host) == NULL) {
9778 scp->result = HOST_BYTE(DID_ERROR);
9779 return FAILED;
9780 }
9781
9782 boardp = ASC_BOARDP(shost);
9783
9784 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
9785 boardp->id);
9786 /*
9787 * Check for re-entrancy.
9788 */
9789 spin_lock_irqsave(&boardp->lock, flags);
9790 if (boardp->flags & ASC_HOST_IN_RESET) {
9791 spin_unlock_irqrestore(&boardp->lock, flags);
9792 return FAILED;
9793 }
9794 boardp->flags |= ASC_HOST_IN_RESET;
9795 spin_unlock_irqrestore(&boardp->lock, flags);
9796
9797 if (ASC_NARROW_BOARD(boardp)) {
9798 /*
9799 * Narrow Board
9800 */
9801 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
9802
9803 /*
9804 * Reset the chip and SCSI bus.
9805 */
9806 ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
9807 status = AscInitAsc1000Driver(asc_dvc_varp);
9808
9809 /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
9810 if (asc_dvc_varp->err_code) {
9811 ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
9812 "error: 0x%x\n", boardp->id,
9813 asc_dvc_varp->err_code);
9814 ret = FAILED;
9815 } else if (status) {
9816 ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
9817 "warning: 0x%x\n", boardp->id, status);
9818 } else {
9819 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
9820 "successful.\n", boardp->id);
9821 }
9822
9823 ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
9824 spin_lock_irqsave(&boardp->lock, flags);
9825
9826 } else {
9827 /*
9828 * Wide Board
9829 *
9830 * If the suggest reset bus flags are set, then reset the bus.
9831 * Otherwise only reset the device.
9832 */
9833 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
9834
9835 /*
9836 * Reset the target's SCSI bus.
9837 */
9838 ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
9839 switch (AdvResetChipAndSB(adv_dvc_varp)) {
9840 case ASC_TRUE:
9841 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
9842 "successful.\n", boardp->id);
9843 break;
9844 case ASC_FALSE:
9845 default:
9846 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
9847 "error.\n", boardp->id);
9848 ret = FAILED;
9849 break;
9850 }
9851 spin_lock_irqsave(&boardp->lock, flags);
9852 AdvISR(adv_dvc_varp);
9853 }
9854 /* Board lock is held. */
9855
9856 /* Save the time of the most recently completed reset. */
9857 boardp->last_reset = jiffies;
9858
9859 /* Clear reset flag. */
9860 boardp->flags &= ~ASC_HOST_IN_RESET;
9861 spin_unlock_irqrestore(&boardp->lock, flags);
9862
9863 ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
9864
9865 return ret;
9866}
9867
9868/*
9869 * advansys_biosparam()
9870 *
9871 * Translate disk drive geometry if the "BIOS greater than 1 GB"
9872 * support is enabled for a drive.
9873 *
9874 * ip (information pointer) is an int array with the following definition:
9875 * ip[0]: heads
9876 * ip[1]: sectors
9877 * ip[2]: cylinders
9878 */
9879static int
9880advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
9881 sector_t capacity, int ip[])
9882{
9883 asc_board_t *boardp;
9884
9885 ASC_DBG(1, "advansys_biosparam: begin\n");
9886 ASC_STATS(sdev->host, biosparam);
9887 boardp = ASC_BOARDP(sdev->host);
9888 if (ASC_NARROW_BOARD(boardp)) {
9889 if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
9890 ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
9891 ip[0] = 255;
9892 ip[1] = 63;
9893 } else {
9894 ip[0] = 64;
9895 ip[1] = 32;
9896 }
9897 } else {
9898 if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
9899 BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
9900 ip[0] = 255;
9901 ip[1] = 63;
9902 } else {
9903 ip[0] = 64;
9904 ip[1] = 32;
9905 }
9906 }
9907 ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
9908 ASC_DBG(1, "advansys_biosparam: end\n");
9909 return 0;
9910}
9911
9912/*
9913 * First-level interrupt handler.
9914 *
9915 * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
9916 */
9917static irqreturn_t advansys_interrupt(int irq, void *dev_id)
9918{
9919 unsigned long flags;
9920 struct Scsi_Host *shost = dev_id;
9921 asc_board_t *boardp = ASC_BOARDP(shost);
9922 irqreturn_t result = IRQ_NONE;
9923
9924 ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
9925 spin_lock_irqsave(&boardp->lock, flags);
9926 if (ASC_NARROW_BOARD(boardp)) {
9927 if (AscIsIntPending(shost->io_port)) {
9928 result = IRQ_HANDLED;
9929 ASC_STATS(shost, interrupt);
9930 ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
9931 AscISR(&boardp->dvc_var.asc_dvc_var);
9932 }
9933 } else {
9934 ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
9935 if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
9936 result = IRQ_HANDLED;
9937 ASC_STATS(shost, interrupt);
9938 }
9939 }
9940 spin_unlock_irqrestore(&boardp->lock, flags);
9941
9942 ASC_DBG(1, "advansys_interrupt: end\n");
9943 return result;
9944}
9945
9946static int AscHostReqRiscHalt(PortAddr iop_base)
9947{
9948 int count = 0;
9949 int sta = 0;
9950 uchar saved_stop_code;
9951
9952 if (AscIsChipHalted(iop_base))
9953 return (1);
9954 saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
9955 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
9956 ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
9957 do {
9958 if (AscIsChipHalted(iop_base)) {
9959 sta = 1;
9960 break;
9961 }
9962 mdelay(100);
9963 } while (count++ < 20);
9964 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
9965 return (sta);
9966}
9967
9968static int
9969AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
9970{
9971 int sta = FALSE;
9972
9973 if (AscHostReqRiscHalt(iop_base)) {
9974 sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
9975 AscStartChip(iop_base);
9976 }
9977 return sta;
9978}
9979
9980static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
9981{
9982 char type = sdev->type;
9983 ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
9984
9985 if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
9986 return;
9987 if (asc_dvc->init_sdtr & tid_bits)
9988 return;
9989
9990 if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
9991 asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
9992
9993 asc_dvc->pci_fix_asyn_xfer |= tid_bits;
9994 if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
9995 (type == TYPE_ROM) || (type == TYPE_TAPE))
9996 asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
9997
9998 if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
9999 AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
10000 ASYN_SDTR_DATA_FIX_PCI_REV_AB);
10001}
10002
10003static void
10004advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
10005{
10006 ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
10007 ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
10008
10009 if (sdev->lun == 0) {
10010 ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
10011 if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
10012 asc_dvc->init_sdtr |= tid_bit;
10013 } else {
10014 asc_dvc->init_sdtr &= ~tid_bit;
10015 }
10016
10017 if (orig_init_sdtr != asc_dvc->init_sdtr)
10018 AscAsyncFix(asc_dvc, sdev);
10019 }
10020
10021 if (sdev->tagged_supported) {
10022 if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
10023 if (sdev->lun == 0) {
10024 asc_dvc->cfg->can_tagged_qng |= tid_bit;
10025 asc_dvc->use_tagged_qng |= tid_bit;
10026 }
10027 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
10028 asc_dvc->max_dvc_qng[sdev->id]);
10029 }
10030 } else {
10031 if (sdev->lun == 0) {
10032 asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
10033 asc_dvc->use_tagged_qng &= ~tid_bit;
10034 }
10035 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
10036 }
10037
10038 if ((sdev->lun == 0) &&
10039 (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
10040 AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
10041 asc_dvc->cfg->disc_enable);
10042 AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
10043 asc_dvc->use_tagged_qng);
10044 AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
10045 asc_dvc->cfg->can_tagged_qng);
10046
10047 asc_dvc->max_dvc_qng[sdev->id] =
10048 asc_dvc->cfg->max_tag_qng[sdev->id];
10049 AscWriteLramByte(asc_dvc->iop_base,
10050 (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
10051 asc_dvc->max_dvc_qng[sdev->id]);
10052 }
10053}
10054
10055/*
10056 * Wide Transfers
10057 *
10058 * If the EEPROM enabled WDTR for the device and the device supports wide
10059 * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
10060 * write the new value to the microcode.
10061 */
10062static void
10063advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
10064{
10065 unsigned short cfg_word;
10066 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
10067 if ((cfg_word & tidmask) != 0)
10068 return;
10069
10070 cfg_word |= tidmask;
10071 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
10072
10073 /*
10074 * Clear the microcode SDTR and WDTR negotiation done indicators for
10075 * the target to cause it to negotiate with the new setting set above.
10076 * WDTR when accepted causes the target to enter asynchronous mode, so
10077 * SDTR must be negotiated.
10078 */
10079 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
10080 cfg_word &= ~tidmask;
10081 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
10082 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
10083 cfg_word &= ~tidmask;
10084 AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
10085}
10086
10087/*
10088 * Synchronous Transfers
10089 *
10090 * If the EEPROM enabled SDTR for the device and the device
10091 * supports synchronous transfers, then turn on the device's
10092 * 'sdtr_able' bit. Write the new value to the microcode.
10093 */
10094static void
10095advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
10096{
10097 unsigned short cfg_word;
10098 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
10099 if ((cfg_word & tidmask) != 0)
10100 return;
10101
10102 cfg_word |= tidmask;
10103 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
10104
10105 /*
10106 * Clear the microcode "SDTR negotiation" done indicator for the
10107 * target to cause it to negotiate with the new setting set above.
10108 */
10109 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
10110 cfg_word &= ~tidmask;
10111 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
10112}
10113
10114/*
10115 * PPR (Parallel Protocol Request) Capable
10116 *
10117 * If the device supports DT mode, then it must be PPR capable.
10118 * The PPR message will be used in place of the SDTR and WDTR
10119 * messages to negotiate synchronous speed and offset, transfer
10120 * width, and protocol options.
10121 */
10122static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
10123 AdvPortAddr iop_base, unsigned short tidmask)
10124{
10125 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
10126 adv_dvc->ppr_able |= tidmask;
10127 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
10128}
10129
10130static void
10131advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
10132{
10133 AdvPortAddr iop_base = adv_dvc->iop_base;
10134 unsigned short tidmask = 1 << sdev->id;
10135
10136 if (sdev->lun == 0) {
10137 /*
10138 * Handle WDTR, SDTR, and Tag Queuing. If the feature
10139 * is enabled in the EEPROM and the device supports the
10140 * feature, then enable it in the microcode.
10141 */
10142
10143 if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
10144 advansys_wide_enable_wdtr(iop_base, tidmask);
10145 if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
10146 advansys_wide_enable_sdtr(iop_base, tidmask);
10147 if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
10148 advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
10149
10150 /*
10151 * Tag Queuing is disabled for the BIOS which runs in polled
10152 * mode and would see no benefit from Tag Queuing. Also by
10153 * disabling Tag Queuing in the BIOS devices with Tag Queuing
10154 * bugs will at least work with the BIOS.
10155 */
10156 if ((adv_dvc->tagqng_able & tidmask) &&
10157 sdev->tagged_supported) {
10158 unsigned short cfg_word;
10159 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
10160 cfg_word |= tidmask;
10161 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
10162 cfg_word);
10163 AdvWriteByteLram(iop_base,
10164 ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
10165 adv_dvc->max_dvc_qng);
10166 }
10167 }
10168
10169 if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
10170 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
10171 adv_dvc->max_dvc_qng);
10172 } else {
10173 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
10174 }
10175}
10176
10177/*
10178 * Set the number of commands to queue per device for the
10179 * specified host adapter.
10180 */
10181static int advansys_slave_configure(struct scsi_device *sdev)
10182{
10183 asc_board_t *boardp = ASC_BOARDP(sdev->host);
10184 boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
10185
10186 /*
10187 * Save a pointer to the sdev and set its initial/maximum
10188 * queue depth. Only save the pointer for a lun0 dev though.
10189 */
10190 if (sdev->lun == 0)
10191 boardp->device[sdev->id] = sdev;
10192
10193 if (ASC_NARROW_BOARD(boardp))
10194 advansys_narrow_slave_configure(sdev,
10195 &boardp->dvc_var.asc_dvc_var);
10196 else
10197 advansys_wide_slave_configure(sdev,
10198 &boardp->dvc_var.adv_dvc_var);
10199
10200 return 0;
10201}
10202
10203/*
10204 * Build a request structure for the Asc Library (Narrow Board).
10205 *
10206 * The global structures 'asc_scsi_q' and 'asc_sg_head' are
10207 * used to build the request.
10208 *
10209 * If an error occurs, then return ASC_ERROR.
10210 */
10211static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
10212{
10213 /*
10214 * Mutually exclusive access is required to 'asc_scsi_q' and
10215 * 'asc_sg_head' until after the request is started.
10216 */
10217 memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
10218
10219 /*
10220 * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
10221 */
10222 asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
10223
10224 /*
10225 * Build the ASC_SCSI_Q request.
10226 */
10227 asc_scsi_q.cdbptr = &scp->cmnd[0];
10228 asc_scsi_q.q2.cdb_len = scp->cmd_len;
10229 asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
10230 asc_scsi_q.q1.target_lun = scp->device->lun;
10231 asc_scsi_q.q2.target_ix =
10232 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
10233 asc_scsi_q.q1.sense_addr =
10234 cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
10235 asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
10236
10237 /*
10238 * If there are any outstanding requests for the current target,
10239 * then every 255th request send an ORDERED request. This heuristic
10240 * tries to retain the benefit of request sorting while preventing
10241 * request starvation. 255 is the max number of tags or pending commands
10242 * a device may have outstanding.
10243 *
10244 * The request count is incremented below for every successfully
10245 * started request.
10246 *
10247 */
10248 if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
10249 (boardp->reqcnt[scp->device->id] % 255) == 0) {
10250 asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
10251 } else {
10252 asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
10253 }
10254
10255 /*
10256 * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
10257 * buffer command.
10258 */
10259 if (scp->use_sg == 0) {
10260 /*
10261 * CDB request of single contiguous buffer.
10262 */
10263 ASC_STATS(scp->device->host, cont_cnt);
10264 scp->SCp.dma_handle = scp->request_bufflen ?
10265 dma_map_single(boardp->dev, scp->request_buffer,
10266 scp->request_bufflen,
10267 scp->sc_data_direction) : 0;
10268 asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
10269 asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
10270 ASC_STATS_ADD(scp->device->host, cont_xfer,
10271 ASC_CEILING(scp->request_bufflen, 512));
10272 asc_scsi_q.q1.sg_queue_cnt = 0;
10273 asc_scsi_q.sg_head = NULL;
10274 } else {
10275 /*
10276 * CDB scatter-gather request list.
10277 */
10278 int sgcnt;
10279 int use_sg;
10280 struct scatterlist *slp;
10281
10282 slp = (struct scatterlist *)scp->request_buffer;
10283 use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
10284 scp->sc_data_direction);
10285
10286 if (use_sg > scp->device->host->sg_tablesize) {
10287 ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
10288 "sg_tablesize %d\n", boardp->id, use_sg,
10289 scp->device->host->sg_tablesize);
10290 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
10291 scp->sc_data_direction);
10292 scp->result = HOST_BYTE(DID_ERROR);
10293 return ASC_ERROR;
10294 }
10295
10296 ASC_STATS(scp->device->host, sg_cnt);
10297
10298 /*
10299 * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
10300 * structure to point to it.
10301 */
10302 memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
10303
10304 asc_scsi_q.q1.cntl |= QC_SG_HEAD;
10305 asc_scsi_q.sg_head = &asc_sg_head;
10306 asc_scsi_q.q1.data_cnt = 0;
10307 asc_scsi_q.q1.data_addr = 0;
10308 /* This is a byte value, otherwise it would need to be swapped. */
10309 asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
10310 ASC_STATS_ADD(scp->device->host, sg_elem,
10311 asc_sg_head.entry_cnt);
10312
10313 /*
10314 * Convert scatter-gather list into ASC_SG_HEAD list.
10315 */
10316 for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
10317 asc_sg_head.sg_list[sgcnt].addr =
10318 cpu_to_le32(sg_dma_address(slp));
10319 asc_sg_head.sg_list[sgcnt].bytes =
10320 cpu_to_le32(sg_dma_len(slp));
10321 ASC_STATS_ADD(scp->device->host, sg_xfer,
10322 ASC_CEILING(sg_dma_len(slp), 512));
10323 }
10324 }
10325
10326 ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
10327 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
10328
10329 return ASC_NOERROR;
10330}
10331
10332/*
10333 * Build scatter-gather list for Adv Library (Wide Board).
10334 *
10335 * Additional ADV_SG_BLOCK structures will need to be allocated
10336 * if the total number of scatter-gather elements exceeds
10337 * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
10338 * assumed to be physically contiguous.
10339 *
10340 * Return:
10341 * ADV_SUCCESS(1) - SG List successfully created
10342 * ADV_ERROR(-1) - SG List creation failed
10343 */
10344static int
10345adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
10346 int use_sg)
10347{
10348 adv_sgblk_t *sgblkp;
10349 ADV_SCSI_REQ_Q *scsiqp;
10350 struct scatterlist *slp;
10351 int sg_elem_cnt;
10352 ADV_SG_BLOCK *sg_block, *prev_sg_block;
10353 ADV_PADDR sg_block_paddr;
10354 int i;
10355
10356 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
10357 slp = (struct scatterlist *)scp->request_buffer;
10358 sg_elem_cnt = use_sg;
10359 prev_sg_block = NULL;
10360 reqp->sgblkp = NULL;
10361
10362 for (;;) {
10363 /*
10364 * Allocate a 'adv_sgblk_t' structure from the board free
10365 * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
10366 * (15) scatter-gather elements.
10367 */
10368 if ((sgblkp = boardp->adv_sgblkp) == NULL) {
10369 ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
10370 ASC_STATS(scp->device->host, adv_build_nosg);
10371
10372 /*
10373 * Allocation failed. Free 'adv_sgblk_t' structures
10374 * already allocated for the request.
10375 */
10376 while ((sgblkp = reqp->sgblkp) != NULL) {
10377 /* Remove 'sgblkp' from the request list. */
10378 reqp->sgblkp = sgblkp->next_sgblkp;
10379
10380 /* Add 'sgblkp' to the board free list. */
10381 sgblkp->next_sgblkp = boardp->adv_sgblkp;
10382 boardp->adv_sgblkp = sgblkp;
10383 }
10384 return ASC_BUSY;
10385 }
10386
10387 /* Complete 'adv_sgblk_t' board allocation. */
10388 boardp->adv_sgblkp = sgblkp->next_sgblkp;
10389 sgblkp->next_sgblkp = NULL;
10390
10391 /*
10392 * Get 8 byte aligned virtual and physical addresses
10393 * for the allocated ADV_SG_BLOCK structure.
10394 */
10395 sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
10396 sg_block_paddr = virt_to_bus(sg_block);
10397
10398 /*
10399 * Check if this is the first 'adv_sgblk_t' for the
10400 * request.
10401 */
10402 if (reqp->sgblkp == NULL) {
10403 /* Request's first scatter-gather block. */
10404 reqp->sgblkp = sgblkp;
10405
10406 /*
10407 * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
10408 * address pointers.
10409 */
10410 scsiqp->sg_list_ptr = sg_block;
10411 scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
10412 } else {
10413 /* Request's second or later scatter-gather block. */
10414 sgblkp->next_sgblkp = reqp->sgblkp;
10415 reqp->sgblkp = sgblkp;
10416
10417 /*
10418 * Point the previous ADV_SG_BLOCK structure to
10419 * the newly allocated ADV_SG_BLOCK structure.
10420 */
10421 prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
10422 }
10423
10424 for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
10425 sg_block->sg_list[i].sg_addr =
10426 cpu_to_le32(sg_dma_address(slp));
10427 sg_block->sg_list[i].sg_count =
10428 cpu_to_le32(sg_dma_len(slp));
10429 ASC_STATS_ADD(scp->device->host, sg_xfer,
10430 ASC_CEILING(sg_dma_len(slp), 512));
10431
10432 if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
10433 sg_block->sg_cnt = i + 1;
10434 sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
10435 return ADV_SUCCESS;
10436 }
10437 slp++;
10438 }
10439 sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
10440 prev_sg_block = sg_block;
10441 }
10442}
10443
10444/*
10445 * Build a request structure for the Adv Library (Wide Board).
10446 *
10447 * If an adv_req_t can not be allocated to issue the request,
10448 * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
10449 *
10450 * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
10451 * microcode for DMA addresses or math operations are byte swapped
10452 * to little-endian order.
10453 */
10454static int
10455adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
10456 ADV_SCSI_REQ_Q **adv_scsiqpp)
10457{
10458 adv_req_t *reqp;
10459 ADV_SCSI_REQ_Q *scsiqp;
10460 int i;
10461 int ret;
10462
10463 /*
10464 * Allocate an adv_req_t structure from the board to execute
10465 * the command.
10466 */
10467 if (boardp->adv_reqp == NULL) {
10468 ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
10469 ASC_STATS(scp->device->host, adv_build_noreq);
10470 return ASC_BUSY;
10471 } else {
10472 reqp = boardp->adv_reqp;
10473 boardp->adv_reqp = reqp->next_reqp;
10474 reqp->next_reqp = NULL;
10475 }
10476
10477 /*
10478 * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
10479 */
10480 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
10481
10482 /*
10483 * Initialize the structure.
10484 */
10485 scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
10486
10487 /*
10488 * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
10489 */
10490 scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
10491
10492 /*
10493 * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
10494 */
10495 reqp->cmndp = scp;
10496
10497 /*
10498 * Build the ADV_SCSI_REQ_Q request.
10499 */
10500
10501 /* Set CDB length and copy it to the request structure. */
10502 scsiqp->cdb_len = scp->cmd_len;
10503 /* Copy first 12 CDB bytes to cdb[]. */
10504 for (i = 0; i < scp->cmd_len && i < 12; i++) {
10505 scsiqp->cdb[i] = scp->cmnd[i];
10506 }
10507 /* Copy last 4 CDB bytes, if present, to cdb16[]. */
10508 for (; i < scp->cmd_len; i++) {
10509 scsiqp->cdb16[i - 12] = scp->cmnd[i];
10510 }
10511
10512 scsiqp->target_id = scp->device->id;
10513 scsiqp->target_lun = scp->device->lun;
10514
10515 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
10516 scsiqp->sense_len = sizeof(scp->sense_buffer);
10517
10518 /*
10519 * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
10520 * buffer command.
10521 */
10522
10523 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
10524 scsiqp->vdata_addr = scp->request_buffer;
10525 scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
10526
10527 if (scp->use_sg == 0) {
10528 /*
10529 * CDB request of single contiguous buffer.
10530 */
10531 reqp->sgblkp = NULL;
10532 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
10533 if (scp->request_bufflen) {
10534 scsiqp->vdata_addr = scp->request_buffer;
10535 scp->SCp.dma_handle =
10536 dma_map_single(boardp->dev, scp->request_buffer,
10537 scp->request_bufflen,
10538 scp->sc_data_direction);
10539 } else {
10540 scsiqp->vdata_addr = NULL;
10541 scp->SCp.dma_handle = 0;
10542 }
10543 scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
10544 scsiqp->sg_list_ptr = NULL;
10545 scsiqp->sg_real_addr = 0;
10546 ASC_STATS(scp->device->host, cont_cnt);
10547 ASC_STATS_ADD(scp->device->host, cont_xfer,
10548 ASC_CEILING(scp->request_bufflen, 512));
10549 } else {
10550 /*
10551 * CDB scatter-gather request list.
10552 */
10553 struct scatterlist *slp;
10554 int use_sg;
10555
10556 slp = (struct scatterlist *)scp->request_buffer;
10557 use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
10558 scp->sc_data_direction);
10559
10560 if (use_sg > ADV_MAX_SG_LIST) {
10561 ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
10562 "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
10563 scp->device->host->sg_tablesize);
10564 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
10565 scp->sc_data_direction);
10566 scp->result = HOST_BYTE(DID_ERROR);
10567
10568 /*
10569 * Free the 'adv_req_t' structure by adding it back
10570 * to the board free list.
10571 */
10572 reqp->next_reqp = boardp->adv_reqp;
10573 boardp->adv_reqp = reqp;
10574
10575 return ASC_ERROR;
10576 }
10577
10578 ret = adv_get_sglist(boardp, reqp, scp, use_sg);
10579 if (ret != ADV_SUCCESS) {
10580 /*
10581 * Free the adv_req_t structure by adding it back to
10582 * the board free list.
10583 */
10584 reqp->next_reqp = boardp->adv_reqp;
10585 boardp->adv_reqp = reqp;
10586
10587 return ret;
10588 }
10589
10590 ASC_STATS(scp->device->host, sg_cnt);
10591 ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
10592 }
10593
10594 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
10595 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
10596
10597 *adv_scsiqpp = scsiqp;
10598
10599 return ASC_NOERROR;
10600}
10601
10602static int AscSgListToQueue(int sg_list)
10603{
10604 int n_sg_list_qs;
10605
10606 n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
10607 if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
10608 n_sg_list_qs++;
10609 return n_sg_list_qs + 1;
10610}
10611
10612static uint
10613AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
10614{
10615 uint cur_used_qs;
10616 uint cur_free_qs;
10617 ASC_SCSI_BIT_ID_TYPE target_id;
10618 uchar tid_no;
10619
10620 target_id = ASC_TIX_TO_TARGET_ID(target_ix);
10621 tid_no = ASC_TIX_TO_TID(target_ix);
10622 if ((asc_dvc->unit_not_ready & target_id) ||
10623 (asc_dvc->queue_full_or_busy & target_id)) {
10624 return 0;
10625 }
10626 if (n_qs == 1) {
10627 cur_used_qs = (uint) asc_dvc->cur_total_qng +
10628 (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
10629 } else {
10630 cur_used_qs = (uint) asc_dvc->cur_total_qng +
10631 (uint) ASC_MIN_FREE_Q;
10632 }
10633 if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
10634 cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
10635 if (asc_dvc->cur_dvc_qng[tid_no] >=
10636 asc_dvc->max_dvc_qng[tid_no]) {
10637 return 0;
10638 }
10639 return cur_free_qs;
10640 }
10641 if (n_qs > 1) {
10642 if ((n_qs > asc_dvc->last_q_shortage)
10643 && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
10644 asc_dvc->last_q_shortage = n_qs;
10645 }
10646 }
10647 return 0;
10648}
10649
10650static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
10651{
10652 ushort q_addr;
10653 uchar next_qp;
10654 uchar q_status;
10655
10656 q_addr = ASC_QNO_TO_QADDR(free_q_head);
10657 q_status = (uchar)AscReadLramByte(iop_base,
10658 (ushort)(q_addr +
10659 ASC_SCSIQ_B_STATUS));
10660 next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
10661 if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
10662 return next_qp;
10663 return ASC_QLINK_END;
10664}
10665
10666static uchar
10667AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
10668{
10669 uchar i;
10670
10671 for (i = 0; i < n_free_q; i++) {
10672 free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
10673 if (free_q_head == ASC_QLINK_END)
10674 break;
10675 }
10676 return free_q_head;
10677}
10678
10679/*
10680 * void
10681 * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
10682 *
10683 * Calling/Exit State:
10684 * none
10685 *
10686 * Description:
10687 * Output an ASC_SCSI_Q structure to the chip
10688 */
10689static void
10690DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
10691{
10692 int i;
10693
10694 ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
10695 AscSetChipLramAddr(iop_base, s_addr);
10696 for (i = 0; i < 2 * words; i += 2) {
10697 if (i == 4 || i == 20) {
10698 continue;
10699 }
10700 outpw(iop_base + IOP_RAM_DATA,
10701 ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
10702 }
10703}
10704
10705static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
10706{
10707 ushort q_addr;
10708 uchar tid_no;
10709 uchar sdtr_data;
10710 uchar syn_period_ix;
10711 uchar syn_offset;
10712 PortAddr iop_base;
10713
10714 iop_base = asc_dvc->iop_base;
10715 if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
10716 ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
10717 tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
10718 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
10719 syn_period_ix =
10720 (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
10721 syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
10722 AscMsgOutSDTR(asc_dvc,
10723 asc_dvc->sdtr_period_tbl[syn_period_ix],
10724 syn_offset);
10725 scsiq->q1.cntl |= QC_MSG_OUT;
10726 }
10727 q_addr = ASC_QNO_TO_QADDR(q_no);
10728 if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
10729 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
10730 }
10731 scsiq->q1.status = QS_FREE;
10732 AscMemWordCopyPtrToLram(iop_base,
10733 q_addr + ASC_SCSIQ_CDB_BEG,
10734 (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
10735
10736 DvcPutScsiQ(iop_base,
10737 q_addr + ASC_SCSIQ_CPY_BEG,
10738 (uchar *)&scsiq->q1.cntl,
10739 ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
10740 AscWriteLramWord(iop_base,
10741 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
10742 (ushort)(((ushort)scsiq->q1.
10743 q_no << 8) | (ushort)QS_READY));
10744 return 1;
10745}
10746
10747static int
10748AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
10749{
10750 int sta;
10751 int i;
10752 ASC_SG_HEAD *sg_head;
10753 ASC_SG_LIST_Q scsi_sg_q;
10754 ASC_DCNT saved_data_addr;
10755 ASC_DCNT saved_data_cnt;
10756 PortAddr iop_base;
10757 ushort sg_list_dwords;
10758 ushort sg_index;
10759 ushort sg_entry_cnt;
10760 ushort q_addr;
10761 uchar next_qp;
10762
10763 iop_base = asc_dvc->iop_base;
10764 sg_head = scsiq->sg_head;
10765 saved_data_addr = scsiq->q1.data_addr;
10766 saved_data_cnt = scsiq->q1.data_cnt;
10767 scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
10768 scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
10769#if CC_VERY_LONG_SG_LIST
10770 /*
10771 * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
10772 * then not all SG elements will fit in the allocated queues.
10773 * The rest of the SG elements will be copied when the RISC
10774 * completes the SG elements that fit and halts.
10775 */
10776 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
10777 /*
10778 * Set sg_entry_cnt to be the number of SG elements that
10779 * will fit in the allocated SG queues. It is minus 1, because
10780 * the first SG element is handled above. ASC_MAX_SG_LIST is
10781 * already inflated by 1 to account for this. For example it
10782 * may be 50 which is 1 + 7 queues * 7 SG elements.
10783 */
10784 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
10785
10786 /*
10787 * Keep track of remaining number of SG elements that will
10788 * need to be handled from a_isr.c.
10789 */
10790 scsiq->remain_sg_entry_cnt =
10791 sg_head->entry_cnt - ASC_MAX_SG_LIST;
10792 } else {
10793#endif /* CC_VERY_LONG_SG_LIST */
10794 /*
10795 * Set sg_entry_cnt to be the number of SG elements that
10796 * will fit in the allocated SG queues. It is minus 1, because
10797 * the first SG element is handled above.
10798 */
10799 sg_entry_cnt = sg_head->entry_cnt - 1;
10800#if CC_VERY_LONG_SG_LIST
10801 }
10802#endif /* CC_VERY_LONG_SG_LIST */
10803 if (sg_entry_cnt != 0) {
10804 scsiq->q1.cntl |= QC_SG_HEAD;
10805 q_addr = ASC_QNO_TO_QADDR(q_no);
10806 sg_index = 1;
10807 scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
10808 scsi_sg_q.sg_head_qp = q_no;
10809 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
10810 for (i = 0; i < sg_head->queue_cnt; i++) {
10811 scsi_sg_q.seq_no = i + 1;
10812 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
10813 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
10814 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
10815 if (i == 0) {
10816 scsi_sg_q.sg_list_cnt =
10817 ASC_SG_LIST_PER_Q;
10818 scsi_sg_q.sg_cur_list_cnt =
10819 ASC_SG_LIST_PER_Q;
10820 } else {
10821 scsi_sg_q.sg_list_cnt =
10822 ASC_SG_LIST_PER_Q - 1;
10823 scsi_sg_q.sg_cur_list_cnt =
10824 ASC_SG_LIST_PER_Q - 1;
10825 }
10826 } else {
10827#if CC_VERY_LONG_SG_LIST
10828 /*
10829 * This is the last SG queue in the list of
10830 * allocated SG queues. If there are more
10831 * SG elements than will fit in the allocated
10832 * queues, then set the QCSG_SG_XFER_MORE flag.
10833 */
10834 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
10835 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
10836 } else {
10837#endif /* CC_VERY_LONG_SG_LIST */
10838 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
10839#if CC_VERY_LONG_SG_LIST
10840 }
10841#endif /* CC_VERY_LONG_SG_LIST */
10842 sg_list_dwords = sg_entry_cnt << 1;
10843 if (i == 0) {
10844 scsi_sg_q.sg_list_cnt = sg_entry_cnt;
10845 scsi_sg_q.sg_cur_list_cnt =
10846 sg_entry_cnt;
10847 } else {
10848 scsi_sg_q.sg_list_cnt =
10849 sg_entry_cnt - 1;
10850 scsi_sg_q.sg_cur_list_cnt =
10851 sg_entry_cnt - 1;
10852 }
10853 sg_entry_cnt = 0;
10854 }
10855 next_qp = AscReadLramByte(iop_base,
10856 (ushort)(q_addr +
10857 ASC_SCSIQ_B_FWD));
10858 scsi_sg_q.q_no = next_qp;
10859 q_addr = ASC_QNO_TO_QADDR(next_qp);
10860 AscMemWordCopyPtrToLram(iop_base,
10861 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
10862 (uchar *)&scsi_sg_q,
10863 sizeof(ASC_SG_LIST_Q) >> 1);
10864 AscMemDWordCopyPtrToLram(iop_base,
10865 q_addr + ASC_SGQ_LIST_BEG,
10866 (uchar *)&sg_head->
10867 sg_list[sg_index],
10868 sg_list_dwords);
10869 sg_index += ASC_SG_LIST_PER_Q;
10870 scsiq->next_sg_index = sg_index;
10871 }
10872 } else {
10873 scsiq->q1.cntl &= ~QC_SG_HEAD;
10874 }
10875 sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
10876 scsiq->q1.data_addr = saved_data_addr;
10877 scsiq->q1.data_cnt = saved_data_cnt;
10878 return (sta);
10879}
10880
10881static int
10882AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
10883{
10884 PortAddr iop_base;
10885 uchar free_q_head;
10886 uchar next_qp;
10887 uchar tid_no;
10888 uchar target_ix;
10889 int sta;
10890
10891 iop_base = asc_dvc->iop_base;
10892 target_ix = scsiq->q2.target_ix;
10893 tid_no = ASC_TIX_TO_TID(target_ix);
10894 sta = 0;
10895 free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
10896 if (n_q_required > 1) {
10897 next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
10898 (uchar)n_q_required);
10899 if (next_qp != ASC_QLINK_END) {
10900 asc_dvc->last_q_shortage = 0;
10901 scsiq->sg_head->queue_cnt = n_q_required - 1;
10902 scsiq->q1.q_no = free_q_head;
10903 sta = AscPutReadySgListQueue(asc_dvc, scsiq,
10904 free_q_head);
10905 }
10906 } else if (n_q_required == 1) {
10907 next_qp = AscAllocFreeQueue(iop_base, free_q_head);
10908 if (next_qp != ASC_QLINK_END) {
10909 scsiq->q1.q_no = free_q_head;
10910 sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
10911 }
10912 }
10913 if (sta == 1) {
10914 AscPutVarFreeQHead(iop_base, next_qp);
10915 asc_dvc->cur_total_qng += n_q_required;
10916 asc_dvc->cur_dvc_qng[tid_no]++;
10917 }
10918 return sta;
10919}
10920
10921#define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
10922static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
10923 INQUIRY,
10924 REQUEST_SENSE,
10925 READ_CAPACITY,
10926 READ_TOC,
10927 MODE_SELECT,
10928 MODE_SENSE,
10929 MODE_SELECT_10,
10930 MODE_SENSE_10,
10931 0xFF,
10932 0xFF,
10933 0xFF,
10934 0xFF,
10935 0xFF,
10936 0xFF,
10937 0xFF,
10938 0xFF
10939};
10940
10941static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
10942{
10943 PortAddr iop_base;
10944 int sta;
10945 int n_q_required;
10946 int disable_syn_offset_one_fix;
10947 int i;
10948 ASC_PADDR addr;
10949 ushort sg_entry_cnt = 0;
10950 ushort sg_entry_cnt_minus_one = 0;
10951 uchar target_ix;
10952 uchar tid_no;
10953 uchar sdtr_data;
10954 uchar extra_bytes;
10955 uchar scsi_cmd;
10956 uchar disable_cmd;
10957 ASC_SG_HEAD *sg_head;
10958 ASC_DCNT data_cnt;
10959
10960 iop_base = asc_dvc->iop_base;
10961 sg_head = scsiq->sg_head;
10962 if (asc_dvc->err_code != 0)
10963 return (ERR);
10964 scsiq->q1.q_no = 0;
10965 if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
10966 scsiq->q1.extra_bytes = 0;
10967 }
10968 sta = 0;
10969 target_ix = scsiq->q2.target_ix;
10970 tid_no = ASC_TIX_TO_TID(target_ix);
10971 n_q_required = 1;
10972 if (scsiq->cdbptr[0] == REQUEST_SENSE) {
10973 if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
10974 asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
10975 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
10976 AscMsgOutSDTR(asc_dvc,
10977 asc_dvc->
10978 sdtr_period_tbl[(sdtr_data >> 4) &
10979 (uchar)(asc_dvc->
10980 max_sdtr_index -
10981 1)],
10982 (uchar)(sdtr_data & (uchar)
10983 ASC_SYN_MAX_OFFSET));
10984 scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
10985 }
10986 }
10987 if (asc_dvc->in_critical_cnt != 0) {
10988 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
10989 return (ERR);
10990 }
10991 asc_dvc->in_critical_cnt++;
10992 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
10993 if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
10994 asc_dvc->in_critical_cnt--;
10995 return (ERR);
10996 }
10997#if !CC_VERY_LONG_SG_LIST
10998 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
10999 asc_dvc->in_critical_cnt--;
11000 return (ERR);
11001 }
11002#endif /* !CC_VERY_LONG_SG_LIST */
11003 if (sg_entry_cnt == 1) {
11004 scsiq->q1.data_addr =
11005 (ADV_PADDR)sg_head->sg_list[0].addr;
11006 scsiq->q1.data_cnt =
11007 (ADV_DCNT)sg_head->sg_list[0].bytes;
11008 scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
11009 }
11010 sg_entry_cnt_minus_one = sg_entry_cnt - 1;
11011 }
11012 scsi_cmd = scsiq->cdbptr[0];
11013 disable_syn_offset_one_fix = FALSE;
11014 if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
11015 !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
11016 if (scsiq->q1.cntl & QC_SG_HEAD) {
11017 data_cnt = 0;
11018 for (i = 0; i < sg_entry_cnt; i++) {
11019 data_cnt +=
11020 (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
11021 bytes);
11022 }
11023 } else {
11024 data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
11025 }
11026 if (data_cnt != 0UL) {
11027 if (data_cnt < 512UL) {
11028 disable_syn_offset_one_fix = TRUE;
11029 } else {
11030 for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
11031 i++) {
11032 disable_cmd =
11033 _syn_offset_one_disable_cmd[i];
11034 if (disable_cmd == 0xFF) {
11035 break;
11036 }
11037 if (scsi_cmd == disable_cmd) {
11038 disable_syn_offset_one_fix =
11039 TRUE;
11040 break;
11041 }
11042 }
11043 }
11044 }
11045 }
11046 if (disable_syn_offset_one_fix) {
11047 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
11048 scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
11049 ASC_TAG_FLAG_DISABLE_DISCONNECT);
11050 } else {
11051 scsiq->q2.tag_code &= 0x27;
11052 }
11053 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
11054 if (asc_dvc->bug_fix_cntl) {
11055 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
11056 if ((scsi_cmd == READ_6) ||
11057 (scsi_cmd == READ_10)) {
11058 addr =
11059 (ADV_PADDR)le32_to_cpu(sg_head->
11060 sg_list
11061 [sg_entry_cnt_minus_one].
11062 addr) +
11063 (ADV_DCNT)le32_to_cpu(sg_head->
11064 sg_list
11065 [sg_entry_cnt_minus_one].
11066 bytes);
11067 extra_bytes =
11068 (uchar)((ushort)addr & 0x0003);
11069 if ((extra_bytes != 0)
11070 &&
11071 ((scsiq->q2.
11072 tag_code &
11073 ASC_TAG_FLAG_EXTRA_BYTES)
11074 == 0)) {
11075 scsiq->q2.tag_code |=
11076 ASC_TAG_FLAG_EXTRA_BYTES;
11077 scsiq->q1.extra_bytes =
11078 extra_bytes;
11079 data_cnt =
11080 le32_to_cpu(sg_head->
11081 sg_list
11082 [sg_entry_cnt_minus_one].
11083 bytes);
11084 data_cnt -=
11085 (ASC_DCNT) extra_bytes;
11086 sg_head->
11087 sg_list
11088 [sg_entry_cnt_minus_one].
11089 bytes =
11090 cpu_to_le32(data_cnt);
11091 }
11092 }
11093 }
11094 }
11095 sg_head->entry_to_copy = sg_head->entry_cnt;
11096#if CC_VERY_LONG_SG_LIST
11097 /*
11098 * Set the sg_entry_cnt to the maximum possible. The rest of
11099 * the SG elements will be copied when the RISC completes the
11100 * SG elements that fit and halts.
11101 */
11102 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
11103 sg_entry_cnt = ASC_MAX_SG_LIST;
11104 }
11105#endif /* CC_VERY_LONG_SG_LIST */
11106 n_q_required = AscSgListToQueue(sg_entry_cnt);
11107 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
11108 (uint) n_q_required)
11109 || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
11110 if ((sta =
11111 AscSendScsiQueue(asc_dvc, scsiq,
11112 n_q_required)) == 1) {
11113 asc_dvc->in_critical_cnt--;
11114 return (sta);
11115 }
11116 }
11117 } else {
11118 if (asc_dvc->bug_fix_cntl) {
11119 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
11120 if ((scsi_cmd == READ_6) ||
11121 (scsi_cmd == READ_10)) {
11122 addr =
11123 le32_to_cpu(scsiq->q1.data_addr) +
11124 le32_to_cpu(scsiq->q1.data_cnt);
11125 extra_bytes =
11126 (uchar)((ushort)addr & 0x0003);
11127 if ((extra_bytes != 0)
11128 &&
11129 ((scsiq->q2.
11130 tag_code &
11131 ASC_TAG_FLAG_EXTRA_BYTES)
11132 == 0)) {
11133 data_cnt =
11134 le32_to_cpu(scsiq->q1.
11135 data_cnt);
11136 if (((ushort)data_cnt & 0x01FF)
11137 == 0) {
11138 scsiq->q2.tag_code |=
11139 ASC_TAG_FLAG_EXTRA_BYTES;
11140 data_cnt -= (ASC_DCNT)
11141 extra_bytes;
11142 scsiq->q1.data_cnt =
11143 cpu_to_le32
11144 (data_cnt);
11145 scsiq->q1.extra_bytes =
11146 extra_bytes;
11147 }
11148 }
11149 }
11150 }
11151 }
11152 n_q_required = 1;
11153 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
11154 ((scsiq->q1.cntl & QC_URGENT) != 0)) {
11155 if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
11156 n_q_required)) == 1) {
11157 asc_dvc->in_critical_cnt--;
11158 return (sta);
11159 }
11160 }
11161 }
11162 asc_dvc->in_critical_cnt--;
11163 return (sta);
11164}
11165
11166/*
11167 * AdvExeScsiQueue() - Send a request to the RISC microcode program.
11168 *
11169 * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
11170 * add the carrier to the ICQ (Initiator Command Queue), and tickle the
11171 * RISC to notify it a new command is ready to be executed.
11172 *
11173 * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
11174 * set to SCSI_MAX_RETRY.
11175 *
11176 * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
11177 * for DMA addresses or math operations are byte swapped to little-endian
11178 * order.
11179 *
11180 * Return:
11181 * ADV_SUCCESS(1) - The request was successfully queued.
11182 * ADV_BUSY(0) - Resource unavailable; Retry again after pending
11183 * request completes.
11184 * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
11185 * host IC error.
11186 */
11187static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
11188{
11189 AdvPortAddr iop_base;
11190 ADV_DCNT req_size;
11191 ADV_PADDR req_paddr;
11192 ADV_CARR_T *new_carrp;
11193
11194 /*
11195 * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
11196 */
11197 if (scsiq->target_id > ADV_MAX_TID) {
11198 scsiq->host_status = QHSTA_M_INVALID_DEVICE;
11199 scsiq->done_status = QD_WITH_ERROR;
11200 return ADV_ERROR;
11201 }
11202
11203 iop_base = asc_dvc->iop_base;
11204
11205 /*
11206 * Allocate a carrier ensuring at least one carrier always
11207 * remains on the freelist and initialize fields.
11208 */
11209 if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
11210 return ADV_BUSY;
11211 }
11212 asc_dvc->carr_freelist = (ADV_CARR_T *)
11213 ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
11214 asc_dvc->carr_pending_cnt++;
11215
11216 /*
11217 * Set the carrier to be a stopper by setting 'next_vpa'
11218 * to the stopper value. The current stopper will be changed
11219 * below to point to the new stopper.
11220 */
11221 new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
11222
11223 /*
11224 * Clear the ADV_SCSI_REQ_Q done flag.
11225 */
11226 scsiq->a_flag &= ~ADV_SCSIQ_DONE;
11227
11228 req_size = sizeof(ADV_SCSI_REQ_Q);
11229 req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
11230 (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
11231
11232 BUG_ON(req_paddr & 31);
11233 BUG_ON(req_size < sizeof(ADV_SCSI_REQ_Q));
11234
11235 /* Wait for assertion before making little-endian */
11236 req_paddr = cpu_to_le32(req_paddr);
11237
11238 /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
11239 scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
11240 scsiq->scsiq_rptr = req_paddr;
11241
11242 scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
11243 /*
11244 * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
11245 * order during initialization.
11246 */
11247 scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
11248
11249 /*
11250 * Use the current stopper to send the ADV_SCSI_REQ_Q command to
11251 * the microcode. The newly allocated stopper will become the new
11252 * stopper.
11253 */
11254 asc_dvc->icq_sp->areq_vpa = req_paddr;
11255
11256 /*
11257 * Set the 'next_vpa' pointer for the old stopper to be the
11258 * physical address of the new stopper. The RISC can only
11259 * follow physical addresses.
11260 */
11261 asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
11262
11263 /*
11264 * Set the host adapter stopper pointer to point to the new carrier.
11265 */
11266 asc_dvc->icq_sp = new_carrp;
11267
11268 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
11269 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
11270 /*
11271 * Tickle the RISC to tell it to read its Command Queue Head pointer.
11272 */
11273 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
11274 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
11275 /*
11276 * Clear the tickle value. In the ASC-3550 the RISC flag
11277 * command 'clr_tickle_a' does not work unless the host
11278 * value is cleared.
11279 */
11280 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
11281 ADV_TICKLE_NOP);
11282 }
11283 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
11284 /*
11285 * Notify the RISC a carrier is ready by writing the physical
11286 * address of the new carrier stopper to the COMMA register.
11287 */
11288 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
11289 le32_to_cpu(new_carrp->carr_pa));
11290 }
11291
11292 return ADV_SUCCESS;
11293}
11294
11295/*
11296 * Execute a single 'Scsi_Cmnd'.
11297 *
11298 * The function 'done' is called when the request has been completed.
11299 *
11300 * Scsi_Cmnd:
11301 *
11302 * host - board controlling device
11303 * device - device to send command
11304 * target - target of device
11305 * lun - lun of device
11306 * cmd_len - length of SCSI CDB
11307 * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
11308 * use_sg - if non-zero indicates scatter-gather request with use_sg elements
11309 *
11310 * if (use_sg == 0) {
11311 * request_buffer - buffer address for request
11312 * request_bufflen - length of request buffer
11313 * } else {
11314 * request_buffer - pointer to scatterlist structure
11315 * }
11316 *
11317 * sense_buffer - sense command buffer
11318 *
11319 * result (4 bytes of an int):
11320 * Byte Meaning
11321 * 0 SCSI Status Byte Code
11322 * 1 SCSI One Byte Message Code
11323 * 2 Host Error Code
11324 * 3 Mid-Level Error Code
11325 *
11326 * host driver fields:
11327 * SCp - Scsi_Pointer used for command processing status
11328 * scsi_done - used to save caller's done function
11329 * host_scribble - used for pointer to another struct scsi_cmnd
11330 *
11331 * If this function returns ASC_NOERROR the request will be completed
11332 * from the interrupt handler.
11333 *
11334 * If this function returns ASC_ERROR the host error code has been set,
11335 * and the called must call asc_scsi_done.
11336 *
11337 * If ASC_BUSY is returned the request will be returned to the midlayer
11338 * and re-tried later.
11339 */
11340static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
11341{
11342 asc_board_t *boardp;
11343 ASC_DVC_VAR *asc_dvc_varp;
11344 ADV_DVC_VAR *adv_dvc_varp;
11345 ADV_SCSI_REQ_Q *adv_scsiqp;
11346 struct scsi_device *device;
11347 int ret;
11348
11349 ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
11350 (ulong)scp, (ulong)scp->scsi_done);
11351
11352 boardp = ASC_BOARDP(scp->device->host);
11353 device = boardp->device[scp->device->id];
11354
11355 if (ASC_NARROW_BOARD(boardp)) {
11356 /*
11357 * Build and execute Narrow Board request.
11358 */
11359
11360 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
11361
11362 /*
11363 * Build Asc Library request structure using the
11364 * global structures 'asc_scsi_req' and 'asc_sg_head'.
11365 *
11366 * If an error is returned, then the request has been
11367 * queued on the board done queue. It will be completed
11368 * by the caller.
11369 *
11370 * asc_build_req() can not return ASC_BUSY.
11371 */
11372 if (asc_build_req(boardp, scp) == ASC_ERROR) {
11373 ASC_STATS(scp->device->host, build_error);
11374 return ASC_ERROR;
11375 }
11376
11377 switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
11378 case ASC_NOERROR:
11379 ASC_STATS(scp->device->host, exe_noerror);
11380 /*
11381 * Increment monotonically increasing per device
11382 * successful request counter. Wrapping doesn't matter.
11383 */
11384 boardp->reqcnt[scp->device->id]++;
11385 ASC_DBG(1, "asc_execute_scsi_cmnd: AscExeScsiQueue(), "
11386 "ASC_NOERROR\n");
11387 break;
11388 case ASC_BUSY:
11389 ASC_STATS(scp->device->host, exe_busy);
11390 break;
11391 case ASC_ERROR:
11392 ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
11393 "AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
11394 boardp->id, asc_dvc_varp->err_code);
11395 ASC_STATS(scp->device->host, exe_error);
11396 scp->result = HOST_BYTE(DID_ERROR);
11397 break;
11398 default:
11399 ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
11400 "AscExeScsiQueue() unknown, err_code 0x%x\n",
11401 boardp->id, asc_dvc_varp->err_code);
11402 ASC_STATS(scp->device->host, exe_unknown);
11403 scp->result = HOST_BYTE(DID_ERROR);
11404 break;
11405 }
11406 } else {
11407 /*
11408 * Build and execute Wide Board request.
11409 */
11410 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
11411
11412 /*
11413 * Build and get a pointer to an Adv Library request structure.
11414 *
11415 * If the request is successfully built then send it below,
11416 * otherwise return with an error.
11417 */
11418 switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
11419 case ASC_NOERROR:
11420 ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
11421 "ASC_NOERROR\n");
11422 break;
11423 case ASC_BUSY:
11424 ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
11425 "ASC_BUSY\n");
11426 /*
11427 * The asc_stats fields 'adv_build_noreq' and
11428 * 'adv_build_nosg' count wide board busy conditions.
11429 * They are updated in adv_build_req and
11430 * adv_get_sglist, respectively.
11431 */
11432 return ASC_BUSY;
11433 case ASC_ERROR:
11434 default:
11435 ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
11436 "ASC_ERROR\n");
11437 ASC_STATS(scp->device->host, build_error);
11438 return ASC_ERROR;
11439 }
11440
11441 switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
11442 case ASC_NOERROR:
11443 ASC_STATS(scp->device->host, exe_noerror);
11444 /*
11445 * Increment monotonically increasing per device
11446 * successful request counter. Wrapping doesn't matter.
11447 */
11448 boardp->reqcnt[scp->device->id]++;
11449 ASC_DBG(1, "asc_execute_scsi_cmnd: AdvExeScsiQueue(), "
11450 "ASC_NOERROR\n");
11451 break;
11452 case ASC_BUSY:
11453 ASC_STATS(scp->device->host, exe_busy);
11454 break;
11455 case ASC_ERROR:
11456 ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
11457 "AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
11458 boardp->id, adv_dvc_varp->err_code);
11459 ASC_STATS(scp->device->host, exe_error);
11460 scp->result = HOST_BYTE(DID_ERROR);
11461 break;
11462 default:
11463 ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
11464 "AdvExeScsiQueue() unknown, err_code 0x%x\n",
11465 boardp->id, adv_dvc_varp->err_code);
11466 ASC_STATS(scp->device->host, exe_unknown);
11467 scp->result = HOST_BYTE(DID_ERROR);
11468 break;
11469 }
11470 }
11471
11472 ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
11473 return ret;
11474}
11475
11476/*
11477 * advansys_queuecommand() - interrupt-driven I/O entrypoint.
11478 *
11479 * This function always returns 0. Command return status is saved
11480 * in the 'scp' result field.
11481 */
11482static int
11483advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
11484{
11485 struct Scsi_Host *shost = scp->device->host;
11486 asc_board_t *boardp = ASC_BOARDP(shost);
11487 unsigned long flags;
11488 int asc_res, result = 0;
11489
11490 ASC_STATS(shost, queuecommand);
11491 scp->scsi_done = done;
11492
11493 /*
11494 * host_lock taken by mid-level prior to call, but need
11495 * to protect against own ISR
11496 */
11497 spin_lock_irqsave(&boardp->lock, flags);
11498 asc_res = asc_execute_scsi_cmnd(scp);
11499 spin_unlock_irqrestore(&boardp->lock, flags);
11500
11501 switch (asc_res) {
11502 case ASC_NOERROR:
11503 break;
11504 case ASC_BUSY:
11505 result = SCSI_MLQUEUE_HOST_BUSY;
11506 break;
11507 case ASC_ERROR:
11508 default:
11509 asc_scsi_done(scp);
11510 break;
11511 }
11512
11513 return result;
11514}
11515
11516static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
11517{
11518 PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
11519 (PortAddr) (ASC_EISA_CFG_IOP_MASK);
11520 return inpw(eisa_cfg_iop);
11521}
11522
11523/*
11524 * Return the BIOS address of the adapter at the specified
11525 * I/O port and with the specified bus type.
11526 */
11527static unsigned short __devinit
11528AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
11529{
11530 unsigned short cfg_lsw;
11531 unsigned short bios_addr;
11532
11533 /*
11534 * The PCI BIOS is re-located by the motherboard BIOS. Because
11535 * of this the driver can not determine where a PCI BIOS is
11536 * loaded and executes.
11537 */
11538 if (bus_type & ASC_IS_PCI)
11539 return 0;
11540
11541 if ((bus_type & ASC_IS_EISA) != 0) {
11542 cfg_lsw = AscGetEisaChipCfg(iop_base);
11543 cfg_lsw &= 0x000F;
11544 bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
11545 return bios_addr;
11546 }
11547
11548 cfg_lsw = AscGetChipCfgLsw(iop_base);
11549
11550 /*
11551 * ISA PnP uses the top bit as the 32K BIOS flag
11552 */
11553 if (bus_type == ASC_IS_ISAPNP)
11554 cfg_lsw &= 0x7FFF;
11555 bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
11556 return bios_addr;
11557}
11558
11559static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
11560{
11561 ushort cfg_lsw;
11562
11563 if (AscGetChipScsiID(iop_base) == new_host_id) {
11564 return (new_host_id);
11565 }
11566 cfg_lsw = AscGetChipCfgLsw(iop_base);
11567 cfg_lsw &= 0xF8FF;
11568 cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
11569 AscSetChipCfgLsw(iop_base, cfg_lsw);
11570 return (AscGetChipScsiID(iop_base));
11571}
11572
11573static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
11574{
11575 unsigned char sc;
11576
11577 AscSetBank(iop_base, 1);
11578 sc = inp(iop_base + IOP_REG_SC);
11579 AscSetBank(iop_base, 0);
11580 return sc;
11581}
11582
11583static unsigned char __devinit
11584AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
11585{
11586 if (bus_type & ASC_IS_EISA) {
11587 PortAddr eisa_iop;
11588 unsigned char revision;
11589 eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
11590 (PortAddr) ASC_EISA_REV_IOP_MASK;
11591 revision = inp(eisa_iop);
11592 return ASC_CHIP_MIN_VER_EISA - 1 + revision;
11593 }
11594 return AscGetChipVerNo(iop_base);
11595}
11596
11597static void __devinit AscToggleIRQAct(PortAddr iop_base)
11598{
11599 AscSetChipStatus(iop_base, CIW_IRQ_ACT);
11600 AscSetChipStatus(iop_base, 0);
11601 return;
11602}
11603
11604static uchar __devinit AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
11605{
11606 ushort cfg_lsw;
11607 uchar chip_irq;
11608
11609 if ((bus_type & ASC_IS_EISA) != 0) {
11610 cfg_lsw = AscGetEisaChipCfg(iop_base);
11611 chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
11612 if ((chip_irq == 13) || (chip_irq > 15)) {
11613 return (0);
11614 }
11615 return (chip_irq);
11616 }
11617 if ((bus_type & ASC_IS_VL) != 0) {
11618 cfg_lsw = AscGetChipCfgLsw(iop_base);
11619 chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
11620 if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
11621 return (0);
11622 }
11623 return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
11624 }
11625 cfg_lsw = AscGetChipCfgLsw(iop_base);
11626 chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
11627 if (chip_irq == 3)
11628 chip_irq += (uchar)2;
11629 return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
11630}
11631
11632static uchar __devinit
11633AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
11634{
11635 ushort cfg_lsw;
11636
11637 if ((bus_type & ASC_IS_VL) != 0) {
11638 if (irq_no != 0) {
11639 if ((irq_no < ASC_MIN_IRQ_NO)
11640 || (irq_no > ASC_MAX_IRQ_NO)) {
11641 irq_no = 0;
11642 } else {
11643 irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
11644 }
11645 }
11646 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
11647 cfg_lsw |= (ushort)0x0010;
11648 AscSetChipCfgLsw(iop_base, cfg_lsw);
11649 AscToggleIRQAct(iop_base);
11650 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
11651 cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
11652 AscSetChipCfgLsw(iop_base, cfg_lsw);
11653 AscToggleIRQAct(iop_base);
11654 return (AscGetChipIRQ(iop_base, bus_type));
11655 }
11656 if ((bus_type & (ASC_IS_ISA)) != 0) {
11657 if (irq_no == 15)
11658 irq_no -= (uchar)2;
11659 irq_no -= (uchar)ASC_MIN_IRQ_NO;
11660 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
11661 cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
11662 AscSetChipCfgLsw(iop_base, cfg_lsw);
11663 return (AscGetChipIRQ(iop_base, bus_type));
11664 }
11665 return (0);
11666}
11667
11668#ifdef CONFIG_ISA
11669static void __devinit AscEnableIsaDma(uchar dma_channel)
11670{
11671 if (dma_channel < 4) {
11672 outp(0x000B, (ushort)(0xC0 | dma_channel));
11673 outp(0x000A, dma_channel);
11674 } else if (dma_channel < 8) {
11675 outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
11676 outp(0x00D4, (ushort)(dma_channel - 4));
11677 }
11678 return;
11679}
11680#endif /* CONFIG_ISA */
11681
11682static int AscStopQueueExe(PortAddr iop_base)
11683{
11684 int count = 0;
11685
11686 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
11687 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
11688 ASC_STOP_REQ_RISC_STOP);
11689 do {
11690 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
11691 ASC_STOP_ACK_RISC_STOP) {
11692 return (1);
11693 }
11694 mdelay(100);
11695 } while (count++ < 20);
11696 }
11697 return (0);
11698}
11699
11700static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
11701{
11702 if (bus_type & ASC_IS_ISA)
11703 return ASC_MAX_ISA_DMA_COUNT;
11704 else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
11705 return ASC_MAX_VL_DMA_COUNT;
11706 return ASC_MAX_PCI_DMA_COUNT;
11707}
11708
11709#ifdef CONFIG_ISA
11710static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
11711{
11712 ushort channel;
11713
11714 channel = AscGetChipCfgLsw(iop_base) & 0x0003;
11715 if (channel == 0x03)
11716 return (0);
11717 else if (channel == 0x00)
11718 return (7);
11719 return (channel + 4);
11720}
11721
11722static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
11723{
11724 ushort cfg_lsw;
11725 uchar value;
11726
11727 if ((dma_channel >= 5) && (dma_channel <= 7)) {
11728 if (dma_channel == 7)
11729 value = 0x00;
11730 else
11731 value = dma_channel - 4;
11732 cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
11733 cfg_lsw |= value;
11734 AscSetChipCfgLsw(iop_base, cfg_lsw);
11735 return (AscGetIsaDmaChannel(iop_base));
11736 }
11737 return 0;
11738}
11739
11740static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
11741{
11742 uchar speed_value;
11743
11744 AscSetBank(iop_base, 1);
11745 speed_value = AscReadChipDmaSpeed(iop_base);
11746 speed_value &= 0x07;
11747 AscSetBank(iop_base, 0);
11748 return speed_value;
11749}
11750
11751static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
11752{
11753 speed_value &= 0x07;
11754 AscSetBank(iop_base, 1);
11755 AscWriteChipDmaSpeed(iop_base, speed_value);
11756 AscSetBank(iop_base, 0);
11757 return AscGetIsaDmaSpeed(iop_base);
11758}
11759#endif /* CONFIG_ISA */
11760
11761static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
11762{
11763 int i;
11764 PortAddr iop_base;
11765 ushort warn_code;
11766 uchar chip_version;
11767
11768 iop_base = asc_dvc->iop_base;
11769 warn_code = 0;
11770 asc_dvc->err_code = 0;
11771 if ((asc_dvc->bus_type &
11772 (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
11773 asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
11774 }
11775 AscSetChipControl(iop_base, CC_HALT);
11776 AscSetChipStatus(iop_base, 0);
11777 asc_dvc->bug_fix_cntl = 0;
11778 asc_dvc->pci_fix_asyn_xfer = 0;
11779 asc_dvc->pci_fix_asyn_xfer_always = 0;
11780 /* asc_dvc->init_state initalized in AscInitGetConfig(). */
11781 asc_dvc->sdtr_done = 0;
11782 asc_dvc->cur_total_qng = 0;
11783 asc_dvc->is_in_int = 0;
11784 asc_dvc->in_critical_cnt = 0;
11785 asc_dvc->last_q_shortage = 0;
11786 asc_dvc->use_tagged_qng = 0;
11787 asc_dvc->no_scam = 0;
11788 asc_dvc->unit_not_ready = 0;
11789 asc_dvc->queue_full_or_busy = 0;
11790 asc_dvc->redo_scam = 0;
11791 asc_dvc->res2 = 0;
11792 asc_dvc->host_init_sdtr_index = 0;
11793 asc_dvc->cfg->can_tagged_qng = 0;
11794 asc_dvc->cfg->cmd_qng_enabled = 0;
11795 asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
11796 asc_dvc->init_sdtr = 0;
11797 asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
11798 asc_dvc->scsi_reset_wait = 3;
11799 asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
11800 asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
11801 asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
11802 asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
11803 asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
11804 asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
11805 asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
11806 ASC_LIB_VERSION_MINOR;
11807 chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
11808 asc_dvc->cfg->chip_version = chip_version;
11809 asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
11810 asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
11811 asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
11812 asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
11813 asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
11814 asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
11815 asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
11816 asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
11817 asc_dvc->max_sdtr_index = 7;
11818 if ((asc_dvc->bus_type & ASC_IS_PCI) &&
11819 (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
11820 asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
11821 asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
11822 asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
11823 asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
11824 asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
11825 asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
11826 asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
11827 asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
11828 asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
11829 asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
11830 asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
11831 asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
11832 asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
11833 asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
11834 asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
11835 asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
11836 asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
11837 asc_dvc->max_sdtr_index = 15;
11838 if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
11839 AscSetExtraControl(iop_base,
11840 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
11841 } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
11842 AscSetExtraControl(iop_base,
11843 (SEC_ACTIVE_NEGATE |
11844 SEC_ENABLE_FILTER));
11845 }
11846 }
11847 if (asc_dvc->bus_type == ASC_IS_PCI) {
11848 AscSetExtraControl(iop_base,
11849 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
11850 }
11851
11852 asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
11853#ifdef CONFIG_ISA
11854 if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
11855 if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
11856 AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
11857 asc_dvc->bus_type = ASC_IS_ISAPNP;
11858 }
11859 asc_dvc->cfg->isa_dma_channel =
11860 (uchar)AscGetIsaDmaChannel(iop_base);
11861 }
11862#endif /* CONFIG_ISA */
11863 for (i = 0; i <= ASC_MAX_TID; i++) {
11864 asc_dvc->cur_dvc_qng[i] = 0;
11865 asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
11866 asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
11867 asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
11868 asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
11869 }
11870 return warn_code;
11871}
11872
11873static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
11874{
11875 int retry;
11876
11877 for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
11878 unsigned char read_back;
11879 AscSetChipEEPCmd(iop_base, cmd_reg);
11880 mdelay(1);
11881 read_back = AscGetChipEEPCmd(iop_base);
11882 if (read_back == cmd_reg)
11883 return 1;
11884 }
11885 return 0;
11886}
11887
11888static void __devinit AscWaitEEPRead(void)
11889{
11890 mdelay(1);
11891}
11892
11893static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
11894{
11895 ushort read_wval;
11896 uchar cmd_reg;
11897
11898 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
11899 AscWaitEEPRead();
11900 cmd_reg = addr | ASC_EEP_CMD_READ;
11901 AscWriteEEPCmdReg(iop_base, cmd_reg);
11902 AscWaitEEPRead();
11903 read_wval = AscGetChipEEPData(iop_base);
11904 AscWaitEEPRead();
11905 return read_wval;
11906}
11907
11908static ushort __devinit
11909AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
11910{
11911 ushort wval;
11912 ushort sum;
11913 ushort *wbuf;
11914 int cfg_beg;
11915 int cfg_end;
11916 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
11917 int s_addr;
11918
11919 wbuf = (ushort *)cfg_buf;
11920 sum = 0;
11921 /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
11922 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
11923 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
11924 sum += *wbuf;
11925 }
11926 if (bus_type & ASC_IS_VL) {
11927 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
11928 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
11929 } else {
11930 cfg_beg = ASC_EEP_DVC_CFG_BEG;
11931 cfg_end = ASC_EEP_MAX_DVC_ADDR;
11932 }
11933 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
11934 wval = AscReadEEPWord(iop_base, (uchar)s_addr);
11935 if (s_addr <= uchar_end_in_config) {
11936 /*
11937 * Swap all char fields - must unswap bytes already swapped
11938 * by AscReadEEPWord().
11939 */
11940 *wbuf = le16_to_cpu(wval);
11941 } else {
11942 /* Don't swap word field at the end - cntl field. */
11943 *wbuf = wval;
11944 }
11945 sum += wval; /* Checksum treats all EEPROM data as words. */
11946 }
11947 /*
11948 * Read the checksum word which will be compared against 'sum'
11949 * by the caller. Word field already swapped.
11950 */
11951 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
11952 return sum;
11953}
11954
11955static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
11956{
11957 PortAddr iop_base;
11958 ushort q_addr;
11959 ushort saved_word;
11960 int sta;
11961
11962 iop_base = asc_dvc->iop_base;
11963 sta = 0;
11964 q_addr = ASC_QNO_TO_QADDR(241);
11965 saved_word = AscReadLramWord(iop_base, q_addr);
11966 AscSetChipLramAddr(iop_base, q_addr);
11967 AscSetChipLramData(iop_base, 0x55AA);
11968 mdelay(10);
11969 AscSetChipLramAddr(iop_base, q_addr);
11970 if (AscGetChipLramData(iop_base) == 0x55AA) {
11971 sta = 1;
11972 AscWriteLramWord(iop_base, q_addr, saved_word);
11973 }
11974 return (sta);
11975}
11976
11977static void __devinit AscWaitEEPWrite(void)
11978{
11979 mdelay(20);
11980 return;
11981}
11982
11983static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
11984{
11985 ushort read_back;
11986 int retry;
11987
11988 retry = 0;
11989 while (TRUE) {
11990 AscSetChipEEPData(iop_base, data_reg);
11991 mdelay(1);
11992 read_back = AscGetChipEEPData(iop_base);
11993 if (read_back == data_reg) {
11994 return (1);
11995 }
11996 if (retry++ > ASC_EEP_MAX_RETRY) {
11997 return (0);
11998 }
11999 }
12000}
12001
12002static ushort __devinit
12003AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
12004{
12005 ushort read_wval;
12006
12007 read_wval = AscReadEEPWord(iop_base, addr);
12008 if (read_wval != word_val) {
12009 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
12010 AscWaitEEPRead();
12011 AscWriteEEPDataReg(iop_base, word_val);
12012 AscWaitEEPRead();
12013 AscWriteEEPCmdReg(iop_base,
12014 (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
12015 AscWaitEEPWrite();
12016 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
12017 AscWaitEEPRead();
12018 return (AscReadEEPWord(iop_base, addr));
12019 }
12020 return (read_wval);
12021}
12022
12023static int __devinit
12024AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
12025{
12026 int n_error;
12027 ushort *wbuf;
12028 ushort word;
12029 ushort sum;
12030 int s_addr;
12031 int cfg_beg;
12032 int cfg_end;
12033 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
12034
12035 wbuf = (ushort *)cfg_buf;
12036 n_error = 0;
12037 sum = 0;
12038 /* Write two config words; AscWriteEEPWord() will swap bytes. */
12039 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
12040 sum += *wbuf;
12041 if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
12042 n_error++;
12043 }
12044 }
12045 if (bus_type & ASC_IS_VL) {
12046 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
12047 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
12048 } else {
12049 cfg_beg = ASC_EEP_DVC_CFG_BEG;
12050 cfg_end = ASC_EEP_MAX_DVC_ADDR;
12051 }
12052 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
12053 if (s_addr <= uchar_end_in_config) {
12054 /*
12055 * This is a char field. Swap char fields before they are
12056 * swapped again by AscWriteEEPWord().
12057 */
12058 word = cpu_to_le16(*wbuf);
12059 if (word !=
12060 AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
12061 n_error++;
12062 }
12063 } else {
12064 /* Don't swap word field at the end - cntl field. */
12065 if (*wbuf !=
12066 AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
12067 n_error++;
12068 }
12069 }
12070 sum += *wbuf; /* Checksum calculated from word values. */
12071 }
12072 /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
12073 *wbuf = sum;
12074 if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
12075 n_error++;
12076 }
12077
12078 /* Read EEPROM back again. */
12079 wbuf = (ushort *)cfg_buf;
12080 /*
12081 * Read two config words; Byte-swapping done by AscReadEEPWord().
12082 */
12083 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
12084 if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
12085 n_error++;
12086 }
12087 }
12088 if (bus_type & ASC_IS_VL) {
12089 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
12090 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
12091 } else {
12092 cfg_beg = ASC_EEP_DVC_CFG_BEG;
12093 cfg_end = ASC_EEP_MAX_DVC_ADDR;
12094 }
12095 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
12096 if (s_addr <= uchar_end_in_config) {
12097 /*
12098 * Swap all char fields. Must unswap bytes already swapped
12099 * by AscReadEEPWord().
12100 */
12101 word =
12102 le16_to_cpu(AscReadEEPWord
12103 (iop_base, (uchar)s_addr));
12104 } else {
12105 /* Don't swap word field at the end - cntl field. */
12106 word = AscReadEEPWord(iop_base, (uchar)s_addr);
12107 }
12108 if (*wbuf != word) {
12109 n_error++;
12110 }
12111 }
12112 /* Read checksum; Byte swapping not needed. */
12113 if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
12114 n_error++;
12115 }
12116 return n_error;
12117}
12118
12119static int __devinit
12120AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
12121{
12122 int retry;
12123 int n_error;
12124
12125 retry = 0;
12126 while (TRUE) {
12127 if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
12128 bus_type)) == 0) {
12129 break;
12130 }
12131 if (++retry > ASC_EEP_MAX_RETRY) {
12132 break;
12133 }
12134 }
12135 return n_error;
12136}
12137
12138static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
12139{
12140 ASCEEP_CONFIG eep_config_buf;
12141 ASCEEP_CONFIG *eep_config;
12142 PortAddr iop_base;
12143 ushort chksum;
12144 ushort warn_code;
12145 ushort cfg_msw, cfg_lsw;
12146 int i;
12147 int write_eep = 0;
12148
12149 iop_base = asc_dvc->iop_base;
12150 warn_code = 0;
12151 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
12152 AscStopQueueExe(iop_base);
12153 if ((AscStopChip(iop_base) == FALSE) ||
12154 (AscGetChipScsiCtrl(iop_base) != 0)) {
12155 asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
12156 AscResetChipAndScsiBus(asc_dvc);
12157 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
12158 }
12159 if (AscIsChipHalted(iop_base) == FALSE) {
12160 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
12161 return (warn_code);
12162 }
12163 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
12164 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
12165 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
12166 return (warn_code);
12167 }
12168 eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
12169 cfg_msw = AscGetChipCfgMsw(iop_base);
12170 cfg_lsw = AscGetChipCfgLsw(iop_base);
12171 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
12172 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
12173 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
12174 AscSetChipCfgMsw(iop_base, cfg_msw);
12175 }
12176 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
12177 ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
12178 if (chksum == 0) {
12179 chksum = 0xaa55;
12180 }
12181 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
12182 warn_code |= ASC_WARN_AUTO_CONFIG;
12183 if (asc_dvc->cfg->chip_version == 3) {
12184 if (eep_config->cfg_lsw != cfg_lsw) {
12185 warn_code |= ASC_WARN_EEPROM_RECOVER;
12186 eep_config->cfg_lsw =
12187 AscGetChipCfgLsw(iop_base);
12188 }
12189 if (eep_config->cfg_msw != cfg_msw) {
12190 warn_code |= ASC_WARN_EEPROM_RECOVER;
12191 eep_config->cfg_msw =
12192 AscGetChipCfgMsw(iop_base);
12193 }
12194 }
12195 }
12196 eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
12197 eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
12198 ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
12199 eep_config->chksum);
12200 if (chksum != eep_config->chksum) {
12201 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
12202 ASC_CHIP_VER_PCI_ULTRA_3050) {
12203 ASC_DBG(1,
12204 "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
12205 eep_config->init_sdtr = 0xFF;
12206 eep_config->disc_enable = 0xFF;
12207 eep_config->start_motor = 0xFF;
12208 eep_config->use_cmd_qng = 0;
12209 eep_config->max_total_qng = 0xF0;
12210 eep_config->max_tag_qng = 0x20;
12211 eep_config->cntl = 0xBFFF;
12212 ASC_EEP_SET_CHIP_ID(eep_config, 7);
12213 eep_config->no_scam = 0;
12214 eep_config->adapter_info[0] = 0;
12215 eep_config->adapter_info[1] = 0;
12216 eep_config->adapter_info[2] = 0;
12217 eep_config->adapter_info[3] = 0;
12218 eep_config->adapter_info[4] = 0;
12219 /* Indicate EEPROM-less board. */
12220 eep_config->adapter_info[5] = 0xBB;
12221 } else {
12222 ASC_PRINT
12223 ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
12224 write_eep = 1;
12225 warn_code |= ASC_WARN_EEPROM_CHKSUM;
12226 }
12227 }
12228 asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
12229 asc_dvc->cfg->disc_enable = eep_config->disc_enable;
12230 asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
12231 asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
12232 asc_dvc->start_motor = eep_config->start_motor;
12233 asc_dvc->dvc_cntl = eep_config->cntl;
12234 asc_dvc->no_scam = eep_config->no_scam;
12235 asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
12236 asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
12237 asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
12238 asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
12239 asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
12240 asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
12241 if (!AscTestExternalLram(asc_dvc)) {
12242 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
12243 ASC_IS_PCI_ULTRA)) {
12244 eep_config->max_total_qng =
12245 ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
12246 eep_config->max_tag_qng =
12247 ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
12248 } else {
12249 eep_config->cfg_msw |= 0x0800;
12250 cfg_msw |= 0x0800;
12251 AscSetChipCfgMsw(iop_base, cfg_msw);
12252 eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
12253 eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
12254 }
12255 } else {
12256 }
12257 if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
12258 eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
12259 }
12260 if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
12261 eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
12262 }
12263 if (eep_config->max_tag_qng > eep_config->max_total_qng) {
12264 eep_config->max_tag_qng = eep_config->max_total_qng;
12265 }
12266 if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
12267 eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
12268 }
12269 asc_dvc->max_total_qng = eep_config->max_total_qng;
12270 if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
12271 eep_config->use_cmd_qng) {
12272 eep_config->disc_enable = eep_config->use_cmd_qng;
12273 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
12274 }
12275 if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
12276 asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
12277 }
12278 ASC_EEP_SET_CHIP_ID(eep_config,
12279 ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
12280 asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
12281 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
12282 !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
12283 asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
12284 }
12285
12286 for (i = 0; i <= ASC_MAX_TID; i++) {
12287 asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
12288 asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
12289 asc_dvc->cfg->sdtr_period_offset[i] =
12290 (uchar)(ASC_DEF_SDTR_OFFSET |
12291 (asc_dvc->host_init_sdtr_index << 4));
12292 }
12293 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
12294 if (write_eep) {
12295 if ((i = AscSetEEPConfig(iop_base, eep_config,
12296 asc_dvc->bus_type)) != 0) {
12297 ASC_PRINT1
12298 ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
12299 i);
12300 } else {
12301 ASC_PRINT
12302 ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
12303 }
12304 }
12305 return (warn_code);
12306}
12307
12308static int __devinit AscInitGetConfig(asc_board_t *boardp)
12309{
12310 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
12311 unsigned short warn_code = 0;
12312
12313 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
12314 if (asc_dvc->err_code != 0)
12315 return asc_dvc->err_code;
12316
12317 if (AscFindSignature(asc_dvc->iop_base)) {
12318 warn_code |= AscInitAscDvcVar(asc_dvc);
12319 warn_code |= AscInitFromEEP(asc_dvc);
12320 asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
12321 if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
12322 asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
12323 } else {
12324 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
12325 }
12326
12327 switch (warn_code) {
12328 case 0: /* No error */
12329 break;
12330 case ASC_WARN_IO_PORT_ROTATE:
12331 ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
12332 "modified\n", boardp->id);
12333 break;
12334 case ASC_WARN_AUTO_CONFIG:
12335 ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
12336 "switch enabled\n", boardp->id);
12337 break;
12338 case ASC_WARN_EEPROM_CHKSUM:
12339 ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
12340 "error\n", boardp->id);
12341 break;
12342 case ASC_WARN_IRQ_MODIFIED:
12343 ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
12344 boardp->id);
12345 break;
12346 case ASC_WARN_CMD_QNG_CONFLICT:
12347 ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
12348 "w/o disconnects\n", boardp->id);
12349 break;
12350 default:
12351 ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
12352 "0x%x\n", boardp->id, warn_code);
12353 break;
12354 }
12355
12356 if (asc_dvc->err_code != 0) {
12357 ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
12358 "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
12359 asc_dvc->err_code);
12360 }
12361
12362 return asc_dvc->err_code;
12363}
12364
12365static int __devinit AscInitSetConfig(struct pci_dev *pdev, asc_board_t *boardp)
12366{
12367 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
12368 PortAddr iop_base = asc_dvc->iop_base;
12369 unsigned short cfg_msw;
12370 unsigned short warn_code = 0;
12371
12372 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
12373 if (asc_dvc->err_code != 0)
12374 return asc_dvc->err_code;
12375 if (!AscFindSignature(asc_dvc->iop_base)) {
12376 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
12377 return asc_dvc->err_code;
12378 }
12379
12380 cfg_msw = AscGetChipCfgMsw(iop_base);
12381 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
12382 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
12383 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
12384 AscSetChipCfgMsw(iop_base, cfg_msw);
12385 }
12386 if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
12387 asc_dvc->cfg->cmd_qng_enabled) {
12388 asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
12389 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
12390 }
12391 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
12392 warn_code |= ASC_WARN_AUTO_CONFIG;
12393 }
12394 if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
12395 if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
12396 != asc_dvc->irq_no) {
12397 asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
12398 }
12399 }
12400#ifdef CONFIG_PCI
12401 if (asc_dvc->bus_type & ASC_IS_PCI) {
12402 cfg_msw &= 0xFFC0;
12403 AscSetChipCfgMsw(iop_base, cfg_msw);
12404 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
12405 } else {
12406 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
12407 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
12408 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
12409 asc_dvc->bug_fix_cntl |=
12410 ASC_BUG_FIX_ASYN_USE_SYN;
12411 }
12412 }
12413 } else
12414#endif /* CONFIG_PCI */
12415 if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
12416 if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
12417 == ASC_CHIP_VER_ASYN_BUG) {
12418 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
12419 }
12420 }
12421 if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
12422 asc_dvc->cfg->chip_scsi_id) {
12423 asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
12424 }
12425#ifdef CONFIG_ISA
12426 if (asc_dvc->bus_type & ASC_IS_ISA) {
12427 AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
12428 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
12429 }
12430#endif /* CONFIG_ISA */
12431
12432 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
12433
12434 switch (warn_code) {
12435 case 0: /* No error. */
12436 break;
12437 case ASC_WARN_IO_PORT_ROTATE:
12438 ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
12439 "modified\n", boardp->id);
12440 break;
12441 case ASC_WARN_AUTO_CONFIG:
12442 ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
12443 "switch enabled\n", boardp->id);
12444 break;
12445 case ASC_WARN_EEPROM_CHKSUM:
12446 ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
12447 "error\n", boardp->id);
12448 break;
12449 case ASC_WARN_IRQ_MODIFIED:
12450 ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
12451 boardp->id);
12452 break;
12453 case ASC_WARN_CMD_QNG_CONFLICT:
12454 ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
12455 "disconnects\n",
12456 boardp->id);
12457 break;
12458 default:
12459 ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
12460 "0x%x\n", boardp->id, warn_code);
12461 break;
12462 }
12463
12464 if (asc_dvc->err_code != 0) {
12465 ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
12466 "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
12467 asc_dvc->err_code);
12468 }
12469
12470 return asc_dvc->err_code;
12471}
12472
12473/*
12474 * EEPROM Configuration.
12475 *
12476 * All drivers should use this structure to set the default EEPROM
12477 * configuration. The BIOS now uses this structure when it is built.
12478 * Additional structure information can be found in a_condor.h where
12479 * the structure is defined.
12480 *
12481 * The *_Field_IsChar structs are needed to correct for endianness.
12482 * These values are read from the board 16 bits at a time directly
12483 * into the structs. Because some fields are char, the values will be
12484 * in the wrong order. The *_Field_IsChar tells when to flip the
12485 * bytes. Data read and written to PCI memory is automatically swapped
12486 * on big-endian platforms so char fields read as words are actually being
12487 * unswapped on big-endian platforms.
12488 */
12489static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
12490 ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
12491 0x0000, /* cfg_msw */
12492 0xFFFF, /* disc_enable */
12493 0xFFFF, /* wdtr_able */
12494 0xFFFF, /* sdtr_able */
12495 0xFFFF, /* start_motor */
12496 0xFFFF, /* tagqng_able */
12497 0xFFFF, /* bios_scan */
12498 0, /* scam_tolerant */
12499 7, /* adapter_scsi_id */
12500 0, /* bios_boot_delay */
12501 3, /* scsi_reset_delay */
12502 0, /* bios_id_lun */
12503 0, /* termination */
12504 0, /* reserved1 */
12505 0xFFE7, /* bios_ctrl */
12506 0xFFFF, /* ultra_able */
12507 0, /* reserved2 */
12508 ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
12509 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
12510 0, /* dvc_cntl */
12511 0, /* bug_fix */
12512 0, /* serial_number_word1 */
12513 0, /* serial_number_word2 */
12514 0, /* serial_number_word3 */
12515 0, /* check_sum */
12516 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
12517 , /* oem_name[16] */
12518 0, /* dvc_err_code */
12519 0, /* adv_err_code */
12520 0, /* adv_err_addr */
12521 0, /* saved_dvc_err_code */
12522 0, /* saved_adv_err_code */
12523 0, /* saved_adv_err_addr */
12524 0 /* num_of_err */
12525};
12526
12527static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
12528 0, /* cfg_lsw */
12529 0, /* cfg_msw */
12530 0, /* -disc_enable */
12531 0, /* wdtr_able */
12532 0, /* sdtr_able */
12533 0, /* start_motor */
12534 0, /* tagqng_able */
12535 0, /* bios_scan */
12536 0, /* scam_tolerant */
12537 1, /* adapter_scsi_id */
12538 1, /* bios_boot_delay */
12539 1, /* scsi_reset_delay */
12540 1, /* bios_id_lun */
12541 1, /* termination */
12542 1, /* reserved1 */
12543 0, /* bios_ctrl */
12544 0, /* ultra_able */
12545 0, /* reserved2 */
12546 1, /* max_host_qng */
12547 1, /* max_dvc_qng */
12548 0, /* dvc_cntl */
12549 0, /* bug_fix */
12550 0, /* serial_number_word1 */
12551 0, /* serial_number_word2 */
12552 0, /* serial_number_word3 */
12553 0, /* check_sum */
12554 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12555 , /* oem_name[16] */
12556 0, /* dvc_err_code */
12557 0, /* adv_err_code */
12558 0, /* adv_err_addr */
12559 0, /* saved_dvc_err_code */
12560 0, /* saved_adv_err_code */
12561 0, /* saved_adv_err_addr */
12562 0 /* num_of_err */
12563};
12564
12565static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
12566 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
12567 0x0000, /* 01 cfg_msw */
12568 0xFFFF, /* 02 disc_enable */
12569 0xFFFF, /* 03 wdtr_able */
12570 0x4444, /* 04 sdtr_speed1 */
12571 0xFFFF, /* 05 start_motor */
12572 0xFFFF, /* 06 tagqng_able */
12573 0xFFFF, /* 07 bios_scan */
12574 0, /* 08 scam_tolerant */
12575 7, /* 09 adapter_scsi_id */
12576 0, /* bios_boot_delay */
12577 3, /* 10 scsi_reset_delay */
12578 0, /* bios_id_lun */
12579 0, /* 11 termination_se */
12580 0, /* termination_lvd */
12581 0xFFE7, /* 12 bios_ctrl */
12582 0x4444, /* 13 sdtr_speed2 */
12583 0x4444, /* 14 sdtr_speed3 */
12584 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
12585 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
12586 0, /* 16 dvc_cntl */
12587 0x4444, /* 17 sdtr_speed4 */
12588 0, /* 18 serial_number_word1 */
12589 0, /* 19 serial_number_word2 */
12590 0, /* 20 serial_number_word3 */
12591 0, /* 21 check_sum */
12592 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
12593 , /* 22-29 oem_name[16] */
12594 0, /* 30 dvc_err_code */
12595 0, /* 31 adv_err_code */
12596 0, /* 32 adv_err_addr */
12597 0, /* 33 saved_dvc_err_code */
12598 0, /* 34 saved_adv_err_code */
12599 0, /* 35 saved_adv_err_addr */
12600 0, /* 36 reserved */
12601 0, /* 37 reserved */
12602 0, /* 38 reserved */
12603 0, /* 39 reserved */
12604 0, /* 40 reserved */
12605 0, /* 41 reserved */
12606 0, /* 42 reserved */
12607 0, /* 43 reserved */
12608 0, /* 44 reserved */
12609 0, /* 45 reserved */
12610 0, /* 46 reserved */
12611 0, /* 47 reserved */
12612 0, /* 48 reserved */
12613 0, /* 49 reserved */
12614 0, /* 50 reserved */
12615 0, /* 51 reserved */
12616 0, /* 52 reserved */
12617 0, /* 53 reserved */
12618 0, /* 54 reserved */
12619 0, /* 55 reserved */
12620 0, /* 56 cisptr_lsw */
12621 0, /* 57 cisprt_msw */
12622 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
12623 PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
12624 0, /* 60 reserved */
12625 0, /* 61 reserved */
12626 0, /* 62 reserved */
12627 0 /* 63 reserved */
12628};
12629
12630static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
12631 0, /* 00 cfg_lsw */
12632 0, /* 01 cfg_msw */
12633 0, /* 02 disc_enable */
12634 0, /* 03 wdtr_able */
12635 0, /* 04 sdtr_speed1 */
12636 0, /* 05 start_motor */
12637 0, /* 06 tagqng_able */
12638 0, /* 07 bios_scan */
12639 0, /* 08 scam_tolerant */
12640 1, /* 09 adapter_scsi_id */
12641 1, /* bios_boot_delay */
12642 1, /* 10 scsi_reset_delay */
12643 1, /* bios_id_lun */
12644 1, /* 11 termination_se */
12645 1, /* termination_lvd */
12646 0, /* 12 bios_ctrl */
12647 0, /* 13 sdtr_speed2 */
12648 0, /* 14 sdtr_speed3 */
12649 1, /* 15 max_host_qng */
12650 1, /* max_dvc_qng */
12651 0, /* 16 dvc_cntl */
12652 0, /* 17 sdtr_speed4 */
12653 0, /* 18 serial_number_word1 */
12654 0, /* 19 serial_number_word2 */
12655 0, /* 20 serial_number_word3 */
12656 0, /* 21 check_sum */
12657 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12658 , /* 22-29 oem_name[16] */
12659 0, /* 30 dvc_err_code */
12660 0, /* 31 adv_err_code */
12661 0, /* 32 adv_err_addr */
12662 0, /* 33 saved_dvc_err_code */
12663 0, /* 34 saved_adv_err_code */
12664 0, /* 35 saved_adv_err_addr */
12665 0, /* 36 reserved */
12666 0, /* 37 reserved */
12667 0, /* 38 reserved */
12668 0, /* 39 reserved */
12669 0, /* 40 reserved */
12670 0, /* 41 reserved */
12671 0, /* 42 reserved */
12672 0, /* 43 reserved */
12673 0, /* 44 reserved */
12674 0, /* 45 reserved */
12675 0, /* 46 reserved */
12676 0, /* 47 reserved */
12677 0, /* 48 reserved */
12678 0, /* 49 reserved */
12679 0, /* 50 reserved */
12680 0, /* 51 reserved */
12681 0, /* 52 reserved */
12682 0, /* 53 reserved */
12683 0, /* 54 reserved */
12684 0, /* 55 reserved */
12685 0, /* 56 cisptr_lsw */
12686 0, /* 57 cisprt_msw */
12687 0, /* 58 subsysvid */
12688 0, /* 59 subsysid */
12689 0, /* 60 reserved */
12690 0, /* 61 reserved */
12691 0, /* 62 reserved */
12692 0 /* 63 reserved */
12693};
12694
12695static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
12696 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
12697 0x0000, /* 01 cfg_msw */
12698 0xFFFF, /* 02 disc_enable */
12699 0xFFFF, /* 03 wdtr_able */
12700 0x5555, /* 04 sdtr_speed1 */
12701 0xFFFF, /* 05 start_motor */
12702 0xFFFF, /* 06 tagqng_able */
12703 0xFFFF, /* 07 bios_scan */
12704 0, /* 08 scam_tolerant */
12705 7, /* 09 adapter_scsi_id */
12706 0, /* bios_boot_delay */
12707 3, /* 10 scsi_reset_delay */
12708 0, /* bios_id_lun */
12709 0, /* 11 termination_se */
12710 0, /* termination_lvd */
12711 0xFFE7, /* 12 bios_ctrl */
12712 0x5555, /* 13 sdtr_speed2 */
12713 0x5555, /* 14 sdtr_speed3 */
12714 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
12715 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
12716 0, /* 16 dvc_cntl */
12717 0x5555, /* 17 sdtr_speed4 */
12718 0, /* 18 serial_number_word1 */
12719 0, /* 19 serial_number_word2 */
12720 0, /* 20 serial_number_word3 */
12721 0, /* 21 check_sum */
12722 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
12723 , /* 22-29 oem_name[16] */
12724 0, /* 30 dvc_err_code */
12725 0, /* 31 adv_err_code */
12726 0, /* 32 adv_err_addr */
12727 0, /* 33 saved_dvc_err_code */
12728 0, /* 34 saved_adv_err_code */
12729 0, /* 35 saved_adv_err_addr */
12730 0, /* 36 reserved */
12731 0, /* 37 reserved */
12732 0, /* 38 reserved */
12733 0, /* 39 reserved */
12734 0, /* 40 reserved */
12735 0, /* 41 reserved */
12736 0, /* 42 reserved */
12737 0, /* 43 reserved */
12738 0, /* 44 reserved */
12739 0, /* 45 reserved */
12740 0, /* 46 reserved */
12741 0, /* 47 reserved */
12742 0, /* 48 reserved */
12743 0, /* 49 reserved */
12744 0, /* 50 reserved */
12745 0, /* 51 reserved */
12746 0, /* 52 reserved */
12747 0, /* 53 reserved */
12748 0, /* 54 reserved */
12749 0, /* 55 reserved */
12750 0, /* 56 cisptr_lsw */
12751 0, /* 57 cisprt_msw */
12752 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
12753 PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
12754 0, /* 60 reserved */
12755 0, /* 61 reserved */
12756 0, /* 62 reserved */
12757 0 /* 63 reserved */
12758};
12759
12760static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
12761 0, /* 00 cfg_lsw */
12762 0, /* 01 cfg_msw */
12763 0, /* 02 disc_enable */
12764 0, /* 03 wdtr_able */
12765 0, /* 04 sdtr_speed1 */
12766 0, /* 05 start_motor */
12767 0, /* 06 tagqng_able */
12768 0, /* 07 bios_scan */
12769 0, /* 08 scam_tolerant */
12770 1, /* 09 adapter_scsi_id */
12771 1, /* bios_boot_delay */
12772 1, /* 10 scsi_reset_delay */
12773 1, /* bios_id_lun */
12774 1, /* 11 termination_se */
12775 1, /* termination_lvd */
12776 0, /* 12 bios_ctrl */
12777 0, /* 13 sdtr_speed2 */
12778 0, /* 14 sdtr_speed3 */
12779 1, /* 15 max_host_qng */
12780 1, /* max_dvc_qng */
12781 0, /* 16 dvc_cntl */
12782 0, /* 17 sdtr_speed4 */
12783 0, /* 18 serial_number_word1 */
12784 0, /* 19 serial_number_word2 */
12785 0, /* 20 serial_number_word3 */
12786 0, /* 21 check_sum */
12787 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12788 , /* 22-29 oem_name[16] */
12789 0, /* 30 dvc_err_code */
12790 0, /* 31 adv_err_code */
12791 0, /* 32 adv_err_addr */
12792 0, /* 33 saved_dvc_err_code */
12793 0, /* 34 saved_adv_err_code */
12794 0, /* 35 saved_adv_err_addr */
12795 0, /* 36 reserved */
12796 0, /* 37 reserved */
12797 0, /* 38 reserved */
12798 0, /* 39 reserved */
12799 0, /* 40 reserved */
12800 0, /* 41 reserved */
12801 0, /* 42 reserved */
12802 0, /* 43 reserved */
12803 0, /* 44 reserved */
12804 0, /* 45 reserved */
12805 0, /* 46 reserved */
12806 0, /* 47 reserved */
12807 0, /* 48 reserved */
12808 0, /* 49 reserved */
12809 0, /* 50 reserved */
12810 0, /* 51 reserved */
12811 0, /* 52 reserved */
12812 0, /* 53 reserved */
12813 0, /* 54 reserved */
12814 0, /* 55 reserved */
12815 0, /* 56 cisptr_lsw */
12816 0, /* 57 cisprt_msw */
12817 0, /* 58 subsysvid */
12818 0, /* 59 subsysid */
12819 0, /* 60 reserved */
12820 0, /* 61 reserved */
12821 0, /* 62 reserved */
12822 0 /* 63 reserved */
12823};
12824
12825#ifdef CONFIG_PCI
12826/*
12827 * Wait for EEPROM command to complete
12828 */
12829static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
12830{
12831 int eep_delay_ms;
12832
12833 for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
12834 if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
12835 ASC_EEP_CMD_DONE) {
12836 break;
12837 }
12838 mdelay(1);
12839 }
12840 if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
12841 0)
12842 BUG();
12843}
12844
12845/*
12846 * Read the EEPROM from specified location
12847 */
12848static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
12849{
12850 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12851 ASC_EEP_CMD_READ | eep_word_addr);
12852 AdvWaitEEPCmd(iop_base);
12853 return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
12854}
12855
12856/*
12857 * Write the EEPROM from 'cfg_buf'.
12858 */
12859void __devinit
12860AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
12861{
12862 ushort *wbuf;
12863 ushort addr, chksum;
12864 ushort *charfields;
12865
12866 wbuf = (ushort *)cfg_buf;
12867 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
12868 chksum = 0;
12869
12870 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
12871 AdvWaitEEPCmd(iop_base);
12872
12873 /*
12874 * Write EEPROM from word 0 to word 20.
12875 */
12876 for (addr = ADV_EEP_DVC_CFG_BEGIN;
12877 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
12878 ushort word;
12879
12880 if (*charfields++) {
12881 word = cpu_to_le16(*wbuf);
12882 } else {
12883 word = *wbuf;
12884 }
12885 chksum += *wbuf; /* Checksum is calculated from word values. */
12886 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12887 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12888 ASC_EEP_CMD_WRITE | addr);
12889 AdvWaitEEPCmd(iop_base);
12890 mdelay(ADV_EEP_DELAY_MS);
12891 }
12892
12893 /*
12894 * Write EEPROM checksum at word 21.
12895 */
12896 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
12897 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
12898 AdvWaitEEPCmd(iop_base);
12899 wbuf++;
12900 charfields++;
12901
12902 /*
12903 * Write EEPROM OEM name at words 22 to 29.
12904 */
12905 for (addr = ADV_EEP_DVC_CTL_BEGIN;
12906 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
12907 ushort word;
12908
12909 if (*charfields++) {
12910 word = cpu_to_le16(*wbuf);
12911 } else {
12912 word = *wbuf;
12913 }
12914 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12915 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12916 ASC_EEP_CMD_WRITE | addr);
12917 AdvWaitEEPCmd(iop_base);
12918 }
12919 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
12920 AdvWaitEEPCmd(iop_base);
12921}
12922
12923/*
12924 * Write the EEPROM from 'cfg_buf'.
12925 */
12926void __devinit
12927AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
12928{
12929 ushort *wbuf;
12930 ushort *charfields;
12931 ushort addr, chksum;
12932
12933 wbuf = (ushort *)cfg_buf;
12934 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
12935 chksum = 0;
12936
12937 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
12938 AdvWaitEEPCmd(iop_base);
12939
12940 /*
12941 * Write EEPROM from word 0 to word 20.
12942 */
12943 for (addr = ADV_EEP_DVC_CFG_BEGIN;
12944 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
12945 ushort word;
12946
12947 if (*charfields++) {
12948 word = cpu_to_le16(*wbuf);
12949 } else {
12950 word = *wbuf;
12951 }
12952 chksum += *wbuf; /* Checksum is calculated from word values. */
12953 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12954 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12955 ASC_EEP_CMD_WRITE | addr);
12956 AdvWaitEEPCmd(iop_base);
12957 mdelay(ADV_EEP_DELAY_MS);
12958 }
12959
12960 /*
12961 * Write EEPROM checksum at word 21.
12962 */
12963 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
12964 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
12965 AdvWaitEEPCmd(iop_base);
12966 wbuf++;
12967 charfields++;
12968
12969 /*
12970 * Write EEPROM OEM name at words 22 to 29.
12971 */
12972 for (addr = ADV_EEP_DVC_CTL_BEGIN;
12973 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
12974 ushort word;
12975
12976 if (*charfields++) {
12977 word = cpu_to_le16(*wbuf);
12978 } else {
12979 word = *wbuf;
12980 }
12981 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12982 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12983 ASC_EEP_CMD_WRITE | addr);
12984 AdvWaitEEPCmd(iop_base);
12985 }
12986 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
12987 AdvWaitEEPCmd(iop_base);
12988}
12989
12990/*
12991 * Write the EEPROM from 'cfg_buf'.
12992 */
12993void __devinit
12994AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
12995{
12996 ushort *wbuf;
12997 ushort *charfields;
12998 ushort addr, chksum;
12999
13000 wbuf = (ushort *)cfg_buf;
13001 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
13002 chksum = 0;
13003
13004 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
13005 AdvWaitEEPCmd(iop_base);
13006
13007 /*
13008 * Write EEPROM from word 0 to word 20.
13009 */
13010 for (addr = ADV_EEP_DVC_CFG_BEGIN;
13011 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
13012 ushort word;
13013
13014 if (*charfields++) {
13015 word = cpu_to_le16(*wbuf);
13016 } else {
13017 word = *wbuf;
13018 }
13019 chksum += *wbuf; /* Checksum is calculated from word values. */
13020 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
13021 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
13022 ASC_EEP_CMD_WRITE | addr);
13023 AdvWaitEEPCmd(iop_base);
13024 mdelay(ADV_EEP_DELAY_MS);
13025 }
13026
13027 /*
13028 * Write EEPROM checksum at word 21.
13029 */
13030 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
13031 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
13032 AdvWaitEEPCmd(iop_base);
13033 wbuf++;
13034 charfields++;
13035
13036 /*
13037 * Write EEPROM OEM name at words 22 to 29.
13038 */
13039 for (addr = ADV_EEP_DVC_CTL_BEGIN;
13040 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
13041 ushort word;
13042
13043 if (*charfields++) {
13044 word = cpu_to_le16(*wbuf);
13045 } else {
13046 word = *wbuf;
13047 }
13048 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
13049 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
13050 ASC_EEP_CMD_WRITE | addr);
13051 AdvWaitEEPCmd(iop_base);
13052 }
13053 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
13054 AdvWaitEEPCmd(iop_base);
13055}
13056
13057/*
13058 * Read EEPROM configuration into the specified buffer.
13059 *
13060 * Return a checksum based on the EEPROM configuration read.
13061 */
13062static ushort __devinit
13063AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
13064{
13065 ushort wval, chksum;
13066 ushort *wbuf;
13067 int eep_addr;
13068 ushort *charfields;
13069
13070 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
13071 wbuf = (ushort *)cfg_buf;
13072 chksum = 0;
13073
13074 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
13075 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
13076 wval = AdvReadEEPWord(iop_base, eep_addr);
13077 chksum += wval; /* Checksum is calculated from word values. */
13078 if (*charfields++) {
13079 *wbuf = le16_to_cpu(wval);
13080 } else {
13081 *wbuf = wval;
13082 }
13083 }
13084 /* Read checksum word. */
13085 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
13086 wbuf++;
13087 charfields++;
13088
13089 /* Read rest of EEPROM not covered by the checksum. */
13090 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
13091 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
13092 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
13093 if (*charfields++) {
13094 *wbuf = le16_to_cpu(*wbuf);
13095 }
13096 }
13097 return chksum;
13098}
13099
13100/*
13101 * Read EEPROM configuration into the specified buffer.
13102 *
13103 * Return a checksum based on the EEPROM configuration read.
13104 */
13105static ushort __devinit
13106AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
13107{
13108 ushort wval, chksum;
13109 ushort *wbuf;
13110 int eep_addr;
13111 ushort *charfields;
13112
13113 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
13114 wbuf = (ushort *)cfg_buf;
13115 chksum = 0;
13116
13117 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
13118 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
13119 wval = AdvReadEEPWord(iop_base, eep_addr);
13120 chksum += wval; /* Checksum is calculated from word values. */
13121 if (*charfields++) {
13122 *wbuf = le16_to_cpu(wval);
13123 } else {
13124 *wbuf = wval;
13125 }
13126 }
13127 /* Read checksum word. */
13128 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
13129 wbuf++;
13130 charfields++;
13131
13132 /* Read rest of EEPROM not covered by the checksum. */
13133 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
13134 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
13135 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
13136 if (*charfields++) {
13137 *wbuf = le16_to_cpu(*wbuf);
13138 }
13139 }
13140 return chksum;
13141}
13142
13143/*
13144 * Read EEPROM configuration into the specified buffer.
13145 *
13146 * Return a checksum based on the EEPROM configuration read.
13147 */
13148static ushort __devinit
13149AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
13150{
13151 ushort wval, chksum;
13152 ushort *wbuf;
13153 int eep_addr;
13154 ushort *charfields;
13155
13156 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
13157 wbuf = (ushort *)cfg_buf;
13158 chksum = 0;
13159
13160 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
13161 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
13162 wval = AdvReadEEPWord(iop_base, eep_addr);
13163 chksum += wval; /* Checksum is calculated from word values. */
13164 if (*charfields++) {
13165 *wbuf = le16_to_cpu(wval);
13166 } else {
13167 *wbuf = wval;
13168 }
13169 }
13170 /* Read checksum word. */
13171 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
13172 wbuf++;
13173 charfields++;
13174
13175 /* Read rest of EEPROM not covered by the checksum. */
13176 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
13177 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
13178 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
13179 if (*charfields++) {
13180 *wbuf = le16_to_cpu(*wbuf);
13181 }
13182 }
13183 return chksum;
13184}
13185
13186/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070013187 * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
13188 * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
13189 * all of this is done.
13190 *
13191 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
13192 *
13193 * For a non-fatal error return a warning code. If there are no warnings
13194 * then 0 is returned.
13195 *
13196 * Note: Chip is stopped on entry.
13197 */
Matthew Wilcox78e77d82007-07-29 21:46:15 -060013198static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013199{
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013200 AdvPortAddr iop_base;
13201 ushort warn_code;
13202 ADVEEP_3550_CONFIG eep_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013203
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013204 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013205
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013206 warn_code = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013207
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013208 /*
13209 * Read the board's EEPROM configuration.
13210 *
13211 * Set default values if a bad checksum is found.
13212 */
13213 if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
13214 warn_code |= ASC_WARN_EEPROM_CHKSUM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013215
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013216 /*
13217 * Set EEPROM default values.
13218 */
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013219 memcpy(&eep_config, &Default_3550_EEPROM_Config,
13220 sizeof(ADVEEP_3550_CONFIG));
Linus Torvalds1da177e2005-04-16 15:20:36 -070013221
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013222 /*
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013223 * Assume the 6 byte board serial number that was read from
13224 * EEPROM is correct even if the EEPROM checksum failed.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013225 */
13226 eep_config.serial_number_word3 =
13227 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013228
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013229 eep_config.serial_number_word2 =
13230 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013231
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013232 eep_config.serial_number_word1 =
13233 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013234
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013235 AdvSet3550EEPConfig(iop_base, &eep_config);
13236 }
13237 /*
13238 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
13239 * EEPROM configuration that was read.
13240 *
13241 * This is the mapping of EEPROM fields to Adv Library fields.
13242 */
13243 asc_dvc->wdtr_able = eep_config.wdtr_able;
13244 asc_dvc->sdtr_able = eep_config.sdtr_able;
13245 asc_dvc->ultra_able = eep_config.ultra_able;
13246 asc_dvc->tagqng_able = eep_config.tagqng_able;
13247 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
13248 asc_dvc->max_host_qng = eep_config.max_host_qng;
13249 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
13250 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
13251 asc_dvc->start_motor = eep_config.start_motor;
13252 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
13253 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
13254 asc_dvc->no_scam = eep_config.scam_tolerant;
13255 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
13256 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
13257 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013258
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013259 /*
13260 * Set the host maximum queuing (max. 253, min. 16) and the per device
13261 * maximum queuing (max. 63, min. 4).
13262 */
13263 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
13264 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13265 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
13266 /* If the value is zero, assume it is uninitialized. */
13267 if (eep_config.max_host_qng == 0) {
13268 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13269 } else {
13270 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
13271 }
13272 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013273
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013274 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
13275 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13276 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
13277 /* If the value is zero, assume it is uninitialized. */
13278 if (eep_config.max_dvc_qng == 0) {
13279 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13280 } else {
13281 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
13282 }
13283 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013284
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013285 /*
13286 * If 'max_dvc_qng' is greater than 'max_host_qng', then
13287 * set 'max_dvc_qng' to 'max_host_qng'.
13288 */
13289 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
13290 eep_config.max_dvc_qng = eep_config.max_host_qng;
13291 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013292
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013293 /*
13294 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
13295 * values based on possibly adjusted EEPROM values.
13296 */
13297 asc_dvc->max_host_qng = eep_config.max_host_qng;
13298 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013299
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013300 /*
13301 * If the EEPROM 'termination' field is set to automatic (0), then set
13302 * the ADV_DVC_CFG 'termination' field to automatic also.
13303 *
13304 * If the termination is specified with a non-zero 'termination'
13305 * value check that a legal value is set and set the ADV_DVC_CFG
13306 * 'termination' field appropriately.
13307 */
13308 if (eep_config.termination == 0) {
13309 asc_dvc->cfg->termination = 0; /* auto termination */
13310 } else {
13311 /* Enable manual control with low off / high off. */
13312 if (eep_config.termination == 1) {
13313 asc_dvc->cfg->termination = TERM_CTL_SEL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013314
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013315 /* Enable manual control with low off / high on. */
13316 } else if (eep_config.termination == 2) {
13317 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013318
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013319 /* Enable manual control with low on / high on. */
13320 } else if (eep_config.termination == 3) {
13321 asc_dvc->cfg->termination =
13322 TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
13323 } else {
13324 /*
13325 * The EEPROM 'termination' field contains a bad value. Use
13326 * automatic termination instead.
13327 */
13328 asc_dvc->cfg->termination = 0;
13329 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13330 }
13331 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013332
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013333 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013334}
13335
13336/*
13337 * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
13338 * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
13339 * all of this is done.
13340 *
13341 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
13342 *
13343 * For a non-fatal error return a warning code. If there are no warnings
13344 * then 0 is returned.
13345 *
13346 * Note: Chip is stopped on entry.
13347 */
Matthew Wilcox78e77d82007-07-29 21:46:15 -060013348static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013349{
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013350 AdvPortAddr iop_base;
13351 ushort warn_code;
13352 ADVEEP_38C0800_CONFIG eep_config;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013353 uchar tid, termination;
13354 ushort sdtr_speed = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013355
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013356 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013357
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013358 warn_code = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013359
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013360 /*
13361 * Read the board's EEPROM configuration.
13362 *
13363 * Set default values if a bad checksum is found.
13364 */
13365 if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
13366 eep_config.check_sum) {
13367 warn_code |= ASC_WARN_EEPROM_CHKSUM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013368
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013369 /*
13370 * Set EEPROM default values.
13371 */
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013372 memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
13373 sizeof(ADVEEP_38C0800_CONFIG));
Linus Torvalds1da177e2005-04-16 15:20:36 -070013374
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013375 /*
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013376 * Assume the 6 byte board serial number that was read from
13377 * EEPROM is correct even if the EEPROM checksum failed.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013378 */
13379 eep_config.serial_number_word3 =
13380 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013381
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013382 eep_config.serial_number_word2 =
13383 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013384
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013385 eep_config.serial_number_word1 =
13386 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013387
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013388 AdvSet38C0800EEPConfig(iop_base, &eep_config);
13389 }
13390 /*
13391 * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
13392 * EEPROM configuration that was read.
13393 *
13394 * This is the mapping of EEPROM fields to Adv Library fields.
13395 */
13396 asc_dvc->wdtr_able = eep_config.wdtr_able;
13397 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
13398 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
13399 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
13400 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
13401 asc_dvc->tagqng_able = eep_config.tagqng_able;
13402 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
13403 asc_dvc->max_host_qng = eep_config.max_host_qng;
13404 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
13405 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
13406 asc_dvc->start_motor = eep_config.start_motor;
13407 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
13408 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
13409 asc_dvc->no_scam = eep_config.scam_tolerant;
13410 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
13411 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
13412 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013413
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013414 /*
13415 * For every Target ID if any of its 'sdtr_speed[1234]' bits
13416 * are set, then set an 'sdtr_able' bit for it.
13417 */
13418 asc_dvc->sdtr_able = 0;
13419 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
13420 if (tid == 0) {
13421 sdtr_speed = asc_dvc->sdtr_speed1;
13422 } else if (tid == 4) {
13423 sdtr_speed = asc_dvc->sdtr_speed2;
13424 } else if (tid == 8) {
13425 sdtr_speed = asc_dvc->sdtr_speed3;
13426 } else if (tid == 12) {
13427 sdtr_speed = asc_dvc->sdtr_speed4;
13428 }
13429 if (sdtr_speed & ADV_MAX_TID) {
13430 asc_dvc->sdtr_able |= (1 << tid);
13431 }
13432 sdtr_speed >>= 4;
13433 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013434
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013435 /*
13436 * Set the host maximum queuing (max. 253, min. 16) and the per device
13437 * maximum queuing (max. 63, min. 4).
13438 */
13439 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
13440 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13441 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
13442 /* If the value is zero, assume it is uninitialized. */
13443 if (eep_config.max_host_qng == 0) {
13444 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13445 } else {
13446 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
13447 }
13448 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013449
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013450 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
13451 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13452 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
13453 /* If the value is zero, assume it is uninitialized. */
13454 if (eep_config.max_dvc_qng == 0) {
13455 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13456 } else {
13457 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
13458 }
13459 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013460
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013461 /*
13462 * If 'max_dvc_qng' is greater than 'max_host_qng', then
13463 * set 'max_dvc_qng' to 'max_host_qng'.
13464 */
13465 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
13466 eep_config.max_dvc_qng = eep_config.max_host_qng;
13467 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013468
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013469 /*
13470 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
13471 * values based on possibly adjusted EEPROM values.
13472 */
13473 asc_dvc->max_host_qng = eep_config.max_host_qng;
13474 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013475
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013476 /*
13477 * If the EEPROM 'termination' field is set to automatic (0), then set
13478 * the ADV_DVC_CFG 'termination' field to automatic also.
13479 *
13480 * If the termination is specified with a non-zero 'termination'
13481 * value check that a legal value is set and set the ADV_DVC_CFG
13482 * 'termination' field appropriately.
13483 */
13484 if (eep_config.termination_se == 0) {
13485 termination = 0; /* auto termination for SE */
13486 } else {
13487 /* Enable manual control with low off / high off. */
13488 if (eep_config.termination_se == 1) {
13489 termination = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013490
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013491 /* Enable manual control with low off / high on. */
13492 } else if (eep_config.termination_se == 2) {
13493 termination = TERM_SE_HI;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013494
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013495 /* Enable manual control with low on / high on. */
13496 } else if (eep_config.termination_se == 3) {
13497 termination = TERM_SE;
13498 } else {
13499 /*
13500 * The EEPROM 'termination_se' field contains a bad value.
13501 * Use automatic termination instead.
13502 */
13503 termination = 0;
13504 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13505 }
13506 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013507
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013508 if (eep_config.termination_lvd == 0) {
13509 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
13510 } else {
13511 /* Enable manual control with low off / high off. */
13512 if (eep_config.termination_lvd == 1) {
13513 asc_dvc->cfg->termination = termination;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013514
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013515 /* Enable manual control with low off / high on. */
13516 } else if (eep_config.termination_lvd == 2) {
13517 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013518
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013519 /* Enable manual control with low on / high on. */
13520 } else if (eep_config.termination_lvd == 3) {
13521 asc_dvc->cfg->termination = termination | TERM_LVD;
13522 } else {
13523 /*
13524 * The EEPROM 'termination_lvd' field contains a bad value.
13525 * Use automatic termination instead.
13526 */
13527 asc_dvc->cfg->termination = termination;
13528 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13529 }
13530 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013531
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013532 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013533}
13534
13535/*
13536 * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
13537 * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
13538 * all of this is done.
13539 *
13540 * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
13541 *
13542 * For a non-fatal error return a warning code. If there are no warnings
13543 * then 0 is returned.
13544 *
13545 * Note: Chip is stopped on entry.
13546 */
Matthew Wilcox78e77d82007-07-29 21:46:15 -060013547static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013548{
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013549 AdvPortAddr iop_base;
13550 ushort warn_code;
13551 ADVEEP_38C1600_CONFIG eep_config;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013552 uchar tid, termination;
13553 ushort sdtr_speed = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013554
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013555 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013556
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013557 warn_code = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013558
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013559 /*
13560 * Read the board's EEPROM configuration.
13561 *
13562 * Set default values if a bad checksum is found.
13563 */
13564 if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
13565 eep_config.check_sum) {
Matthew Wilcox13ac2d92007-07-30 08:10:23 -060013566 struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013567 warn_code |= ASC_WARN_EEPROM_CHKSUM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013568
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013569 /*
13570 * Set EEPROM default values.
13571 */
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013572 memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
13573 sizeof(ADVEEP_38C1600_CONFIG));
Linus Torvalds1da177e2005-04-16 15:20:36 -070013574
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013575 if (PCI_FUNC(pdev->devfn) != 0) {
13576 u8 ints;
13577 /*
13578 * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
13579 * and old Mac system booting problem. The Expansion
13580 * ROM must be disabled in Function 1 for these systems
13581 */
13582 eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
13583 /*
13584 * Clear the INTAB (bit 11) if the GPIO 0 input
13585 * indicates the Function 1 interrupt line is wired
13586 * to INTB.
13587 *
13588 * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
13589 * 1 - Function 1 interrupt line wired to INT A.
13590 * 0 - Function 1 interrupt line wired to INT B.
13591 *
13592 * Note: Function 0 is always wired to INTA.
13593 * Put all 5 GPIO bits in input mode and then read
13594 * their input values.
13595 */
13596 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
13597 ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
13598 if ((ints & 0x01) == 0)
13599 eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013600 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013601
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013602 /*
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013603 * Assume the 6 byte board serial number that was read from
13604 * EEPROM is correct even if the EEPROM checksum failed.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013605 */
13606 eep_config.serial_number_word3 =
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013607 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013608 eep_config.serial_number_word2 =
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013609 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013610 eep_config.serial_number_word1 =
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013611 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013612
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013613 AdvSet38C1600EEPConfig(iop_base, &eep_config);
13614 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013615
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013616 /*
13617 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
13618 * EEPROM configuration that was read.
13619 *
13620 * This is the mapping of EEPROM fields to Adv Library fields.
13621 */
13622 asc_dvc->wdtr_able = eep_config.wdtr_able;
13623 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
13624 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
13625 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
13626 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
13627 asc_dvc->ppr_able = 0;
13628 asc_dvc->tagqng_able = eep_config.tagqng_able;
13629 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
13630 asc_dvc->max_host_qng = eep_config.max_host_qng;
13631 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
13632 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
13633 asc_dvc->start_motor = eep_config.start_motor;
13634 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
13635 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
13636 asc_dvc->no_scam = eep_config.scam_tolerant;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013637
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013638 /*
13639 * For every Target ID if any of its 'sdtr_speed[1234]' bits
13640 * are set, then set an 'sdtr_able' bit for it.
13641 */
13642 asc_dvc->sdtr_able = 0;
13643 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
13644 if (tid == 0) {
13645 sdtr_speed = asc_dvc->sdtr_speed1;
13646 } else if (tid == 4) {
13647 sdtr_speed = asc_dvc->sdtr_speed2;
13648 } else if (tid == 8) {
13649 sdtr_speed = asc_dvc->sdtr_speed3;
13650 } else if (tid == 12) {
13651 sdtr_speed = asc_dvc->sdtr_speed4;
13652 }
13653 if (sdtr_speed & ASC_MAX_TID) {
13654 asc_dvc->sdtr_able |= (1 << tid);
13655 }
13656 sdtr_speed >>= 4;
13657 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013658
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013659 /*
13660 * Set the host maximum queuing (max. 253, min. 16) and the per device
13661 * maximum queuing (max. 63, min. 4).
13662 */
13663 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
13664 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13665 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
13666 /* If the value is zero, assume it is uninitialized. */
13667 if (eep_config.max_host_qng == 0) {
13668 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13669 } else {
13670 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
13671 }
13672 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013673
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013674 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
13675 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13676 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
13677 /* If the value is zero, assume it is uninitialized. */
13678 if (eep_config.max_dvc_qng == 0) {
13679 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13680 } else {
13681 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
13682 }
13683 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013684
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013685 /*
13686 * If 'max_dvc_qng' is greater than 'max_host_qng', then
13687 * set 'max_dvc_qng' to 'max_host_qng'.
13688 */
13689 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
13690 eep_config.max_dvc_qng = eep_config.max_host_qng;
13691 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013692
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013693 /*
13694 * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
13695 * values based on possibly adjusted EEPROM values.
13696 */
13697 asc_dvc->max_host_qng = eep_config.max_host_qng;
13698 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013699
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013700 /*
13701 * If the EEPROM 'termination' field is set to automatic (0), then set
13702 * the ASC_DVC_CFG 'termination' field to automatic also.
13703 *
13704 * If the termination is specified with a non-zero 'termination'
13705 * value check that a legal value is set and set the ASC_DVC_CFG
13706 * 'termination' field appropriately.
13707 */
13708 if (eep_config.termination_se == 0) {
13709 termination = 0; /* auto termination for SE */
13710 } else {
13711 /* Enable manual control with low off / high off. */
13712 if (eep_config.termination_se == 1) {
13713 termination = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013714
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013715 /* Enable manual control with low off / high on. */
13716 } else if (eep_config.termination_se == 2) {
13717 termination = TERM_SE_HI;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013718
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013719 /* Enable manual control with low on / high on. */
13720 } else if (eep_config.termination_se == 3) {
13721 termination = TERM_SE;
13722 } else {
13723 /*
13724 * The EEPROM 'termination_se' field contains a bad value.
13725 * Use automatic termination instead.
13726 */
13727 termination = 0;
13728 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13729 }
13730 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013731
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013732 if (eep_config.termination_lvd == 0) {
13733 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
13734 } else {
13735 /* Enable manual control with low off / high off. */
13736 if (eep_config.termination_lvd == 1) {
13737 asc_dvc->cfg->termination = termination;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013738
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013739 /* Enable manual control with low off / high on. */
13740 } else if (eep_config.termination_lvd == 2) {
13741 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013742
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013743 /* Enable manual control with low on / high on. */
13744 } else if (eep_config.termination_lvd == 3) {
13745 asc_dvc->cfg->termination = termination | TERM_LVD;
13746 } else {
13747 /*
13748 * The EEPROM 'termination_lvd' field contains a bad value.
13749 * Use automatic termination instead.
13750 */
13751 asc_dvc->cfg->termination = termination;
13752 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13753 }
13754 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013755
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013756 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013757}
13758
13759/*
Matthew Wilcox51219352007-10-02 21:55:22 -040013760 * Initialize the ADV_DVC_VAR structure.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013761 *
Matthew Wilcox51219352007-10-02 21:55:22 -040013762 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013763 *
Matthew Wilcox51219352007-10-02 21:55:22 -040013764 * For a non-fatal error return a warning code. If there are no warnings
13765 * then 0 is returned.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013766 */
Matthew Wilcox51219352007-10-02 21:55:22 -040013767static int __devinit
13768AdvInitGetConfig(struct pci_dev *pdev, asc_board_t *boardp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013769{
Matthew Wilcox51219352007-10-02 21:55:22 -040013770 ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
13771 unsigned short warn_code = 0;
13772 AdvPortAddr iop_base = asc_dvc->iop_base;
13773 u16 cmd;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013774 int status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013775
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013776 asc_dvc->err_code = 0;
Matthew Wilcox51219352007-10-02 21:55:22 -040013777
13778 /*
13779 * Save the state of the PCI Configuration Command Register
13780 * "Parity Error Response Control" Bit. If the bit is clear (0),
13781 * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
13782 * DMA parity errors.
13783 */
13784 asc_dvc->cfg->control_flag = 0;
13785 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
13786 if ((cmd & PCI_COMMAND_PARITY) == 0)
13787 asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
13788
13789 asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
13790 ADV_LIB_VERSION_MINOR;
13791 asc_dvc->cfg->chip_version =
13792 AdvGetChipVersion(iop_base, asc_dvc->bus_type);
13793
13794 ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
13795 (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
13796 (ushort)ADV_CHIP_ID_BYTE);
13797
13798 ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
13799 (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
13800 (ushort)ADV_CHIP_ID_WORD);
13801
13802 /*
13803 * Reset the chip to start and allow register writes.
13804 */
13805 if (AdvFindSignature(iop_base) == 0) {
13806 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
13807 return ADV_ERROR;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013808 } else {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013809 /*
Matthew Wilcox51219352007-10-02 21:55:22 -040013810 * The caller must set 'chip_type' to a valid setting.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013811 */
Matthew Wilcox51219352007-10-02 21:55:22 -040013812 if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
13813 asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
13814 asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
13815 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
13816 return ADV_ERROR;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013817 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013818
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013819 /*
Matthew Wilcox51219352007-10-02 21:55:22 -040013820 * Reset Chip.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013821 */
Matthew Wilcox51219352007-10-02 21:55:22 -040013822 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
13823 ADV_CTRL_REG_CMD_RESET);
13824 mdelay(100);
13825 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
13826 ADV_CTRL_REG_CMD_WR_IO_REG);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013827
Matthew Wilcox51219352007-10-02 21:55:22 -040013828 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
13829 status = AdvInitFrom38C1600EEP(asc_dvc);
13830 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
13831 status = AdvInitFrom38C0800EEP(asc_dvc);
13832 } else {
13833 status = AdvInitFrom3550EEP(asc_dvc);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013834 }
Matthew Wilcox51219352007-10-02 21:55:22 -040013835 warn_code |= status;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013836 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013837
Matthew Wilcox51219352007-10-02 21:55:22 -040013838 if (warn_code != 0) {
13839 ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
13840 boardp->id, warn_code);
13841 }
13842
13843 if (asc_dvc->err_code) {
13844 ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
13845 boardp->id, asc_dvc->err_code);
13846 }
13847
13848 return asc_dvc->err_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013849}
Matthew Wilcox51219352007-10-02 21:55:22 -040013850#endif
13851
13852static struct scsi_host_template advansys_template = {
13853 .proc_name = DRV_NAME,
13854#ifdef CONFIG_PROC_FS
13855 .proc_info = advansys_proc_info,
13856#endif
13857 .name = DRV_NAME,
13858 .info = advansys_info,
13859 .queuecommand = advansys_queuecommand,
13860 .eh_bus_reset_handler = advansys_reset,
13861 .bios_param = advansys_biosparam,
13862 .slave_configure = advansys_slave_configure,
13863 /*
13864 * Because the driver may control an ISA adapter 'unchecked_isa_dma'
13865 * must be set. The flag will be cleared in advansys_board_found
13866 * for non-ISA adapters.
13867 */
13868 .unchecked_isa_dma = 1,
13869 /*
13870 * All adapters controlled by this driver are capable of large
13871 * scatter-gather lists. According to the mid-level SCSI documentation
13872 * this obviates any performance gain provided by setting
13873 * 'use_clustering'. But empirically while CPU utilization is increased
13874 * by enabling clustering, I/O throughput increases as well.
13875 */
13876 .use_clustering = ENABLE_CLUSTERING,
13877};
Linus Torvalds1da177e2005-04-16 15:20:36 -070013878
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013879static int __devinit
13880advansys_wide_init_chip(asc_board_t *boardp, ADV_DVC_VAR *adv_dvc_varp)
13881{
13882 int req_cnt = 0;
13883 adv_req_t *reqp = NULL;
13884 int sg_cnt = 0;
13885 adv_sgblk_t *sgp;
13886 int warn_code, err_code;
13887
13888 /*
13889 * Allocate buffer carrier structures. The total size
13890 * is about 4 KB, so allocate all at once.
13891 */
13892 boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
13893 ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
13894
13895 if (!boardp->carrp)
13896 goto kmalloc_failed;
13897
13898 /*
13899 * Allocate up to 'max_host_qng' request structures for the Wide
13900 * board. The total size is about 16 KB, so allocate all at once.
13901 * If the allocation fails decrement and try again.
13902 */
13903 for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
13904 reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
13905
13906 ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
13907 "bytes %lu\n", reqp, req_cnt,
13908 (ulong)sizeof(adv_req_t) * req_cnt);
13909
13910 if (reqp)
13911 break;
13912 }
13913
13914 if (!reqp)
13915 goto kmalloc_failed;
13916
13917 boardp->orig_reqp = reqp;
13918
13919 /*
13920 * Allocate up to ADV_TOT_SG_BLOCK request structures for
13921 * the Wide board. Each structure is about 136 bytes.
13922 */
13923 boardp->adv_sgblkp = NULL;
13924 for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
13925 sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
13926
13927 if (!sgp)
13928 break;
13929
13930 sgp->next_sgblkp = boardp->adv_sgblkp;
13931 boardp->adv_sgblkp = sgp;
13932
13933 }
13934
13935 ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
13936 sg_cnt, sizeof(adv_sgblk_t),
13937 (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
13938
13939 if (!boardp->adv_sgblkp)
13940 goto kmalloc_failed;
13941
13942 adv_dvc_varp->carrier_buf = boardp->carrp;
13943
13944 /*
13945 * Point 'adv_reqp' to the request structures and
13946 * link them together.
13947 */
13948 req_cnt--;
13949 reqp[req_cnt].next_reqp = NULL;
13950 for (; req_cnt > 0; req_cnt--) {
13951 reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
13952 }
13953 boardp->adv_reqp = &reqp[0];
13954
13955 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
13956 ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
13957 warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
13958 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
13959 ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
13960 "\n");
13961 warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
13962 } else {
13963 ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
13964 "\n");
13965 warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
13966 }
13967 err_code = adv_dvc_varp->err_code;
13968
13969 if (warn_code || err_code) {
13970 ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
13971 " error 0x%x\n", boardp->id, warn_code, err_code);
13972 }
13973
13974 goto exit;
13975
13976 kmalloc_failed:
13977 ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
13978 "failed\n", boardp->id);
13979 err_code = ADV_ERROR;
13980 exit:
13981 return err_code;
13982}
13983
13984static void advansys_wide_free_mem(asc_board_t *boardp)
13985{
13986 kfree(boardp->carrp);
13987 boardp->carrp = NULL;
13988 kfree(boardp->orig_reqp);
13989 boardp->orig_reqp = boardp->adv_reqp = NULL;
13990 while (boardp->adv_sgblkp) {
13991 adv_sgblk_t *sgp = boardp->adv_sgblkp;
13992 boardp->adv_sgblkp = sgp->next_sgblkp;
13993 kfree(sgp);
13994 }
13995}
13996
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013997static struct Scsi_Host *__devinit
13998advansys_board_found(int iop, struct device *dev, int bus_type)
13999{
14000 struct Scsi_Host *shost;
14001 struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
14002 asc_board_t *boardp;
14003 ASC_DVC_VAR *asc_dvc_varp = NULL;
14004 ADV_DVC_VAR *adv_dvc_varp = NULL;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014005 int share_irq;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014006 int warn_code, err_code;
14007 int ret;
14008
14009 /*
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014010 * Register the adapter, get its configuration, and
14011 * initialize it.
14012 */
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014013 ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
14014 shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014015 if (!shost)
14016 return NULL;
14017
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014018 /* Initialize private per board data */
14019 boardp = ASC_BOARDP(shost);
14020 memset(boardp, 0, sizeof(asc_board_t));
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014021 boardp->id = asc_board_count++;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014022 spin_lock_init(&boardp->lock);
Matthew Wilcox394dbf32007-07-26 11:56:40 -040014023 boardp->dev = dev;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014024
14025 /*
14026 * Handle both narrow and wide boards.
14027 *
14028 * If a Wide board was detected, set the board structure
14029 * wide board flag. Set-up the board structure based on
14030 * the board type.
14031 */
14032#ifdef CONFIG_PCI
14033 if (bus_type == ASC_IS_PCI &&
14034 (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
14035 pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
14036 pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
14037 boardp->flags |= ASC_IS_WIDE_BOARD;
14038 }
14039#endif /* CONFIG_PCI */
14040
14041 if (ASC_NARROW_BOARD(boardp)) {
14042 ASC_DBG(1, "advansys_board_found: narrow board\n");
14043 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
14044 asc_dvc_varp->bus_type = bus_type;
14045 asc_dvc_varp->drv_ptr = boardp;
14046 asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
14047 asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
14048 asc_dvc_varp->iop_base = iop;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014049 } else {
Matthew Wilcox57ba5fe2007-07-26 11:55:07 -040014050#ifdef CONFIG_PCI
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014051 ASC_DBG(1, "advansys_board_found: wide board\n");
14052 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
14053 adv_dvc_varp->drv_ptr = boardp;
14054 adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014055 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
14056 ASC_DBG(1, "advansys_board_found: ASC-3550\n");
14057 adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
14058 } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
14059 ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
14060 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
14061 } else {
14062 ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
14063 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
14064 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014065
Matthew Wilcox57ba5fe2007-07-26 11:55:07 -040014066 boardp->asc_n_io_port = pci_resource_len(pdev, 1);
14067 boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
14068 boardp->asc_n_io_port);
14069 if (!boardp->ioremap_addr) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014070 ASC_PRINT3
14071 ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
Matthew Wilcox57ba5fe2007-07-26 11:55:07 -040014072 boardp->id, pci_resource_start(pdev, 1),
14073 boardp->asc_n_io_port);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014074 goto err_shost;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014075 }
Matthew Wilcox57ba5fe2007-07-26 11:55:07 -040014076 adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr
Matthew Wilcox71f36112007-07-30 08:04:53 -060014077 ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014078 adv_dvc_varp->iop_base);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014079
14080 /*
14081 * Even though it isn't used to access wide boards, other
14082 * than for the debug line below, save I/O Port address so
14083 * that it can be reported.
14084 */
14085 boardp->ioport = iop;
14086
Matthew Wilcox57ba5fe2007-07-26 11:55:07 -040014087 ASC_DBG2(1, "advansys_board_found: iopb_chip_id_1 0x%x, "
14088 "iopw_chip_id_0 0x%x\n", (ushort)inp(iop + 1),
14089 (ushort)inpw(iop));
14090#endif /* CONFIG_PCI */
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014091 }
14092
14093#ifdef CONFIG_PROC_FS
14094 /*
14095 * Allocate buffer for printing information from
14096 * /proc/scsi/advansys/[0...].
14097 */
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014098 boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
14099 if (!boardp->prtbuf) {
14100 ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
14101 "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
14102 goto err_unmap;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014103 }
14104#endif /* CONFIG_PROC_FS */
14105
14106 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014107 /*
14108 * Set the board bus type and PCI IRQ before
14109 * calling AscInitGetConfig().
14110 */
14111 switch (asc_dvc_varp->bus_type) {
14112#ifdef CONFIG_ISA
14113 case ASC_IS_ISA:
14114 shost->unchecked_isa_dma = TRUE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014115 share_irq = 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014116 break;
14117 case ASC_IS_VL:
14118 shost->unchecked_isa_dma = FALSE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014119 share_irq = 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014120 break;
14121 case ASC_IS_EISA:
14122 shost->unchecked_isa_dma = FALSE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014123 share_irq = IRQF_SHARED;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014124 break;
14125#endif /* CONFIG_ISA */
14126#ifdef CONFIG_PCI
14127 case ASC_IS_PCI:
14128 shost->irq = asc_dvc_varp->irq_no = pdev->irq;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014129 shost->unchecked_isa_dma = FALSE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014130 share_irq = IRQF_SHARED;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014131 break;
14132#endif /* CONFIG_PCI */
14133 default:
14134 ASC_PRINT2
14135 ("advansys_board_found: board %d: unknown adapter type: %d\n",
14136 boardp->id, asc_dvc_varp->bus_type);
14137 shost->unchecked_isa_dma = TRUE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014138 share_irq = 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014139 break;
14140 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014141
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014142 /*
14143 * NOTE: AscInitGetConfig() may change the board's
14144 * bus_type value. The bus_type value should no
14145 * longer be used. If the bus_type field must be
14146 * referenced only use the bit-wise AND operator "&".
14147 */
14148 ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
Matthew Wilcoxc2dce2f2007-09-09 08:56:30 -060014149 err_code = AscInitGetConfig(boardp);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014150 } else {
Matthew Wilcoxc2dce2f2007-09-09 08:56:30 -060014151#ifdef CONFIG_PCI
14152 /*
14153 * For Wide boards set PCI information before calling
14154 * AdvInitGetConfig().
14155 */
14156 shost->irq = adv_dvc_varp->irq_no = pdev->irq;
14157 shost->unchecked_isa_dma = FALSE;
14158 share_irq = IRQF_SHARED;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014159 ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
Matthew Wilcox394dbf32007-07-26 11:56:40 -040014160
Matthew Wilcoxc2dce2f2007-09-09 08:56:30 -060014161 err_code = AdvInitGetConfig(pdev, boardp);
14162#endif /* CONFIG_PCI */
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014163 }
14164
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014165 if (err_code != 0)
14166 goto err_free_proc;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014167
14168 /*
14169 * Save the EEPROM configuration so that it can be displayed
14170 * from /proc/scsi/advansys/[0...].
14171 */
14172 if (ASC_NARROW_BOARD(boardp)) {
14173
14174 ASCEEP_CONFIG *ep;
14175
14176 /*
14177 * Set the adapter's target id bit in the 'init_tidmask' field.
14178 */
14179 boardp->init_tidmask |=
14180 ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
14181
14182 /*
14183 * Save EEPROM settings for the board.
14184 */
14185 ep = &boardp->eep_config.asc_eep;
14186
14187 ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
14188 ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
14189 ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
14190 ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
14191 ep->start_motor = asc_dvc_varp->start_motor;
14192 ep->cntl = asc_dvc_varp->dvc_cntl;
14193 ep->no_scam = asc_dvc_varp->no_scam;
14194 ep->max_total_qng = asc_dvc_varp->max_total_qng;
14195 ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
14196 /* 'max_tag_qng' is set to the same value for every device. */
14197 ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
14198 ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
14199 ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
14200 ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
14201 ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
14202 ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
14203 ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
14204
14205 /*
14206 * Modify board configuration.
14207 */
14208 ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
Matthew Wilcoxc2dce2f2007-09-09 08:56:30 -060014209 err_code = AscInitSetConfig(pdev, boardp);
14210 if (err_code)
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014211 goto err_free_proc;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014212
14213 /*
14214 * Finish initializing the 'Scsi_Host' structure.
14215 */
14216 /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
14217 if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
14218 shost->irq = asc_dvc_varp->irq_no;
14219 }
14220 } else {
14221 ADVEEP_3550_CONFIG *ep_3550;
14222 ADVEEP_38C0800_CONFIG *ep_38C0800;
14223 ADVEEP_38C1600_CONFIG *ep_38C1600;
14224
14225 /*
14226 * Save Wide EEP Configuration Information.
14227 */
14228 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
14229 ep_3550 = &boardp->eep_config.adv_3550_eep;
14230
14231 ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
14232 ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
14233 ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
14234 ep_3550->termination = adv_dvc_varp->cfg->termination;
14235 ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
14236 ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
14237 ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
14238 ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
14239 ep_3550->ultra_able = adv_dvc_varp->ultra_able;
14240 ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
14241 ep_3550->start_motor = adv_dvc_varp->start_motor;
14242 ep_3550->scsi_reset_delay =
14243 adv_dvc_varp->scsi_reset_wait;
14244 ep_3550->serial_number_word1 =
14245 adv_dvc_varp->cfg->serial1;
14246 ep_3550->serial_number_word2 =
14247 adv_dvc_varp->cfg->serial2;
14248 ep_3550->serial_number_word3 =
14249 adv_dvc_varp->cfg->serial3;
14250 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
14251 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
14252
14253 ep_38C0800->adapter_scsi_id =
14254 adv_dvc_varp->chip_scsi_id;
14255 ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
14256 ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
14257 ep_38C0800->termination_lvd =
14258 adv_dvc_varp->cfg->termination;
14259 ep_38C0800->disc_enable =
14260 adv_dvc_varp->cfg->disc_enable;
14261 ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
14262 ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
14263 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
14264 ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
14265 ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
14266 ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
14267 ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
14268 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
14269 ep_38C0800->start_motor = adv_dvc_varp->start_motor;
14270 ep_38C0800->scsi_reset_delay =
14271 adv_dvc_varp->scsi_reset_wait;
14272 ep_38C0800->serial_number_word1 =
14273 adv_dvc_varp->cfg->serial1;
14274 ep_38C0800->serial_number_word2 =
14275 adv_dvc_varp->cfg->serial2;
14276 ep_38C0800->serial_number_word3 =
14277 adv_dvc_varp->cfg->serial3;
14278 } else {
14279 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
14280
14281 ep_38C1600->adapter_scsi_id =
14282 adv_dvc_varp->chip_scsi_id;
14283 ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
14284 ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
14285 ep_38C1600->termination_lvd =
14286 adv_dvc_varp->cfg->termination;
14287 ep_38C1600->disc_enable =
14288 adv_dvc_varp->cfg->disc_enable;
14289 ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
14290 ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
14291 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
14292 ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
14293 ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
14294 ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
14295 ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
14296 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
14297 ep_38C1600->start_motor = adv_dvc_varp->start_motor;
14298 ep_38C1600->scsi_reset_delay =
14299 adv_dvc_varp->scsi_reset_wait;
14300 ep_38C1600->serial_number_word1 =
14301 adv_dvc_varp->cfg->serial1;
14302 ep_38C1600->serial_number_word2 =
14303 adv_dvc_varp->cfg->serial2;
14304 ep_38C1600->serial_number_word3 =
14305 adv_dvc_varp->cfg->serial3;
14306 }
14307
14308 /*
14309 * Set the adapter's target id bit in the 'init_tidmask' field.
14310 */
14311 boardp->init_tidmask |=
14312 ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014313 }
14314
14315 /*
14316 * Channels are numbered beginning with 0. For AdvanSys one host
14317 * structure supports one channel. Multi-channel boards have a
14318 * separate host structure for each channel.
14319 */
14320 shost->max_channel = 0;
14321 if (ASC_NARROW_BOARD(boardp)) {
14322 shost->max_id = ASC_MAX_TID + 1;
14323 shost->max_lun = ASC_MAX_LUN + 1;
Matthew Wilcoxf05ec592007-09-09 08:56:36 -060014324 shost->max_cmd_len = ASC_MAX_CDB_LEN;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014325
14326 shost->io_port = asc_dvc_varp->iop_base;
14327 boardp->asc_n_io_port = ASC_IOADR_GAP;
14328 shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
14329
14330 /* Set maximum number of queues the adapter can handle. */
14331 shost->can_queue = asc_dvc_varp->max_total_qng;
14332 } else {
14333 shost->max_id = ADV_MAX_TID + 1;
14334 shost->max_lun = ADV_MAX_LUN + 1;
Matthew Wilcoxf05ec592007-09-09 08:56:36 -060014335 shost->max_cmd_len = ADV_MAX_CDB_LEN;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014336
14337 /*
14338 * Save the I/O Port address and length even though
14339 * I/O ports are not used to access Wide boards.
14340 * Instead the Wide boards are accessed with
14341 * PCI Memory Mapped I/O.
14342 */
14343 shost->io_port = iop;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014344
14345 shost->this_id = adv_dvc_varp->chip_scsi_id;
14346
14347 /* Set maximum number of queues the adapter can handle. */
14348 shost->can_queue = adv_dvc_varp->max_host_qng;
14349 }
14350
14351 /*
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014352 * Following v1.3.89, 'cmd_per_lun' is no longer needed
14353 * and should be set to zero.
14354 *
14355 * But because of a bug introduced in v1.3.89 if the driver is
14356 * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
14357 * SCSI function 'allocate_device' will panic. To allow the driver
14358 * to work as a module in these kernels set 'cmd_per_lun' to 1.
14359 *
14360 * Note: This is wrong. cmd_per_lun should be set to the depth
14361 * you want on untagged devices always.
14362 #ifdef MODULE
14363 */
14364 shost->cmd_per_lun = 1;
14365/* #else
14366 shost->cmd_per_lun = 0;
14367#endif */
14368
14369 /*
14370 * Set the maximum number of scatter-gather elements the
14371 * adapter can handle.
14372 */
14373 if (ASC_NARROW_BOARD(boardp)) {
14374 /*
14375 * Allow two commands with 'sg_tablesize' scatter-gather
14376 * elements to be executed simultaneously. This value is
14377 * the theoretical hardware limit. It may be decreased
14378 * below.
14379 */
14380 shost->sg_tablesize =
14381 (((asc_dvc_varp->max_total_qng - 2) / 2) *
14382 ASC_SG_LIST_PER_Q) + 1;
14383 } else {
14384 shost->sg_tablesize = ADV_MAX_SG_LIST;
14385 }
14386
14387 /*
14388 * The value of 'sg_tablesize' can not exceed the SCSI
14389 * mid-level driver definition of SG_ALL. SG_ALL also
14390 * must not be exceeded, because it is used to define the
14391 * size of the scatter-gather table in 'struct asc_sg_head'.
14392 */
14393 if (shost->sg_tablesize > SG_ALL) {
14394 shost->sg_tablesize = SG_ALL;
14395 }
14396
14397 ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
14398
14399 /* BIOS start address. */
14400 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014401 shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
14402 asc_dvc_varp->bus_type);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014403 } else {
14404 /*
14405 * Fill-in BIOS board variables. The Wide BIOS saves
14406 * information in LRAM that is used by the driver.
14407 */
14408 AdvReadWordLram(adv_dvc_varp->iop_base,
14409 BIOS_SIGNATURE, boardp->bios_signature);
14410 AdvReadWordLram(adv_dvc_varp->iop_base,
14411 BIOS_VERSION, boardp->bios_version);
14412 AdvReadWordLram(adv_dvc_varp->iop_base,
14413 BIOS_CODESEG, boardp->bios_codeseg);
14414 AdvReadWordLram(adv_dvc_varp->iop_base,
14415 BIOS_CODELEN, boardp->bios_codelen);
14416
14417 ASC_DBG2(1,
14418 "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
14419 boardp->bios_signature, boardp->bios_version);
14420
14421 ASC_DBG2(1,
14422 "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
14423 boardp->bios_codeseg, boardp->bios_codelen);
14424
14425 /*
14426 * If the BIOS saved a valid signature, then fill in
14427 * the BIOS code segment base address.
14428 */
14429 if (boardp->bios_signature == 0x55AA) {
14430 /*
14431 * Convert x86 realmode code segment to a linear
14432 * address by shifting left 4.
14433 */
14434 shost->base = ((ulong)boardp->bios_codeseg << 4);
14435 } else {
14436 shost->base = 0;
14437 }
14438 }
14439
14440 /*
14441 * Register Board Resources - I/O Port, DMA, IRQ
14442 */
14443
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014444 /* Register DMA Channel for Narrow boards. */
14445 shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
14446#ifdef CONFIG_ISA
14447 if (ASC_NARROW_BOARD(boardp)) {
14448 /* Register DMA channel for ISA bus. */
14449 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
14450 shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014451 ret = request_dma(shost->dma_channel, DRV_NAME);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014452 if (ret) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014453 ASC_PRINT3
14454 ("advansys_board_found: board %d: request_dma() %d failed %d\n",
14455 boardp->id, shost->dma_channel, ret);
Matthew Wilcox71f36112007-07-30 08:04:53 -060014456 goto err_free_proc;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014457 }
14458 AscEnableIsaDma(shost->dma_channel);
14459 }
14460 }
14461#endif /* CONFIG_ISA */
14462
14463 /* Register IRQ Number. */
14464 ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014465
14466 ret = request_irq(shost->irq, advansys_interrupt, share_irq,
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014467 DRV_NAME, shost);
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014468
14469 if (ret) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014470 if (ret == -EBUSY) {
14471 ASC_PRINT2
14472 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
14473 boardp->id, shost->irq);
14474 } else if (ret == -EINVAL) {
14475 ASC_PRINT2
14476 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
14477 boardp->id, shost->irq);
14478 } else {
14479 ASC_PRINT3
14480 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
14481 boardp->id, shost->irq, ret);
14482 }
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014483 goto err_free_dma;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014484 }
14485
14486 /*
14487 * Initialize board RISC chip and enable interrupts.
14488 */
14489 if (ASC_NARROW_BOARD(boardp)) {
14490 ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
14491 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
14492 err_code = asc_dvc_varp->err_code;
14493
14494 if (warn_code || err_code) {
14495 ASC_PRINT4
14496 ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
14497 boardp->id,
14498 asc_dvc_varp->init_state, warn_code, err_code);
14499 }
14500 } else {
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014501 err_code = advansys_wide_init_chip(boardp, adv_dvc_varp);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014502 }
14503
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014504 if (err_code != 0)
14505 goto err_free_wide_mem;
14506
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014507 ASC_DBG_PRT_SCSI_HOST(2, shost);
14508
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014509 ret = scsi_add_host(shost, dev);
14510 if (ret)
14511 goto err_free_wide_mem;
14512
14513 scsi_scan_host(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014514 return shost;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014515
14516 err_free_wide_mem:
14517 advansys_wide_free_mem(boardp);
14518 free_irq(shost->irq, shost);
14519 err_free_dma:
14520 if (shost->dma_channel != NO_ISA_DMA)
14521 free_dma(shost->dma_channel);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014522 err_free_proc:
14523 kfree(boardp->prtbuf);
14524 err_unmap:
14525 if (boardp->ioremap_addr)
14526 iounmap(boardp->ioremap_addr);
14527 err_shost:
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014528 scsi_host_put(shost);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014529 return NULL;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014530}
14531
14532/*
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014533 * advansys_release()
14534 *
14535 * Release resources allocated for a single AdvanSys adapter.
14536 */
14537static int advansys_release(struct Scsi_Host *shost)
14538{
14539 asc_board_t *boardp;
14540
14541 ASC_DBG(1, "advansys_release: begin\n");
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014542 scsi_remove_host(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014543 boardp = ASC_BOARDP(shost);
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060014544 free_irq(shost->irq, shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014545 if (shost->dma_channel != NO_ISA_DMA) {
14546 ASC_DBG(1, "advansys_release: free_dma()\n");
14547 free_dma(shost->dma_channel);
14548 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014549 if (ASC_WIDE_BOARD(boardp)) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014550 iounmap(boardp->ioremap_addr);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060014551 advansys_wide_free_mem(boardp);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014552 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014553 kfree(boardp->prtbuf);
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014554 scsi_host_put(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014555 ASC_DBG(1, "advansys_release: end\n");
14556 return 0;
14557}
14558
Matthew Wilcox95c9f162007-09-09 08:56:39 -060014559#define ASC_IOADR_TABLE_MAX_IX 11
14560
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014561static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
14562 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
14563 0x0210, 0x0230, 0x0250, 0x0330
14564};
14565
14566static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
14567{
14568 PortAddr iop_base = _asc_def_iop_base[id];
14569 struct Scsi_Host *shost;
14570
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014571 if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
Matthew Wilcox71f36112007-07-30 08:04:53 -060014572 ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
14573 iop_base);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014574 return -ENODEV;
14575 }
14576 ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014577 if (!AscFindSignature(iop_base))
14578 goto nodev;
14579 if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
14580 goto nodev;
14581
14582 shost = advansys_board_found(iop_base, dev, ASC_IS_ISA);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014583 if (!shost)
14584 goto nodev;
14585
14586 dev_set_drvdata(dev, shost);
14587 return 0;
14588
14589 nodev:
Matthew Wilcox71f36112007-07-30 08:04:53 -060014590 release_region(iop_base, ASC_IOADR_GAP);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014591 return -ENODEV;
14592}
14593
14594static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
14595{
Matthew Wilcox71f36112007-07-30 08:04:53 -060014596 int ioport = _asc_def_iop_base[id];
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014597 advansys_release(dev_get_drvdata(dev));
Matthew Wilcox71f36112007-07-30 08:04:53 -060014598 release_region(ioport, ASC_IOADR_GAP);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014599 return 0;
14600}
14601
14602static struct isa_driver advansys_isa_driver = {
14603 .probe = advansys_isa_probe,
14604 .remove = __devexit_p(advansys_isa_remove),
14605 .driver = {
14606 .owner = THIS_MODULE,
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014607 .name = DRV_NAME,
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014608 },
14609};
14610
14611static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
14612{
14613 PortAddr iop_base = _asc_def_iop_base[id];
14614 struct Scsi_Host *shost;
14615
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014616 if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
Matthew Wilcox71f36112007-07-30 08:04:53 -060014617 ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
14618 iop_base);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014619 return -ENODEV;
14620 }
14621 ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014622 if (!AscFindSignature(iop_base))
14623 goto nodev;
14624 /*
14625 * I don't think this condition can actually happen, but the old
14626 * driver did it, and the chances of finding a VLB setup in 2007
14627 * to do testing with is slight to none.
14628 */
14629 if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
14630 goto nodev;
14631
14632 shost = advansys_board_found(iop_base, dev, ASC_IS_VL);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014633 if (!shost)
14634 goto nodev;
14635
14636 dev_set_drvdata(dev, shost);
14637 return 0;
14638
14639 nodev:
Matthew Wilcox71f36112007-07-30 08:04:53 -060014640 release_region(iop_base, ASC_IOADR_GAP);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014641 return -ENODEV;
14642}
14643
14644static struct isa_driver advansys_vlb_driver = {
14645 .probe = advansys_vlb_probe,
14646 .remove = __devexit_p(advansys_isa_remove),
14647 .driver = {
14648 .owner = THIS_MODULE,
Matthew Wilcoxb8e5152b2007-09-09 08:56:26 -060014649 .name = "advansys_vlb",
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014650 },
14651};
14652
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014653static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
14654 { "ABP7401" },
14655 { "ABP7501" },
14656 { "" }
14657};
14658
14659MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
14660
14661/*
14662 * EISA is a little more tricky than PCI; each EISA device may have two
14663 * channels, and this driver is written to make each channel its own Scsi_Host
14664 */
14665struct eisa_scsi_data {
14666 struct Scsi_Host *host[2];
14667};
14668
14669static int __devinit advansys_eisa_probe(struct device *dev)
14670{
14671 int i, ioport;
14672 int err;
14673 struct eisa_device *edev = to_eisa_device(dev);
14674 struct eisa_scsi_data *data;
14675
14676 err = -ENOMEM;
14677 data = kzalloc(sizeof(*data), GFP_KERNEL);
14678 if (!data)
14679 goto fail;
14680 ioport = edev->base_addr + 0xc30;
14681
14682 err = -ENODEV;
14683 for (i = 0; i < 2; i++, ioport += 0x20) {
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014684 if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
Matthew Wilcox71f36112007-07-30 08:04:53 -060014685 printk(KERN_WARNING "Region %x-%x busy\n", ioport,
14686 ioport + ASC_IOADR_GAP - 1);
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014687 continue;
Matthew Wilcox71f36112007-07-30 08:04:53 -060014688 }
14689 if (!AscFindSignature(ioport)) {
14690 release_region(ioport, ASC_IOADR_GAP);
14691 continue;
14692 }
14693
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014694 /*
14695 * I don't know why we need to do this for EISA chips, but
14696 * not for any others. It looks to be equivalent to
14697 * AscGetChipCfgMsw, but I may have overlooked something,
14698 * so I'm not converting it until I get an EISA board to
14699 * test with.
14700 */
14701 inw(ioport + 4);
14702 data->host[i] = advansys_board_found(ioport, dev, ASC_IS_EISA);
Matthew Wilcox71f36112007-07-30 08:04:53 -060014703 if (data->host[i]) {
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014704 err = 0;
Matthew Wilcox71f36112007-07-30 08:04:53 -060014705 } else {
14706 release_region(ioport, ASC_IOADR_GAP);
14707 }
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014708 }
14709
14710 if (err) {
14711 kfree(data);
14712 } else {
14713 dev_set_drvdata(dev, data);
14714 }
14715
14716 fail:
14717 return err;
14718}
14719
14720static __devexit int advansys_eisa_remove(struct device *dev)
14721{
14722 int i;
14723 struct eisa_scsi_data *data = dev_get_drvdata(dev);
14724
14725 for (i = 0; i < 2; i++) {
Matthew Wilcox71f36112007-07-30 08:04:53 -060014726 int ioport;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014727 struct Scsi_Host *shost = data->host[i];
14728 if (!shost)
14729 continue;
Matthew Wilcox71f36112007-07-30 08:04:53 -060014730 ioport = shost->io_port;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014731 advansys_release(shost);
Matthew Wilcox71f36112007-07-30 08:04:53 -060014732 release_region(ioport, ASC_IOADR_GAP);
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014733 }
14734
14735 kfree(data);
14736 return 0;
14737}
14738
14739static struct eisa_driver advansys_eisa_driver = {
14740 .id_table = advansys_eisa_table,
14741 .driver = {
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014742 .name = DRV_NAME,
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014743 .probe = advansys_eisa_probe,
14744 .remove = __devexit_p(advansys_eisa_remove),
14745 }
14746};
14747
Dave Jones2672ea82006-08-02 17:11:49 -040014748/* PCI Devices supported by this driver */
14749static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014750 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
14751 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14752 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
14753 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14754 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
14755 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14756 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
14757 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14758 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
14759 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14760 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
14761 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14762 {}
Dave Jones2672ea82006-08-02 17:11:49 -040014763};
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014764
Dave Jones2672ea82006-08-02 17:11:49 -040014765MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014766
Matthew Wilcox9649af32007-07-26 21:51:47 -060014767static void __devinit advansys_set_latency(struct pci_dev *pdev)
14768{
14769 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
14770 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
14771 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
14772 } else {
14773 u8 latency;
14774 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
14775 if (latency < 0x20)
14776 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
14777 }
14778}
14779
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014780static int __devinit
14781advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
14782{
14783 int err, ioport;
14784 struct Scsi_Host *shost;
14785
14786 err = pci_enable_device(pdev);
14787 if (err)
14788 goto fail;
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014789 err = pci_request_regions(pdev, DRV_NAME);
Matthew Wilcox71f36112007-07-30 08:04:53 -060014790 if (err)
14791 goto disable_device;
Matthew Wilcox9649af32007-07-26 21:51:47 -060014792 pci_set_master(pdev);
14793 advansys_set_latency(pdev);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014794
14795 if (pci_resource_len(pdev, 0) == 0)
14796 goto nodev;
14797
14798 ioport = pci_resource_start(pdev, 0);
14799 shost = advansys_board_found(ioport, &pdev->dev, ASC_IS_PCI);
14800
14801 if (!shost)
14802 goto nodev;
14803
14804 pci_set_drvdata(pdev, shost);
14805 return 0;
14806
14807 nodev:
14808 err = -ENODEV;
Matthew Wilcox71f36112007-07-30 08:04:53 -060014809 pci_release_regions(pdev);
14810 disable_device:
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014811 pci_disable_device(pdev);
14812 fail:
14813 return err;
14814}
14815
14816static void __devexit advansys_pci_remove(struct pci_dev *pdev)
14817{
14818 advansys_release(pci_get_drvdata(pdev));
Matthew Wilcox71f36112007-07-30 08:04:53 -060014819 pci_release_regions(pdev);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014820 pci_disable_device(pdev);
14821}
14822
14823static struct pci_driver advansys_pci_driver = {
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014824 .name = DRV_NAME,
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014825 .id_table = advansys_pci_tbl,
14826 .probe = advansys_pci_probe,
14827 .remove = __devexit_p(advansys_pci_remove),
14828};
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040014829
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014830static int __init advansys_init(void)
14831{
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014832 int error;
14833
14834 error = isa_register_driver(&advansys_isa_driver,
14835 ASC_IOADR_TABLE_MAX_IX);
14836 if (error)
14837 goto fail;
14838
14839 error = isa_register_driver(&advansys_vlb_driver,
14840 ASC_IOADR_TABLE_MAX_IX);
14841 if (error)
14842 goto unregister_isa;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014843
14844 error = eisa_driver_register(&advansys_eisa_driver);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014845 if (error)
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014846 goto unregister_vlb;
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014847
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014848 error = pci_register_driver(&advansys_pci_driver);
14849 if (error)
14850 goto unregister_eisa;
14851
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014852 return 0;
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014853
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014854 unregister_eisa:
14855 eisa_driver_unregister(&advansys_eisa_driver);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014856 unregister_vlb:
14857 isa_unregister_driver(&advansys_vlb_driver);
14858 unregister_isa:
14859 isa_unregister_driver(&advansys_isa_driver);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014860 fail:
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014861 return error;
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014862}
14863
14864static void __exit advansys_exit(void)
14865{
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014866 pci_unregister_driver(&advansys_pci_driver);
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014867 eisa_driver_unregister(&advansys_eisa_driver);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014868 isa_unregister_driver(&advansys_vlb_driver);
14869 isa_unregister_driver(&advansys_isa_driver);
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014870}
14871
14872module_init(advansys_init);
14873module_exit(advansys_exit);
14874
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040014875MODULE_LICENSE("GPL");