]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/scsi/advansys.c
[SCSI] advansys: Remove DvcGetPhyAddr
[mirror_ubuntu-artful-kernel.git] / drivers / scsi / advansys.c
CommitLineData
01fbfe0b 1#define DRV_NAME "advansys"
8c6af9e1 2#define ASC_VERSION "3.4" /* AdvanSys Driver Version */
1da177e4
LT
3
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.
8c6af9e1 9 * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
1da177e4
LT
10 * All Rights Reserved.
11 *
8c6af9e1
MW
12 * 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/*
1da177e4
LT
19 * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
20 * changed its name to ConnectCom Solutions, Inc.
8c6af9e1 21 * On June 18, 2001 Initio Corp. acquired ConnectCom's SCSI assets
1da177e4
LT
22 */
23
1da177e4 24#include <linux/module.h>
1da177e4
LT
25#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>
c304ec94 36#include <linux/isa.h>
b09e05a7 37#include <linux/eisa.h>
8c6af9e1 38#include <linux/pci.h>
1da177e4
LT
39#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
8c6af9e1
MW
46#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
4bd6d7f3 52/* FIXME:
1da177e4 53 *
4bd6d7f3
MW
54 * 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
349d2c44
MW
67 * 6. Use scsi_transport_spi
68 * 7. advansys_info is not safe against multiple simultaneous callers
9d0e96eb 69 * 8. Add module_param to override ISA/VLB ioport array
1da177e4
LT
70 */
71#warning this driver is still not properly converted to the DMA API
72
1da177e4
LT
73/* Enable driver /proc statistics. */
74#define ADVANSYS_STATS
75
76/* Enable driver tracing. */
b352f923 77#undef ADVANSYS_DEBUG
1da177e4 78
1da177e4
LT
79/*
80 * Portable Data Types
81 *
82 * Any instance where a 32-bit long or pointer type is assumed
83 * for precision or HW defined structures, the following define
84 * types must be used. In Linux the char, short, and int types
85 * are all consistent at 8, 16, and 32 bits respectively. Pointers
86 * and long types are 64 bits on Alpha and UltraSPARC.
87 */
27c868c2
MW
88#define ASC_PADDR __u32 /* Physical/Bus address data type. */
89#define ASC_VADDR __u32 /* Virtual address data type. */
90#define ASC_DCNT __u32 /* Unsigned Data count type. */
91#define ASC_SDCNT __s32 /* Signed Data count type. */
1da177e4
LT
92
93/*
94 * These macros are used to convert a virtual address to a
95 * 32-bit value. This currently can be used on Linux Alpha
96 * which uses 64-bit virtual address but a 32-bit bus address.
97 * This is likely to break in the future, but doing this now
98 * will give us time to change the HW and FW to handle 64-bit
99 * addresses.
100 */
101#define ASC_VADDR_TO_U32 virt_to_bus
102#define ASC_U32_TO_VADDR bus_to_virt
103
104typedef unsigned char uchar;
105
106#ifndef TRUE
107#define TRUE (1)
108#endif
109#ifndef FALSE
110#define FALSE (0)
111#endif
112
1da177e4
LT
113#define ERR (-1)
114#define UW_ERR (uint)(0xFFFF)
115#define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
1da177e4 116
2672ea86
DJ
117#define PCI_VENDOR_ID_ASP 0x10cd
118#define PCI_DEVICE_ID_ASP_1200A 0x1100
119#define PCI_DEVICE_ID_ASP_ABP940 0x1200
120#define PCI_DEVICE_ID_ASP_ABP940U 0x1300
121#define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
122#define PCI_DEVICE_ID_38C0800_REV1 0x2500
123#define PCI_DEVICE_ID_38C1600_REV1 0x2700
124
1da177e4
LT
125/*
126 * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
127 * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
128 * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
129 * SRB structure.
130 */
131#define CC_VERY_LONG_SG_LIST 0
132#define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
133
27c868c2 134#define PortAddr unsigned short /* port address size */
1da177e4
LT
135#define inp(port) inb(port)
136#define outp(port, byte) outb((byte), (port))
137
138#define inpw(port) inw(port)
139#define outpw(port, word) outw((word), (port))
140
141#define ASC_MAX_SG_QUEUE 7
142#define ASC_MAX_SG_LIST 255
143
144#define ASC_CS_TYPE unsigned short
145
146#define ASC_IS_ISA (0x0001)
147#define ASC_IS_ISAPNP (0x0081)
148#define ASC_IS_EISA (0x0002)
149#define ASC_IS_PCI (0x0004)
150#define ASC_IS_PCI_ULTRA (0x0104)
151#define ASC_IS_PCMCIA (0x0008)
152#define ASC_IS_MCA (0x0020)
153#define ASC_IS_VL (0x0040)
1da177e4
LT
154#define ASC_IS_WIDESCSI_16 (0x0100)
155#define ASC_IS_WIDESCSI_32 (0x0200)
156#define ASC_IS_BIG_ENDIAN (0x8000)
95c9f162 157
1da177e4
LT
158#define ASC_CHIP_MIN_VER_VL (0x01)
159#define ASC_CHIP_MAX_VER_VL (0x07)
160#define ASC_CHIP_MIN_VER_PCI (0x09)
161#define ASC_CHIP_MAX_VER_PCI (0x0F)
162#define ASC_CHIP_VER_PCI_BIT (0x08)
163#define ASC_CHIP_MIN_VER_ISA (0x11)
164#define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
165#define ASC_CHIP_MAX_VER_ISA (0x27)
166#define ASC_CHIP_VER_ISA_BIT (0x30)
167#define ASC_CHIP_VER_ISAPNP_BIT (0x20)
168#define ASC_CHIP_VER_ASYN_BUG (0x21)
169#define ASC_CHIP_VER_PCI 0x08
170#define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
171#define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
172#define ASC_CHIP_MIN_VER_EISA (0x41)
173#define ASC_CHIP_MAX_VER_EISA (0x47)
174#define ASC_CHIP_VER_EISA_BIT (0x40)
175#define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
1da177e4 176#define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
1da177e4 177#define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
1da177e4 178#define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
1da177e4
LT
179
180#define ASC_SCSI_ID_BITS 3
181#define ASC_SCSI_TIX_TYPE uchar
182#define ASC_ALL_DEVICE_BIT_SET 0xFF
183#define ASC_SCSI_BIT_ID_TYPE uchar
184#define ASC_MAX_TID 7
185#define ASC_MAX_LUN 7
186#define ASC_SCSI_WIDTH_BIT_SET 0xFF
187#define ASC_MAX_SENSE_LEN 32
188#define ASC_MIN_SENSE_LEN 14
1da177e4
LT
189#define ASC_SCSI_RESET_HOLD_TIME_US 60
190
f05ec594
MW
191/*
192 * Narrow boards only support 12-byte commands, while wide boards
193 * extend to 16-byte commands.
194 */
195#define ASC_MAX_CDB_LEN 12
196#define ADV_MAX_CDB_LEN 16
197
1da177e4 198#define MS_SDTR_LEN 0x03
1da177e4 199#define MS_WDTR_LEN 0x02
1da177e4
LT
200
201#define ASC_SG_LIST_PER_Q 7
202#define QS_FREE 0x00
203#define QS_READY 0x01
204#define QS_DISC1 0x02
205#define QS_DISC2 0x04
206#define QS_BUSY 0x08
207#define QS_ABORTED 0x40
208#define QS_DONE 0x80
209#define QC_NO_CALLBACK 0x01
210#define QC_SG_SWAP_QUEUE 0x02
211#define QC_SG_HEAD 0x04
212#define QC_DATA_IN 0x08
213#define QC_DATA_OUT 0x10
214#define QC_URGENT 0x20
215#define QC_MSG_OUT 0x40
216#define QC_REQ_SENSE 0x80
217#define QCSG_SG_XFER_LIST 0x02
218#define QCSG_SG_XFER_MORE 0x04
219#define QCSG_SG_XFER_END 0x08
220#define QD_IN_PROGRESS 0x00
221#define QD_NO_ERROR 0x01
222#define QD_ABORTED_BY_HOST 0x02
223#define QD_WITH_ERROR 0x04
224#define QD_INVALID_REQUEST 0x80
225#define QD_INVALID_HOST_NUM 0x81
226#define QD_INVALID_DEVICE 0x82
227#define QD_ERR_INTERNAL 0xFF
228#define QHSTA_NO_ERROR 0x00
229#define QHSTA_M_SEL_TIMEOUT 0x11
230#define QHSTA_M_DATA_OVER_RUN 0x12
231#define QHSTA_M_DATA_UNDER_RUN 0x12
232#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
233#define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
234#define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
235#define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
236#define QHSTA_D_HOST_ABORT_FAILED 0x23
237#define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
238#define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
239#define QHSTA_D_ASPI_NO_BUF_POOL 0x26
240#define QHSTA_M_WTM_TIMEOUT 0x41
241#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
242#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
243#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
244#define QHSTA_M_TARGET_STATUS_BUSY 0x45
245#define QHSTA_M_BAD_TAG_CODE 0x46
246#define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
247#define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
248#define QHSTA_D_LRAM_CMP_ERROR 0x81
249#define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
250#define ASC_FLAG_SCSIQ_REQ 0x01
251#define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
252#define ASC_FLAG_BIOS_ASYNC_IO 0x04
253#define ASC_FLAG_SRB_LINEAR_ADDR 0x08
254#define ASC_FLAG_WIN16 0x10
255#define ASC_FLAG_WIN32 0x20
256#define ASC_FLAG_ISA_OVER_16MB 0x40
257#define ASC_FLAG_DOS_VM_CALLBACK 0x80
258#define ASC_TAG_FLAG_EXTRA_BYTES 0x10
259#define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
260#define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
261#define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
262#define ASC_SCSIQ_CPY_BEG 4
263#define ASC_SCSIQ_SGHD_CPY_BEG 2
264#define ASC_SCSIQ_B_FWD 0
265#define ASC_SCSIQ_B_BWD 1
266#define ASC_SCSIQ_B_STATUS 2
267#define ASC_SCSIQ_B_QNO 3
268#define ASC_SCSIQ_B_CNTL 4
269#define ASC_SCSIQ_B_SG_QUEUE_CNT 5
270#define ASC_SCSIQ_D_DATA_ADDR 8
271#define ASC_SCSIQ_D_DATA_CNT 12
272#define ASC_SCSIQ_B_SENSE_LEN 20
273#define ASC_SCSIQ_DONE_INFO_BEG 22
274#define ASC_SCSIQ_D_SRBPTR 22
275#define ASC_SCSIQ_B_TARGET_IX 26
276#define ASC_SCSIQ_B_CDB_LEN 28
277#define ASC_SCSIQ_B_TAG_CODE 29
278#define ASC_SCSIQ_W_VM_ID 30
279#define ASC_SCSIQ_DONE_STATUS 32
280#define ASC_SCSIQ_HOST_STATUS 33
281#define ASC_SCSIQ_SCSI_STATUS 34
282#define ASC_SCSIQ_CDB_BEG 36
283#define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
284#define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
285#define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
286#define ASC_SCSIQ_B_SG_WK_QP 49
287#define ASC_SCSIQ_B_SG_WK_IX 50
288#define ASC_SCSIQ_W_ALT_DC1 52
289#define ASC_SCSIQ_B_LIST_CNT 6
290#define ASC_SCSIQ_B_CUR_LIST_CNT 7
291#define ASC_SGQ_B_SG_CNTL 4
292#define ASC_SGQ_B_SG_HEAD_QP 5
293#define ASC_SGQ_B_SG_LIST_CNT 6
294#define ASC_SGQ_B_SG_CUR_LIST_CNT 7
295#define ASC_SGQ_LIST_BEG 8
296#define ASC_DEF_SCSI1_QNG 4
297#define ASC_MAX_SCSI1_QNG 4
298#define ASC_DEF_SCSI2_QNG 16
299#define ASC_MAX_SCSI2_QNG 32
300#define ASC_TAG_CODE_MASK 0x23
301#define ASC_STOP_REQ_RISC_STOP 0x01
302#define ASC_STOP_ACK_RISC_STOP 0x03
303#define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
304#define ASC_STOP_CLEAN_UP_DISC_Q 0x20
305#define ASC_STOP_HOST_REQ_RISC_HALT 0x40
306#define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
307#define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
308#define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
309#define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
310#define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
311#define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
312#define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
313
314typedef struct asc_scsiq_1 {
27c868c2
MW
315 uchar status;
316 uchar q_no;
317 uchar cntl;
318 uchar sg_queue_cnt;
319 uchar target_id;
320 uchar target_lun;
321 ASC_PADDR data_addr;
322 ASC_DCNT data_cnt;
323 ASC_PADDR sense_addr;
324 uchar sense_len;
325 uchar extra_bytes;
1da177e4
LT
326} ASC_SCSIQ_1;
327
328typedef struct asc_scsiq_2 {
27c868c2
MW
329 ASC_VADDR srb_ptr;
330 uchar target_ix;
331 uchar flag;
332 uchar cdb_len;
333 uchar tag_code;
334 ushort vm_id;
1da177e4
LT
335} ASC_SCSIQ_2;
336
337typedef struct asc_scsiq_3 {
27c868c2
MW
338 uchar done_stat;
339 uchar host_stat;
340 uchar scsi_stat;
341 uchar scsi_msg;
1da177e4
LT
342} ASC_SCSIQ_3;
343
344typedef struct asc_scsiq_4 {
27c868c2
MW
345 uchar cdb[ASC_MAX_CDB_LEN];
346 uchar y_first_sg_list_qp;
347 uchar y_working_sg_qp;
348 uchar y_working_sg_ix;
349 uchar y_res;
350 ushort x_req_count;
351 ushort x_reconnect_rtn;
352 ASC_PADDR x_saved_data_addr;
353 ASC_DCNT x_saved_data_cnt;
1da177e4
LT
354} ASC_SCSIQ_4;
355
356typedef struct asc_q_done_info {
27c868c2
MW
357 ASC_SCSIQ_2 d2;
358 ASC_SCSIQ_3 d3;
359 uchar q_status;
360 uchar q_no;
361 uchar cntl;
362 uchar sense_len;
363 uchar extra_bytes;
364 uchar res;
365 ASC_DCNT remain_bytes;
1da177e4
LT
366} ASC_QDONE_INFO;
367
368typedef struct asc_sg_list {
27c868c2
MW
369 ASC_PADDR addr;
370 ASC_DCNT bytes;
1da177e4
LT
371} ASC_SG_LIST;
372
373typedef struct asc_sg_head {
27c868c2
MW
374 ushort entry_cnt;
375 ushort queue_cnt;
376 ushort entry_to_copy;
377 ushort res;
05848b6e 378 ASC_SG_LIST sg_list[0];
1da177e4
LT
379} ASC_SG_HEAD;
380
1da177e4 381typedef struct asc_scsi_q {
27c868c2
MW
382 ASC_SCSIQ_1 q1;
383 ASC_SCSIQ_2 q2;
384 uchar *cdbptr;
385 ASC_SG_HEAD *sg_head;
386 ushort remain_sg_entry_cnt;
387 ushort next_sg_index;
1da177e4
LT
388} ASC_SCSI_Q;
389
390typedef struct asc_scsi_req_q {
27c868c2
MW
391 ASC_SCSIQ_1 r1;
392 ASC_SCSIQ_2 r2;
393 uchar *cdbptr;
394 ASC_SG_HEAD *sg_head;
395 uchar *sense_ptr;
396 ASC_SCSIQ_3 r3;
397 uchar cdb[ASC_MAX_CDB_LEN];
398 uchar sense[ASC_MIN_SENSE_LEN];
1da177e4
LT
399} ASC_SCSI_REQ_Q;
400
401typedef struct asc_scsi_bios_req_q {
27c868c2
MW
402 ASC_SCSIQ_1 r1;
403 ASC_SCSIQ_2 r2;
404 uchar *cdbptr;
405 ASC_SG_HEAD *sg_head;
406 uchar *sense_ptr;
407 ASC_SCSIQ_3 r3;
408 uchar cdb[ASC_MAX_CDB_LEN];
409 uchar sense[ASC_MIN_SENSE_LEN];
1da177e4
LT
410} ASC_SCSI_BIOS_REQ_Q;
411
412typedef struct asc_risc_q {
27c868c2
MW
413 uchar fwd;
414 uchar bwd;
415 ASC_SCSIQ_1 i1;
416 ASC_SCSIQ_2 i2;
417 ASC_SCSIQ_3 i3;
418 ASC_SCSIQ_4 i4;
1da177e4
LT
419} ASC_RISC_Q;
420
421typedef struct asc_sg_list_q {
27c868c2
MW
422 uchar seq_no;
423 uchar q_no;
424 uchar cntl;
425 uchar sg_head_qp;
426 uchar sg_list_cnt;
427 uchar sg_cur_list_cnt;
1da177e4
LT
428} ASC_SG_LIST_Q;
429
430typedef struct asc_risc_sg_list_q {
27c868c2
MW
431 uchar fwd;
432 uchar bwd;
433 ASC_SG_LIST_Q sg;
434 ASC_SG_LIST sg_list[7];
1da177e4
LT
435} ASC_RISC_SG_LIST_Q;
436
1da177e4 437#define ASCQ_ERR_Q_STATUS 0x0D
1da177e4
LT
438#define ASCQ_ERR_CUR_QNG 0x17
439#define ASCQ_ERR_SG_Q_LINKS 0x18
1da177e4
LT
440#define ASCQ_ERR_ISR_RE_ENTRY 0x1A
441#define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
442#define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
1da177e4
LT
443
444/*
445 * Warning code values are set in ASC_DVC_VAR 'warn_code'.
446 */
447#define ASC_WARN_NO_ERROR 0x0000
448#define ASC_WARN_IO_PORT_ROTATE 0x0001
449#define ASC_WARN_EEPROM_CHKSUM 0x0002
450#define ASC_WARN_IRQ_MODIFIED 0x0004
451#define ASC_WARN_AUTO_CONFIG 0x0008
452#define ASC_WARN_CMD_QNG_CONFLICT 0x0010
453#define ASC_WARN_EEPROM_RECOVER 0x0020
454#define ASC_WARN_CFG_MSW_RECOVER 0x0040
1da177e4
LT
455
456/*
720349a8 457 * Error code values are set in {ASC/ADV}_DVC_VAR 'err_code'.
1da177e4 458 */
720349a8
MW
459#define ASC_IERR_NO_CARRIER 0x0001 /* No more carrier memory */
460#define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
461#define ASC_IERR_SET_PC_ADDR 0x0004
462#define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
463#define ASC_IERR_ILLEGAL_CONNECTION 0x0010 /* Illegal cable connection */
464#define ASC_IERR_SINGLE_END_DEVICE 0x0020 /* SE device on DIFF bus */
465#define ASC_IERR_REVERSED_CABLE 0x0040 /* Narrow flat cable reversed */
466#define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
467#define ASC_IERR_HVD_DEVICE 0x0100 /* HVD device on LVD port */
468#define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
469#define ASC_IERR_NO_BUS_TYPE 0x0400
470#define ASC_IERR_BIST_PRE_TEST 0x0800 /* BIST pre-test error */
471#define ASC_IERR_BIST_RAM_TEST 0x1000 /* BIST RAM test error */
472#define ASC_IERR_BAD_CHIPTYPE 0x2000 /* Invalid chip_type setting */
1da177e4 473
1da177e4
LT
474#define ASC_DEF_MAX_TOTAL_QNG (0xF0)
475#define ASC_MIN_TAG_Q_PER_DVC (0x04)
95c9f162 476#define ASC_MIN_FREE_Q (0x02)
1da177e4
LT
477#define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
478#define ASC_MAX_TOTAL_QNG 240
479#define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
480#define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
481#define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
482#define ASC_MAX_INRAM_TAG_QNG 16
1da177e4 483#define ASC_IOADR_GAP 0x10
1da177e4
LT
484#define ASC_SYN_MAX_OFFSET 0x0F
485#define ASC_DEF_SDTR_OFFSET 0x0F
1da177e4 486#define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
afbb68c3
MW
487#define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
488
489/* The narrow chip only supports a limited selection of transfer rates.
490 * These are encoded in the range 0..7 or 0..15 depending whether the chip
491 * is Ultra-capable or not. These tables let us convert from one to the other.
492 */
493static const unsigned char asc_syn_xfer_period[8] = {
494 25, 30, 35, 40, 50, 60, 70, 85
495};
496
497static const unsigned char asc_syn_ultra_xfer_period[16] = {
498 12, 19, 25, 32, 38, 44, 50, 57, 63, 69, 75, 82, 88, 94, 100, 107
499};
1da177e4
LT
500
501typedef struct ext_msg {
27c868c2
MW
502 uchar msg_type;
503 uchar msg_len;
504 uchar msg_req;
505 union {
506 struct {
507 uchar sdtr_xfer_period;
508 uchar sdtr_req_ack_offset;
509 } sdtr;
510 struct {
511 uchar wdtr_width;
512 } wdtr;
513 struct {
514 uchar mdp_b3;
515 uchar mdp_b2;
516 uchar mdp_b1;
517 uchar mdp_b0;
518 } mdp;
519 } u_ext_msg;
520 uchar res;
1da177e4
LT
521} EXT_MSG;
522
523#define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
524#define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
525#define wdtr_width u_ext_msg.wdtr.wdtr_width
526#define mdp_b3 u_ext_msg.mdp_b3
527#define mdp_b2 u_ext_msg.mdp_b2
528#define mdp_b1 u_ext_msg.mdp_b1
529#define mdp_b0 u_ext_msg.mdp_b0
530
531typedef struct asc_dvc_cfg {
27c868c2
MW
532 ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
533 ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
534 ASC_SCSI_BIT_ID_TYPE disc_enable;
535 ASC_SCSI_BIT_ID_TYPE sdtr_enable;
536 uchar chip_scsi_id;
537 uchar isa_dma_speed;
538 uchar isa_dma_channel;
539 uchar chip_version;
27c868c2
MW
540 ushort mcode_date;
541 ushort mcode_version;
542 uchar max_tag_qng[ASC_MAX_TID + 1];
543 uchar *overrun_buf;
544 uchar sdtr_period_offset[ASC_MAX_TID + 1];
27c868c2 545 uchar adapter_info[6];
1da177e4
LT
546} ASC_DVC_CFG;
547
548#define ASC_DEF_DVC_CNTL 0xFFFF
549#define ASC_DEF_CHIP_SCSI_ID 7
550#define ASC_DEF_ISA_DMA_SPEED 4
1da177e4
LT
551#define ASC_INIT_STATE_BEG_GET_CFG 0x0001
552#define ASC_INIT_STATE_END_GET_CFG 0x0002
553#define ASC_INIT_STATE_BEG_SET_CFG 0x0004
554#define ASC_INIT_STATE_END_SET_CFG 0x0008
555#define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
556#define ASC_INIT_STATE_END_LOAD_MC 0x0020
557#define ASC_INIT_STATE_BEG_INQUIRY 0x0040
558#define ASC_INIT_STATE_END_INQUIRY 0x0080
559#define ASC_INIT_RESET_SCSI_DONE 0x0100
560#define ASC_INIT_STATE_WITHOUT_EEP 0x8000
1da177e4
LT
561#define ASC_BUG_FIX_IF_NOT_DWB 0x0001
562#define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
1da177e4
LT
563#define ASC_MIN_TAGGED_CMD 7
564#define ASC_MAX_SCSI_RESET_WAIT 30
565
27c868c2 566struct asc_dvc_var; /* Forward Declaration. */
1da177e4 567
1da177e4 568typedef struct asc_dvc_var {
27c868c2
MW
569 PortAddr iop_base;
570 ushort err_code;
571 ushort dvc_cntl;
572 ushort bug_fix_cntl;
573 ushort bus_type;
27c868c2
MW
574 ASC_SCSI_BIT_ID_TYPE init_sdtr;
575 ASC_SCSI_BIT_ID_TYPE sdtr_done;
576 ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
577 ASC_SCSI_BIT_ID_TYPE unit_not_ready;
578 ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
579 ASC_SCSI_BIT_ID_TYPE start_motor;
580 uchar scsi_reset_wait;
581 uchar chip_no;
582 char is_in_int;
583 uchar max_total_qng;
584 uchar cur_total_qng;
585 uchar in_critical_cnt;
27c868c2
MW
586 uchar last_q_shortage;
587 ushort init_state;
588 uchar cur_dvc_qng[ASC_MAX_TID + 1];
589 uchar max_dvc_qng[ASC_MAX_TID + 1];
590 ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
591 ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
afbb68c3 592 const uchar *sdtr_period_tbl;
27c868c2
MW
593 ASC_DVC_CFG *cfg;
594 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
595 char redo_scam;
596 ushort res2;
597 uchar dos_int13_table[ASC_MAX_TID + 1];
598 ASC_DCNT max_dma_count;
599 ASC_SCSI_BIT_ID_TYPE no_scam;
600 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
afbb68c3 601 uchar min_sdtr_index;
27c868c2 602 uchar max_sdtr_index;
27c868c2
MW
603 struct asc_board *drv_ptr;
604 ASC_DCNT uc_break;
1da177e4
LT
605} ASC_DVC_VAR;
606
607typedef struct asc_dvc_inq_info {
27c868c2 608 uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
1da177e4
LT
609} ASC_DVC_INQ_INFO;
610
611typedef struct asc_cap_info {
27c868c2
MW
612 ASC_DCNT lba;
613 ASC_DCNT blk_size;
1da177e4
LT
614} ASC_CAP_INFO;
615
616typedef struct asc_cap_info_array {
27c868c2 617 ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
1da177e4
LT
618} ASC_CAP_INFO_ARRAY;
619
620#define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
621#define ASC_MCNTL_NULL_TARGET (ushort)0x0002
622#define ASC_CNTL_INITIATOR (ushort)0x0001
623#define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
624#define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
625#define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
626#define ASC_CNTL_NO_SCAM (ushort)0x0010
627#define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
628#define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
629#define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
630#define ASC_CNTL_RESET_SCSI (ushort)0x0200
631#define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
632#define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
633#define ASC_CNTL_SCSI_PARITY (ushort)0x1000
634#define ASC_CNTL_BURST_MODE (ushort)0x2000
635#define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
636#define ASC_EEP_DVC_CFG_BEG_VL 2
637#define ASC_EEP_MAX_DVC_ADDR_VL 15
638#define ASC_EEP_DVC_CFG_BEG 32
639#define ASC_EEP_MAX_DVC_ADDR 45
1da177e4 640#define ASC_EEP_MAX_RETRY 20
1da177e4
LT
641
642/*
643 * These macros keep the chip SCSI id and ISA DMA speed
644 * bitfields in board order. C bitfields aren't portable
645 * between big and little-endian platforms so they are
646 * not used.
647 */
648
649#define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
650#define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
651#define ASC_EEP_SET_CHIP_ID(cfg, sid) \
652 ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
653#define ASC_EEP_SET_DMA_SPD(cfg, spd) \
654 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
655
656typedef struct asceep_config {
27c868c2
MW
657 ushort cfg_lsw;
658 ushort cfg_msw;
659 uchar init_sdtr;
660 uchar disc_enable;
661 uchar use_cmd_qng;
662 uchar start_motor;
663 uchar max_total_qng;
664 uchar max_tag_qng;
665 uchar bios_scan;
666 uchar power_up_wait;
667 uchar no_scam;
668 uchar id_speed; /* low order 4 bits is chip scsi id */
669 /* high order 4 bits is isa dma speed */
670 uchar dos_int13_table[ASC_MAX_TID + 1];
671 uchar adapter_info[6];
672 ushort cntl;
673 ushort chksum;
1da177e4
LT
674} ASCEEP_CONFIG;
675
1da177e4
LT
676#define ASC_EEP_CMD_READ 0x80
677#define ASC_EEP_CMD_WRITE 0x40
678#define ASC_EEP_CMD_WRITE_ABLE 0x30
679#define ASC_EEP_CMD_WRITE_DISABLE 0x00
680#define ASC_OVERRUN_BSIZE 0x00000048UL
1da177e4
LT
681#define ASCV_MSGOUT_BEG 0x0000
682#define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
683#define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
684#define ASCV_BREAK_SAVED_CODE (ushort)0x0006
685#define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
686#define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
687#define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
688#define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
689#define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
690#define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
691#define ASCV_BREAK_ADDR (ushort)0x0028
692#define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
693#define ASCV_BREAK_CONTROL (ushort)0x002C
694#define ASCV_BREAK_HIT_COUNT (ushort)0x002E
695
696#define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
697#define ASCV_MCODE_CHKSUM_W (ushort)0x0032
698#define ASCV_MCODE_SIZE_W (ushort)0x0034
699#define ASCV_STOP_CODE_B (ushort)0x0036
700#define ASCV_DVC_ERR_CODE_B (ushort)0x0037
701#define ASCV_OVERRUN_PADDR_D (ushort)0x0038
702#define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
703#define ASCV_HALTCODE_W (ushort)0x0040
704#define ASCV_CHKSUM_W (ushort)0x0042
705#define ASCV_MC_DATE_W (ushort)0x0044
706#define ASCV_MC_VER_W (ushort)0x0046
707#define ASCV_NEXTRDY_B (ushort)0x0048
708#define ASCV_DONENEXT_B (ushort)0x0049
709#define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
710#define ASCV_SCSIBUSY_B (ushort)0x004B
711#define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
712#define ASCV_CURCDB_B (ushort)0x004D
713#define ASCV_RCLUN_B (ushort)0x004E
714#define ASCV_BUSY_QHEAD_B (ushort)0x004F
715#define ASCV_DISC1_QHEAD_B (ushort)0x0050
716#define ASCV_DISC_ENABLE_B (ushort)0x0052
717#define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
718#define ASCV_HOSTSCSI_ID_B (ushort)0x0055
719#define ASCV_MCODE_CNTL_B (ushort)0x0056
720#define ASCV_NULL_TARGET_B (ushort)0x0057
721#define ASCV_FREE_Q_HEAD_W (ushort)0x0058
722#define ASCV_DONE_Q_TAIL_W (ushort)0x005A
723#define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
724#define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
725#define ASCV_HOST_FLAG_B (ushort)0x005D
726#define ASCV_TOTAL_READY_Q_B (ushort)0x0064
727#define ASCV_VER_SERIAL_B (ushort)0x0065
728#define ASCV_HALTCODE_SAVED_W (ushort)0x0066
729#define ASCV_WTM_FLAG_B (ushort)0x0068
730#define ASCV_RISC_FLAG_B (ushort)0x006A
731#define ASCV_REQ_SG_LIST_QP (ushort)0x006B
732#define ASC_HOST_FLAG_IN_ISR 0x01
733#define ASC_HOST_FLAG_ACK_INT 0x02
734#define ASC_RISC_FLAG_GEN_INT 0x01
735#define ASC_RISC_FLAG_REQ_SG_LIST 0x02
736#define IOP_CTRL (0x0F)
737#define IOP_STATUS (0x0E)
738#define IOP_INT_ACK IOP_STATUS
739#define IOP_REG_IFC (0x0D)
740#define IOP_SYN_OFFSET (0x0B)
741#define IOP_EXTRA_CONTROL (0x0D)
742#define IOP_REG_PC (0x0C)
743#define IOP_RAM_ADDR (0x0A)
744#define IOP_RAM_DATA (0x08)
745#define IOP_EEP_DATA (0x06)
746#define IOP_EEP_CMD (0x07)
747#define IOP_VERSION (0x03)
748#define IOP_CONFIG_HIGH (0x04)
749#define IOP_CONFIG_LOW (0x02)
750#define IOP_SIG_BYTE (0x01)
751#define IOP_SIG_WORD (0x00)
752#define IOP_REG_DC1 (0x0E)
753#define IOP_REG_DC0 (0x0C)
754#define IOP_REG_SB (0x0B)
755#define IOP_REG_DA1 (0x0A)
756#define IOP_REG_DA0 (0x08)
757#define IOP_REG_SC (0x09)
758#define IOP_DMA_SPEED (0x07)
759#define IOP_REG_FLAG (0x07)
760#define IOP_FIFO_H (0x06)
761#define IOP_FIFO_L (0x04)
762#define IOP_REG_ID (0x05)
763#define IOP_REG_QP (0x03)
764#define IOP_REG_IH (0x02)
765#define IOP_REG_IX (0x01)
766#define IOP_REG_AX (0x00)
767#define IFC_REG_LOCK (0x00)
768#define IFC_REG_UNLOCK (0x09)
769#define IFC_WR_EN_FILTER (0x10)
770#define IFC_RD_NO_EEPROM (0x10)
771#define IFC_SLEW_RATE (0x20)
772#define IFC_ACT_NEG (0x40)
773#define IFC_INP_FILTER (0x80)
774#define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
775#define SC_SEL (uchar)(0x80)
776#define SC_BSY (uchar)(0x40)
777#define SC_ACK (uchar)(0x20)
778#define SC_REQ (uchar)(0x10)
779#define SC_ATN (uchar)(0x08)
780#define SC_IO (uchar)(0x04)
781#define SC_CD (uchar)(0x02)
782#define SC_MSG (uchar)(0x01)
783#define SEC_SCSI_CTL (uchar)(0x80)
784#define SEC_ACTIVE_NEGATE (uchar)(0x40)
785#define SEC_SLEW_RATE (uchar)(0x20)
786#define SEC_ENABLE_FILTER (uchar)(0x10)
787#define ASC_HALT_EXTMSG_IN (ushort)0x8000
788#define ASC_HALT_CHK_CONDITION (ushort)0x8100
789#define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
790#define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
791#define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
792#define ASC_HALT_SDTR_REJECTED (ushort)0x4000
793#define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
794#define ASC_MAX_QNO 0xF8
795#define ASC_DATA_SEC_BEG (ushort)0x0080
796#define ASC_DATA_SEC_END (ushort)0x0080
797#define ASC_CODE_SEC_BEG (ushort)0x0080
798#define ASC_CODE_SEC_END (ushort)0x0080
799#define ASC_QADR_BEG (0x4000)
800#define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
801#define ASC_QADR_END (ushort)0x7FFF
802#define ASC_QLAST_ADR (ushort)0x7FC0
803#define ASC_QBLK_SIZE 0x40
804#define ASC_BIOS_DATA_QBEG 0xF8
805#define ASC_MIN_ACTIVE_QNO 0x01
806#define ASC_QLINK_END 0xFF
807#define ASC_EEPROM_WORDS 0x10
808#define ASC_MAX_MGS_LEN 0x10
809#define ASC_BIOS_ADDR_DEF 0xDC00
810#define ASC_BIOS_SIZE 0x3800
811#define ASC_BIOS_RAM_OFF 0x3800
812#define ASC_BIOS_RAM_SIZE 0x800
813#define ASC_BIOS_MIN_ADDR 0xC000
814#define ASC_BIOS_MAX_ADDR 0xEC00
815#define ASC_BIOS_BANK_SIZE 0x0400
816#define ASC_MCODE_START_ADDR 0x0080
817#define ASC_CFG0_HOST_INT_ON 0x0020
818#define ASC_CFG0_BIOS_ON 0x0040
819#define ASC_CFG0_VERA_BURST_ON 0x0080
820#define ASC_CFG0_SCSI_PARITY_ON 0x0800
821#define ASC_CFG1_SCSI_TARGET_ON 0x0080
822#define ASC_CFG1_LRAM_8BITS_ON 0x0800
823#define ASC_CFG_MSW_CLR_MASK 0x3080
824#define CSW_TEST1 (ASC_CS_TYPE)0x8000
825#define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
826#define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
827#define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
828#define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
829#define CSW_TEST2 (ASC_CS_TYPE)0x0400
830#define CSW_TEST3 (ASC_CS_TYPE)0x0200
831#define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
832#define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
833#define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
834#define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
835#define CSW_HALTED (ASC_CS_TYPE)0x0010
836#define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
837#define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
838#define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
839#define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
840#define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
841#define CIW_INT_ACK (ASC_CS_TYPE)0x0100
842#define CIW_TEST1 (ASC_CS_TYPE)0x0200
843#define CIW_TEST2 (ASC_CS_TYPE)0x0400
844#define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
845#define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
846#define CC_CHIP_RESET (uchar)0x80
847#define CC_SCSI_RESET (uchar)0x40
848#define CC_HALT (uchar)0x20
849#define CC_SINGLE_STEP (uchar)0x10
850#define CC_DMA_ABLE (uchar)0x08
851#define CC_TEST (uchar)0x04
852#define CC_BANK_ONE (uchar)0x02
853#define CC_DIAG (uchar)0x01
854#define ASC_1000_ID0W 0x04C1
855#define ASC_1000_ID0W_FIX 0x00C1
856#define ASC_1000_ID1B 0x25
1da177e4 857#define ASC_EISA_REV_IOP_MASK (0x0C83)
1da177e4
LT
858#define ASC_EISA_CFG_IOP_MASK (0x0C86)
859#define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
1da177e4
LT
860#define INS_HALTINT (ushort)0x6281
861#define INS_HALT (ushort)0x6280
862#define INS_SINT (ushort)0x6200
863#define INS_RFLAG_WTM (ushort)0x7380
864#define ASC_MC_SAVE_CODE_WSIZE 0x500
865#define ASC_MC_SAVE_DATA_WSIZE 0x40
866
867typedef struct asc_mc_saved {
27c868c2
MW
868 ushort data[ASC_MC_SAVE_DATA_WSIZE];
869 ushort code[ASC_MC_SAVE_CODE_WSIZE];
1da177e4
LT
870} ASC_MC_SAVED;
871
872#define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
873#define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
874#define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
875#define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
876#define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
877#define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
878#define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
879#define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
880#define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
881#define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
51219358
MW
882#define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
883#define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
884#define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
885#define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
1da177e4
LT
886#define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
887#define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
888#define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
889#define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
890#define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
891#define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
892#define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
893#define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
894#define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
895#define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
896#define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
897#define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
898#define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
899#define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
900#define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
901#define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
902#define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
903#define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
904#define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
905#define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
906#define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
907#define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
908#define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
909#define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
910#define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
911#define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
912#define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
913#define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
914#define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
915#define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
916#define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
917#define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
918#define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
919#define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
920#define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
921#define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
922#define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
923#define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
924#define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
925#define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
926#define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
927#define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
928#define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
929#define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
930#define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
931#define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
932#define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
933#define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
934#define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
935#define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
936#define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
937#define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
938#define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
939
1da177e4
LT
940/*
941 * Portable Data Types
942 *
943 * Any instance where a 32-bit long or pointer type is assumed
944 * for precision or HW defined structures, the following define
945 * types must be used. In Linux the char, short, and int types
946 * are all consistent at 8, 16, and 32 bits respectively. Pointers
947 * and long types are 64 bits on Alpha and UltraSPARC.
948 */
27c868c2
MW
949#define ADV_PADDR __u32 /* Physical address data type. */
950#define ADV_VADDR __u32 /* Virtual address data type. */
951#define ADV_DCNT __u32 /* Unsigned Data count type. */
952#define ADV_SDCNT __s32 /* Signed Data count type. */
1da177e4
LT
953
954/*
955 * These macros are used to convert a virtual address to a
956 * 32-bit value. This currently can be used on Linux Alpha
957 * which uses 64-bit virtual address but a 32-bit bus address.
958 * This is likely to break in the future, but doing this now
959 * will give us time to change the HW and FW to handle 64-bit
960 * addresses.
961 */
962#define ADV_VADDR_TO_U32 virt_to_bus
963#define ADV_U32_TO_VADDR bus_to_virt
964
27c868c2 965#define AdvPortAddr void __iomem * /* Virtual memory address size */
1da177e4
LT
966
967/*
968 * Define Adv Library required memory access macros.
969 */
970#define ADV_MEM_READB(addr) readb(addr)
971#define ADV_MEM_READW(addr) readw(addr)
972#define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
973#define ADV_MEM_WRITEW(addr, word) writew(word, addr)
974#define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
975
976#define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
977
1da177e4
LT
978/*
979 * Define total number of simultaneous maximum element scatter-gather
980 * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
981 * maximum number of outstanding commands per wide host adapter. Each
982 * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
983 * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
984 * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
985 * structures or 255 scatter-gather elements.
1da177e4
LT
986 */
987#define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
988
989/*
98d41c29 990 * Define maximum number of scatter-gather elements per request.
1da177e4
LT
991 */
992#define ADV_MAX_SG_LIST 255
98d41c29 993#define NO_OF_SG_PER_BLOCK 15
1da177e4 994
1da177e4
LT
995#define ADV_EEP_DVC_CFG_BEGIN (0x00)
996#define ADV_EEP_DVC_CFG_END (0x15)
27c868c2 997#define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
1da177e4
LT
998#define ADV_EEP_MAX_WORD_ADDR (0x1E)
999
1000#define ADV_EEP_DELAY_MS 100
1001
27c868c2
MW
1002#define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
1003#define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
1da177e4
LT
1004/*
1005 * For the ASC3550 Bit 13 is Termination Polarity control bit.
1006 * For later ICs Bit 13 controls whether the CIS (Card Information
1007 * Service Section) is loaded from EEPROM.
1008 */
27c868c2
MW
1009#define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
1010#define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
1da177e4
LT
1011/*
1012 * ASC38C1600 Bit 11
1013 *
1014 * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
1015 * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
1016 * Function 0 will specify INT B.
1017 *
1018 * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
1019 * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
1020 * Function 1 will specify INT A.
1021 */
27c868c2
MW
1022#define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
1023
1024typedef struct adveep_3550_config {
1025 /* Word Offset, Description */
1026
1027 ushort cfg_lsw; /* 00 power up initialization */
1028 /* bit 13 set - Term Polarity Control */
1029 /* bit 14 set - BIOS Enable */
1030 /* bit 15 set - Big Endian Mode */
1031 ushort cfg_msw; /* 01 unused */
1032 ushort disc_enable; /* 02 disconnect enable */
1033 ushort wdtr_able; /* 03 Wide DTR able */
1034 ushort sdtr_able; /* 04 Synchronous DTR able */
1035 ushort start_motor; /* 05 send start up motor */
1036 ushort tagqng_able; /* 06 tag queuing able */
1037 ushort bios_scan; /* 07 BIOS device control */
1038 ushort scam_tolerant; /* 08 no scam */
1039
1040 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1041 uchar bios_boot_delay; /* power up wait */
1042
1043 uchar scsi_reset_delay; /* 10 reset delay */
1044 uchar bios_id_lun; /* first boot device scsi id & lun */
1045 /* high nibble is lun */
1046 /* low nibble is scsi id */
1047
1048 uchar termination; /* 11 0 - automatic */
1049 /* 1 - low off / high off */
1050 /* 2 - low off / high on */
1051 /* 3 - low on / high on */
1052 /* There is no low on / high off */
1053
1054 uchar reserved1; /* reserved byte (not used) */
1055
1056 ushort bios_ctrl; /* 12 BIOS control bits */
1057 /* bit 0 BIOS don't act as initiator. */
1058 /* bit 1 BIOS > 1 GB support */
1059 /* bit 2 BIOS > 2 Disk Support */
1060 /* bit 3 BIOS don't support removables */
1061 /* bit 4 BIOS support bootable CD */
1062 /* bit 5 BIOS scan enabled */
1063 /* bit 6 BIOS support multiple LUNs */
1064 /* bit 7 BIOS display of message */
1065 /* bit 8 SCAM disabled */
1066 /* bit 9 Reset SCSI bus during init. */
1067 /* bit 10 */
1068 /* bit 11 No verbose initialization. */
1069 /* bit 12 SCSI parity enabled */
1070 /* bit 13 */
1071 /* bit 14 */
1072 /* bit 15 */
1073 ushort ultra_able; /* 13 ULTRA speed able */
1074 ushort reserved2; /* 14 reserved */
1075 uchar max_host_qng; /* 15 maximum host queuing */
1076 uchar max_dvc_qng; /* maximum per device queuing */
1077 ushort dvc_cntl; /* 16 control bit for driver */
1078 ushort bug_fix; /* 17 control bit for bug fix */
1079 ushort serial_number_word1; /* 18 Board serial number word 1 */
1080 ushort serial_number_word2; /* 19 Board serial number word 2 */
1081 ushort serial_number_word3; /* 20 Board serial number word 3 */
1082 ushort check_sum; /* 21 EEP check sum */
1083 uchar oem_name[16]; /* 22 OEM name */
1084 ushort dvc_err_code; /* 30 last device driver error code */
1085 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1086 ushort adv_err_addr; /* 32 last uc error address */
1087 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1088 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1089 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1090 ushort num_of_err; /* 36 number of error */
1da177e4
LT
1091} ADVEEP_3550_CONFIG;
1092
27c868c2
MW
1093typedef struct adveep_38C0800_config {
1094 /* Word Offset, Description */
1095
1096 ushort cfg_lsw; /* 00 power up initialization */
1097 /* bit 13 set - Load CIS */
1098 /* bit 14 set - BIOS Enable */
1099 /* bit 15 set - Big Endian Mode */
1100 ushort cfg_msw; /* 01 unused */
1101 ushort disc_enable; /* 02 disconnect enable */
1102 ushort wdtr_able; /* 03 Wide DTR able */
1103 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
1104 ushort start_motor; /* 05 send start up motor */
1105 ushort tagqng_able; /* 06 tag queuing able */
1106 ushort bios_scan; /* 07 BIOS device control */
1107 ushort scam_tolerant; /* 08 no scam */
1108
1109 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1110 uchar bios_boot_delay; /* power up wait */
1111
1112 uchar scsi_reset_delay; /* 10 reset delay */
1113 uchar bios_id_lun; /* first boot device scsi id & lun */
1114 /* high nibble is lun */
1115 /* low nibble is scsi id */
1116
1117 uchar termination_se; /* 11 0 - automatic */
1118 /* 1 - low off / high off */
1119 /* 2 - low off / high on */
1120 /* 3 - low on / high on */
1121 /* There is no low on / high off */
1122
1123 uchar termination_lvd; /* 11 0 - automatic */
1124 /* 1 - low off / high off */
1125 /* 2 - low off / high on */
1126 /* 3 - low on / high on */
1127 /* There is no low on / high off */
1128
1129 ushort bios_ctrl; /* 12 BIOS control bits */
1130 /* bit 0 BIOS don't act as initiator. */
1131 /* bit 1 BIOS > 1 GB support */
1132 /* bit 2 BIOS > 2 Disk Support */
1133 /* bit 3 BIOS don't support removables */
1134 /* bit 4 BIOS support bootable CD */
1135 /* bit 5 BIOS scan enabled */
1136 /* bit 6 BIOS support multiple LUNs */
1137 /* bit 7 BIOS display of message */
1138 /* bit 8 SCAM disabled */
1139 /* bit 9 Reset SCSI bus during init. */
1140 /* bit 10 */
1141 /* bit 11 No verbose initialization. */
1142 /* bit 12 SCSI parity enabled */
1143 /* bit 13 */
1144 /* bit 14 */
1145 /* bit 15 */
1146 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
1147 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
1148 uchar max_host_qng; /* 15 maximum host queueing */
1149 uchar max_dvc_qng; /* maximum per device queuing */
1150 ushort dvc_cntl; /* 16 control bit for driver */
1151 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
1152 ushort serial_number_word1; /* 18 Board serial number word 1 */
1153 ushort serial_number_word2; /* 19 Board serial number word 2 */
1154 ushort serial_number_word3; /* 20 Board serial number word 3 */
1155 ushort check_sum; /* 21 EEP check sum */
1156 uchar oem_name[16]; /* 22 OEM name */
1157 ushort dvc_err_code; /* 30 last device driver error code */
1158 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1159 ushort adv_err_addr; /* 32 last uc error address */
1160 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1161 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1162 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1163 ushort reserved36; /* 36 reserved */
1164 ushort reserved37; /* 37 reserved */
1165 ushort reserved38; /* 38 reserved */
1166 ushort reserved39; /* 39 reserved */
1167 ushort reserved40; /* 40 reserved */
1168 ushort reserved41; /* 41 reserved */
1169 ushort reserved42; /* 42 reserved */
1170 ushort reserved43; /* 43 reserved */
1171 ushort reserved44; /* 44 reserved */
1172 ushort reserved45; /* 45 reserved */
1173 ushort reserved46; /* 46 reserved */
1174 ushort reserved47; /* 47 reserved */
1175 ushort reserved48; /* 48 reserved */
1176 ushort reserved49; /* 49 reserved */
1177 ushort reserved50; /* 50 reserved */
1178 ushort reserved51; /* 51 reserved */
1179 ushort reserved52; /* 52 reserved */
1180 ushort reserved53; /* 53 reserved */
1181 ushort reserved54; /* 54 reserved */
1182 ushort reserved55; /* 55 reserved */
1183 ushort cisptr_lsw; /* 56 CIS PTR LSW */
1184 ushort cisprt_msw; /* 57 CIS PTR MSW */
1185 ushort subsysvid; /* 58 SubSystem Vendor ID */
1186 ushort subsysid; /* 59 SubSystem ID */
1187 ushort reserved60; /* 60 reserved */
1188 ushort reserved61; /* 61 reserved */
1189 ushort reserved62; /* 62 reserved */
1190 ushort reserved63; /* 63 reserved */
1da177e4
LT
1191} ADVEEP_38C0800_CONFIG;
1192
27c868c2
MW
1193typedef struct adveep_38C1600_config {
1194 /* Word Offset, Description */
1195
1196 ushort cfg_lsw; /* 00 power up initialization */
1197 /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
1198 /* clear - Func. 0 INTA, Func. 1 INTB */
1199 /* bit 13 set - Load CIS */
1200 /* bit 14 set - BIOS Enable */
1201 /* bit 15 set - Big Endian Mode */
1202 ushort cfg_msw; /* 01 unused */
1203 ushort disc_enable; /* 02 disconnect enable */
1204 ushort wdtr_able; /* 03 Wide DTR able */
1205 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
1206 ushort start_motor; /* 05 send start up motor */
1207 ushort tagqng_able; /* 06 tag queuing able */
1208 ushort bios_scan; /* 07 BIOS device control */
1209 ushort scam_tolerant; /* 08 no scam */
1210
1211 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1212 uchar bios_boot_delay; /* power up wait */
1213
1214 uchar scsi_reset_delay; /* 10 reset delay */
1215 uchar bios_id_lun; /* first boot device scsi id & lun */
1216 /* high nibble is lun */
1217 /* low nibble is scsi id */
1218
1219 uchar termination_se; /* 11 0 - automatic */
1220 /* 1 - low off / high off */
1221 /* 2 - low off / high on */
1222 /* 3 - low on / high on */
1223 /* There is no low on / high off */
1224
1225 uchar termination_lvd; /* 11 0 - automatic */
1226 /* 1 - low off / high off */
1227 /* 2 - low off / high on */
1228 /* 3 - low on / high on */
1229 /* There is no low on / high off */
1230
1231 ushort bios_ctrl; /* 12 BIOS control bits */
1232 /* bit 0 BIOS don't act as initiator. */
1233 /* bit 1 BIOS > 1 GB support */
1234 /* bit 2 BIOS > 2 Disk Support */
1235 /* bit 3 BIOS don't support removables */
1236 /* bit 4 BIOS support bootable CD */
1237 /* bit 5 BIOS scan enabled */
1238 /* bit 6 BIOS support multiple LUNs */
1239 /* bit 7 BIOS display of message */
1240 /* bit 8 SCAM disabled */
1241 /* bit 9 Reset SCSI bus during init. */
1242 /* bit 10 Basic Integrity Checking disabled */
1243 /* bit 11 No verbose initialization. */
1244 /* bit 12 SCSI parity enabled */
1245 /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
1246 /* bit 14 */
1247 /* bit 15 */
1248 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
1249 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
1250 uchar max_host_qng; /* 15 maximum host queueing */
1251 uchar max_dvc_qng; /* maximum per device queuing */
1252 ushort dvc_cntl; /* 16 control bit for driver */
1253 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
1254 ushort serial_number_word1; /* 18 Board serial number word 1 */
1255 ushort serial_number_word2; /* 19 Board serial number word 2 */
1256 ushort serial_number_word3; /* 20 Board serial number word 3 */
1257 ushort check_sum; /* 21 EEP check sum */
1258 uchar oem_name[16]; /* 22 OEM name */
1259 ushort dvc_err_code; /* 30 last device driver error code */
1260 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1261 ushort adv_err_addr; /* 32 last uc error address */
1262 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1263 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1264 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1265 ushort reserved36; /* 36 reserved */
1266 ushort reserved37; /* 37 reserved */
1267 ushort reserved38; /* 38 reserved */
1268 ushort reserved39; /* 39 reserved */
1269 ushort reserved40; /* 40 reserved */
1270 ushort reserved41; /* 41 reserved */
1271 ushort reserved42; /* 42 reserved */
1272 ushort reserved43; /* 43 reserved */
1273 ushort reserved44; /* 44 reserved */
1274 ushort reserved45; /* 45 reserved */
1275 ushort reserved46; /* 46 reserved */
1276 ushort reserved47; /* 47 reserved */
1277 ushort reserved48; /* 48 reserved */
1278 ushort reserved49; /* 49 reserved */
1279 ushort reserved50; /* 50 reserved */
1280 ushort reserved51; /* 51 reserved */
1281 ushort reserved52; /* 52 reserved */
1282 ushort reserved53; /* 53 reserved */
1283 ushort reserved54; /* 54 reserved */
1284 ushort reserved55; /* 55 reserved */
1285 ushort cisptr_lsw; /* 56 CIS PTR LSW */
1286 ushort cisprt_msw; /* 57 CIS PTR MSW */
1287 ushort subsysvid; /* 58 SubSystem Vendor ID */
1288 ushort subsysid; /* 59 SubSystem ID */
1289 ushort reserved60; /* 60 reserved */
1290 ushort reserved61; /* 61 reserved */
1291 ushort reserved62; /* 62 reserved */
1292 ushort reserved63; /* 63 reserved */
1da177e4
LT
1293} ADVEEP_38C1600_CONFIG;
1294
1295/*
1296 * EEPROM Commands
1297 */
1298#define ASC_EEP_CMD_DONE 0x0200
1da177e4
LT
1299
1300/* bios_ctrl */
1301#define BIOS_CTRL_BIOS 0x0001
1302#define BIOS_CTRL_EXTENDED_XLAT 0x0002
1303#define BIOS_CTRL_GT_2_DISK 0x0004
1304#define BIOS_CTRL_BIOS_REMOVABLE 0x0008
1305#define BIOS_CTRL_BOOTABLE_CD 0x0010
1306#define BIOS_CTRL_MULTIPLE_LUN 0x0040
1307#define BIOS_CTRL_DISPLAY_MSG 0x0080
1308#define BIOS_CTRL_NO_SCAM 0x0100
1309#define BIOS_CTRL_RESET_SCSI_BUS 0x0200
1310#define BIOS_CTRL_INIT_VERBOSE 0x0800
1311#define BIOS_CTRL_SCSI_PARITY 0x1000
1312#define BIOS_CTRL_AIPP_DIS 0x2000
1313
27c868c2 1314#define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
1da177e4 1315
27c868c2 1316#define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
1da177e4
LT
1317
1318/*
1319 * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
1320 * a special 16K Adv Library and Microcode version. After the issue is
1321 * resolved, should restore 32K support.
1322 *
1323 * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
1324 */
27c868c2 1325#define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
1da177e4
LT
1326
1327/*
1328 * Byte I/O register address from base of 'iop_base'.
1329 */
1330#define IOPB_INTR_STATUS_REG 0x00
1331#define IOPB_CHIP_ID_1 0x01
1332#define IOPB_INTR_ENABLES 0x02
1333#define IOPB_CHIP_TYPE_REV 0x03
1334#define IOPB_RES_ADDR_4 0x04
1335#define IOPB_RES_ADDR_5 0x05
1336#define IOPB_RAM_DATA 0x06
1337#define IOPB_RES_ADDR_7 0x07
1338#define IOPB_FLAG_REG 0x08
1339#define IOPB_RES_ADDR_9 0x09
1340#define IOPB_RISC_CSR 0x0A
1341#define IOPB_RES_ADDR_B 0x0B
1342#define IOPB_RES_ADDR_C 0x0C
1343#define IOPB_RES_ADDR_D 0x0D
1344#define IOPB_SOFT_OVER_WR 0x0E
1345#define IOPB_RES_ADDR_F 0x0F
1346#define IOPB_MEM_CFG 0x10
1347#define IOPB_RES_ADDR_11 0x11
1348#define IOPB_GPIO_DATA 0x12
1349#define IOPB_RES_ADDR_13 0x13
1350#define IOPB_FLASH_PAGE 0x14
1351#define IOPB_RES_ADDR_15 0x15
1352#define IOPB_GPIO_CNTL 0x16
1353#define IOPB_RES_ADDR_17 0x17
1354#define IOPB_FLASH_DATA 0x18
1355#define IOPB_RES_ADDR_19 0x19
1356#define IOPB_RES_ADDR_1A 0x1A
1357#define IOPB_RES_ADDR_1B 0x1B
1358#define IOPB_RES_ADDR_1C 0x1C
1359#define IOPB_RES_ADDR_1D 0x1D
1360#define IOPB_RES_ADDR_1E 0x1E
1361#define IOPB_RES_ADDR_1F 0x1F
1362#define IOPB_DMA_CFG0 0x20
1363#define IOPB_DMA_CFG1 0x21
1364#define IOPB_TICKLE 0x22
1365#define IOPB_DMA_REG_WR 0x23
1366#define IOPB_SDMA_STATUS 0x24
1367#define IOPB_SCSI_BYTE_CNT 0x25
1368#define IOPB_HOST_BYTE_CNT 0x26
1369#define IOPB_BYTE_LEFT_TO_XFER 0x27
1370#define IOPB_BYTE_TO_XFER_0 0x28
1371#define IOPB_BYTE_TO_XFER_1 0x29
1372#define IOPB_BYTE_TO_XFER_2 0x2A
1373#define IOPB_BYTE_TO_XFER_3 0x2B
1374#define IOPB_ACC_GRP 0x2C
1375#define IOPB_RES_ADDR_2D 0x2D
1376#define IOPB_DEV_ID 0x2E
1377#define IOPB_RES_ADDR_2F 0x2F
1378#define IOPB_SCSI_DATA 0x30
1379#define IOPB_RES_ADDR_31 0x31
1380#define IOPB_RES_ADDR_32 0x32
1381#define IOPB_SCSI_DATA_HSHK 0x33
1382#define IOPB_SCSI_CTRL 0x34
1383#define IOPB_RES_ADDR_35 0x35
1384#define IOPB_RES_ADDR_36 0x36
1385#define IOPB_RES_ADDR_37 0x37
1386#define IOPB_RAM_BIST 0x38
1387#define IOPB_PLL_TEST 0x39
1388#define IOPB_PCI_INT_CFG 0x3A
1389#define IOPB_RES_ADDR_3B 0x3B
1390#define IOPB_RFIFO_CNT 0x3C
1391#define IOPB_RES_ADDR_3D 0x3D
1392#define IOPB_RES_ADDR_3E 0x3E
1393#define IOPB_RES_ADDR_3F 0x3F
1394
1395/*
1396 * Word I/O register address from base of 'iop_base'.
1397 */
27c868c2
MW
1398#define IOPW_CHIP_ID_0 0x00 /* CID0 */
1399#define IOPW_CTRL_REG 0x02 /* CC */
1400#define IOPW_RAM_ADDR 0x04 /* LA */
1401#define IOPW_RAM_DATA 0x06 /* LD */
1da177e4 1402#define IOPW_RES_ADDR_08 0x08
27c868c2
MW
1403#define IOPW_RISC_CSR 0x0A /* CSR */
1404#define IOPW_SCSI_CFG0 0x0C /* CFG0 */
1405#define IOPW_SCSI_CFG1 0x0E /* CFG1 */
1da177e4 1406#define IOPW_RES_ADDR_10 0x10
27c868c2 1407#define IOPW_SEL_MASK 0x12 /* SM */
1da177e4 1408#define IOPW_RES_ADDR_14 0x14
27c868c2 1409#define IOPW_FLASH_ADDR 0x16 /* FA */
1da177e4 1410#define IOPW_RES_ADDR_18 0x18
27c868c2
MW
1411#define IOPW_EE_CMD 0x1A /* EC */
1412#define IOPW_EE_DATA 0x1C /* ED */
1413#define IOPW_SFIFO_CNT 0x1E /* SFC */
1da177e4 1414#define IOPW_RES_ADDR_20 0x20
27c868c2
MW
1415#define IOPW_Q_BASE 0x22 /* QB */
1416#define IOPW_QP 0x24 /* QP */
1417#define IOPW_IX 0x26 /* IX */
1418#define IOPW_SP 0x28 /* SP */
1419#define IOPW_PC 0x2A /* PC */
1da177e4
LT
1420#define IOPW_RES_ADDR_2C 0x2C
1421#define IOPW_RES_ADDR_2E 0x2E
27c868c2
MW
1422#define IOPW_SCSI_DATA 0x30 /* SD */
1423#define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
1424#define IOPW_SCSI_CTRL 0x34 /* SC */
1425#define IOPW_HSHK_CFG 0x36 /* HCFG */
1426#define IOPW_SXFR_STATUS 0x36 /* SXS */
1427#define IOPW_SXFR_CNTL 0x38 /* SXL */
1428#define IOPW_SXFR_CNTH 0x3A /* SXH */
1da177e4 1429#define IOPW_RES_ADDR_3C 0x3C
27c868c2 1430#define IOPW_RFIFO_DATA 0x3E /* RFD */
1da177e4
LT
1431
1432/*
1433 * Doubleword I/O register address from base of 'iop_base'.
1434 */
1435#define IOPDW_RES_ADDR_0 0x00
1436#define IOPDW_RAM_DATA 0x04
1437#define IOPDW_RES_ADDR_8 0x08
1438#define IOPDW_RES_ADDR_C 0x0C
1439#define IOPDW_RES_ADDR_10 0x10
1440#define IOPDW_COMMA 0x14
1441#define IOPDW_COMMB 0x18
1442#define IOPDW_RES_ADDR_1C 0x1C
1443#define IOPDW_SDMA_ADDR0 0x20
1444#define IOPDW_SDMA_ADDR1 0x24
1445#define IOPDW_SDMA_COUNT 0x28
1446#define IOPDW_SDMA_ERROR 0x2C
1447#define IOPDW_RDMA_ADDR0 0x30
1448#define IOPDW_RDMA_ADDR1 0x34
1449#define IOPDW_RDMA_COUNT 0x38
1450#define IOPDW_RDMA_ERROR 0x3C
1451
1452#define ADV_CHIP_ID_BYTE 0x25
1453#define ADV_CHIP_ID_WORD 0x04C1
1454
1da177e4
LT
1455#define ADV_INTR_ENABLE_HOST_INTR 0x01
1456#define ADV_INTR_ENABLE_SEL_INTR 0x02
1457#define ADV_INTR_ENABLE_DPR_INTR 0x04
1458#define ADV_INTR_ENABLE_RTA_INTR 0x08
1459#define ADV_INTR_ENABLE_RMA_INTR 0x10
1460#define ADV_INTR_ENABLE_RST_INTR 0x20
1461#define ADV_INTR_ENABLE_DPE_INTR 0x40
1462#define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
1463
1464#define ADV_INTR_STATUS_INTRA 0x01
1465#define ADV_INTR_STATUS_INTRB 0x02
1466#define ADV_INTR_STATUS_INTRC 0x04
1467
1468#define ADV_RISC_CSR_STOP (0x0000)
1469#define ADV_RISC_TEST_COND (0x2000)
1470#define ADV_RISC_CSR_RUN (0x4000)
1471#define ADV_RISC_CSR_SINGLE_STEP (0x8000)
1472
1473#define ADV_CTRL_REG_HOST_INTR 0x0100
1474#define ADV_CTRL_REG_SEL_INTR 0x0200
1475#define ADV_CTRL_REG_DPR_INTR 0x0400
1476#define ADV_CTRL_REG_RTA_INTR 0x0800
1477#define ADV_CTRL_REG_RMA_INTR 0x1000
1478#define ADV_CTRL_REG_RES_BIT14 0x2000
1479#define ADV_CTRL_REG_DPE_INTR 0x4000
1480#define ADV_CTRL_REG_POWER_DONE 0x8000
1481#define ADV_CTRL_REG_ANY_INTR 0xFF00
1482
1483#define ADV_CTRL_REG_CMD_RESET 0x00C6
1484#define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
1485#define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
1486#define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
1487#define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
1488
1489#define ADV_TICKLE_NOP 0x00
1490#define ADV_TICKLE_A 0x01
1491#define ADV_TICKLE_B 0x02
1492#define ADV_TICKLE_C 0x03
1493
1da177e4
LT
1494#define AdvIsIntPending(port) \
1495 (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
1496
1497/*
1498 * SCSI_CFG0 Register bit definitions
1499 */
27c868c2
MW
1500#define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
1501#define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
1502#define EVEN_PARITY 0x1000 /* Select Even Parity */
1503#define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
1504#define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
1505#define PRIM_MODE 0x0100 /* Primitive SCSI mode */
1506#define SCAM_EN 0x0080 /* Enable SCAM selection */
1507#define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
1508#define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
1509#define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
1510#define OUR_ID 0x000F /* SCSI ID */
1da177e4
LT
1511
1512/*
1513 * SCSI_CFG1 Register bit definitions
1514 */
27c868c2
MW
1515#define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
1516#define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
1517#define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
1518#define FILTER_SEL 0x0C00 /* Filter Period Selection */
1519#define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
1520#define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
1521#define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
1522#define ACTIVE_DBL 0x0200 /* Disable Active Negation */
1523#define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
1524#define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
1525#define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
1526#define TERM_CTL 0x0030 /* External SCSI Termination Bits */
1527#define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
1528#define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
1529#define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
1da177e4
LT
1530
1531/*
1532 * Addendum for ASC-38C0800 Chip
1533 *
1534 * The ASC-38C1600 Chip uses the same definitions except that the
1535 * bus mode override bits [12:10] have been moved to byte register
1536 * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
1537 * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
1538 * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
1539 * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
1540 * and [1:0]. Bits [14], [7:6], [3:2] are unused.
1541 */
27c868c2
MW
1542#define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
1543#define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
1544#define HVD 0x1000 /* HVD Device Detect */
1545#define LVD 0x0800 /* LVD Device Detect */
1546#define SE 0x0400 /* SE Device Detect */
1547#define TERM_LVD 0x00C0 /* LVD Termination Bits */
1548#define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
1549#define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
1550#define TERM_SE 0x0030 /* SE Termination Bits */
1551#define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
1552#define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
1553#define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
1554#define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
1555#define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
1556#define C_DET_SE 0x0003 /* SE Cable Detect Bits */
1557#define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
1558#define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
1da177e4
LT
1559
1560#define CABLE_ILLEGAL_A 0x7
1561 /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
1562
1563#define CABLE_ILLEGAL_B 0xB
1564 /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
1565
1566/*
1567 * MEM_CFG Register bit definitions
1568 */
27c868c2
MW
1569#define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
1570#define FAST_EE_CLK 0x20 /* Diagnostic Bit */
1571#define RAM_SZ 0x1C /* Specify size of RAM to RISC */
1572#define RAM_SZ_2KB 0x00 /* 2 KB */
1573#define RAM_SZ_4KB 0x04 /* 4 KB */
1574#define RAM_SZ_8KB 0x08 /* 8 KB */
1575#define RAM_SZ_16KB 0x0C /* 16 KB */
1576#define RAM_SZ_32KB 0x10 /* 32 KB */
1577#define RAM_SZ_64KB 0x14 /* 64 KB */
1da177e4
LT
1578
1579/*
1580 * DMA_CFG0 Register bit definitions
1581 *
1582 * This register is only accessible to the host.
1583 */
27c868c2
MW
1584#define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
1585#define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
1586#define FIFO_THRESH_16B 0x00 /* 16 bytes */
1587#define FIFO_THRESH_32B 0x20 /* 32 bytes */
1588#define FIFO_THRESH_48B 0x30 /* 48 bytes */
1589#define FIFO_THRESH_64B 0x40 /* 64 bytes */
1590#define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
1591#define FIFO_THRESH_96B 0x60 /* 96 bytes */
1592#define FIFO_THRESH_112B 0x70 /* 112 bytes */
1593#define START_CTL 0x0C /* DMA start conditions */
1594#define START_CTL_TH 0x00 /* Wait threshold level (default) */
1595#define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
1596#define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
1597#define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
1598#define READ_CMD 0x03 /* Memory Read Method */
1599#define READ_CMD_MR 0x00 /* Memory Read */
1600#define READ_CMD_MRL 0x02 /* Memory Read Long */
1601#define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
1da177e4
LT
1602
1603/*
1604 * ASC-38C0800 RAM BIST Register bit definitions
1605 */
1606#define RAM_TEST_MODE 0x80
1607#define PRE_TEST_MODE 0x40
1608#define NORMAL_MODE 0x00
1609#define RAM_TEST_DONE 0x10
1610#define RAM_TEST_STATUS 0x0F
1611#define RAM_TEST_HOST_ERROR 0x08
1612#define RAM_TEST_INTRAM_ERROR 0x04
1613#define RAM_TEST_RISC_ERROR 0x02
1614#define RAM_TEST_SCSI_ERROR 0x01
1615#define RAM_TEST_SUCCESS 0x00
1616#define PRE_TEST_VALUE 0x05
1617#define NORMAL_VALUE 0x00
1618
1619/*
1620 * ASC38C1600 Definitions
1621 *
1622 * IOPB_PCI_INT_CFG Bit Field Definitions
1623 */
1624
27c868c2 1625#define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
1da177e4
LT
1626
1627/*
1628 * Bit 1 can be set to change the interrupt for the Function to operate in
1629 * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
1630 * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
1631 * mode, otherwise the operating mode is undefined.
1632 */
1633#define TOTEMPOLE 0x02
1634
1635/*
1636 * Bit 0 can be used to change the Int Pin for the Function. The value is
1637 * 0 by default for both Functions with Function 0 using INT A and Function
1638 * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
1639 * INT A is used.
1640 *
1641 * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
1642 * value specified in the PCI Configuration Space.
1643 */
1644#define INTAB 0x01
1645
1da177e4
LT
1646/*
1647 * Adv Library Status Definitions
1648 */
1649#define ADV_TRUE 1
1650#define ADV_FALSE 0
1da177e4
LT
1651#define ADV_SUCCESS 1
1652#define ADV_BUSY 0
1653#define ADV_ERROR (-1)
1654
1da177e4
LT
1655/*
1656 * ADV_DVC_VAR 'warn_code' values
1657 */
27c868c2
MW
1658#define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
1659#define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
1660#define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
27c868c2 1661#define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
1da177e4 1662
27c868c2
MW
1663#define ADV_MAX_TID 15 /* max. target identifier */
1664#define ADV_MAX_LUN 7 /* max. logical unit number */
1da177e4 1665
1da177e4
LT
1666/*
1667 * Fixed locations of microcode operating variables.
1668 */
27c868c2
MW
1669#define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
1670#define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
1671#define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
1672#define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
1673#define ASC_MC_VERSION_NUM 0x003A /* microcode number */
1674#define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
1675#define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
1676#define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
1677#define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
1678#define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
1679#define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
1680#define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
1681#define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
1da177e4
LT
1682#define ASC_MC_CHIP_TYPE 0x009A
1683#define ASC_MC_INTRB_CODE 0x009B
1684#define ASC_MC_WDTR_ABLE 0x009C
1685#define ASC_MC_SDTR_ABLE 0x009E
1686#define ASC_MC_TAGQNG_ABLE 0x00A0
1687#define ASC_MC_DISC_ENABLE 0x00A2
1688#define ASC_MC_IDLE_CMD_STATUS 0x00A4
1689#define ASC_MC_IDLE_CMD 0x00A6
1690#define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
1691#define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
1692#define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
1693#define ASC_MC_DEFAULT_MEM_CFG 0x00B0
1694#define ASC_MC_DEFAULT_SEL_MASK 0x00B2
1695#define ASC_MC_SDTR_DONE 0x00B6
1696#define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
1697#define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
1698#define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
27c868c2 1699#define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
1da177e4 1700#define ASC_MC_WDTR_DONE 0x0124
27c868c2 1701#define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
1da177e4
LT
1702#define ASC_MC_ICQ 0x0160
1703#define ASC_MC_IRQ 0x0164
1704#define ASC_MC_PPR_ABLE 0x017A
1705
1706/*
1707 * BIOS LRAM variable absolute offsets.
1708 */
1709#define BIOS_CODESEG 0x54
1710#define BIOS_CODELEN 0x56
1711#define BIOS_SIGNATURE 0x58
1712#define BIOS_VERSION 0x5A
1713
1714/*
1715 * Microcode Control Flags
1716 *
1717 * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
1718 * and handled by the microcode.
1719 */
27c868c2
MW
1720#define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
1721#define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
1da177e4
LT
1722
1723/*
1724 * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
1725 */
1726#define HSHK_CFG_WIDE_XFR 0x8000
1727#define HSHK_CFG_RATE 0x0F00
1728#define HSHK_CFG_OFFSET 0x001F
1729
27c868c2
MW
1730#define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
1731#define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
1732#define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
1733#define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
1734
1735#define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
1736#define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
1737#define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
1738#define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
1739#define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
1740
1741#define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
1742#define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
1743#define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
1744#define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
1745#define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
1da177e4
LT
1746/*
1747 * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
1748 * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
1749 */
27c868c2
MW
1750#define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
1751#define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
1da177e4
LT
1752
1753/*
1754 * All fields here are accessed by the board microcode and need to be
1755 * little-endian.
1756 */
27c868c2
MW
1757typedef struct adv_carr_t {
1758 ADV_VADDR carr_va; /* Carrier Virtual Address */
1759 ADV_PADDR carr_pa; /* Carrier Physical Address */
1760 ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
1761 /*
1762 * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
1763 *
1764 * next_vpa [3:1] Reserved Bits
1765 * next_vpa [0] Done Flag set in Response Queue.
1766 */
1767 ADV_VADDR next_vpa;
1da177e4
LT
1768} ADV_CARR_T;
1769
1770/*
1771 * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
1772 */
1773#define ASC_NEXT_VPA_MASK 0xFFFFFFF0
1774
1775#define ASC_RQ_DONE 0x00000001
1776#define ASC_RQ_GOOD 0x00000002
1777#define ASC_CQ_STOPPER 0x00000000
1778
1779#define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
1780
1781#define ADV_CARRIER_NUM_PAGE_CROSSING \
fd625f47 1782 (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + (PAGE_SIZE - 1))/PAGE_SIZE)
1da177e4
LT
1783
1784#define ADV_CARRIER_BUFSIZE \
1785 ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
1786
1787/*
1788 * ASC_SCSI_REQ_Q 'a_flag' definitions
1789 *
1790 * The Adv Library should limit use to the lower nibble (4 bits) of
1791 * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
1792 */
27c868c2
MW
1793#define ADV_POLL_REQUEST 0x01 /* poll for request completion */
1794#define ADV_SCSIQ_DONE 0x02 /* request done */
1795#define ADV_DONT_RETRY 0x08 /* don't do retry */
1da177e4 1796
27c868c2
MW
1797#define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
1798#define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
1799#define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
1da177e4
LT
1800
1801/*
1802 * Adapter temporary configuration structure
1803 *
1804 * This structure can be discarded after initialization. Don't add
1805 * fields here needed after initialization.
1806 *
1807 * Field naming convention:
1808 *
1809 * *_enable indicates the field enables or disables a feature. The
1810 * value of the field is never reset.
1811 */
1812typedef struct adv_dvc_cfg {
27c868c2
MW
1813 ushort disc_enable; /* enable disconnection */
1814 uchar chip_version; /* chip version */
1815 uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
27c868c2
MW
1816 ushort control_flag; /* Microcode Control Flag */
1817 ushort mcode_date; /* Microcode date */
1818 ushort mcode_version; /* Microcode version */
27c868c2
MW
1819 ushort serial1; /* EEPROM serial number word 1 */
1820 ushort serial2; /* EEPROM serial number word 2 */
1821 ushort serial3; /* EEPROM serial number word 3 */
1da177e4
LT
1822} ADV_DVC_CFG;
1823
1824struct adv_dvc_var;
1825struct adv_scsi_req_q;
1826
1da177e4 1827typedef struct asc_sg_block {
27c868c2
MW
1828 uchar reserved1;
1829 uchar reserved2;
1830 uchar reserved3;
1831 uchar sg_cnt; /* Valid entries in block. */
1832 ADV_PADDR sg_ptr; /* Pointer to next sg block. */
1833 struct {
1834 ADV_PADDR sg_addr; /* SG element address. */
1835 ADV_DCNT sg_count; /* SG element count. */
1836 } sg_list[NO_OF_SG_PER_BLOCK];
1da177e4
LT
1837} ADV_SG_BLOCK;
1838
1839/*
1840 * ADV_SCSI_REQ_Q - microcode request structure
1841 *
1842 * All fields in this structure up to byte 60 are used by the microcode.
1843 * The microcode makes assumptions about the size and ordering of fields
1844 * in this structure. Do not change the structure definition here without
1845 * coordinating the change with the microcode.
1846 *
1847 * All fields accessed by microcode must be maintained in little_endian
1848 * order.
1849 */
1850typedef struct adv_scsi_req_q {
27c868c2
MW
1851 uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
1852 uchar target_cmd;
1853 uchar target_id; /* Device target identifier. */
1854 uchar target_lun; /* Device target logical unit number. */
1855 ADV_PADDR data_addr; /* Data buffer physical address. */
1856 ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
1857 ADV_PADDR sense_addr;
1858 ADV_PADDR carr_pa;
1859 uchar mflag;
1860 uchar sense_len;
1861 uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
1862 uchar scsi_cntl;
1863 uchar done_status; /* Completion status. */
1864 uchar scsi_status; /* SCSI status byte. */
1865 uchar host_status; /* Ucode host status. */
1866 uchar sg_working_ix;
1867 uchar cdb[12]; /* SCSI CDB bytes 0-11. */
1868 ADV_PADDR sg_real_addr; /* SG list physical address. */
1869 ADV_PADDR scsiq_rptr;
1870 uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
1871 ADV_VADDR scsiq_ptr;
1872 ADV_VADDR carr_va;
1873 /*
1874 * End of microcode structure - 60 bytes. The rest of the structure
1875 * is used by the Adv Library and ignored by the microcode.
1876 */
1877 ADV_VADDR srb_ptr;
1878 ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
1879 char *vdata_addr; /* Data buffer virtual address. */
1880 uchar a_flag;
1881 uchar pad[2]; /* Pad out to a word boundary. */
1da177e4
LT
1882} ADV_SCSI_REQ_Q;
1883
98d41c29
MW
1884/*
1885 * The following two structures are used to process Wide Board requests.
1886 *
1887 * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
1888 * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
1889 * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
1890 * Mid-Level SCSI request structure.
1891 *
1892 * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
1893 * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
1894 * up to 255 scatter-gather elements may be used per request or
1895 * ADV_SCSI_REQ_Q.
1896 *
1897 * Both structures must be 32 byte aligned.
1898 */
1899typedef struct adv_sgblk {
1900 ADV_SG_BLOCK sg_block; /* Sgblock structure. */
1901 uchar align[32]; /* Sgblock structure padding. */
1902 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
1903} adv_sgblk_t;
1904
1905typedef struct adv_req {
1906 ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
1907 uchar align[32]; /* Request structure padding. */
1908 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
1909 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
1910 struct adv_req *next_reqp; /* Next Request Structure. */
1911} adv_req_t;
1912
1913/*
1914 * Adapter operation variable structure.
1915 *
1916 * One structure is required per host adapter.
1917 *
1918 * Field naming convention:
1919 *
1920 * *_able indicates both whether a feature should be enabled or disabled
1921 * and whether a device isi capable of the feature. At initialization
1922 * this field may be set, but later if a device is found to be incapable
1923 * of the feature, the field is cleared.
1924 */
1925typedef struct adv_dvc_var {
1926 AdvPortAddr iop_base; /* I/O port address */
1927 ushort err_code; /* fatal error code */
1928 ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
1929 ushort wdtr_able; /* try WDTR for a device */
1930 ushort sdtr_able; /* try SDTR for a device */
1931 ushort ultra_able; /* try SDTR Ultra speed for a device */
1932 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
1933 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
1934 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
1935 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
1936 ushort tagqng_able; /* try tagged queuing with a device */
1937 ushort ppr_able; /* PPR message capable per TID bitmask. */
1938 uchar max_dvc_qng; /* maximum number of tagged commands per device */
1939 ushort start_motor; /* start motor command allowed */
1940 uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
1941 uchar chip_no; /* should be assigned by caller */
1942 uchar max_host_qng; /* maximum number of Q'ed command allowed */
1943 ushort no_scam; /* scam_tolerant of EEPROM */
1944 struct asc_board *drv_ptr; /* driver pointer to private structure */
1945 uchar chip_scsi_id; /* chip SCSI target ID */
1946 uchar chip_type;
1947 uchar bist_err_code;
1948 ADV_CARR_T *carrier_buf;
1949 ADV_CARR_T *carr_freelist; /* Carrier free list. */
1950 ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
1951 ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
1952 ushort carr_pending_cnt; /* Count of pending carriers. */
1953 struct adv_req *orig_reqp; /* adv_req_t memory block. */
1954 /*
1955 * Note: The following fields will not be used after initialization. The
1956 * driver may discard the buffer after initialization is done.
1957 */
1958 ADV_DVC_CFG *cfg; /* temporary configuration structure */
1959} ADV_DVC_VAR;
1960
1da177e4
LT
1961/*
1962 * Microcode idle loop commands
1963 */
1964#define IDLE_CMD_COMPLETED 0
1965#define IDLE_CMD_STOP_CHIP 0x0001
1966#define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
1967#define IDLE_CMD_SEND_INT 0x0004
1968#define IDLE_CMD_ABORT 0x0008
1969#define IDLE_CMD_DEVICE_RESET 0x0010
27c868c2
MW
1970#define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
1971#define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
1da177e4
LT
1972#define IDLE_CMD_SCSIREQ 0x0080
1973
1974#define IDLE_CMD_STATUS_SUCCESS 0x0001
1975#define IDLE_CMD_STATUS_FAILURE 0x0002
1976
1977/*
1978 * AdvSendIdleCmd() flag definitions.
1979 */
1980#define ADV_NOWAIT 0x01
1981
1982/*
1983 * Wait loop time out values.
1984 */
27c868c2
MW
1985#define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
1986#define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
27c868c2 1987#define SCSI_MAX_RETRY 10 /* retry count */
1da177e4 1988
27c868c2
MW
1989#define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
1990#define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
1991#define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
1992#define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
1da177e4 1993
27c868c2 1994#define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
1da177e4 1995
1da177e4
LT
1996/* Read byte from a register. */
1997#define AdvReadByteRegister(iop_base, reg_off) \
1998 (ADV_MEM_READB((iop_base) + (reg_off)))
1999
2000/* Write byte to a register. */
2001#define AdvWriteByteRegister(iop_base, reg_off, byte) \
2002 (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
2003
2004/* Read word (2 bytes) from a register. */
2005#define AdvReadWordRegister(iop_base, reg_off) \
2006 (ADV_MEM_READW((iop_base) + (reg_off)))
2007
2008/* Write word (2 bytes) to a register. */
2009#define AdvWriteWordRegister(iop_base, reg_off, word) \
2010 (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
2011
2012/* Write dword (4 bytes) to a register. */
2013#define AdvWriteDWordRegister(iop_base, reg_off, dword) \
2014 (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
2015
2016/* Read byte from LRAM. */
2017#define AdvReadByteLram(iop_base, addr, byte) \
2018do { \
2019 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
2020 (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
2021} while (0)
2022
2023/* Write byte to LRAM. */
2024#define AdvWriteByteLram(iop_base, addr, byte) \
2025 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2026 ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
2027
2028/* Read word (2 bytes) from LRAM. */
2029#define AdvReadWordLram(iop_base, addr, word) \
2030do { \
2031 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
2032 (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
2033} while (0)
2034
2035/* Write word (2 bytes) to LRAM. */
2036#define AdvWriteWordLram(iop_base, addr, word) \
2037 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2038 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
2039
2040/* Write little-endian double word (4 bytes) to LRAM */
2041/* Because of unspecified C language ordering don't use auto-increment. */
2042#define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
2043 ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2044 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
2045 cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
2046 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
2047 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
2048 cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
2049
2050/* Read word (2 bytes) from LRAM assuming that the address is already set. */
2051#define AdvReadWordAutoIncLram(iop_base) \
2052 (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
2053
2054/* Write word (2 bytes) to LRAM assuming that the address is already set. */
2055#define AdvWriteWordAutoIncLram(iop_base, word) \
2056 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
2057
1da177e4
LT
2058/*
2059 * Define macro to check for Condor signature.
2060 *
2061 * Evaluate to ADV_TRUE if a Condor chip is found the specified port
2062 * address 'iop_base'. Otherwise evalue to ADV_FALSE.
2063 */
2064#define AdvFindSignature(iop_base) \
2065 (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
2066 ADV_CHIP_ID_BYTE) && \
2067 (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
2068 ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
2069
2070/*
2071 * Define macro to Return the version number of the chip at 'iop_base'.
2072 *
2073 * The second parameter 'bus_type' is currently unused.
2074 */
2075#define AdvGetChipVersion(iop_base, bus_type) \
2076 AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
2077
2078/*
2079 * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
2080 * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
2081 *
2082 * If the request has not yet been sent to the device it will simply be
2083 * aborted from RISC memory. If the request is disconnected it will be
2084 * aborted on reselection by sending an Abort Message to the target ID.
2085 *
2086 * Return value:
2087 * ADV_TRUE(1) - Queue was successfully aborted.
2088 * ADV_FALSE(0) - Queue was not found on the active queue list.
2089 */
2090#define AdvAbortQueue(asc_dvc, scsiq) \
2091 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
2092 (ADV_DCNT) (scsiq))
2093
2094/*
2095 * Send a Bus Device Reset Message to the specified target ID.
2096 *
2097 * All outstanding commands will be purged if sending the
2098 * Bus Device Reset Message is successful.
2099 *
2100 * Return Value:
2101 * ADV_TRUE(1) - All requests on the target are purged.
2102 * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
2103 * are not purged.
2104 */
2105#define AdvResetDevice(asc_dvc, target_id) \
2106 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
2107 (ADV_DCNT) (target_id))
2108
2109/*
2110 * SCSI Wide Type definition.
2111 */
2112#define ADV_SCSI_BIT_ID_TYPE ushort
2113
2114/*
2115 * AdvInitScsiTarget() 'cntl_flag' options.
2116 */
2117#define ADV_SCAN_LUN 0x01
2118#define ADV_CAPINFO_NOLUN 0x02
2119
2120/*
2121 * Convert target id to target id bit mask.
2122 */
2123#define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
2124
2125/*
2126 * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
2127 */
2128
27c868c2 2129#define QD_NO_STATUS 0x00 /* Request not completed yet. */
1da177e4
LT
2130#define QD_NO_ERROR 0x01
2131#define QD_ABORTED_BY_HOST 0x02
2132#define QD_WITH_ERROR 0x04
2133
2134#define QHSTA_NO_ERROR 0x00
2135#define QHSTA_M_SEL_TIMEOUT 0x11
2136#define QHSTA_M_DATA_OVER_RUN 0x12
2137#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
2138#define QHSTA_M_QUEUE_ABORTED 0x15
27c868c2
MW
2139#define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
2140#define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
2141#define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
2142#define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
2143#define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
2144#define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
2145#define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
1da177e4 2146/* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
27c868c2
MW
2147#define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
2148#define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
2149#define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
2150#define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
2151#define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
2152#define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
2153#define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
2154#define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
1da177e4
LT
2155#define QHSTA_M_WTM_TIMEOUT 0x41
2156#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
2157#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
2158#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
27c868c2
MW
2159#define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
2160#define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
2161#define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
1da177e4 2162
1da177e4
LT
2163/* Return the address that is aligned at the next doubleword >= to 'addr'. */
2164#define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
2165#define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
2166#define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
2167
2168/*
2169 * Total contiguous memory needed for driver SG blocks.
2170 *
2171 * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
2172 * number of scatter-gather elements the driver supports in a
2173 * single request.
2174 */
2175
2176#define ADV_SG_LIST_MAX_BYTE_SIZE \
2177 (sizeof(ADV_SG_BLOCK) * \
2178 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
2179
d2411495 2180/* struct asc_board flags */
27c868c2 2181#define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
1da177e4
LT
2182
2183#define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
1da177e4 2184
27c868c2 2185#define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
1da177e4 2186
27c868c2 2187#define ASC_INFO_SIZE 128 /* advansys_info() line size */
1da177e4
LT
2188
2189#ifdef CONFIG_PROC_FS
2190/* /proc/scsi/advansys/[0...] related definitions */
2191#define ASC_PRTBUF_SIZE 2048
2192#define ASC_PRTLINE_SIZE 160
2193
2194#define ASC_PRT_NEXT() \
2195 if (cp) { \
2196 totlen += len; \
2197 leftlen -= len; \
2198 if (leftlen == 0) { \
2199 return totlen; \
2200 } \
2201 cp += len; \
2202 }
2203#endif /* CONFIG_PROC_FS */
2204
2205/* Asc Library return codes */
2206#define ASC_TRUE 1
2207#define ASC_FALSE 0
2208#define ASC_NOERROR 1
2209#define ASC_BUSY 0
2210#define ASC_ERROR (-1)
2211
2212/* struct scsi_cmnd function return codes */
2213#define STATUS_BYTE(byte) (byte)
2214#define MSG_BYTE(byte) ((byte) << 8)
2215#define HOST_BYTE(byte) ((byte) << 16)
2216#define DRIVER_BYTE(byte) ((byte) << 24)
2217
d2411495 2218#define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
1da177e4 2219#ifndef ADVANSYS_STATS
27c868c2 2220#define ASC_STATS_ADD(shost, counter, count)
1da177e4 2221#else /* ADVANSYS_STATS */
27c868c2 2222#define ASC_STATS_ADD(shost, counter, count) \
d2411495 2223 (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
1da177e4
LT
2224#endif /* ADVANSYS_STATS */
2225
2226#define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
2227
2228/* If the result wraps when calculating tenths, return 0. */
2229#define ASC_TENTHS(num, den) \
2230 (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
2231 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
2232
2233/*
2234 * Display a message to the console.
2235 */
2236#define ASC_PRINT(s) \
2237 { \
2238 printk("advansys: "); \
2239 printk(s); \
2240 }
2241
2242#define ASC_PRINT1(s, a1) \
2243 { \
2244 printk("advansys: "); \
2245 printk((s), (a1)); \
2246 }
2247
2248#define ASC_PRINT2(s, a1, a2) \
2249 { \
2250 printk("advansys: "); \
2251 printk((s), (a1), (a2)); \
2252 }
2253
2254#define ASC_PRINT3(s, a1, a2, a3) \
2255 { \
2256 printk("advansys: "); \
2257 printk((s), (a1), (a2), (a3)); \
2258 }
2259
2260#define ASC_PRINT4(s, a1, a2, a3, a4) \
2261 { \
2262 printk("advansys: "); \
2263 printk((s), (a1), (a2), (a3), (a4)); \
2264 }
2265
1da177e4
LT
2266#ifndef ADVANSYS_DEBUG
2267
b352f923 2268#define ASC_DBG(lvl, s...)
1da177e4 2269#define ASC_DBG_PRT_SCSI_HOST(lvl, s)
1da177e4
LT
2270#define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
2271#define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
2272#define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
2273#define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
2274#define ASC_DBG_PRT_HEX(lvl, name, start, length)
2275#define ASC_DBG_PRT_CDB(lvl, cdb, len)
2276#define ASC_DBG_PRT_SENSE(lvl, sense, len)
2277#define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
2278
2279#else /* ADVANSYS_DEBUG */
2280
2281/*
2282 * Debugging Message Levels:
2283 * 0: Errors Only
2284 * 1: High-Level Tracing
2285 * 2-N: Verbose Tracing
2286 */
2287
b352f923
MW
2288#define ASC_DBG(lvl, format, arg...) { \
2289 if (asc_dbglvl >= (lvl)) \
2290 printk(KERN_DEBUG "%s: %s: " format, DRV_NAME, \
2291 __FUNCTION__ , ## arg); \
2292}
1da177e4
LT
2293
2294#define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
2295 { \
2296 if (asc_dbglvl >= (lvl)) { \
2297 asc_prt_scsi_host(s); \
2298 } \
2299 }
2300
1da177e4
LT
2301#define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
2302 { \
2303 if (asc_dbglvl >= (lvl)) { \
2304 asc_prt_asc_scsi_q(scsiqp); \
2305 } \
2306 }
2307
2308#define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
2309 { \
2310 if (asc_dbglvl >= (lvl)) { \
2311 asc_prt_asc_qdone_info(qdone); \
2312 } \
2313 }
2314
2315#define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
2316 { \
2317 if (asc_dbglvl >= (lvl)) { \
2318 asc_prt_adv_scsi_req_q(scsiqp); \
2319 } \
2320 }
2321
2322#define ASC_DBG_PRT_HEX(lvl, name, start, length) \
2323 { \
2324 if (asc_dbglvl >= (lvl)) { \
2325 asc_prt_hex((name), (start), (length)); \
2326 } \
2327 }
2328
2329#define ASC_DBG_PRT_CDB(lvl, cdb, len) \
2330 ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
2331
2332#define ASC_DBG_PRT_SENSE(lvl, sense, len) \
2333 ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
2334
2335#define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
2336 ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
2337#endif /* ADVANSYS_DEBUG */
2338
1da177e4
LT
2339#ifdef ADVANSYS_STATS
2340
2341/* Per board statistics structure */
2342struct asc_stats {
27c868c2
MW
2343 /* Driver Entrypoint Statistics */
2344 ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
2345 ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
2346 ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
2347 ADV_DCNT interrupt; /* # advansys_interrupt() calls */
2348 ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
2349 ADV_DCNT done; /* # calls to request's scsi_done function */
2350 ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
2351 ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
2352 ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
2353 /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
2354 ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
2355 ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
2356 ADV_DCNT exe_error; /* # ASC_ERROR returns. */
2357 ADV_DCNT exe_unknown; /* # unknown returns. */
2358 /* Data Transfer Statistics */
2359 ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
2360 ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
2361 ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
2362 ADV_DCNT sg_elem; /* # scatter-gather elements */
2363 ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
1da177e4
LT
2364};
2365#endif /* ADVANSYS_STATS */
2366
1da177e4
LT
2367/*
2368 * Structure allocated for each board.
2369 *
8dfb5379 2370 * This structure is allocated by scsi_host_alloc() at the end
1da177e4
LT
2371 * of the 'Scsi_Host' structure starting at the 'hostdata'
2372 * field. It is guaranteed to be allocated from DMA-able memory.
2373 */
d2411495 2374struct asc_board {
394dbf3f 2375 struct device *dev;
27c868c2 2376 uint flags; /* Board flags */
d361db48 2377 unsigned int irq;
27c868c2
MW
2378 union {
2379 ASC_DVC_VAR asc_dvc_var; /* Narrow board */
2380 ADV_DVC_VAR adv_dvc_var; /* Wide board */
2381 } dvc_var;
2382 union {
2383 ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
2384 ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
2385 } dvc_cfg;
2386 ushort asc_n_io_port; /* Number I/O ports. */
27c868c2 2387 ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
27c868c2
MW
2388 ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
2389 ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
2390 ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
2391 union {
2392 ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
2393 ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
2394 ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
2395 ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
2396 } eep_config;
2397 ulong last_reset; /* Saved last reset time */
27c868c2
MW
2398 /* /proc/scsi/advansys/[0...] */
2399 char *prtbuf; /* /proc print buffer */
1da177e4 2400#ifdef ADVANSYS_STATS
27c868c2
MW
2401 struct asc_stats asc_stats; /* Board statistics */
2402#endif /* ADVANSYS_STATS */
2403 /*
2404 * The following fields are used only for Narrow Boards.
2405 */
27c868c2
MW
2406 uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
2407 /*
2408 * The following fields are used only for Wide Boards.
2409 */
2410 void __iomem *ioremap_addr; /* I/O Memory remap address. */
2411 ushort ioport; /* I/O Port address. */
27c868c2
MW
2412 adv_req_t *adv_reqp; /* Request structures. */
2413 adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
2414 ushort bios_signature; /* BIOS Signature. */
2415 ushort bios_version; /* BIOS Version. */
2416 ushort bios_codeseg; /* BIOS Code Segment. */
2417 ushort bios_codelen; /* BIOS Code Segment Length. */
d2411495 2418};
1da177e4 2419
13ac2d9c
MW
2420#define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
2421 dvc_var.adv_dvc_var)
2422#define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
2423
1da177e4 2424/* Overrun buffer used by all narrow boards. */
27c868c2 2425static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
1da177e4 2426
1da177e4 2427#ifdef ADVANSYS_DEBUG
27c868c2 2428static int asc_dbglvl = 3;
1da177e4 2429
1da177e4 2430/*
51219358 2431 * asc_prt_asc_dvc_var()
1da177e4 2432 */
51219358 2433static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
1da177e4 2434{
51219358 2435 printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
27c868c2 2436
51219358
MW
2437 printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
2438 "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
2439
2440 printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
2441 (unsigned)h->init_sdtr);
2442
2443 printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
2444 "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
2445 (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
2446 (unsigned)h->chip_no);
2447
2448 printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
2449 "%u,\n", (unsigned)h->queue_full_or_busy,
2450 (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
2451
2452 printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
2453 "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
2454 (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
2455 (unsigned)h->in_critical_cnt);
2456
2457 printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
2458 "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
2459 (unsigned)h->init_state, (unsigned)h->no_scam,
2460 (unsigned)h->pci_fix_asyn_xfer);
2461
d361db48 2462 printk(" cfg 0x%lx\n", (ulong)h->cfg);
1da177e4
LT
2463}
2464
51219358
MW
2465/*
2466 * asc_prt_asc_dvc_cfg()
2467 */
2468static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
6ed1ef07 2469{
51219358 2470 printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
6ed1ef07 2471
51219358
MW
2472 printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
2473 h->can_tagged_qng, h->cmd_qng_enabled);
2474 printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
2475 h->disc_enable, h->sdtr_enable);
6ed1ef07 2476
b08fc565
MW
2477 printk(" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, "
2478 "chip_version %d,\n", h->chip_scsi_id, h->isa_dma_speed,
2479 h->isa_dma_channel, h->chip_version);
51219358 2480
b352f923 2481 printk(" mcode_date 0x%x, mcode_version %d, overrun_buf 0x%p\n",
b08fc565 2482 h->mcode_date, h->mcode_version, h->overrun_buf);
6ed1ef07
MW
2483}
2484
1da177e4 2485/*
51219358 2486 * asc_prt_adv_dvc_var()
1da177e4 2487 *
51219358 2488 * Display an ADV_DVC_VAR structure.
1da177e4 2489 */
51219358 2490static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
1da177e4 2491{
51219358 2492 printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
27c868c2 2493
51219358
MW
2494 printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
2495 (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
1da177e4 2496
b352f923
MW
2497 printk(" sdtr_able 0x%x, wdtr_able 0x%x\n",
2498 (unsigned)h->sdtr_able, (unsigned)h->wdtr_able);
1da177e4 2499
d361db48
MW
2500 printk(" start_motor 0x%x, scsi_reset_wait 0x%x\n",
2501 (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
1da177e4 2502
51219358
MW
2503 printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
2504 (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
2505 (ulong)h->carr_freelist);
1da177e4 2506
51219358
MW
2507 printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
2508 (ulong)h->icq_sp, (ulong)h->irq_sp);
1da177e4 2509
51219358
MW
2510 printk(" no_scam 0x%x, tagqng_able 0x%x\n",
2511 (unsigned)h->no_scam, (unsigned)h->tagqng_able);
1da177e4 2512
51219358
MW
2513 printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
2514 (unsigned)h->chip_scsi_id, (ulong)h->cfg);
2515}
1da177e4 2516
51219358
MW
2517/*
2518 * asc_prt_adv_dvc_cfg()
2519 *
2520 * Display an ADV_DVC_CFG structure.
2521 */
2522static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
2523{
2524 printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
27c868c2 2525
51219358
MW
2526 printk(" disc_enable 0x%x, termination 0x%x\n",
2527 h->disc_enable, h->termination);
1da177e4 2528
51219358
MW
2529 printk(" chip_version 0x%x, mcode_date 0x%x\n",
2530 h->chip_version, h->mcode_date);
27c868c2 2531
b352f923
MW
2532 printk(" mcode_version 0x%x, control_flag 0x%x\n",
2533 h->mcode_version, h->control_flag);
1da177e4
LT
2534}
2535
2536/*
b352f923 2537 * asc_prt_scsi_host()
1da177e4 2538 */
b352f923 2539static void asc_prt_scsi_host(struct Scsi_Host *s)
1da177e4 2540{
b352f923 2541 struct asc_board *boardp = shost_priv(s);
51219358 2542
b352f923
MW
2543 printk("Scsi_Host at addr 0x%p, device %s\n", s, boardp->dev->bus_id);
2544 printk(" host_busy %u, host_no %d, last_reset %d,\n",
2545 s->host_busy, s->host_no, (unsigned)s->last_reset);
51219358 2546
b352f923
MW
2547 printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
2548 (ulong)s->base, (ulong)s->io_port, boardp->irq);
51219358 2549
b352f923
MW
2550 printk(" dma_channel %d, this_id %d, can_queue %d,\n",
2551 s->dma_channel, s->this_id, s->can_queue);
1da177e4 2552
b352f923
MW
2553 printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
2554 s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
27c868c2 2555
b352f923
MW
2556 if (ASC_NARROW_BOARD(boardp)) {
2557 asc_prt_asc_dvc_var(&boardp->dvc_var.asc_dvc_var);
2558 asc_prt_asc_dvc_cfg(&boardp->dvc_cfg.asc_dvc_cfg);
2559 } else {
2560 asc_prt_adv_dvc_var(&boardp->dvc_var.adv_dvc_var);
2561 asc_prt_adv_dvc_cfg(&boardp->dvc_cfg.adv_dvc_cfg);
074c8fe4 2562 }
1da177e4
LT
2563}
2564
51219358
MW
2565/*
2566 * asc_prt_hex()
2567 *
2568 * Print hexadecimal output in 4 byte groupings 32 bytes
2569 * or 8 double-words per line.
2570 */
2571static void asc_prt_hex(char *f, uchar *s, int l)
47d853cc 2572{
51219358
MW
2573 int i;
2574 int j;
2575 int k;
2576 int m;
47d853cc 2577
51219358
MW
2578 printk("%s: (%d bytes)\n", f, l);
2579
2580 for (i = 0; i < l; i += 32) {
2581
2582 /* Display a maximum of 8 double-words per line. */
2583 if ((k = (l - i) / 4) >= 8) {
2584 k = 8;
2585 m = 0;
47d853cc 2586 } else {
51219358 2587 m = (l - i) % 4;
47d853cc
MW
2588 }
2589
51219358
MW
2590 for (j = 0; j < k; j++) {
2591 printk(" %2.2X%2.2X%2.2X%2.2X",
2592 (unsigned)s[i + (j * 4)],
2593 (unsigned)s[i + (j * 4) + 1],
2594 (unsigned)s[i + (j * 4) + 2],
2595 (unsigned)s[i + (j * 4) + 3]);
47d853cc 2596 }
47d853cc 2597
51219358
MW
2598 switch (m) {
2599 case 0:
2600 default:
2601 break;
2602 case 1:
2603 printk(" %2.2X", (unsigned)s[i + (j * 4)]);
2604 break;
2605 case 2:
2606 printk(" %2.2X%2.2X",
2607 (unsigned)s[i + (j * 4)],
2608 (unsigned)s[i + (j * 4) + 1]);
2609 break;
2610 case 3:
2611 printk(" %2.2X%2.2X%2.2X",
2612 (unsigned)s[i + (j * 4) + 1],
2613 (unsigned)s[i + (j * 4) + 2],
2614 (unsigned)s[i + (j * 4) + 3]);
2615 break;
2616 }
47d853cc 2617
51219358 2618 printk("\n");
47d853cc
MW
2619 }
2620}
b352f923
MW
2621
2622/*
2623 * asc_prt_asc_scsi_q()
2624 */
2625static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
2626{
2627 ASC_SG_HEAD *sgp;
2628 int i;
2629
2630 printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
2631
2632 printk
2633 (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
2634 q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
2635 q->q2.tag_code);
2636
2637 printk
2638 (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
2639 (ulong)le32_to_cpu(q->q1.data_addr),
2640 (ulong)le32_to_cpu(q->q1.data_cnt),
2641 (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
2642
2643 printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
2644 (ulong)q->cdbptr, q->q2.cdb_len,
2645 (ulong)q->sg_head, q->q1.sg_queue_cnt);
2646
2647 if (q->sg_head) {
2648 sgp = q->sg_head;
2649 printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
2650 printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
2651 sgp->queue_cnt);
2652 for (i = 0; i < sgp->entry_cnt; i++) {
2653 printk(" [%u]: addr 0x%lx, bytes %lu\n",
2654 i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
2655 (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
2656 }
2657
2658 }
2659}
2660
2661/*
2662 * asc_prt_asc_qdone_info()
2663 */
2664static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
2665{
2666 printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
2667 printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
2668 (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
2669 q->d2.tag_code);
2670 printk
2671 (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
2672 q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
2673}
2674
2675/*
2676 * asc_prt_adv_sgblock()
2677 *
2678 * Display an ADV_SG_BLOCK structure.
2679 */
2680static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
2681{
2682 int i;
2683
2684 printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
2685 (ulong)b, sgblockno);
2686 printk(" sg_cnt %u, sg_ptr 0x%lx\n",
2687 b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
2688 BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
2689 if (b->sg_ptr != 0)
2690 BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
2691 for (i = 0; i < b->sg_cnt; i++) {
2692 printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
2693 i, (ulong)b->sg_list[i].sg_addr,
2694 (ulong)b->sg_list[i].sg_count);
2695 }
2696}
2697
2698/*
2699 * asc_prt_adv_scsi_req_q()
2700 *
2701 * Display an ADV_SCSI_REQ_Q structure.
2702 */
2703static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
2704{
2705 int sg_blk_cnt;
2706 struct asc_sg_block *sg_ptr;
2707
2708 printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
2709
2710 printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
2711 q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
2712
2713 printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
2714 q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
2715
2716 printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
2717 (ulong)le32_to_cpu(q->data_cnt),
2718 (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
2719
2720 printk
2721 (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
2722 q->cdb_len, q->done_status, q->host_status, q->scsi_status);
2723
2724 printk(" sg_working_ix 0x%x, target_cmd %u\n",
2725 q->sg_working_ix, q->target_cmd);
2726
2727 printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
2728 (ulong)le32_to_cpu(q->scsiq_rptr),
2729 (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
2730
2731 /* Display the request's ADV_SG_BLOCK structures. */
2732 if (q->sg_list_ptr != NULL) {
2733 sg_blk_cnt = 0;
2734 while (1) {
2735 /*
2736 * 'sg_ptr' is a physical address. Convert it to a virtual
2737 * address by indexing 'sg_blk_cnt' into the virtual address
2738 * array 'sg_list_ptr'.
2739 *
2740 * XXX - Assumes all SG physical blocks are virtually contiguous.
2741 */
2742 sg_ptr =
2743 &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
2744 asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
2745 if (sg_ptr->sg_ptr == 0) {
2746 break;
2747 }
2748 sg_blk_cnt++;
2749 }
2750 }
2751}
51219358 2752#endif /* ADVANSYS_DEBUG */
47d853cc 2753
1da177e4 2754/*
51219358 2755 * advansys_info()
47d853cc 2756 *
51219358
MW
2757 * Return suitable for printing on the console with the argument
2758 * adapter's configuration information.
2759 *
2760 * Note: The information line should not exceed ASC_INFO_SIZE bytes,
2761 * otherwise the static 'info' array will be overrun.
1da177e4 2762 */
51219358 2763static const char *advansys_info(struct Scsi_Host *shost)
1da177e4 2764{
51219358 2765 static char info[ASC_INFO_SIZE];
d2411495 2766 struct asc_board *boardp = shost_priv(shost);
51219358
MW
2767 ASC_DVC_VAR *asc_dvc_varp;
2768 ADV_DVC_VAR *adv_dvc_varp;
2769 char *busname;
2770 char *widename = NULL;
1da177e4 2771
51219358
MW
2772 if (ASC_NARROW_BOARD(boardp)) {
2773 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
b352f923 2774 ASC_DBG(1, "begin\n");
51219358
MW
2775 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
2776 if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
2777 ASC_IS_ISAPNP) {
2778 busname = "ISA PnP";
2779 } else {
2780 busname = "ISA";
2781 }
2782 sprintf(info,
2783 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
2784 ASC_VERSION, busname,
2785 (ulong)shost->io_port,
2786 (ulong)shost->io_port + ASC_IOADR_GAP - 1,
d361db48 2787 boardp->irq, shost->dma_channel);
51219358
MW
2788 } else {
2789 if (asc_dvc_varp->bus_type & ASC_IS_VL) {
2790 busname = "VL";
2791 } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
2792 busname = "EISA";
2793 } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
2794 if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
2795 == ASC_IS_PCI_ULTRA) {
2796 busname = "PCI Ultra";
2797 } else {
2798 busname = "PCI";
2799 }
2800 } else {
2801 busname = "?";
9d0e96eb
MW
2802 shost_printk(KERN_ERR, shost, "unknown bus "
2803 "type %d\n", asc_dvc_varp->bus_type);
51219358
MW
2804 }
2805 sprintf(info,
2806 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
2807 ASC_VERSION, busname, (ulong)shost->io_port,
2808 (ulong)shost->io_port + ASC_IOADR_GAP - 1,
d361db48 2809 boardp->irq);
51219358
MW
2810 }
2811 } else {
2812 /*
2813 * Wide Adapter Information
2814 *
2815 * Memory-mapped I/O is used instead of I/O space to access
2816 * the adapter, but display the I/O Port range. The Memory
2817 * I/O address is displayed through the driver /proc file.
2818 */
2819 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
2820 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
2821 widename = "Ultra-Wide";
2822 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
2823 widename = "Ultra2-Wide";
2824 } else {
2825 widename = "Ultra3-Wide";
2826 }
2827 sprintf(info,
2828 "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
2829 ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
d361db48 2830 (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, boardp->irq);
51219358
MW
2831 }
2832 BUG_ON(strlen(info) >= ASC_INFO_SIZE);
b352f923 2833 ASC_DBG(1, "end\n");
51219358 2834 return info;
47d853cc
MW
2835}
2836
51219358 2837#ifdef CONFIG_PROC_FS
47d853cc 2838/*
51219358 2839 * asc_prt_line()
47d853cc 2840 *
51219358
MW
2841 * If 'cp' is NULL print to the console, otherwise print to a buffer.
2842 *
2843 * Return 0 if printing to the console, otherwise return the number of
2844 * bytes written to the buffer.
2845 *
2846 * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
2847 * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
47d853cc 2848 */
51219358 2849static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
47d853cc 2850{
51219358
MW
2851 va_list args;
2852 int ret;
2853 char s[ASC_PRTLINE_SIZE];
47d853cc 2854
51219358
MW
2855 va_start(args, fmt);
2856 ret = vsprintf(s, fmt, args);
2857 BUG_ON(ret >= ASC_PRTLINE_SIZE);
2858 if (buf == NULL) {
2859 (void)printk(s);
2860 ret = 0;
2861 } else {
2862 ret = min(buflen, ret);
2863 memcpy(buf, s, ret);
2864 }
2865 va_end(args);
2866 return ret;
47d853cc
MW
2867}
2868
2869/*
51219358 2870 * asc_prt_board_devices()
47d853cc 2871 *
51219358
MW
2872 * Print driver information for devices attached to the board.
2873 *
2874 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
2875 * cf. asc_prt_line().
2876 *
2877 * Return the number of characters copied into 'cp'. No more than
2878 * 'cplen' characters will be copied to 'cp'.
47d853cc 2879 */
51219358 2880static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
47d853cc 2881{
d2411495 2882 struct asc_board *boardp = shost_priv(shost);
51219358
MW
2883 int leftlen;
2884 int totlen;
2885 int len;
2886 int chip_scsi_id;
2887 int i;
47d853cc 2888
51219358
MW
2889 leftlen = cplen;
2890 totlen = len = 0;
47d853cc 2891
51219358
MW
2892 len = asc_prt_line(cp, leftlen,
2893 "\nDevice Information for AdvanSys SCSI Host %d:\n",
2894 shost->host_no);
2895 ASC_PRT_NEXT();
47d853cc 2896
51219358
MW
2897 if (ASC_NARROW_BOARD(boardp)) {
2898 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
2899 } else {
2900 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
47d853cc
MW
2901 }
2902
51219358
MW
2903 len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
2904 ASC_PRT_NEXT();
2905 for (i = 0; i <= ADV_MAX_TID; i++) {
2906 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
2907 len = asc_prt_line(cp, leftlen, " %X,", i);
2908 ASC_PRT_NEXT();
2909 }
27c868c2 2910 }
51219358
MW
2911 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
2912 ASC_PRT_NEXT();
2913
2914 return totlen;
47d853cc
MW
2915}
2916
2917/*
51219358 2918 * Display Wide Board BIOS Information.
47d853cc 2919 */
51219358 2920static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
47d853cc 2921{
d2411495 2922 struct asc_board *boardp = shost_priv(shost);
51219358
MW
2923 int leftlen;
2924 int totlen;
2925 int len;
2926 ushort major, minor, letter;
2927
51219358
MW
2928 leftlen = cplen;
2929 totlen = len = 0;
2930
2931 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
2932 ASC_PRT_NEXT();
47d853cc
MW
2933
2934 /*
51219358
MW
2935 * If the BIOS saved a valid signature, then fill in
2936 * the BIOS code segment base address.
47d853cc 2937 */
51219358
MW
2938 if (boardp->bios_signature != 0x55AA) {
2939 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
2940 ASC_PRT_NEXT();
2941 len = asc_prt_line(cp, leftlen,
2942 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
2943 ASC_PRT_NEXT();
2944 len = asc_prt_line(cp, leftlen,
2945 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
2946 ASC_PRT_NEXT();
2947 } else {
2948 major = (boardp->bios_version >> 12) & 0xF;
2949 minor = (boardp->bios_version >> 8) & 0xF;
2950 letter = (boardp->bios_version & 0xFF);
47d853cc 2951
51219358
MW
2952 len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
2953 major, minor,
2954 letter >= 26 ? '?' : letter + 'A');
2955 ASC_PRT_NEXT();
47d853cc 2956
51219358
MW
2957 /*
2958 * Current available ROM BIOS release is 3.1I for UW
2959 * and 3.2I for U2W. This code doesn't differentiate
2960 * UW and U2W boards.
2961 */
2962 if (major < 3 || (major <= 3 && minor < 1) ||
2963 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
2964 len = asc_prt_line(cp, leftlen,
2965 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
2966 ASC_PRT_NEXT();
2967 len = asc_prt_line(cp, leftlen,
2968 "ftp://ftp.connectcom.net/pub\n");
2969 ASC_PRT_NEXT();
2970 }
2971 }
2972
2973 return totlen;
1da177e4
LT
2974}
2975
1da177e4 2976/*
51219358
MW
2977 * Add serial number to information bar if signature AAh
2978 * is found in at bit 15-9 (7 bits) of word 1.
1da177e4 2979 *
51219358 2980 * Serial Number consists fo 12 alpha-numeric digits.
1da177e4 2981 *
51219358
MW
2982 * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
2983 * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
2984 * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
2985 * 5 - Product revision (A-J) Word0: " "
1da177e4 2986 *
51219358
MW
2987 * Signature Word1: 15-9 (7 bits)
2988 * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
2989 * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
1da177e4 2990 *
51219358 2991 * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
1da177e4 2992 *
51219358 2993 * Note 1: Only production cards will have a serial number.
1da177e4 2994 *
51219358 2995 * Note 2: Signature is most significant 7 bits (0xFE).
1da177e4 2996 *
51219358 2997 * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
1da177e4 2998 */
51219358 2999static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
1da177e4 3000{
51219358 3001 ushort w, num;
27c868c2 3002
51219358
MW
3003 if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
3004 return ASC_FALSE;
3005 } else {
3006 /*
3007 * First word - 6 digits.
3008 */
3009 w = serialnum[0];
27c868c2 3010
51219358
MW
3011 /* Product type - 1st digit. */
3012 if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
3013 /* Product type is P=Prototype */
3014 *cp += 0x8;
3015 }
3016 cp++;
3017
3018 /* Manufacturing location - 2nd digit. */
3019 *cp++ = 'A' + ((w & 0x1C00) >> 10);
3020
3021 /* Product ID - 3rd, 4th digits. */
3022 num = w & 0x3FF;
3023 *cp++ = '0' + (num / 100);
3024 num %= 100;
3025 *cp++ = '0' + (num / 10);
3026
3027 /* Product revision - 5th digit. */
3028 *cp++ = 'A' + (num % 10);
27c868c2 3029
27c868c2 3030 /*
51219358 3031 * Second word
27c868c2 3032 */
51219358 3033 w = serialnum[1];
27c868c2
MW
3034
3035 /*
51219358 3036 * Year - 6th digit.
27c868c2 3037 *
51219358
MW
3038 * If bit 15 of third word is set, then the
3039 * last digit of the year is greater than 7.
27c868c2 3040 */
51219358
MW
3041 if (serialnum[2] & 0x8000) {
3042 *cp++ = '8' + ((w & 0x1C0) >> 6);
3043 } else {
3044 *cp++ = '0' + ((w & 0x1C0) >> 6);
27c868c2
MW
3045 }
3046
51219358
MW
3047 /* Week of year - 7th, 8th digits. */
3048 num = w & 0x003F;
3049 *cp++ = '0' + num / 10;
3050 num %= 10;
3051 *cp++ = '0' + num;
27c868c2
MW
3052
3053 /*
51219358 3054 * Third word
27c868c2 3055 */
51219358 3056 w = serialnum[2] & 0x7FFF;
1da177e4 3057
51219358
MW
3058 /* Serial number - 9th digit. */
3059 *cp++ = 'A' + (w / 1000);
27c868c2 3060
51219358
MW
3061 /* 10th, 11th, 12th digits. */
3062 num = w % 1000;
3063 *cp++ = '0' + num / 100;
3064 num %= 100;
3065 *cp++ = '0' + num / 10;
3066 num %= 10;
3067 *cp++ = '0' + num;
3068
3069 *cp = '\0'; /* Null Terminate the string. */
3070 return ASC_TRUE;
3071 }
1da177e4
LT
3072}
3073
3074/*
51219358 3075 * asc_prt_asc_board_eeprom()
1da177e4 3076 *
51219358 3077 * Print board EEPROM configuration.
1da177e4 3078 *
51219358
MW
3079 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3080 * cf. asc_prt_line().
3081 *
3082 * Return the number of characters copied into 'cp'. No more than
3083 * 'cplen' characters will be copied to 'cp'.
1da177e4 3084 */
51219358 3085static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
1da177e4 3086{
d2411495 3087 struct asc_board *boardp = shost_priv(shost);
51219358
MW
3088 ASC_DVC_VAR *asc_dvc_varp;
3089 int leftlen;
3090 int totlen;
3091 int len;
3092 ASCEEP_CONFIG *ep;
3093 int i;
3094#ifdef CONFIG_ISA
3095 int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
3096#endif /* CONFIG_ISA */
3097 uchar serialstr[13];
27c868c2 3098
51219358
MW
3099 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
3100 ep = &boardp->eep_config.asc_eep;
27c868c2 3101
51219358
MW
3102 leftlen = cplen;
3103 totlen = len = 0;
27c868c2 3104
51219358
MW
3105 len = asc_prt_line(cp, leftlen,
3106 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3107 shost->host_no);
3108 ASC_PRT_NEXT();
1da177e4 3109
51219358
MW
3110 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
3111 == ASC_TRUE) {
3112 len =
3113 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
3114 serialstr);
3115 ASC_PRT_NEXT();
27c868c2 3116 } else {
51219358
MW
3117 if (ep->adapter_info[5] == 0xBB) {
3118 len = asc_prt_line(cp, leftlen,
3119 " Default Settings Used for EEPROM-less Adapter.\n");
3120 ASC_PRT_NEXT();
3121 } else {
3122 len = asc_prt_line(cp, leftlen,
3123 " Serial Number Signature Not Present.\n");
3124 ASC_PRT_NEXT();
27c868c2 3125 }
51219358 3126 }
27c868c2 3127
51219358
MW
3128 len = asc_prt_line(cp, leftlen,
3129 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3130 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
3131 ep->max_tag_qng);
3132 ASC_PRT_NEXT();
1da177e4 3133
51219358
MW
3134 len = asc_prt_line(cp, leftlen,
3135 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
3136 ASC_PRT_NEXT();
27c868c2 3137
51219358
MW
3138 len = asc_prt_line(cp, leftlen, " Target ID: ");
3139 ASC_PRT_NEXT();
3140 for (i = 0; i <= ASC_MAX_TID; i++) {
3141 len = asc_prt_line(cp, leftlen, " %d", i);
3142 ASC_PRT_NEXT();
3143 }
3144 len = asc_prt_line(cp, leftlen, "\n");
3145 ASC_PRT_NEXT();
1da177e4 3146
51219358
MW
3147 len = asc_prt_line(cp, leftlen, " Disconnects: ");
3148 ASC_PRT_NEXT();
3149 for (i = 0; i <= ASC_MAX_TID; i++) {
3150 len = asc_prt_line(cp, leftlen, " %c",
3151 (ep->
3152 disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3153 'N');
3154 ASC_PRT_NEXT();
27c868c2 3155 }
51219358
MW
3156 len = asc_prt_line(cp, leftlen, "\n");
3157 ASC_PRT_NEXT();
1da177e4 3158
51219358
MW
3159 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
3160 ASC_PRT_NEXT();
3161 for (i = 0; i <= ASC_MAX_TID; i++) {
3162 len = asc_prt_line(cp, leftlen, " %c",
3163 (ep->
3164 use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3165 'N');
3166 ASC_PRT_NEXT();
3167 }
3168 len = asc_prt_line(cp, leftlen, "\n");
3169 ASC_PRT_NEXT();
1da177e4 3170
51219358
MW
3171 len = asc_prt_line(cp, leftlen, " Start Motor: ");
3172 ASC_PRT_NEXT();
3173 for (i = 0; i <= ASC_MAX_TID; i++) {
3174 len = asc_prt_line(cp, leftlen, " %c",
3175 (ep->
3176 start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3177 'N');
3178 ASC_PRT_NEXT();
3179 }
3180 len = asc_prt_line(cp, leftlen, "\n");
3181 ASC_PRT_NEXT();
3182
3183 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3184 ASC_PRT_NEXT();
3185 for (i = 0; i <= ASC_MAX_TID; i++) {
3186 len = asc_prt_line(cp, leftlen, " %c",
3187 (ep->
3188 init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3189 'N');
3190 ASC_PRT_NEXT();
3191 }
3192 len = asc_prt_line(cp, leftlen, "\n");
3193 ASC_PRT_NEXT();
3194
3195#ifdef CONFIG_ISA
3196 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
3197 len = asc_prt_line(cp, leftlen,
3198 " Host ISA DMA speed: %d MB/S\n",
3199 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
3200 ASC_PRT_NEXT();
3201 }
3202#endif /* CONFIG_ISA */
3203
3204 return totlen;
1da177e4
LT
3205}
3206
3207/*
51219358 3208 * asc_prt_adv_board_eeprom()
1da177e4 3209 *
51219358 3210 * Print board EEPROM configuration.
1da177e4 3211 *
51219358
MW
3212 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3213 * cf. asc_prt_line().
3214 *
3215 * Return the number of characters copied into 'cp'. No more than
3216 * 'cplen' characters will be copied to 'cp'.
1da177e4 3217 */
51219358 3218static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
1da177e4 3219{
d2411495 3220 struct asc_board *boardp = shost_priv(shost);
51219358
MW
3221 ADV_DVC_VAR *adv_dvc_varp;
3222 int leftlen;
3223 int totlen;
3224 int len;
27c868c2 3225 int i;
51219358
MW
3226 char *termstr;
3227 uchar serialstr[13];
3228 ADVEEP_3550_CONFIG *ep_3550 = NULL;
3229 ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
3230 ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
3231 ushort word;
3232 ushort *wordp;
3233 ushort sdtr_speed = 0;
27c868c2 3234
51219358
MW
3235 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
3236 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3237 ep_3550 = &boardp->eep_config.adv_3550_eep;
3238 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3239 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
27c868c2 3240 } else {
51219358 3241 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
27c868c2 3242 }
1da177e4 3243
51219358
MW
3244 leftlen = cplen;
3245 totlen = len = 0;
27c868c2 3246
51219358
MW
3247 len = asc_prt_line(cp, leftlen,
3248 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3249 shost->host_no);
3250 ASC_PRT_NEXT();
27c868c2 3251
51219358
MW
3252 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3253 wordp = &ep_3550->serial_number_word1;
3254 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3255 wordp = &ep_38C0800->serial_number_word1;
3256 } else {
3257 wordp = &ep_38C1600->serial_number_word1;
3258 }
27c868c2 3259
51219358
MW
3260 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
3261 len =
3262 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
3263 serialstr);
3264 ASC_PRT_NEXT();
3265 } else {
3266 len = asc_prt_line(cp, leftlen,
3267 " Serial Number Signature Not Present.\n");
3268 ASC_PRT_NEXT();
3269 }
27c868c2 3270
51219358
MW
3271 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3272 len = asc_prt_line(cp, leftlen,
3273 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3274 ep_3550->adapter_scsi_id,
3275 ep_3550->max_host_qng, ep_3550->max_dvc_qng);
3276 ASC_PRT_NEXT();
3277 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3278 len = asc_prt_line(cp, leftlen,
3279 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3280 ep_38C0800->adapter_scsi_id,
3281 ep_38C0800->max_host_qng,
3282 ep_38C0800->max_dvc_qng);
3283 ASC_PRT_NEXT();
3284 } else {
3285 len = asc_prt_line(cp, leftlen,
3286 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3287 ep_38C1600->adapter_scsi_id,
3288 ep_38C1600->max_host_qng,
3289 ep_38C1600->max_dvc_qng);
3290 ASC_PRT_NEXT();
27c868c2 3291 }
51219358
MW
3292 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3293 word = ep_3550->termination;
3294 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3295 word = ep_38C0800->termination_lvd;
3296 } else {
3297 word = ep_38C1600->termination_lvd;
3298 }
3299 switch (word) {
3300 case 1:
3301 termstr = "Low Off/High Off";
3302 break;
3303 case 2:
3304 termstr = "Low Off/High On";
3305 break;
3306 case 3:
3307 termstr = "Low On/High On";
3308 break;
3309 default:
3310 case 0:
3311 termstr = "Automatic";
3312 break;
27c868c2 3313 }
1da177e4 3314
51219358
MW
3315 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3316 len = asc_prt_line(cp, leftlen,
3317 " termination: %u (%s), bios_ctrl: 0x%x\n",
3318 ep_3550->termination, termstr,
3319 ep_3550->bios_ctrl);
3320 ASC_PRT_NEXT();
3321 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3322 len = asc_prt_line(cp, leftlen,
3323 " termination: %u (%s), bios_ctrl: 0x%x\n",
3324 ep_38C0800->termination_lvd, termstr,
3325 ep_38C0800->bios_ctrl);
3326 ASC_PRT_NEXT();
3327 } else {
3328 len = asc_prt_line(cp, leftlen,
3329 " termination: %u (%s), bios_ctrl: 0x%x\n",
3330 ep_38C1600->termination_lvd, termstr,
3331 ep_38C1600->bios_ctrl);
3332 ASC_PRT_NEXT();
3333 }
1da177e4 3334
51219358
MW
3335 len = asc_prt_line(cp, leftlen, " Target ID: ");
3336 ASC_PRT_NEXT();
3337 for (i = 0; i <= ADV_MAX_TID; i++) {
3338 len = asc_prt_line(cp, leftlen, " %X", i);
3339 ASC_PRT_NEXT();
3340 }
3341 len = asc_prt_line(cp, leftlen, "\n");
3342 ASC_PRT_NEXT();
1da177e4 3343
51219358
MW
3344 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3345 word = ep_3550->disc_enable;
3346 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3347 word = ep_38C0800->disc_enable;
3348 } else {
3349 word = ep_38C1600->disc_enable;
3350 }
3351 len = asc_prt_line(cp, leftlen, " Disconnects: ");
3352 ASC_PRT_NEXT();
3353 for (i = 0; i <= ADV_MAX_TID; i++) {
3354 len = asc_prt_line(cp, leftlen, " %c",
3355 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3356 ASC_PRT_NEXT();
3357 }
3358 len = asc_prt_line(cp, leftlen, "\n");
3359 ASC_PRT_NEXT();
1da177e4 3360
51219358
MW
3361 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3362 word = ep_3550->tagqng_able;
3363 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3364 word = ep_38C0800->tagqng_able;
3365 } else {
3366 word = ep_38C1600->tagqng_able;
3367 }
3368 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
3369 ASC_PRT_NEXT();
3370 for (i = 0; i <= ADV_MAX_TID; i++) {
3371 len = asc_prt_line(cp, leftlen, " %c",
3372 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3373 ASC_PRT_NEXT();
3374 }
3375 len = asc_prt_line(cp, leftlen, "\n");
3376 ASC_PRT_NEXT();
1da177e4 3377
51219358
MW
3378 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3379 word = ep_3550->start_motor;
3380 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3381 word = ep_38C0800->start_motor;
27c868c2 3382 } else {
51219358
MW
3383 word = ep_38C1600->start_motor;
3384 }
3385 len = asc_prt_line(cp, leftlen, " Start Motor: ");
3386 ASC_PRT_NEXT();
3387 for (i = 0; i <= ADV_MAX_TID; i++) {
3388 len = asc_prt_line(cp, leftlen, " %c",
3389 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3390 ASC_PRT_NEXT();
3391 }
3392 len = asc_prt_line(cp, leftlen, "\n");
3393 ASC_PRT_NEXT();
27c868c2 3394
51219358
MW
3395 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3396 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3397 ASC_PRT_NEXT();
3398 for (i = 0; i <= ADV_MAX_TID; i++) {
3399 len = asc_prt_line(cp, leftlen, " %c",
3400 (ep_3550->
3401 sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
3402 'Y' : 'N');
3403 ASC_PRT_NEXT();
27c868c2 3404 }
51219358
MW
3405 len = asc_prt_line(cp, leftlen, "\n");
3406 ASC_PRT_NEXT();
3407 }
27c868c2 3408
51219358
MW
3409 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3410 len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
3411 ASC_PRT_NEXT();
3412 for (i = 0; i <= ADV_MAX_TID; i++) {
3413 len = asc_prt_line(cp, leftlen, " %c",
3414 (ep_3550->
3415 ultra_able & ADV_TID_TO_TIDMASK(i))
3416 ? 'Y' : 'N');
3417 ASC_PRT_NEXT();
27c868c2 3418 }
51219358
MW
3419 len = asc_prt_line(cp, leftlen, "\n");
3420 ASC_PRT_NEXT();
3421 }
27c868c2 3422
51219358
MW
3423 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3424 word = ep_3550->wdtr_able;
3425 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3426 word = ep_38C0800->wdtr_able;
3427 } else {
3428 word = ep_38C1600->wdtr_able;
3429 }
3430 len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
3431 ASC_PRT_NEXT();
3432 for (i = 0; i <= ADV_MAX_TID; i++) {
3433 len = asc_prt_line(cp, leftlen, " %c",
3434 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3435 ASC_PRT_NEXT();
27c868c2 3436 }
51219358
MW
3437 len = asc_prt_line(cp, leftlen, "\n");
3438 ASC_PRT_NEXT();
1da177e4 3439
51219358
MW
3440 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
3441 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
3442 len = asc_prt_line(cp, leftlen,
3443 " Synchronous Transfer Speed (Mhz):\n ");
3444 ASC_PRT_NEXT();
3445 for (i = 0; i <= ADV_MAX_TID; i++) {
3446 char *speed_str;
1da177e4 3447
51219358
MW
3448 if (i == 0) {
3449 sdtr_speed = adv_dvc_varp->sdtr_speed1;
3450 } else if (i == 4) {
3451 sdtr_speed = adv_dvc_varp->sdtr_speed2;
3452 } else if (i == 8) {
3453 sdtr_speed = adv_dvc_varp->sdtr_speed3;
3454 } else if (i == 12) {
3455 sdtr_speed = adv_dvc_varp->sdtr_speed4;
3456 }
3457 switch (sdtr_speed & ADV_MAX_TID) {
3458 case 0:
3459 speed_str = "Off";
3460 break;
3461 case 1:
3462 speed_str = " 5";
3463 break;
3464 case 2:
3465 speed_str = " 10";
3466 break;
3467 case 3:
3468 speed_str = " 20";
3469 break;
3470 case 4:
3471 speed_str = " 40";
3472 break;
3473 case 5:
3474 speed_str = " 80";
3475 break;
3476 default:
3477 speed_str = "Unk";
3478 break;
3479 }
3480 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
3481 ASC_PRT_NEXT();
3482 if (i == 7) {
3483 len = asc_prt_line(cp, leftlen, "\n ");
3484 ASC_PRT_NEXT();
3485 }
3486 sdtr_speed >>= 4;
3487 }
3488 len = asc_prt_line(cp, leftlen, "\n");
3489 ASC_PRT_NEXT();
3490 }
1da177e4 3491
51219358 3492 return totlen;
1da177e4
LT
3493}
3494
3495/*
51219358 3496 * asc_prt_driver_conf()
1da177e4 3497 *
51219358
MW
3498 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3499 * cf. asc_prt_line().
1da177e4 3500 *
51219358
MW
3501 * Return the number of characters copied into 'cp'. No more than
3502 * 'cplen' characters will be copied to 'cp'.
1da177e4 3503 */
51219358 3504static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
1da177e4 3505{
d2411495 3506 struct asc_board *boardp = shost_priv(shost);
51219358
MW
3507 int leftlen;
3508 int totlen;
3509 int len;
3510 int chip_scsi_id;
27c868c2 3511
51219358
MW
3512 leftlen = cplen;
3513 totlen = len = 0;
27c868c2 3514
51219358
MW
3515 len = asc_prt_line(cp, leftlen,
3516 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
3517 shost->host_no);
3518 ASC_PRT_NEXT();
95c9f162 3519
51219358
MW
3520 len = asc_prt_line(cp, leftlen,
3521 " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
3522 shost->host_busy, shost->last_reset, shost->max_id,
3523 shost->max_lun, shost->max_channel);
3524 ASC_PRT_NEXT();
95c9f162 3525
51219358
MW
3526 len = asc_prt_line(cp, leftlen,
3527 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
3528 shost->unique_id, shost->can_queue, shost->this_id,
3529 shost->sg_tablesize, shost->cmd_per_lun);
3530 ASC_PRT_NEXT();
95c9f162 3531
51219358
MW
3532 len = asc_prt_line(cp, leftlen,
3533 " unchecked_isa_dma %d, use_clustering %d\n",
3534 shost->unchecked_isa_dma, shost->use_clustering);
3535 ASC_PRT_NEXT();
27c868c2 3536
51219358
MW
3537 len = asc_prt_line(cp, leftlen,
3538 " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
3539 boardp->flags, boardp->last_reset, jiffies,
3540 boardp->asc_n_io_port);
3541 ASC_PRT_NEXT();
27c868c2 3542
51219358
MW
3543 len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
3544 ASC_PRT_NEXT();
27c868c2 3545
51219358
MW
3546 if (ASC_NARROW_BOARD(boardp)) {
3547 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
3548 } else {
3549 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
27c868c2 3550 }
51219358
MW
3551
3552 return totlen;
1da177e4
LT
3553}
3554
3555/*
51219358 3556 * asc_prt_asc_board_info()
1da177e4 3557 *
51219358
MW
3558 * Print dynamic board configuration information.
3559 *
3560 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3561 * cf. asc_prt_line().
3562 *
3563 * Return the number of characters copied into 'cp'. No more than
3564 * 'cplen' characters will be copied to 'cp'.
1da177e4 3565 */
51219358 3566static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
1da177e4 3567{
d2411495 3568 struct asc_board *boardp = shost_priv(shost);
51219358
MW
3569 int chip_scsi_id;
3570 int leftlen;
3571 int totlen;
3572 int len;
3573 ASC_DVC_VAR *v;
3574 ASC_DVC_CFG *c;
3575 int i;
3576 int renegotiate = 0;
27c868c2 3577
51219358
MW
3578 v = &boardp->dvc_var.asc_dvc_var;
3579 c = &boardp->dvc_cfg.asc_dvc_cfg;
3580 chip_scsi_id = c->chip_scsi_id;
27c868c2 3581
51219358
MW
3582 leftlen = cplen;
3583 totlen = len = 0;
27c868c2 3584
51219358
MW
3585 len = asc_prt_line(cp, leftlen,
3586 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3587 shost->host_no);
3588 ASC_PRT_NEXT();
27c868c2 3589
b08fc565
MW
3590 len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
3591 "mcode_version 0x%x, err_code %u\n",
3592 c->chip_version, c->mcode_date, c->mcode_version,
3593 v->err_code);
51219358 3594 ASC_PRT_NEXT();
1da177e4 3595
51219358
MW
3596 /* Current number of commands waiting for the host. */
3597 len = asc_prt_line(cp, leftlen,
3598 " Total Command Pending: %d\n", v->cur_total_qng);
3599 ASC_PRT_NEXT();
1da177e4 3600
51219358
MW
3601 len = asc_prt_line(cp, leftlen, " Command Queuing:");
3602 ASC_PRT_NEXT();
3603 for (i = 0; i <= ASC_MAX_TID; i++) {
3604 if ((chip_scsi_id == i) ||
3605 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3606 continue;
27c868c2 3607 }
51219358
MW
3608 len = asc_prt_line(cp, leftlen, " %X:%c",
3609 i,
3610 (v->
3611 use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
3612 'Y' : 'N');
3613 ASC_PRT_NEXT();
3614 }
3615 len = asc_prt_line(cp, leftlen, "\n");
3616 ASC_PRT_NEXT();
27c868c2 3617
51219358
MW
3618 /* Current number of commands waiting for a device. */
3619 len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
3620 ASC_PRT_NEXT();
3621 for (i = 0; i <= ASC_MAX_TID; i++) {
3622 if ((chip_scsi_id == i) ||
3623 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3624 continue;
27c868c2 3625 }
51219358
MW
3626 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
3627 ASC_PRT_NEXT();
27c868c2 3628 }
51219358
MW
3629 len = asc_prt_line(cp, leftlen, "\n");
3630 ASC_PRT_NEXT();
1da177e4 3631
51219358
MW
3632 /* Current limit on number of commands that can be sent to a device. */
3633 len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
3634 ASC_PRT_NEXT();
3635 for (i = 0; i <= ASC_MAX_TID; i++) {
3636 if ((chip_scsi_id == i) ||
3637 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3638 continue;
3639 }
3640 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
3641 ASC_PRT_NEXT();
27c868c2 3642 }
51219358
MW
3643 len = asc_prt_line(cp, leftlen, "\n");
3644 ASC_PRT_NEXT();
1da177e4 3645
51219358
MW
3646 /* Indicate whether the device has returned queue full status. */
3647 len = asc_prt_line(cp, leftlen, " Command Queue Full:");
3648 ASC_PRT_NEXT();
3649 for (i = 0; i <= ASC_MAX_TID; i++) {
3650 if ((chip_scsi_id == i) ||
3651 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3652 continue;
3653 }
3654 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
3655 len = asc_prt_line(cp, leftlen, " %X:Y-%d",
3656 i, boardp->queue_full_cnt[i]);
3657 } else {
3658 len = asc_prt_line(cp, leftlen, " %X:N", i);
3659 }
3660 ASC_PRT_NEXT();
3661 }
3662 len = asc_prt_line(cp, leftlen, "\n");
3663 ASC_PRT_NEXT();
1da177e4 3664
51219358
MW
3665 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3666 ASC_PRT_NEXT();
3667 for (i = 0; i <= ASC_MAX_TID; i++) {
3668 if ((chip_scsi_id == i) ||
3669 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3670 continue;
3671 }
3672 len = asc_prt_line(cp, leftlen, " %X:%c",
3673 i,
3674 (v->
3675 sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3676 'N');
3677 ASC_PRT_NEXT();
27c868c2 3678 }
51219358
MW
3679 len = asc_prt_line(cp, leftlen, "\n");
3680 ASC_PRT_NEXT();
1da177e4 3681
51219358
MW
3682 for (i = 0; i <= ASC_MAX_TID; i++) {
3683 uchar syn_period_ix;
1da177e4 3684
51219358
MW
3685 if ((chip_scsi_id == i) ||
3686 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
3687 ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
3688 continue;
27c868c2 3689 }
27c868c2 3690
51219358
MW
3691 len = asc_prt_line(cp, leftlen, " %X:", i);
3692 ASC_PRT_NEXT();
27c868c2 3693
51219358
MW
3694 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
3695 len = asc_prt_line(cp, leftlen, " Asynchronous");
3696 ASC_PRT_NEXT();
3697 } else {
3698 syn_period_ix =
3699 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
3700 1);
27c868c2 3701
51219358
MW
3702 len = asc_prt_line(cp, leftlen,
3703 " Transfer Period Factor: %d (%d.%d Mhz),",
3704 v->sdtr_period_tbl[syn_period_ix],
3705 250 /
3706 v->sdtr_period_tbl[syn_period_ix],
3707 ASC_TENTHS(250,
3708 v->
3709 sdtr_period_tbl
3710 [syn_period_ix]));
3711 ASC_PRT_NEXT();
27c868c2 3712
51219358
MW
3713 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
3714 boardp->
3715 sdtr_data[i] & ASC_SYN_MAX_OFFSET);
3716 ASC_PRT_NEXT();
3717 }
1da177e4 3718
51219358
MW
3719 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3720 len = asc_prt_line(cp, leftlen, "*\n");
3721 renegotiate = 1;
3722 } else {
3723 len = asc_prt_line(cp, leftlen, "\n");
3724 }
3725 ASC_PRT_NEXT();
27c868c2 3726 }
1da177e4 3727
51219358
MW
3728 if (renegotiate) {
3729 len = asc_prt_line(cp, leftlen,
3730 " * = Re-negotiation pending before next command.\n");
3731 ASC_PRT_NEXT();
27c868c2 3732 }
1da177e4 3733
51219358 3734 return totlen;
1da177e4
LT
3735}
3736
1da177e4 3737/*
51219358 3738 * asc_prt_adv_board_info()
1da177e4 3739 *
51219358 3740 * Print dynamic board configuration information.
1da177e4
LT
3741 *
3742 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3743 * cf. asc_prt_line().
3744 *
3745 * Return the number of characters copied into 'cp'. No more than
3746 * 'cplen' characters will be copied to 'cp'.
3747 */
51219358 3748static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
1da177e4 3749{
d2411495 3750 struct asc_board *boardp = shost_priv(shost);
27c868c2
MW
3751 int leftlen;
3752 int totlen;
3753 int len;
27c868c2 3754 int i;
51219358
MW
3755 ADV_DVC_VAR *v;
3756 ADV_DVC_CFG *c;
3757 AdvPortAddr iop_base;
3758 ushort chip_scsi_id;
3759 ushort lramword;
3760 uchar lrambyte;
3761 ushort tagqng_able;
3762 ushort sdtr_able, wdtr_able;
3763 ushort wdtr_done, sdtr_done;
3764 ushort period = 0;
3765 int renegotiate = 0;
27c868c2 3766
51219358
MW
3767 v = &boardp->dvc_var.adv_dvc_var;
3768 c = &boardp->dvc_cfg.adv_dvc_cfg;
3769 iop_base = v->iop_base;
3770 chip_scsi_id = v->chip_scsi_id;
3771
27c868c2
MW
3772 leftlen = cplen;
3773 totlen = len = 0;
3774
3775 len = asc_prt_line(cp, leftlen,
51219358 3776 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
27c868c2
MW
3777 shost->host_no);
3778 ASC_PRT_NEXT();
3779
51219358
MW
3780 len = asc_prt_line(cp, leftlen,
3781 " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
3782 v->iop_base,
3783 AdvReadWordRegister(iop_base,
3784 IOPW_SCSI_CFG1) & CABLE_DETECT,
3785 v->err_code);
3786 ASC_PRT_NEXT();
1da177e4 3787
b08fc565
MW
3788 len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
3789 "mcode_version 0x%x\n", c->chip_version,
3790 c->mcode_date, c->mcode_version);
51219358
MW
3791 ASC_PRT_NEXT();
3792
3793 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
3794 len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
27c868c2
MW
3795 ASC_PRT_NEXT();
3796 for (i = 0; i <= ADV_MAX_TID; i++) {
51219358
MW
3797 if ((chip_scsi_id == i) ||
3798 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3799 continue;
27c868c2 3800 }
51219358
MW
3801
3802 len = asc_prt_line(cp, leftlen, " %X:%c",
3803 i,
3804 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3805 'N');
3806 ASC_PRT_NEXT();
27c868c2 3807 }
51219358 3808 len = asc_prt_line(cp, leftlen, "\n");
27c868c2 3809 ASC_PRT_NEXT();
1da177e4 3810
51219358
MW
3811 len = asc_prt_line(cp, leftlen, " Queue Limit:");
3812 ASC_PRT_NEXT();
3813 for (i = 0; i <= ADV_MAX_TID; i++) {
3814 if ((chip_scsi_id == i) ||
3815 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3816 continue;
3817 }
1da177e4 3818
51219358
MW
3819 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
3820 lrambyte);
27c868c2 3821
51219358
MW
3822 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
3823 ASC_PRT_NEXT();
3824 }
3825 len = asc_prt_line(cp, leftlen, "\n");
3826 ASC_PRT_NEXT();
27c868c2 3827
51219358 3828 len = asc_prt_line(cp, leftlen, " Command Pending:");
27c868c2 3829 ASC_PRT_NEXT();
51219358
MW
3830 for (i = 0; i <= ADV_MAX_TID; i++) {
3831 if ((chip_scsi_id == i) ||
3832 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3833 continue;
3834 }
27c868c2 3835
51219358
MW
3836 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
3837 lrambyte);
1da177e4 3838
51219358 3839 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
27c868c2 3840 ASC_PRT_NEXT();
51219358
MW
3841 }
3842 len = asc_prt_line(cp, leftlen, "\n");
3843 ASC_PRT_NEXT();
1da177e4 3844
51219358
MW
3845 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
3846 len = asc_prt_line(cp, leftlen, " Wide Enabled:");
3847 ASC_PRT_NEXT();
3848 for (i = 0; i <= ADV_MAX_TID; i++) {
3849 if ((chip_scsi_id == i) ||
3850 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3851 continue;
27c868c2 3852 }
51219358
MW
3853
3854 len = asc_prt_line(cp, leftlen, " %X:%c",
3855 i,
3856 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3857 'N');
3858 ASC_PRT_NEXT();
27c868c2 3859 }
51219358
MW
3860 len = asc_prt_line(cp, leftlen, "\n");
3861 ASC_PRT_NEXT();
1da177e4 3862
51219358
MW
3863 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
3864 len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
3865 ASC_PRT_NEXT();
3866 for (i = 0; i <= ADV_MAX_TID; i++) {
3867 if ((chip_scsi_id == i) ||
3868 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3869 continue;
3870 }
1da177e4 3871
51219358
MW
3872 AdvReadWordLram(iop_base,
3873 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
3874 lramword);
27c868c2 3875
51219358
MW
3876 len = asc_prt_line(cp, leftlen, " %X:%d",
3877 i, (lramword & 0x8000) ? 16 : 8);
3878 ASC_PRT_NEXT();
27c868c2 3879
51219358
MW
3880 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
3881 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3882 len = asc_prt_line(cp, leftlen, "*");
3883 ASC_PRT_NEXT();
3884 renegotiate = 1;
27c868c2 3885 }
51219358
MW
3886 }
3887 len = asc_prt_line(cp, leftlen, "\n");
3888 ASC_PRT_NEXT();
27c868c2 3889
51219358
MW
3890 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
3891 len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
3892 ASC_PRT_NEXT();
3893 for (i = 0; i <= ADV_MAX_TID; i++) {
3894 if ((chip_scsi_id == i) ||
3895 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3896 continue;
3897 }
27c868c2 3898
51219358
MW
3899 len = asc_prt_line(cp, leftlen, " %X:%c",
3900 i,
3901 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3902 'N');
3903 ASC_PRT_NEXT();
3904 }
3905 len = asc_prt_line(cp, leftlen, "\n");
3906 ASC_PRT_NEXT();
27c868c2 3907
51219358
MW
3908 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
3909 for (i = 0; i <= ADV_MAX_TID; i++) {
27c868c2 3910
51219358
MW
3911 AdvReadWordLram(iop_base,
3912 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
3913 lramword);
3914 lramword &= ~0x8000;
27c868c2 3915
51219358
MW
3916 if ((chip_scsi_id == i) ||
3917 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
3918 ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
3919 continue;
27c868c2
MW
3920 }
3921
51219358
MW
3922 len = asc_prt_line(cp, leftlen, " %X:", i);
3923 ASC_PRT_NEXT();
27c868c2 3924
51219358
MW
3925 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
3926 len = asc_prt_line(cp, leftlen, " Asynchronous");
3927 ASC_PRT_NEXT();
3928 } else {
3929 len =
3930 asc_prt_line(cp, leftlen,
3931 " Transfer Period Factor: ");
3932 ASC_PRT_NEXT();
27c868c2 3933
51219358
MW
3934 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
3935 len =
3936 asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
3937 ASC_PRT_NEXT();
3938 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
3939 len =
3940 asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
3941 ASC_PRT_NEXT();
3942 } else { /* 20 Mhz or below. */
27c868c2 3943
51219358
MW
3944 period = (((lramword >> 8) * 25) + 50) / 4;
3945
3946 if (period == 0) { /* Should never happen. */
3947 len =
3948 asc_prt_line(cp, leftlen,
3949 "%d (? Mhz), ");
3950 ASC_PRT_NEXT();
3951 } else {
3952 len = asc_prt_line(cp, leftlen,
3953 "%d (%d.%d Mhz),",
3954 period, 250 / period,
3955 ASC_TENTHS(250,
3956 period));
3957 ASC_PRT_NEXT();
3958 }
3959 }
3960
3961 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
3962 lramword & 0x1F);
3963 ASC_PRT_NEXT();
3964 }
3965
3966 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3967 len = asc_prt_line(cp, leftlen, "*\n");
3968 renegotiate = 1;
3969 } else {
3970 len = asc_prt_line(cp, leftlen, "\n");
3971 }
3972 ASC_PRT_NEXT();
27c868c2 3973 }
51219358
MW
3974
3975 if (renegotiate) {
3976 len = asc_prt_line(cp, leftlen,
3977 " * = Re-negotiation pending before next command.\n");
3978 ASC_PRT_NEXT();
3979 }
3980
3981 return totlen;
1da177e4
LT
3982}
3983
3984/*
51219358 3985 * asc_proc_copy()
1da177e4 3986 *
51219358
MW
3987 * Copy proc information to a read buffer taking into account the current
3988 * read offset in the file and the remaining space in the read buffer.
3989 */
3990static int
3991asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
3992 char *cp, int cplen)
3993{
3994 int cnt = 0;
3995
b352f923 3996 ASC_DBG(2, "offset %d, advoffset %d, cplen %d\n",
51219358
MW
3997 (unsigned)offset, (unsigned)advoffset, cplen);
3998 if (offset <= advoffset) {
3999 /* Read offset below current offset, copy everything. */
4000 cnt = min(cplen, leftlen);
b352f923 4001 ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
51219358
MW
4002 (ulong)curbuf, (ulong)cp, cnt);
4003 memcpy(curbuf, cp, cnt);
4004 } else if (offset < advoffset + cplen) {
4005 /* Read offset within current range, partial copy. */
4006 cnt = (advoffset + cplen) - offset;
4007 cp = (cp + cplen) - cnt;
4008 cnt = min(cnt, leftlen);
b352f923 4009 ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
51219358
MW
4010 (ulong)curbuf, (ulong)cp, cnt);
4011 memcpy(curbuf, cp, cnt);
4012 }
4013 return cnt;
4014}
4015
4016#ifdef ADVANSYS_STATS
4017/*
4018 * asc_prt_board_stats()
1da177e4
LT
4019 *
4020 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
4021 * cf. asc_prt_line().
4022 *
4023 * Return the number of characters copied into 'cp'. No more than
4024 * 'cplen' characters will be copied to 'cp'.
4025 */
51219358 4026static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
1da177e4 4027{
d2411495
MW
4028 struct asc_board *boardp = shost_priv(shost);
4029 struct asc_stats *s = &boardp->asc_stats;
27c868c2 4030
d2411495
MW
4031 int leftlen = cplen;
4032 int len, totlen = 0;
51219358 4033
27c868c2 4034 len = asc_prt_line(cp, leftlen,
51219358 4035 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
27c868c2
MW
4036 shost->host_no);
4037 ASC_PRT_NEXT();
4038
27c868c2 4039 len = asc_prt_line(cp, leftlen,
51219358
MW
4040 " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
4041 s->queuecommand, s->reset, s->biosparam,
4042 s->interrupt);
27c868c2
MW
4043 ASC_PRT_NEXT();
4044
4045 len = asc_prt_line(cp, leftlen,
51219358
MW
4046 " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
4047 s->callback, s->done, s->build_error,
4048 s->adv_build_noreq, s->adv_build_nosg);
27c868c2
MW
4049 ASC_PRT_NEXT();
4050
51219358
MW
4051 len = asc_prt_line(cp, leftlen,
4052 " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
4053 s->exe_noerror, s->exe_busy, s->exe_error,
4054 s->exe_unknown);
27c868c2 4055 ASC_PRT_NEXT();
51219358
MW
4056
4057 /*
4058 * Display data transfer statistics.
4059 */
4060 if (s->cont_cnt > 0) {
4061 len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
27c868c2 4062 ASC_PRT_NEXT();
27c868c2 4063
51219358
MW
4064 len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
4065 s->cont_xfer / 2,
4066 ASC_TENTHS(s->cont_xfer, 2));
27c868c2 4067 ASC_PRT_NEXT();
27c868c2 4068
51219358
MW
4069 /* Contiguous transfer average size */
4070 len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
4071 (s->cont_xfer / 2) / s->cont_cnt,
4072 ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
27c868c2
MW
4073 ASC_PRT_NEXT();
4074 }
27c868c2 4075
51219358
MW
4076 if (s->sg_cnt > 0) {
4077
4078 len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
4079 s->sg_cnt, s->sg_elem);
27c868c2 4080 ASC_PRT_NEXT();
27c868c2 4081
51219358
MW
4082 len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
4083 s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
27c868c2 4084 ASC_PRT_NEXT();
1da177e4 4085
51219358
MW
4086 /* Scatter gather transfer statistics */
4087 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
4088 s->sg_elem / s->sg_cnt,
4089 ASC_TENTHS(s->sg_elem, s->sg_cnt));
4090 ASC_PRT_NEXT();
4091
4092 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
4093 (s->sg_xfer / 2) / s->sg_elem,
4094 ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
4095 ASC_PRT_NEXT();
4096
4097 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
4098 (s->sg_xfer / 2) / s->sg_cnt,
4099 ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
27c868c2
MW
4100 ASC_PRT_NEXT();
4101 }
51219358
MW
4102
4103 /*
4104 * Display request queuing statistics.
4105 */
4106 len = asc_prt_line(cp, leftlen,
4107 " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
4108 HZ);
4109 ASC_PRT_NEXT();
1da177e4 4110
27c868c2 4111 return totlen;
1da177e4 4112}
51219358 4113#endif /* ADVANSYS_STATS */
1da177e4
LT
4114
4115/*
51219358 4116 * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
1da177e4 4117 *
51219358
MW
4118 * *buffer: I/O buffer
4119 * **start: if inout == FALSE pointer into buffer where user read should start
4120 * offset: current offset into a /proc/scsi/advansys/[0...] file
4121 * length: length of buffer
4122 * hostno: Scsi_Host host_no
4123 * inout: TRUE - user is writing; FALSE - user is reading
1da177e4 4124 *
51219358
MW
4125 * Return the number of bytes read from or written to a
4126 * /proc/scsi/advansys/[0...] file.
1da177e4 4127 *
51219358
MW
4128 * Note: This function uses the per board buffer 'prtbuf' which is
4129 * allocated when the board is initialized in advansys_detect(). The
4130 * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
4131 * used to write to the buffer. The way asc_proc_copy() is written
4132 * if 'prtbuf' is too small it will not be overwritten. Instead the
4133 * user just won't get all the available statistics.
1da177e4 4134 */
51219358
MW
4135static int
4136advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
4137 off_t offset, int length, int inout)
1da177e4 4138{
d2411495 4139 struct asc_board *boardp = shost_priv(shost);
51219358
MW
4140 char *cp;
4141 int cplen;
4142 int cnt;
4143 int totcnt;
27c868c2 4144 int leftlen;
51219358
MW
4145 char *curbuf;
4146 off_t advoffset;
27c868c2 4147
b352f923 4148 ASC_DBG(1, "begin\n");
51219358
MW
4149
4150 /*
4151 * User write not supported.
4152 */
d2411495
MW
4153 if (inout == TRUE)
4154 return -ENOSYS;
1da177e4 4155
51219358
MW
4156 /*
4157 * User read of /proc/scsi/advansys/[0...] file.
4158 */
1da177e4 4159
51219358
MW
4160 /* Copy read data starting at the beginning of the buffer. */
4161 *start = buffer;
4162 curbuf = buffer;
4163 advoffset = 0;
4164 totcnt = 0;
4165 leftlen = length;
4166
4167 /*
4168 * Get board configuration information.
4169 *
4170 * advansys_info() returns the board string from its own static buffer.
4171 */
4172 cp = (char *)advansys_info(shost);
4173 strcat(cp, "\n");
4174 cplen = strlen(cp);
4175 /* Copy board information. */
4176 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4177 totcnt += cnt;
4178 leftlen -= cnt;
4179 if (leftlen == 0) {
b352f923 4180 ASC_DBG(1, "totcnt %d\n", totcnt);
51219358 4181 return totcnt;
27c868c2 4182 }
51219358
MW
4183 advoffset += cplen;
4184 curbuf += cnt;
1da177e4 4185
51219358
MW
4186 /*
4187 * Display Wide Board BIOS Information.
4188 */
9a256fa5 4189 if (!ASC_NARROW_BOARD(boardp)) {
51219358
MW
4190 cp = boardp->prtbuf;
4191 cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
4192 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4193 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4194 cplen);
4195 totcnt += cnt;
4196 leftlen -= cnt;
4197 if (leftlen == 0) {
b352f923 4198 ASC_DBG(1, "totcnt %d\n", totcnt);
51219358
MW
4199 return totcnt;
4200 }
4201 advoffset += cplen;
4202 curbuf += cnt;
27c868c2 4203 }
1da177e4 4204
51219358
MW
4205 /*
4206 * Display driver information for each device attached to the board.
4207 */
4208 cp = boardp->prtbuf;
4209 cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
4210 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4211 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4212 totcnt += cnt;
4213 leftlen -= cnt;
4214 if (leftlen == 0) {
b352f923 4215 ASC_DBG(1, "totcnt %d\n", totcnt);
51219358 4216 return totcnt;
27c868c2 4217 }
51219358
MW
4218 advoffset += cplen;
4219 curbuf += cnt;
4220
4221 /*
4222 * Display EEPROM configuration for the board.
4223 */
4224 cp = boardp->prtbuf;
4225 if (ASC_NARROW_BOARD(boardp)) {
4226 cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
27c868c2 4227 } else {
51219358 4228 cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
27c868c2 4229 }
51219358
MW
4230 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4231 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4232 totcnt += cnt;
4233 leftlen -= cnt;
4234 if (leftlen == 0) {
b352f923 4235 ASC_DBG(1, "totcnt %d\n", totcnt);
51219358 4236 return totcnt;
27c868c2 4237 }
51219358
MW
4238 advoffset += cplen;
4239 curbuf += cnt;
1da177e4 4240
51219358
MW
4241 /*
4242 * Display driver configuration and information for the board.
4243 */
4244 cp = boardp->prtbuf;
4245 cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
4246 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4247 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4248 totcnt += cnt;
4249 leftlen -= cnt;
4250 if (leftlen == 0) {
b352f923 4251 ASC_DBG(1, "totcnt %d\n", totcnt);
51219358 4252 return totcnt;
27c868c2 4253 }
51219358
MW
4254 advoffset += cplen;
4255 curbuf += cnt;
1da177e4 4256
51219358
MW
4257#ifdef ADVANSYS_STATS
4258 /*
4259 * Display driver statistics for the board.
4260 */
4261 cp = boardp->prtbuf;
4262 cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
4263 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4264 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4265 totcnt += cnt;
4266 leftlen -= cnt;
4267 if (leftlen == 0) {
b352f923 4268 ASC_DBG(1, "totcnt %d\n", totcnt);
51219358 4269 return totcnt;
27c868c2 4270 }
51219358
MW
4271 advoffset += cplen;
4272 curbuf += cnt;
4273#endif /* ADVANSYS_STATS */
1da177e4 4274
51219358
MW
4275 /*
4276 * Display Asc Library dynamic configuration information
4277 * for the board.
4278 */
4279 cp = boardp->prtbuf;
4280 if (ASC_NARROW_BOARD(boardp)) {
4281 cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
27c868c2 4282 } else {
51219358 4283 cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
27c868c2 4284 }
51219358
MW
4285 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4286 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4287 totcnt += cnt;
4288 leftlen -= cnt;
4289 if (leftlen == 0) {
b352f923 4290 ASC_DBG(1, "totcnt %d\n", totcnt);
51219358 4291 return totcnt;
27c868c2 4292 }
51219358
MW
4293 advoffset += cplen;
4294 curbuf += cnt;
1da177e4 4295
b352f923 4296 ASC_DBG(1, "totcnt %d\n", totcnt);
27c868c2 4297
51219358
MW
4298 return totcnt;
4299}
4300#endif /* CONFIG_PROC_FS */
4301
4302static void asc_scsi_done(struct scsi_cmnd *scp)
4303{
d2411495 4304 struct asc_board *boardp = shost_priv(scp->device->host);
51219358
MW
4305
4306 if (scp->use_sg)
4307 dma_unmap_sg(boardp->dev,
4308 (struct scatterlist *)scp->request_buffer,
4309 scp->use_sg, scp->sc_data_direction);
4310 else if (scp->request_bufflen)
4311 dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
4312 scp->request_bufflen, scp->sc_data_direction);
4313
4314 ASC_STATS(scp->device->host, done);
4315
4316 scp->scsi_done(scp);
4317}
4318
4319static void AscSetBank(PortAddr iop_base, uchar bank)
4320{
4321 uchar val;
4322
4323 val = AscGetChipControl(iop_base) &
4324 (~
4325 (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
4326 CC_CHIP_RESET));
4327 if (bank == 1) {
4328 val |= CC_BANK_ONE;
4329 } else if (bank == 2) {
4330 val |= CC_DIAG | CC_BANK_ONE;
27c868c2 4331 } else {
51219358 4332 val &= ~CC_BANK_ONE;
27c868c2 4333 }
51219358 4334 AscSetChipControl(iop_base, val);
51219358
MW
4335}
4336
4337static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
4338{
4339 AscSetBank(iop_base, 1);
4340 AscWriteChipIH(iop_base, ins_code);
4341 AscSetBank(iop_base, 0);
51219358
MW
4342}
4343
4344static int AscStartChip(PortAddr iop_base)
4345{
4346 AscSetChipControl(iop_base, 0);
4347 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
4348 return (0);
27c868c2 4349 }
51219358
MW
4350 return (1);
4351}
27c868c2 4352
51219358
MW
4353static int AscStopChip(PortAddr iop_base)
4354{
4355 uchar cc_val;
4356
4357 cc_val =
4358 AscGetChipControl(iop_base) &
4359 (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
4360 AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
4361 AscSetChipIH(iop_base, INS_HALT);
4362 AscSetChipIH(iop_base, INS_RFLAG_WTM);
4363 if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
4364 return (0);
27c868c2 4365 }
51219358
MW
4366 return (1);
4367}
27c868c2 4368
51219358
MW
4369static int AscIsChipHalted(PortAddr iop_base)
4370{
4371 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
4372 if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
4373 return (1);
27c868c2 4374 }
27c868c2 4375 }
51219358
MW
4376 return (0);
4377}
27c868c2 4378
51219358
MW
4379static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
4380{
4381 PortAddr iop_base;
4382 int i = 10;
4383
4384 iop_base = asc_dvc->iop_base;
4385 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
4386 && (i-- > 0)) {
4387 mdelay(100);
27c868c2 4388 }
51219358
MW
4389 AscStopChip(iop_base);
4390 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
4391 udelay(60);
4392 AscSetChipIH(iop_base, INS_RFLAG_WTM);
4393 AscSetChipIH(iop_base, INS_HALT);
4394 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
4395 AscSetChipControl(iop_base, CC_HALT);
4396 mdelay(200);
4397 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
4398 AscSetChipStatus(iop_base, 0);
4399 return (AscIsChipHalted(iop_base));
4400}
27c868c2 4401
51219358
MW
4402static int AscFindSignature(PortAddr iop_base)
4403{
4404 ushort sig_word;
27c868c2 4405
b352f923 4406 ASC_DBG(1, "AscGetChipSignatureByte(0x%x) 0x%x\n",
51219358
MW
4407 iop_base, AscGetChipSignatureByte(iop_base));
4408 if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
b352f923 4409 ASC_DBG(1, "AscGetChipSignatureWord(0x%x) 0x%x\n",
51219358
MW
4410 iop_base, AscGetChipSignatureWord(iop_base));
4411 sig_word = AscGetChipSignatureWord(iop_base);
4412 if ((sig_word == (ushort)ASC_1000_ID0W) ||
4413 (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
4414 return (1);
27c868c2 4415 }
27c868c2 4416 }
51219358 4417 return (0);
27c868c2
MW
4418}
4419
51219358 4420static void AscEnableInterrupt(PortAddr iop_base)
1da177e4 4421{
51219358 4422 ushort cfg;
27c868c2 4423
51219358
MW
4424 cfg = AscGetChipCfgLsw(iop_base);
4425 AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
51219358 4426}
27c868c2 4427
51219358
MW
4428static void AscDisableInterrupt(PortAddr iop_base)
4429{
4430 ushort cfg;
27c868c2 4431
51219358
MW
4432 cfg = AscGetChipCfgLsw(iop_base);
4433 AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
51219358 4434}
27c868c2 4435
51219358
MW
4436static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
4437{
4438 unsigned char byte_data;
4439 unsigned short word_data;
27c868c2 4440
51219358
MW
4441 if (isodd_word(addr)) {
4442 AscSetChipLramAddr(iop_base, addr - 1);
4443 word_data = AscGetChipLramData(iop_base);
4444 byte_data = (word_data >> 8) & 0xFF;
4445 } else {
4446 AscSetChipLramAddr(iop_base, addr);
4447 word_data = AscGetChipLramData(iop_base);
4448 byte_data = word_data & 0xFF;
4449 }
4450 return byte_data;
4451}
27c868c2 4452
51219358
MW
4453static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
4454{
4455 ushort word_data;
27c868c2 4456
51219358
MW
4457 AscSetChipLramAddr(iop_base, addr);
4458 word_data = AscGetChipLramData(iop_base);
4459 return (word_data);
4460}
27c868c2 4461
51219358
MW
4462#if CC_VERY_LONG_SG_LIST
4463static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
4464{
4465 ushort val_low, val_high;
4466 ASC_DCNT dword_data;
27c868c2 4467
51219358
MW
4468 AscSetChipLramAddr(iop_base, addr);
4469 val_low = AscGetChipLramData(iop_base);
4470 val_high = AscGetChipLramData(iop_base);
4471 dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
4472 return (dword_data);
4473}
4474#endif /* CC_VERY_LONG_SG_LIST */
4475
4476static void
4477AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
4478{
4479 int i;
4480
4481 AscSetChipLramAddr(iop_base, s_addr);
4482 for (i = 0; i < words; i++) {
4483 AscSetChipLramData(iop_base, set_wval);
27c868c2 4484 }
51219358 4485}
1da177e4 4486
51219358
MW
4487static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
4488{
4489 AscSetChipLramAddr(iop_base, addr);
4490 AscSetChipLramData(iop_base, word_val);
51219358
MW
4491}
4492
4493static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
4494{
4495 ushort word_data;
4496
4497 if (isodd_word(addr)) {
4498 addr--;
4499 word_data = AscReadLramWord(iop_base, addr);
4500 word_data &= 0x00FF;
4501 word_data |= (((ushort)byte_val << 8) & 0xFF00);
4502 } else {
4503 word_data = AscReadLramWord(iop_base, addr);
4504 word_data &= 0xFF00;
4505 word_data |= ((ushort)byte_val & 0x00FF);
4506 }
4507 AscWriteLramWord(iop_base, addr, word_data);
1da177e4
LT
4508}
4509
4510/*
51219358 4511 * Copy 2 bytes to LRAM.
1da177e4 4512 *
51219358
MW
4513 * The source data is assumed to be in little-endian order in memory
4514 * and is maintained in little-endian order when written to LRAM.
1da177e4 4515 */
51219358
MW
4516static void
4517AscMemWordCopyPtrToLram(PortAddr iop_base,
4518 ushort s_addr, uchar *s_buffer, int words)
1da177e4 4519{
27c868c2 4520 int i;
27c868c2 4521
51219358
MW
4522 AscSetChipLramAddr(iop_base, s_addr);
4523 for (i = 0; i < 2 * words; i += 2) {
4524 /*
4525 * On a little-endian system the second argument below
4526 * produces a little-endian ushort which is written to
4527 * LRAM in little-endian order. On a big-endian system
4528 * the second argument produces a big-endian ushort which
4529 * is "transparently" byte-swapped by outpw() and written
4530 * in little-endian order to LRAM.
4531 */
4532 outpw(iop_base + IOP_RAM_DATA,
4533 ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
4534 }
51219358 4535}
27c868c2 4536
51219358
MW
4537/*
4538 * Copy 4 bytes to LRAM.
4539 *
4540 * The source data is assumed to be in little-endian order in memory
4541 * and is maintained in little-endian order when writen to LRAM.
4542 */
4543static void
4544AscMemDWordCopyPtrToLram(PortAddr iop_base,
4545 ushort s_addr, uchar *s_buffer, int dwords)
4546{
4547 int i;
27c868c2 4548
51219358
MW
4549 AscSetChipLramAddr(iop_base, s_addr);
4550 for (i = 0; i < 4 * dwords; i += 4) {
4551 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
4552 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
4553 }
51219358 4554}
27c868c2 4555
51219358
MW
4556/*
4557 * Copy 2 bytes from LRAM.
4558 *
4559 * The source data is assumed to be in little-endian order in LRAM
4560 * and is maintained in little-endian order when written to memory.
4561 */
4562static void
4563AscMemWordCopyPtrFromLram(PortAddr iop_base,
4564 ushort s_addr, uchar *d_buffer, int words)
4565{
4566 int i;
4567 ushort word;
27c868c2 4568
51219358
MW
4569 AscSetChipLramAddr(iop_base, s_addr);
4570 for (i = 0; i < 2 * words; i += 2) {
4571 word = inpw(iop_base + IOP_RAM_DATA);
4572 d_buffer[i] = word & 0xff;
4573 d_buffer[i + 1] = (word >> 8) & 0xff;
27c868c2 4574 }
51219358 4575}
27c868c2 4576
51219358
MW
4577static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
4578{
4579 ASC_DCNT sum;
4580 int i;
27c868c2 4581
51219358
MW
4582 sum = 0L;
4583 for (i = 0; i < words; i++, s_addr += 2) {
4584 sum += AscReadLramWord(iop_base, s_addr);
27c868c2 4585 }
51219358
MW
4586 return (sum);
4587}
27c868c2 4588
51219358
MW
4589static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
4590{
4591 uchar i;
4592 ushort s_addr;
4593 PortAddr iop_base;
4594 ushort warn_code;
27c868c2 4595
51219358
MW
4596 iop_base = asc_dvc->iop_base;
4597 warn_code = 0;
4598 AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
4599 (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
4600 64) >> 1));
4601 i = ASC_MIN_ACTIVE_QNO;
4602 s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
4603 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4604 (uchar)(i + 1));
4605 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4606 (uchar)(asc_dvc->max_total_qng));
4607 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4608 (uchar)i);
4609 i++;
4610 s_addr += ASC_QBLK_SIZE;
4611 for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
4612 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4613 (uchar)(i + 1));
4614 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4615 (uchar)(i - 1));
4616 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4617 (uchar)i);
27c868c2 4618 }
51219358
MW
4619 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4620 (uchar)ASC_QLINK_END);
4621 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4622 (uchar)(asc_dvc->max_total_qng - 1));
4623 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4624 (uchar)asc_dvc->max_total_qng);
4625 i++;
4626 s_addr += ASC_QBLK_SIZE;
4627 for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
4628 i++, s_addr += ASC_QBLK_SIZE) {
4629 AscWriteLramByte(iop_base,
4630 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
4631 AscWriteLramByte(iop_base,
4632 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
4633 AscWriteLramByte(iop_base,
4634 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
27c868c2 4635 }
51219358 4636 return warn_code;
1da177e4
LT
4637}
4638
51219358
MW
4639static ASC_DCNT
4640AscLoadMicroCode(PortAddr iop_base,
4641 ushort s_addr, uchar *mcode_buf, ushort mcode_size)
1da177e4 4642{
51219358
MW
4643 ASC_DCNT chksum;
4644 ushort mcode_word_size;
4645 ushort mcode_chksum;
27c868c2 4646
51219358
MW
4647 /* Write the microcode buffer starting at LRAM address 0. */
4648 mcode_word_size = (ushort)(mcode_size >> 1);
4649 AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
4650 AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
27c868c2 4651
51219358 4652 chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
b352f923 4653 ASC_DBG(1, "chksum 0x%lx\n", (ulong)chksum);
51219358
MW
4654 mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
4655 (ushort)ASC_CODE_SEC_BEG,
4656 (ushort)((mcode_size -
4657 s_addr - (ushort)
4658 ASC_CODE_SEC_BEG) /
4659 2));
b352f923 4660 ASC_DBG(1, "mcode_chksum 0x%lx\n", (ulong)mcode_chksum);
51219358
MW
4661 AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
4662 AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
b352f923 4663 return chksum;
51219358 4664}
27c868c2 4665
51219358
MW
4666/* Microcode buffer is kept after initialization for error recovery. */
4667static uchar _asc_mcode_buf[] = {
4668 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4669 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
4670 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4671 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4672 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4673 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
4674 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4675 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4676 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
4677 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
4678 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
4679 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
4680 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
4681 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
4682 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
4683 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
4684 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
4685 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
4686 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
4687 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
4688 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
4689 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
4690 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
4691 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
4692 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
4693 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
4694 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
4695 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
4696 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
4697 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
4698 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
4699 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
4700 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
4701 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
4702 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
4703 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
4704 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
4705 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
4706 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
4707 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
4708 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
4709 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
4710 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
4711 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
4712 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
4713 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
4714 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
4715 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
4716 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
4717 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
4718 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
4719 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
4720 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
4721 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
4722 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
4723 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
4724 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
4725 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
4726 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
4727 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
4728 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
4729 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
4730 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
4731 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
4732 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
4733 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
4734 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
4735 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
4736 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
4737 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
4738 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
4739 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
4740 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
4741 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
4742 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
4743 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
4744 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
4745 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
4746 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
4747 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
4748 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
4749 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
4750 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
4751 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
4752 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
4753 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
4754 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
4755 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
4756 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
4757 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
4758 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
4759 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
4760 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
4761 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
4762 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
4763 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
4764 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
4765 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
4766 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
4767 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
4768 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
4769 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
4770 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
4771 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
4772 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
4773 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
4774 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
4775 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
4776 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
4777 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
4778 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
4779 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
4780 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
4781 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
4782 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
4783 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
4784 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
4785 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
4786 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
4787 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
4788 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
4789 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
4790 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
4791 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
4792 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
4793 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
4794 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
4795 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
4796 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
4797 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
4798 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
4799 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
4800 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
4801 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
4802 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
4803 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
4804 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
4805 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
4806 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
4807 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
4808 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
4809 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
4810 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
4811 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
4812 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
4813 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
4814 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
4815 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
4816 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
4817 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
4818 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
4819 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
4820 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
4821 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
4822 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
4823 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
4824 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
4825 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
4826 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
4827 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
4828 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
4829 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
4830 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
4831 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
4832 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
4833 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
4834 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
4835 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
4836 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
4837 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
4838 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
4839 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
4840 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
4841 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
4842 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
4843 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
4844 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
4845 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
4846 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
4847 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
4848 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
4849 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
4850 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
4851 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
4852 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
4853 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
4854 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
4855 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
4856 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
4857 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
4858 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
4859 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
4860};
27c868c2 4861
51219358
MW
4862static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
4863static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
1da177e4 4864
1da177e4 4865/* Microcode buffer is kept after initialization for error recovery. */
27c868c2
MW
4866static unsigned char _adv_asc3550_buf[] = {
4867 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
629d688d
MW
4868 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
4869 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
4870 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
27c868c2 4871 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
629d688d
MW
4872 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
4873 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
4874 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
27c868c2 4875 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
629d688d
MW
4876 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
4877 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
4878 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
27c868c2 4879 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
629d688d
MW
4880 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
4881 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
4882 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
27c868c2 4883 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
629d688d
MW
4884 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
4885 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
4886 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
27c868c2 4887 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
629d688d
MW
4888 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
4889 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
4890 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
27c868c2 4891 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
629d688d
MW
4892 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
4893 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
4894 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
27c868c2 4895 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
629d688d
MW
4896 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
4897 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
4898 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
27c868c2 4899 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
629d688d
MW
4900 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
4901 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
4902 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
27c868c2 4903 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
629d688d
MW
4904 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
4905 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
4906 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
27c868c2 4907 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
629d688d
MW
4908 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
4909 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
4910 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
27c868c2 4911 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
629d688d
MW
4912 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
4913 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
4914 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
27c868c2 4915 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
629d688d
MW
4916 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
4917 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
4918 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
27c868c2 4919 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
629d688d
MW
4920 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
4921 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
4922 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
27c868c2 4923 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
629d688d
MW
4924 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
4925 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
4926 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
27c868c2 4927 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
629d688d
MW
4928 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
4929 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
4930 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
27c868c2 4931 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
629d688d
MW
4932 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
4933 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
4934 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
27c868c2 4935 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
629d688d
MW
4936 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
4937 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
4938 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
27c868c2 4939 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
629d688d
MW
4940 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
4941 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
4942 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
27c868c2 4943 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
629d688d
MW
4944 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
4945 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
4946 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
27c868c2 4947 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
629d688d
MW
4948 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
4949 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
4950 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
27c868c2 4951 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
629d688d
MW
4952 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
4953 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
4954 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
27c868c2 4955 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
629d688d
MW
4956 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
4957 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
4958 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
27c868c2 4959 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
629d688d
MW
4960 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
4961 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
4962 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
27c868c2 4963 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
629d688d
MW
4964 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
4965 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
4966 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
27c868c2 4967 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
629d688d
MW
4968 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
4969 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
4970 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
27c868c2 4971 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
629d688d
MW
4972 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
4973 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
4974 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
27c868c2 4975 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
629d688d
MW
4976 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
4977 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
4978 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
27c868c2 4979 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
629d688d
MW
4980 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
4981 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
4982 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
27c868c2 4983 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
629d688d
MW
4984 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
4985 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
4986 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
27c868c2 4987 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
629d688d
MW
4988 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
4989 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
4990 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
27c868c2 4991 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
629d688d
MW
4992 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
4993 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
4994 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
27c868c2 4995 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
629d688d
MW
4996 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
4997 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
4998 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
27c868c2 4999 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
629d688d
MW
5000 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
5001 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
5002 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
27c868c2 5003 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
629d688d
MW
5004 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
5005 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
5006 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
27c868c2 5007 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
629d688d
MW
5008 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
5009 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
5010 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
27c868c2 5011 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
629d688d
MW
5012 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
5013 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
5014 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
27c868c2 5015 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
629d688d
MW
5016 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
5017 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
5018 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
27c868c2 5019 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
629d688d
MW
5020 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
5021 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
5022 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
27c868c2 5023 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
629d688d
MW
5024 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
5025 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
5026 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
27c868c2 5027 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
629d688d
MW
5028 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
5029 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
5030 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
27c868c2 5031 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
629d688d
MW
5032 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
5033 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
5034 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
27c868c2 5035 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
629d688d
MW
5036 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
5037 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
5038 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
27c868c2 5039 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
629d688d
MW
5040 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
5041 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
5042 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
27c868c2 5043 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
629d688d
MW
5044 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
5045 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
5046 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
27c868c2 5047 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
629d688d
MW
5048 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
5049 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
5050 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
27c868c2 5051 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
629d688d
MW
5052 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
5053 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
5054 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
27c868c2 5055 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
629d688d
MW
5056 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
5057 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
5058 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
27c868c2 5059 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
629d688d
MW
5060 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
5061 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
5062 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
27c868c2 5063 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
629d688d
MW
5064 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
5065 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
5066 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
27c868c2 5067 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
629d688d
MW
5068 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
5069 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
5070 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
27c868c2 5071 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
629d688d
MW
5072 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
5073 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
5074 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
27c868c2 5075 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
629d688d
MW
5076 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
5077 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
5078 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
27c868c2 5079 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
629d688d
MW
5080 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
5081 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
5082 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
27c868c2 5083 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
629d688d
MW
5084 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
5085 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
5086 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
27c868c2 5087 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
629d688d
MW
5088 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
5089 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
5090 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
27c868c2 5091 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
629d688d
MW
5092 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
5093 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
5094 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
27c868c2 5095 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
629d688d
MW
5096 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
5097 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
5098 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
27c868c2 5099 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
629d688d
MW
5100 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
5101 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
5102 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
27c868c2 5103 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
629d688d
MW
5104 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
5105 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
5106 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
27c868c2 5107 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
629d688d
MW
5108 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
5109 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
5110 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
27c868c2 5111 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
629d688d
MW
5112 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
5113 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
5114 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
27c868c2 5115 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
629d688d
MW
5116 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
5117 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
5118 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
27c868c2 5119 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
629d688d
MW
5120 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
5121 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
5122 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
27c868c2 5123 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
629d688d
MW
5124 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
5125 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
5126 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
27c868c2 5127 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
629d688d
MW
5128 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
5129 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
5130 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
27c868c2 5131 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
629d688d
MW
5132 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
5133 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
5134 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
27c868c2 5135 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
629d688d
MW
5136 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
5137 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
5138 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
27c868c2 5139 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
629d688d
MW
5140 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
5141 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
5142 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
27c868c2 5143 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
629d688d
MW
5144 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
5145 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
5146 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
27c868c2 5147 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
629d688d
MW
5148 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
5149 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
5150 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
27c868c2 5151 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
629d688d
MW
5152 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
5153 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
5154 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
27c868c2 5155 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
629d688d
MW
5156 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
5157 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
5158 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
27c868c2 5159 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
629d688d
MW
5160 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
5161 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
5162 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
27c868c2 5163 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
629d688d
MW
5164 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
5165 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
5166 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
27c868c2 5167 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
629d688d
MW
5168 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
5169 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
5170 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
27c868c2 5171 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
629d688d
MW
5172 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
5173 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
5174 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
27c868c2 5175 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
629d688d
MW
5176 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
5177 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
5178 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
27c868c2 5179 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
629d688d
MW
5180 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
5181 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
5182 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
27c868c2 5183 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
629d688d
MW
5184 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
5185 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
5186 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
27c868c2 5187 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
629d688d
MW
5188 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
5189 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
5190 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
27c868c2 5191 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
629d688d
MW
5192 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
5193 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
5194 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
27c868c2 5195 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
629d688d
MW
5196 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
5197 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
5198 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
27c868c2 5199 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
629d688d
MW
5200 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
5201 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
5202 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
27c868c2 5203 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
629d688d
MW
5204 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
5205 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
5206 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
27c868c2 5207 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
629d688d
MW
5208 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
5209 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
5210 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
27c868c2 5211 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
629d688d
MW
5212 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
5213 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
5214 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
27c868c2 5215 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
629d688d
MW
5216 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
5217 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
5218 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
27c868c2 5219 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
629d688d
MW
5220 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
5221 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
5222 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
27c868c2 5223 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
629d688d
MW
5224 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
5225 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
5226 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
27c868c2 5227 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
629d688d
MW
5228 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
5229 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
5230 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
27c868c2 5231 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
629d688d
MW
5232 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
5233 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
5234 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
27c868c2 5235 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
629d688d
MW
5236 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
5237 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
5238 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
27c868c2 5239 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
629d688d
MW
5240 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
5241 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
5242 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
27c868c2 5243 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
629d688d
MW
5244 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
5245 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
5246 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
27c868c2 5247 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
629d688d
MW
5248 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
5249 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
5250 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
27c868c2 5251 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
629d688d
MW
5252 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
5253 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
5254 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
27c868c2 5255 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
629d688d
MW
5256 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
5257 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
5258 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
27c868c2 5259 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
629d688d
MW
5260 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
5261 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
5262 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
27c868c2 5263 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
629d688d
MW
5264 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
5265 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
5266 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
27c868c2 5267 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
629d688d
MW
5268 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
5269 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
5270 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
27c868c2 5271 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
629d688d
MW
5272 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
5273 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
5274 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
27c868c2 5275 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
629d688d
MW
5276 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
5277 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
5278 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
27c868c2 5279 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
629d688d
MW
5280 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
5281 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
5282 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
27c868c2 5283 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
629d688d
MW
5284 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
5285 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
1da177e4
LT
5286};
5287
27c868c2
MW
5288static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
5289static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
1da177e4
LT
5290
5291/* Microcode buffer is kept after initialization for error recovery. */
27c868c2
MW
5292static unsigned char _adv_asc38C0800_buf[] = {
5293 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
629d688d
MW
5294 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
5295 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
5296 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
27c868c2 5297 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
629d688d
MW
5298 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
5299 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
5300 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
27c868c2 5301 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
629d688d
MW
5302 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
5303 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
5304 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
27c868c2 5305 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
629d688d
MW
5306 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
5307 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
5308 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
27c868c2 5309 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
629d688d
MW
5310 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
5311 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
5312 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
27c868c2 5313 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
629d688d
MW
5314 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
5315 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
5316 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
27c868c2 5317 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
629d688d
MW
5318 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
5319 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
5320 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
27c868c2 5321 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
629d688d
MW
5322 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
5323 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
5324 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
27c868c2 5325 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
629d688d
MW
5326 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
5327 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
5328 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
27c868c2 5329 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
629d688d
MW
5330 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
5331 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
5332 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
27c868c2 5333 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
629d688d
MW
5334 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
5335 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
5336 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
27c868c2 5337 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
629d688d
MW
5338 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
5339 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
5340 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
27c868c2 5341 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
629d688d
MW
5342 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
5343 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
5344 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
27c868c2 5345 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
629d688d
MW
5346 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
5347 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
5348 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
27c868c2 5349 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
629d688d
MW
5350 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
5351 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
5352 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
27c868c2 5353 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
629d688d
MW
5354 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
5355 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
5356 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
27c868c2 5357 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
629d688d
MW
5358 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
5359 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
5360 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
27c868c2 5361 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
629d688d
MW
5362 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
5363 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
5364 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
27c868c2 5365 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
629d688d
MW
5366 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
5367 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
5368 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
27c868c2 5369 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
629d688d
MW
5370 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
5371 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
5372 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
27c868c2 5373 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
629d688d
MW
5374 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
5375 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
5376 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
27c868c2 5377 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
629d688d
MW
5378 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
5379 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
5380 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
27c868c2 5381 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
629d688d
MW
5382 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
5383 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
5384 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
27c868c2 5385 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
629d688d
MW
5386 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
5387 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
5388 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
27c868c2 5389 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
629d688d
MW
5390 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
5391 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
5392 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
27c868c2 5393 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
629d688d
MW
5394 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
5395 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
5396 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
27c868c2 5397 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
629d688d
MW
5398 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
5399 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
5400 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
27c868c2 5401 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
629d688d
MW
5402 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
5403 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
5404 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
27c868c2 5405 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
629d688d
MW
5406 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
5407 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
5408 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
27c868c2 5409 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
629d688d
MW
5410 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
5411 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
5412 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
27c868c2 5413 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
629d688d
MW
5414 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
5415 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
5416 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
27c868c2 5417 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
629d688d
MW
5418 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
5419 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
5420 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
27c868c2 5421 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
629d688d
MW
5422 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
5423 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
5424 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
27c868c2 5425 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
629d688d
MW
5426 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
5427 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
5428 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
27c868c2 5429 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
629d688d
MW
5430 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
5431 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
5432 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
27c868c2 5433 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
629d688d
MW
5434 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
5435 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
5436 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
27c868c2 5437 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
629d688d
MW
5438 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
5439 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
5440 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
27c868c2 5441 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
629d688d
MW
5442 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
5443 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
5444 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
27c868c2 5445 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
629d688d
MW
5446 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
5447 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
5448 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
27c868c2 5449 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
629d688d
MW
5450 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
5451 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
5452 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
27c868c2 5453 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
629d688d
MW
5454 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
5455 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
5456 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
27c868c2 5457 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
629d688d
MW
5458 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
5459 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
5460 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
27c868c2 5461 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
629d688d
MW
5462 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
5463 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
5464 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
27c868c2 5465 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
629d688d
MW
5466 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
5467 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
5468 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
27c868c2 5469 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
629d688d
MW
5470 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
5471 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
5472 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
27c868c2 5473 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
629d688d
MW
5474 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
5475 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
5476 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
27c868c2 5477 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
629d688d
MW
5478 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
5479 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
5480 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
27c868c2 5481 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
629d688d
MW
5482 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
5483 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
5484 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
27c868c2 5485 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
629d688d
MW
5486 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
5487 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
5488 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
27c868c2 5489 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
629d688d
MW
5490 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
5491 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
5492 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
27c868c2 5493 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
629d688d
MW
5494 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
5495 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
5496 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
27c868c2 5497 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
629d688d
MW
5498 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
5499 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
5500 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
27c868c2 5501 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
629d688d
MW
5502 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
5503 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
5504 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
27c868c2 5505 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
629d688d
MW
5506 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
5507 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
5508 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
27c868c2 5509 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
629d688d
MW
5510 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
5511 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
5512 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
27c868c2 5513 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
629d688d
MW
5514 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
5515 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
5516 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
27c868c2 5517 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
629d688d
MW
5518 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
5519 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
5520 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
27c868c2 5521 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
629d688d
MW
5522 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
5523 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
5524 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
27c868c2 5525 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
629d688d
MW
5526 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
5527 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
5528 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
27c868c2 5529 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
629d688d
MW
5530 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
5531 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
5532 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
27c868c2 5533 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
629d688d
MW
5534 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
5535 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
5536 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
27c868c2 5537 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
629d688d
MW
5538 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
5539 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
5540 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
27c868c2 5541 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
629d688d
MW
5542 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
5543 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
5544 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
27c868c2 5545 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
629d688d
MW
5546 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
5547 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
5548 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
27c868c2 5549 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
629d688d
MW
5550 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
5551 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
5552 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
27c868c2 5553 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
629d688d
MW
5554 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
5555 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
5556 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
27c868c2 5557 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
629d688d
MW
5558 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
5559 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
5560 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
27c868c2 5561 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
629d688d
MW
5562 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
5563 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
5564 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
27c868c2 5565 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
629d688d
MW
5566 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
5567 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
5568 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
27c868c2 5569 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
629d688d
MW
5570 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
5571 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
5572 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
27c868c2 5573 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
629d688d
MW
5574 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
5575 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
5576 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
27c868c2 5577 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
629d688d
MW
5578 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
5579 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
5580 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
27c868c2 5581 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
629d688d
MW
5582 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
5583 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
5584 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
27c868c2 5585 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
629d688d
MW
5586 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
5587 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
5588 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
27c868c2 5589 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
629d688d
MW
5590 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
5591 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
5592 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
27c868c2 5593 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
629d688d
MW
5594 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
5595 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
5596 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
27c868c2 5597 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
629d688d
MW
5598 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
5599 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
5600 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
27c868c2 5601 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
629d688d
MW
5602 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
5603 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
5604 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
27c868c2 5605 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
629d688d
MW
5606 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
5607 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
5608 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
27c868c2 5609 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
629d688d
MW
5610 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
5611 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
5612 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
27c868c2 5613 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
629d688d
MW
5614 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
5615 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
5616 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
27c868c2 5617 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
629d688d
MW
5618 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
5619 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
5620 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
27c868c2 5621 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
629d688d
MW
5622 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
5623 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
5624 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
27c868c2 5625 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
629d688d
MW
5626 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
5627 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
5628 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
27c868c2 5629 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
629d688d
MW
5630 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
5631 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
5632 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
27c868c2 5633 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
629d688d
MW
5634 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
5635 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
5636 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
27c868c2 5637 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
629d688d
MW
5638 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
5639 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
5640 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
27c868c2 5641 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
629d688d
MW
5642 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
5643 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
5644 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
27c868c2 5645 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
629d688d
MW
5646 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
5647 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
5648 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
27c868c2 5649 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
629d688d
MW
5650 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
5651 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
5652 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
27c868c2 5653 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
629d688d
MW
5654 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
5655 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
5656 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
27c868c2 5657 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
629d688d
MW
5658 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
5659 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
5660 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
27c868c2 5661 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
629d688d
MW
5662 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
5663 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
5664 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
27c868c2 5665 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
629d688d
MW
5666 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
5667 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
5668 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
27c868c2 5669 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
629d688d
MW
5670 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
5671 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
5672 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
27c868c2 5673 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
629d688d
MW
5674 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
5675 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
5676 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
27c868c2 5677 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
629d688d
MW
5678 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
5679 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
5680 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
27c868c2 5681 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
629d688d
MW
5682 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
5683 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
5684 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
27c868c2 5685 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
629d688d
MW
5686 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
5687 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
5688 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
27c868c2 5689 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
629d688d
MW
5690 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
5691 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
5692 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
27c868c2 5693 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
629d688d
MW
5694 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
5695 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
5696 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
27c868c2 5697 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
629d688d
MW
5698 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
5699 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
5700 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
27c868c2 5701 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
629d688d
MW
5702 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
5703 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
5704 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
27c868c2 5705 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
629d688d
MW
5706 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
5707 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
5708 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
27c868c2 5709 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
629d688d
MW
5710 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
5711 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
5712 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
27c868c2 5713 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
629d688d
MW
5714 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
5715 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
5716 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
27c868c2 5717 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
629d688d
MW
5718 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
5719 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
5720 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
27c868c2 5721 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
629d688d
MW
5722 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
5723 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
5724 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
27c868c2 5725 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
629d688d
MW
5726 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
5727 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
5728 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
27c868c2 5729 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
629d688d
MW
5730 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
5731 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
5732 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
27c868c2 5733 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
629d688d
MW
5734 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
5735 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
5736 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
27c868c2 5737 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
1da177e4
LT
5738};
5739
27c868c2
MW
5740static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
5741static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
1da177e4
LT
5742
5743/* Microcode buffer is kept after initialization for error recovery. */
27c868c2
MW
5744static unsigned char _adv_asc38C1600_buf[] = {
5745 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
629d688d
MW
5746 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
5747 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
5748 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
27c868c2 5749 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
629d688d
MW
5750 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
5751 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
5752 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
27c868c2 5753 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
629d688d
MW
5754 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
5755 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
5756 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
27c868c2 5757 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
629d688d
MW
5758 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
5759 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
5760 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
27c868c2 5761 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
629d688d
MW
5762 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
5763 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
5764 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
27c868c2 5765 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
629d688d
MW
5766 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
5767 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
5768 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
27c868c2 5769 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
629d688d
MW
5770 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
5771 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
5772 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
27c868c2 5773 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
629d688d
MW
5774 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
5775 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
5776 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
27c868c2 5777 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
629d688d
MW
5778 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
5779 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
5780 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
27c868c2 5781 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
629d688d
MW
5782 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
5783 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
5784 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
27c868c2 5785 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
629d688d
MW
5786 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
5787 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
5788 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
27c868c2 5789 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
629d688d
MW
5790 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
5791 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
5792 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
27c868c2 5793 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
629d688d
MW
5794 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
5795 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
5796 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
27c868c2 5797 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
629d688d
MW
5798 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
5799 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
5800 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
27c868c2 5801 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
629d688d
MW
5802 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
5803 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
5804 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
27c868c2 5805 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
629d688d
MW
5806 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
5807 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
5808 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
27c868c2 5809 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
629d688d
MW
5810 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
5811 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
5812 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
27c868c2 5813 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
629d688d
MW
5814 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
5815 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
5816 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
27c868c2 5817 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
629d688d
MW
5818 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
5819 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
5820 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
27c868c2 5821 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
629d688d
MW
5822 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
5823 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
5824 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
27c868c2 5825 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
629d688d
MW
5826 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
5827 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
5828 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
27c868c2 5829 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
629d688d
MW
5830 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
5831 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
5832 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
27c868c2 5833 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
629d688d
MW
5834 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
5835 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
5836 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
27c868c2 5837 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
629d688d
MW
5838 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
5839 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
5840 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
27c868c2 5841 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
629d688d
MW
5842 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
5843 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
5844 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
27c868c2 5845 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
629d688d
MW
5846 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
5847 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
5848 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
27c868c2 5849 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
629d688d
MW
5850 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
5851 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
5852 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
27c868c2 5853 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
629d688d
MW
5854 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
5855 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
5856 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
27c868c2 5857 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
629d688d
MW
5858 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
5859 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
5860 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
27c868c2 5861 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
629d688d
MW
5862 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
5863 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
5864 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
27c868c2 5865 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
629d688d
MW
5866 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
5867 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
5868 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
27c868c2 5869 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
629d688d
MW
5870 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
5871 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
5872 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
27c868c2 5873 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
629d688d
MW
5874 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
5875 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
5876 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
27c868c2 5877 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
629d688d
MW
5878 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
5879 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
5880 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
27c868c2 5881 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
629d688d
MW
5882 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
5883 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
5884 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
27c868c2 5885 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
629d688d
MW
5886 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
5887 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
5888 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
27c868c2 5889 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
629d688d
MW
5890 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
5891 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
5892 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
27c868c2 5893 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
629d688d
MW
5894 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
5895 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
5896 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
27c868c2 5897 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
629d688d
MW
5898 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
5899 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
5900 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
27c868c2 5901 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
629d688d
MW
5902 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
5903 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
5904 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
27c868c2 5905 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
629d688d
MW
5906 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
5907 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
5908 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
27c868c2 5909 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
629d688d
MW
5910 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
5911 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
5912 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
27c868c2 5913 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
629d688d
MW
5914 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
5915 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
5916 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
27c868c2 5917 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
629d688d
MW
5918 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
5919 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
5920 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
27c868c2 5921 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
629d688d
MW
5922 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
5923 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
5924 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
27c868c2 5925 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
629d688d
MW
5926 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
5927 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
5928 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
27c868c2 5929 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
629d688d
MW
5930 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
5931 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
5932 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
27c868c2 5933 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
629d688d
MW
5934 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
5935 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
5936 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
27c868c2 5937 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
629d688d
MW
5938 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
5939 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
5940 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
27c868c2 5941 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
629d688d
MW
5942 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
5943 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
5944 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
27c868c2 5945 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
629d688d
MW
5946 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
5947 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
5948 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
27c868c2 5949 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
629d688d
MW
5950 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
5951 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
5952 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
27c868c2 5953 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
629d688d
MW
5954 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
5955 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
5956 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
27c868c2 5957 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
629d688d
MW
5958 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
5959 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
5960 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
27c868c2 5961 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
629d688d
MW
5962 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
5963 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
5964 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
27c868c2 5965 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
629d688d
MW
5966 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
5967 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
5968 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
27c868c2 5969 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
629d688d
MW
5970 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
5971 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
5972 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
27c868c2 5973 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
629d688d
MW
5974 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
5975 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
5976 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
27c868c2 5977 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
629d688d
MW
5978 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
5979 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
5980 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
27c868c2 5981 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
629d688d
MW
5982 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
5983 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
5984 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
27c868c2 5985 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
629d688d
MW
5986 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
5987 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
5988 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
27c868c2 5989 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
629d688d
MW
5990 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
5991 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
5992 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
27c868c2 5993 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
629d688d
MW
5994 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
5995 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
5996 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
27c868c2 5997 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
629d688d
MW
5998 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
5999 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
6000 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
27c868c2 6001 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
629d688d
MW
6002 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
6003 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
6004 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
27c868c2 6005 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
629d688d
MW
6006 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
6007 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
6008 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
27c868c2 6009 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
629d688d
MW
6010 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
6011 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
6012 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
27c868c2 6013 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
629d688d
MW
6014 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
6015 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
6016 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
27c868c2 6017 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
629d688d
MW
6018 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
6019 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
6020 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
27c868c2 6021 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
629d688d
MW
6022 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
6023 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
6024 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
27c868c2 6025 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
629d688d
MW
6026 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
6027 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
6028 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
27c868c2 6029 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
629d688d
MW
6030 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
6031 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
6032 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
27c868c2 6033 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
629d688d
MW
6034 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
6035 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
6036 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
27c868c2 6037 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
629d688d
MW
6038 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
6039 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
6040 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
27c868c2 6041 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
629d688d
MW
6042 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
6043 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
6044 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
27c868c2 6045 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
629d688d
MW
6046 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
6047 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
6048 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
27c868c2 6049 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
629d688d
MW
6050 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
6051 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
6052 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
27c868c2 6053 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
629d688d
MW
6054 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
6055 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
6056 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
27c868c2 6057 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
629d688d
MW
6058 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
6059 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
6060 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
27c868c2 6061 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
629d688d
MW
6062 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
6063 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
6064 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
27c868c2 6065 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
629d688d
MW
6066 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
6067 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
6068 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
27c868c2 6069 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
629d688d
MW
6070 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
6071 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
6072 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
27c868c2 6073 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
629d688d
MW
6074 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
6075 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
6076 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
27c868c2 6077 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
629d688d
MW
6078 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
6079 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
6080 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
27c868c2 6081 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
629d688d
MW
6082 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
6083 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
6084 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
27c868c2 6085 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
629d688d
MW
6086 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
6087 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
6088 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
27c868c2 6089 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
629d688d
MW
6090 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
6091 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
6092 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
27c868c2 6093 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
629d688d
MW
6094 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
6095 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
6096 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
27c868c2 6097 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
629d688d
MW
6098 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
6099 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
6100 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
27c868c2 6101 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
629d688d
MW
6102 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
6103 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
6104 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
27c868c2 6105 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
629d688d
MW
6106 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
6107 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
6108 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
27c868c2 6109 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
629d688d
MW
6110 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
6111 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
6112 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
27c868c2 6113 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
629d688d
MW
6114 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
6115 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
6116 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
27c868c2 6117 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
629d688d
MW
6118 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
6119 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
6120 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
27c868c2 6121 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
629d688d
MW
6122 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
6123 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
6124 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
27c868c2 6125 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
629d688d
MW
6126 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
6127 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
6128 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
27c868c2 6129 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
629d688d
MW
6130 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
6131 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
6132 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
27c868c2 6133 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
629d688d
MW
6134 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
6135 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
6136 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
27c868c2 6137 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
629d688d
MW
6138 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
6139 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
6140 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
27c868c2 6141 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
629d688d
MW
6142 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
6143 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
6144 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
27c868c2 6145 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
629d688d
MW
6146 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
6147 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
6148 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
27c868c2 6149 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
629d688d
MW
6150 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
6151 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
6152 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
27c868c2 6153 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
629d688d
MW
6154 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
6155 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
6156 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
27c868c2 6157 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
629d688d
MW
6158 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
6159 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
6160 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
27c868c2 6161 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
629d688d
MW
6162 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
6163 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
6164 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
27c868c2 6165 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
629d688d
MW
6166 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
6167 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
6168 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
27c868c2 6169 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
629d688d
MW
6170 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
6171 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
6172 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
27c868c2 6173 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
629d688d
MW
6174 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
6175 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
6176 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
27c868c2 6177 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
629d688d
MW
6178 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
6179 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
6180 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
27c868c2 6181 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
629d688d
MW
6182 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
6183 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
6184 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
27c868c2 6185 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
629d688d
MW
6186 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
6187 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
6188 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
27c868c2 6189 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
629d688d
MW
6190 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
6191 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
6192 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
27c868c2 6193 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
629d688d
MW
6194 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
6195 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
6196 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
27c868c2 6197 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
629d688d
MW
6198 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
6199 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
6200 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
27c868c2 6201 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
629d688d
MW
6202 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
6203 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
6204 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
27c868c2 6205 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
629d688d
MW
6206 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
6207 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
6208 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
27c868c2 6209 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
629d688d
MW
6210 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
6211 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
6212 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
27c868c2 6213 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
629d688d
MW
6214 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
6215 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
6216 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
27c868c2 6217 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
629d688d
MW
6218 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
6219 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
6220 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
27c868c2 6221 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
629d688d
MW
6222 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
6223 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
6224 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
27c868c2 6225 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
629d688d
MW
6226 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
6227 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
6228 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
27c868c2 6229 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
629d688d
MW
6230 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
6231 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
6232 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
27c868c2 6233 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
629d688d
MW
6234 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
6235 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
6236 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
27c868c2 6237 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
629d688d
MW
6238 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
6239 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
6240 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
27c868c2 6241 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
629d688d
MW
6242 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
6243 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
6244 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
27c868c2 6245 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
629d688d
MW
6246 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
6247 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
6248 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
27c868c2 6249 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
629d688d
MW
6250 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
6251 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
6252 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
27c868c2 6253 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
629d688d
MW
6254 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
6255 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
6256 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
27c868c2 6257 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
629d688d
MW
6258 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
6259 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
6260 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
27c868c2 6261 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
629d688d
MW
6262 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
6263 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
6264 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
27c868c2 6265 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
629d688d
MW
6266 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
6267 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
6268 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
27c868c2 6269 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
629d688d
MW
6270 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
6271 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
6272 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
1da177e4
LT
6273};
6274
51219358
MW
6275static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
6276static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
6277
6278static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
6279{
6280 PortAddr iop_base;
6281 int i;
6282 ushort lram_addr;
6283
6284 iop_base = asc_dvc->iop_base;
6285 AscPutRiscVarFreeQHead(iop_base, 1);
6286 AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
6287 AscPutVarFreeQHead(iop_base, 1);
6288 AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
6289 AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
6290 (uchar)((int)asc_dvc->max_total_qng + 1));
6291 AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
6292 (uchar)((int)asc_dvc->max_total_qng + 2));
6293 AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
6294 asc_dvc->max_total_qng);
6295 AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
6296 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
6297 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
6298 AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
6299 AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
6300 AscPutQDoneInProgress(iop_base, 0);
6301 lram_addr = ASC_QADR_BEG;
6302 for (i = 0; i < 32; i++, lram_addr += 2) {
6303 AscWriteLramWord(iop_base, lram_addr, 0);
6304 }
6305}
6306
6307static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
6308{
6309 int i;
6310 ushort warn_code;
6311 PortAddr iop_base;
6312 ASC_PADDR phy_addr;
6313 ASC_DCNT phy_size;
6314
6315 iop_base = asc_dvc->iop_base;
6316 warn_code = 0;
6317 for (i = 0; i <= ASC_MAX_TID; i++) {
6318 AscPutMCodeInitSDTRAtID(iop_base, i,
6319 asc_dvc->cfg->sdtr_period_offset[i]);
6320 }
6321
6322 AscInitQLinkVar(asc_dvc);
6323 AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
6324 asc_dvc->cfg->disc_enable);
6325 AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
6326 ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
6327
6328 /* Align overrun buffer on an 8 byte boundary. */
6329 phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
6330 phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
6331 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
6332 (uchar *)&phy_addr, 1);
6333 phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
6334 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
6335 (uchar *)&phy_size, 1);
6336
6337 asc_dvc->cfg->mcode_date =
6338 AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
6339 asc_dvc->cfg->mcode_version =
6340 AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
6341
6342 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
6343 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
6344 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
6345 return warn_code;
6346 }
6347 if (AscStartChip(iop_base) != 1) {
6348 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
6349 return warn_code;
6350 }
6351
6352 return warn_code;
6353}
6354
6355static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
6356{
6357 ushort warn_code;
6358 PortAddr iop_base;
6359
6360 iop_base = asc_dvc->iop_base;
6361 warn_code = 0;
6362 if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
6363 !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
6364 AscResetChipAndScsiBus(asc_dvc);
6365 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
6366 }
6367 asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
6368 if (asc_dvc->err_code != 0)
6369 return UW_ERR;
6370 if (!AscFindSignature(asc_dvc->iop_base)) {
6371 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
6372 return warn_code;
6373 }
6374 AscDisableInterrupt(iop_base);
6375 warn_code |= AscInitLram(asc_dvc);
6376 if (asc_dvc->err_code != 0)
6377 return UW_ERR;
b352f923 6378 ASC_DBG(1, "_asc_mcode_chksum 0x%lx\n", (ulong)_asc_mcode_chksum);
51219358
MW
6379 if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
6380 _asc_mcode_size) != _asc_mcode_chksum) {
6381 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
6382 return warn_code;
6383 }
6384 warn_code |= AscInitMicroCodeVar(asc_dvc);
6385 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
6386 AscEnableInterrupt(iop_base);
6387 return warn_code;
6388}
6389
6390/*
6391 * Load the Microcode
6392 *
6393 * Write the microcode image to RISC memory starting at address 0.
6394 *
6395 * The microcode is stored compressed in the following format:
6396 *
6397 * 254 word (508 byte) table indexed by byte code followed
6398 * by the following byte codes:
6399 *
6400 * 1-Byte Code:
6401 * 00: Emit word 0 in table.
6402 * 01: Emit word 1 in table.
6403 * .
6404 * FD: Emit word 253 in table.
6405 *
6406 * Multi-Byte Code:
6407 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
6408 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
6409 *
6410 * Returns 0 or an error if the checksum doesn't match
6411 */
6412static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
6413 int memsize, int chksum)
6414{
6415 int i, j, end, len = 0;
6416 ADV_DCNT sum;
6417
6418 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
6419
6420 for (i = 253 * 2; i < size; i++) {
6421 if (buf[i] == 0xff) {
6422 unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
6423 for (j = 0; j < buf[i + 1]; j++) {
6424 AdvWriteWordAutoIncLram(iop_base, word);
6425 len += 2;
6426 }
6427 i += 3;
6428 } else if (buf[i] == 0xfe) {
6429 unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
6430 AdvWriteWordAutoIncLram(iop_base, word);
6431 i += 2;
6432 len += 2;
6433 } else {
6434 unsigned char off = buf[i] * 2;
6435 unsigned short word = (buf[off + 1] << 8) | buf[off];
6436 AdvWriteWordAutoIncLram(iop_base, word);
6437 len += 2;
6438 }
6439 }
6440
6441 end = len;
6442
6443 while (len < memsize) {
6444 AdvWriteWordAutoIncLram(iop_base, 0);
6445 len += 2;
6446 }
6447
6448 /* Verify the microcode checksum. */
6449 sum = 0;
6450 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
6451
6452 for (len = 0; len < end; len += 2) {
6453 sum += AdvReadWordAutoIncLram(iop_base);
6454 }
6455
6456 if (sum != chksum)
6457 return ASC_IERR_MCODE_CHKSUM;
6458
6459 return 0;
6460}
6461
51219358
MW
6462static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
6463{
6464 ADV_CARR_T *carrp;
6465 ADV_SDCNT buf_size;
6466 ADV_PADDR carr_paddr;
6467
51219358
MW
6468 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
6469 asc_dvc->carr_freelist = NULL;
6470 if (carrp == asc_dvc->carrier_buf) {
6471 buf_size = ADV_CARRIER_BUFSIZE;
6472 } else {
6473 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
6474 }
6475
6476 do {
6477 /* Get physical address of the carrier 'carrp'. */
fd625f47 6478 carr_paddr = cpu_to_le32(virt_to_bus(carrp));
51219358
MW
6479
6480 buf_size -= sizeof(ADV_CARR_T);
6481
51219358
MW
6482 carrp->carr_pa = carr_paddr;
6483 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
6484
6485 /*
6486 * Insert the carrier at the beginning of the freelist.
6487 */
6488 carrp->next_vpa =
6489 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
6490 asc_dvc->carr_freelist = carrp;
6491
6492 carrp++;
6493 } while (buf_size > 0);
6494}
6495
6496/*
6497 * Send an idle command to the chip and wait for completion.
6498 *
6499 * Command completion is polled for once per microsecond.
6500 *
6501 * The function can be called from anywhere including an interrupt handler.
6502 * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
6503 * functions to prevent reentrancy.
6504 *
6505 * Return Values:
6506 * ADV_TRUE - command completed successfully
6507 * ADV_FALSE - command failed
6508 * ADV_ERROR - command timed out
6509 */
6510static int
6511AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
6512 ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
6513{
6514 int result;
6515 ADV_DCNT i, j;
6516 AdvPortAddr iop_base;
6517
6518 iop_base = asc_dvc->iop_base;
6519
6520 /*
6521 * Clear the idle command status which is set by the microcode
6522 * to a non-zero value to indicate when the command is completed.
6523 * The non-zero result is one of the IDLE_CMD_STATUS_* values
6524 */
6525 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
6526
6527 /*
6528 * Write the idle command value after the idle command parameter
6529 * has been written to avoid a race condition. If the order is not
6530 * followed, the microcode may process the idle command before the
6531 * parameters have been written to LRAM.
6532 */
6533 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
6534 cpu_to_le32(idle_cmd_parameter));
6535 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
6536
6537 /*
6538 * Tickle the RISC to tell it to process the idle command.
6539 */
6540 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
6541 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
6542 /*
6543 * Clear the tickle value. In the ASC-3550 the RISC flag
6544 * command 'clr_tickle_b' does not work unless the host
6545 * value is cleared.
6546 */
6547 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
6548 }
6549
6550 /* Wait for up to 100 millisecond for the idle command to timeout. */
6551 for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
6552 /* Poll once each microsecond for command completion. */
6553 for (j = 0; j < SCSI_US_PER_MSEC; j++) {
6554 AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
6555 result);
6556 if (result != 0)
6557 return result;
6558 udelay(1);
6559 }
6560 }
6561
6562 BUG(); /* The idle command should never timeout. */
6563 return ADV_ERROR;
6564}
6565
6566/*
6567 * Reset SCSI Bus and purge all outstanding requests.
6568 *
6569 * Return Value:
6570 * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
6571 * ADV_FALSE(0) - Microcode command failed.
6572 * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
6573 * may be hung which requires driver recovery.
6574 */
6575static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
6576{
6577 int status;
6578
6579 /*
6580 * Send the SCSI Bus Reset idle start idle command which asserts
6581 * the SCSI Bus Reset signal.
6582 */
6583 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
6584 if (status != ADV_TRUE) {
6585 return status;
6586 }
6587
6588 /*
6589 * Delay for the specified SCSI Bus Reset hold time.
6590 *
6591 * The hold time delay is done on the host because the RISC has no
6592 * microsecond accurate timer.
6593 */
6594 udelay(ASC_SCSI_RESET_HOLD_TIME_US);
6595
6596 /*
6597 * Send the SCSI Bus Reset end idle command which de-asserts
6598 * the SCSI Bus Reset signal and purges any pending requests.
6599 */
6600 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
6601 if (status != ADV_TRUE) {
6602 return status;
6603 }
6604
6605 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
6606
6607 return status;
6608}
6609
6610/*
6611 * Initialize the ASC-3550.
6612 *
6613 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
6614 *
6615 * For a non-fatal error return a warning code. If there are no warnings
6616 * then 0 is returned.
6617 *
6618 * Needed after initialization for error recovery.
6619 */
6620static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
6621{
6622 AdvPortAddr iop_base;
6623 ushort warn_code;
6624 int begin_addr;
6625 int end_addr;
6626 ushort code_sum;
6627 int word;
6628 int i;
6629 ushort scsi_cfg1;
6630 uchar tid;
6631 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
6632 ushort wdtr_able = 0, sdtr_able, tagqng_able;
6633 uchar max_cmd[ADV_MAX_TID + 1];
6634
6635 /* If there is already an error, don't continue. */
6636 if (asc_dvc->err_code != 0)
6637 return ADV_ERROR;
6638
6639 /*
6640 * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
6641 */
6642 if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
6643 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
6644 return ADV_ERROR;
6645 }
6646
6647 warn_code = 0;
6648 iop_base = asc_dvc->iop_base;
6649
6650 /*
6651 * Save the RISC memory BIOS region before writing the microcode.
6652 * The BIOS may already be loaded and using its RISC LRAM region
6653 * so its region must be saved and restored.
6654 *
6655 * Note: This code makes the assumption, which is currently true,
6656 * that a chip reset does not clear RISC LRAM.
6657 */
6658 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
6659 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
6660 bios_mem[i]);
6661 }
6662
6663 /*
6664 * Save current per TID negotiated values.
6665 */
6666 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
6667 ushort bios_version, major, minor;
6668
6669 bios_version =
6670 bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
6671 major = (bios_version >> 12) & 0xF;
6672 minor = (bios_version >> 8) & 0xF;
6673 if (major < 3 || (major == 3 && minor == 1)) {
6674 /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
6675 AdvReadWordLram(iop_base, 0x120, wdtr_able);
6676 } else {
6677 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
6678 }
6679 }
6680 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
6681 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
6682 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
6683 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
6684 max_cmd[tid]);
6685 }
6686
6687 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
6688 _adv_asc3550_size, ADV_3550_MEMSIZE,
6689 _adv_asc3550_chksum);
6690 if (asc_dvc->err_code)
6691 return ADV_ERROR;
6692
6693 /*
6694 * Restore the RISC memory BIOS region.
6695 */
6696 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
6697 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
6698 bios_mem[i]);
6699 }
6700
6701 /*
6702 * Calculate and write the microcode code checksum to the microcode
6703 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
6704 */
6705 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
6706 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
6707 code_sum = 0;
6708 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
6709 for (word = begin_addr; word < end_addr; word += 2) {
6710 code_sum += AdvReadWordAutoIncLram(iop_base);
6711 }
6712 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
6713
6714 /*
6715 * Read and save microcode version and date.
6716 */
6717 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
6718 asc_dvc->cfg->mcode_date);
6719 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
6720 asc_dvc->cfg->mcode_version);
6721
6722 /*
6723 * Set the chip type to indicate the ASC3550.
6724 */
6725 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
6726
6727 /*
6728 * If the PCI Configuration Command Register "Parity Error Response
6729 * Control" Bit was clear (0), then set the microcode variable
6730 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
6731 * to ignore DMA parity errors.
6732 */
6733 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
6734 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
6735 word |= CONTROL_FLAG_IGNORE_PERR;
6736 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
6737 }
6738
6739 /*
6740 * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
6741 * threshold of 128 bytes. This register is only accessible to the host.
6742 */
6743 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
6744 START_CTL_EMFU | READ_CMD_MRM);
6745
6746 /*
6747 * Microcode operating variables for WDTR, SDTR, and command tag
6748 * queuing will be set in slave_configure() based on what a
6749 * device reports it is capable of in Inquiry byte 7.
6750 *
6751 * If SCSI Bus Resets have been disabled, then directly set
6752 * SDTR and WDTR from the EEPROM configuration. This will allow
6753 * the BIOS and warm boot to work without a SCSI bus hang on
6754 * the Inquiry caused by host and target mismatched DTR values.
6755 * Without the SCSI Bus Reset, before an Inquiry a device can't
6756 * be assumed to be in Asynchronous, Narrow mode.
6757 */
6758 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
6759 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
6760 asc_dvc->wdtr_able);
6761 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
6762 asc_dvc->sdtr_able);
6763 }
6764
6765 /*
6766 * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
6767 * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
6768 * bitmask. These values determine the maximum SDTR speed negotiated
6769 * with a device.
6770 *
6771 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
6772 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
6773 * without determining here whether the device supports SDTR.
6774 *
6775 * 4-bit speed SDTR speed name
6776 * =========== ===============
6777 * 0000b (0x0) SDTR disabled
6778 * 0001b (0x1) 5 Mhz
6779 * 0010b (0x2) 10 Mhz
6780 * 0011b (0x3) 20 Mhz (Ultra)
6781 * 0100b (0x4) 40 Mhz (LVD/Ultra2)
6782 * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
6783 * 0110b (0x6) Undefined
6784 * .
6785 * 1111b (0xF) Undefined
6786 */
6787 word = 0;
6788 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
6789 if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
6790 /* Set Ultra speed for TID 'tid'. */
6791 word |= (0x3 << (4 * (tid % 4)));
6792 } else {
6793 /* Set Fast speed for TID 'tid'. */
6794 word |= (0x2 << (4 * (tid % 4)));
6795 }
6796 if (tid == 3) { /* Check if done with sdtr_speed1. */
6797 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
6798 word = 0;
6799 } else if (tid == 7) { /* Check if done with sdtr_speed2. */
6800 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
6801 word = 0;
6802 } else if (tid == 11) { /* Check if done with sdtr_speed3. */
6803 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
6804 word = 0;
6805 } else if (tid == 15) { /* Check if done with sdtr_speed4. */
6806 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
6807 /* End of loop. */
6808 }
6809 }
6810
6811 /*
6812 * Set microcode operating variable for the disconnect per TID bitmask.
6813 */
6814 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
6815 asc_dvc->cfg->disc_enable);
6816
6817 /*
6818 * Set SCSI_CFG0 Microcode Default Value.
6819 *
6820 * The microcode will set the SCSI_CFG0 register using this value
6821 * after it is started below.
6822 */
6823 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
6824 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
6825 asc_dvc->chip_scsi_id);
6826
6827 /*
6828 * Determine SCSI_CFG1 Microcode Default Value.
6829 *
6830 * The microcode will set the SCSI_CFG1 register using this value
6831 * after it is started below.
6832 */
6833
6834 /* Read current SCSI_CFG1 Register value. */
6835 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
6836
6837 /*
6838 * If all three connectors are in use, return an error.
6839 */
6840 if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
6841 (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
6842 asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
6843 return ADV_ERROR;
6844 }
6845
6846 /*
6847 * If the internal narrow cable is reversed all of the SCSI_CTRL
6848 * register signals will be set. Check for and return an error if
6849 * this condition is found.
6850 */
6851 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
6852 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
6853 return ADV_ERROR;
6854 }
6855
6856 /*
6857 * If this is a differential board and a single-ended device
6858 * is attached to one of the connectors, return an error.
6859 */
6860 if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
6861 asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
6862 return ADV_ERROR;
6863 }
6864
6865 /*
6866 * If automatic termination control is enabled, then set the
6867 * termination value based on a table listed in a_condor.h.
6868 *
6869 * If manual termination was specified with an EEPROM setting
6870 * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
6871 * is ready to be 'ored' into SCSI_CFG1.
6872 */
6873 if (asc_dvc->cfg->termination == 0) {
6874 /*
6875 * The software always controls termination by setting TERM_CTL_SEL.
6876 * If TERM_CTL_SEL were set to 0, the hardware would set termination.
6877 */
6878 asc_dvc->cfg->termination |= TERM_CTL_SEL;
6879
6880 switch (scsi_cfg1 & CABLE_DETECT) {
6881 /* TERM_CTL_H: on, TERM_CTL_L: on */
6882 case 0x3:
6883 case 0x7:
6884 case 0xB:
6885 case 0xD:
6886 case 0xE:
6887 case 0xF:
6888 asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
6889 break;
6890
6891 /* TERM_CTL_H: on, TERM_CTL_L: off */
6892 case 0x1:
6893 case 0x5:
6894 case 0x9:
6895 case 0xA:
6896 case 0xC:
6897 asc_dvc->cfg->termination |= TERM_CTL_H;
6898 break;
6899
6900 /* TERM_CTL_H: off, TERM_CTL_L: off */
6901 case 0x2:
6902 case 0x6:
6903 break;
6904 }
6905 }
6906
6907 /*
6908 * Clear any set TERM_CTL_H and TERM_CTL_L bits.
6909 */
6910 scsi_cfg1 &= ~TERM_CTL;
6911
6912 /*
6913 * Invert the TERM_CTL_H and TERM_CTL_L bits and then
6914 * set 'scsi_cfg1'. The TERM_POL bit does not need to be
6915 * referenced, because the hardware internally inverts
6916 * the Termination High and Low bits if TERM_POL is set.
6917 */
6918 scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
6919
6920 /*
6921 * Set SCSI_CFG1 Microcode Default Value
6922 *
6923 * Set filter value and possibly modified termination control
6924 * bits in the Microcode SCSI_CFG1 Register Value.
6925 *
6926 * The microcode will set the SCSI_CFG1 register using this value
6927 * after it is started below.
6928 */
6929 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
6930 FLTR_DISABLE | scsi_cfg1);
6931
6932 /*
6933 * Set MEM_CFG Microcode Default Value
6934 *
6935 * The microcode will set the MEM_CFG register using this value
6936 * after it is started below.
6937 *
6938 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
6939 * are defined.
6940 *
6941 * ASC-3550 has 8KB internal memory.
6942 */
6943 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
6944 BIOS_EN | RAM_SZ_8KB);
6945
6946 /*
6947 * Set SEL_MASK Microcode Default Value
6948 *
6949 * The microcode will set the SEL_MASK register using this value
6950 * after it is started below.
6951 */
6952 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
6953 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
6954
6955 AdvBuildCarrierFreelist(asc_dvc);
6956
6957 /*
6958 * Set-up the Host->RISC Initiator Command Queue (ICQ).
6959 */
6960
6961 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
6962 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
6963 return ADV_ERROR;
6964 }
6965 asc_dvc->carr_freelist = (ADV_CARR_T *)
6966 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
6967
6968 /*
6969 * The first command issued will be placed in the stopper carrier.
6970 */
6971 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
6972
6973 /*
6974 * Set RISC ICQ physical address start value.
6975 */
6976 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
6977
6978 /*
6979 * Set-up the RISC->Host Initiator Response Queue (IRQ).
6980 */
6981 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
6982 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
6983 return ADV_ERROR;
6984 }
6985 asc_dvc->carr_freelist = (ADV_CARR_T *)
6986 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
6987
6988 /*
6989 * The first command completed by the RISC will be placed in
6990 * the stopper.
6991 *
6992 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
6993 * completed the RISC will set the ASC_RQ_STOPPER bit.
6994 */
6995 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
6996
6997 /*
6998 * Set RISC IRQ physical address start value.
6999 */
7000 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
7001 asc_dvc->carr_pending_cnt = 0;
7002
7003 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
7004 (ADV_INTR_ENABLE_HOST_INTR |
7005 ADV_INTR_ENABLE_GLOBAL_INTR));
7006
7007 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
7008 AdvWriteWordRegister(iop_base, IOPW_PC, word);
7009
7010 /* finally, finally, gentlemen, start your engine */
7011 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
7012
7013 /*
7014 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
7015 * Resets should be performed. The RISC has to be running
7016 * to issue a SCSI Bus Reset.
7017 */
7018 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
7019 /*
7020 * If the BIOS Signature is present in memory, restore the
7021 * BIOS Handshake Configuration Table and do not perform
7022 * a SCSI Bus Reset.
7023 */
7024 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
7025 0x55AA) {
7026 /*
7027 * Restore per TID negotiated values.
7028 */
7029 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7030 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7031 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
7032 tagqng_able);
7033 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7034 AdvWriteByteLram(iop_base,
7035 ASC_MC_NUMBER_OF_MAX_CMD + tid,
7036 max_cmd[tid]);
7037 }
7038 } else {
7039 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
7040 warn_code = ASC_WARN_BUSRESET_ERROR;
7041 }
7042 }
7043 }
7044
7045 return warn_code;
7046}
7047
7048/*
7049 * Initialize the ASC-38C0800.
7050 *
7051 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
7052 *
7053 * For a non-fatal error return a warning code. If there are no warnings
7054 * then 0 is returned.
7055 *
7056 * Needed after initialization for error recovery.
7057 */
7058static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
7059{
7060 AdvPortAddr iop_base;
7061 ushort warn_code;
7062 int begin_addr;
7063 int end_addr;
7064 ushort code_sum;
7065 int word;
7066 int i;
7067 ushort scsi_cfg1;
7068 uchar byte;
7069 uchar tid;
7070 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
7071 ushort wdtr_able, sdtr_able, tagqng_able;
7072 uchar max_cmd[ADV_MAX_TID + 1];
7073
7074 /* If there is already an error, don't continue. */
7075 if (asc_dvc->err_code != 0)
7076 return ADV_ERROR;
7077
7078 /*
7079 * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
7080 */
7081 if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
7082 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
7083 return ADV_ERROR;
7084 }
7085
7086 warn_code = 0;
7087 iop_base = asc_dvc->iop_base;
7088
7089 /*
7090 * Save the RISC memory BIOS region before writing the microcode.
7091 * The BIOS may already be loaded and using its RISC LRAM region
7092 * so its region must be saved and restored.
7093 *
7094 * Note: This code makes the assumption, which is currently true,
7095 * that a chip reset does not clear RISC LRAM.
7096 */
7097 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7098 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7099 bios_mem[i]);
7100 }
7101
7102 /*
7103 * Save current per TID negotiated values.
7104 */
7105 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7106 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7107 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
7108 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7109 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
7110 max_cmd[tid]);
7111 }
7112
7113 /*
7114 * RAM BIST (RAM Built-In Self Test)
7115 *
7116 * Address : I/O base + offset 0x38h register (byte).
7117 * Function: Bit 7-6(RW) : RAM mode
7118 * Normal Mode : 0x00
7119 * Pre-test Mode : 0x40
7120 * RAM Test Mode : 0x80
7121 * Bit 5 : unused
7122 * Bit 4(RO) : Done bit
7123 * Bit 3-0(RO) : Status
7124 * Host Error : 0x08
7125 * Int_RAM Error : 0x04
7126 * RISC Error : 0x02
7127 * SCSI Error : 0x01
7128 * No Error : 0x00
7129 *
7130 * Note: RAM BIST code should be put right here, before loading the
7131 * microcode and after saving the RISC memory BIOS region.
7132 */
7133
7134 /*
7135 * LRAM Pre-test
7136 *
7137 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
7138 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
7139 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
7140 * to NORMAL_MODE, return an error too.
7141 */
7142 for (i = 0; i < 2; i++) {
7143 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
7144 mdelay(10); /* Wait for 10ms before reading back. */
7145 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7146 if ((byte & RAM_TEST_DONE) == 0
7147 || (byte & 0x0F) != PRE_TEST_VALUE) {
7148 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
7149 return ADV_ERROR;
7150 }
7151
7152 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
7153 mdelay(10); /* Wait for 10ms before reading back. */
7154 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
7155 != NORMAL_VALUE) {
7156 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
7157 return ADV_ERROR;
7158 }
7159 }
7160
7161 /*
7162 * LRAM Test - It takes about 1.5 ms to run through the test.
7163 *
7164 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
7165 * If Done bit not set or Status not 0, save register byte, set the
7166 * err_code, and return an error.
7167 */
7168 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
7169 mdelay(10); /* Wait for 10ms before checking status. */
7170
7171 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7172 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
7173 /* Get here if Done bit not set or Status not 0. */
7174 asc_dvc->bist_err_code = byte; /* for BIOS display message */
7175 asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
7176 return ADV_ERROR;
7177 }
7178
7179 /* We need to reset back to normal mode after LRAM test passes. */
7180 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
7181
7182 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
7183 _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
7184 _adv_asc38C0800_chksum);
7185 if (asc_dvc->err_code)
7186 return ADV_ERROR;
7187
7188 /*
7189 * Restore the RISC memory BIOS region.
7190 */
7191 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7192 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7193 bios_mem[i]);
7194 }
7195
7196 /*
7197 * Calculate and write the microcode code checksum to the microcode
7198 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
7199 */
7200 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
7201 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
7202 code_sum = 0;
7203 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
7204 for (word = begin_addr; word < end_addr; word += 2) {
7205 code_sum += AdvReadWordAutoIncLram(iop_base);
7206 }
7207 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
7208
7209 /*
7210 * Read microcode version and date.
7211 */
7212 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
7213 asc_dvc->cfg->mcode_date);
7214 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
7215 asc_dvc->cfg->mcode_version);
7216
7217 /*
7218 * Set the chip type to indicate the ASC38C0800.
7219 */
7220 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
7221
7222 /*
7223 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
7224 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
7225 * cable detection and then we are able to read C_DET[3:0].
7226 *
7227 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
7228 * Microcode Default Value' section below.
7229 */
7230 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
7231 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
7232 scsi_cfg1 | DIS_TERM_DRV);
7233
7234 /*
7235 * If the PCI Configuration Command Register "Parity Error Response
7236 * Control" Bit was clear (0), then set the microcode variable
7237 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
7238 * to ignore DMA parity errors.
7239 */
7240 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
7241 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7242 word |= CONTROL_FLAG_IGNORE_PERR;
7243 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7244 }
7245
7246 /*
7247 * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
7248 * bits for the default FIFO threshold.
7249 *
7250 * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
7251 *
7252 * For DMA Errata #4 set the BC_THRESH_ENB bit.
7253 */
7254 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
7255 BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
7256 READ_CMD_MRM);
7257
7258 /*
7259 * Microcode operating variables for WDTR, SDTR, and command tag
7260 * queuing will be set in slave_configure() based on what a
7261 * device reports it is capable of in Inquiry byte 7.
7262 *
7263 * If SCSI Bus Resets have been disabled, then directly set
7264 * SDTR and WDTR from the EEPROM configuration. This will allow
7265 * the BIOS and warm boot to work without a SCSI bus hang on
7266 * the Inquiry caused by host and target mismatched DTR values.
7267 * Without the SCSI Bus Reset, before an Inquiry a device can't
7268 * be assumed to be in Asynchronous, Narrow mode.
7269 */
7270 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
7271 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
7272 asc_dvc->wdtr_able);
7273 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
7274 asc_dvc->sdtr_able);
7275 }
7276
7277 /*
7278 * Set microcode operating variables for DISC and SDTR_SPEED1,
7279 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
7280 * configuration values.
7281 *
7282 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
7283 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
7284 * without determining here whether the device supports SDTR.
7285 */
7286 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
7287 asc_dvc->cfg->disc_enable);
7288 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
7289 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
7290 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
7291 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
7292
7293 /*
7294 * Set SCSI_CFG0 Microcode Default Value.
7295 *
7296 * The microcode will set the SCSI_CFG0 register using this value
7297 * after it is started below.
7298 */
7299 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
7300 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
7301 asc_dvc->chip_scsi_id);
7302
7303 /*
7304 * Determine SCSI_CFG1 Microcode Default Value.
7305 *
7306 * The microcode will set the SCSI_CFG1 register using this value
7307 * after it is started below.
7308 */
7309
7310 /* Read current SCSI_CFG1 Register value. */
7311 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
7312
7313 /*
7314 * If the internal narrow cable is reversed all of the SCSI_CTRL
7315 * register signals will be set. Check for and return an error if
7316 * this condition is found.
7317 */
7318 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
7319 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
7320 return ADV_ERROR;
7321 }
7322
7323 /*
7324 * All kind of combinations of devices attached to one of four
7325 * connectors are acceptable except HVD device attached. For example,
7326 * LVD device can be attached to SE connector while SE device attached
7327 * to LVD connector. If LVD device attached to SE connector, it only
7328 * runs up to Ultra speed.
7329 *
7330 * If an HVD device is attached to one of LVD connectors, return an
7331 * error. However, there is no way to detect HVD device attached to
7332 * SE connectors.
7333 */
7334 if (scsi_cfg1 & HVD) {
7335 asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
7336 return ADV_ERROR;
7337 }
7338
7339 /*
7340 * If either SE or LVD automatic termination control is enabled, then
7341 * set the termination value based on a table listed in a_condor.h.
7342 *
7343 * If manual termination was specified with an EEPROM setting then
7344 * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
7345 * to be 'ored' into SCSI_CFG1.
7346 */
7347 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
7348 /* SE automatic termination control is enabled. */
7349 switch (scsi_cfg1 & C_DET_SE) {
7350 /* TERM_SE_HI: on, TERM_SE_LO: on */
7351 case 0x1:
7352 case 0x2:
7353 case 0x3:
7354 asc_dvc->cfg->termination |= TERM_SE;
7355 break;
7356
7357 /* TERM_SE_HI: on, TERM_SE_LO: off */
7358 case 0x0:
7359 asc_dvc->cfg->termination |= TERM_SE_HI;
7360 break;
7361 }
7362 }
7363
7364 if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
7365 /* LVD automatic termination control is enabled. */
7366 switch (scsi_cfg1 & C_DET_LVD) {
7367 /* TERM_LVD_HI: on, TERM_LVD_LO: on */
7368 case 0x4:
7369 case 0x8:
7370 case 0xC:
7371 asc_dvc->cfg->termination |= TERM_LVD;
7372 break;
7373
7374 /* TERM_LVD_HI: off, TERM_LVD_LO: off */
7375 case 0x0:
7376 break;
7377 }
7378 }
7379
7380 /*
7381 * Clear any set TERM_SE and TERM_LVD bits.
7382 */
7383 scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
7384
7385 /*
7386 * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
7387 */
7388 scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
7389
7390 /*
7391 * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
7392 * bits and set possibly modified termination control bits in the
7393 * Microcode SCSI_CFG1 Register Value.
7394 */
7395 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
7396
7397 /*
7398 * Set SCSI_CFG1 Microcode Default Value
7399 *
7400 * Set possibly modified termination control and reset DIS_TERM_DRV
7401 * bits in the Microcode SCSI_CFG1 Register Value.
7402 *
7403 * The microcode will set the SCSI_CFG1 register using this value
7404 * after it is started below.
7405 */
7406 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
7407
7408 /*
7409 * Set MEM_CFG Microcode Default Value
7410 *
7411 * The microcode will set the MEM_CFG register using this value
7412 * after it is started below.
7413 *
7414 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
7415 * are defined.
7416 *
7417 * ASC-38C0800 has 16KB internal memory.
7418 */
7419 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
7420 BIOS_EN | RAM_SZ_16KB);
7421
7422 /*
7423 * Set SEL_MASK Microcode Default Value
7424 *
7425 * The microcode will set the SEL_MASK register using this value
7426 * after it is started below.
7427 */
7428 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
7429 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
7430
7431 AdvBuildCarrierFreelist(asc_dvc);
7432
7433 /*
7434 * Set-up the Host->RISC Initiator Command Queue (ICQ).
7435 */
7436
7437 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
7438 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7439 return ADV_ERROR;
7440 }
7441 asc_dvc->carr_freelist = (ADV_CARR_T *)
7442 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
7443
7444 /*
7445 * The first command issued will be placed in the stopper carrier.
7446 */
7447 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
7448
7449 /*
7450 * Set RISC ICQ physical address start value.
7451 * carr_pa is LE, must be native before write
7452 */
7453 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
7454
7455 /*
7456 * Set-up the RISC->Host Initiator Response Queue (IRQ).
7457 */
7458 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
7459 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7460 return ADV_ERROR;
7461 }
7462 asc_dvc->carr_freelist = (ADV_CARR_T *)
7463 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
7464
7465 /*
7466 * The first command completed by the RISC will be placed in
7467 * the stopper.
7468 *
7469 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
7470 * completed the RISC will set the ASC_RQ_STOPPER bit.
7471 */
7472 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
7473
7474 /*
7475 * Set RISC IRQ physical address start value.
7476 *
7477 * carr_pa is LE, must be native before write *
7478 */
7479 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
7480 asc_dvc->carr_pending_cnt = 0;
7481
7482 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
7483 (ADV_INTR_ENABLE_HOST_INTR |
7484 ADV_INTR_ENABLE_GLOBAL_INTR));
7485
7486 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
7487 AdvWriteWordRegister(iop_base, IOPW_PC, word);
7488
7489 /* finally, finally, gentlemen, start your engine */
7490 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
7491
7492 /*
7493 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
7494 * Resets should be performed. The RISC has to be running
7495 * to issue a SCSI Bus Reset.
7496 */
7497 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
7498 /*
7499 * If the BIOS Signature is present in memory, restore the
7500 * BIOS Handshake Configuration Table and do not perform
7501 * a SCSI Bus Reset.
7502 */
7503 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
7504 0x55AA) {
7505 /*
7506 * Restore per TID negotiated values.
7507 */
7508 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7509 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7510 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
7511 tagqng_able);
7512 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7513 AdvWriteByteLram(iop_base,
7514 ASC_MC_NUMBER_OF_MAX_CMD + tid,
7515 max_cmd[tid]);
7516 }
7517 } else {
7518 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
7519 warn_code = ASC_WARN_BUSRESET_ERROR;
7520 }
7521 }
7522 }
7523
7524 return warn_code;
7525}
7526
7527/*
7528 * Initialize the ASC-38C1600.
7529 *
7530 * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
7531 *
7532 * For a non-fatal error return a warning code. If there are no warnings
7533 * then 0 is returned.
7534 *
7535 * Needed after initialization for error recovery.
7536 */
7537static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
7538{
7539 AdvPortAddr iop_base;
7540 ushort warn_code;
7541 int begin_addr;
7542 int end_addr;
7543 ushort code_sum;
7544 long word;
7545 int i;
7546 ushort scsi_cfg1;
7547 uchar byte;
7548 uchar tid;
7549 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
7550 ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
7551 uchar max_cmd[ASC_MAX_TID + 1];
7552
7553 /* If there is already an error, don't continue. */
7554 if (asc_dvc->err_code != 0) {
7555 return ADV_ERROR;
7556 }
7557
7558 /*
7559 * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
7560 */
7561 if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
7562 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
7563 return ADV_ERROR;
7564 }
7565
7566 warn_code = 0;
7567 iop_base = asc_dvc->iop_base;
7568
7569 /*
7570 * Save the RISC memory BIOS region before writing the microcode.
7571 * The BIOS may already be loaded and using its RISC LRAM region
7572 * so its region must be saved and restored.
7573 *
7574 * Note: This code makes the assumption, which is currently true,
7575 * that a chip reset does not clear RISC LRAM.
7576 */
7577 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7578 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7579 bios_mem[i]);
7580 }
7581
7582 /*
7583 * Save current per TID negotiated values.
7584 */
7585 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7586 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7587 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
7588 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
7589 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
7590 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
7591 max_cmd[tid]);
7592 }
7593
7594 /*
7595 * RAM BIST (Built-In Self Test)
7596 *
7597 * Address : I/O base + offset 0x38h register (byte).
7598 * Function: Bit 7-6(RW) : RAM mode
7599 * Normal Mode : 0x00
7600 * Pre-test Mode : 0x40
7601 * RAM Test Mode : 0x80
7602 * Bit 5 : unused
7603 * Bit 4(RO) : Done bit
7604 * Bit 3-0(RO) : Status
7605 * Host Error : 0x08
7606 * Int_RAM Error : 0x04
7607 * RISC Error : 0x02
7608 * SCSI Error : 0x01
7609 * No Error : 0x00
7610 *
7611 * Note: RAM BIST code should be put right here, before loading the
7612 * microcode and after saving the RISC memory BIOS region.
7613 */
7614
7615 /*
7616 * LRAM Pre-test
7617 *
7618 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
7619 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
7620 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
7621 * to NORMAL_MODE, return an error too.
7622 */
7623 for (i = 0; i < 2; i++) {
7624 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
7625 mdelay(10); /* Wait for 10ms before reading back. */
7626 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7627 if ((byte & RAM_TEST_DONE) == 0
7628 || (byte & 0x0F) != PRE_TEST_VALUE) {
7629 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
7630 return ADV_ERROR;
7631 }
7632
7633 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
7634 mdelay(10); /* Wait for 10ms before reading back. */
7635 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
7636 != NORMAL_VALUE) {
7637 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
7638 return ADV_ERROR;
7639 }
7640 }
7641
7642 /*
7643 * LRAM Test - It takes about 1.5 ms to run through the test.
7644 *
7645 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
7646 * If Done bit not set or Status not 0, save register byte, set the
7647 * err_code, and return an error.
7648 */
7649 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
7650 mdelay(10); /* Wait for 10ms before checking status. */
7651
7652 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7653 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
7654 /* Get here if Done bit not set or Status not 0. */
7655 asc_dvc->bist_err_code = byte; /* for BIOS display message */
7656 asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
7657 return ADV_ERROR;
7658 }
7659
7660 /* We need to reset back to normal mode after LRAM test passes. */
7661 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
7662
7663 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
7664 _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
7665 _adv_asc38C1600_chksum);
7666 if (asc_dvc->err_code)
7667 return ADV_ERROR;
7668
7669 /*
7670 * Restore the RISC memory BIOS region.
7671 */
7672 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7673 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7674 bios_mem[i]);
7675 }
7676
7677 /*
7678 * Calculate and write the microcode code checksum to the microcode
7679 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
7680 */
7681 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
7682 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
7683 code_sum = 0;
7684 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
7685 for (word = begin_addr; word < end_addr; word += 2) {
7686 code_sum += AdvReadWordAutoIncLram(iop_base);
7687 }
7688 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
7689
7690 /*
7691 * Read microcode version and date.
7692 */
7693 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
7694 asc_dvc->cfg->mcode_date);
7695 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
7696 asc_dvc->cfg->mcode_version);
7697
7698 /*
7699 * Set the chip type to indicate the ASC38C1600.
7700 */
7701 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
7702
7703 /*
7704 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
7705 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
7706 * cable detection and then we are able to read C_DET[3:0].
7707 *
7708 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
7709 * Microcode Default Value' section below.
7710 */
7711 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
7712 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
7713 scsi_cfg1 | DIS_TERM_DRV);
7714
7715 /*
7716 * If the PCI Configuration Command Register "Parity Error Response
7717 * Control" Bit was clear (0), then set the microcode variable
7718 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
7719 * to ignore DMA parity errors.
7720 */
7721 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
7722 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7723 word |= CONTROL_FLAG_IGNORE_PERR;
7724 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7725 }
7726
7727 /*
7728 * If the BIOS control flag AIPP (Asynchronous Information
7729 * Phase Protection) disable bit is not set, then set the firmware
7730 * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
7731 * AIPP checking and encoding.
7732 */
7733 if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
7734 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7735 word |= CONTROL_FLAG_ENABLE_AIPP;
7736 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7737 }
7738
7739 /*
7740 * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
7741 * and START_CTL_TH [3:2].
7742 */
7743 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
7744 FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
7745
7746 /*
7747 * Microcode operating variables for WDTR, SDTR, and command tag
7748 * queuing will be set in slave_configure() based on what a
7749 * device reports it is capable of in Inquiry byte 7.
7750 *
7751 * If SCSI Bus Resets have been disabled, then directly set
7752 * SDTR and WDTR from the EEPROM configuration. This will allow
7753 * the BIOS and warm boot to work without a SCSI bus hang on
7754 * the Inquiry caused by host and target mismatched DTR values.
7755 * Without the SCSI Bus Reset, before an Inquiry a device can't
7756 * be assumed to be in Asynchronous, Narrow mode.
7757 */
7758 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
7759 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
7760 asc_dvc->wdtr_able);
7761 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
7762 asc_dvc->sdtr_able);
7763 }
7764
7765 /*
7766 * Set microcode operating variables for DISC and SDTR_SPEED1,
7767 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
7768 * configuration values.
7769 *
7770 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
7771 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
7772 * without determining here whether the device supports SDTR.
7773 */
7774 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
7775 asc_dvc->cfg->disc_enable);
7776 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
7777 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
7778 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
7779 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
7780
7781 /*
7782 * Set SCSI_CFG0 Microcode Default Value.
7783 *
7784 * The microcode will set the SCSI_CFG0 register using this value
7785 * after it is started below.
7786 */
7787 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
7788 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
7789 asc_dvc->chip_scsi_id);
7790
7791 /*
7792 * Calculate SCSI_CFG1 Microcode Default Value.
7793 *
7794 * The microcode will set the SCSI_CFG1 register using this value
7795 * after it is started below.
7796 *
7797 * Each ASC-38C1600 function has only two cable detect bits.
7798 * The bus mode override bits are in IOPB_SOFT_OVER_WR.
7799 */
7800 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
7801
7802 /*
7803 * If the cable is reversed all of the SCSI_CTRL register signals
7804 * will be set. Check for and return an error if this condition is
7805 * found.
7806 */
7807 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
7808 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
7809 return ADV_ERROR;
7810 }
7811
7812 /*
7813 * Each ASC-38C1600 function has two connectors. Only an HVD device
7814 * can not be connected to either connector. An LVD device or SE device
7815 * may be connected to either connecor. If an SE device is connected,
7816 * then at most Ultra speed (20 Mhz) can be used on both connectors.
7817 *
7818 * If an HVD device is attached, return an error.
7819 */
7820 if (scsi_cfg1 & HVD) {
7821 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
7822 return ADV_ERROR;
7823 }
7824
7825 /*
7826 * Each function in the ASC-38C1600 uses only the SE cable detect and
7827 * termination because there are two connectors for each function. Each
7828 * function may use either LVD or SE mode. Corresponding the SE automatic
7829 * termination control EEPROM bits are used for each function. Each
7830 * function has its own EEPROM. If SE automatic control is enabled for
7831 * the function, then set the termination value based on a table listed
7832 * in a_condor.h.
7833 *
7834 * If manual termination is specified in the EEPROM for the function,
7835 * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
7836 * ready to be 'ored' into SCSI_CFG1.
7837 */
7838 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
7839 struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
7840 /* SE automatic termination control is enabled. */
7841 switch (scsi_cfg1 & C_DET_SE) {
7842 /* TERM_SE_HI: on, TERM_SE_LO: on */
7843 case 0x1:
7844 case 0x2:
7845 case 0x3:
7846 asc_dvc->cfg->termination |= TERM_SE;
7847 break;
7848
7849 case 0x0:
7850 if (PCI_FUNC(pdev->devfn) == 0) {
7851 /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
7852 } else {
7853 /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
7854 asc_dvc->cfg->termination |= TERM_SE_HI;
7855 }
7856 break;
7857 }
7858 }
7859
7860 /*
7861 * Clear any set TERM_SE bits.
7862 */
7863 scsi_cfg1 &= ~TERM_SE;
7864
7865 /*
7866 * Invert the TERM_SE bits and then set 'scsi_cfg1'.
7867 */
7868 scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
7869
7870 /*
7871 * Clear Big Endian and Terminator Polarity bits and set possibly
7872 * modified termination control bits in the Microcode SCSI_CFG1
7873 * Register Value.
7874 *
7875 * Big Endian bit is not used even on big endian machines.
7876 */
7877 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
7878
7879 /*
7880 * Set SCSI_CFG1 Microcode Default Value
7881 *
7882 * Set possibly modified termination control bits in the Microcode
7883 * SCSI_CFG1 Register Value.
7884 *
7885 * The microcode will set the SCSI_CFG1 register using this value
7886 * after it is started below.
7887 */
7888 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
7889
7890 /*
7891 * Set MEM_CFG Microcode Default Value
7892 *
7893 * The microcode will set the MEM_CFG register using this value
7894 * after it is started below.
7895 *
7896 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
7897 * are defined.
7898 *
7899 * ASC-38C1600 has 32KB internal memory.
7900 *
7901 * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
7902 * out a special 16K Adv Library and Microcode version. After the issue
7903 * resolved, we should turn back to the 32K support. Both a_condor.h and
7904 * mcode.sas files also need to be updated.
7905 *
7906 * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
7907 * BIOS_EN | RAM_SZ_32KB);
7908 */
7909 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
7910 BIOS_EN | RAM_SZ_16KB);
7911
7912 /*
7913 * Set SEL_MASK Microcode Default Value
7914 *
7915 * The microcode will set the SEL_MASK register using this value
7916 * after it is started below.
7917 */
7918 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
7919 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
7920
7921 AdvBuildCarrierFreelist(asc_dvc);
7922
7923 /*
7924 * Set-up the Host->RISC Initiator Command Queue (ICQ).
7925 */
7926 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
7927 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7928 return ADV_ERROR;
7929 }
7930 asc_dvc->carr_freelist = (ADV_CARR_T *)
7931 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
7932
7933 /*
7934 * The first command issued will be placed in the stopper carrier.
7935 */
7936 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
7937
7938 /*
7939 * Set RISC ICQ physical address start value. Initialize the
7940 * COMMA register to the same value otherwise the RISC will
7941 * prematurely detect a command is available.
7942 */
7943 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
7944 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
7945 le32_to_cpu(asc_dvc->icq_sp->carr_pa));
7946
7947 /*
7948 * Set-up the RISC->Host Initiator Response Queue (IRQ).
7949 */
7950 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
7951 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7952 return ADV_ERROR;
7953 }
7954 asc_dvc->carr_freelist = (ADV_CARR_T *)
7955 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
7956
7957 /*
7958 * The first command completed by the RISC will be placed in
7959 * the stopper.
7960 *
7961 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
7962 * completed the RISC will set the ASC_RQ_STOPPER bit.
7963 */
7964 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
7965
7966 /*
7967 * Set RISC IRQ physical address start value.
7968 */
7969 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
7970 asc_dvc->carr_pending_cnt = 0;
7971
7972 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
7973 (ADV_INTR_ENABLE_HOST_INTR |
7974 ADV_INTR_ENABLE_GLOBAL_INTR));
7975 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
7976 AdvWriteWordRegister(iop_base, IOPW_PC, word);
7977
7978 /* finally, finally, gentlemen, start your engine */
7979 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
7980
7981 /*
7982 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
7983 * Resets should be performed. The RISC has to be running
7984 * to issue a SCSI Bus Reset.
7985 */
7986 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
7987 /*
7988 * If the BIOS Signature is present in memory, restore the
7989 * per TID microcode operating variables.
7990 */
7991 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
7992 0x55AA) {
7993 /*
7994 * Restore per TID negotiated values.
7995 */
7996 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7997 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7998 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
7999 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
8000 tagqng_able);
8001 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
8002 AdvWriteByteLram(iop_base,
8003 ASC_MC_NUMBER_OF_MAX_CMD + tid,
8004 max_cmd[tid]);
8005 }
8006 } else {
8007 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
8008 warn_code = ASC_WARN_BUSRESET_ERROR;
8009 }
8010 }
8011 }
8012
8013 return warn_code;
8014}
8015
8016/*
8017 * Reset chip and SCSI Bus.
8018 *
8019 * Return Value:
8020 * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
8021 * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
8022 */
8023static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
8024{
8025 int status;
8026 ushort wdtr_able, sdtr_able, tagqng_able;
8027 ushort ppr_able = 0;
8028 uchar tid, max_cmd[ADV_MAX_TID + 1];
8029 AdvPortAddr iop_base;
8030 ushort bios_sig;
8031
8032 iop_base = asc_dvc->iop_base;
8033
8034 /*
8035 * Save current per TID negotiated values.
8036 */
8037 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8038 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8039 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8040 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
8041 }
8042 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
8043 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
8044 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
8045 max_cmd[tid]);
8046 }
8047
8048 /*
8049 * Force the AdvInitAsc3550/38C0800Driver() function to
8050 * perform a SCSI Bus Reset by clearing the BIOS signature word.
8051 * The initialization functions assumes a SCSI Bus Reset is not
8052 * needed if the BIOS signature word is present.
8053 */
8054 AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
8055 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
8056
8057 /*
8058 * Stop chip and reset it.
8059 */
8060 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
8061 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
8062 mdelay(100);
8063 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
8064 ADV_CTRL_REG_CMD_WR_IO_REG);
8065
8066 /*
8067 * Reset Adv Library error code, if any, and try
8068 * re-initializing the chip.
8069 */
8070 asc_dvc->err_code = 0;
8071 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8072 status = AdvInitAsc38C1600Driver(asc_dvc);
8073 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
8074 status = AdvInitAsc38C0800Driver(asc_dvc);
8075 } else {
8076 status = AdvInitAsc3550Driver(asc_dvc);
8077 }
8078
8079 /* Translate initialization return value to status value. */
8080 if (status == 0) {
8081 status = ADV_TRUE;
8082 } else {
8083 status = ADV_FALSE;
8084 }
8085
8086 /*
8087 * Restore the BIOS signature word.
8088 */
8089 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
8090
8091 /*
8092 * Restore per TID negotiated values.
8093 */
8094 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8095 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8096 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8097 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
8098 }
8099 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
8100 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
8101 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
8102 max_cmd[tid]);
8103 }
8104
8105 return status;
8106}
8107
8108/*
8109 * adv_async_callback() - Adv Library asynchronous event callback function.
8110 */
8111static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
8112{
8113 switch (code) {
8114 case ADV_ASYNC_SCSI_BUS_RESET_DET:
8115 /*
8116 * The firmware detected a SCSI Bus reset.
8117 */
b352f923 8118 ASC_DBG(0, "ADV_ASYNC_SCSI_BUS_RESET_DET\n");
51219358
MW
8119 break;
8120
8121 case ADV_ASYNC_RDMA_FAILURE:
8122 /*
8123 * Handle RDMA failure by resetting the SCSI Bus and
8124 * possibly the chip if it is unresponsive. Log the error
8125 * with a unique code.
8126 */
b352f923 8127 ASC_DBG(0, "ADV_ASYNC_RDMA_FAILURE\n");
51219358
MW
8128 AdvResetChipAndSB(adv_dvc_varp);
8129 break;
8130
8131 case ADV_HOST_SCSI_BUS_RESET:
8132 /*
8133 * Host generated SCSI bus reset occurred.
8134 */
b352f923 8135 ASC_DBG(0, "ADV_HOST_SCSI_BUS_RESET\n");
51219358
MW
8136 break;
8137
8138 default:
b352f923 8139 ASC_DBG(0, "unknown code 0x%x\n", code);
51219358
MW
8140 break;
8141 }
8142}
8143
8144/*
8145 * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
8146 *
8147 * Callback function for the Wide SCSI Adv Library.
8148 */
8149static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
8150{
d2411495 8151 struct asc_board *boardp;
51219358
MW
8152 adv_req_t *reqp;
8153 adv_sgblk_t *sgblkp;
8154 struct scsi_cmnd *scp;
8155 struct Scsi_Host *shost;
8156 ADV_DCNT resid_cnt;
8157
b352f923 8158 ASC_DBG(1, "adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
51219358
MW
8159 (ulong)adv_dvc_varp, (ulong)scsiqp);
8160 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
8161
8162 /*
8163 * Get the adv_req_t structure for the command that has been
8164 * completed. The adv_req_t structure actually contains the
8165 * completed ADV_SCSI_REQ_Q structure.
8166 */
8167 reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
b352f923 8168 ASC_DBG(1, "reqp 0x%lx\n", (ulong)reqp);
51219358
MW
8169 if (reqp == NULL) {
8170 ASC_PRINT("adv_isr_callback: reqp is NULL\n");
8171 return;
8172 }
8173
8174 /*
8175 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
8176 * command that has been completed.
8177 *
8178 * Note: The adv_req_t request structure and adv_sgblk_t structure,
8179 * if any, are dropped, because a board structure pointer can not be
8180 * determined.
8181 */
8182 scp = reqp->cmndp;
b352f923 8183 ASC_DBG(1, "scp 0x%p\n", scp);
51219358
MW
8184 if (scp == NULL) {
8185 ASC_PRINT
8186 ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
8187 return;
8188 }
8189 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
8190
8191 shost = scp->device->host;
8192 ASC_STATS(shost, callback);
b352f923 8193 ASC_DBG(1, "shost 0x%p\n", shost);
51219358 8194
d2411495 8195 boardp = shost_priv(shost);
51219358
MW
8196 BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
8197
8198 /*
8199 * 'done_status' contains the command's ending status.
8200 */
8201 switch (scsiqp->done_status) {
8202 case QD_NO_ERROR:
b352f923 8203 ASC_DBG(2, "QD_NO_ERROR\n");
51219358
MW
8204 scp->result = 0;
8205
8206 /*
8207 * Check for an underrun condition.
8208 *
8209 * If there was no error and an underrun condition, then
8210 * then return the number of underrun bytes.
8211 */
8212 resid_cnt = le32_to_cpu(scsiqp->data_cnt);
8213 if (scp->request_bufflen != 0 && resid_cnt != 0 &&
8214 resid_cnt <= scp->request_bufflen) {
b352f923 8215 ASC_DBG(1, "underrun condition %lu bytes\n",
51219358
MW
8216 (ulong)resid_cnt);
8217 scp->resid = resid_cnt;
8218 }
8219 break;
8220
8221 case QD_WITH_ERROR:
b352f923 8222 ASC_DBG(2, "QD_WITH_ERROR\n");
51219358
MW
8223 switch (scsiqp->host_status) {
8224 case QHSTA_NO_ERROR:
8225 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
b352f923 8226 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
51219358
MW
8227 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
8228 sizeof(scp->sense_buffer));
8229 /*
8230 * Note: The 'status_byte()' macro used by
8231 * target drivers defined in scsi.h shifts the
8232 * status byte returned by host drivers right
8233 * by 1 bit. This is why target drivers also
8234 * use right shifted status byte definitions.
8235 * For instance target drivers use
8236 * CHECK_CONDITION, defined to 0x1, instead of
8237 * the SCSI defined check condition value of
8238 * 0x2. Host drivers are supposed to return
8239 * the status byte as it is defined by SCSI.
8240 */
8241 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
8242 STATUS_BYTE(scsiqp->scsi_status);
8243 } else {
8244 scp->result = STATUS_BYTE(scsiqp->scsi_status);
8245 }
8246 break;
8247
8248 default:
8249 /* Some other QHSTA error occurred. */
b352f923 8250 ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status);
51219358
MW
8251 scp->result = HOST_BYTE(DID_BAD_TARGET);
8252 break;
8253 }
8254 break;
8255
8256 case QD_ABORTED_BY_HOST:
b352f923 8257 ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
51219358
MW
8258 scp->result =
8259 HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
8260 break;
8261
8262 default:
b352f923 8263 ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status);
51219358
MW
8264 scp->result =
8265 HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
8266 break;
8267 }
8268
8269 /*
8270 * If the 'init_tidmask' bit isn't already set for the target and the
8271 * current request finished normally, then set the bit for the target
8272 * to indicate that a device is present.
8273 */
8274 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
8275 scsiqp->done_status == QD_NO_ERROR &&
8276 scsiqp->host_status == QHSTA_NO_ERROR) {
8277 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
8278 }
8279
8280 asc_scsi_done(scp);
8281
8282 /*
8283 * Free all 'adv_sgblk_t' structures allocated for the request.
8284 */
8285 while ((sgblkp = reqp->sgblkp) != NULL) {
8286 /* Remove 'sgblkp' from the request list. */
8287 reqp->sgblkp = sgblkp->next_sgblkp;
8288
8289 /* Add 'sgblkp' to the board free list. */
8290 sgblkp->next_sgblkp = boardp->adv_sgblkp;
8291 boardp->adv_sgblkp = sgblkp;
8292 }
8293
8294 /*
8295 * Free the adv_req_t structure used with the command by adding
8296 * it back to the board free list.
8297 */
8298 reqp->next_reqp = boardp->adv_reqp;
8299 boardp->adv_reqp = reqp;
8300
b352f923 8301 ASC_DBG(1, "done\n");
51219358
MW
8302}
8303
8304/*
8305 * Adv Library Interrupt Service Routine
8306 *
8307 * This function is called by a driver's interrupt service routine.
8308 * The function disables and re-enables interrupts.
8309 *
8310 * When a microcode idle command is completed, the ADV_DVC_VAR
8311 * 'idle_cmd_done' field is set to ADV_TRUE.
8312 *
8313 * Note: AdvISR() can be called when interrupts are disabled or even
8314 * when there is no hardware interrupt condition present. It will
8315 * always check for completed idle commands and microcode requests.
8316 * This is an important feature that shouldn't be changed because it
8317 * allows commands to be completed from polling mode loops.
8318 *
8319 * Return:
8320 * ADV_TRUE(1) - interrupt was pending
8321 * ADV_FALSE(0) - no interrupt was pending
8322 */
8323static int AdvISR(ADV_DVC_VAR *asc_dvc)
8324{
8325 AdvPortAddr iop_base;
8326 uchar int_stat;
8327 ushort target_bit;
8328 ADV_CARR_T *free_carrp;
8329 ADV_VADDR irq_next_vpa;
8330 ADV_SCSI_REQ_Q *scsiq;
8331
8332 iop_base = asc_dvc->iop_base;
8333
8334 /* Reading the register clears the interrupt. */
8335 int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
8336
8337 if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
8338 ADV_INTR_STATUS_INTRC)) == 0) {
8339 return ADV_FALSE;
8340 }
8341
8342 /*
8343 * Notify the driver of an asynchronous microcode condition by
8344 * calling the adv_async_callback function. The function
8345 * is passed the microcode ASC_MC_INTRB_CODE byte value.
8346 */
8347 if (int_stat & ADV_INTR_STATUS_INTRB) {
8348 uchar intrb_code;
8349
8350 AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
8351
8352 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
8353 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
8354 if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
8355 asc_dvc->carr_pending_cnt != 0) {
8356 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
8357 ADV_TICKLE_A);
8358 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
8359 AdvWriteByteRegister(iop_base,
8360 IOPB_TICKLE,
8361 ADV_TICKLE_NOP);
8362 }
8363 }
8364 }
8365
8366 adv_async_callback(asc_dvc, intrb_code);
8367 }
8368
8369 /*
8370 * Check if the IRQ stopper carrier contains a completed request.
8371 */
8372 while (((irq_next_vpa =
8373 le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
8374 /*
8375 * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
8376 * The RISC will have set 'areq_vpa' to a virtual address.
8377 *
8378 * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
8379 * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
8380 * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
8381 * in AdvExeScsiQueue().
8382 */
8383 scsiq = (ADV_SCSI_REQ_Q *)
8384 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
8385
8386 /*
8387 * Request finished with good status and the queue was not
8388 * DMAed to host memory by the firmware. Set all status fields
8389 * to indicate good status.
8390 */
8391 if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
8392 scsiq->done_status = QD_NO_ERROR;
8393 scsiq->host_status = scsiq->scsi_status = 0;
8394 scsiq->data_cnt = 0L;
8395 }
8396
8397 /*
8398 * Advance the stopper pointer to the next carrier
8399 * ignoring the lower four bits. Free the previous
8400 * stopper carrier.
8401 */
8402 free_carrp = asc_dvc->irq_sp;
8403 asc_dvc->irq_sp = (ADV_CARR_T *)
8404 ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
8405
8406 free_carrp->next_vpa =
8407 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
8408 asc_dvc->carr_freelist = free_carrp;
8409 asc_dvc->carr_pending_cnt--;
8410
8411 target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
8412
8413 /*
8414 * Clear request microcode control flag.
8415 */
8416 scsiq->cntl = 0;
8417
8418 /*
8419 * Notify the driver of the completed request by passing
8420 * the ADV_SCSI_REQ_Q pointer to its callback function.
8421 */
8422 scsiq->a_flag |= ADV_SCSIQ_DONE;
8423 adv_isr_callback(asc_dvc, scsiq);
8424 /*
8425 * Note: After the driver callback function is called, 'scsiq'
8426 * can no longer be referenced.
8427 *
8428 * Fall through and continue processing other completed
8429 * requests...
8430 */
8431 }
8432 return ADV_TRUE;
8433}
8434
8435static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
8436{
8437 if (asc_dvc->err_code == 0) {
8438 asc_dvc->err_code = err_code;
8439 AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
8440 err_code);
8441 }
8442 return err_code;
8443}
8444
8445static void AscAckInterrupt(PortAddr iop_base)
8446{
8447 uchar host_flag;
8448 uchar risc_flag;
8449 ushort loop;
8450
8451 loop = 0;
8452 do {
8453 risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
8454 if (loop++ > 0x7FFF) {
8455 break;
8456 }
8457 } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
8458 host_flag =
8459 AscReadLramByte(iop_base,
8460 ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
8461 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
8462 (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
8463 AscSetChipStatus(iop_base, CIW_INT_ACK);
8464 loop = 0;
8465 while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
8466 AscSetChipStatus(iop_base, CIW_INT_ACK);
8467 if (loop++ > 3) {
8468 break;
8469 }
8470 }
8471 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
51219358
MW
8472}
8473
8474static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
8475{
afbb68c3 8476 const uchar *period_table;
51219358
MW
8477 int max_index;
8478 int min_index;
8479 int i;
8480
8481 period_table = asc_dvc->sdtr_period_tbl;
8482 max_index = (int)asc_dvc->max_sdtr_index;
afbb68c3 8483 min_index = (int)asc_dvc->min_sdtr_index;
51219358
MW
8484 if ((syn_time <= period_table[max_index])) {
8485 for (i = min_index; i < (max_index - 1); i++) {
8486 if (syn_time <= period_table[i]) {
8487 return (uchar)i;
8488 }
8489 }
8490 return (uchar)max_index;
8491 } else {
8492 return (uchar)(max_index + 1);
8493 }
8494}
8495
8496static uchar
8497AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
8498{
8499 EXT_MSG sdtr_buf;
8500 uchar sdtr_period_index;
8501 PortAddr iop_base;
8502
8503 iop_base = asc_dvc->iop_base;
8504 sdtr_buf.msg_type = EXTENDED_MESSAGE;
8505 sdtr_buf.msg_len = MS_SDTR_LEN;
8506 sdtr_buf.msg_req = EXTENDED_SDTR;
8507 sdtr_buf.xfer_period = sdtr_period;
8508 sdtr_offset &= ASC_SYN_MAX_OFFSET;
8509 sdtr_buf.req_ack_offset = sdtr_offset;
8510 sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
8511 if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
8512 AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
8513 (uchar *)&sdtr_buf,
8514 sizeof(EXT_MSG) >> 1);
8515 return ((sdtr_period_index << 4) | sdtr_offset);
8516 } else {
8517 sdtr_buf.req_ack_offset = 0;
8518 AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
8519 (uchar *)&sdtr_buf,
8520 sizeof(EXT_MSG) >> 1);
8521 return 0;
8522 }
8523}
8524
8525static uchar
8526AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
8527{
8528 uchar byte;
8529 uchar sdtr_period_ix;
8530
8531 sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
afbb68c3 8532 if (sdtr_period_ix > asc_dvc->max_sdtr_index)
51219358 8533 return 0xFF;
51219358
MW
8534 byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
8535 return byte;
8536}
8537
8538static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
8539{
8540 ASC_SCSI_BIT_ID_TYPE org_id;
8541 int i;
8542 int sta = TRUE;
8543
8544 AscSetBank(iop_base, 1);
8545 org_id = AscReadChipDvcID(iop_base);
8546 for (i = 0; i <= ASC_MAX_TID; i++) {
8547 if (org_id == (0x01 << i))
8548 break;
8549 }
8550 org_id = (ASC_SCSI_BIT_ID_TYPE) i;
8551 AscWriteChipDvcID(iop_base, id);
8552 if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
8553 AscSetBank(iop_base, 0);
8554 AscSetChipSyn(iop_base, sdtr_data);
8555 if (AscGetChipSyn(iop_base) != sdtr_data) {
8556 sta = FALSE;
8557 }
8558 } else {
8559 sta = FALSE;
8560 }
8561 AscSetBank(iop_base, 1);
8562 AscWriteChipDvcID(iop_base, org_id);
8563 AscSetBank(iop_base, 0);
8564 return (sta);
8565}
8566
8567static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
8568{
8569 AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
8570 AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
8571}
8572
8573static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
8574{
8575 EXT_MSG ext_msg;
8576 EXT_MSG out_msg;
8577 ushort halt_q_addr;
8578 int sdtr_accept;
8579 ushort int_halt_code;
8580 ASC_SCSI_BIT_ID_TYPE scsi_busy;
8581 ASC_SCSI_BIT_ID_TYPE target_id;
8582 PortAddr iop_base;
8583 uchar tag_code;
8584 uchar q_status;
8585 uchar halt_qp;
8586 uchar sdtr_data;
8587 uchar target_ix;
8588 uchar q_cntl, tid_no;
8589 uchar cur_dvc_qng;
8590 uchar asyn_sdtr;
8591 uchar scsi_status;
d2411495 8592 struct asc_board *boardp;
51219358
MW
8593
8594 BUG_ON(!asc_dvc->drv_ptr);
8595 boardp = asc_dvc->drv_ptr;
8596
8597 iop_base = asc_dvc->iop_base;
8598 int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
8599
8600 halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
8601 halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
8602 target_ix = AscReadLramByte(iop_base,
8603 (ushort)(halt_q_addr +
8604 (ushort)ASC_SCSIQ_B_TARGET_IX));
8605 q_cntl = AscReadLramByte(iop_base,
8606 (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
8607 tid_no = ASC_TIX_TO_TID(target_ix);
8608 target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
8609 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8610 asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
8611 } else {
8612 asyn_sdtr = 0;
8613 }
8614 if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
8615 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8616 AscSetChipSDTR(iop_base, 0, tid_no);
8617 boardp->sdtr_data[tid_no] = 0;
8618 }
8619 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8620 return (0);
8621 } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
8622 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8623 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8624 boardp->sdtr_data[tid_no] = asyn_sdtr;
8625 }
8626 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8627 return (0);
8628 } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
8629 AscMemWordCopyPtrFromLram(iop_base,
8630 ASCV_MSGIN_BEG,
8631 (uchar *)&ext_msg,
8632 sizeof(EXT_MSG) >> 1);
8633
8634 if (ext_msg.msg_type == EXTENDED_MESSAGE &&
8635 ext_msg.msg_req == EXTENDED_SDTR &&
8636 ext_msg.msg_len == MS_SDTR_LEN) {
8637 sdtr_accept = TRUE;
8638 if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
8639
8640 sdtr_accept = FALSE;
8641 ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
8642 }
8643 if ((ext_msg.xfer_period <
afbb68c3 8644 asc_dvc->sdtr_period_tbl[asc_dvc->min_sdtr_index])
51219358
MW
8645 || (ext_msg.xfer_period >
8646 asc_dvc->sdtr_period_tbl[asc_dvc->
8647 max_sdtr_index])) {
8648 sdtr_accept = FALSE;
8649 ext_msg.xfer_period =
8650 asc_dvc->sdtr_period_tbl[asc_dvc->
afbb68c3 8651 min_sdtr_index];
51219358
MW
8652 }
8653 if (sdtr_accept) {
8654 sdtr_data =
8655 AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
8656 ext_msg.req_ack_offset);
8657 if ((sdtr_data == 0xFF)) {
8658
8659 q_cntl |= QC_MSG_OUT;
8660 asc_dvc->init_sdtr &= ~target_id;
8661 asc_dvc->sdtr_done &= ~target_id;
8662 AscSetChipSDTR(iop_base, asyn_sdtr,
8663 tid_no);
8664 boardp->sdtr_data[tid_no] = asyn_sdtr;
8665 }
8666 }
8667 if (ext_msg.req_ack_offset == 0) {
8668
8669 q_cntl &= ~QC_MSG_OUT;
8670 asc_dvc->init_sdtr &= ~target_id;
8671 asc_dvc->sdtr_done &= ~target_id;
8672 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8673 } else {
8674 if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
51219358
MW
8675 q_cntl &= ~QC_MSG_OUT;
8676 asc_dvc->sdtr_done |= target_id;
8677 asc_dvc->init_sdtr |= target_id;
8678 asc_dvc->pci_fix_asyn_xfer &=
8679 ~target_id;
8680 sdtr_data =
8681 AscCalSDTRData(asc_dvc,
8682 ext_msg.xfer_period,
8683 ext_msg.
8684 req_ack_offset);
8685 AscSetChipSDTR(iop_base, sdtr_data,
8686 tid_no);
8687 boardp->sdtr_data[tid_no] = sdtr_data;
8688 } else {
51219358
MW
8689 q_cntl |= QC_MSG_OUT;
8690 AscMsgOutSDTR(asc_dvc,
8691 ext_msg.xfer_period,
8692 ext_msg.req_ack_offset);
8693 asc_dvc->pci_fix_asyn_xfer &=
8694 ~target_id;
8695 sdtr_data =
8696 AscCalSDTRData(asc_dvc,
8697 ext_msg.xfer_period,
8698 ext_msg.
8699 req_ack_offset);
8700 AscSetChipSDTR(iop_base, sdtr_data,
8701 tid_no);
8702 boardp->sdtr_data[tid_no] = sdtr_data;
8703 asc_dvc->sdtr_done |= target_id;
8704 asc_dvc->init_sdtr |= target_id;
8705 }
8706 }
8707
8708 AscWriteLramByte(iop_base,
8709 (ushort)(halt_q_addr +
8710 (ushort)ASC_SCSIQ_B_CNTL),
8711 q_cntl);
8712 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8713 return (0);
8714 } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
8715 ext_msg.msg_req == EXTENDED_WDTR &&
8716 ext_msg.msg_len == MS_WDTR_LEN) {
8717
8718 ext_msg.wdtr_width = 0;
8719 AscMemWordCopyPtrToLram(iop_base,
8720 ASCV_MSGOUT_BEG,
8721 (uchar *)&ext_msg,
8722 sizeof(EXT_MSG) >> 1);
8723 q_cntl |= QC_MSG_OUT;
8724 AscWriteLramByte(iop_base,
8725 (ushort)(halt_q_addr +
8726 (ushort)ASC_SCSIQ_B_CNTL),
8727 q_cntl);
8728 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8729 return (0);
8730 } else {
8731
8732 ext_msg.msg_type = MESSAGE_REJECT;
8733 AscMemWordCopyPtrToLram(iop_base,
8734 ASCV_MSGOUT_BEG,
8735 (uchar *)&ext_msg,
8736 sizeof(EXT_MSG) >> 1);
8737 q_cntl |= QC_MSG_OUT;
8738 AscWriteLramByte(iop_base,
8739 (ushort)(halt_q_addr +
8740 (ushort)ASC_SCSIQ_B_CNTL),
8741 q_cntl);
8742 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8743 return (0);
8744 }
8745 } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
8746
8747 q_cntl |= QC_REQ_SENSE;
8748
8749 if ((asc_dvc->init_sdtr & target_id) != 0) {
8750
8751 asc_dvc->sdtr_done &= ~target_id;
8752
8753 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
8754 q_cntl |= QC_MSG_OUT;
8755 AscMsgOutSDTR(asc_dvc,
8756 asc_dvc->
8757 sdtr_period_tbl[(sdtr_data >> 4) &
8758 (uchar)(asc_dvc->
8759 max_sdtr_index -
8760 1)],
8761 (uchar)(sdtr_data & (uchar)
8762 ASC_SYN_MAX_OFFSET));
8763 }
8764
8765 AscWriteLramByte(iop_base,
8766 (ushort)(halt_q_addr +
8767 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
8768
8769 tag_code = AscReadLramByte(iop_base,
8770 (ushort)(halt_q_addr + (ushort)
8771 ASC_SCSIQ_B_TAG_CODE));
8772 tag_code &= 0xDC;
8773 if ((asc_dvc->pci_fix_asyn_xfer & target_id)
8774 && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
8775 ) {
8776
8777 tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
8778 | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
8779
8780 }
8781 AscWriteLramByte(iop_base,
8782 (ushort)(halt_q_addr +
8783 (ushort)ASC_SCSIQ_B_TAG_CODE),
8784 tag_code);
8785
8786 q_status = AscReadLramByte(iop_base,
8787 (ushort)(halt_q_addr + (ushort)
8788 ASC_SCSIQ_B_STATUS));
8789 q_status |= (QS_READY | QS_BUSY);
8790 AscWriteLramByte(iop_base,
8791 (ushort)(halt_q_addr +
8792 (ushort)ASC_SCSIQ_B_STATUS),
8793 q_status);
8794
8795 scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
8796 scsi_busy &= ~target_id;
8797 AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
8798
8799 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8800 return (0);
8801 } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
8802
8803 AscMemWordCopyPtrFromLram(iop_base,
8804 ASCV_MSGOUT_BEG,
8805 (uchar *)&out_msg,
8806 sizeof(EXT_MSG) >> 1);
8807
8808 if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
8809 (out_msg.msg_len == MS_SDTR_LEN) &&
8810 (out_msg.msg_req == EXTENDED_SDTR)) {
8811
8812 asc_dvc->init_sdtr &= ~target_id;
8813 asc_dvc->sdtr_done &= ~target_id;
8814 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8815 boardp->sdtr_data[tid_no] = asyn_sdtr;
8816 }
8817 q_cntl &= ~QC_MSG_OUT;
8818 AscWriteLramByte(iop_base,
8819 (ushort)(halt_q_addr +
8820 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
8821 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8822 return (0);
8823 } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
8824
8825 scsi_status = AscReadLramByte(iop_base,
8826 (ushort)((ushort)halt_q_addr +
8827 (ushort)
8828 ASC_SCSIQ_SCSI_STATUS));
8829 cur_dvc_qng =
8830 AscReadLramByte(iop_base,
8831 (ushort)((ushort)ASC_QADR_BEG +
8832 (ushort)target_ix));
8833 if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
8834
8835 scsi_busy = AscReadLramByte(iop_base,
8836 (ushort)ASCV_SCSIBUSY_B);
8837 scsi_busy |= target_id;
8838 AscWriteLramByte(iop_base,
8839 (ushort)ASCV_SCSIBUSY_B, scsi_busy);
8840 asc_dvc->queue_full_or_busy |= target_id;
8841
8842 if (scsi_status == SAM_STAT_TASK_SET_FULL) {
8843 if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
8844 cur_dvc_qng -= 1;
8845 asc_dvc->max_dvc_qng[tid_no] =
8846 cur_dvc_qng;
8847
8848 AscWriteLramByte(iop_base,
8849 (ushort)((ushort)
8850 ASCV_MAX_DVC_QNG_BEG
8851 + (ushort)
8852 tid_no),
8853 cur_dvc_qng);
8854
8855 /*
8856 * Set the device queue depth to the
8857 * number of active requests when the
8858 * QUEUE FULL condition was encountered.
8859 */
8860 boardp->queue_full |= target_id;
8861 boardp->queue_full_cnt[tid_no] =
8862 cur_dvc_qng;
8863 }
8864 }
8865 }
8866 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8867 return (0);
8868 }
8869#if CC_VERY_LONG_SG_LIST
8870 else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
8871 uchar q_no;
8872 ushort q_addr;
8873 uchar sg_wk_q_no;
8874 uchar first_sg_wk_q_no;
8875 ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
8876 ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
8877 ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
8878 ushort sg_list_dwords;
8879 ushort sg_entry_cnt;
8880 uchar next_qp;
8881 int i;
8882
8883 q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
8884 if (q_no == ASC_QLINK_END)
8885 return 0;
8886
8887 q_addr = ASC_QNO_TO_QADDR(q_no);
8888
8889 /*
8890 * Convert the request's SRB pointer to a host ASC_SCSI_REQ
8891 * structure pointer using a macro provided by the driver.
8892 * The ASC_SCSI_REQ pointer provides a pointer to the
8893 * host ASC_SG_HEAD structure.
8894 */
8895 /* Read request's SRB pointer. */
8896 scsiq = (ASC_SCSI_Q *)
8897 ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
8898 (ushort)
8899 (q_addr +
8900 ASC_SCSIQ_D_SRBPTR))));
8901
8902 /*
8903 * Get request's first and working SG queue.
8904 */
8905 sg_wk_q_no = AscReadLramByte(iop_base,
8906 (ushort)(q_addr +
8907 ASC_SCSIQ_B_SG_WK_QP));
8908
8909 first_sg_wk_q_no = AscReadLramByte(iop_base,
8910 (ushort)(q_addr +
8911 ASC_SCSIQ_B_FIRST_SG_WK_QP));
8912
8913 /*
8914 * Reset request's working SG queue back to the
8915 * first SG queue.
8916 */
8917 AscWriteLramByte(iop_base,
8918 (ushort)(q_addr +
8919 (ushort)ASC_SCSIQ_B_SG_WK_QP),
8920 first_sg_wk_q_no);
8921
8922 sg_head = scsiq->sg_head;
8923
8924 /*
8925 * Set sg_entry_cnt to the number of SG elements
8926 * that will be completed on this interrupt.
8927 *
8928 * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
8929 * SG elements. The data_cnt and data_addr fields which
8930 * add 1 to the SG element capacity are not used when
8931 * restarting SG handling after a halt.
8932 */
8933 if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
8934 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
8935
8936 /*
8937 * Keep track of remaining number of SG elements that
8938 * will need to be handled on the next interrupt.
8939 */
8940 scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
8941 } else {
8942 sg_entry_cnt = scsiq->remain_sg_entry_cnt;
8943 scsiq->remain_sg_entry_cnt = 0;
8944 }
8945
8946 /*
8947 * Copy SG elements into the list of allocated SG queues.
8948 *
8949 * Last index completed is saved in scsiq->next_sg_index.
8950 */
8951 next_qp = first_sg_wk_q_no;
8952 q_addr = ASC_QNO_TO_QADDR(next_qp);
8953 scsi_sg_q.sg_head_qp = q_no;
8954 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
8955 for (i = 0; i < sg_head->queue_cnt; i++) {
8956 scsi_sg_q.seq_no = i + 1;
8957 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
8958 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
8959 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
8960 /*
8961 * After very first SG queue RISC FW uses next
8962 * SG queue first element then checks sg_list_cnt
8963 * against zero and then decrements, so set
8964 * sg_list_cnt 1 less than number of SG elements
8965 * in each SG queue.
8966 */
8967 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
8968 scsi_sg_q.sg_cur_list_cnt =
8969 ASC_SG_LIST_PER_Q - 1;
8970 } else {
8971 /*
8972 * This is the last SG queue in the list of
8973 * allocated SG queues. If there are more
8974 * SG elements than will fit in the allocated
8975 * queues, then set the QCSG_SG_XFER_MORE flag.
8976 */
8977 if (scsiq->remain_sg_entry_cnt != 0) {
8978 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
8979 } else {
8980 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
8981 }
8982 /* equals sg_entry_cnt * 2 */
8983 sg_list_dwords = sg_entry_cnt << 1;
8984 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
8985 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
8986 sg_entry_cnt = 0;
8987 }
8988
8989 scsi_sg_q.q_no = next_qp;
8990 AscMemWordCopyPtrToLram(iop_base,
8991 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
8992 (uchar *)&scsi_sg_q,
8993 sizeof(ASC_SG_LIST_Q) >> 1);
8994
8995 AscMemDWordCopyPtrToLram(iop_base,
8996 q_addr + ASC_SGQ_LIST_BEG,
8997 (uchar *)&sg_head->
8998 sg_list[scsiq->next_sg_index],
8999 sg_list_dwords);
9000
9001 scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
9002
9003 /*
9004 * If the just completed SG queue contained the
9005 * last SG element, then no more SG queues need
9006 * to be written.
9007 */
9008 if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
9009 break;
9010 }
9011
9012 next_qp = AscReadLramByte(iop_base,
9013 (ushort)(q_addr +
9014 ASC_SCSIQ_B_FWD));
9015 q_addr = ASC_QNO_TO_QADDR(next_qp);
9016 }
9017
9018 /*
9019 * Clear the halt condition so the RISC will be restarted
9020 * after the return.
9021 */
9022 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9023 return (0);
9024 }
9025#endif /* CC_VERY_LONG_SG_LIST */
9026 return (0);
9027}
1da177e4 9028
1da177e4 9029/*
51219358
MW
9030 * void
9031 * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
1da177e4 9032 *
51219358
MW
9033 * Calling/Exit State:
9034 * none
1da177e4 9035 *
51219358
MW
9036 * Description:
9037 * Input an ASC_QDONE_INFO structure from the chip
1da177e4 9038 */
51219358
MW
9039static void
9040DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
9041{
9042 int i;
9043 ushort word;
9044
9045 AscSetChipLramAddr(iop_base, s_addr);
9046 for (i = 0; i < 2 * words; i += 2) {
9047 if (i == 10) {
9048 continue;
9049 }
9050 word = inpw(iop_base + IOP_RAM_DATA);
9051 inbuf[i] = word & 0xff;
9052 inbuf[i + 1] = (word >> 8) & 0xff;
9053 }
9054 ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
9055}
9056
9057static uchar
9058_AscCopyLramScsiDoneQ(PortAddr iop_base,
9059 ushort q_addr,
9060 ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
9061{
9062 ushort _val;
9063 uchar sg_queue_cnt;
9064
9065 DvcGetQinfo(iop_base,
9066 q_addr + ASC_SCSIQ_DONE_INFO_BEG,
9067 (uchar *)scsiq,
9068 (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
9069
9070 _val = AscReadLramWord(iop_base,
9071 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
9072 scsiq->q_status = (uchar)_val;
9073 scsiq->q_no = (uchar)(_val >> 8);
9074 _val = AscReadLramWord(iop_base,
9075 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
9076 scsiq->cntl = (uchar)_val;
9077 sg_queue_cnt = (uchar)(_val >> 8);
9078 _val = AscReadLramWord(iop_base,
9079 (ushort)(q_addr +
9080 (ushort)ASC_SCSIQ_B_SENSE_LEN));
9081 scsiq->sense_len = (uchar)_val;
9082 scsiq->extra_bytes = (uchar)(_val >> 8);
9083
9084 /*
9085 * Read high word of remain bytes from alternate location.
9086 */
9087 scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
9088 (ushort)(q_addr +
9089 (ushort)
9090 ASC_SCSIQ_W_ALT_DC1)))
9091 << 16);
9092 /*
9093 * Read low word of remain bytes from original location.
9094 */
9095 scsiq->remain_bytes += AscReadLramWord(iop_base,
9096 (ushort)(q_addr + (ushort)
9097 ASC_SCSIQ_DW_REMAIN_XFER_CNT));
9098
9099 scsiq->remain_bytes &= max_dma_count;
9100 return sg_queue_cnt;
9101}
9102
9103/*
9104 * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
9105 *
9106 * Interrupt callback function for the Narrow SCSI Asc Library.
9107 */
9108static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
9109{
d2411495 9110 struct asc_board *boardp;
51219358
MW
9111 struct scsi_cmnd *scp;
9112 struct Scsi_Host *shost;
9113
b352f923 9114 ASC_DBG(1, "asc_dvc_varp 0x%p, qdonep 0x%p\n", asc_dvc_varp, qdonep);
51219358
MW
9115 ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
9116
9117 /*
9118 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
9119 * command that has been completed.
9120 */
9121 scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
b352f923 9122 ASC_DBG(1, "scp 0x%p\n", scp);
51219358
MW
9123
9124 if (scp == NULL) {
9125 ASC_PRINT("asc_isr_callback: scp is NULL\n");
9126 return;
9127 }
9128 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
9129
9130 shost = scp->device->host;
9131 ASC_STATS(shost, callback);
b352f923 9132 ASC_DBG(1, "shost 0x%p\n", shost);
51219358 9133
d2411495 9134 boardp = shost_priv(shost);
51219358
MW
9135 BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
9136
9137 /*
9138 * 'qdonep' contains the command's ending status.
9139 */
9140 switch (qdonep->d3.done_stat) {
9141 case QD_NO_ERROR:
b352f923 9142 ASC_DBG(2, "QD_NO_ERROR\n");
51219358
MW
9143 scp->result = 0;
9144
9145 /*
9146 * Check for an underrun condition.
9147 *
9148 * If there was no error and an underrun condition, then
9149 * return the number of underrun bytes.
9150 */
9151 if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
9152 qdonep->remain_bytes <= scp->request_bufflen) {
b352f923 9153 ASC_DBG(1, "underrun condition %u bytes\n",
51219358
MW
9154 (unsigned)qdonep->remain_bytes);
9155 scp->resid = qdonep->remain_bytes;
9156 }
9157 break;
9158
9159 case QD_WITH_ERROR:
b352f923 9160 ASC_DBG(2, "QD_WITH_ERROR\n");
51219358
MW
9161 switch (qdonep->d3.host_stat) {
9162 case QHSTA_NO_ERROR:
9163 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
b352f923 9164 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
51219358
MW
9165 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
9166 sizeof(scp->sense_buffer));
9167 /*
9168 * Note: The 'status_byte()' macro used by
9169 * target drivers defined in scsi.h shifts the
9170 * status byte returned by host drivers right
9171 * by 1 bit. This is why target drivers also
9172 * use right shifted status byte definitions.
9173 * For instance target drivers use
9174 * CHECK_CONDITION, defined to 0x1, instead of
9175 * the SCSI defined check condition value of
9176 * 0x2. Host drivers are supposed to return
9177 * the status byte as it is defined by SCSI.
9178 */
9179 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
9180 STATUS_BYTE(qdonep->d3.scsi_stat);
9181 } else {
9182 scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
9183 }
9184 break;
9185
9186 default:
9187 /* QHSTA error occurred */
b352f923 9188 ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat);
51219358
MW
9189 scp->result = HOST_BYTE(DID_BAD_TARGET);
9190 break;
9191 }
9192 break;
9193
9194 case QD_ABORTED_BY_HOST:
b352f923 9195 ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
51219358
MW
9196 scp->result =
9197 HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
9198 scsi_msg) |
9199 STATUS_BYTE(qdonep->d3.scsi_stat);
9200 break;
9201
9202 default:
b352f923 9203 ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat);
51219358
MW
9204 scp->result =
9205 HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
9206 scsi_msg) |
9207 STATUS_BYTE(qdonep->d3.scsi_stat);
9208 break;
9209 }
9210
9211 /*
9212 * If the 'init_tidmask' bit isn't already set for the target and the
9213 * current request finished normally, then set the bit for the target
9214 * to indicate that a device is present.
9215 */
9216 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
9217 qdonep->d3.done_stat == QD_NO_ERROR &&
9218 qdonep->d3.host_stat == QHSTA_NO_ERROR) {
9219 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
9220 }
1da177e4 9221
51219358 9222 asc_scsi_done(scp);
51219358
MW
9223}
9224
9225static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
9226{
9227 uchar next_qp;
9228 uchar n_q_used;
9229 uchar sg_list_qp;
9230 uchar sg_queue_cnt;
9231 uchar q_cnt;
9232 uchar done_q_tail;
9233 uchar tid_no;
9234 ASC_SCSI_BIT_ID_TYPE scsi_busy;
9235 ASC_SCSI_BIT_ID_TYPE target_id;
9236 PortAddr iop_base;
9237 ushort q_addr;
9238 ushort sg_q_addr;
9239 uchar cur_target_qng;
9240 ASC_QDONE_INFO scsiq_buf;
9241 ASC_QDONE_INFO *scsiq;
9242 int false_overrun;
9243
9244 iop_base = asc_dvc->iop_base;
9245 n_q_used = 1;
9246 scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
9247 done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
9248 q_addr = ASC_QNO_TO_QADDR(done_q_tail);
9249 next_qp = AscReadLramByte(iop_base,
9250 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
9251 if (next_qp != ASC_QLINK_END) {
9252 AscPutVarDoneQTail(iop_base, next_qp);
9253 q_addr = ASC_QNO_TO_QADDR(next_qp);
9254 sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
9255 asc_dvc->max_dma_count);
9256 AscWriteLramByte(iop_base,
9257 (ushort)(q_addr +
9258 (ushort)ASC_SCSIQ_B_STATUS),
9259 (uchar)(scsiq->
9260 q_status & (uchar)~(QS_READY |
9261 QS_ABORTED)));
9262 tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
9263 target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
9264 if ((scsiq->cntl & QC_SG_HEAD) != 0) {
9265 sg_q_addr = q_addr;
9266 sg_list_qp = next_qp;
9267 for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
9268 sg_list_qp = AscReadLramByte(iop_base,
9269 (ushort)(sg_q_addr
9270 + (ushort)
9271 ASC_SCSIQ_B_FWD));
9272 sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
9273 if (sg_list_qp == ASC_QLINK_END) {
9274 AscSetLibErrorCode(asc_dvc,
9275 ASCQ_ERR_SG_Q_LINKS);
9276 scsiq->d3.done_stat = QD_WITH_ERROR;
9277 scsiq->d3.host_stat =
9278 QHSTA_D_QDONE_SG_LIST_CORRUPTED;
9279 goto FATAL_ERR_QDONE;
9280 }
9281 AscWriteLramByte(iop_base,
9282 (ushort)(sg_q_addr + (ushort)
9283 ASC_SCSIQ_B_STATUS),
9284 QS_FREE);
9285 }
9286 n_q_used = sg_queue_cnt + 1;
9287 AscPutVarDoneQTail(iop_base, sg_list_qp);
9288 }
9289 if (asc_dvc->queue_full_or_busy & target_id) {
9290 cur_target_qng = AscReadLramByte(iop_base,
9291 (ushort)((ushort)
9292 ASC_QADR_BEG
9293 + (ushort)
9294 scsiq->d2.
9295 target_ix));
9296 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
9297 scsi_busy = AscReadLramByte(iop_base, (ushort)
9298 ASCV_SCSIBUSY_B);
9299 scsi_busy &= ~target_id;
9300 AscWriteLramByte(iop_base,
9301 (ushort)ASCV_SCSIBUSY_B,
9302 scsi_busy);
9303 asc_dvc->queue_full_or_busy &= ~target_id;
9304 }
9305 }
9306 if (asc_dvc->cur_total_qng >= n_q_used) {
9307 asc_dvc->cur_total_qng -= n_q_used;
9308 if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
9309 asc_dvc->cur_dvc_qng[tid_no]--;
9310 }
9311 } else {
9312 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
9313 scsiq->d3.done_stat = QD_WITH_ERROR;
9314 goto FATAL_ERR_QDONE;
9315 }
9316 if ((scsiq->d2.srb_ptr == 0UL) ||
9317 ((scsiq->q_status & QS_ABORTED) != 0)) {
9318 return (0x11);
9319 } else if (scsiq->q_status == QS_DONE) {
9320 false_overrun = FALSE;
9321 if (scsiq->extra_bytes != 0) {
9322 scsiq->remain_bytes +=
9323 (ADV_DCNT)scsiq->extra_bytes;
9324 }
9325 if (scsiq->d3.done_stat == QD_WITH_ERROR) {
9326 if (scsiq->d3.host_stat ==
9327 QHSTA_M_DATA_OVER_RUN) {
9328 if ((scsiq->
9329 cntl & (QC_DATA_IN | QC_DATA_OUT))
9330 == 0) {
9331 scsiq->d3.done_stat =
9332 QD_NO_ERROR;
9333 scsiq->d3.host_stat =
9334 QHSTA_NO_ERROR;
9335 } else if (false_overrun) {
9336 scsiq->d3.done_stat =
9337 QD_NO_ERROR;
9338 scsiq->d3.host_stat =
9339 QHSTA_NO_ERROR;
9340 }
9341 } else if (scsiq->d3.host_stat ==
9342 QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
9343 AscStopChip(iop_base);
9344 AscSetChipControl(iop_base,
9345 (uchar)(CC_SCSI_RESET
9346 | CC_HALT));
9347 udelay(60);
9348 AscSetChipControl(iop_base, CC_HALT);
9349 AscSetChipStatus(iop_base,
9350 CIW_CLR_SCSI_RESET_INT);
9351 AscSetChipStatus(iop_base, 0);
9352 AscSetChipControl(iop_base, 0);
9353 }
9354 }
9355 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
9356 asc_isr_callback(asc_dvc, scsiq);
9357 } else {
9358 if ((AscReadLramByte(iop_base,
9359 (ushort)(q_addr + (ushort)
9360 ASC_SCSIQ_CDB_BEG))
9361 == START_STOP)) {
9362 asc_dvc->unit_not_ready &= ~target_id;
9363 if (scsiq->d3.done_stat != QD_NO_ERROR) {
9364 asc_dvc->start_motor &=
9365 ~target_id;
9366 }
9367 }
9368 }
9369 return (1);
9370 } else {
9371 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
9372 FATAL_ERR_QDONE:
9373 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
9374 asc_isr_callback(asc_dvc, scsiq);
9375 }
9376 return (0x80);
9377 }
9378 }
9379 return (0);
9380}
1da177e4 9381
51219358
MW
9382static int AscISR(ASC_DVC_VAR *asc_dvc)
9383{
9384 ASC_CS_TYPE chipstat;
9385 PortAddr iop_base;
9386 ushort saved_ram_addr;
9387 uchar ctrl_reg;
9388 uchar saved_ctrl_reg;
9389 int int_pending;
9390 int status;
9391 uchar host_flag;
1da177e4 9392
51219358
MW
9393 iop_base = asc_dvc->iop_base;
9394 int_pending = FALSE;
1da177e4 9395
51219358
MW
9396 if (AscIsIntPending(iop_base) == 0)
9397 return int_pending;
9398
9399 if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
9400 return ERR;
9401 }
9402 if (asc_dvc->in_critical_cnt != 0) {
9403 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
9404 return ERR;
9405 }
9406 if (asc_dvc->is_in_int) {
9407 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
9408 return ERR;
9409 }
9410 asc_dvc->is_in_int = TRUE;
9411 ctrl_reg = AscGetChipControl(iop_base);
9412 saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
9413 CC_SINGLE_STEP | CC_DIAG | CC_TEST));
9414 chipstat = AscGetChipStatus(iop_base);
9415 if (chipstat & CSW_SCSI_RESET_LATCH) {
9416 if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
9417 int i = 10;
9418 int_pending = TRUE;
9419 asc_dvc->sdtr_done = 0;
9420 saved_ctrl_reg &= (uchar)(~CC_HALT);
9421 while ((AscGetChipStatus(iop_base) &
9422 CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
9423 mdelay(100);
9424 }
9425 AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
9426 AscSetChipControl(iop_base, CC_HALT);
9427 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
9428 AscSetChipStatus(iop_base, 0);
9429 chipstat = AscGetChipStatus(iop_base);
9430 }
9431 }
9432 saved_ram_addr = AscGetChipLramAddr(iop_base);
9433 host_flag = AscReadLramByte(iop_base,
9434 ASCV_HOST_FLAG_B) &
9435 (uchar)(~ASC_HOST_FLAG_IN_ISR);
9436 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
9437 (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
9438 if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
9439 AscAckInterrupt(iop_base);
9440 int_pending = TRUE;
9441 if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
9442 if (AscIsrChipHalted(asc_dvc) == ERR) {
9443 goto ISR_REPORT_QDONE_FATAL_ERROR;
9444 } else {
9445 saved_ctrl_reg &= (uchar)(~CC_HALT);
9446 }
9447 } else {
9448 ISR_REPORT_QDONE_FATAL_ERROR:
9449 if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
9450 while (((status =
9451 AscIsrQDone(asc_dvc)) & 0x01) != 0) {
9452 }
9453 } else {
9454 do {
9455 if ((status =
9456 AscIsrQDone(asc_dvc)) == 1) {
9457 break;
9458 }
9459 } while (status == 0x11);
9460 }
9461 if ((status & 0x80) != 0)
9462 int_pending = ERR;
9463 }
9464 }
9465 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
9466 AscSetChipLramAddr(iop_base, saved_ram_addr);
9467 AscSetChipControl(iop_base, saved_ctrl_reg);
9468 asc_dvc->is_in_int = FALSE;
9469 return int_pending;
9470}
1da177e4
LT
9471
9472/*
51219358 9473 * advansys_reset()
1da177e4 9474 *
51219358 9475 * Reset the bus associated with the command 'scp'.
1da177e4 9476 *
51219358
MW
9477 * This function runs its own thread. Interrupts must be blocked but
9478 * sleeping is allowed and no locking other than for host structures is
9479 * required. Returns SUCCESS or FAILED.
1da177e4 9480 */
51219358 9481static int advansys_reset(struct scsi_cmnd *scp)
1da177e4 9482{
52fa0777 9483 struct Scsi_Host *shost = scp->device->host;
d2411495 9484 struct asc_board *boardp = shost_priv(shost);
52fa0777 9485 unsigned long flags;
27c868c2 9486 int status;
51219358 9487 int ret = SUCCESS;
27c868c2 9488
b352f923 9489 ASC_DBG(1, "0x%p\n", scp);
27c868c2 9490
52fa0777 9491 ASC_STATS(shost, reset);
27c868c2 9492
52fa0777 9493 scmd_printk(KERN_INFO, scp, "SCSI bus reset started...\n");
51219358
MW
9494
9495 if (ASC_NARROW_BOARD(boardp)) {
52fa0777 9496 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
1da177e4 9497
52fa0777 9498 /* Reset the chip and SCSI bus. */
b352f923 9499 ASC_DBG(1, "before AscInitAsc1000Driver()\n");
52fa0777 9500 status = AscInitAsc1000Driver(asc_dvc);
27c868c2 9501
51219358 9502 /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
52fa0777
MW
9503 if (asc_dvc->err_code) {
9504 scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
9505 "0x%x\n", asc_dvc->err_code);
51219358
MW
9506 ret = FAILED;
9507 } else if (status) {
52fa0777
MW
9508 scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
9509 "0x%x\n", status);
27c868c2 9510 } else {
52fa0777
MW
9511 scmd_printk(KERN_INFO, scp, "SCSI bus reset "
9512 "successful\n");
27c868c2 9513 }
a9f4a59a 9514
b352f923 9515 ASC_DBG(1, "after AscInitAsc1000Driver()\n");
f092d229 9516 spin_lock_irqsave(shost->host_lock, flags);
a9f4a59a 9517 } else {
a9f4a59a 9518 /*
51219358
MW
9519 * If the suggest reset bus flags are set, then reset the bus.
9520 * Otherwise only reset the device.
a9f4a59a 9521 */
52fa0777 9522 ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
a9f4a59a
MW
9523
9524 /*
51219358 9525 * Reset the target's SCSI bus.
a9f4a59a 9526 */
b352f923 9527 ASC_DBG(1, "before AdvResetChipAndSB()\n");
52fa0777 9528 switch (AdvResetChipAndSB(adv_dvc)) {
51219358 9529 case ASC_TRUE:
52fa0777
MW
9530 scmd_printk(KERN_INFO, scp, "SCSI bus reset "
9531 "successful\n");
51219358
MW
9532 break;
9533 case ASC_FALSE:
9534 default:
52fa0777 9535 scmd_printk(KERN_INFO, scp, "SCSI bus reset error\n");
51219358
MW
9536 ret = FAILED;
9537 break;
b9d96614 9538 }
f092d229 9539 spin_lock_irqsave(shost->host_lock, flags);
52fa0777 9540 AdvISR(adv_dvc);
b9d96614
MW
9541 }
9542
51219358
MW
9543 /* Save the time of the most recently completed reset. */
9544 boardp->last_reset = jiffies;
f092d229 9545 spin_unlock_irqrestore(shost->host_lock, flags);
b9d96614 9546
b352f923 9547 ASC_DBG(1, "ret %d\n", ret);
b9d96614 9548
51219358 9549 return ret;
b9d96614
MW
9550}
9551
1da177e4 9552/*
51219358 9553 * advansys_biosparam()
1da177e4 9554 *
51219358
MW
9555 * Translate disk drive geometry if the "BIOS greater than 1 GB"
9556 * support is enabled for a drive.
1da177e4 9557 *
51219358
MW
9558 * ip (information pointer) is an int array with the following definition:
9559 * ip[0]: heads
9560 * ip[1]: sectors
9561 * ip[2]: cylinders
1da177e4 9562 */
51219358
MW
9563static int
9564advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
9565 sector_t capacity, int ip[])
1da177e4 9566{
d2411495 9567 struct asc_board *boardp = shost_priv(sdev->host);
1da177e4 9568
b352f923 9569 ASC_DBG(1, "begin\n");
51219358 9570 ASC_STATS(sdev->host, biosparam);
51219358
MW
9571 if (ASC_NARROW_BOARD(boardp)) {
9572 if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
9573 ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
9574 ip[0] = 255;
9575 ip[1] = 63;
9576 } else {
9577 ip[0] = 64;
9578 ip[1] = 32;
9579 }
9580 } else {
9581 if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
9582 BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
9583 ip[0] = 255;
9584 ip[1] = 63;
9585 } else {
9586 ip[0] = 64;
9587 ip[1] = 32;
9588 }
27c868c2 9589 }
51219358 9590 ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
b352f923 9591 ASC_DBG(1, "end\n");
51219358
MW
9592 return 0;
9593}
1da177e4 9594
51219358
MW
9595/*
9596 * First-level interrupt handler.
9597 *
9598 * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
9599 */
9600static irqreturn_t advansys_interrupt(int irq, void *dev_id)
9601{
51219358 9602 struct Scsi_Host *shost = dev_id;
d2411495 9603 struct asc_board *boardp = shost_priv(shost);
51219358 9604 irqreturn_t result = IRQ_NONE;
27c868c2 9605
b352f923 9606 ASC_DBG(2, "boardp 0x%p\n", boardp);
f092d229 9607 spin_lock(shost->host_lock);
51219358
MW
9608 if (ASC_NARROW_BOARD(boardp)) {
9609 if (AscIsIntPending(shost->io_port)) {
9610 result = IRQ_HANDLED;
9611 ASC_STATS(shost, interrupt);
b352f923 9612 ASC_DBG(1, "before AscISR()\n");
51219358
MW
9613 AscISR(&boardp->dvc_var.asc_dvc_var);
9614 }
9615 } else {
b352f923 9616 ASC_DBG(1, "before AdvISR()\n");
51219358
MW
9617 if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
9618 result = IRQ_HANDLED;
9619 ASC_STATS(shost, interrupt);
9620 }
27c868c2 9621 }
f092d229 9622 spin_unlock(shost->host_lock);
1da177e4 9623
b352f923 9624 ASC_DBG(1, "end\n");
51219358
MW
9625 return result;
9626}
27c868c2 9627
51219358
MW
9628static int AscHostReqRiscHalt(PortAddr iop_base)
9629{
9630 int count = 0;
9631 int sta = 0;
9632 uchar saved_stop_code;
9633
9634 if (AscIsChipHalted(iop_base))
9635 return (1);
9636 saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
9637 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
9638 ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
9639 do {
9640 if (AscIsChipHalted(iop_base)) {
9641 sta = 1;
9642 break;
27c868c2 9643 }
51219358
MW
9644 mdelay(100);
9645 } while (count++ < 20);
9646 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
9647 return (sta);
9648}
1da177e4 9649
51219358
MW
9650static int
9651AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
9652{
9653 int sta = FALSE;
1da177e4 9654
51219358
MW
9655 if (AscHostReqRiscHalt(iop_base)) {
9656 sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
9657 AscStartChip(iop_base);
27c868c2 9658 }
51219358
MW
9659 return sta;
9660}
1da177e4 9661
51219358
MW
9662static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
9663{
9664 char type = sdev->type;
9665 ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
27c868c2 9666
51219358
MW
9667 if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
9668 return;
9669 if (asc_dvc->init_sdtr & tid_bits)
9670 return;
27c868c2 9671
51219358
MW
9672 if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
9673 asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
27c868c2 9674
51219358
MW
9675 asc_dvc->pci_fix_asyn_xfer |= tid_bits;
9676 if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
9677 (type == TYPE_ROM) || (type == TYPE_TAPE))
9678 asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
9679
9680 if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
9681 AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
9682 ASYN_SDTR_DATA_FIX_PCI_REV_AB);
9683}
1da177e4 9684
51219358
MW
9685static void
9686advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
9687{
9688 ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
9689 ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
27c868c2 9690
51219358
MW
9691 if (sdev->lun == 0) {
9692 ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
9693 if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
9694 asc_dvc->init_sdtr |= tid_bit;
9695 } else {
9696 asc_dvc->init_sdtr &= ~tid_bit;
9697 }
9698
9699 if (orig_init_sdtr != asc_dvc->init_sdtr)
9700 AscAsyncFix(asc_dvc, sdev);
27c868c2 9701 }
1da177e4 9702
51219358
MW
9703 if (sdev->tagged_supported) {
9704 if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
9705 if (sdev->lun == 0) {
9706 asc_dvc->cfg->can_tagged_qng |= tid_bit;
9707 asc_dvc->use_tagged_qng |= tid_bit;
9708 }
9709 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
9710 asc_dvc->max_dvc_qng[sdev->id]);
27c868c2 9711 }
51219358
MW
9712 } else {
9713 if (sdev->lun == 0) {
9714 asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
9715 asc_dvc->use_tagged_qng &= ~tid_bit;
27c868c2 9716 }
51219358 9717 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
27c868c2 9718 }
1da177e4 9719
51219358
MW
9720 if ((sdev->lun == 0) &&
9721 (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
9722 AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
9723 asc_dvc->cfg->disc_enable);
9724 AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
9725 asc_dvc->use_tagged_qng);
9726 AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
9727 asc_dvc->cfg->can_tagged_qng);
27c868c2 9728
51219358
MW
9729 asc_dvc->max_dvc_qng[sdev->id] =
9730 asc_dvc->cfg->max_tag_qng[sdev->id];
9731 AscWriteLramByte(asc_dvc->iop_base,
9732 (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
9733 asc_dvc->max_dvc_qng[sdev->id]);
9734 }
9735}
27c868c2 9736
51219358
MW
9737/*
9738 * Wide Transfers
9739 *
9740 * If the EEPROM enabled WDTR for the device and the device supports wide
9741 * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
9742 * write the new value to the microcode.
9743 */
9744static void
9745advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
9746{
9747 unsigned short cfg_word;
9748 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
9749 if ((cfg_word & tidmask) != 0)
9750 return;
27c868c2 9751
51219358
MW
9752 cfg_word |= tidmask;
9753 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
27c868c2
MW
9754
9755 /*
51219358
MW
9756 * Clear the microcode SDTR and WDTR negotiation done indicators for
9757 * the target to cause it to negotiate with the new setting set above.
9758 * WDTR when accepted causes the target to enter asynchronous mode, so
9759 * SDTR must be negotiated.
27c868c2 9760 */
51219358
MW
9761 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
9762 cfg_word &= ~tidmask;
9763 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
9764 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
9765 cfg_word &= ~tidmask;
9766 AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
9767}
1da177e4 9768
51219358
MW
9769/*
9770 * Synchronous Transfers
9771 *
9772 * If the EEPROM enabled SDTR for the device and the device
9773 * supports synchronous transfers, then turn on the device's
9774 * 'sdtr_able' bit. Write the new value to the microcode.
9775 */
9776static void
9777advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
9778{
9779 unsigned short cfg_word;
9780 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
9781 if ((cfg_word & tidmask) != 0)
9782 return;
1da177e4 9783
51219358
MW
9784 cfg_word |= tidmask;
9785 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
1da177e4 9786
27c868c2 9787 /*
51219358
MW
9788 * Clear the microcode "SDTR negotiation" done indicator for the
9789 * target to cause it to negotiate with the new setting set above.
27c868c2 9790 */
51219358
MW
9791 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
9792 cfg_word &= ~tidmask;
9793 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
9794}
27c868c2 9795
51219358
MW
9796/*
9797 * PPR (Parallel Protocol Request) Capable
9798 *
9799 * If the device supports DT mode, then it must be PPR capable.
9800 * The PPR message will be used in place of the SDTR and WDTR
9801 * messages to negotiate synchronous speed and offset, transfer
9802 * width, and protocol options.
9803 */
9804static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
9805 AdvPortAddr iop_base, unsigned short tidmask)
9806{
9807 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
9808 adv_dvc->ppr_able |= tidmask;
9809 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
9810}
27c868c2 9811
51219358
MW
9812static void
9813advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
9814{
9815 AdvPortAddr iop_base = adv_dvc->iop_base;
9816 unsigned short tidmask = 1 << sdev->id;
9817
9818 if (sdev->lun == 0) {
9819 /*
9820 * Handle WDTR, SDTR, and Tag Queuing. If the feature
9821 * is enabled in the EEPROM and the device supports the
9822 * feature, then enable it in the microcode.
9823 */
27c868c2 9824
51219358
MW
9825 if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
9826 advansys_wide_enable_wdtr(iop_base, tidmask);
9827 if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
9828 advansys_wide_enable_sdtr(iop_base, tidmask);
9829 if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
9830 advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
9831
9832 /*
9833 * Tag Queuing is disabled for the BIOS which runs in polled
9834 * mode and would see no benefit from Tag Queuing. Also by
9835 * disabling Tag Queuing in the BIOS devices with Tag Queuing
9836 * bugs will at least work with the BIOS.
9837 */
9838 if ((adv_dvc->tagqng_able & tidmask) &&
9839 sdev->tagged_supported) {
9840 unsigned short cfg_word;
9841 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
9842 cfg_word |= tidmask;
9843 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
9844 cfg_word);
9845 AdvWriteByteLram(iop_base,
9846 ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
9847 adv_dvc->max_dvc_qng);
27c868c2
MW
9848 }
9849 }
1da177e4 9850
51219358
MW
9851 if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
9852 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
9853 adv_dvc->max_dvc_qng);
9854 } else {
9855 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
9856 }
9857}
27c868c2 9858
51219358
MW
9859/*
9860 * Set the number of commands to queue per device for the
9861 * specified host adapter.
9862 */
9863static int advansys_slave_configure(struct scsi_device *sdev)
9864{
d2411495 9865 struct asc_board *boardp = shost_priv(sdev->host);
27c868c2 9866
51219358
MW
9867 if (ASC_NARROW_BOARD(boardp))
9868 advansys_narrow_slave_configure(sdev,
9869 &boardp->dvc_var.asc_dvc_var);
9870 else
9871 advansys_wide_slave_configure(sdev,
9872 &boardp->dvc_var.adv_dvc_var);
1da177e4 9873
51219358
MW
9874 return 0;
9875}
27c868c2 9876
d2411495 9877static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
05848b6e 9878 struct asc_scsi_q *asc_scsi_q)
51219358 9879{
05848b6e 9880 memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
27c868c2
MW
9881
9882 /*
51219358 9883 * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
27c868c2 9884 */
05848b6e 9885 asc_scsi_q->q2.srb_ptr = ASC_VADDR_TO_U32(scp);
27c868c2
MW
9886
9887 /*
51219358 9888 * Build the ASC_SCSI_Q request.
27c868c2 9889 */
05848b6e
MW
9890 asc_scsi_q->cdbptr = &scp->cmnd[0];
9891 asc_scsi_q->q2.cdb_len = scp->cmd_len;
9892 asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
9893 asc_scsi_q->q1.target_lun = scp->device->lun;
9894 asc_scsi_q->q2.target_ix =
51219358 9895 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
05848b6e 9896 asc_scsi_q->q1.sense_addr =
51219358 9897 cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
05848b6e 9898 asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
27c868c2
MW
9899
9900 /*
51219358
MW
9901 * If there are any outstanding requests for the current target,
9902 * then every 255th request send an ORDERED request. This heuristic
9903 * tries to retain the benefit of request sorting while preventing
9904 * request starvation. 255 is the max number of tags or pending commands
9905 * a device may have outstanding.
9906 *
9907 * The request count is incremented below for every successfully
9908 * started request.
27c868c2 9909 *
27c868c2 9910 */
51219358
MW
9911 if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
9912 (boardp->reqcnt[scp->device->id] % 255) == 0) {
05848b6e 9913 asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
51219358 9914 } else {
05848b6e 9915 asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
51219358 9916 }
27c868c2
MW
9917
9918 /*
51219358
MW
9919 * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
9920 * buffer command.
27c868c2 9921 */
51219358
MW
9922 if (scp->use_sg == 0) {
9923 /*
9924 * CDB request of single contiguous buffer.
9925 */
9926 ASC_STATS(scp->device->host, cont_cnt);
9927 scp->SCp.dma_handle = scp->request_bufflen ?
9928 dma_map_single(boardp->dev, scp->request_buffer,
9929 scp->request_bufflen,
9930 scp->sc_data_direction) : 0;
05848b6e
MW
9931 asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
9932 asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen);
51219358
MW
9933 ASC_STATS_ADD(scp->device->host, cont_xfer,
9934 ASC_CEILING(scp->request_bufflen, 512));
05848b6e
MW
9935 asc_scsi_q->q1.sg_queue_cnt = 0;
9936 asc_scsi_q->sg_head = NULL;
51219358
MW
9937 } else {
9938 /*
9939 * CDB scatter-gather request list.
9940 */
9941 int sgcnt;
9942 int use_sg;
9943 struct scatterlist *slp;
05848b6e 9944 struct asc_sg_head *asc_sg_head;
27c868c2 9945
51219358
MW
9946 slp = (struct scatterlist *)scp->request_buffer;
9947 use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
9948 scp->sc_data_direction);
27c868c2 9949
51219358 9950 if (use_sg > scp->device->host->sg_tablesize) {
9d0e96eb
MW
9951 scmd_printk(KERN_ERR, scp, "use_sg %d > "
9952 "sg_tablesize %d\n", use_sg,
9953 scp->device->host->sg_tablesize);
51219358
MW
9954 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
9955 scp->sc_data_direction);
9956 scp->result = HOST_BYTE(DID_ERROR);
9957 return ASC_ERROR;
9958 }
27c868c2 9959
51219358 9960 ASC_STATS(scp->device->host, sg_cnt);
27c868c2 9961
05848b6e
MW
9962 asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
9963 use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
9964 if (!asc_sg_head) {
9965 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
9966 scp->sc_data_direction);
9967 scp->result = HOST_BYTE(DID_SOFT_ERROR);
9968 return ASC_ERROR;
9969 }
51219358 9970
05848b6e
MW
9971 asc_scsi_q->q1.cntl |= QC_SG_HEAD;
9972 asc_scsi_q->sg_head = asc_sg_head;
9973 asc_scsi_q->q1.data_cnt = 0;
9974 asc_scsi_q->q1.data_addr = 0;
51219358 9975 /* This is a byte value, otherwise it would need to be swapped. */
05848b6e 9976 asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
51219358 9977 ASC_STATS_ADD(scp->device->host, sg_elem,
05848b6e 9978 asc_sg_head->entry_cnt);
51219358
MW
9979
9980 /*
9981 * Convert scatter-gather list into ASC_SG_HEAD list.
9982 */
9983 for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
05848b6e 9984 asc_sg_head->sg_list[sgcnt].addr =
51219358 9985 cpu_to_le32(sg_dma_address(slp));
05848b6e 9986 asc_sg_head->sg_list[sgcnt].bytes =
51219358
MW
9987 cpu_to_le32(sg_dma_len(slp));
9988 ASC_STATS_ADD(scp->device->host, sg_xfer,
9989 ASC_CEILING(sg_dma_len(slp), 512));
27c868c2
MW
9990 }
9991 }
1da177e4 9992
b352f923 9993 ASC_DBG_PRT_ASC_SCSI_Q(2, asc_scsi_q);
51219358
MW
9994 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
9995
9996 return ASC_NOERROR;
27c868c2 9997}
1da177e4 9998
27c868c2 9999/*
51219358 10000 * Build scatter-gather list for Adv Library (Wide Board).
27c868c2 10001 *
51219358
MW
10002 * Additional ADV_SG_BLOCK structures will need to be allocated
10003 * if the total number of scatter-gather elements exceeds
10004 * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
10005 * assumed to be physically contiguous.
27c868c2 10006 *
51219358
MW
10007 * Return:
10008 * ADV_SUCCESS(1) - SG List successfully created
10009 * ADV_ERROR(-1) - SG List creation failed
27c868c2 10010 */
51219358 10011static int
d2411495 10012adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
51219358 10013 int use_sg)
27c868c2 10014{
51219358
MW
10015 adv_sgblk_t *sgblkp;
10016 ADV_SCSI_REQ_Q *scsiqp;
10017 struct scatterlist *slp;
10018 int sg_elem_cnt;
10019 ADV_SG_BLOCK *sg_block, *prev_sg_block;
10020 ADV_PADDR sg_block_paddr;
27c868c2 10021 int i;
27c868c2 10022
51219358
MW
10023 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
10024 slp = (struct scatterlist *)scp->request_buffer;
10025 sg_elem_cnt = use_sg;
10026 prev_sg_block = NULL;
10027 reqp->sgblkp = NULL;
1da177e4 10028
51219358
MW
10029 for (;;) {
10030 /*
10031 * Allocate a 'adv_sgblk_t' structure from the board free
10032 * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
10033 * (15) scatter-gather elements.
10034 */
10035 if ((sgblkp = boardp->adv_sgblkp) == NULL) {
b352f923 10036 ASC_DBG(1, "no free adv_sgblk_t\n");
51219358 10037 ASC_STATS(scp->device->host, adv_build_nosg);
1da177e4 10038
51219358
MW
10039 /*
10040 * Allocation failed. Free 'adv_sgblk_t' structures
10041 * already allocated for the request.
10042 */
10043 while ((sgblkp = reqp->sgblkp) != NULL) {
10044 /* Remove 'sgblkp' from the request list. */
10045 reqp->sgblkp = sgblkp->next_sgblkp;
27c868c2 10046
51219358
MW
10047 /* Add 'sgblkp' to the board free list. */
10048 sgblkp->next_sgblkp = boardp->adv_sgblkp;
10049 boardp->adv_sgblkp = sgblkp;
10050 }
10051 return ASC_BUSY;
10052 }
1da177e4 10053
51219358
MW
10054 /* Complete 'adv_sgblk_t' board allocation. */
10055 boardp->adv_sgblkp = sgblkp->next_sgblkp;
10056 sgblkp->next_sgblkp = NULL;
1da177e4 10057
51219358
MW
10058 /*
10059 * Get 8 byte aligned virtual and physical addresses
10060 * for the allocated ADV_SG_BLOCK structure.
10061 */
10062 sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
10063 sg_block_paddr = virt_to_bus(sg_block);
27c868c2 10064
51219358
MW
10065 /*
10066 * Check if this is the first 'adv_sgblk_t' for the
10067 * request.
10068 */
10069 if (reqp->sgblkp == NULL) {
10070 /* Request's first scatter-gather block. */
10071 reqp->sgblkp = sgblkp;
27c868c2 10072
51219358
MW
10073 /*
10074 * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
10075 * address pointers.
10076 */
10077 scsiqp->sg_list_ptr = sg_block;
10078 scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
10079 } else {
10080 /* Request's second or later scatter-gather block. */
10081 sgblkp->next_sgblkp = reqp->sgblkp;
10082 reqp->sgblkp = sgblkp;
10083
10084 /*
10085 * Point the previous ADV_SG_BLOCK structure to
10086 * the newly allocated ADV_SG_BLOCK structure.
10087 */
10088 prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
27c868c2 10089 }
1da177e4 10090
51219358
MW
10091 for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
10092 sg_block->sg_list[i].sg_addr =
10093 cpu_to_le32(sg_dma_address(slp));
10094 sg_block->sg_list[i].sg_count =
10095 cpu_to_le32(sg_dma_len(slp));
10096 ASC_STATS_ADD(scp->device->host, sg_xfer,
10097 ASC_CEILING(sg_dma_len(slp), 512));
27c868c2 10098
51219358
MW
10099 if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
10100 sg_block->sg_cnt = i + 1;
10101 sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
10102 return ADV_SUCCESS;
10103 }
10104 slp++;
10105 }
10106 sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
10107 prev_sg_block = sg_block;
27c868c2 10108 }
51219358 10109}
1da177e4 10110
51219358
MW
10111/*
10112 * Build a request structure for the Adv Library (Wide Board).
10113 *
10114 * If an adv_req_t can not be allocated to issue the request,
10115 * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
10116 *
10117 * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
10118 * microcode for DMA addresses or math operations are byte swapped
10119 * to little-endian order.
10120 */
10121static int
d2411495 10122adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
51219358
MW
10123 ADV_SCSI_REQ_Q **adv_scsiqpp)
10124{
10125 adv_req_t *reqp;
10126 ADV_SCSI_REQ_Q *scsiqp;
10127 int i;
10128 int ret;
1da177e4 10129
27c868c2 10130 /*
51219358
MW
10131 * Allocate an adv_req_t structure from the board to execute
10132 * the command.
27c868c2 10133 */
51219358 10134 if (boardp->adv_reqp == NULL) {
b352f923 10135 ASC_DBG(1, "no free adv_req_t\n");
51219358
MW
10136 ASC_STATS(scp->device->host, adv_build_noreq);
10137 return ASC_BUSY;
10138 } else {
10139 reqp = boardp->adv_reqp;
10140 boardp->adv_reqp = reqp->next_reqp;
10141 reqp->next_reqp = NULL;
27c868c2 10142 }
1da177e4 10143
27c868c2 10144 /*
51219358 10145 * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
27c868c2 10146 */
51219358 10147 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
27c868c2
MW
10148
10149 /*
51219358 10150 * Initialize the structure.
27c868c2 10151 */
51219358 10152 scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
27c868c2
MW
10153
10154 /*
51219358 10155 * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
27c868c2 10156 */
51219358 10157 scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
27c868c2
MW
10158
10159 /*
51219358 10160 * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
27c868c2 10161 */
51219358 10162 reqp->cmndp = scp;
27c868c2
MW
10163
10164 /*
51219358 10165 * Build the ADV_SCSI_REQ_Q request.
27c868c2 10166 */
51219358
MW
10167
10168 /* Set CDB length and copy it to the request structure. */
10169 scsiqp->cdb_len = scp->cmd_len;
10170 /* Copy first 12 CDB bytes to cdb[]. */
10171 for (i = 0; i < scp->cmd_len && i < 12; i++) {
10172 scsiqp->cdb[i] = scp->cmnd[i];
10173 }
10174 /* Copy last 4 CDB bytes, if present, to cdb16[]. */
10175 for (; i < scp->cmd_len; i++) {
10176 scsiqp->cdb16[i - 12] = scp->cmnd[i];
27c868c2 10177 }
1da177e4 10178
51219358
MW
10179 scsiqp->target_id = scp->device->id;
10180 scsiqp->target_lun = scp->device->lun;
10181
10182 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
10183 scsiqp->sense_len = sizeof(scp->sense_buffer);
27c868c2
MW
10184
10185 /*
51219358
MW
10186 * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
10187 * buffer command.
27c868c2 10188 */
51219358
MW
10189
10190 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
10191 scsiqp->vdata_addr = scp->request_buffer;
10192 scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
10193
10194 if (scp->use_sg == 0) {
10195 /*
10196 * CDB request of single contiguous buffer.
10197 */
10198 reqp->sgblkp = NULL;
10199 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
10200 if (scp->request_bufflen) {
10201 scsiqp->vdata_addr = scp->request_buffer;
10202 scp->SCp.dma_handle =
10203 dma_map_single(boardp->dev, scp->request_buffer,
10204 scp->request_bufflen,
10205 scp->sc_data_direction);
10206 } else {
10207 scsiqp->vdata_addr = NULL;
10208 scp->SCp.dma_handle = 0;
10209 }
10210 scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
10211 scsiqp->sg_list_ptr = NULL;
10212 scsiqp->sg_real_addr = 0;
10213 ASC_STATS(scp->device->host, cont_cnt);
10214 ASC_STATS_ADD(scp->device->host, cont_xfer,
10215 ASC_CEILING(scp->request_bufflen, 512));
10216 } else {
10217 /*
10218 * CDB scatter-gather request list.
10219 */
10220 struct scatterlist *slp;
10221 int use_sg;
10222
10223 slp = (struct scatterlist *)scp->request_buffer;
10224 use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
10225 scp->sc_data_direction);
10226
10227 if (use_sg > ADV_MAX_SG_LIST) {
9d0e96eb
MW
10228 scmd_printk(KERN_ERR, scp, "use_sg %d > "
10229 "ADV_MAX_SG_LIST %d\n", use_sg,
51219358
MW
10230 scp->device->host->sg_tablesize);
10231 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
10232 scp->sc_data_direction);
10233 scp->result = HOST_BYTE(DID_ERROR);
10234
10235 /*
10236 * Free the 'adv_req_t' structure by adding it back
10237 * to the board free list.
10238 */
10239 reqp->next_reqp = boardp->adv_reqp;
10240 boardp->adv_reqp = reqp;
10241
10242 return ASC_ERROR;
10243 }
10244
10245 ret = adv_get_sglist(boardp, reqp, scp, use_sg);
10246 if (ret != ADV_SUCCESS) {
10247 /*
10248 * Free the adv_req_t structure by adding it back to
10249 * the board free list.
10250 */
10251 reqp->next_reqp = boardp->adv_reqp;
10252 boardp->adv_reqp = reqp;
10253
10254 return ret;
10255 }
10256
10257 ASC_STATS(scp->device->host, sg_cnt);
10258 ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
27c868c2 10259 }
1da177e4 10260
51219358
MW
10261 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
10262 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
27c868c2 10263
51219358 10264 *adv_scsiqpp = scsiqp;
27c868c2 10265
51219358
MW
10266 return ASC_NOERROR;
10267}
10268
10269static int AscSgListToQueue(int sg_list)
10270{
10271 int n_sg_list_qs;
10272
10273 n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
10274 if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
10275 n_sg_list_qs++;
10276 return n_sg_list_qs + 1;
10277}
10278
10279static uint
10280AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
10281{
10282 uint cur_used_qs;
10283 uint cur_free_qs;
10284 ASC_SCSI_BIT_ID_TYPE target_id;
10285 uchar tid_no;
10286
10287 target_id = ASC_TIX_TO_TARGET_ID(target_ix);
10288 tid_no = ASC_TIX_TO_TID(target_ix);
10289 if ((asc_dvc->unit_not_ready & target_id) ||
10290 (asc_dvc->queue_full_or_busy & target_id)) {
10291 return 0;
10292 }
10293 if (n_qs == 1) {
10294 cur_used_qs = (uint) asc_dvc->cur_total_qng +
10295 (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
10296 } else {
10297 cur_used_qs = (uint) asc_dvc->cur_total_qng +
10298 (uint) ASC_MIN_FREE_Q;
10299 }
10300 if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
10301 cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
10302 if (asc_dvc->cur_dvc_qng[tid_no] >=
10303 asc_dvc->max_dvc_qng[tid_no]) {
10304 return 0;
10305 }
10306 return cur_free_qs;
10307 }
10308 if (n_qs > 1) {
10309 if ((n_qs > asc_dvc->last_q_shortage)
10310 && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
10311 asc_dvc->last_q_shortage = n_qs;
10312 }
10313 }
10314 return 0;
10315}
10316
10317static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
10318{
10319 ushort q_addr;
10320 uchar next_qp;
10321 uchar q_status;
10322
10323 q_addr = ASC_QNO_TO_QADDR(free_q_head);
10324 q_status = (uchar)AscReadLramByte(iop_base,
10325 (ushort)(q_addr +
10326 ASC_SCSIQ_B_STATUS));
10327 next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
10328 if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
10329 return next_qp;
10330 return ASC_QLINK_END;
10331}
10332
10333static uchar
10334AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
10335{
10336 uchar i;
27c868c2 10337
51219358
MW
10338 for (i = 0; i < n_free_q; i++) {
10339 free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
10340 if (free_q_head == ASC_QLINK_END)
10341 break;
10342 }
10343 return free_q_head;
10344}
27c868c2 10345
51219358
MW
10346/*
10347 * void
10348 * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
10349 *
10350 * Calling/Exit State:
10351 * none
10352 *
10353 * Description:
10354 * Output an ASC_SCSI_Q structure to the chip
10355 */
10356static void
10357DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
10358{
10359 int i;
10360
10361 ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
10362 AscSetChipLramAddr(iop_base, s_addr);
10363 for (i = 0; i < 2 * words; i += 2) {
10364 if (i == 4 || i == 20) {
10365 continue;
10366 }
10367 outpw(iop_base + IOP_RAM_DATA,
10368 ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
27c868c2 10369 }
51219358 10370}
1da177e4 10371
51219358
MW
10372static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
10373{
10374 ushort q_addr;
10375 uchar tid_no;
10376 uchar sdtr_data;
10377 uchar syn_period_ix;
10378 uchar syn_offset;
10379 PortAddr iop_base;
10380
10381 iop_base = asc_dvc->iop_base;
10382 if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
10383 ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
10384 tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
10385 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
10386 syn_period_ix =
10387 (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
10388 syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
10389 AscMsgOutSDTR(asc_dvc,
10390 asc_dvc->sdtr_period_tbl[syn_period_ix],
10391 syn_offset);
10392 scsiq->q1.cntl |= QC_MSG_OUT;
10393 }
10394 q_addr = ASC_QNO_TO_QADDR(q_no);
10395 if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
10396 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
27c868c2 10397 }
51219358
MW
10398 scsiq->q1.status = QS_FREE;
10399 AscMemWordCopyPtrToLram(iop_base,
10400 q_addr + ASC_SCSIQ_CDB_BEG,
10401 (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
10402
10403 DvcPutScsiQ(iop_base,
10404 q_addr + ASC_SCSIQ_CPY_BEG,
10405 (uchar *)&scsiq->q1.cntl,
10406 ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
10407 AscWriteLramWord(iop_base,
10408 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
10409 (ushort)(((ushort)scsiq->q1.
10410 q_no << 8) | (ushort)QS_READY));
10411 return 1;
10412}
10413
10414static int
10415AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
10416{
10417 int sta;
10418 int i;
10419 ASC_SG_HEAD *sg_head;
10420 ASC_SG_LIST_Q scsi_sg_q;
10421 ASC_DCNT saved_data_addr;
10422 ASC_DCNT saved_data_cnt;
10423 PortAddr iop_base;
10424 ushort sg_list_dwords;
10425 ushort sg_index;
10426 ushort sg_entry_cnt;
10427 ushort q_addr;
10428 uchar next_qp;
1da177e4 10429
51219358
MW
10430 iop_base = asc_dvc->iop_base;
10431 sg_head = scsiq->sg_head;
10432 saved_data_addr = scsiq->q1.data_addr;
10433 saved_data_cnt = scsiq->q1.data_cnt;
10434 scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
10435 scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
10436#if CC_VERY_LONG_SG_LIST
27c868c2 10437 /*
51219358
MW
10438 * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
10439 * then not all SG elements will fit in the allocated queues.
10440 * The rest of the SG elements will be copied when the RISC
10441 * completes the SG elements that fit and halts.
27c868c2 10442 */
51219358
MW
10443 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
10444 /*
10445 * Set sg_entry_cnt to be the number of SG elements that
10446 * will fit in the allocated SG queues. It is minus 1, because
10447 * the first SG element is handled above. ASC_MAX_SG_LIST is
10448 * already inflated by 1 to account for this. For example it
10449 * may be 50 which is 1 + 7 queues * 7 SG elements.
10450 */
10451 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
27c868c2 10452
51219358
MW
10453 /*
10454 * Keep track of remaining number of SG elements that will
10455 * need to be handled from a_isr.c.
10456 */
10457 scsiq->remain_sg_entry_cnt =
10458 sg_head->entry_cnt - ASC_MAX_SG_LIST;
10459 } else {
10460#endif /* CC_VERY_LONG_SG_LIST */
10461 /*
10462 * Set sg_entry_cnt to be the number of SG elements that
10463 * will fit in the allocated SG queues. It is minus 1, because
10464 * the first SG element is handled above.
10465 */
10466 sg_entry_cnt = sg_head->entry_cnt - 1;
10467#if CC_VERY_LONG_SG_LIST
10468 }
10469#endif /* CC_VERY_LONG_SG_LIST */
10470 if (sg_entry_cnt != 0) {
10471 scsiq->q1.cntl |= QC_SG_HEAD;
10472 q_addr = ASC_QNO_TO_QADDR(q_no);
10473 sg_index = 1;
10474 scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
10475 scsi_sg_q.sg_head_qp = q_no;
10476 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
10477 for (i = 0; i < sg_head->queue_cnt; i++) {
10478 scsi_sg_q.seq_no = i + 1;
10479 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
10480 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
10481 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
10482 if (i == 0) {
10483 scsi_sg_q.sg_list_cnt =
10484 ASC_SG_LIST_PER_Q;
10485 scsi_sg_q.sg_cur_list_cnt =
10486 ASC_SG_LIST_PER_Q;
10487 } else {
10488 scsi_sg_q.sg_list_cnt =
10489 ASC_SG_LIST_PER_Q - 1;
10490 scsi_sg_q.sg_cur_list_cnt =
10491 ASC_SG_LIST_PER_Q - 1;
10492 }
10493 } else {
10494#if CC_VERY_LONG_SG_LIST
10495 /*
10496 * This is the last SG queue in the list of
10497 * allocated SG queues. If there are more
10498 * SG elements than will fit in the allocated
10499 * queues, then set the QCSG_SG_XFER_MORE flag.
10500 */
10501 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
10502 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
10503 } else {
10504#endif /* CC_VERY_LONG_SG_LIST */
10505 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
10506#if CC_VERY_LONG_SG_LIST
10507 }
10508#endif /* CC_VERY_LONG_SG_LIST */
10509 sg_list_dwords = sg_entry_cnt << 1;
10510 if (i == 0) {
10511 scsi_sg_q.sg_list_cnt = sg_entry_cnt;
10512 scsi_sg_q.sg_cur_list_cnt =
10513 sg_entry_cnt;
10514 } else {
10515 scsi_sg_q.sg_list_cnt =
10516 sg_entry_cnt - 1;
10517 scsi_sg_q.sg_cur_list_cnt =
10518 sg_entry_cnt - 1;
10519 }
10520 sg_entry_cnt = 0;
10521 }
10522 next_qp = AscReadLramByte(iop_base,
10523 (ushort)(q_addr +
10524 ASC_SCSIQ_B_FWD));
10525 scsi_sg_q.q_no = next_qp;
10526 q_addr = ASC_QNO_TO_QADDR(next_qp);
10527 AscMemWordCopyPtrToLram(iop_base,
10528 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
10529 (uchar *)&scsi_sg_q,
10530 sizeof(ASC_SG_LIST_Q) >> 1);
10531 AscMemDWordCopyPtrToLram(iop_base,
10532 q_addr + ASC_SGQ_LIST_BEG,
10533 (uchar *)&sg_head->
10534 sg_list[sg_index],
10535 sg_list_dwords);
10536 sg_index += ASC_SG_LIST_PER_Q;
10537 scsiq->next_sg_index = sg_index;
27c868c2 10538 }
51219358
MW
10539 } else {
10540 scsiq->q1.cntl &= ~QC_SG_HEAD;
27c868c2 10541 }
51219358
MW
10542 sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
10543 scsiq->q1.data_addr = saved_data_addr;
10544 scsiq->q1.data_cnt = saved_data_cnt;
10545 return (sta);
10546}
27c868c2 10547
51219358
MW
10548static int
10549AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
10550{
10551 PortAddr iop_base;
10552 uchar free_q_head;
10553 uchar next_qp;
10554 uchar tid_no;
10555 uchar target_ix;
10556 int sta;
27c868c2 10557
51219358
MW
10558 iop_base = asc_dvc->iop_base;
10559 target_ix = scsiq->q2.target_ix;
10560 tid_no = ASC_TIX_TO_TID(target_ix);
10561 sta = 0;
10562 free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
10563 if (n_q_required > 1) {
10564 next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
10565 (uchar)n_q_required);
10566 if (next_qp != ASC_QLINK_END) {
10567 asc_dvc->last_q_shortage = 0;
10568 scsiq->sg_head->queue_cnt = n_q_required - 1;
10569 scsiq->q1.q_no = free_q_head;
10570 sta = AscPutReadySgListQueue(asc_dvc, scsiq,
10571 free_q_head);
10572 }
10573 } else if (n_q_required == 1) {
10574 next_qp = AscAllocFreeQueue(iop_base, free_q_head);
10575 if (next_qp != ASC_QLINK_END) {
10576 scsiq->q1.q_no = free_q_head;
10577 sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
27c868c2
MW
10578 }
10579 }
51219358
MW
10580 if (sta == 1) {
10581 AscPutVarFreeQHead(iop_base, next_qp);
10582 asc_dvc->cur_total_qng += n_q_required;
10583 asc_dvc->cur_dvc_qng[tid_no]++;
27c868c2 10584 }
51219358
MW
10585 return sta;
10586}
27c868c2 10587
51219358
MW
10588#define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
10589static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
10590 INQUIRY,
10591 REQUEST_SENSE,
10592 READ_CAPACITY,
10593 READ_TOC,
10594 MODE_SELECT,
10595 MODE_SENSE,
10596 MODE_SELECT_10,
10597 MODE_SENSE_10,
10598 0xFF,
10599 0xFF,
10600 0xFF,
10601 0xFF,
10602 0xFF,
10603 0xFF,
10604 0xFF,
10605 0xFF
10606};
27c868c2 10607
51219358
MW
10608static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
10609{
10610 PortAddr iop_base;
10611 int sta;
10612 int n_q_required;
10613 int disable_syn_offset_one_fix;
10614 int i;
10615 ASC_PADDR addr;
10616 ushort sg_entry_cnt = 0;
10617 ushort sg_entry_cnt_minus_one = 0;
10618 uchar target_ix;
10619 uchar tid_no;
10620 uchar sdtr_data;
10621 uchar extra_bytes;
10622 uchar scsi_cmd;
10623 uchar disable_cmd;
10624 ASC_SG_HEAD *sg_head;
10625 ASC_DCNT data_cnt;
27c868c2 10626
51219358
MW
10627 iop_base = asc_dvc->iop_base;
10628 sg_head = scsiq->sg_head;
10629 if (asc_dvc->err_code != 0)
10630 return (ERR);
10631 scsiq->q1.q_no = 0;
10632 if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
10633 scsiq->q1.extra_bytes = 0;
27c868c2 10634 }
51219358
MW
10635 sta = 0;
10636 target_ix = scsiq->q2.target_ix;
10637 tid_no = ASC_TIX_TO_TID(target_ix);
10638 n_q_required = 1;
10639 if (scsiq->cdbptr[0] == REQUEST_SENSE) {
10640 if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
10641 asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
10642 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
10643 AscMsgOutSDTR(asc_dvc,
10644 asc_dvc->
10645 sdtr_period_tbl[(sdtr_data >> 4) &
10646 (uchar)(asc_dvc->
10647 max_sdtr_index -
10648 1)],
10649 (uchar)(sdtr_data & (uchar)
10650 ASC_SYN_MAX_OFFSET));
10651 scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
10652 }
10653 }
10654 if (asc_dvc->in_critical_cnt != 0) {
10655 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
10656 return (ERR);
10657 }
10658 asc_dvc->in_critical_cnt++;
10659 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
10660 if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
10661 asc_dvc->in_critical_cnt--;
10662 return (ERR);
10663 }
10664#if !CC_VERY_LONG_SG_LIST
10665 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
10666 asc_dvc->in_critical_cnt--;
10667 return (ERR);
10668 }
10669#endif /* !CC_VERY_LONG_SG_LIST */
10670 if (sg_entry_cnt == 1) {
10671 scsiq->q1.data_addr =
10672 (ADV_PADDR)sg_head->sg_list[0].addr;
10673 scsiq->q1.data_cnt =
10674 (ADV_DCNT)sg_head->sg_list[0].bytes;
10675 scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
10676 }
10677 sg_entry_cnt_minus_one = sg_entry_cnt - 1;
10678 }
10679 scsi_cmd = scsiq->cdbptr[0];
10680 disable_syn_offset_one_fix = FALSE;
10681 if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
10682 !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
10683 if (scsiq->q1.cntl & QC_SG_HEAD) {
10684 data_cnt = 0;
10685 for (i = 0; i < sg_entry_cnt; i++) {
10686 data_cnt +=
10687 (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
10688 bytes);
10689 }
10690 } else {
10691 data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
10692 }
10693 if (data_cnt != 0UL) {
10694 if (data_cnt < 512UL) {
10695 disable_syn_offset_one_fix = TRUE;
10696 } else {
10697 for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
10698 i++) {
10699 disable_cmd =
10700 _syn_offset_one_disable_cmd[i];
10701 if (disable_cmd == 0xFF) {
10702 break;
10703 }
10704 if (scsi_cmd == disable_cmd) {
10705 disable_syn_offset_one_fix =
10706 TRUE;
10707 break;
10708 }
10709 }
10710 }
10711 }
10712 }
10713 if (disable_syn_offset_one_fix) {
10714 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
10715 scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
10716 ASC_TAG_FLAG_DISABLE_DISCONNECT);
10717 } else {
10718 scsiq->q2.tag_code &= 0x27;
10719 }
10720 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
10721 if (asc_dvc->bug_fix_cntl) {
10722 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
10723 if ((scsi_cmd == READ_6) ||
10724 (scsi_cmd == READ_10)) {
10725 addr =
10726 (ADV_PADDR)le32_to_cpu(sg_head->
10727 sg_list
10728 [sg_entry_cnt_minus_one].
10729 addr) +
10730 (ADV_DCNT)le32_to_cpu(sg_head->
10731 sg_list
10732 [sg_entry_cnt_minus_one].
10733 bytes);
10734 extra_bytes =
10735 (uchar)((ushort)addr & 0x0003);
10736 if ((extra_bytes != 0)
10737 &&
10738 ((scsiq->q2.
10739 tag_code &
10740 ASC_TAG_FLAG_EXTRA_BYTES)
10741 == 0)) {
10742 scsiq->q2.tag_code |=
10743 ASC_TAG_FLAG_EXTRA_BYTES;
10744 scsiq->q1.extra_bytes =
10745 extra_bytes;
10746 data_cnt =
10747 le32_to_cpu(sg_head->
10748 sg_list
10749 [sg_entry_cnt_minus_one].
10750 bytes);
10751 data_cnt -=
10752 (ASC_DCNT) extra_bytes;
10753 sg_head->
10754 sg_list
10755 [sg_entry_cnt_minus_one].
10756 bytes =
10757 cpu_to_le32(data_cnt);
10758 }
10759 }
10760 }
10761 }
10762 sg_head->entry_to_copy = sg_head->entry_cnt;
10763#if CC_VERY_LONG_SG_LIST
27c868c2 10764 /*
51219358
MW
10765 * Set the sg_entry_cnt to the maximum possible. The rest of
10766 * the SG elements will be copied when the RISC completes the
10767 * SG elements that fit and halts.
27c868c2 10768 */
51219358
MW
10769 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
10770 sg_entry_cnt = ASC_MAX_SG_LIST;
10771 }
10772#endif /* CC_VERY_LONG_SG_LIST */
10773 n_q_required = AscSgListToQueue(sg_entry_cnt);
10774 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
10775 (uint) n_q_required)
10776 || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
10777 if ((sta =
10778 AscSendScsiQueue(asc_dvc, scsiq,
10779 n_q_required)) == 1) {
10780 asc_dvc->in_critical_cnt--;
10781 return (sta);
27c868c2 10782 }
51219358
MW
10783 }
10784 } else {
10785 if (asc_dvc->bug_fix_cntl) {
10786 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
10787 if ((scsi_cmd == READ_6) ||
10788 (scsi_cmd == READ_10)) {
10789 addr =
10790 le32_to_cpu(scsiq->q1.data_addr) +
10791 le32_to_cpu(scsiq->q1.data_cnt);
10792 extra_bytes =
10793 (uchar)((ushort)addr & 0x0003);
10794 if ((extra_bytes != 0)
10795 &&
10796 ((scsiq->q2.
10797 tag_code &
10798 ASC_TAG_FLAG_EXTRA_BYTES)
10799 == 0)) {
10800 data_cnt =
10801 le32_to_cpu(scsiq->q1.
10802 data_cnt);
10803 if (((ushort)data_cnt & 0x01FF)
10804 == 0) {
10805 scsiq->q2.tag_code |=
10806 ASC_TAG_FLAG_EXTRA_BYTES;
10807 data_cnt -= (ASC_DCNT)
10808 extra_bytes;
10809 scsiq->q1.data_cnt =
10810 cpu_to_le32
10811 (data_cnt);
10812 scsiq->q1.extra_bytes =
10813 extra_bytes;
10814 }
10815 }
10816 }
10817 }
10818 }
10819 n_q_required = 1;
10820 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
10821 ((scsiq->q1.cntl & QC_URGENT) != 0)) {
10822 if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
10823 n_q_required)) == 1) {
10824 asc_dvc->in_critical_cnt--;
10825 return (sta);
27c868c2
MW
10826 }
10827 }
10828 }
51219358
MW
10829 asc_dvc->in_critical_cnt--;
10830 return (sta);
1da177e4
LT
10831}
10832
10833/*
51219358 10834 * AdvExeScsiQueue() - Send a request to the RISC microcode program.
1da177e4 10835 *
51219358
MW
10836 * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
10837 * add the carrier to the ICQ (Initiator Command Queue), and tickle the
10838 * RISC to notify it a new command is ready to be executed.
10839 *
10840 * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
10841 * set to SCSI_MAX_RETRY.
10842 *
10843 * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
10844 * for DMA addresses or math operations are byte swapped to little-endian
10845 * order.
10846 *
10847 * Return:
10848 * ADV_SUCCESS(1) - The request was successfully queued.
10849 * ADV_BUSY(0) - Resource unavailable; Retry again after pending
10850 * request completes.
10851 * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
10852 * host IC error.
10853 */
10854static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
10855{
10856 AdvPortAddr iop_base;
51219358
MW
10857 ADV_PADDR req_paddr;
10858 ADV_CARR_T *new_carrp;
1da177e4 10859
27c868c2 10860 /*
51219358 10861 * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
27c868c2 10862 */
51219358
MW
10863 if (scsiq->target_id > ADV_MAX_TID) {
10864 scsiq->host_status = QHSTA_M_INVALID_DEVICE;
10865 scsiq->done_status = QD_WITH_ERROR;
27c868c2
MW
10866 return ADV_ERROR;
10867 }
1da177e4 10868
51219358 10869 iop_base = asc_dvc->iop_base;
1da177e4 10870
27c868c2 10871 /*
51219358
MW
10872 * Allocate a carrier ensuring at least one carrier always
10873 * remains on the freelist and initialize fields.
27c868c2 10874 */
51219358
MW
10875 if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
10876 return ADV_BUSY;
27c868c2 10877 }
51219358
MW
10878 asc_dvc->carr_freelist = (ADV_CARR_T *)
10879 ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
10880 asc_dvc->carr_pending_cnt++;
1da177e4 10881
27c868c2 10882 /*
51219358
MW
10883 * Set the carrier to be a stopper by setting 'next_vpa'
10884 * to the stopper value. The current stopper will be changed
10885 * below to point to the new stopper.
27c868c2 10886 */
51219358 10887 new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
27c868c2
MW
10888
10889 /*
51219358 10890 * Clear the ADV_SCSI_REQ_Q done flag.
27c868c2 10891 */
51219358 10892 scsiq->a_flag &= ~ADV_SCSIQ_DONE;
27c868c2 10893
fd625f47 10894 req_paddr = virt_to_bus(scsiq);
51219358 10895 BUG_ON(req_paddr & 31);
51219358
MW
10896 /* Wait for assertion before making little-endian */
10897 req_paddr = cpu_to_le32(req_paddr);
27c868c2 10898
51219358
MW
10899 /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
10900 scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
10901 scsiq->scsiq_rptr = req_paddr;
10902
10903 scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
27c868c2 10904 /*
51219358
MW
10905 * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
10906 * order during initialization.
27c868c2 10907 */
51219358 10908 scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
1da177e4 10909
27c868c2 10910 /*
51219358
MW
10911 * Use the current stopper to send the ADV_SCSI_REQ_Q command to
10912 * the microcode. The newly allocated stopper will become the new
10913 * stopper.
27c868c2 10914 */
51219358 10915 asc_dvc->icq_sp->areq_vpa = req_paddr;
1da177e4 10916
27c868c2 10917 /*
51219358
MW
10918 * Set the 'next_vpa' pointer for the old stopper to be the
10919 * physical address of the new stopper. The RISC can only
10920 * follow physical addresses.
27c868c2 10921 */
51219358 10922 asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
27c868c2
MW
10923
10924 /*
51219358 10925 * Set the host adapter stopper pointer to point to the new carrier.
27c868c2 10926 */
51219358
MW
10927 asc_dvc->icq_sp = new_carrp;
10928
10929 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
10930 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
10931 /*
10932 * Tickle the RISC to tell it to read its Command Queue Head pointer.
10933 */
10934 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
10935 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
10936 /*
10937 * Clear the tickle value. In the ASC-3550 the RISC flag
10938 * command 'clr_tickle_a' does not work unless the host
10939 * value is cleared.
10940 */
10941 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
10942 ADV_TICKLE_NOP);
10943 }
10944 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
10945 /*
10946 * Notify the RISC a carrier is ready by writing the physical
10947 * address of the new carrier stopper to the COMMA register.
10948 */
10949 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
10950 le32_to_cpu(new_carrp->carr_pa));
27c868c2 10951 }
1da177e4 10952
51219358
MW
10953 return ADV_SUCCESS;
10954}
10955
10956/*
10957 * Execute a single 'Scsi_Cmnd'.
10958 *
10959 * The function 'done' is called when the request has been completed.
10960 *
10961 * Scsi_Cmnd:
10962 *
10963 * host - board controlling device
10964 * device - device to send command
10965 * target - target of device
10966 * lun - lun of device
10967 * cmd_len - length of SCSI CDB
10968 * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
10969 * use_sg - if non-zero indicates scatter-gather request with use_sg elements
10970 *
10971 * if (use_sg == 0) {
10972 * request_buffer - buffer address for request
10973 * request_bufflen - length of request buffer
10974 * } else {
10975 * request_buffer - pointer to scatterlist structure
10976 * }
10977 *
10978 * sense_buffer - sense command buffer
10979 *
10980 * result (4 bytes of an int):
10981 * Byte Meaning
10982 * 0 SCSI Status Byte Code
10983 * 1 SCSI One Byte Message Code
10984 * 2 Host Error Code
10985 * 3 Mid-Level Error Code
10986 *
10987 * host driver fields:
10988 * SCp - Scsi_Pointer used for command processing status
10989 * scsi_done - used to save caller's done function
10990 * host_scribble - used for pointer to another struct scsi_cmnd
10991 *
10992 * If this function returns ASC_NOERROR the request will be completed
10993 * from the interrupt handler.
10994 *
10995 * If this function returns ASC_ERROR the host error code has been set,
10996 * and the called must call asc_scsi_done.
10997 *
10998 * If ASC_BUSY is returned the request will be returned to the midlayer
10999 * and re-tried later.
11000 */
11001static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
11002{
41d2493d 11003 int ret, err_code;
d2411495 11004 struct asc_board *boardp = shost_priv(scp->device->host);
51219358 11005
b352f923 11006 ASC_DBG(1, "scp 0x%p\n", scp);
27c868c2 11007
51219358 11008 if (ASC_NARROW_BOARD(boardp)) {
41d2493d 11009 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
05848b6e 11010 struct asc_scsi_q asc_scsi_q;
27c868c2 11011
41d2493d 11012 /* asc_build_req() can not return ASC_BUSY. */
05848b6e
MW
11013 ret = asc_build_req(boardp, scp, &asc_scsi_q);
11014 if (ret == ASC_ERROR) {
51219358
MW
11015 ASC_STATS(scp->device->host, build_error);
11016 return ASC_ERROR;
11017 }
1da177e4 11018
41d2493d 11019 ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
05848b6e 11020 kfree(asc_scsi_q.sg_head);
41d2493d 11021 err_code = asc_dvc->err_code;
51219358 11022 } else {
41d2493d
MW
11023 ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
11024 ADV_SCSI_REQ_Q *adv_scsiqp;
27c868c2 11025
51219358
MW
11026 switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
11027 case ASC_NOERROR:
b352f923 11028 ASC_DBG(3, "adv_build_req ASC_NOERROR\n");
51219358
MW
11029 break;
11030 case ASC_BUSY:
b352f923 11031 ASC_DBG(1, "adv_build_req ASC_BUSY\n");
51219358
MW
11032 /*
11033 * The asc_stats fields 'adv_build_noreq' and
11034 * 'adv_build_nosg' count wide board busy conditions.
11035 * They are updated in adv_build_req and
11036 * adv_get_sglist, respectively.
11037 */
11038 return ASC_BUSY;
11039 case ASC_ERROR:
11040 default:
b352f923 11041 ASC_DBG(1, "adv_build_req ASC_ERROR\n");
51219358
MW
11042 ASC_STATS(scp->device->host, build_error);
11043 return ASC_ERROR;
11044 }
11045
41d2493d
MW
11046 ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
11047 err_code = adv_dvc->err_code;
11048 }
11049
11050 switch (ret) {
11051 case ASC_NOERROR:
11052 ASC_STATS(scp->device->host, exe_noerror);
11053 /*
11054 * Increment monotonically increasing per device
11055 * successful request counter. Wrapping doesn't matter.
11056 */
11057 boardp->reqcnt[scp->device->id]++;
b352f923 11058 ASC_DBG(1, "ExeScsiQueue() ASC_NOERROR\n");
41d2493d
MW
11059 break;
11060 case ASC_BUSY:
11061 ASC_STATS(scp->device->host, exe_busy);
11062 break;
11063 case ASC_ERROR:
9d0e96eb
MW
11064 scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, "
11065 "err_code 0x%x\n", err_code);
41d2493d
MW
11066 ASC_STATS(scp->device->host, exe_error);
11067 scp->result = HOST_BYTE(DID_ERROR);
11068 break;
11069 default:
9d0e96eb
MW
11070 scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, "
11071 "err_code 0x%x\n", err_code);
41d2493d
MW
11072 ASC_STATS(scp->device->host, exe_unknown);
11073 scp->result = HOST_BYTE(DID_ERROR);
11074 break;
27c868c2 11075 }
1da177e4 11076
b352f923 11077 ASC_DBG(1, "end\n");
51219358
MW
11078 return ret;
11079}
27c868c2 11080
51219358
MW
11081/*
11082 * advansys_queuecommand() - interrupt-driven I/O entrypoint.
11083 *
11084 * This function always returns 0. Command return status is saved
11085 * in the 'scp' result field.
11086 */
11087static int
11088advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
11089{
11090 struct Scsi_Host *shost = scp->device->host;
51219358 11091 int asc_res, result = 0;
27c868c2 11092
51219358
MW
11093 ASC_STATS(shost, queuecommand);
11094 scp->scsi_done = done;
27c868c2 11095
51219358 11096 asc_res = asc_execute_scsi_cmnd(scp);
51219358
MW
11097
11098 switch (asc_res) {
11099 case ASC_NOERROR:
11100 break;
11101 case ASC_BUSY:
11102 result = SCSI_MLQUEUE_HOST_BUSY;
11103 break;
11104 case ASC_ERROR:
11105 default:
11106 asc_scsi_done(scp);
11107 break;
11108 }
11109
11110 return result;
11111}
11112
11113static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
11114{
11115 PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
11116 (PortAddr) (ASC_EISA_CFG_IOP_MASK);
11117 return inpw(eisa_cfg_iop);
11118}
11119
11120/*
11121 * Return the BIOS address of the adapter at the specified
11122 * I/O port and with the specified bus type.
11123 */
11124static unsigned short __devinit
11125AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
11126{
11127 unsigned short cfg_lsw;
11128 unsigned short bios_addr;
27c868c2
MW
11129
11130 /*
51219358
MW
11131 * The PCI BIOS is re-located by the motherboard BIOS. Because
11132 * of this the driver can not determine where a PCI BIOS is
11133 * loaded and executes.
27c868c2 11134 */
51219358
MW
11135 if (bus_type & ASC_IS_PCI)
11136 return 0;
27c868c2 11137
51219358
MW
11138 if ((bus_type & ASC_IS_EISA) != 0) {
11139 cfg_lsw = AscGetEisaChipCfg(iop_base);
11140 cfg_lsw &= 0x000F;
11141 bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
11142 return bios_addr;
11143 }
27c868c2 11144
51219358 11145 cfg_lsw = AscGetChipCfgLsw(iop_base);
27c868c2
MW
11146
11147 /*
51219358 11148 * ISA PnP uses the top bit as the 32K BIOS flag
27c868c2 11149 */
51219358
MW
11150 if (bus_type == ASC_IS_ISAPNP)
11151 cfg_lsw &= 0x7FFF;
11152 bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
11153 return bios_addr;
11154}
11155
11156static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
11157{
11158 ushort cfg_lsw;
11159
11160 if (AscGetChipScsiID(iop_base) == new_host_id) {
11161 return (new_host_id);
27c868c2 11162 }
51219358
MW
11163 cfg_lsw = AscGetChipCfgLsw(iop_base);
11164 cfg_lsw &= 0xF8FF;
11165 cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
11166 AscSetChipCfgLsw(iop_base, cfg_lsw);
11167 return (AscGetChipScsiID(iop_base));
11168}
27c868c2 11169
51219358
MW
11170static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
11171{
11172 unsigned char sc;
27c868c2 11173
51219358
MW
11174 AscSetBank(iop_base, 1);
11175 sc = inp(iop_base + IOP_REG_SC);
11176 AscSetBank(iop_base, 0);
11177 return sc;
11178}
27c868c2 11179
51219358
MW
11180static unsigned char __devinit
11181AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
11182{
11183 if (bus_type & ASC_IS_EISA) {
11184 PortAddr eisa_iop;
11185 unsigned char revision;
11186 eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
11187 (PortAddr) ASC_EISA_REV_IOP_MASK;
11188 revision = inp(eisa_iop);
11189 return ASC_CHIP_MIN_VER_EISA - 1 + revision;
27c868c2 11190 }
51219358
MW
11191 return AscGetChipVerNo(iop_base);
11192}
27c868c2 11193
51219358
MW
11194#ifdef CONFIG_ISA
11195static void __devinit AscEnableIsaDma(uchar dma_channel)
11196{
11197 if (dma_channel < 4) {
11198 outp(0x000B, (ushort)(0xC0 | dma_channel));
11199 outp(0x000A, dma_channel);
11200 } else if (dma_channel < 8) {
11201 outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
11202 outp(0x00D4, (ushort)(dma_channel - 4));
11203 }
51219358
MW
11204}
11205#endif /* CONFIG_ISA */
11206
11207static int AscStopQueueExe(PortAddr iop_base)
11208{
11209 int count = 0;
11210
11211 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
11212 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
11213 ASC_STOP_REQ_RISC_STOP);
11214 do {
11215 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
11216 ASC_STOP_ACK_RISC_STOP) {
11217 return (1);
11218 }
11219 mdelay(100);
11220 } while (count++ < 20);
11221 }
11222 return (0);
11223}
11224
11225static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
11226{
11227 if (bus_type & ASC_IS_ISA)
11228 return ASC_MAX_ISA_DMA_COUNT;
11229 else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
11230 return ASC_MAX_VL_DMA_COUNT;
11231 return ASC_MAX_PCI_DMA_COUNT;
27c868c2 11232}
1da177e4 11233
51219358
MW
11234#ifdef CONFIG_ISA
11235static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
27c868c2 11236{
51219358 11237 ushort channel;
1da177e4 11238
51219358
MW
11239 channel = AscGetChipCfgLsw(iop_base) & 0x0003;
11240 if (channel == 0x03)
11241 return (0);
11242 else if (channel == 0x00)
11243 return (7);
11244 return (channel + 4);
11245}
1da177e4 11246
51219358
MW
11247static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
11248{
11249 ushort cfg_lsw;
11250 uchar value;
1da177e4 11251
51219358
MW
11252 if ((dma_channel >= 5) && (dma_channel <= 7)) {
11253 if (dma_channel == 7)
11254 value = 0x00;
11255 else
11256 value = dma_channel - 4;
11257 cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
11258 cfg_lsw |= value;
11259 AscSetChipCfgLsw(iop_base, cfg_lsw);
11260 return (AscGetIsaDmaChannel(iop_base));
11261 }
11262 return 0;
11263}
1da177e4 11264
51219358
MW
11265static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
11266{
11267 uchar speed_value;
1da177e4 11268
51219358
MW
11269 AscSetBank(iop_base, 1);
11270 speed_value = AscReadChipDmaSpeed(iop_base);
11271 speed_value &= 0x07;
11272 AscSetBank(iop_base, 0);
11273 return speed_value;
11274}
1da177e4 11275
51219358
MW
11276static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
11277{
11278 speed_value &= 0x07;
11279 AscSetBank(iop_base, 1);
11280 AscWriteChipDmaSpeed(iop_base, speed_value);
11281 AscSetBank(iop_base, 0);
11282 return AscGetIsaDmaSpeed(iop_base);
11283}
11284#endif /* CONFIG_ISA */
1da177e4 11285
51219358
MW
11286static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
11287{
11288 int i;
11289 PortAddr iop_base;
11290 ushort warn_code;
11291 uchar chip_version;
1da177e4 11292
51219358
MW
11293 iop_base = asc_dvc->iop_base;
11294 warn_code = 0;
11295 asc_dvc->err_code = 0;
11296 if ((asc_dvc->bus_type &
11297 (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
11298 asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
27c868c2 11299 }
51219358
MW
11300 AscSetChipControl(iop_base, CC_HALT);
11301 AscSetChipStatus(iop_base, 0);
11302 asc_dvc->bug_fix_cntl = 0;
11303 asc_dvc->pci_fix_asyn_xfer = 0;
11304 asc_dvc->pci_fix_asyn_xfer_always = 0;
11305 /* asc_dvc->init_state initalized in AscInitGetConfig(). */
11306 asc_dvc->sdtr_done = 0;
11307 asc_dvc->cur_total_qng = 0;
11308 asc_dvc->is_in_int = 0;
11309 asc_dvc->in_critical_cnt = 0;
11310 asc_dvc->last_q_shortage = 0;
11311 asc_dvc->use_tagged_qng = 0;
11312 asc_dvc->no_scam = 0;
11313 asc_dvc->unit_not_ready = 0;
11314 asc_dvc->queue_full_or_busy = 0;
11315 asc_dvc->redo_scam = 0;
11316 asc_dvc->res2 = 0;
afbb68c3 11317 asc_dvc->min_sdtr_index = 0;
51219358
MW
11318 asc_dvc->cfg->can_tagged_qng = 0;
11319 asc_dvc->cfg->cmd_qng_enabled = 0;
11320 asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
11321 asc_dvc->init_sdtr = 0;
11322 asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
11323 asc_dvc->scsi_reset_wait = 3;
11324 asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
11325 asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
11326 asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
11327 asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
11328 asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
51219358
MW
11329 chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
11330 asc_dvc->cfg->chip_version = chip_version;
afbb68c3 11331 asc_dvc->sdtr_period_tbl = asc_syn_xfer_period;
51219358
MW
11332 asc_dvc->max_sdtr_index = 7;
11333 if ((asc_dvc->bus_type & ASC_IS_PCI) &&
11334 (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
11335 asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
afbb68c3 11336 asc_dvc->sdtr_period_tbl = asc_syn_ultra_xfer_period;
51219358
MW
11337 asc_dvc->max_sdtr_index = 15;
11338 if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
11339 AscSetExtraControl(iop_base,
11340 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
11341 } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
11342 AscSetExtraControl(iop_base,
11343 (SEC_ACTIVE_NEGATE |
11344 SEC_ENABLE_FILTER));
27c868c2
MW
11345 }
11346 }
51219358
MW
11347 if (asc_dvc->bus_type == ASC_IS_PCI) {
11348 AscSetExtraControl(iop_base,
11349 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
11350 }
1da177e4 11351
51219358
MW
11352 asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
11353#ifdef CONFIG_ISA
11354 if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
11355 if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
11356 AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
11357 asc_dvc->bus_type = ASC_IS_ISAPNP;
27c868c2 11358 }
51219358
MW
11359 asc_dvc->cfg->isa_dma_channel =
11360 (uchar)AscGetIsaDmaChannel(iop_base);
27c868c2 11361 }
51219358
MW
11362#endif /* CONFIG_ISA */
11363 for (i = 0; i <= ASC_MAX_TID; i++) {
11364 asc_dvc->cur_dvc_qng[i] = 0;
11365 asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
11366 asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
11367 asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
11368 asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
27c868c2 11369 }
51219358
MW
11370 return warn_code;
11371}
1da177e4 11372
51219358
MW
11373static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
11374{
11375 int retry;
27c868c2 11376
51219358
MW
11377 for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
11378 unsigned char read_back;
11379 AscSetChipEEPCmd(iop_base, cmd_reg);
11380 mdelay(1);
11381 read_back = AscGetChipEEPCmd(iop_base);
11382 if (read_back == cmd_reg)
11383 return 1;
27c868c2 11384 }
51219358
MW
11385 return 0;
11386}
1da177e4 11387
51219358
MW
11388static void __devinit AscWaitEEPRead(void)
11389{
11390 mdelay(1);
27c868c2 11391}
1da177e4 11392
51219358 11393static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
27c868c2 11394{
51219358
MW
11395 ushort read_wval;
11396 uchar cmd_reg;
27c868c2 11397
51219358
MW
11398 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
11399 AscWaitEEPRead();
11400 cmd_reg = addr | ASC_EEP_CMD_READ;
11401 AscWriteEEPCmdReg(iop_base, cmd_reg);
11402 AscWaitEEPRead();
11403 read_wval = AscGetChipEEPData(iop_base);
11404 AscWaitEEPRead();
11405 return read_wval;
11406}
27c868c2 11407
51219358
MW
11408static ushort __devinit
11409AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
11410{
11411 ushort wval;
11412 ushort sum;
11413 ushort *wbuf;
11414 int cfg_beg;
11415 int cfg_end;
11416 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
11417 int s_addr;
27c868c2 11418
51219358
MW
11419 wbuf = (ushort *)cfg_buf;
11420 sum = 0;
11421 /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
11422 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
11423 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
11424 sum += *wbuf;
11425 }
11426 if (bus_type & ASC_IS_VL) {
11427 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
11428 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
11429 } else {
11430 cfg_beg = ASC_EEP_DVC_CFG_BEG;
11431 cfg_end = ASC_EEP_MAX_DVC_ADDR;
11432 }
11433 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
11434 wval = AscReadEEPWord(iop_base, (uchar)s_addr);
11435 if (s_addr <= uchar_end_in_config) {
11436 /*
11437 * Swap all char fields - must unswap bytes already swapped
11438 * by AscReadEEPWord().
11439 */
11440 *wbuf = le16_to_cpu(wval);
11441 } else {
11442 /* Don't swap word field at the end - cntl field. */
11443 *wbuf = wval;
11444 }
11445 sum += wval; /* Checksum treats all EEPROM data as words. */
11446 }
27c868c2 11447 /*
51219358
MW
11448 * Read the checksum word which will be compared against 'sum'
11449 * by the caller. Word field already swapped.
27c868c2 11450 */
51219358
MW
11451 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
11452 return sum;
11453}
1da177e4 11454
51219358
MW
11455static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
11456{
11457 PortAddr iop_base;
11458 ushort q_addr;
11459 ushort saved_word;
11460 int sta;
1da177e4 11461
51219358
MW
11462 iop_base = asc_dvc->iop_base;
11463 sta = 0;
11464 q_addr = ASC_QNO_TO_QADDR(241);
11465 saved_word = AscReadLramWord(iop_base, q_addr);
11466 AscSetChipLramAddr(iop_base, q_addr);
11467 AscSetChipLramData(iop_base, 0x55AA);
11468 mdelay(10);
11469 AscSetChipLramAddr(iop_base, q_addr);
11470 if (AscGetChipLramData(iop_base) == 0x55AA) {
11471 sta = 1;
11472 AscWriteLramWord(iop_base, q_addr, saved_word);
11473 }
11474 return (sta);
11475}
1da177e4 11476
51219358
MW
11477static void __devinit AscWaitEEPWrite(void)
11478{
11479 mdelay(20);
51219358 11480}
1da177e4 11481
51219358
MW
11482static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
11483{
11484 ushort read_back;
11485 int retry;
1da177e4 11486
51219358
MW
11487 retry = 0;
11488 while (TRUE) {
11489 AscSetChipEEPData(iop_base, data_reg);
11490 mdelay(1);
11491 read_back = AscGetChipEEPData(iop_base);
11492 if (read_back == data_reg) {
11493 return (1);
11494 }
11495 if (retry++ > ASC_EEP_MAX_RETRY) {
11496 return (0);
11497 }
27c868c2 11498 }
51219358 11499}
27c868c2 11500
51219358
MW
11501static ushort __devinit
11502AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
11503{
11504 ushort read_wval;
11505
11506 read_wval = AscReadEEPWord(iop_base, addr);
11507 if (read_wval != word_val) {
11508 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
11509 AscWaitEEPRead();
11510 AscWriteEEPDataReg(iop_base, word_val);
11511 AscWaitEEPRead();
11512 AscWriteEEPCmdReg(iop_base,
11513 (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
11514 AscWaitEEPWrite();
11515 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
11516 AscWaitEEPRead();
11517 return (AscReadEEPWord(iop_base, addr));
11518 }
11519 return (read_wval);
11520}
11521
11522static int __devinit
11523AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
11524{
11525 int n_error;
11526 ushort *wbuf;
11527 ushort word;
11528 ushort sum;
11529 int s_addr;
11530 int cfg_beg;
11531 int cfg_end;
11532 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
11533
11534 wbuf = (ushort *)cfg_buf;
11535 n_error = 0;
11536 sum = 0;
11537 /* Write two config words; AscWriteEEPWord() will swap bytes. */
11538 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
11539 sum += *wbuf;
11540 if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
11541 n_error++;
27c868c2 11542 }
51219358
MW
11543 }
11544 if (bus_type & ASC_IS_VL) {
11545 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
11546 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
11547 } else {
11548 cfg_beg = ASC_EEP_DVC_CFG_BEG;
11549 cfg_end = ASC_EEP_MAX_DVC_ADDR;
11550 }
11551 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
11552 if (s_addr <= uchar_end_in_config) {
11553 /*
11554 * This is a char field. Swap char fields before they are
11555 * swapped again by AscWriteEEPWord().
11556 */
11557 word = cpu_to_le16(*wbuf);
11558 if (word !=
11559 AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
11560 n_error++;
11561 }
11562 } else {
11563 /* Don't swap word field at the end - cntl field. */
11564 if (*wbuf !=
11565 AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
11566 n_error++;
11567 }
27c868c2 11568 }
51219358
MW
11569 sum += *wbuf; /* Checksum calculated from word values. */
11570 }
11571 /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
11572 *wbuf = sum;
11573 if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
11574 n_error++;
27c868c2 11575 }
1da177e4 11576
51219358
MW
11577 /* Read EEPROM back again. */
11578 wbuf = (ushort *)cfg_buf;
27c868c2 11579 /*
51219358 11580 * Read two config words; Byte-swapping done by AscReadEEPWord().
27c868c2 11581 */
51219358
MW
11582 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
11583 if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
11584 n_error++;
27c868c2
MW
11585 }
11586 }
51219358
MW
11587 if (bus_type & ASC_IS_VL) {
11588 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
11589 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
11590 } else {
11591 cfg_beg = ASC_EEP_DVC_CFG_BEG;
11592 cfg_end = ASC_EEP_MAX_DVC_ADDR;
11593 }
11594 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
11595 if (s_addr <= uchar_end_in_config) {
11596 /*
11597 * Swap all char fields. Must unswap bytes already swapped
11598 * by AscReadEEPWord().
11599 */
11600 word =
11601 le16_to_cpu(AscReadEEPWord
11602 (iop_base, (uchar)s_addr));
27c868c2 11603 } else {
51219358
MW
11604 /* Don't swap word field at the end - cntl field. */
11605 word = AscReadEEPWord(iop_base, (uchar)s_addr);
11606 }
11607 if (*wbuf != word) {
11608 n_error++;
27c868c2
MW
11609 }
11610 }
51219358
MW
11611 /* Read checksum; Byte swapping not needed. */
11612 if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
11613 n_error++;
27c868c2 11614 }
51219358
MW
11615 return n_error;
11616}
1da177e4 11617
51219358
MW
11618static int __devinit
11619AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
11620{
11621 int retry;
11622 int n_error;
27c868c2 11623
51219358
MW
11624 retry = 0;
11625 while (TRUE) {
11626 if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
11627 bus_type)) == 0) {
11628 break;
11629 }
11630 if (++retry > ASC_EEP_MAX_RETRY) {
11631 break;
11632 }
11633 }
11634 return n_error;
11635}
27c868c2 11636
51219358
MW
11637static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
11638{
11639 ASCEEP_CONFIG eep_config_buf;
11640 ASCEEP_CONFIG *eep_config;
11641 PortAddr iop_base;
11642 ushort chksum;
11643 ushort warn_code;
11644 ushort cfg_msw, cfg_lsw;
11645 int i;
11646 int write_eep = 0;
27c868c2 11647
51219358
MW
11648 iop_base = asc_dvc->iop_base;
11649 warn_code = 0;
11650 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
11651 AscStopQueueExe(iop_base);
11652 if ((AscStopChip(iop_base) == FALSE) ||
11653 (AscGetChipScsiCtrl(iop_base) != 0)) {
11654 asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
11655 AscResetChipAndScsiBus(asc_dvc);
11656 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
11657 }
11658 if (AscIsChipHalted(iop_base) == FALSE) {
11659 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
11660 return (warn_code);
11661 }
11662 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
11663 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
11664 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
11665 return (warn_code);
11666 }
11667 eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
11668 cfg_msw = AscGetChipCfgMsw(iop_base);
11669 cfg_lsw = AscGetChipCfgLsw(iop_base);
11670 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
11671 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
11672 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
11673 AscSetChipCfgMsw(iop_base, cfg_msw);
11674 }
11675 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
b352f923 11676 ASC_DBG(1, "chksum 0x%x\n", chksum);
51219358
MW
11677 if (chksum == 0) {
11678 chksum = 0xaa55;
11679 }
11680 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
11681 warn_code |= ASC_WARN_AUTO_CONFIG;
11682 if (asc_dvc->cfg->chip_version == 3) {
11683 if (eep_config->cfg_lsw != cfg_lsw) {
11684 warn_code |= ASC_WARN_EEPROM_RECOVER;
11685 eep_config->cfg_lsw =
11686 AscGetChipCfgLsw(iop_base);
11687 }
11688 if (eep_config->cfg_msw != cfg_msw) {
11689 warn_code |= ASC_WARN_EEPROM_RECOVER;
11690 eep_config->cfg_msw =
11691 AscGetChipCfgMsw(iop_base);
11692 }
11693 }
11694 }
11695 eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
11696 eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
b352f923 11697 ASC_DBG(1, "eep_config->chksum 0x%x\n", eep_config->chksum);
51219358
MW
11698 if (chksum != eep_config->chksum) {
11699 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
11700 ASC_CHIP_VER_PCI_ULTRA_3050) {
b352f923 11701 ASC_DBG(1, "chksum error ignored; EEPROM-less board\n");
51219358
MW
11702 eep_config->init_sdtr = 0xFF;
11703 eep_config->disc_enable = 0xFF;
11704 eep_config->start_motor = 0xFF;
11705 eep_config->use_cmd_qng = 0;
11706 eep_config->max_total_qng = 0xF0;
11707 eep_config->max_tag_qng = 0x20;
11708 eep_config->cntl = 0xBFFF;
11709 ASC_EEP_SET_CHIP_ID(eep_config, 7);
11710 eep_config->no_scam = 0;
11711 eep_config->adapter_info[0] = 0;
11712 eep_config->adapter_info[1] = 0;
11713 eep_config->adapter_info[2] = 0;
11714 eep_config->adapter_info[3] = 0;
11715 eep_config->adapter_info[4] = 0;
11716 /* Indicate EEPROM-less board. */
11717 eep_config->adapter_info[5] = 0xBB;
27c868c2 11718 } else {
51219358
MW
11719 ASC_PRINT
11720 ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
11721 write_eep = 1;
11722 warn_code |= ASC_WARN_EEPROM_CHKSUM;
11723 }
11724 }
11725 asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
11726 asc_dvc->cfg->disc_enable = eep_config->disc_enable;
11727 asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
11728 asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
11729 asc_dvc->start_motor = eep_config->start_motor;
11730 asc_dvc->dvc_cntl = eep_config->cntl;
11731 asc_dvc->no_scam = eep_config->no_scam;
11732 asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
11733 asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
11734 asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
11735 asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
11736 asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
11737 asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
11738 if (!AscTestExternalLram(asc_dvc)) {
11739 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
11740 ASC_IS_PCI_ULTRA)) {
11741 eep_config->max_total_qng =
11742 ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
11743 eep_config->max_tag_qng =
11744 ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
11745 } else {
11746 eep_config->cfg_msw |= 0x0800;
11747 cfg_msw |= 0x0800;
11748 AscSetChipCfgMsw(iop_base, cfg_msw);
11749 eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
11750 eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
27c868c2 11751 }
51219358
MW
11752 } else {
11753 }
11754 if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
11755 eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
11756 }
11757 if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
11758 eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
11759 }
11760 if (eep_config->max_tag_qng > eep_config->max_total_qng) {
11761 eep_config->max_tag_qng = eep_config->max_total_qng;
11762 }
11763 if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
11764 eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
11765 }
11766 asc_dvc->max_total_qng = eep_config->max_total_qng;
11767 if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
11768 eep_config->use_cmd_qng) {
11769 eep_config->disc_enable = eep_config->use_cmd_qng;
11770 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
11771 }
51219358
MW
11772 ASC_EEP_SET_CHIP_ID(eep_config,
11773 ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
11774 asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
11775 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
11776 !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
afbb68c3 11777 asc_dvc->min_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
27c868c2 11778 }
1da177e4 11779
51219358
MW
11780 for (i = 0; i <= ASC_MAX_TID; i++) {
11781 asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
11782 asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
11783 asc_dvc->cfg->sdtr_period_offset[i] =
11784 (uchar)(ASC_DEF_SDTR_OFFSET |
afbb68c3 11785 (asc_dvc->min_sdtr_index << 4));
51219358
MW
11786 }
11787 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
11788 if (write_eep) {
11789 if ((i = AscSetEEPConfig(iop_base, eep_config,
11790 asc_dvc->bus_type)) != 0) {
11791 ASC_PRINT1
11792 ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
11793 i);
27c868c2 11794 } else {
51219358
MW
11795 ASC_PRINT
11796 ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
27c868c2
MW
11797 }
11798 }
51219358 11799 return (warn_code);
1da177e4
LT
11800}
11801
9d0e96eb 11802static int __devinit AscInitGetConfig(struct Scsi_Host *shost)
1da177e4 11803{
9d0e96eb
MW
11804 struct asc_board *board = shost_priv(shost);
11805 ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
51219358 11806 unsigned short warn_code = 0;
27c868c2 11807
51219358
MW
11808 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
11809 if (asc_dvc->err_code != 0)
11810 return asc_dvc->err_code;
27c868c2 11811
51219358
MW
11812 if (AscFindSignature(asc_dvc->iop_base)) {
11813 warn_code |= AscInitAscDvcVar(asc_dvc);
11814 warn_code |= AscInitFromEEP(asc_dvc);
11815 asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
11816 if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
11817 asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
11818 } else {
11819 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
11820 }
27c868c2 11821
51219358
MW
11822 switch (warn_code) {
11823 case 0: /* No error */
11824 break;
11825 case ASC_WARN_IO_PORT_ROTATE:
9d0e96eb
MW
11826 shost_printk(KERN_WARNING, shost, "I/O port address "
11827 "modified\n");
51219358
MW
11828 break;
11829 case ASC_WARN_AUTO_CONFIG:
9d0e96eb
MW
11830 shost_printk(KERN_WARNING, shost, "I/O port increment switch "
11831 "enabled\n");
51219358
MW
11832 break;
11833 case ASC_WARN_EEPROM_CHKSUM:
9d0e96eb 11834 shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
51219358
MW
11835 break;
11836 case ASC_WARN_IRQ_MODIFIED:
9d0e96eb 11837 shost_printk(KERN_WARNING, shost, "IRQ modified\n");
51219358
MW
11838 break;
11839 case ASC_WARN_CMD_QNG_CONFLICT:
9d0e96eb
MW
11840 shost_printk(KERN_WARNING, shost, "tag queuing enabled w/o "
11841 "disconnects\n");
51219358
MW
11842 break;
11843 default:
9d0e96eb
MW
11844 shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
11845 warn_code);
51219358
MW
11846 break;
11847 }
1da177e4 11848
9d0e96eb
MW
11849 if (asc_dvc->err_code != 0)
11850 shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
11851 "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
27c868c2 11852
51219358
MW
11853 return asc_dvc->err_code;
11854}
1da177e4 11855
9d0e96eb 11856static int __devinit AscInitSetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
51219358 11857{
9d0e96eb
MW
11858 struct asc_board *board = shost_priv(shost);
11859 ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
51219358
MW
11860 PortAddr iop_base = asc_dvc->iop_base;
11861 unsigned short cfg_msw;
11862 unsigned short warn_code = 0;
1da177e4 11863
51219358
MW
11864 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
11865 if (asc_dvc->err_code != 0)
11866 return asc_dvc->err_code;
11867 if (!AscFindSignature(asc_dvc->iop_base)) {
11868 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
11869 return asc_dvc->err_code;
27c868c2 11870 }
1da177e4 11871
51219358
MW
11872 cfg_msw = AscGetChipCfgMsw(iop_base);
11873 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
11874 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
11875 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
11876 AscSetChipCfgMsw(iop_base, cfg_msw);
11877 }
11878 if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
11879 asc_dvc->cfg->cmd_qng_enabled) {
11880 asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
11881 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
11882 }
11883 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
11884 warn_code |= ASC_WARN_AUTO_CONFIG;
11885 }
51219358
MW
11886#ifdef CONFIG_PCI
11887 if (asc_dvc->bus_type & ASC_IS_PCI) {
11888 cfg_msw &= 0xFFC0;
11889 AscSetChipCfgMsw(iop_base, cfg_msw);
11890 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
27c868c2 11891 } else {
51219358
MW
11892 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
11893 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
11894 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
11895 asc_dvc->bug_fix_cntl |=
11896 ASC_BUG_FIX_ASYN_USE_SYN;
11897 }
27c868c2 11898 }
51219358
MW
11899 } else
11900#endif /* CONFIG_PCI */
11901 if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
11902 if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
11903 == ASC_CHIP_VER_ASYN_BUG) {
11904 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
27c868c2
MW
11905 }
11906 }
51219358
MW
11907 if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
11908 asc_dvc->cfg->chip_scsi_id) {
11909 asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
11910 }
11911#ifdef CONFIG_ISA
11912 if (asc_dvc->bus_type & ASC_IS_ISA) {
11913 AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
11914 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
11915 }
11916#endif /* CONFIG_ISA */
1da177e4 11917
51219358
MW
11918 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
11919
11920 switch (warn_code) {
11921 case 0: /* No error. */
11922 break;
11923 case ASC_WARN_IO_PORT_ROTATE:
9d0e96eb
MW
11924 shost_printk(KERN_WARNING, shost, "I/O port address "
11925 "modified\n");
51219358
MW
11926 break;
11927 case ASC_WARN_AUTO_CONFIG:
9d0e96eb
MW
11928 shost_printk(KERN_WARNING, shost, "I/O port increment switch "
11929 "enabled\n");
51219358
MW
11930 break;
11931 case ASC_WARN_EEPROM_CHKSUM:
9d0e96eb 11932 shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
51219358
MW
11933 break;
11934 case ASC_WARN_IRQ_MODIFIED:
9d0e96eb 11935 shost_printk(KERN_WARNING, shost, "IRQ modified\n");
51219358
MW
11936 break;
11937 case ASC_WARN_CMD_QNG_CONFLICT:
9d0e96eb
MW
11938 shost_printk(KERN_WARNING, shost, "tag queuing w/o "
11939 "disconnects\n");
51219358
MW
11940 break;
11941 default:
9d0e96eb
MW
11942 shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
11943 warn_code);
51219358 11944 break;
27c868c2 11945 }
1da177e4 11946
9d0e96eb
MW
11947 if (asc_dvc->err_code != 0)
11948 shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
11949 "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
27c868c2 11950
51219358
MW
11951 return asc_dvc->err_code;
11952}
27c868c2 11953
51219358
MW
11954/*
11955 * EEPROM Configuration.
11956 *
11957 * All drivers should use this structure to set the default EEPROM
11958 * configuration. The BIOS now uses this structure when it is built.
11959 * Additional structure information can be found in a_condor.h where
11960 * the structure is defined.
11961 *
11962 * The *_Field_IsChar structs are needed to correct for endianness.
11963 * These values are read from the board 16 bits at a time directly
11964 * into the structs. Because some fields are char, the values will be
11965 * in the wrong order. The *_Field_IsChar tells when to flip the
11966 * bytes. Data read and written to PCI memory is automatically swapped
11967 * on big-endian platforms so char fields read as words are actually being
11968 * unswapped on big-endian platforms.
11969 */
11970static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
11971 ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
11972 0x0000, /* cfg_msw */
11973 0xFFFF, /* disc_enable */
11974 0xFFFF, /* wdtr_able */
11975 0xFFFF, /* sdtr_able */
11976 0xFFFF, /* start_motor */
11977 0xFFFF, /* tagqng_able */
11978 0xFFFF, /* bios_scan */
11979 0, /* scam_tolerant */
11980 7, /* adapter_scsi_id */
11981 0, /* bios_boot_delay */
11982 3, /* scsi_reset_delay */
11983 0, /* bios_id_lun */
11984 0, /* termination */
11985 0, /* reserved1 */
11986 0xFFE7, /* bios_ctrl */
11987 0xFFFF, /* ultra_able */
11988 0, /* reserved2 */
11989 ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
11990 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
11991 0, /* dvc_cntl */
11992 0, /* bug_fix */
11993 0, /* serial_number_word1 */
11994 0, /* serial_number_word2 */
11995 0, /* serial_number_word3 */
11996 0, /* check_sum */
11997 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
11998 , /* oem_name[16] */
11999 0, /* dvc_err_code */
12000 0, /* adv_err_code */
12001 0, /* adv_err_addr */
12002 0, /* saved_dvc_err_code */
12003 0, /* saved_adv_err_code */
12004 0, /* saved_adv_err_addr */
12005 0 /* num_of_err */
12006};
27c868c2 12007
51219358
MW
12008static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
12009 0, /* cfg_lsw */
12010 0, /* cfg_msw */
12011 0, /* -disc_enable */
12012 0, /* wdtr_able */
12013 0, /* sdtr_able */
12014 0, /* start_motor */
12015 0, /* tagqng_able */
12016 0, /* bios_scan */
12017 0, /* scam_tolerant */
12018 1, /* adapter_scsi_id */
12019 1, /* bios_boot_delay */
12020 1, /* scsi_reset_delay */
12021 1, /* bios_id_lun */
12022 1, /* termination */
12023 1, /* reserved1 */
12024 0, /* bios_ctrl */
12025 0, /* ultra_able */
12026 0, /* reserved2 */
12027 1, /* max_host_qng */
12028 1, /* max_dvc_qng */
12029 0, /* dvc_cntl */
12030 0, /* bug_fix */
12031 0, /* serial_number_word1 */
12032 0, /* serial_number_word2 */
12033 0, /* serial_number_word3 */
12034 0, /* check_sum */
12035 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12036 , /* oem_name[16] */
12037 0, /* dvc_err_code */
12038 0, /* adv_err_code */
12039 0, /* adv_err_addr */
12040 0, /* saved_dvc_err_code */
12041 0, /* saved_adv_err_code */
12042 0, /* saved_adv_err_addr */
12043 0 /* num_of_err */
12044};
1da177e4 12045
51219358
MW
12046static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
12047 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
12048 0x0000, /* 01 cfg_msw */
12049 0xFFFF, /* 02 disc_enable */
12050 0xFFFF, /* 03 wdtr_able */
12051 0x4444, /* 04 sdtr_speed1 */
12052 0xFFFF, /* 05 start_motor */
12053 0xFFFF, /* 06 tagqng_able */
12054 0xFFFF, /* 07 bios_scan */
12055 0, /* 08 scam_tolerant */
12056 7, /* 09 adapter_scsi_id */
12057 0, /* bios_boot_delay */
12058 3, /* 10 scsi_reset_delay */
12059 0, /* bios_id_lun */
12060 0, /* 11 termination_se */
12061 0, /* termination_lvd */
12062 0xFFE7, /* 12 bios_ctrl */
12063 0x4444, /* 13 sdtr_speed2 */
12064 0x4444, /* 14 sdtr_speed3 */
12065 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
12066 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
12067 0, /* 16 dvc_cntl */
12068 0x4444, /* 17 sdtr_speed4 */
12069 0, /* 18 serial_number_word1 */
12070 0, /* 19 serial_number_word2 */
12071 0, /* 20 serial_number_word3 */
12072 0, /* 21 check_sum */
12073 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
12074 , /* 22-29 oem_name[16] */
12075 0, /* 30 dvc_err_code */
12076 0, /* 31 adv_err_code */
12077 0, /* 32 adv_err_addr */
12078 0, /* 33 saved_dvc_err_code */
12079 0, /* 34 saved_adv_err_code */
12080 0, /* 35 saved_adv_err_addr */
12081 0, /* 36 reserved */
12082 0, /* 37 reserved */
12083 0, /* 38 reserved */
12084 0, /* 39 reserved */
12085 0, /* 40 reserved */
12086 0, /* 41 reserved */
12087 0, /* 42 reserved */
12088 0, /* 43 reserved */
12089 0, /* 44 reserved */
12090 0, /* 45 reserved */
12091 0, /* 46 reserved */
12092 0, /* 47 reserved */
12093 0, /* 48 reserved */
12094 0, /* 49 reserved */
12095 0, /* 50 reserved */
12096 0, /* 51 reserved */
12097 0, /* 52 reserved */
12098 0, /* 53 reserved */
12099 0, /* 54 reserved */
12100 0, /* 55 reserved */
12101 0, /* 56 cisptr_lsw */
12102 0, /* 57 cisprt_msw */
12103 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
12104 PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
12105 0, /* 60 reserved */
12106 0, /* 61 reserved */
12107 0, /* 62 reserved */
12108 0 /* 63 reserved */
12109};
27c868c2 12110
51219358
MW
12111static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
12112 0, /* 00 cfg_lsw */
12113 0, /* 01 cfg_msw */
12114 0, /* 02 disc_enable */
12115 0, /* 03 wdtr_able */
12116 0, /* 04 sdtr_speed1 */
12117 0, /* 05 start_motor */
12118 0, /* 06 tagqng_able */
12119 0, /* 07 bios_scan */
12120 0, /* 08 scam_tolerant */
12121 1, /* 09 adapter_scsi_id */
12122 1, /* bios_boot_delay */
12123 1, /* 10 scsi_reset_delay */
12124 1, /* bios_id_lun */
12125 1, /* 11 termination_se */
12126 1, /* termination_lvd */
12127 0, /* 12 bios_ctrl */
12128 0, /* 13 sdtr_speed2 */
12129 0, /* 14 sdtr_speed3 */
12130 1, /* 15 max_host_qng */
12131 1, /* max_dvc_qng */
12132 0, /* 16 dvc_cntl */
12133 0, /* 17 sdtr_speed4 */
12134 0, /* 18 serial_number_word1 */
12135 0, /* 19 serial_number_word2 */
12136 0, /* 20 serial_number_word3 */
12137 0, /* 21 check_sum */
12138 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12139 , /* 22-29 oem_name[16] */
12140 0, /* 30 dvc_err_code */
12141 0, /* 31 adv_err_code */
12142 0, /* 32 adv_err_addr */
12143 0, /* 33 saved_dvc_err_code */
12144 0, /* 34 saved_adv_err_code */
12145 0, /* 35 saved_adv_err_addr */
12146 0, /* 36 reserved */
12147 0, /* 37 reserved */
12148 0, /* 38 reserved */
12149 0, /* 39 reserved */
12150 0, /* 40 reserved */
12151 0, /* 41 reserved */
12152 0, /* 42 reserved */
12153 0, /* 43 reserved */
12154 0, /* 44 reserved */
12155 0, /* 45 reserved */
12156 0, /* 46 reserved */
12157 0, /* 47 reserved */
12158 0, /* 48 reserved */
12159 0, /* 49 reserved */
12160 0, /* 50 reserved */
12161 0, /* 51 reserved */
12162 0, /* 52 reserved */
12163 0, /* 53 reserved */
12164 0, /* 54 reserved */
12165 0, /* 55 reserved */
12166 0, /* 56 cisptr_lsw */
12167 0, /* 57 cisprt_msw */
12168 0, /* 58 subsysvid */
12169 0, /* 59 subsysid */
12170 0, /* 60 reserved */
12171 0, /* 61 reserved */
12172 0, /* 62 reserved */
12173 0 /* 63 reserved */
12174};
27c868c2 12175
51219358
MW
12176static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
12177 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
12178 0x0000, /* 01 cfg_msw */
12179 0xFFFF, /* 02 disc_enable */
12180 0xFFFF, /* 03 wdtr_able */
12181 0x5555, /* 04 sdtr_speed1 */
12182 0xFFFF, /* 05 start_motor */
12183 0xFFFF, /* 06 tagqng_able */
12184 0xFFFF, /* 07 bios_scan */
12185 0, /* 08 scam_tolerant */
12186 7, /* 09 adapter_scsi_id */
12187 0, /* bios_boot_delay */
12188 3, /* 10 scsi_reset_delay */
12189 0, /* bios_id_lun */
12190 0, /* 11 termination_se */
12191 0, /* termination_lvd */
12192 0xFFE7, /* 12 bios_ctrl */
12193 0x5555, /* 13 sdtr_speed2 */
12194 0x5555, /* 14 sdtr_speed3 */
12195 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
12196 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
12197 0, /* 16 dvc_cntl */
12198 0x5555, /* 17 sdtr_speed4 */
12199 0, /* 18 serial_number_word1 */
12200 0, /* 19 serial_number_word2 */
12201 0, /* 20 serial_number_word3 */
12202 0, /* 21 check_sum */
12203 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
12204 , /* 22-29 oem_name[16] */
12205 0, /* 30 dvc_err_code */
12206 0, /* 31 adv_err_code */
12207 0, /* 32 adv_err_addr */
12208 0, /* 33 saved_dvc_err_code */
12209 0, /* 34 saved_adv_err_code */
12210 0, /* 35 saved_adv_err_addr */
12211 0, /* 36 reserved */
12212 0, /* 37 reserved */
12213 0, /* 38 reserved */
12214 0, /* 39 reserved */
12215 0, /* 40 reserved */
12216 0, /* 41 reserved */
12217 0, /* 42 reserved */
12218 0, /* 43 reserved */
12219 0, /* 44 reserved */
12220 0, /* 45 reserved */
12221 0, /* 46 reserved */
12222 0, /* 47 reserved */
12223 0, /* 48 reserved */
12224 0, /* 49 reserved */
12225 0, /* 50 reserved */
12226 0, /* 51 reserved */
12227 0, /* 52 reserved */
12228 0, /* 53 reserved */
12229 0, /* 54 reserved */
12230 0, /* 55 reserved */
12231 0, /* 56 cisptr_lsw */
12232 0, /* 57 cisprt_msw */
12233 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
12234 PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
12235 0, /* 60 reserved */
12236 0, /* 61 reserved */
12237 0, /* 62 reserved */
12238 0 /* 63 reserved */
12239};
1da177e4 12240
51219358
MW
12241static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
12242 0, /* 00 cfg_lsw */
12243 0, /* 01 cfg_msw */
12244 0, /* 02 disc_enable */
12245 0, /* 03 wdtr_able */
12246 0, /* 04 sdtr_speed1 */
12247 0, /* 05 start_motor */
12248 0, /* 06 tagqng_able */
12249 0, /* 07 bios_scan */
12250 0, /* 08 scam_tolerant */
12251 1, /* 09 adapter_scsi_id */
12252 1, /* bios_boot_delay */
12253 1, /* 10 scsi_reset_delay */
12254 1, /* bios_id_lun */
12255 1, /* 11 termination_se */
12256 1, /* termination_lvd */
12257 0, /* 12 bios_ctrl */
12258 0, /* 13 sdtr_speed2 */
12259 0, /* 14 sdtr_speed3 */
12260 1, /* 15 max_host_qng */
12261 1, /* max_dvc_qng */
12262 0, /* 16 dvc_cntl */
12263 0, /* 17 sdtr_speed4 */
12264 0, /* 18 serial_number_word1 */
12265 0, /* 19 serial_number_word2 */
12266 0, /* 20 serial_number_word3 */
12267 0, /* 21 check_sum */
12268 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12269 , /* 22-29 oem_name[16] */
12270 0, /* 30 dvc_err_code */
12271 0, /* 31 adv_err_code */
12272 0, /* 32 adv_err_addr */
12273 0, /* 33 saved_dvc_err_code */
12274 0, /* 34 saved_adv_err_code */
12275 0, /* 35 saved_adv_err_addr */
12276 0, /* 36 reserved */
12277 0, /* 37 reserved */
12278 0, /* 38 reserved */
12279 0, /* 39 reserved */
12280 0, /* 40 reserved */
12281 0, /* 41 reserved */
12282 0, /* 42 reserved */
12283 0, /* 43 reserved */
12284 0, /* 44 reserved */
12285 0, /* 45 reserved */
12286 0, /* 46 reserved */
12287 0, /* 47 reserved */
12288 0, /* 48 reserved */
12289 0, /* 49 reserved */
12290 0, /* 50 reserved */
12291 0, /* 51 reserved */
12292 0, /* 52 reserved */
12293 0, /* 53 reserved */
12294 0, /* 54 reserved */
12295 0, /* 55 reserved */
12296 0, /* 56 cisptr_lsw */
12297 0, /* 57 cisprt_msw */
12298 0, /* 58 subsysvid */
12299 0, /* 59 subsysid */
12300 0, /* 60 reserved */
12301 0, /* 61 reserved */
12302 0, /* 62 reserved */
12303 0 /* 63 reserved */
12304};
1da177e4 12305
51219358 12306#ifdef CONFIG_PCI
1da177e4 12307/*
51219358 12308 * Wait for EEPROM command to complete
1da177e4 12309 */
51219358 12310static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
1da177e4 12311{
51219358 12312 int eep_delay_ms;
27c868c2 12313
51219358
MW
12314 for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
12315 if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
12316 ASC_EEP_CMD_DONE) {
12317 break;
27c868c2 12318 }
51219358 12319 mdelay(1);
27c868c2 12320 }
51219358
MW
12321 if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
12322 0)
12323 BUG();
1da177e4
LT
12324}
12325
12326/*
51219358 12327 * Read the EEPROM from specified location
1da177e4 12328 */
51219358
MW
12329static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
12330{
12331 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12332 ASC_EEP_CMD_READ | eep_word_addr);
12333 AdvWaitEEPCmd(iop_base);
12334 return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
12335}
12336
12337/*
12338 * Write the EEPROM from 'cfg_buf'.
12339 */
12340void __devinit
12341AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
1da177e4 12342{
27c868c2 12343 ushort *wbuf;
51219358 12344 ushort addr, chksum;
27c868c2
MW
12345 ushort *charfields;
12346
27c868c2 12347 wbuf = (ushort *)cfg_buf;
51219358 12348 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
27c868c2
MW
12349 chksum = 0;
12350
51219358
MW
12351 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
12352 AdvWaitEEPCmd(iop_base);
12353
12354 /*
12355 * Write EEPROM from word 0 to word 20.
12356 */
12357 for (addr = ADV_EEP_DVC_CFG_BEGIN;
12358 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
12359 ushort word;
12360
27c868c2 12361 if (*charfields++) {
51219358 12362 word = cpu_to_le16(*wbuf);
27c868c2 12363 } else {
51219358 12364 word = *wbuf;
27c868c2 12365 }
51219358
MW
12366 chksum += *wbuf; /* Checksum is calculated from word values. */
12367 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12368 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12369 ASC_EEP_CMD_WRITE | addr);
12370 AdvWaitEEPCmd(iop_base);
12371 mdelay(ADV_EEP_DELAY_MS);
27c868c2 12372 }
51219358
MW
12373
12374 /*
12375 * Write EEPROM checksum at word 21.
12376 */
12377 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
12378 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
12379 AdvWaitEEPCmd(iop_base);
27c868c2
MW
12380 wbuf++;
12381 charfields++;
12382
51219358
MW
12383 /*
12384 * Write EEPROM OEM name at words 22 to 29.
12385 */
12386 for (addr = ADV_EEP_DVC_CTL_BEGIN;
12387 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
12388 ushort word;
12389
27c868c2 12390 if (*charfields++) {
51219358
MW
12391 word = cpu_to_le16(*wbuf);
12392 } else {
12393 word = *wbuf;
27c868c2 12394 }
51219358
MW
12395 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12396 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12397 ASC_EEP_CMD_WRITE | addr);
12398 AdvWaitEEPCmd(iop_base);
27c868c2 12399 }
51219358
MW
12400 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
12401 AdvWaitEEPCmd(iop_base);
1da177e4
LT
12402}
12403
12404/*
51219358 12405 * Write the EEPROM from 'cfg_buf'.
1da177e4 12406 */
51219358
MW
12407void __devinit
12408AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
1da177e4 12409{
27c868c2 12410 ushort *wbuf;
27c868c2 12411 ushort *charfields;
51219358 12412 ushort addr, chksum;
27c868c2 12413
27c868c2 12414 wbuf = (ushort *)cfg_buf;
51219358 12415 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
27c868c2
MW
12416 chksum = 0;
12417
51219358
MW
12418 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
12419 AdvWaitEEPCmd(iop_base);
12420
12421 /*
12422 * Write EEPROM from word 0 to word 20.
12423 */
12424 for (addr = ADV_EEP_DVC_CFG_BEGIN;
12425 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
12426 ushort word;
12427
27c868c2 12428 if (*charfields++) {
51219358 12429 word = cpu_to_le16(*wbuf);
27c868c2 12430 } else {
51219358 12431 word = *wbuf;
27c868c2 12432 }
51219358
MW
12433 chksum += *wbuf; /* Checksum is calculated from word values. */
12434 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12435 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12436 ASC_EEP_CMD_WRITE | addr);
12437 AdvWaitEEPCmd(iop_base);
12438 mdelay(ADV_EEP_DELAY_MS);
27c868c2 12439 }
51219358
MW
12440
12441 /*
12442 * Write EEPROM checksum at word 21.
12443 */
12444 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
12445 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
12446 AdvWaitEEPCmd(iop_base);
27c868c2
MW
12447 wbuf++;
12448 charfields++;
12449
51219358
MW
12450 /*
12451 * Write EEPROM OEM name at words 22 to 29.
12452 */
12453 for (addr = ADV_EEP_DVC_CTL_BEGIN;
12454 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
12455 ushort word;
12456
27c868c2 12457 if (*charfields++) {
51219358
MW
12458 word = cpu_to_le16(*wbuf);
12459 } else {
12460 word = *wbuf;
27c868c2 12461 }
51219358
MW
12462 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12463 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12464 ASC_EEP_CMD_WRITE | addr);
12465 AdvWaitEEPCmd(iop_base);
27c868c2 12466 }
51219358 12467 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
27c868c2 12468 AdvWaitEEPCmd(iop_base);
1da177e4
LT
12469}
12470
12471/*
12472 * Write the EEPROM from 'cfg_buf'.
12473 */
78e77d8b 12474void __devinit
51219358 12475AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
1da177e4 12476{
27c868c2 12477 ushort *wbuf;
27c868c2 12478 ushort *charfields;
51219358 12479 ushort addr, chksum;
27c868c2
MW
12480
12481 wbuf = (ushort *)cfg_buf;
51219358 12482 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
27c868c2
MW
12483 chksum = 0;
12484
12485 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
12486 AdvWaitEEPCmd(iop_base);
12487
12488 /*
12489 * Write EEPROM from word 0 to word 20.
12490 */
12491 for (addr = ADV_EEP_DVC_CFG_BEGIN;
12492 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
12493 ushort word;
12494
12495 if (*charfields++) {
12496 word = cpu_to_le16(*wbuf);
12497 } else {
12498 word = *wbuf;
12499 }
12500 chksum += *wbuf; /* Checksum is calculated from word values. */
12501 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12502 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12503 ASC_EEP_CMD_WRITE | addr);
12504 AdvWaitEEPCmd(iop_base);
b009bef6 12505 mdelay(ADV_EEP_DELAY_MS);
27c868c2 12506 }
1da177e4 12507
27c868c2
MW
12508 /*
12509 * Write EEPROM checksum at word 21.
12510 */
12511 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
12512 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
12513 AdvWaitEEPCmd(iop_base);
12514 wbuf++;
12515 charfields++;
12516
12517 /*
12518 * Write EEPROM OEM name at words 22 to 29.
12519 */
12520 for (addr = ADV_EEP_DVC_CTL_BEGIN;
12521 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
12522 ushort word;
12523
12524 if (*charfields++) {
12525 word = cpu_to_le16(*wbuf);
12526 } else {
12527 word = *wbuf;
12528 }
12529 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12530 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12531 ASC_EEP_CMD_WRITE | addr);
12532 AdvWaitEEPCmd(iop_base);
12533 }
12534 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
12535 AdvWaitEEPCmd(iop_base);
1da177e4
LT
12536}
12537
12538/*
51219358
MW
12539 * Read EEPROM configuration into the specified buffer.
12540 *
12541 * Return a checksum based on the EEPROM configuration read.
1da177e4 12542 */
51219358
MW
12543static ushort __devinit
12544AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
1da177e4 12545{
51219358 12546 ushort wval, chksum;
27c868c2 12547 ushort *wbuf;
51219358 12548 int eep_addr;
27c868c2 12549 ushort *charfields;
27c868c2 12550
51219358 12551 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
27c868c2 12552 wbuf = (ushort *)cfg_buf;
27c868c2
MW
12553 chksum = 0;
12554
51219358
MW
12555 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
12556 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
12557 wval = AdvReadEEPWord(iop_base, eep_addr);
12558 chksum += wval; /* Checksum is calculated from word values. */
12559 if (*charfields++) {
12560 *wbuf = le16_to_cpu(wval);
12561 } else {
12562 *wbuf = wval;
12563 }
12564 }
12565 /* Read checksum word. */
12566 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
12567 wbuf++;
12568 charfields++;
27c868c2 12569
51219358
MW
12570 /* Read rest of EEPROM not covered by the checksum. */
12571 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
12572 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
12573 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
12574 if (*charfields++) {
12575 *wbuf = le16_to_cpu(*wbuf);
12576 }
12577 }
12578 return chksum;
12579}
12580
12581/*
12582 * Read EEPROM configuration into the specified buffer.
12583 *
12584 * Return a checksum based on the EEPROM configuration read.
12585 */
12586static ushort __devinit
12587AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
12588{
12589 ushort wval, chksum;
12590 ushort *wbuf;
12591 int eep_addr;
12592 ushort *charfields;
27c868c2 12593
51219358
MW
12594 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
12595 wbuf = (ushort *)cfg_buf;
12596 chksum = 0;
12597
12598 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
12599 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
12600 wval = AdvReadEEPWord(iop_base, eep_addr);
12601 chksum += wval; /* Checksum is calculated from word values. */
27c868c2 12602 if (*charfields++) {
51219358 12603 *wbuf = le16_to_cpu(wval);
27c868c2 12604 } else {
51219358 12605 *wbuf = wval;
27c868c2 12606 }
27c868c2 12607 }
51219358
MW
12608 /* Read checksum word. */
12609 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
27c868c2
MW
12610 wbuf++;
12611 charfields++;
12612
51219358
MW
12613 /* Read rest of EEPROM not covered by the checksum. */
12614 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
12615 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
12616 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
27c868c2 12617 if (*charfields++) {
51219358 12618 *wbuf = le16_to_cpu(*wbuf);
27c868c2 12619 }
27c868c2 12620 }
51219358 12621 return chksum;
1da177e4
LT
12622}
12623
12624/*
51219358
MW
12625 * Read EEPROM configuration into the specified buffer.
12626 *
12627 * Return a checksum based on the EEPROM configuration read.
1da177e4 12628 */
51219358
MW
12629static ushort __devinit
12630AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
1da177e4 12631{
51219358 12632 ushort wval, chksum;
27c868c2 12633 ushort *wbuf;
51219358 12634 int eep_addr;
27c868c2 12635 ushort *charfields;
27c868c2 12636
27c868c2 12637 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
51219358 12638 wbuf = (ushort *)cfg_buf;
27c868c2
MW
12639 chksum = 0;
12640
51219358
MW
12641 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
12642 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
12643 wval = AdvReadEEPWord(iop_base, eep_addr);
12644 chksum += wval; /* Checksum is calculated from word values. */
27c868c2 12645 if (*charfields++) {
51219358 12646 *wbuf = le16_to_cpu(wval);
27c868c2 12647 } else {
51219358 12648 *wbuf = wval;
27c868c2 12649 }
27c868c2 12650 }
51219358
MW
12651 /* Read checksum word. */
12652 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
27c868c2
MW
12653 wbuf++;
12654 charfields++;
12655
51219358
MW
12656 /* Read rest of EEPROM not covered by the checksum. */
12657 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
12658 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
12659 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
27c868c2 12660 if (*charfields++) {
51219358 12661 *wbuf = le16_to_cpu(*wbuf);
27c868c2 12662 }
27c868c2 12663 }
51219358 12664 return chksum;
1da177e4
LT
12665}
12666
1da177e4 12667/*
51219358
MW
12668 * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
12669 * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
12670 * all of this is done.
1da177e4 12671 *
51219358 12672 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
1da177e4 12673 *
51219358
MW
12674 * For a non-fatal error return a warning code. If there are no warnings
12675 * then 0 is returned.
1da177e4 12676 *
51219358 12677 * Note: Chip is stopped on entry.
1da177e4 12678 */
51219358 12679static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
1da177e4 12680{
27c868c2 12681 AdvPortAddr iop_base;
51219358
MW
12682 ushort warn_code;
12683 ADVEEP_3550_CONFIG eep_config;
1da177e4 12684
27c868c2 12685 iop_base = asc_dvc->iop_base;
1da177e4 12686
51219358 12687 warn_code = 0;
27c868c2
MW
12688
12689 /*
51219358
MW
12690 * Read the board's EEPROM configuration.
12691 *
12692 * Set default values if a bad checksum is found.
27c868c2 12693 */
51219358
MW
12694 if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
12695 warn_code |= ASC_WARN_EEPROM_CHKSUM;
27c868c2 12696
51219358
MW
12697 /*
12698 * Set EEPROM default values.
12699 */
12700 memcpy(&eep_config, &Default_3550_EEPROM_Config,
12701 sizeof(ADVEEP_3550_CONFIG));
27c868c2 12702
51219358
MW
12703 /*
12704 * Assume the 6 byte board serial number that was read from
12705 * EEPROM is correct even if the EEPROM checksum failed.
12706 */
12707 eep_config.serial_number_word3 =
12708 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
27c868c2 12709
51219358
MW
12710 eep_config.serial_number_word2 =
12711 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
27c868c2 12712
51219358
MW
12713 eep_config.serial_number_word1 =
12714 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
27c868c2 12715
51219358
MW
12716 AdvSet3550EEPConfig(iop_base, &eep_config);
12717 }
12718 /*
12719 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
12720 * EEPROM configuration that was read.
12721 *
12722 * This is the mapping of EEPROM fields to Adv Library fields.
12723 */
12724 asc_dvc->wdtr_able = eep_config.wdtr_able;
12725 asc_dvc->sdtr_able = eep_config.sdtr_able;
12726 asc_dvc->ultra_able = eep_config.ultra_able;
12727 asc_dvc->tagqng_able = eep_config.tagqng_able;
12728 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
12729 asc_dvc->max_host_qng = eep_config.max_host_qng;
12730 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
12731 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
12732 asc_dvc->start_motor = eep_config.start_motor;
12733 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
12734 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
12735 asc_dvc->no_scam = eep_config.scam_tolerant;
12736 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
12737 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
12738 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
27c868c2 12739
27c868c2 12740 /*
51219358
MW
12741 * Set the host maximum queuing (max. 253, min. 16) and the per device
12742 * maximum queuing (max. 63, min. 4).
27c868c2 12743 */
51219358
MW
12744 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
12745 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
12746 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
12747 /* If the value is zero, assume it is uninitialized. */
12748 if (eep_config.max_host_qng == 0) {
12749 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
12750 } else {
12751 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
12752 }
12753 }
12754
12755 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
12756 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
12757 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
12758 /* If the value is zero, assume it is uninitialized. */
12759 if (eep_config.max_dvc_qng == 0) {
12760 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
12761 } else {
12762 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
12763 }
12764 }
27c868c2
MW
12765
12766 /*
51219358
MW
12767 * If 'max_dvc_qng' is greater than 'max_host_qng', then
12768 * set 'max_dvc_qng' to 'max_host_qng'.
27c868c2 12769 */
51219358
MW
12770 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
12771 eep_config.max_dvc_qng = eep_config.max_host_qng;
12772 }
27c868c2
MW
12773
12774 /*
51219358
MW
12775 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
12776 * values based on possibly adjusted EEPROM values.
27c868c2 12777 */
51219358
MW
12778 asc_dvc->max_host_qng = eep_config.max_host_qng;
12779 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
27c868c2
MW
12780
12781 /*
51219358
MW
12782 * If the EEPROM 'termination' field is set to automatic (0), then set
12783 * the ADV_DVC_CFG 'termination' field to automatic also.
12784 *
12785 * If the termination is specified with a non-zero 'termination'
12786 * value check that a legal value is set and set the ADV_DVC_CFG
12787 * 'termination' field appropriately.
27c868c2 12788 */
51219358
MW
12789 if (eep_config.termination == 0) {
12790 asc_dvc->cfg->termination = 0; /* auto termination */
12791 } else {
12792 /* Enable manual control with low off / high off. */
12793 if (eep_config.termination == 1) {
12794 asc_dvc->cfg->termination = TERM_CTL_SEL;
27c868c2 12795
51219358
MW
12796 /* Enable manual control with low off / high on. */
12797 } else if (eep_config.termination == 2) {
12798 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
12799
12800 /* Enable manual control with low on / high on. */
12801 } else if (eep_config.termination == 3) {
12802 asc_dvc->cfg->termination =
12803 TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
12804 } else {
27c868c2 12805 /*
51219358
MW
12806 * The EEPROM 'termination' field contains a bad value. Use
12807 * automatic termination instead.
27c868c2 12808 */
51219358
MW
12809 asc_dvc->cfg->termination = 0;
12810 warn_code |= ASC_WARN_EEPROM_TERMINATION;
27c868c2 12811 }
27c868c2 12812 }
1da177e4 12813
51219358 12814 return warn_code;
1da177e4
LT
12815}
12816
12817/*
51219358
MW
12818 * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
12819 * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
12820 * all of this is done.
1da177e4 12821 *
51219358
MW
12822 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
12823 *
12824 * For a non-fatal error return a warning code. If there are no warnings
12825 * then 0 is returned.
12826 *
12827 * Note: Chip is stopped on entry.
1da177e4 12828 */
51219358 12829static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
1da177e4 12830{
51219358
MW
12831 AdvPortAddr iop_base;
12832 ushort warn_code;
12833 ADVEEP_38C0800_CONFIG eep_config;
12834 uchar tid, termination;
12835 ushort sdtr_speed = 0;
27c868c2 12836
51219358 12837 iop_base = asc_dvc->iop_base;
1da177e4 12838
51219358 12839 warn_code = 0;
27c868c2
MW
12840
12841 /*
51219358
MW
12842 * Read the board's EEPROM configuration.
12843 *
12844 * Set default values if a bad checksum is found.
27c868c2 12845 */
51219358
MW
12846 if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
12847 eep_config.check_sum) {
12848 warn_code |= ASC_WARN_EEPROM_CHKSUM;
27c868c2 12849
51219358
MW
12850 /*
12851 * Set EEPROM default values.
12852 */
12853 memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
12854 sizeof(ADVEEP_38C0800_CONFIG));
1da177e4 12855
51219358
MW
12856 /*
12857 * Assume the 6 byte board serial number that was read from
12858 * EEPROM is correct even if the EEPROM checksum failed.
12859 */
12860 eep_config.serial_number_word3 =
12861 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
1da177e4 12862
51219358
MW
12863 eep_config.serial_number_word2 =
12864 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
27c868c2 12865
51219358
MW
12866 eep_config.serial_number_word1 =
12867 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
27c868c2 12868
51219358 12869 AdvSet38C0800EEPConfig(iop_base, &eep_config);
27c868c2 12870 }
27c868c2 12871 /*
51219358
MW
12872 * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
12873 * EEPROM configuration that was read.
12874 *
12875 * This is the mapping of EEPROM fields to Adv Library fields.
27c868c2 12876 */
51219358
MW
12877 asc_dvc->wdtr_able = eep_config.wdtr_able;
12878 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
12879 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
12880 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
12881 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
12882 asc_dvc->tagqng_able = eep_config.tagqng_able;
12883 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
12884 asc_dvc->max_host_qng = eep_config.max_host_qng;
12885 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
12886 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
12887 asc_dvc->start_motor = eep_config.start_motor;
12888 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
12889 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
12890 asc_dvc->no_scam = eep_config.scam_tolerant;
12891 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
12892 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
12893 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
27c868c2
MW
12894
12895 /*
51219358
MW
12896 * For every Target ID if any of its 'sdtr_speed[1234]' bits
12897 * are set, then set an 'sdtr_able' bit for it.
27c868c2 12898 */
51219358
MW
12899 asc_dvc->sdtr_able = 0;
12900 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
12901 if (tid == 0) {
12902 sdtr_speed = asc_dvc->sdtr_speed1;
12903 } else if (tid == 4) {
12904 sdtr_speed = asc_dvc->sdtr_speed2;
12905 } else if (tid == 8) {
12906 sdtr_speed = asc_dvc->sdtr_speed3;
12907 } else if (tid == 12) {
12908 sdtr_speed = asc_dvc->sdtr_speed4;
12909 }
12910 if (sdtr_speed & ADV_MAX_TID) {
12911 asc_dvc->sdtr_able |= (1 << tid);
12912 }
12913 sdtr_speed >>= 4;
12914 }
27c868c2
MW
12915
12916 /*
51219358
MW
12917 * Set the host maximum queuing (max. 253, min. 16) and the per device
12918 * maximum queuing (max. 63, min. 4).
27c868c2 12919 */
51219358
MW
12920 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
12921 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
12922 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
12923 /* If the value is zero, assume it is uninitialized. */
12924 if (eep_config.max_host_qng == 0) {
12925 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
12926 } else {
12927 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
12928 }
27c868c2 12929 }
1da177e4 12930
51219358
MW
12931 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
12932 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
12933 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
12934 /* If the value is zero, assume it is uninitialized. */
12935 if (eep_config.max_dvc_qng == 0) {
12936 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
12937 } else {
12938 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
12939 }
12940 }
12941
12942 /*
12943 * If 'max_dvc_qng' is greater than 'max_host_qng', then
12944 * set 'max_dvc_qng' to 'max_host_qng'.
12945 */
12946 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
12947 eep_config.max_dvc_qng = eep_config.max_host_qng;
27c868c2 12948 }
1da177e4 12949
27c868c2 12950 /*
51219358
MW
12951 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
12952 * values based on possibly adjusted EEPROM values.
27c868c2 12953 */
51219358
MW
12954 asc_dvc->max_host_qng = eep_config.max_host_qng;
12955 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
27c868c2
MW
12956
12957 /*
51219358
MW
12958 * If the EEPROM 'termination' field is set to automatic (0), then set
12959 * the ADV_DVC_CFG 'termination' field to automatic also.
12960 *
12961 * If the termination is specified with a non-zero 'termination'
12962 * value check that a legal value is set and set the ADV_DVC_CFG
12963 * 'termination' field appropriately.
27c868c2 12964 */
51219358
MW
12965 if (eep_config.termination_se == 0) {
12966 termination = 0; /* auto termination for SE */
12967 } else {
12968 /* Enable manual control with low off / high off. */
12969 if (eep_config.termination_se == 1) {
12970 termination = 0;
12971
12972 /* Enable manual control with low off / high on. */
12973 } else if (eep_config.termination_se == 2) {
12974 termination = TERM_SE_HI;
12975
12976 /* Enable manual control with low on / high on. */
12977 } else if (eep_config.termination_se == 3) {
12978 termination = TERM_SE;
12979 } else {
12980 /*
12981 * The EEPROM 'termination_se' field contains a bad value.
12982 * Use automatic termination instead.
12983 */
12984 termination = 0;
12985 warn_code |= ASC_WARN_EEPROM_TERMINATION;
12986 }
27c868c2 12987 }
51219358
MW
12988
12989 if (eep_config.termination_lvd == 0) {
12990 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
12991 } else {
12992 /* Enable manual control with low off / high off. */
12993 if (eep_config.termination_lvd == 1) {
12994 asc_dvc->cfg->termination = termination;
12995
12996 /* Enable manual control with low off / high on. */
12997 } else if (eep_config.termination_lvd == 2) {
12998 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
12999
13000 /* Enable manual control with low on / high on. */
13001 } else if (eep_config.termination_lvd == 3) {
13002 asc_dvc->cfg->termination = termination | TERM_LVD;
13003 } else {
13004 /*
13005 * The EEPROM 'termination_lvd' field contains a bad value.
13006 * Use automatic termination instead.
13007 */
13008 asc_dvc->cfg->termination = termination;
13009 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13010 }
27c868c2 13011 }
1da177e4 13012
51219358 13013 return warn_code;
1da177e4
LT
13014}
13015
13016/*
51219358
MW
13017 * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
13018 * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
13019 * all of this is done.
1da177e4 13020 *
51219358 13021 * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
1da177e4 13022 *
51219358
MW
13023 * For a non-fatal error return a warning code. If there are no warnings
13024 * then 0 is returned.
1da177e4 13025 *
51219358 13026 * Note: Chip is stopped on entry.
1da177e4 13027 */
51219358 13028static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
1da177e4 13029{
27c868c2 13030 AdvPortAddr iop_base;
51219358
MW
13031 ushort warn_code;
13032 ADVEEP_38C1600_CONFIG eep_config;
13033 uchar tid, termination;
13034 ushort sdtr_speed = 0;
1da177e4 13035
27c868c2
MW
13036 iop_base = asc_dvc->iop_base;
13037
51219358 13038 warn_code = 0;
27c868c2 13039
51219358
MW
13040 /*
13041 * Read the board's EEPROM configuration.
13042 *
13043 * Set default values if a bad checksum is found.
13044 */
13045 if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
13046 eep_config.check_sum) {
13047 struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
13048 warn_code |= ASC_WARN_EEPROM_CHKSUM;
13049
13050 /*
13051 * Set EEPROM default values.
13052 */
13053 memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
13054 sizeof(ADVEEP_38C1600_CONFIG));
13055
13056 if (PCI_FUNC(pdev->devfn) != 0) {
13057 u8 ints;
13058 /*
13059 * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
13060 * and old Mac system booting problem. The Expansion
13061 * ROM must be disabled in Function 1 for these systems
13062 */
13063 eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
13064 /*
13065 * Clear the INTAB (bit 11) if the GPIO 0 input
13066 * indicates the Function 1 interrupt line is wired
13067 * to INTB.
13068 *
13069 * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
13070 * 1 - Function 1 interrupt line wired to INT A.
13071 * 0 - Function 1 interrupt line wired to INT B.
13072 *
13073 * Note: Function 0 is always wired to INTA.
13074 * Put all 5 GPIO bits in input mode and then read
13075 * their input values.
13076 */
13077 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
13078 ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
13079 if ((ints & 0x01) == 0)
13080 eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
13081 }
13082
13083 /*
13084 * Assume the 6 byte board serial number that was read from
13085 * EEPROM is correct even if the EEPROM checksum failed.
13086 */
13087 eep_config.serial_number_word3 =
13088 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
13089 eep_config.serial_number_word2 =
13090 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
13091 eep_config.serial_number_word1 =
13092 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
13093
13094 AdvSet38C1600EEPConfig(iop_base, &eep_config);
27c868c2
MW
13095 }
13096
13097 /*
51219358
MW
13098 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
13099 * EEPROM configuration that was read.
13100 *
13101 * This is the mapping of EEPROM fields to Adv Library fields.
27c868c2 13102 */
51219358
MW
13103 asc_dvc->wdtr_able = eep_config.wdtr_able;
13104 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
13105 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
13106 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
13107 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
13108 asc_dvc->ppr_able = 0;
13109 asc_dvc->tagqng_able = eep_config.tagqng_able;
13110 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
13111 asc_dvc->max_host_qng = eep_config.max_host_qng;
13112 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
13113 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
13114 asc_dvc->start_motor = eep_config.start_motor;
13115 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
13116 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
13117 asc_dvc->no_scam = eep_config.scam_tolerant;
27c868c2 13118
51219358
MW
13119 /*
13120 * For every Target ID if any of its 'sdtr_speed[1234]' bits
13121 * are set, then set an 'sdtr_able' bit for it.
13122 */
13123 asc_dvc->sdtr_able = 0;
13124 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
13125 if (tid == 0) {
13126 sdtr_speed = asc_dvc->sdtr_speed1;
13127 } else if (tid == 4) {
13128 sdtr_speed = asc_dvc->sdtr_speed2;
13129 } else if (tid == 8) {
13130 sdtr_speed = asc_dvc->sdtr_speed3;
13131 } else if (tid == 12) {
13132 sdtr_speed = asc_dvc->sdtr_speed4;
13133 }
13134 if (sdtr_speed & ASC_MAX_TID) {
13135 asc_dvc->sdtr_able |= (1 << tid);
13136 }
13137 sdtr_speed >>= 4;
13138 }
27c868c2 13139
51219358
MW
13140 /*
13141 * Set the host maximum queuing (max. 253, min. 16) and the per device
13142 * maximum queuing (max. 63, min. 4).
13143 */
13144 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
13145 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13146 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
13147 /* If the value is zero, assume it is uninitialized. */
13148 if (eep_config.max_host_qng == 0) {
13149 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13150 } else {
13151 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
27c868c2 13152 }
51219358 13153 }
27c868c2 13154
51219358
MW
13155 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
13156 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13157 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
13158 /* If the value is zero, assume it is uninitialized. */
13159 if (eep_config.max_dvc_qng == 0) {
13160 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13161 } else {
13162 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
13163 }
13164 }
13165
13166 /*
13167 * If 'max_dvc_qng' is greater than 'max_host_qng', then
13168 * set 'max_dvc_qng' to 'max_host_qng'.
13169 */
13170 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
13171 eep_config.max_dvc_qng = eep_config.max_host_qng;
27c868c2
MW
13172 }
13173
13174 /*
51219358
MW
13175 * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
13176 * values based on possibly adjusted EEPROM values.
13177 */
13178 asc_dvc->max_host_qng = eep_config.max_host_qng;
13179 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
13180
13181 /*
13182 * If the EEPROM 'termination' field is set to automatic (0), then set
13183 * the ASC_DVC_CFG 'termination' field to automatic also.
13184 *
13185 * If the termination is specified with a non-zero 'termination'
13186 * value check that a legal value is set and set the ASC_DVC_CFG
13187 * 'termination' field appropriately.
27c868c2 13188 */
51219358
MW
13189 if (eep_config.termination_se == 0) {
13190 termination = 0; /* auto termination for SE */
13191 } else {
13192 /* Enable manual control with low off / high off. */
13193 if (eep_config.termination_se == 1) {
13194 termination = 0;
27c868c2 13195
51219358
MW
13196 /* Enable manual control with low off / high on. */
13197 } else if (eep_config.termination_se == 2) {
13198 termination = TERM_SE_HI;
27c868c2 13199
51219358
MW
13200 /* Enable manual control with low on / high on. */
13201 } else if (eep_config.termination_se == 3) {
13202 termination = TERM_SE;
13203 } else {
13204 /*
13205 * The EEPROM 'termination_se' field contains a bad value.
13206 * Use automatic termination instead.
13207 */
13208 termination = 0;
13209 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13210 }
13211 }
27c868c2 13212
51219358
MW
13213 if (eep_config.termination_lvd == 0) {
13214 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
13215 } else {
13216 /* Enable manual control with low off / high off. */
13217 if (eep_config.termination_lvd == 1) {
13218 asc_dvc->cfg->termination = termination;
27c868c2 13219
51219358
MW
13220 /* Enable manual control with low off / high on. */
13221 } else if (eep_config.termination_lvd == 2) {
13222 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
27c868c2 13223
51219358
MW
13224 /* Enable manual control with low on / high on. */
13225 } else if (eep_config.termination_lvd == 3) {
13226 asc_dvc->cfg->termination = termination | TERM_LVD;
13227 } else {
13228 /*
13229 * The EEPROM 'termination_lvd' field contains a bad value.
13230 * Use automatic termination instead.
13231 */
13232 asc_dvc->cfg->termination = termination;
13233 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13234 }
27c868c2 13235 }
51219358
MW
13236
13237 return warn_code;
1da177e4
LT
13238}
13239
13240/*
51219358 13241 * Initialize the ADV_DVC_VAR structure.
1da177e4 13242 *
51219358 13243 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
1da177e4 13244 *
51219358
MW
13245 * For a non-fatal error return a warning code. If there are no warnings
13246 * then 0 is returned.
1da177e4 13247 */
51219358 13248static int __devinit
9d0e96eb 13249AdvInitGetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
1da177e4 13250{
9d0e96eb
MW
13251 struct asc_board *board = shost_priv(shost);
13252 ADV_DVC_VAR *asc_dvc = &board->dvc_var.adv_dvc_var;
51219358
MW
13253 unsigned short warn_code = 0;
13254 AdvPortAddr iop_base = asc_dvc->iop_base;
13255 u16 cmd;
13256 int status;
27c868c2 13257
51219358 13258 asc_dvc->err_code = 0;
27c868c2
MW
13259
13260 /*
51219358
MW
13261 * Save the state of the PCI Configuration Command Register
13262 * "Parity Error Response Control" Bit. If the bit is clear (0),
13263 * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
13264 * DMA parity errors.
27c868c2 13265 */
51219358
MW
13266 asc_dvc->cfg->control_flag = 0;
13267 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
13268 if ((cmd & PCI_COMMAND_PARITY) == 0)
13269 asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
27c868c2 13270
51219358
MW
13271 asc_dvc->cfg->chip_version =
13272 AdvGetChipVersion(iop_base, asc_dvc->bus_type);
13273
b352f923 13274 ASC_DBG(1, "iopb_chip_id_1: 0x%x 0x%x\n",
51219358
MW
13275 (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
13276 (ushort)ADV_CHIP_ID_BYTE);
13277
b352f923 13278 ASC_DBG(1, "iopw_chip_id_0: 0x%x 0x%x\n",
51219358
MW
13279 (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
13280 (ushort)ADV_CHIP_ID_WORD);
27c868c2
MW
13281
13282 /*
51219358 13283 * Reset the chip to start and allow register writes.
27c868c2 13284 */
51219358
MW
13285 if (AdvFindSignature(iop_base) == 0) {
13286 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
13287 return ADV_ERROR;
13288 } else {
27c868c2 13289 /*
51219358 13290 * The caller must set 'chip_type' to a valid setting.
27c868c2 13291 */
51219358
MW
13292 if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
13293 asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
13294 asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
13295 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
13296 return ADV_ERROR;
13297 }
1da177e4 13298
51219358
MW
13299 /*
13300 * Reset Chip.
13301 */
13302 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
13303 ADV_CTRL_REG_CMD_RESET);
13304 mdelay(100);
13305 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
13306 ADV_CTRL_REG_CMD_WR_IO_REG);
13307
13308 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
13309 status = AdvInitFrom38C1600EEP(asc_dvc);
13310 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
13311 status = AdvInitFrom38C0800EEP(asc_dvc);
13312 } else {
13313 status = AdvInitFrom3550EEP(asc_dvc);
27c868c2 13314 }
51219358 13315 warn_code |= status;
27c868c2 13316 }
1da177e4 13317
9d0e96eb
MW
13318 if (warn_code != 0)
13319 shost_printk(KERN_WARNING, shost, "warning: 0x%x\n", warn_code);
51219358 13320
9d0e96eb
MW
13321 if (asc_dvc->err_code)
13322 shost_printk(KERN_ERR, shost, "error code 0x%x\n",
13323 asc_dvc->err_code);
51219358
MW
13324
13325 return asc_dvc->err_code;
1da177e4 13326}
51219358
MW
13327#endif
13328
13329static struct scsi_host_template advansys_template = {
13330 .proc_name = DRV_NAME,
13331#ifdef CONFIG_PROC_FS
13332 .proc_info = advansys_proc_info,
13333#endif
13334 .name = DRV_NAME,
13335 .info = advansys_info,
13336 .queuecommand = advansys_queuecommand,
13337 .eh_bus_reset_handler = advansys_reset,
13338 .bios_param = advansys_biosparam,
13339 .slave_configure = advansys_slave_configure,
13340 /*
13341 * Because the driver may control an ISA adapter 'unchecked_isa_dma'
13342 * must be set. The flag will be cleared in advansys_board_found
13343 * for non-ISA adapters.
13344 */
13345 .unchecked_isa_dma = 1,
13346 /*
13347 * All adapters controlled by this driver are capable of large
13348 * scatter-gather lists. According to the mid-level SCSI documentation
13349 * this obviates any performance gain provided by setting
13350 * 'use_clustering'. But empirically while CPU utilization is increased
13351 * by enabling clustering, I/O throughput increases as well.
13352 */
13353 .use_clustering = ENABLE_CLUSTERING,
13354};
1da177e4 13355
9d0e96eb 13356static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
b2c16f58 13357{
9d0e96eb
MW
13358 struct asc_board *board = shost_priv(shost);
13359 struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
b2c16f58
MW
13360 int req_cnt = 0;
13361 adv_req_t *reqp = NULL;
13362 int sg_cnt = 0;
13363 adv_sgblk_t *sgp;
13364 int warn_code, err_code;
13365
13366 /*
13367 * Allocate buffer carrier structures. The total size
13368 * is about 4 KB, so allocate all at once.
13369 */
98d41c29
MW
13370 adv_dvc->carrier_buf = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
13371 ASC_DBG(1, "carrier_buf 0x%p\n", adv_dvc->carrier_buf);
b2c16f58 13372
98d41c29 13373 if (!adv_dvc->carrier_buf)
b2c16f58
MW
13374 goto kmalloc_failed;
13375
13376 /*
13377 * Allocate up to 'max_host_qng' request structures for the Wide
13378 * board. The total size is about 16 KB, so allocate all at once.
13379 * If the allocation fails decrement and try again.
13380 */
9d0e96eb 13381 for (req_cnt = adv_dvc->max_host_qng; req_cnt > 0; req_cnt--) {
b2c16f58
MW
13382 reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
13383
b352f923 13384 ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", reqp, req_cnt,
b2c16f58
MW
13385 (ulong)sizeof(adv_req_t) * req_cnt);
13386
13387 if (reqp)
13388 break;
13389 }
13390
13391 if (!reqp)
13392 goto kmalloc_failed;
13393
98d41c29 13394 adv_dvc->orig_reqp = reqp;
b2c16f58
MW
13395
13396 /*
13397 * Allocate up to ADV_TOT_SG_BLOCK request structures for
13398 * the Wide board. Each structure is about 136 bytes.
13399 */
9d0e96eb 13400 board->adv_sgblkp = NULL;
b2c16f58
MW
13401 for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
13402 sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
13403
13404 if (!sgp)
13405 break;
13406
9d0e96eb
MW
13407 sgp->next_sgblkp = board->adv_sgblkp;
13408 board->adv_sgblkp = sgp;
b2c16f58
MW
13409
13410 }
13411
b352f923 13412 ASC_DBG(1, "sg_cnt %d * %u = %u bytes\n", sg_cnt, sizeof(adv_sgblk_t),
b2c16f58
MW
13413 (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
13414
9d0e96eb 13415 if (!board->adv_sgblkp)
b2c16f58
MW
13416 goto kmalloc_failed;
13417
b2c16f58
MW
13418 /*
13419 * Point 'adv_reqp' to the request structures and
13420 * link them together.
13421 */
13422 req_cnt--;
13423 reqp[req_cnt].next_reqp = NULL;
13424 for (; req_cnt > 0; req_cnt--) {
13425 reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
13426 }
9d0e96eb 13427 board->adv_reqp = &reqp[0];
b2c16f58 13428
9d0e96eb 13429 if (adv_dvc->chip_type == ADV_CHIP_ASC3550) {
b352f923 13430 ASC_DBG(2, "AdvInitAsc3550Driver()\n");
9d0e96eb
MW
13431 warn_code = AdvInitAsc3550Driver(adv_dvc);
13432 } else if (adv_dvc->chip_type == ADV_CHIP_ASC38C0800) {
b352f923 13433 ASC_DBG(2, "AdvInitAsc38C0800Driver()\n");
9d0e96eb 13434 warn_code = AdvInitAsc38C0800Driver(adv_dvc);
b2c16f58 13435 } else {
b352f923 13436 ASC_DBG(2, "AdvInitAsc38C1600Driver()\n");
9d0e96eb 13437 warn_code = AdvInitAsc38C1600Driver(adv_dvc);
b2c16f58 13438 }
9d0e96eb 13439 err_code = adv_dvc->err_code;
b2c16f58
MW
13440
13441 if (warn_code || err_code) {
9d0e96eb
MW
13442 shost_printk(KERN_WARNING, shost, "error: warn 0x%x, error "
13443 "0x%x\n", warn_code, err_code);
b2c16f58
MW
13444 }
13445
13446 goto exit;
13447
13448 kmalloc_failed:
9d0e96eb 13449 shost_printk(KERN_ERR, shost, "error: kmalloc() failed\n");
b2c16f58
MW
13450 err_code = ADV_ERROR;
13451 exit:
13452 return err_code;
13453}
13454
98d41c29 13455static void advansys_wide_free_mem(struct asc_board *board)
b2c16f58 13456{
98d41c29
MW
13457 struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
13458 kfree(adv_dvc->carrier_buf);
13459 adv_dvc->carrier_buf = NULL;
13460 kfree(adv_dvc->orig_reqp);
13461 adv_dvc->orig_reqp = board->adv_reqp = NULL;
13462 while (board->adv_sgblkp) {
13463 adv_sgblk_t *sgp = board->adv_sgblkp;
13464 board->adv_sgblkp = sgp->next_sgblkp;
b2c16f58
MW
13465 kfree(sgp);
13466 }
13467}
13468
d361db48
MW
13469static int __devinit advansys_board_found(struct Scsi_Host *shost,
13470 unsigned int iop, int bus_type)
27c868c2 13471{
d361db48 13472 struct pci_dev *pdev;
d2411495 13473 struct asc_board *boardp = shost_priv(shost);
27c868c2
MW
13474 ASC_DVC_VAR *asc_dvc_varp = NULL;
13475 ADV_DVC_VAR *adv_dvc_varp = NULL;
d361db48 13476 int share_irq, warn_code, ret;
27c868c2 13477
d361db48 13478 pdev = (bus_type == ASC_IS_PCI) ? to_pci_dev(boardp->dev) : NULL;
27c868c2
MW
13479
13480 if (ASC_NARROW_BOARD(boardp)) {
b352f923 13481 ASC_DBG(1, "narrow board\n");
27c868c2
MW
13482 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
13483 asc_dvc_varp->bus_type = bus_type;
13484 asc_dvc_varp->drv_ptr = boardp;
13485 asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
13486 asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
13487 asc_dvc_varp->iop_base = iop;
27c868c2 13488 } else {
57ba5fe9 13489#ifdef CONFIG_PCI
27c868c2
MW
13490 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
13491 adv_dvc_varp->drv_ptr = boardp;
13492 adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
27c868c2 13493 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
b352f923 13494 ASC_DBG(1, "wide board ASC-3550\n");
27c868c2
MW
13495 adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
13496 } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
b352f923 13497 ASC_DBG(1, "wide board ASC-38C0800\n");
27c868c2
MW
13498 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
13499 } else {
b352f923 13500 ASC_DBG(1, "wide board ASC-38C1600\n");
27c868c2
MW
13501 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
13502 }
27c868c2 13503
57ba5fe9
MW
13504 boardp->asc_n_io_port = pci_resource_len(pdev, 1);
13505 boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
13506 boardp->asc_n_io_port);
13507 if (!boardp->ioremap_addr) {
9d0e96eb
MW
13508 shost_printk(KERN_ERR, shost, "ioremap(%x, %d) "
13509 "returned NULL\n",
13510 pci_resource_start(pdev, 1),
13511 boardp->asc_n_io_port);
d361db48 13512 ret = -ENODEV;
b2c16f58 13513 goto err_shost;
27c868c2 13514 }
b352f923
MW
13515 adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr;
13516 ASC_DBG(1, "iop_base: 0x%p\n", adv_dvc_varp->iop_base);
27c868c2
MW
13517
13518 /*
13519 * Even though it isn't used to access wide boards, other
13520 * than for the debug line below, save I/O Port address so
13521 * that it can be reported.
13522 */
13523 boardp->ioport = iop;
13524
b352f923
MW
13525 ASC_DBG(1, "iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
13526 (ushort)inp(iop + 1), (ushort)inpw(iop));
57ba5fe9 13527#endif /* CONFIG_PCI */
27c868c2
MW
13528 }
13529
13530#ifdef CONFIG_PROC_FS
13531 /*
13532 * Allocate buffer for printing information from
13533 * /proc/scsi/advansys/[0...].
13534 */
b2c16f58
MW
13535 boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
13536 if (!boardp->prtbuf) {
9d0e96eb
MW
13537 shost_printk(KERN_ERR, shost, "kmalloc(%d) returned NULL\n",
13538 ASC_PRTBUF_SIZE);
d361db48 13539 ret = -ENOMEM;
b2c16f58 13540 goto err_unmap;
27c868c2
MW
13541 }
13542#endif /* CONFIG_PROC_FS */
13543
13544 if (ASC_NARROW_BOARD(boardp)) {
27c868c2
MW
13545 /*
13546 * Set the board bus type and PCI IRQ before
13547 * calling AscInitGetConfig().
13548 */
13549 switch (asc_dvc_varp->bus_type) {
13550#ifdef CONFIG_ISA
13551 case ASC_IS_ISA:
13552 shost->unchecked_isa_dma = TRUE;
074c8fe4 13553 share_irq = 0;
27c868c2
MW
13554 break;
13555 case ASC_IS_VL:
13556 shost->unchecked_isa_dma = FALSE;
074c8fe4 13557 share_irq = 0;
27c868c2
MW
13558 break;
13559 case ASC_IS_EISA:
13560 shost->unchecked_isa_dma = FALSE;
074c8fe4 13561 share_irq = IRQF_SHARED;
27c868c2
MW
13562 break;
13563#endif /* CONFIG_ISA */
13564#ifdef CONFIG_PCI
13565 case ASC_IS_PCI:
27c868c2 13566 shost->unchecked_isa_dma = FALSE;
074c8fe4 13567 share_irq = IRQF_SHARED;
27c868c2
MW
13568 break;
13569#endif /* CONFIG_PCI */
13570 default:
9d0e96eb
MW
13571 shost_printk(KERN_ERR, shost, "unknown adapter type: "
13572 "%d\n", asc_dvc_varp->bus_type);
27c868c2 13573 shost->unchecked_isa_dma = TRUE;
074c8fe4 13574 share_irq = 0;
27c868c2
MW
13575 break;
13576 }
27c868c2 13577
27c868c2
MW
13578 /*
13579 * NOTE: AscInitGetConfig() may change the board's
13580 * bus_type value. The bus_type value should no
13581 * longer be used. If the bus_type field must be
13582 * referenced only use the bit-wise AND operator "&".
13583 */
b352f923 13584 ASC_DBG(2, "AscInitGetConfig()\n");
9d0e96eb 13585 ret = AscInitGetConfig(shost) ? -ENODEV : 0;
27c868c2 13586 } else {
c2dce2fa
MW
13587#ifdef CONFIG_PCI
13588 /*
13589 * For Wide boards set PCI information before calling
13590 * AdvInitGetConfig().
13591 */
c2dce2fa
MW
13592 shost->unchecked_isa_dma = FALSE;
13593 share_irq = IRQF_SHARED;
b352f923 13594 ASC_DBG(2, "AdvInitGetConfig()\n");
394dbf3f 13595
9d0e96eb 13596 ret = AdvInitGetConfig(pdev, shost) ? -ENODEV : 0;
c2dce2fa 13597#endif /* CONFIG_PCI */
27c868c2
MW
13598 }
13599
d361db48 13600 if (ret)
b2c16f58 13601 goto err_free_proc;
27c868c2
MW
13602
13603 /*
13604 * Save the EEPROM configuration so that it can be displayed
13605 * from /proc/scsi/advansys/[0...].
13606 */
13607 if (ASC_NARROW_BOARD(boardp)) {
13608
13609 ASCEEP_CONFIG *ep;
13610
13611 /*
13612 * Set the adapter's target id bit in the 'init_tidmask' field.
13613 */
13614 boardp->init_tidmask |=
13615 ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
13616
13617 /*
13618 * Save EEPROM settings for the board.
13619 */
13620 ep = &boardp->eep_config.asc_eep;
13621
13622 ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
13623 ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
13624 ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
13625 ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
13626 ep->start_motor = asc_dvc_varp->start_motor;
13627 ep->cntl = asc_dvc_varp->dvc_cntl;
13628 ep->no_scam = asc_dvc_varp->no_scam;
13629 ep->max_total_qng = asc_dvc_varp->max_total_qng;
13630 ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
13631 /* 'max_tag_qng' is set to the same value for every device. */
13632 ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
13633 ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
13634 ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
13635 ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
13636 ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
13637 ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
13638 ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
13639
13640 /*
13641 * Modify board configuration.
13642 */
b352f923 13643 ASC_DBG(2, "AscInitSetConfig()\n");
9d0e96eb 13644 ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0;
d361db48 13645 if (ret)
b2c16f58 13646 goto err_free_proc;
27c868c2
MW
13647 } else {
13648 ADVEEP_3550_CONFIG *ep_3550;
13649 ADVEEP_38C0800_CONFIG *ep_38C0800;
13650 ADVEEP_38C1600_CONFIG *ep_38C1600;
13651
13652 /*
13653 * Save Wide EEP Configuration Information.
13654 */
13655 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
13656 ep_3550 = &boardp->eep_config.adv_3550_eep;
13657
13658 ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
13659 ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
13660 ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
13661 ep_3550->termination = adv_dvc_varp->cfg->termination;
13662 ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
13663 ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
13664 ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
13665 ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
13666 ep_3550->ultra_able = adv_dvc_varp->ultra_able;
13667 ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
13668 ep_3550->start_motor = adv_dvc_varp->start_motor;
13669 ep_3550->scsi_reset_delay =
13670 adv_dvc_varp->scsi_reset_wait;
13671 ep_3550->serial_number_word1 =
13672 adv_dvc_varp->cfg->serial1;
13673 ep_3550->serial_number_word2 =
13674 adv_dvc_varp->cfg->serial2;
13675 ep_3550->serial_number_word3 =
13676 adv_dvc_varp->cfg->serial3;
13677 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
13678 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
13679
13680 ep_38C0800->adapter_scsi_id =
13681 adv_dvc_varp->chip_scsi_id;
13682 ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
13683 ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
13684 ep_38C0800->termination_lvd =
13685 adv_dvc_varp->cfg->termination;
13686 ep_38C0800->disc_enable =
13687 adv_dvc_varp->cfg->disc_enable;
13688 ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
13689 ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
13690 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
13691 ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
13692 ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
13693 ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
13694 ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
13695 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
13696 ep_38C0800->start_motor = adv_dvc_varp->start_motor;
13697 ep_38C0800->scsi_reset_delay =
13698 adv_dvc_varp->scsi_reset_wait;
13699 ep_38C0800->serial_number_word1 =
13700 adv_dvc_varp->cfg->serial1;
13701 ep_38C0800->serial_number_word2 =
13702 adv_dvc_varp->cfg->serial2;
13703 ep_38C0800->serial_number_word3 =
13704 adv_dvc_varp->cfg->serial3;
13705 } else {
13706 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
13707
13708 ep_38C1600->adapter_scsi_id =
13709 adv_dvc_varp->chip_scsi_id;
13710 ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
13711 ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
13712 ep_38C1600->termination_lvd =
13713 adv_dvc_varp->cfg->termination;
13714 ep_38C1600->disc_enable =
13715 adv_dvc_varp->cfg->disc_enable;
13716 ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
13717 ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
13718 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
13719 ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
13720 ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
13721 ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
13722 ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
13723 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
13724 ep_38C1600->start_motor = adv_dvc_varp->start_motor;
13725 ep_38C1600->scsi_reset_delay =
13726 adv_dvc_varp->scsi_reset_wait;
13727 ep_38C1600->serial_number_word1 =
13728 adv_dvc_varp->cfg->serial1;
13729 ep_38C1600->serial_number_word2 =
13730 adv_dvc_varp->cfg->serial2;
13731 ep_38C1600->serial_number_word3 =
13732 adv_dvc_varp->cfg->serial3;
13733 }
13734
13735 /*
13736 * Set the adapter's target id bit in the 'init_tidmask' field.
13737 */
13738 boardp->init_tidmask |=
13739 ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
27c868c2
MW
13740 }
13741
13742 /*
13743 * Channels are numbered beginning with 0. For AdvanSys one host
13744 * structure supports one channel. Multi-channel boards have a
13745 * separate host structure for each channel.
13746 */
13747 shost->max_channel = 0;
13748 if (ASC_NARROW_BOARD(boardp)) {
13749 shost->max_id = ASC_MAX_TID + 1;
13750 shost->max_lun = ASC_MAX_LUN + 1;
f05ec594 13751 shost->max_cmd_len = ASC_MAX_CDB_LEN;
27c868c2
MW
13752
13753 shost->io_port = asc_dvc_varp->iop_base;
13754 boardp->asc_n_io_port = ASC_IOADR_GAP;
13755 shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
13756
13757 /* Set maximum number of queues the adapter can handle. */
13758 shost->can_queue = asc_dvc_varp->max_total_qng;
13759 } else {
13760 shost->max_id = ADV_MAX_TID + 1;
13761 shost->max_lun = ADV_MAX_LUN + 1;
f05ec594 13762 shost->max_cmd_len = ADV_MAX_CDB_LEN;
27c868c2
MW
13763
13764 /*
13765 * Save the I/O Port address and length even though
13766 * I/O ports are not used to access Wide boards.
13767 * Instead the Wide boards are accessed with
13768 * PCI Memory Mapped I/O.
13769 */
13770 shost->io_port = iop;
27c868c2
MW
13771
13772 shost->this_id = adv_dvc_varp->chip_scsi_id;
13773
13774 /* Set maximum number of queues the adapter can handle. */
13775 shost->can_queue = adv_dvc_varp->max_host_qng;
13776 }
13777
27c868c2
MW
13778 /*
13779 * Following v1.3.89, 'cmd_per_lun' is no longer needed
13780 * and should be set to zero.
13781 *
13782 * But because of a bug introduced in v1.3.89 if the driver is
13783 * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
13784 * SCSI function 'allocate_device' will panic. To allow the driver
13785 * to work as a module in these kernels set 'cmd_per_lun' to 1.
13786 *
13787 * Note: This is wrong. cmd_per_lun should be set to the depth
13788 * you want on untagged devices always.
13789 #ifdef MODULE
13790 */
13791 shost->cmd_per_lun = 1;
13792/* #else
13793 shost->cmd_per_lun = 0;
13794#endif */
13795
13796 /*
13797 * Set the maximum number of scatter-gather elements the
13798 * adapter can handle.
13799 */
13800 if (ASC_NARROW_BOARD(boardp)) {
13801 /*
13802 * Allow two commands with 'sg_tablesize' scatter-gather
13803 * elements to be executed simultaneously. This value is
13804 * the theoretical hardware limit. It may be decreased
13805 * below.
13806 */
13807 shost->sg_tablesize =
13808 (((asc_dvc_varp->max_total_qng - 2) / 2) *
13809 ASC_SG_LIST_PER_Q) + 1;
13810 } else {
13811 shost->sg_tablesize = ADV_MAX_SG_LIST;
13812 }
13813
13814 /*
13815 * The value of 'sg_tablesize' can not exceed the SCSI
13816 * mid-level driver definition of SG_ALL. SG_ALL also
13817 * must not be exceeded, because it is used to define the
13818 * size of the scatter-gather table in 'struct asc_sg_head'.
13819 */
13820 if (shost->sg_tablesize > SG_ALL) {
13821 shost->sg_tablesize = SG_ALL;
13822 }
13823
b352f923 13824 ASC_DBG(1, "sg_tablesize: %d\n", shost->sg_tablesize);
27c868c2
MW
13825
13826 /* BIOS start address. */
13827 if (ASC_NARROW_BOARD(boardp)) {
b2c16f58
MW
13828 shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
13829 asc_dvc_varp->bus_type);
27c868c2
MW
13830 } else {
13831 /*
13832 * Fill-in BIOS board variables. The Wide BIOS saves
13833 * information in LRAM that is used by the driver.
13834 */
13835 AdvReadWordLram(adv_dvc_varp->iop_base,
13836 BIOS_SIGNATURE, boardp->bios_signature);
13837 AdvReadWordLram(adv_dvc_varp->iop_base,
13838 BIOS_VERSION, boardp->bios_version);
13839 AdvReadWordLram(adv_dvc_varp->iop_base,
13840 BIOS_CODESEG, boardp->bios_codeseg);
13841 AdvReadWordLram(adv_dvc_varp->iop_base,
13842 BIOS_CODELEN, boardp->bios_codelen);
13843
b352f923 13844 ASC_DBG(1, "bios_signature 0x%x, bios_version 0x%x\n",
27c868c2
MW
13845 boardp->bios_signature, boardp->bios_version);
13846
b352f923 13847 ASC_DBG(1, "bios_codeseg 0x%x, bios_codelen 0x%x\n",
27c868c2
MW
13848 boardp->bios_codeseg, boardp->bios_codelen);
13849
13850 /*
13851 * If the BIOS saved a valid signature, then fill in
13852 * the BIOS code segment base address.
13853 */
13854 if (boardp->bios_signature == 0x55AA) {
13855 /*
13856 * Convert x86 realmode code segment to a linear
13857 * address by shifting left 4.
13858 */
13859 shost->base = ((ulong)boardp->bios_codeseg << 4);
13860 } else {
13861 shost->base = 0;
13862 }
13863 }
13864
13865 /*
13866 * Register Board Resources - I/O Port, DMA, IRQ
13867 */
13868
27c868c2
MW
13869 /* Register DMA Channel for Narrow boards. */
13870 shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
13871#ifdef CONFIG_ISA
13872 if (ASC_NARROW_BOARD(boardp)) {
13873 /* Register DMA channel for ISA bus. */
13874 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
13875 shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
01fbfe0b 13876 ret = request_dma(shost->dma_channel, DRV_NAME);
b2c16f58 13877 if (ret) {
9d0e96eb
MW
13878 shost_printk(KERN_ERR, shost, "request_dma() "
13879 "%d failed %d\n",
13880 shost->dma_channel, ret);
71f36115 13881 goto err_free_proc;
27c868c2
MW
13882 }
13883 AscEnableIsaDma(shost->dma_channel);
13884 }
13885 }
13886#endif /* CONFIG_ISA */
13887
13888 /* Register IRQ Number. */
b352f923 13889 ASC_DBG(2, "request_irq(%d, %p)\n", boardp->irq, shost);
074c8fe4 13890
d361db48 13891 ret = request_irq(boardp->irq, advansys_interrupt, share_irq,
01fbfe0b 13892 DRV_NAME, shost);
074c8fe4
MW
13893
13894 if (ret) {
27c868c2 13895 if (ret == -EBUSY) {
9d0e96eb
MW
13896 shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
13897 "already in use\n", boardp->irq);
27c868c2 13898 } else if (ret == -EINVAL) {
9d0e96eb
MW
13899 shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
13900 "not valid\n", boardp->irq);
27c868c2 13901 } else {
9d0e96eb
MW
13902 shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
13903 "failed with %d\n", boardp->irq, ret);
27c868c2 13904 }
b2c16f58 13905 goto err_free_dma;
27c868c2
MW
13906 }
13907
13908 /*
13909 * Initialize board RISC chip and enable interrupts.
13910 */
13911 if (ASC_NARROW_BOARD(boardp)) {
b352f923 13912 ASC_DBG(2, "AscInitAsc1000Driver()\n");
27c868c2 13913 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
27c868c2 13914
d361db48 13915 if (warn_code || asc_dvc_varp->err_code) {
9d0e96eb
MW
13916 shost_printk(KERN_ERR, shost, "error: init_state 0x%x, "
13917 "warn 0x%x, error 0x%x\n",
13918 asc_dvc_varp->init_state, warn_code,
13919 asc_dvc_varp->err_code);
d361db48
MW
13920 if (asc_dvc_varp->err_code)
13921 ret = -ENODEV;
27c868c2
MW
13922 }
13923 } else {
9d0e96eb 13924 if (advansys_wide_init_chip(shost))
d361db48 13925 ret = -ENODEV;
27c868c2
MW
13926 }
13927
d361db48 13928 if (ret)
b2c16f58
MW
13929 goto err_free_wide_mem;
13930
27c868c2
MW
13931 ASC_DBG_PRT_SCSI_HOST(2, shost);
13932
d361db48 13933 ret = scsi_add_host(shost, boardp->dev);
8dfb5379
MW
13934 if (ret)
13935 goto err_free_wide_mem;
13936
13937 scsi_scan_host(shost);
d361db48 13938 return 0;
b2c16f58
MW
13939
13940 err_free_wide_mem:
13941 advansys_wide_free_mem(boardp);
d361db48 13942 free_irq(boardp->irq, shost);
b2c16f58
MW
13943 err_free_dma:
13944 if (shost->dma_channel != NO_ISA_DMA)
13945 free_dma(shost->dma_channel);
b2c16f58
MW
13946 err_free_proc:
13947 kfree(boardp->prtbuf);
13948 err_unmap:
13949 if (boardp->ioremap_addr)
13950 iounmap(boardp->ioremap_addr);
13951 err_shost:
d361db48 13952 return ret;
27c868c2
MW
13953}
13954
27c868c2
MW
13955/*
13956 * advansys_release()
13957 *
13958 * Release resources allocated for a single AdvanSys adapter.
13959 */
13960static int advansys_release(struct Scsi_Host *shost)
13961{
d2411495 13962 struct asc_board *boardp = shost_priv(shost);
b352f923 13963 ASC_DBG(1, "begin\n");
8dfb5379 13964 scsi_remove_host(shost);
d361db48 13965 free_irq(boardp->irq, shost);
27c868c2 13966 if (shost->dma_channel != NO_ISA_DMA) {
b352f923 13967 ASC_DBG(1, "free_dma()\n");
27c868c2
MW
13968 free_dma(shost->dma_channel);
13969 }
9a256fa5 13970 if (!ASC_NARROW_BOARD(boardp)) {
27c868c2 13971 iounmap(boardp->ioremap_addr);
b2c16f58 13972 advansys_wide_free_mem(boardp);
27c868c2 13973 }
27c868c2 13974 kfree(boardp->prtbuf);
8dfb5379 13975 scsi_host_put(shost);
b352f923 13976 ASC_DBG(1, "end\n");
27c868c2
MW
13977 return 0;
13978}
13979
95c9f162
MW
13980#define ASC_IOADR_TABLE_MAX_IX 11
13981
c304ec94
MW
13982static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
13983 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
13984 0x0210, 0x0230, 0x0250, 0x0330
13985};
13986
d361db48
MW
13987/*
13988 * The ISA IRQ number is found in bits 2 and 3 of the CfgLsw. It decodes as:
13989 * 00: 10
13990 * 01: 11
13991 * 10: 12
13992 * 11: 15
13993 */
13994static unsigned int __devinit advansys_isa_irq_no(PortAddr iop_base)
13995{
13996 unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
13997 unsigned int chip_irq = ((cfg_lsw >> 2) & 0x03) + 10;
13998 if (chip_irq == 13)
13999 chip_irq = 15;
14000 return chip_irq;
14001}
14002
c304ec94
MW
14003static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
14004{
d361db48 14005 int err = -ENODEV;
c304ec94
MW
14006 PortAddr iop_base = _asc_def_iop_base[id];
14007 struct Scsi_Host *shost;
d361db48 14008 struct asc_board *board;
c304ec94 14009
01fbfe0b 14010 if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
b352f923 14011 ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
c304ec94
MW
14012 return -ENODEV;
14013 }
b352f923 14014 ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
c304ec94 14015 if (!AscFindSignature(iop_base))
d361db48 14016 goto release_region;
c304ec94 14017 if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
d361db48 14018 goto release_region;
c304ec94 14019
d361db48
MW
14020 err = -ENOMEM;
14021 shost = scsi_host_alloc(&advansys_template, sizeof(*board));
c304ec94 14022 if (!shost)
d361db48
MW
14023 goto release_region;
14024
d2411495 14025 board = shost_priv(shost);
d361db48
MW
14026 board->irq = advansys_isa_irq_no(iop_base);
14027 board->dev = dev;
14028
14029 err = advansys_board_found(shost, iop_base, ASC_IS_ISA);
14030 if (err)
14031 goto free_host;
c304ec94
MW
14032
14033 dev_set_drvdata(dev, shost);
14034 return 0;
14035
d361db48
MW
14036 free_host:
14037 scsi_host_put(shost);
14038 release_region:
71f36115 14039 release_region(iop_base, ASC_IOADR_GAP);
d361db48 14040 return err;
c304ec94
MW
14041}
14042
14043static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
14044{
71f36115 14045 int ioport = _asc_def_iop_base[id];
c304ec94 14046 advansys_release(dev_get_drvdata(dev));
71f36115 14047 release_region(ioport, ASC_IOADR_GAP);
c304ec94
MW
14048 return 0;
14049}
14050
14051static struct isa_driver advansys_isa_driver = {
14052 .probe = advansys_isa_probe,
14053 .remove = __devexit_p(advansys_isa_remove),
14054 .driver = {
14055 .owner = THIS_MODULE,
01fbfe0b 14056 .name = DRV_NAME,
c304ec94
MW
14057 },
14058};
14059
d361db48
MW
14060/*
14061 * The VLB IRQ number is found in bits 2 to 4 of the CfgLsw. It decodes as:
14062 * 000: invalid
14063 * 001: 10
14064 * 010: 11
14065 * 011: 12
14066 * 100: invalid
14067 * 101: 14
14068 * 110: 15
14069 * 111: invalid
14070 */
14071static unsigned int __devinit advansys_vlb_irq_no(PortAddr iop_base)
14072{
14073 unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
14074 unsigned int chip_irq = ((cfg_lsw >> 2) & 0x07) + 9;
14075 if ((chip_irq < 10) || (chip_irq == 13) || (chip_irq > 15))
14076 return 0;
14077 return chip_irq;
14078}
14079
c304ec94
MW
14080static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
14081{
d361db48 14082 int err = -ENODEV;
c304ec94
MW
14083 PortAddr iop_base = _asc_def_iop_base[id];
14084 struct Scsi_Host *shost;
d361db48 14085 struct asc_board *board;
c304ec94 14086
01fbfe0b 14087 if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
b352f923 14088 ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
c304ec94
MW
14089 return -ENODEV;
14090 }
b352f923 14091 ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
c304ec94 14092 if (!AscFindSignature(iop_base))
d361db48 14093 goto release_region;
c304ec94
MW
14094 /*
14095 * I don't think this condition can actually happen, but the old
14096 * driver did it, and the chances of finding a VLB setup in 2007
14097 * to do testing with is slight to none.
14098 */
14099 if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
d361db48 14100 goto release_region;
c304ec94 14101
d361db48
MW
14102 err = -ENOMEM;
14103 shost = scsi_host_alloc(&advansys_template, sizeof(*board));
c304ec94 14104 if (!shost)
d361db48
MW
14105 goto release_region;
14106
d2411495 14107 board = shost_priv(shost);
d361db48
MW
14108 board->irq = advansys_vlb_irq_no(iop_base);
14109 board->dev = dev;
14110
14111 err = advansys_board_found(shost, iop_base, ASC_IS_VL);
14112 if (err)
14113 goto free_host;
c304ec94
MW
14114
14115 dev_set_drvdata(dev, shost);
14116 return 0;
14117
d361db48
MW
14118 free_host:
14119 scsi_host_put(shost);
14120 release_region:
71f36115 14121 release_region(iop_base, ASC_IOADR_GAP);
c304ec94
MW
14122 return -ENODEV;
14123}
14124
14125static struct isa_driver advansys_vlb_driver = {
14126 .probe = advansys_vlb_probe,
14127 .remove = __devexit_p(advansys_isa_remove),
14128 .driver = {
14129 .owner = THIS_MODULE,
b8e5152b 14130 .name = "advansys_vlb",
c304ec94
MW
14131 },
14132};
14133
b09e05a7
MW
14134static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
14135 { "ABP7401" },
14136 { "ABP7501" },
14137 { "" }
14138};
14139
14140MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
14141
14142/*
14143 * EISA is a little more tricky than PCI; each EISA device may have two
14144 * channels, and this driver is written to make each channel its own Scsi_Host
14145 */
14146struct eisa_scsi_data {
14147 struct Scsi_Host *host[2];
14148};
14149
d361db48
MW
14150/*
14151 * The EISA IRQ number is found in bits 8 to 10 of the CfgLsw. It decodes as:
14152 * 000: 10
14153 * 001: 11
14154 * 010: 12
14155 * 011: invalid
14156 * 100: 14
14157 * 101: 15
14158 * 110: invalid
14159 * 111: invalid
14160 */
14161static unsigned int __devinit advansys_eisa_irq_no(struct eisa_device *edev)
14162{
14163 unsigned short cfg_lsw = inw(edev->base_addr + 0xc86);
14164 unsigned int chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
14165 if ((chip_irq == 13) || (chip_irq > 15))
14166 return 0;
14167 return chip_irq;
14168}
14169
b09e05a7
MW
14170static int __devinit advansys_eisa_probe(struct device *dev)
14171{
d361db48 14172 int i, ioport, irq = 0;
b09e05a7
MW
14173 int err;
14174 struct eisa_device *edev = to_eisa_device(dev);
14175 struct eisa_scsi_data *data;
14176
14177 err = -ENOMEM;
14178 data = kzalloc(sizeof(*data), GFP_KERNEL);
14179 if (!data)
14180 goto fail;
14181 ioport = edev->base_addr + 0xc30;
14182
14183 err = -ENODEV;
14184 for (i = 0; i < 2; i++, ioport += 0x20) {
d361db48
MW
14185 struct asc_board *board;
14186 struct Scsi_Host *shost;
01fbfe0b 14187 if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
71f36115
MW
14188 printk(KERN_WARNING "Region %x-%x busy\n", ioport,
14189 ioport + ASC_IOADR_GAP - 1);
14190 continue;
14191 }
14192 if (!AscFindSignature(ioport)) {
14193 release_region(ioport, ASC_IOADR_GAP);
b09e05a7 14194 continue;
71f36115
MW
14195 }
14196
b09e05a7
MW
14197 /*
14198 * I don't know why we need to do this for EISA chips, but
14199 * not for any others. It looks to be equivalent to
14200 * AscGetChipCfgMsw, but I may have overlooked something,
14201 * so I'm not converting it until I get an EISA board to
14202 * test with.
14203 */
14204 inw(ioport + 4);
d361db48
MW
14205
14206 if (!irq)
14207 irq = advansys_eisa_irq_no(edev);
14208
14209 err = -ENOMEM;
14210 shost = scsi_host_alloc(&advansys_template, sizeof(*board));
14211 if (!shost)
14212 goto release_region;
14213
d2411495 14214 board = shost_priv(shost);
d361db48
MW
14215 board->irq = irq;
14216 board->dev = dev;
14217
14218 err = advansys_board_found(shost, ioport, ASC_IS_EISA);
14219 if (!err) {
14220 data->host[i] = shost;
14221 continue;
71f36115 14222 }
b09e05a7 14223
d361db48
MW
14224 scsi_host_put(shost);
14225 release_region:
14226 release_region(ioport, ASC_IOADR_GAP);
14227 break;
b09e05a7
MW
14228 }
14229
d361db48
MW
14230 if (err)
14231 goto free_data;
14232 dev_set_drvdata(dev, data);
14233 return 0;
14234
14235 free_data:
14236 kfree(data->host[0]);
14237 kfree(data->host[1]);
14238 kfree(data);
b09e05a7
MW
14239 fail:
14240 return err;
14241}
14242
14243static __devexit int advansys_eisa_remove(struct device *dev)
14244{
14245 int i;
14246 struct eisa_scsi_data *data = dev_get_drvdata(dev);
14247
14248 for (i = 0; i < 2; i++) {
71f36115 14249 int ioport;
b09e05a7
MW
14250 struct Scsi_Host *shost = data->host[i];
14251 if (!shost)
14252 continue;
71f36115 14253 ioport = shost->io_port;
b09e05a7 14254 advansys_release(shost);
71f36115 14255 release_region(ioport, ASC_IOADR_GAP);
b09e05a7
MW
14256 }
14257
14258 kfree(data);
14259 return 0;
14260}
14261
14262static struct eisa_driver advansys_eisa_driver = {
14263 .id_table = advansys_eisa_table,
14264 .driver = {
01fbfe0b 14265 .name = DRV_NAME,
b09e05a7
MW
14266 .probe = advansys_eisa_probe,
14267 .remove = __devexit_p(advansys_eisa_remove),
14268 }
14269};
14270
2672ea86
DJ
14271/* PCI Devices supported by this driver */
14272static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
27c868c2
MW
14273 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
14274 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14275 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
14276 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14277 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
14278 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14279 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
14280 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14281 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
14282 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14283 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
14284 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14285 {}
2672ea86 14286};
27c868c2 14287
2672ea86 14288MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
78e77d8b 14289
9649af39
MW
14290static void __devinit advansys_set_latency(struct pci_dev *pdev)
14291{
14292 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
14293 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
14294 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
14295 } else {
14296 u8 latency;
14297 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
14298 if (latency < 0x20)
14299 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
14300 }
14301}
14302
78e77d8b
MW
14303static int __devinit
14304advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
14305{
14306 int err, ioport;
14307 struct Scsi_Host *shost;
d361db48 14308 struct asc_board *board;
78e77d8b
MW
14309
14310 err = pci_enable_device(pdev);
14311 if (err)
14312 goto fail;
01fbfe0b 14313 err = pci_request_regions(pdev, DRV_NAME);
71f36115
MW
14314 if (err)
14315 goto disable_device;
9649af39
MW
14316 pci_set_master(pdev);
14317 advansys_set_latency(pdev);
78e77d8b 14318
d361db48 14319 err = -ENODEV;
78e77d8b 14320 if (pci_resource_len(pdev, 0) == 0)
d361db48 14321 goto release_region;
78e77d8b
MW
14322
14323 ioport = pci_resource_start(pdev, 0);
78e77d8b 14324
d361db48
MW
14325 err = -ENOMEM;
14326 shost = scsi_host_alloc(&advansys_template, sizeof(*board));
78e77d8b 14327 if (!shost)
d361db48
MW
14328 goto release_region;
14329
d2411495 14330 board = shost_priv(shost);
d361db48
MW
14331 board->irq = pdev->irq;
14332 board->dev = &pdev->dev;
14333
14334 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
14335 pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
14336 pdev->device == PCI_DEVICE_ID_38C1600_REV1) {
14337 board->flags |= ASC_IS_WIDE_BOARD;
14338 }
14339
14340 err = advansys_board_found(shost, ioport, ASC_IS_PCI);
14341 if (err)
14342 goto free_host;
78e77d8b
MW
14343
14344 pci_set_drvdata(pdev, shost);
14345 return 0;
14346
d361db48
MW
14347 free_host:
14348 scsi_host_put(shost);
14349 release_region:
71f36115
MW
14350 pci_release_regions(pdev);
14351 disable_device:
78e77d8b
MW
14352 pci_disable_device(pdev);
14353 fail:
14354 return err;
14355}
14356
14357static void __devexit advansys_pci_remove(struct pci_dev *pdev)
14358{
14359 advansys_release(pci_get_drvdata(pdev));
71f36115 14360 pci_release_regions(pdev);
78e77d8b
MW
14361 pci_disable_device(pdev);
14362}
14363
14364static struct pci_driver advansys_pci_driver = {
01fbfe0b 14365 .name = DRV_NAME,
78e77d8b
MW
14366 .id_table = advansys_pci_tbl,
14367 .probe = advansys_pci_probe,
14368 .remove = __devexit_p(advansys_pci_remove),
14369};
8c6af9e1 14370
8dfb5379
MW
14371static int __init advansys_init(void)
14372{
c304ec94 14373 int error;
b09e05a7 14374
c304ec94
MW
14375 error = isa_register_driver(&advansys_isa_driver,
14376 ASC_IOADR_TABLE_MAX_IX);
78e77d8b
MW
14377 if (error)
14378 goto fail;
8dfb5379 14379
c304ec94
MW
14380 error = isa_register_driver(&advansys_vlb_driver,
14381 ASC_IOADR_TABLE_MAX_IX);
14382 if (error)
14383 goto unregister_isa;
14384
14385 error = eisa_driver_register(&advansys_eisa_driver);
14386 if (error)
14387 goto unregister_vlb;
14388
b09e05a7
MW
14389 error = pci_register_driver(&advansys_pci_driver);
14390 if (error)
14391 goto unregister_eisa;
14392
8dfb5379 14393 return 0;
78e77d8b 14394
b09e05a7
MW
14395 unregister_eisa:
14396 eisa_driver_unregister(&advansys_eisa_driver);
c304ec94
MW
14397 unregister_vlb:
14398 isa_unregister_driver(&advansys_vlb_driver);
14399 unregister_isa:
14400 isa_unregister_driver(&advansys_isa_driver);
78e77d8b 14401 fail:
78e77d8b 14402 return error;
8dfb5379
MW
14403}
14404
14405static void __exit advansys_exit(void)
14406{
78e77d8b 14407 pci_unregister_driver(&advansys_pci_driver);
b09e05a7 14408 eisa_driver_unregister(&advansys_eisa_driver);
c304ec94
MW
14409 isa_unregister_driver(&advansys_vlb_driver);
14410 isa_unregister_driver(&advansys_isa_driver);
8dfb5379
MW
14411}
14412
14413module_init(advansys_init);
14414module_exit(advansys_exit);
14415
8c6af9e1 14416MODULE_LICENSE("GPL");