1 #define ASC_VERSION "3.4" /* AdvanSys Driver Version */
4 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
6 * Copyright (c) 1995-2000 Advanced System Products, Inc.
7 * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
8 * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
18 * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
19 * changed its name to ConnectCom Solutions, Inc.
20 * On June 18, 2001 Initio Corp. acquired ConnectCom's SCSI assets
25 Documentation for the AdvanSys Driver
27 A. Linux Kernels Supported by this Driver
28 B. Adapters Supported by this Driver
29 C. Linux source files modified by AdvanSys Driver
31 E. Driver Compile Time Options and Debugging
33 G. Tests to run before releasing new driver
35 I. Known Problems/Fix List
36 J. Credits (Chronological Order)
38 A. Linux Kernels Supported by this Driver
40 This driver has been tested in the following Linux kernels: v2.2.18
41 v2.4.0. The driver is supported on v2.2 and v2.4 kernels and on x86,
42 alpha, and PowerPC platforms.
44 B. Adapters Supported by this Driver
46 AdvanSys (Advanced System Products, Inc.) manufactures the following
47 RISC-based, Bus-Mastering, Fast (10 Mhz) and Ultra (20 Mhz) Narrow
48 (8-bit transfer) SCSI Host Adapters for the ISA, EISA, VL, and PCI
49 buses and RISC-based, Bus-Mastering, Ultra (20 Mhz) Wide (16-bit
50 transfer) SCSI Host Adapters for the PCI bus.
52 The CDB counts below indicate the number of SCSI CDB (Command
53 Descriptor Block) requests that can be stored in the RISC chip
54 cache and board LRAM. A CDB is a single SCSI command. The driver
55 detect routine will display the number of CDBs available for each
56 adapter detected. The number of CDBs used by the driver can be
57 lowered in the BIOS by changing the 'Host Queue Size' adapter setting.
60 ABP-480 - Bus-Master CardBus (16 CDB) (2.4 kernel and greater)
62 Connectivity Products:
63 ABP510/5150 - Bus-Master ISA (240 CDB)
64 ABP5140 - Bus-Master ISA PnP (16 CDB)
65 ABP5142 - Bus-Master ISA PnP with floppy (16 CDB)
66 ABP902/3902 - Bus-Master PCI (16 CDB)
67 ABP3905 - Bus-Master PCI (16 CDB)
68 ABP915 - Bus-Master PCI (16 CDB)
69 ABP920 - Bus-Master PCI (16 CDB)
70 ABP3922 - Bus-Master PCI (16 CDB)
71 ABP3925 - Bus-Master PCI (16 CDB)
72 ABP930 - Bus-Master PCI (16 CDB)
73 ABP930U - Bus-Master PCI Ultra (16 CDB)
74 ABP930UA - Bus-Master PCI Ultra (16 CDB)
75 ABP960 - Bus-Master PCI MAC/PC (16 CDB)
76 ABP960U - Bus-Master PCI MAC/PC Ultra (16 CDB)
78 Single Channel Products:
79 ABP542 - Bus-Master ISA with floppy (240 CDB)
80 ABP742 - Bus-Master EISA (240 CDB)
81 ABP842 - Bus-Master VL (240 CDB)
82 ABP940 - Bus-Master PCI (240 CDB)
83 ABP940U - Bus-Master PCI Ultra (240 CDB)
84 ABP940UA/3940UA - Bus-Master PCI Ultra (240 CDB)
85 ABP970 - Bus-Master PCI MAC/PC (240 CDB)
86 ABP970U - Bus-Master PCI MAC/PC Ultra (240 CDB)
87 ABP3960UA - Bus-Master PCI MAC/PC Ultra (240 CDB)
88 ABP940UW/3940UW - Bus-Master PCI Ultra-Wide (253 CDB)
89 ABP970UW - Bus-Master PCI MAC/PC Ultra-Wide (253 CDB)
90 ABP3940U2W - Bus-Master PCI LVD/Ultra2-Wide (253 CDB)
92 Multi-Channel Products:
93 ABP752 - Dual Channel Bus-Master EISA (240 CDB Per Channel)
94 ABP852 - Dual Channel Bus-Master VL (240 CDB Per Channel)
95 ABP950 - Dual Channel Bus-Master PCI (240 CDB Per Channel)
96 ABP950UW - Dual Channel Bus-Master PCI Ultra-Wide (253 CDB Per Channel)
97 ABP980 - Four Channel Bus-Master PCI (240 CDB Per Channel)
98 ABP980U - Four Channel Bus-Master PCI Ultra (240 CDB Per Channel)
99 ABP980UA/3980UA - Four Channel Bus-Master PCI Ultra (16 CDB Per Chan.)
100 ABP3950U2W - Bus-Master PCI LVD/Ultra2-Wide and Ultra-Wide (253 CDB)
101 ABP3950U3W - Bus-Master PCI Dual LVD2/Ultra3-Wide (253 CDB)
103 C. Linux source files modified by AdvanSys Driver
105 This section for historical purposes documents the changes
106 originally made to the Linux kernel source to add the advansys
107 driver. As Linux has changed some of these files have also
110 1. linux/arch/i386/config.in:
112 bool 'AdvanSys SCSI support' CONFIG_SCSI_ADVANSYS y
114 2. linux/drivers/scsi/hosts.c:
116 #ifdef CONFIG_SCSI_ADVANSYS
117 #include "advansys.h"
120 and after "static struct scsi_host_template builtin_scsi_hosts[] =":
122 #ifdef CONFIG_SCSI_ADVANSYS
126 3. linux/drivers/scsi/Makefile:
128 ifdef CONFIG_SCSI_ADVANSYS
129 SCSI_SRCS := $(SCSI_SRCS) advansys.c
130 SCSI_OBJS := $(SCSI_OBJS) advansys.o
132 SCSI_MODULE_OBJS := $(SCSI_MODULE_OBJS) advansys.o
135 4. linux/init/main.c:
137 extern void advansys_setup(char *str, int *ints);
139 and add the following lines to the bootsetups[] array.
141 #ifdef CONFIG_SCSI_ADVANSYS
142 { "advansys=", advansys_setup },
147 1. Use tab stops set to 4 for the source files. For vi use 'se tabstops=4'.
149 2. This driver should be maintained in multiple files. But to make
150 it easier to include with Linux and to follow Linux conventions,
151 the whole driver is maintained in the source files advansys.h and
152 advansys.c. In this file logical sections of the driver begin with
153 a comment that contains '---'. The following are the logical sections
157 --- Linux Include File
160 --- Asc Library Constants and Macros
161 --- Adv Library Constants and Macros
162 --- Driver Constants and Macros
163 --- Driver Structures
165 --- Driver Function Prototypes
166 --- Linux 'struct scsi_host_template' and advansys_setup() Functions
167 --- Loadable Driver Support
168 --- Miscellaneous Driver Functions
169 --- Functions Required by the Asc Library
170 --- Functions Required by the Adv Library
171 --- Tracing and Debugging Functions
172 --- Asc Library Functions
173 --- Adv Library Functions
175 3. The string 'XXX' is used to flag code that needs to be re-written
176 or that contains a problem that needs to be addressed.
178 4. I have stripped comments from and reformatted the source for the
179 Asc Library and Adv Library to reduce the size of this file. This
180 source can be found under the following headings. The Asc Library
181 is used to support Narrow Boards. The Adv Library is used to
184 --- Asc Library Constants and Macros
185 --- Adv Library Constants and Macros
186 --- Asc Library Functions
187 --- Adv Library Functions
189 E. Driver Compile Time Options and Debugging
191 In this source file the following constants can be defined. They are
192 defined in the source below. Both of these options are enabled by
195 1. ADVANSYS_ASSERT - Enable driver assertions (Def: Enabled)
197 Enabling this option adds assertion logic statements to the
198 driver. If an assertion fails a message will be displayed to
199 the console, but the system will continue to operate. Any
200 assertions encountered should be reported to the person
201 responsible for the driver. Assertion statements may proactively
202 detect problems with the driver and facilitate fixing these
203 problems. Enabling assertions will add a small overhead to the
204 execution of the driver.
206 2. ADVANSYS_DEBUG - Enable driver debugging (Def: Disabled)
208 Enabling this option adds tracing functions to the driver and
209 the ability to set a driver tracing level at boot time. This
210 option will also export symbols not required outside the driver to
211 the kernel name space. This option is very useful for debugging
212 the driver, but it will add to the size of the driver execution
213 image and add overhead to the execution of the driver.
215 The amount of debugging output can be controlled with the global
216 variable 'asc_dbglvl'. The higher the number the more output. By
217 default the debug level is 0.
219 If the driver is loaded at boot time and the LILO Driver Option
220 is included in the system, the debug level can be changed by
221 specifying a 5th (ASC_NUM_IOPORT_PROBE + 1) I/O Port. The
222 first three hex digits of the pseudo I/O Port must be set to
223 'deb' and the fourth hex digit specifies the debug level: 0 - F.
224 The following command line will look for an adapter at 0x330
225 and set the debug level to 2.
227 linux advansys=0x330,0,0,0,0xdeb2
229 If the driver is built as a loadable module this variable can be
230 defined when the driver is loaded. The following insmod command
231 will set the debug level to one.
233 insmod advansys.o asc_dbglvl=1
235 Debugging Message Levels:
237 1: High-Level Tracing
240 To enable debug output to console, please make sure that:
242 a. System and kernel logging is enabled (syslogd, klogd running).
243 b. Kernel messages are routed to console output. Check
244 /etc/syslog.conf for an entry similar to this:
248 c. klogd is started with the appropriate -c parameter
251 This will cause printk() messages to be be displayed on the
252 current console. Refer to the klogd(8) and syslogd(8) man pages
255 Alternatively you can enable printk() to console with this
256 program. However, this is not the 'official' way to do this.
257 Debug output is logged in /var/log/messages.
261 syscall(103, 7, 0, 0);
264 Increasing LOG_BUF_LEN in kernel/printk.c to something like
265 40960 allows more debug messages to be buffered in the kernel
266 and written to the console or log file.
268 3. ADVANSYS_STATS - Enable statistics (Def: Enabled >= v1.3.0)
270 Enabling this option adds statistics collection and display
271 through /proc to the driver. The information is useful for
272 monitoring driver and device performance. It will add to the
273 size of the driver execution image and add minor overhead to
274 the execution of the driver.
276 Statistics are maintained on a per adapter basis. Driver entry
277 point call counts and transfer size counts are maintained.
278 Statistics are only available for kernels greater than or equal
279 to v1.3.0 with the CONFIG_PROC_FS (/proc) file system configured.
281 AdvanSys SCSI adapter files have the following path name format:
283 /proc/scsi/advansys/{0,1,2,3,...}
285 This information can be displayed with cat. For example:
287 cat /proc/scsi/advansys/0
289 When ADVANSYS_STATS is not defined the AdvanSys /proc files only
290 contain adapter and device configuration information.
292 F. Driver LILO Option
294 If init/main.c is modified as described in the 'Directions for Adding
295 the AdvanSys Driver to Linux' section (B.4.) above, the driver will
296 recognize the 'advansys' LILO command line and /etc/lilo.conf option.
297 This option can be used to either disable I/O port scanning or to limit
298 scanning to 1 - 4 I/O ports. Regardless of the option setting EISA and
299 PCI boards will still be searched for and detected. This option only
300 affects searching for ISA and VL boards.
303 1. Eliminate I/O port scanning:
304 boot: linux advansys=
306 boot: linux advansys=0x0
307 2. Limit I/O port scanning to one I/O port:
308 boot: linux advansys=0x110
309 3. Limit I/O port scanning to four I/O ports:
310 boot: linux advansys=0x110,0x210,0x230,0x330
312 For a loadable module the same effect can be achieved by setting
313 the 'asc_iopflag' variable and 'asc_ioport' array when loading
316 insmod advansys.o asc_iopflag=1 asc_ioport=0x110,0x330
318 If ADVANSYS_DEBUG is defined a 5th (ASC_NUM_IOPORT_PROBE + 1)
319 I/O Port may be added to specify the driver debug level. Refer to
320 the 'Driver Compile Time Options and Debugging' section above for
323 G. Tests to run before releasing new driver
325 1. In the supported kernels verify there are no warning or compile
326 errors when the kernel is built as both a driver and as a module
327 and with the following options:
329 ADVANSYS_DEBUG - enabled and disabled
330 CONFIG_SMP - enabled and disabled
331 CONFIG_PROC_FS - enabled and disabled
333 2. Run tests on an x86, alpha, and PowerPC with at least one narrow
334 card and one wide card attached to a hard disk and CD-ROM drive:
335 fdisk, mkfs, fsck, bonnie, copy/compare test from the
336 CD-ROM to the hard drive.
344 1. Prevent advansys_detect() from being called twice.
345 2. Add LILO 0xdeb[0-f] option to set 'asc_dbglvl'.
348 1. Prevent re-entrancy in the interrupt handler which
349 resulted in the driver hanging Linux.
350 2. Fix problem that prevented ABP-940 cards from being
351 recognized on some PCI motherboards.
352 3. Add support for the ABP-5140 PnP ISA card.
353 4. Fix check condition return status.
354 5. Add conditionally compiled code for Linux v1.3.X.
357 1. Fix problem in advansys_biosparam() that resulted in the
358 wrong drive geometry being returned for drives > 1GB with
359 extended translation enabled.
360 2. Add additional tracing during device initialization.
361 3. Change code that only applies to ISA PnP adapter.
362 4. Eliminate 'make dep' warning.
363 5. Try to fix problem with handling resets by increasing their
367 1. Change definitions to eliminate conflicts with other subsystems.
368 2. Add versioning code for the shared interrupt changes.
369 3. Eliminate problem in asc_rmqueue() with iterating after removing
371 4. Remove reset request loop problem from the "Known Problems or
372 Issues" section. This problem was isolated and fixed in the
373 mid-level SCSI driver.
376 1. Add support for ABP-940U (PCI Ultra) adapter.
377 2. Add support for IRQ sharing by setting the IRQF_SHARED flag for
378 request_irq and supplying a dev_id pointer to both request_irq()
380 3. In AscSearchIOPortAddr11() restore a call to check_region() which
381 should be used before I/O port probing.
382 4. Fix bug in asc_prt_hex() which resulted in the displaying
384 5. Incorporate miscellaneous Asc Library bug fixes and new microcode.
385 6. Change driver versioning to be specific to each Linux sub-level.
386 7. Change statistics gathering to be per adapter instead of global
388 8. Add more information and statistics to the adapter /proc file:
389 /proc/scsi/advansys[0...].
390 9. Remove 'cmd_per_lun' from the "Known Problems or Issues" list.
391 This problem has been addressed with the SCSI mid-level changes
392 made in v1.3.89. The advansys_select_queue_depths() function
393 was added for the v1.3.89 changes.
396 1. Incorporate miscellaneous Asc Library bug fixes and new microcode.
399 1. Enable clustering and optimize the setting of the maximum number
400 of scatter gather elements for any particular board. Clustering
401 increases CPU utilization, but results in a relatively larger
402 increase in I/O throughput.
403 2. Improve the performance of the request queuing functions by
404 adding a last pointer to the queue structure.
405 3. Correct problems with reset and abort request handling that
406 could have hung or crashed Linux.
407 4. Add more information to the adapter /proc file:
408 /proc/scsi/advansys[0...].
409 5. Remove the request timeout issue form the driver issues list.
410 6. Miscellaneous documentation additions and changes.
413 1. Make changes to handle the new v2.1.0 kernel memory mapping
414 in which a kernel virtual address may not be equivalent to its
415 bus or DMA memory address.
416 2. Change abort and reset request handling to make it yet even
418 3. Try to mitigate request starvation by sending ordered requests
419 to heavily loaded, tag queuing enabled devices.
420 4. Maintain statistics on request response time.
421 5. Add request response time statistics and other information to
422 the adapter /proc file: /proc/scsi/advansys[0...].
425 1. Add conditionally compiled code (ASC_QUEUE_FLOW_CONTROL) to
426 make use of mid-level SCSI driver device queue depth flow
427 control mechanism. This will eliminate aborts caused by a
428 device being unable to keep up with requests and eliminate
429 repeat busy or QUEUE FULL status returned by a device.
430 2. Incorporate miscellaneous Asc Library bug fixes.
431 3. To allow the driver to work in kernels with broken module
432 support set 'cmd_per_lun' if the driver is compiled as a
433 module. This change affects kernels v1.3.89 to present.
434 4. Remove PCI BIOS address from the driver banner. The PCI BIOS
435 is relocated by the motherboard BIOS and its new address can
436 not be determined by the driver.
437 5. Add mid-level SCSI queue depth information to the adapter
438 /proc file: /proc/scsi/advansys[0...].
441 1. Change allocation of global structures used for device
442 initialization to guarantee they are in DMA-able memory.
443 Previously when the driver was loaded as a module these
444 structures might not have been in DMA-able memory, causing
445 device initialization to fail.
448 1. In advansys_reset(), if the request is a synchronous reset
449 request, even if the request serial number has changed, then
450 complete the request.
451 2. Add Asc Library bug fixes including new microcode.
452 3. Clear inquiry buffer before using it.
453 4. Correct ifdef typo.
456 1. Add Asc Library bug fixes including new microcode.
457 2. Add synchronous data transfer rate information to the
458 adapter /proc file: /proc/scsi/advansys[0...].
459 3. Change ADVANSYS_DEBUG to be disabled by default. This
460 will reduce the size of the driver image, eliminate execution
461 overhead, and remove unneeded symbols from the kernel symbol
462 space that were previously added by the driver.
463 4. Add new compile-time option ADVANSYS_ASSERT for assertion
464 code that used to be defined within ADVANSYS_DEBUG. This
465 option is enabled by default.
468 1. Change version number to 2.8 to synchronize the Linux driver
469 version numbering with other AdvanSys drivers.
470 2. Reformat source files without tabs to present the same view
471 of the file to everyone regardless of the editor tab setting
473 3. Add Asc Library bug fixes.
476 1. Change version number to 3.1 to indicate that support for
477 Ultra-Wide adapters (ABP-940UW) is included in this release.
478 2. Add Asc Library (Narrow Board) bug fixes.
479 3. Report an underrun condition with the host status byte set
480 to DID_UNDERRUN. Currently DID_UNDERRUN is defined to 0 which
481 causes the underrun condition to be ignored. When Linux defines
482 its own DID_UNDERRUN the constant defined in this file can be
484 4. Add patch to AscWaitTixISRDone().
485 5. Add support for up to 16 different AdvanSys host adapter SCSI
486 channels in one system. This allows four cards with four channels
487 to be used in one system.
490 1. Handle that PCI register base addresses are not always page
491 aligned even though ioremap() requires that the address argument
495 1. Update latest BIOS version checked for from the /proc file.
496 2. Don't set microcode SDTR variable at initialization. Instead
497 wait until device capabilities have been detected from an Inquiry
501 1. Improve performance when the driver is compiled as module by
502 allowing up to 64 scatter-gather elements instead of 8.
505 1. Set time delay in AscWaitTixISRDone() to 1000 ms.
506 2. Include SMP locking changes.
507 3. For v2.1.93 and newer kernels use CONFIG_PCI and new PCI BIOS
509 4. Update board serial number printing.
510 5. Try allocating an IRQ both with and without the IRQF_DISABLED
511 flag set to allow IRQ sharing with drivers that do not set
512 the IRQF_DISABLED flag. Also display a more descriptive error
513 message if request_irq() fails.
514 6. Update to latest Asc and Adv Libraries.
517 1. Update Adv Library to 4.16 which includes support for
518 the ASC38C0800 (Ultra2/LVD) IC.
521 1. Correct PCI compile time option for v2.1.93 and greater
522 kernels, advansys_info() string, and debug compile time
524 2. Correct DvcSleepMilliSecond() for v2.1.0 and greater
525 kernels. This caused an LVD detection/BIST problem problem
527 3. Sort PCI cards by PCI Bus, Slot, Function ascending order
528 to be consistent with the BIOS.
529 4. Update to Asc Library S121 and Adv Library 5.2.
532 1. Correct PCI card detection bug introduced in 3.2B that
533 prevented PCI cards from being detected in kernels older
537 1. Correct /proc device synchronous speed information display.
538 Also when re-negotiation is pending for a target device
539 note this condition with an * and footnote.
540 2. Correct initialization problem with Ultra-Wide cards that
541 have a pre-3.2 BIOS. A microcode variable changed locations
542 in 3.2 and greater BIOSes which caused WDTR to be attempted
543 erroneously with drives that don't support WDTR.
546 1. Fix compile error caused by v2.3.13 PCI structure change.
547 2. Remove field from ASCEEP_CONFIG that resulted in an EEPROM
548 checksum error for ISA cards.
549 3. Remove ASC_QUEUE_FLOW_CONTROL conditional code. The mid-level
550 SCSI changes that it depended on were never included in Linux.
553 1. Handle new initial function code added in v2.3.16 for all
557 1. Fix PCI board detection in v2.3.13 and greater kernels.
558 2. Fix comiple errors in v2.3.X with debugging enabled.
561 1. Add 64-bit address, long support for Alpha and UltraSPARC.
562 The driver has been verified to work on an Alpha system.
563 2. Add partial byte order handling support for Power PC and
564 other big-endian platforms. This support has not yet been
565 completed or verified.
566 3. For wide boards replace block zeroing of request and
567 scatter-gather structures with individual field initialization
568 to improve performance.
569 4. Correct and clarify ROM BIOS version detection.
572 1. Update to Adv Library 5.4.
573 2. Add v2.3.19 underrun reporting to asc_isr_callback() and
574 adv_isr_callback(). Remove DID_UNDERRUN constant and other
575 no longer needed code that previously documented the lack
576 of underrun handling.
579 1. Eliminate compile errors for v2.0 and earlier kernels.
582 1. Correct debug compile error in asc_prt_adv_scsi_req_q().
583 2. Update Adv Library to 5.5.
584 3. Add ifdef handling for /proc changes added in v2.3.28.
585 4. Increase Wide board scatter-gather list maximum length to
586 255 when the driver is compiled into the kernel.
589 1. Fix bug in adv_get_sglist() that caused an assertion failure
590 at line 7475. The reqp->sgblkp pointer must be initialized
591 to NULL in adv_get_sglist().
594 1. Really fix bug in adv_get_sglist().
595 2. Incorporate v2.3.29 changes into driver.
598 1. Add CONFIG_ISA ifdef code.
599 2. Include advansys_interrupts_enabled name change patch.
600 3. For >= v2.3.28 use new SCSI error handling with new function
601 advansys_eh_bus_reset(). Don't include an abort function
602 because of base library limitations.
603 4. For >= v2.3.28 use per board lock instead of io_request_lock.
604 5. For >= v2.3.28 eliminate advansys_command() and
605 advansys_command_done().
606 6. Add some changes for PowerPC (Big Endian) support, but it isn't
608 7. Fix "nonexistent resource free" problem that occurred on a module
609 unload for boards with an I/O space >= 255. The 'n_io_port' field
610 is only one byte and can not be used to hold an ioport length more
614 1. Update to Adv Library 5.8.
615 2. For wide cards add support for CDBs up to 16 bytes.
616 3. Eliminate warnings when CONFIG_PROC_FS is not defined.
619 1. Support for PowerPC (Big Endian) wide cards. Narrow cards
621 2. Change bitfields to shift and mask access for endian
625 1. Update for latest 2.4 kernel.
626 2. Test ABP-480 CardBus support in 2.4 kernel - works!
627 3. Update to Asc Library S123.
628 4. Update to Adv Library 5.12.
631 1. Update for latest 2.4 kernel.
632 2. Create patches for 2.2 and 2.4 kernels.
635 1. Now that 2.4 is released remove ifdef code for kernel versions
636 less than 2.2. The driver is now only supported in kernels 2.2,
638 2. Add code to release and acquire the io_request_lock in
639 the driver entrypoint functions: advansys_detect and
640 advansys_queuecommand. In kernel 2.4 the SCSI mid-level driver
641 still holds the io_request_lock on entry to SCSI low-level drivers.
642 This was supposed to be removed before 2.4 was released but never
643 happened. When the mid-level SCSI driver is changed all references
644 to the io_request_lock should be removed from the driver.
645 3. Simplify error handling by removing advansys_abort(),
646 AscAbortSRB(), AscResetDevice(). SCSI bus reset requests are
647 now handled by resetting the SCSI bus and fully re-initializing
648 the chip. This simple method of error recovery has proven to work
649 most reliably after attempts at different methods. Also now only
650 support the "new" error handling method and remove the obsolete
651 error handling interface.
652 4. Fix debug build errors.
655 1. Merge with ConnectCom version from Andy Kellner which
656 updates Adv Library to 5.14.
657 2. Make PowerPC (Big Endian) work for narrow cards and
658 fix problems writing EEPROM for wide cards.
659 3. Remove interrupts_enabled assertion function.
662 1. Return an error from narrow boards if passed a 16 byte
663 CDB. The wide board can already handle 16 byte CDBs.
666 1. hacks for lk 2.5 series (D. Gilbert)
669 1. change select_queue_depths to slave_configure
670 2. make cmd_per_lun be sane again
673 1. continuing cleanup for lk 2.6 series
674 2. Fix problem in lk 2.6.7-bk2 that broke PCI wide cards
675 3. Fix problem that oopsed ISA cards
677 I. Known Problems/Fix List (XXX)
679 1. Need to add memory mapping workaround. Test the memory mapping.
680 If it doesn't work revert to I/O port access. Can a test be done
682 2. Handle an interrupt not working. Keep an interrupt counter in
683 the interrupt handler. In the timeout function if the interrupt
684 has not occurred then print a message and run in polled mode.
685 3. Allow bus type scanning order to be changed.
686 4. Need to add support for target mode commands, cf. CAM XPT.
688 J. Credits (Chronological Order)
690 Bob Frey <bfrey@turbolinux.com.cn> wrote the AdvanSys SCSI driver
691 and maintained it up to 3.3F. He continues to answer questions
692 and help maintain the driver.
694 Nathan Hartwell <mage@cdc3.cdc.net> provided the directions and
695 basis for the Linux v1.3.X changes which were included in the
698 Thomas E Zerucha <zerucha@shell.portal.com> pointed out a bug
699 in advansys_biosparam() which was fixed in the 1.3 release.
701 Erik Ratcliffe <erik@caldera.com> has done testing of the
702 AdvanSys driver in the Caldera releases.
704 Rik van Riel <H.H.vanRiel@fys.ruu.nl> provided a patch to
705 AscWaitTixISRDone() which he found necessary to make the
706 driver work with a SCSI-1 disk.
708 Mark Moran <mmoran@mmoran.com> has helped test Ultra-Wide
709 support in the 3.1A driver.
711 Doug Gilbert <dgilbert@interlog.com> has made changes and
712 suggestions to improve the driver and done a lot of testing.
714 Ken Mort <ken@mort.net> reported a DEBUG compile bug fixed
717 Tom Rini <trini@kernel.crashing.org> provided the CONFIG_ISA
718 patch and helped with PowerPC wide and narrow board support.
720 Philip Blundell <philb@gnu.org> provided an
721 advansys_interrupts_enabled patch.
723 Dave Jones <dave@denial.force9.co.uk> reported the compiler
724 warnings generated when CONFIG_PROC_FS was not defined in
727 Jerry Quinn <jlquinn@us.ibm.com> fixed PowerPC support (endian
728 problems) for wide cards.
730 Bryan Henderson <bryanh@giraffe-data.com> helped debug narrow
733 Manuel Veloso <veloso@pobox.com> worked hard on PowerPC narrow
734 board support and fixed a bug in AscGetEEPConfig().
736 Arnaldo Carvalho de Melo <acme@conectiva.com.br> made
737 save_flags/restore_flags changes.
739 Andy Kellner <AKellner@connectcom.net> continues the Advansys SCSI
740 driver development for ConnectCom (Version > 3.3F).
742 K. ConnectCom (AdvanSys) Contact Information
744 Mail: ConnectCom Solutions, Inc.
747 Operator/Sales: 1-408-383-9400
749 Tech Support: 1-408-467-2930
750 Tech Support E-Mail: linux@connectcom.net
751 FTP Site: ftp.connectcom.net (login: anonymous)
752 Web Site: http://www.connectcom.net
757 * --- Linux Include Files
760 #include <linux/module.h>
761 #include <linux/string.h>
762 #include <linux/kernel.h>
763 #include <linux/types.h>
764 #include <linux/ioport.h>
765 #include <linux/interrupt.h>
766 #include <linux/delay.h>
767 #include <linux/slab.h>
768 #include <linux/mm.h>
769 #include <linux/proc_fs.h>
770 #include <linux/init.h>
771 #include <linux/blkdev.h>
772 #include <linux/isa.h>
773 #include <linux/eisa.h>
774 #include <linux/pci.h>
775 #include <linux/spinlock.h>
776 #include <linux/dma-mapping.h>
779 #include <asm/system.h>
782 #include <scsi/scsi_cmnd.h>
783 #include <scsi/scsi_device.h>
784 #include <scsi/scsi_tcq.h>
785 #include <scsi/scsi.h>
786 #include <scsi/scsi_host.h>
788 /* FIXME: (by jejb@steeleye.com)
790 * Although all of the necessary command mapping places have the
791 * appropriate dma_map.. APIs, the driver still processes its internal
792 * queue using bus_to_virt() and virt_to_bus() which are illegal under
793 * the API. The entire queue processing structure will need to be
794 * altered to fix this.
796 #warning this driver is still not properly converted to the DMA API
802 /* Enable driver assertions. */
803 #define ADVANSYS_ASSERT
805 /* Enable driver /proc statistics. */
806 #define ADVANSYS_STATS
808 /* Enable driver tracing. */
809 /* #define ADVANSYS_DEBUG */
812 * --- Asc Library Constants and Macros
815 #define ASC_LIB_VERSION_MAJOR 1
816 #define ASC_LIB_VERSION_MINOR 24
817 #define ASC_LIB_SERIAL_NUMBER 123
820 * Portable Data Types
822 * Any instance where a 32-bit long or pointer type is assumed
823 * for precision or HW defined structures, the following define
824 * types must be used. In Linux the char, short, and int types
825 * are all consistent at 8, 16, and 32 bits respectively. Pointers
826 * and long types are 64 bits on Alpha and UltraSPARC.
828 #define ASC_PADDR __u32 /* Physical/Bus address data type. */
829 #define ASC_VADDR __u32 /* Virtual address data type. */
830 #define ASC_DCNT __u32 /* Unsigned Data count type. */
831 #define ASC_SDCNT __s32 /* Signed Data count type. */
834 * These macros are used to convert a virtual address to a
835 * 32-bit value. This currently can be used on Linux Alpha
836 * which uses 64-bit virtual address but a 32-bit bus address.
837 * This is likely to break in the future, but doing this now
838 * will give us time to change the HW and FW to handle 64-bit
841 #define ASC_VADDR_TO_U32 virt_to_bus
842 #define ASC_U32_TO_VADDR bus_to_virt
844 typedef unsigned char uchar;
855 #define UW_ERR (uint)(0xFFFF)
856 #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
857 #define ASC_PCI_ID2FUNC(id) (((id) >> 8) & 0x7)
858 #define ASC_PCI_MKID(bus, dev, func) ((((dev) & 0x1F) << 11) | (((func) & 0x7) << 8) | ((bus) & 0xFF))
860 #define ASC_DVCLIB_CALL_DONE (1)
861 #define ASC_DVCLIB_CALL_FAILED (0)
862 #define ASC_DVCLIB_CALL_ERROR (-1)
864 #define PCI_VENDOR_ID_ASP 0x10cd
865 #define PCI_DEVICE_ID_ASP_1200A 0x1100
866 #define PCI_DEVICE_ID_ASP_ABP940 0x1200
867 #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
868 #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
869 #define PCI_DEVICE_ID_38C0800_REV1 0x2500
870 #define PCI_DEVICE_ID_38C1600_REV1 0x2700
873 * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
874 * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
875 * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
878 #define CC_VERY_LONG_SG_LIST 0
879 #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
881 #define PortAddr unsigned short /* port address size */
882 #define inp(port) inb(port)
883 #define outp(port, byte) outb((byte), (port))
885 #define inpw(port) inw(port)
886 #define outpw(port, word) outw((word), (port))
888 #define ASC_MAX_SG_QUEUE 7
889 #define ASC_MAX_SG_LIST 255
891 #define ASC_CS_TYPE unsigned short
893 #define ASC_IS_ISA (0x0001)
894 #define ASC_IS_ISAPNP (0x0081)
895 #define ASC_IS_EISA (0x0002)
896 #define ASC_IS_PCI (0x0004)
897 #define ASC_IS_PCI_ULTRA (0x0104)
898 #define ASC_IS_PCMCIA (0x0008)
899 #define ASC_IS_MCA (0x0020)
900 #define ASC_IS_VL (0x0040)
901 #define ASC_ISA_PNP_PORT_ADDR (0x279)
902 #define ASC_ISA_PNP_PORT_WRITE (ASC_ISA_PNP_PORT_ADDR+0x800)
903 #define ASC_IS_WIDESCSI_16 (0x0100)
904 #define ASC_IS_WIDESCSI_32 (0x0200)
905 #define ASC_IS_BIG_ENDIAN (0x8000)
906 #define ASC_CHIP_MIN_VER_VL (0x01)
907 #define ASC_CHIP_MAX_VER_VL (0x07)
908 #define ASC_CHIP_MIN_VER_PCI (0x09)
909 #define ASC_CHIP_MAX_VER_PCI (0x0F)
910 #define ASC_CHIP_VER_PCI_BIT (0x08)
911 #define ASC_CHIP_MIN_VER_ISA (0x11)
912 #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
913 #define ASC_CHIP_MAX_VER_ISA (0x27)
914 #define ASC_CHIP_VER_ISA_BIT (0x30)
915 #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
916 #define ASC_CHIP_VER_ASYN_BUG (0x21)
917 #define ASC_CHIP_VER_PCI 0x08
918 #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
919 #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
920 #define ASC_CHIP_MIN_VER_EISA (0x41)
921 #define ASC_CHIP_MAX_VER_EISA (0x47)
922 #define ASC_CHIP_VER_EISA_BIT (0x40)
923 #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
924 #define ASC_MAX_LIB_SUPPORTED_ISA_CHIP_VER 0x21
925 #define ASC_MAX_LIB_SUPPORTED_PCI_CHIP_VER 0x0A
926 #define ASC_MAX_VL_DMA_ADDR (0x07FFFFFFL)
927 #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
928 #define ASC_MAX_PCI_DMA_ADDR (0xFFFFFFFFL)
929 #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
930 #define ASC_MAX_ISA_DMA_ADDR (0x00FFFFFFL)
931 #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
932 #define ASC_MAX_EISA_DMA_ADDR (0x07FFFFFFL)
933 #define ASC_MAX_EISA_DMA_COUNT (0x07FFFFFFL)
935 #define ASC_SCSI_ID_BITS 3
936 #define ASC_SCSI_TIX_TYPE uchar
937 #define ASC_ALL_DEVICE_BIT_SET 0xFF
938 #define ASC_SCSI_BIT_ID_TYPE uchar
939 #define ASC_MAX_TID 7
940 #define ASC_MAX_LUN 7
941 #define ASC_SCSI_WIDTH_BIT_SET 0xFF
942 #define ASC_MAX_SENSE_LEN 32
943 #define ASC_MIN_SENSE_LEN 14
944 #define ASC_MAX_CDB_LEN 12
945 #define ASC_SCSI_RESET_HOLD_TIME_US 60
947 #define ADV_INQ_CLOCKING_ST_ONLY 0x0
948 #define ADV_INQ_CLOCKING_DT_ONLY 0x1
949 #define ADV_INQ_CLOCKING_ST_AND_DT 0x3
952 * Inquiry SPC-2 SPI Byte 1 EVPD (Enable Vital Product Data)
953 * and CmdDt (Command Support Data) field bit definitions.
955 #define ADV_INQ_RTN_VPD_AND_CMDDT 0x3
956 #define ADV_INQ_RTN_CMDDT_FOR_OP_CODE 0x2
957 #define ADV_INQ_RTN_VPD_FOR_PG_CODE 0x1
958 #define ADV_INQ_RTN_STD_INQUIRY_DATA 0x0
960 #define ASC_SCSIDIR_NOCHK 0x00
961 #define ASC_SCSIDIR_T2H 0x08
962 #define ASC_SCSIDIR_H2T 0x10
963 #define ASC_SCSIDIR_NODATA 0x18
964 #define SCSI_ASC_NOMEDIA 0x3A
965 #define ASC_SRB_HOST(x) ((uchar)((uchar)(x) >> 4))
966 #define ASC_SRB_TID(x) ((uchar)((uchar)(x) & (uchar)0x0F))
967 #define ASC_SRB_LUN(x) ((uchar)((uint)(x) >> 13))
968 #define PUT_CDB1(x) ((uchar)((uint)(x) >> 8))
969 #define MS_CMD_DONE 0x00
970 #define MS_EXTEND 0x01
971 #define MS_SDTR_LEN 0x03
972 #define MS_SDTR_CODE 0x01
973 #define MS_WDTR_LEN 0x02
974 #define MS_WDTR_CODE 0x03
975 #define MS_MDP_LEN 0x05
976 #define MS_MDP_CODE 0x00
979 * Inquiry data structure and bitfield macros
981 * Only quantities of more than 1 bit are shifted, since the others are
982 * just tested for true or false. C bitfields aren't portable between big
983 * and little-endian platforms so they are not used.
986 #define ASC_INQ_DVC_TYPE(inq) ((inq)->periph & 0x1f)
987 #define ASC_INQ_QUALIFIER(inq) (((inq)->periph & 0xe0) >> 5)
988 #define ASC_INQ_DVC_TYPE_MOD(inq) ((inq)->devtype & 0x7f)
989 #define ASC_INQ_REMOVABLE(inq) ((inq)->devtype & 0x80)
990 #define ASC_INQ_ANSI_VER(inq) ((inq)->ver & 0x07)
991 #define ASC_INQ_ECMA_VER(inq) (((inq)->ver & 0x38) >> 3)
992 #define ASC_INQ_ISO_VER(inq) (((inq)->ver & 0xc0) >> 6)
993 #define ASC_INQ_RESPONSE_FMT(inq) ((inq)->byte3 & 0x0f)
994 #define ASC_INQ_TERM_IO(inq) ((inq)->byte3 & 0x40)
995 #define ASC_INQ_ASYNC_NOTIF(inq) ((inq)->byte3 & 0x80)
996 #define ASC_INQ_SOFT_RESET(inq) ((inq)->flags & 0x01)
997 #define ASC_INQ_CMD_QUEUE(inq) ((inq)->flags & 0x02)
998 #define ASC_INQ_LINK_CMD(inq) ((inq)->flags & 0x08)
999 #define ASC_INQ_SYNC(inq) ((inq)->flags & 0x10)
1000 #define ASC_INQ_WIDE16(inq) ((inq)->flags & 0x20)
1001 #define ASC_INQ_WIDE32(inq) ((inq)->flags & 0x40)
1002 #define ASC_INQ_REL_ADDR(inq) ((inq)->flags & 0x80)
1003 #define ASC_INQ_INFO_UNIT(inq) ((inq)->info & 0x01)
1004 #define ASC_INQ_QUICK_ARB(inq) ((inq)->info & 0x02)
1005 #define ASC_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
1017 uchar product_id[16];
1018 uchar product_rev_level[4];
1021 #define ASC_SG_LIST_PER_Q 7
1022 #define QS_FREE 0x00
1023 #define QS_READY 0x01
1024 #define QS_DISC1 0x02
1025 #define QS_DISC2 0x04
1026 #define QS_BUSY 0x08
1027 #define QS_ABORTED 0x40
1028 #define QS_DONE 0x80
1029 #define QC_NO_CALLBACK 0x01
1030 #define QC_SG_SWAP_QUEUE 0x02
1031 #define QC_SG_HEAD 0x04
1032 #define QC_DATA_IN 0x08
1033 #define QC_DATA_OUT 0x10
1034 #define QC_URGENT 0x20
1035 #define QC_MSG_OUT 0x40
1036 #define QC_REQ_SENSE 0x80
1037 #define QCSG_SG_XFER_LIST 0x02
1038 #define QCSG_SG_XFER_MORE 0x04
1039 #define QCSG_SG_XFER_END 0x08
1040 #define QD_IN_PROGRESS 0x00
1041 #define QD_NO_ERROR 0x01
1042 #define QD_ABORTED_BY_HOST 0x02
1043 #define QD_WITH_ERROR 0x04
1044 #define QD_INVALID_REQUEST 0x80
1045 #define QD_INVALID_HOST_NUM 0x81
1046 #define QD_INVALID_DEVICE 0x82
1047 #define QD_ERR_INTERNAL 0xFF
1048 #define QHSTA_NO_ERROR 0x00
1049 #define QHSTA_M_SEL_TIMEOUT 0x11
1050 #define QHSTA_M_DATA_OVER_RUN 0x12
1051 #define QHSTA_M_DATA_UNDER_RUN 0x12
1052 #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
1053 #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
1054 #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
1055 #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
1056 #define QHSTA_D_HOST_ABORT_FAILED 0x23
1057 #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
1058 #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
1059 #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
1060 #define QHSTA_M_WTM_TIMEOUT 0x41
1061 #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
1062 #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
1063 #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
1064 #define QHSTA_M_TARGET_STATUS_BUSY 0x45
1065 #define QHSTA_M_BAD_TAG_CODE 0x46
1066 #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
1067 #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
1068 #define QHSTA_D_LRAM_CMP_ERROR 0x81
1069 #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
1070 #define ASC_FLAG_SCSIQ_REQ 0x01
1071 #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
1072 #define ASC_FLAG_BIOS_ASYNC_IO 0x04
1073 #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
1074 #define ASC_FLAG_WIN16 0x10
1075 #define ASC_FLAG_WIN32 0x20
1076 #define ASC_FLAG_ISA_OVER_16MB 0x40
1077 #define ASC_FLAG_DOS_VM_CALLBACK 0x80
1078 #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
1079 #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
1080 #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
1081 #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
1082 #define ASC_SCSIQ_CPY_BEG 4
1083 #define ASC_SCSIQ_SGHD_CPY_BEG 2
1084 #define ASC_SCSIQ_B_FWD 0
1085 #define ASC_SCSIQ_B_BWD 1
1086 #define ASC_SCSIQ_B_STATUS 2
1087 #define ASC_SCSIQ_B_QNO 3
1088 #define ASC_SCSIQ_B_CNTL 4
1089 #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
1090 #define ASC_SCSIQ_D_DATA_ADDR 8
1091 #define ASC_SCSIQ_D_DATA_CNT 12
1092 #define ASC_SCSIQ_B_SENSE_LEN 20
1093 #define ASC_SCSIQ_DONE_INFO_BEG 22
1094 #define ASC_SCSIQ_D_SRBPTR 22
1095 #define ASC_SCSIQ_B_TARGET_IX 26
1096 #define ASC_SCSIQ_B_CDB_LEN 28
1097 #define ASC_SCSIQ_B_TAG_CODE 29
1098 #define ASC_SCSIQ_W_VM_ID 30
1099 #define ASC_SCSIQ_DONE_STATUS 32
1100 #define ASC_SCSIQ_HOST_STATUS 33
1101 #define ASC_SCSIQ_SCSI_STATUS 34
1102 #define ASC_SCSIQ_CDB_BEG 36
1103 #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
1104 #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
1105 #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
1106 #define ASC_SCSIQ_B_SG_WK_QP 49
1107 #define ASC_SCSIQ_B_SG_WK_IX 50
1108 #define ASC_SCSIQ_W_ALT_DC1 52
1109 #define ASC_SCSIQ_B_LIST_CNT 6
1110 #define ASC_SCSIQ_B_CUR_LIST_CNT 7
1111 #define ASC_SGQ_B_SG_CNTL 4
1112 #define ASC_SGQ_B_SG_HEAD_QP 5
1113 #define ASC_SGQ_B_SG_LIST_CNT 6
1114 #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
1115 #define ASC_SGQ_LIST_BEG 8
1116 #define ASC_DEF_SCSI1_QNG 4
1117 #define ASC_MAX_SCSI1_QNG 4
1118 #define ASC_DEF_SCSI2_QNG 16
1119 #define ASC_MAX_SCSI2_QNG 32
1120 #define ASC_TAG_CODE_MASK 0x23
1121 #define ASC_STOP_REQ_RISC_STOP 0x01
1122 #define ASC_STOP_ACK_RISC_STOP 0x03
1123 #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
1124 #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
1125 #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
1126 #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
1127 #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
1128 #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
1129 #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
1130 #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
1131 #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
1132 #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
1134 typedef struct asc_scsiq_1 {
1141 ASC_PADDR data_addr;
1143 ASC_PADDR sense_addr;
1148 typedef struct asc_scsiq_2 {
1157 typedef struct asc_scsiq_3 {
1164 typedef struct asc_scsiq_4 {
1165 uchar cdb[ASC_MAX_CDB_LEN];
1166 uchar y_first_sg_list_qp;
1167 uchar y_working_sg_qp;
1168 uchar y_working_sg_ix;
1171 ushort x_reconnect_rtn;
1172 ASC_PADDR x_saved_data_addr;
1173 ASC_DCNT x_saved_data_cnt;
1176 typedef struct asc_q_done_info {
1185 ASC_DCNT remain_bytes;
1188 typedef struct asc_sg_list {
1193 typedef struct asc_sg_head {
1196 ushort entry_to_copy;
1198 ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
1201 #define ASC_MIN_SG_LIST 2
1203 typedef struct asc_min_sg_head {
1206 ushort entry_to_copy;
1208 ASC_SG_LIST sg_list[ASC_MIN_SG_LIST];
1211 #define QCX_SORT (0x0001)
1212 #define QCX_COALEASE (0x0002)
1214 typedef struct asc_scsi_q {
1218 ASC_SG_HEAD *sg_head;
1219 ushort remain_sg_entry_cnt;
1220 ushort next_sg_index;
1223 typedef struct asc_scsi_req_q {
1227 ASC_SG_HEAD *sg_head;
1230 uchar cdb[ASC_MAX_CDB_LEN];
1231 uchar sense[ASC_MIN_SENSE_LEN];
1234 typedef struct asc_scsi_bios_req_q {
1238 ASC_SG_HEAD *sg_head;
1241 uchar cdb[ASC_MAX_CDB_LEN];
1242 uchar sense[ASC_MIN_SENSE_LEN];
1243 } ASC_SCSI_BIOS_REQ_Q;
1245 typedef struct asc_risc_q {
1254 typedef struct asc_sg_list_q {
1260 uchar sg_cur_list_cnt;
1263 typedef struct asc_risc_sg_list_q {
1267 ASC_SG_LIST sg_list[7];
1268 } ASC_RISC_SG_LIST_Q;
1270 #define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL
1271 #define ASC_EXE_SCSI_IO_MAX_WAIT_LOOP 1024
1272 #define ASCQ_ERR_NO_ERROR 0
1273 #define ASCQ_ERR_IO_NOT_FOUND 1
1274 #define ASCQ_ERR_LOCAL_MEM 2
1275 #define ASCQ_ERR_CHKSUM 3
1276 #define ASCQ_ERR_START_CHIP 4
1277 #define ASCQ_ERR_INT_TARGET_ID 5
1278 #define ASCQ_ERR_INT_LOCAL_MEM 6
1279 #define ASCQ_ERR_HALT_RISC 7
1280 #define ASCQ_ERR_GET_ASPI_ENTRY 8
1281 #define ASCQ_ERR_CLOSE_ASPI 9
1282 #define ASCQ_ERR_HOST_INQUIRY 0x0A
1283 #define ASCQ_ERR_SAVED_SRB_BAD 0x0B
1284 #define ASCQ_ERR_QCNTL_SG_LIST 0x0C
1285 #define ASCQ_ERR_Q_STATUS 0x0D
1286 #define ASCQ_ERR_WR_SCSIQ 0x0E
1287 #define ASCQ_ERR_PC_ADDR 0x0F
1288 #define ASCQ_ERR_SYN_OFFSET 0x10
1289 #define ASCQ_ERR_SYN_XFER_TIME 0x11
1290 #define ASCQ_ERR_LOCK_DMA 0x12
1291 #define ASCQ_ERR_UNLOCK_DMA 0x13
1292 #define ASCQ_ERR_VDS_CHK_INSTALL 0x14
1293 #define ASCQ_ERR_MICRO_CODE_HALT 0x15
1294 #define ASCQ_ERR_SET_LRAM_ADDR 0x16
1295 #define ASCQ_ERR_CUR_QNG 0x17
1296 #define ASCQ_ERR_SG_Q_LINKS 0x18
1297 #define ASCQ_ERR_SCSIQ_PTR 0x19
1298 #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
1299 #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
1300 #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
1301 #define ASCQ_ERR_SG_LIST_ODD_ADDRESS 0x1D
1302 #define ASCQ_ERR_XFER_ADDRESS_TOO_BIG 0x1E
1303 #define ASCQ_ERR_SCSIQ_NULL_PTR 0x1F
1304 #define ASCQ_ERR_SCSIQ_BAD_NEXT_PTR 0x20
1305 #define ASCQ_ERR_GET_NUM_OF_FREE_Q 0x21
1306 #define ASCQ_ERR_SEND_SCSI_Q 0x22
1307 #define ASCQ_ERR_HOST_REQ_RISC_HALT 0x23
1308 #define ASCQ_ERR_RESET_SDTR 0x24
1311 * Warning code values are set in ASC_DVC_VAR 'warn_code'.
1313 #define ASC_WARN_NO_ERROR 0x0000
1314 #define ASC_WARN_IO_PORT_ROTATE 0x0001
1315 #define ASC_WARN_EEPROM_CHKSUM 0x0002
1316 #define ASC_WARN_IRQ_MODIFIED 0x0004
1317 #define ASC_WARN_AUTO_CONFIG 0x0008
1318 #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
1319 #define ASC_WARN_EEPROM_RECOVER 0x0020
1320 #define ASC_WARN_CFG_MSW_RECOVER 0x0040
1321 #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080
1324 * Error code values are set in ASC_DVC_VAR 'err_code'.
1326 #define ASC_IERR_WRITE_EEPROM 0x0001
1327 #define ASC_IERR_MCODE_CHKSUM 0x0002
1328 #define ASC_IERR_SET_PC_ADDR 0x0004
1329 #define ASC_IERR_START_STOP_CHIP 0x0008
1330 #define ASC_IERR_IRQ_NO 0x0010
1331 #define ASC_IERR_SET_IRQ_NO 0x0020
1332 #define ASC_IERR_CHIP_VERSION 0x0040
1333 #define ASC_IERR_SET_SCSI_ID 0x0080
1334 #define ASC_IERR_GET_PHY_ADDR 0x0100
1335 #define ASC_IERR_BAD_SIGNATURE 0x0200
1336 #define ASC_IERR_NO_BUS_TYPE 0x0400
1337 #define ASC_IERR_SCAM 0x0800
1338 #define ASC_IERR_SET_SDTR 0x1000
1339 #define ASC_IERR_RW_LRAM 0x8000
1341 #define ASC_DEF_IRQ_NO 10
1342 #define ASC_MAX_IRQ_NO 15
1343 #define ASC_MIN_IRQ_NO 10
1344 #define ASC_MIN_REMAIN_Q (0x02)
1345 #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
1346 #define ASC_MIN_TAG_Q_PER_DVC (0x04)
1347 #define ASC_DEF_TAG_Q_PER_DVC (0x04)
1348 #define ASC_MIN_FREE_Q ASC_MIN_REMAIN_Q
1349 #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
1350 #define ASC_MAX_TOTAL_QNG 240
1351 #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
1352 #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
1353 #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
1354 #define ASC_MAX_INRAM_TAG_QNG 16
1355 #define ASC_IOADR_TABLE_MAX_IX 11
1356 #define ASC_IOADR_GAP 0x10
1357 #define ASC_LIB_SCSIQ_WK_SP 256
1358 #define ASC_MAX_SYN_XFER_NO 16
1359 #define ASC_SYN_MAX_OFFSET 0x0F
1360 #define ASC_DEF_SDTR_OFFSET 0x0F
1361 #define ASC_DEF_SDTR_INDEX 0x00
1362 #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
1363 #define SYN_XFER_NS_0 25
1364 #define SYN_XFER_NS_1 30
1365 #define SYN_XFER_NS_2 35
1366 #define SYN_XFER_NS_3 40
1367 #define SYN_XFER_NS_4 50
1368 #define SYN_XFER_NS_5 60
1369 #define SYN_XFER_NS_6 70
1370 #define SYN_XFER_NS_7 85
1371 #define SYN_ULTRA_XFER_NS_0 12
1372 #define SYN_ULTRA_XFER_NS_1 19
1373 #define SYN_ULTRA_XFER_NS_2 25
1374 #define SYN_ULTRA_XFER_NS_3 32
1375 #define SYN_ULTRA_XFER_NS_4 38
1376 #define SYN_ULTRA_XFER_NS_5 44
1377 #define SYN_ULTRA_XFER_NS_6 50
1378 #define SYN_ULTRA_XFER_NS_7 57
1379 #define SYN_ULTRA_XFER_NS_8 63
1380 #define SYN_ULTRA_XFER_NS_9 69
1381 #define SYN_ULTRA_XFER_NS_10 75
1382 #define SYN_ULTRA_XFER_NS_11 82
1383 #define SYN_ULTRA_XFER_NS_12 88
1384 #define SYN_ULTRA_XFER_NS_13 94
1385 #define SYN_ULTRA_XFER_NS_14 100
1386 #define SYN_ULTRA_XFER_NS_15 107
1388 typedef struct ext_msg {
1394 uchar sdtr_xfer_period;
1395 uchar sdtr_req_ack_offset;
1410 #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
1411 #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
1412 #define wdtr_width u_ext_msg.wdtr.wdtr_width
1413 #define mdp_b3 u_ext_msg.mdp_b3
1414 #define mdp_b2 u_ext_msg.mdp_b2
1415 #define mdp_b1 u_ext_msg.mdp_b1
1416 #define mdp_b0 u_ext_msg.mdp_b0
1418 typedef struct asc_dvc_cfg {
1419 ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
1420 ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
1421 ASC_SCSI_BIT_ID_TYPE disc_enable;
1422 ASC_SCSI_BIT_ID_TYPE sdtr_enable;
1424 uchar isa_dma_speed;
1425 uchar isa_dma_channel;
1427 ushort lib_serial_no;
1430 ushort mcode_version;
1431 uchar max_tag_qng[ASC_MAX_TID + 1];
1433 uchar sdtr_period_offset[ASC_MAX_TID + 1];
1434 ushort pci_slot_info;
1435 uchar adapter_info[6];
1439 #define ASC_DEF_DVC_CNTL 0xFFFF
1440 #define ASC_DEF_CHIP_SCSI_ID 7
1441 #define ASC_DEF_ISA_DMA_SPEED 4
1442 #define ASC_INIT_STATE_NULL 0x0000
1443 #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
1444 #define ASC_INIT_STATE_END_GET_CFG 0x0002
1445 #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
1446 #define ASC_INIT_STATE_END_SET_CFG 0x0008
1447 #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
1448 #define ASC_INIT_STATE_END_LOAD_MC 0x0020
1449 #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
1450 #define ASC_INIT_STATE_END_INQUIRY 0x0080
1451 #define ASC_INIT_RESET_SCSI_DONE 0x0100
1452 #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
1453 #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
1454 #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
1455 #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
1456 #define ASC_MIN_TAGGED_CMD 7
1457 #define ASC_MAX_SCSI_RESET_WAIT 30
1459 struct asc_dvc_var; /* Forward Declaration. */
1461 typedef void (*ASC_ISR_CALLBACK) (struct asc_dvc_var *, ASC_QDONE_INFO *);
1462 typedef int (*ASC_EXE_CALLBACK) (struct asc_dvc_var *, ASC_SCSI_Q *);
1464 typedef struct asc_dvc_var {
1468 ushort bug_fix_cntl;
1470 ASC_ISR_CALLBACK isr_callback;
1471 ASC_EXE_CALLBACK exe_callback;
1472 ASC_SCSI_BIT_ID_TYPE init_sdtr;
1473 ASC_SCSI_BIT_ID_TYPE sdtr_done;
1474 ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
1475 ASC_SCSI_BIT_ID_TYPE unit_not_ready;
1476 ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
1477 ASC_SCSI_BIT_ID_TYPE start_motor;
1478 uchar scsi_reset_wait;
1481 uchar max_total_qng;
1482 uchar cur_total_qng;
1483 uchar in_critical_cnt;
1485 uchar last_q_shortage;
1487 uchar cur_dvc_qng[ASC_MAX_TID + 1];
1488 uchar max_dvc_qng[ASC_MAX_TID + 1];
1489 ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
1490 ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
1491 uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
1493 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
1496 uchar dos_int13_table[ASC_MAX_TID + 1];
1497 ASC_DCNT max_dma_count;
1498 ASC_SCSI_BIT_ID_TYPE no_scam;
1499 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
1500 uchar max_sdtr_index;
1501 uchar host_init_sdtr_index;
1502 struct asc_board *drv_ptr;
1506 typedef struct asc_dvc_inq_info {
1507 uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
1510 typedef struct asc_cap_info {
1515 typedef struct asc_cap_info_array {
1516 ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
1517 } ASC_CAP_INFO_ARRAY;
1519 #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
1520 #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
1521 #define ASC_CNTL_INITIATOR (ushort)0x0001
1522 #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
1523 #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
1524 #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
1525 #define ASC_CNTL_NO_SCAM (ushort)0x0010
1526 #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
1527 #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
1528 #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
1529 #define ASC_CNTL_RESET_SCSI (ushort)0x0200
1530 #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
1531 #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
1532 #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
1533 #define ASC_CNTL_BURST_MODE (ushort)0x2000
1534 #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
1535 #define ASC_EEP_DVC_CFG_BEG_VL 2
1536 #define ASC_EEP_MAX_DVC_ADDR_VL 15
1537 #define ASC_EEP_DVC_CFG_BEG 32
1538 #define ASC_EEP_MAX_DVC_ADDR 45
1539 #define ASC_EEP_DEFINED_WORDS 10
1540 #define ASC_EEP_MAX_ADDR 63
1541 #define ASC_EEP_RES_WORDS 0
1542 #define ASC_EEP_MAX_RETRY 20
1543 #define ASC_MAX_INIT_BUSY_RETRY 8
1544 #define ASC_EEP_ISA_PNP_WSIZE 16
1547 * These macros keep the chip SCSI id and ISA DMA speed
1548 * bitfields in board order. C bitfields aren't portable
1549 * between big and little-endian platforms so they are
1553 #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
1554 #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
1555 #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
1556 ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
1557 #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
1558 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
1560 typedef struct asceep_config {
1567 uchar max_total_qng;
1570 uchar power_up_wait;
1572 uchar id_speed; /* low order 4 bits is chip scsi id */
1573 /* high order 4 bits is isa dma speed */
1574 uchar dos_int13_table[ASC_MAX_TID + 1];
1575 uchar adapter_info[6];
1580 #define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800
1581 #define ASC_PCI_CFG_LSW_BURST_MODE 0x0080
1582 #define ASC_PCI_CFG_LSW_INTR_ABLE 0x0020
1584 #define ASC_EEP_CMD_READ 0x80
1585 #define ASC_EEP_CMD_WRITE 0x40
1586 #define ASC_EEP_CMD_WRITE_ABLE 0x30
1587 #define ASC_EEP_CMD_WRITE_DISABLE 0x00
1588 #define ASC_OVERRUN_BSIZE 0x00000048UL
1589 #define ASC_CTRL_BREAK_ONCE 0x0001
1590 #define ASC_CTRL_BREAK_STAY_IDLE 0x0002
1591 #define ASCV_MSGOUT_BEG 0x0000
1592 #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
1593 #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
1594 #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
1595 #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
1596 #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
1597 #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
1598 #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
1599 #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
1600 #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
1601 #define ASCV_BREAK_ADDR (ushort)0x0028
1602 #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
1603 #define ASCV_BREAK_CONTROL (ushort)0x002C
1604 #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
1606 #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
1607 #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
1608 #define ASCV_MCODE_SIZE_W (ushort)0x0034
1609 #define ASCV_STOP_CODE_B (ushort)0x0036
1610 #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
1611 #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
1612 #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
1613 #define ASCV_HALTCODE_W (ushort)0x0040
1614 #define ASCV_CHKSUM_W (ushort)0x0042
1615 #define ASCV_MC_DATE_W (ushort)0x0044
1616 #define ASCV_MC_VER_W (ushort)0x0046
1617 #define ASCV_NEXTRDY_B (ushort)0x0048
1618 #define ASCV_DONENEXT_B (ushort)0x0049
1619 #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
1620 #define ASCV_SCSIBUSY_B (ushort)0x004B
1621 #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
1622 #define ASCV_CURCDB_B (ushort)0x004D
1623 #define ASCV_RCLUN_B (ushort)0x004E
1624 #define ASCV_BUSY_QHEAD_B (ushort)0x004F
1625 #define ASCV_DISC1_QHEAD_B (ushort)0x0050
1626 #define ASCV_DISC_ENABLE_B (ushort)0x0052
1627 #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
1628 #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
1629 #define ASCV_MCODE_CNTL_B (ushort)0x0056
1630 #define ASCV_NULL_TARGET_B (ushort)0x0057
1631 #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
1632 #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
1633 #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
1634 #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
1635 #define ASCV_HOST_FLAG_B (ushort)0x005D
1636 #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
1637 #define ASCV_VER_SERIAL_B (ushort)0x0065
1638 #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
1639 #define ASCV_WTM_FLAG_B (ushort)0x0068
1640 #define ASCV_RISC_FLAG_B (ushort)0x006A
1641 #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
1642 #define ASC_HOST_FLAG_IN_ISR 0x01
1643 #define ASC_HOST_FLAG_ACK_INT 0x02
1644 #define ASC_RISC_FLAG_GEN_INT 0x01
1645 #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
1646 #define IOP_CTRL (0x0F)
1647 #define IOP_STATUS (0x0E)
1648 #define IOP_INT_ACK IOP_STATUS
1649 #define IOP_REG_IFC (0x0D)
1650 #define IOP_SYN_OFFSET (0x0B)
1651 #define IOP_EXTRA_CONTROL (0x0D)
1652 #define IOP_REG_PC (0x0C)
1653 #define IOP_RAM_ADDR (0x0A)
1654 #define IOP_RAM_DATA (0x08)
1655 #define IOP_EEP_DATA (0x06)
1656 #define IOP_EEP_CMD (0x07)
1657 #define IOP_VERSION (0x03)
1658 #define IOP_CONFIG_HIGH (0x04)
1659 #define IOP_CONFIG_LOW (0x02)
1660 #define IOP_SIG_BYTE (0x01)
1661 #define IOP_SIG_WORD (0x00)
1662 #define IOP_REG_DC1 (0x0E)
1663 #define IOP_REG_DC0 (0x0C)
1664 #define IOP_REG_SB (0x0B)
1665 #define IOP_REG_DA1 (0x0A)
1666 #define IOP_REG_DA0 (0x08)
1667 #define IOP_REG_SC (0x09)
1668 #define IOP_DMA_SPEED (0x07)
1669 #define IOP_REG_FLAG (0x07)
1670 #define IOP_FIFO_H (0x06)
1671 #define IOP_FIFO_L (0x04)
1672 #define IOP_REG_ID (0x05)
1673 #define IOP_REG_QP (0x03)
1674 #define IOP_REG_IH (0x02)
1675 #define IOP_REG_IX (0x01)
1676 #define IOP_REG_AX (0x00)
1677 #define IFC_REG_LOCK (0x00)
1678 #define IFC_REG_UNLOCK (0x09)
1679 #define IFC_WR_EN_FILTER (0x10)
1680 #define IFC_RD_NO_EEPROM (0x10)
1681 #define IFC_SLEW_RATE (0x20)
1682 #define IFC_ACT_NEG (0x40)
1683 #define IFC_INP_FILTER (0x80)
1684 #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
1685 #define SC_SEL (uchar)(0x80)
1686 #define SC_BSY (uchar)(0x40)
1687 #define SC_ACK (uchar)(0x20)
1688 #define SC_REQ (uchar)(0x10)
1689 #define SC_ATN (uchar)(0x08)
1690 #define SC_IO (uchar)(0x04)
1691 #define SC_CD (uchar)(0x02)
1692 #define SC_MSG (uchar)(0x01)
1693 #define SEC_SCSI_CTL (uchar)(0x80)
1694 #define SEC_ACTIVE_NEGATE (uchar)(0x40)
1695 #define SEC_SLEW_RATE (uchar)(0x20)
1696 #define SEC_ENABLE_FILTER (uchar)(0x10)
1697 #define ASC_HALT_EXTMSG_IN (ushort)0x8000
1698 #define ASC_HALT_CHK_CONDITION (ushort)0x8100
1699 #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
1700 #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
1701 #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
1702 #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
1703 #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
1704 #define ASC_MAX_QNO 0xF8
1705 #define ASC_DATA_SEC_BEG (ushort)0x0080
1706 #define ASC_DATA_SEC_END (ushort)0x0080
1707 #define ASC_CODE_SEC_BEG (ushort)0x0080
1708 #define ASC_CODE_SEC_END (ushort)0x0080
1709 #define ASC_QADR_BEG (0x4000)
1710 #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
1711 #define ASC_QADR_END (ushort)0x7FFF
1712 #define ASC_QLAST_ADR (ushort)0x7FC0
1713 #define ASC_QBLK_SIZE 0x40
1714 #define ASC_BIOS_DATA_QBEG 0xF8
1715 #define ASC_MIN_ACTIVE_QNO 0x01
1716 #define ASC_QLINK_END 0xFF
1717 #define ASC_EEPROM_WORDS 0x10
1718 #define ASC_MAX_MGS_LEN 0x10
1719 #define ASC_BIOS_ADDR_DEF 0xDC00
1720 #define ASC_BIOS_SIZE 0x3800
1721 #define ASC_BIOS_RAM_OFF 0x3800
1722 #define ASC_BIOS_RAM_SIZE 0x800
1723 #define ASC_BIOS_MIN_ADDR 0xC000
1724 #define ASC_BIOS_MAX_ADDR 0xEC00
1725 #define ASC_BIOS_BANK_SIZE 0x0400
1726 #define ASC_MCODE_START_ADDR 0x0080
1727 #define ASC_CFG0_HOST_INT_ON 0x0020
1728 #define ASC_CFG0_BIOS_ON 0x0040
1729 #define ASC_CFG0_VERA_BURST_ON 0x0080
1730 #define ASC_CFG0_SCSI_PARITY_ON 0x0800
1731 #define ASC_CFG1_SCSI_TARGET_ON 0x0080
1732 #define ASC_CFG1_LRAM_8BITS_ON 0x0800
1733 #define ASC_CFG_MSW_CLR_MASK 0x3080
1734 #define CSW_TEST1 (ASC_CS_TYPE)0x8000
1735 #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
1736 #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
1737 #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
1738 #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
1739 #define CSW_TEST2 (ASC_CS_TYPE)0x0400
1740 #define CSW_TEST3 (ASC_CS_TYPE)0x0200
1741 #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
1742 #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
1743 #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
1744 #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
1745 #define CSW_HALTED (ASC_CS_TYPE)0x0010
1746 #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
1747 #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
1748 #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
1749 #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
1750 #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
1751 #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
1752 #define CIW_TEST1 (ASC_CS_TYPE)0x0200
1753 #define CIW_TEST2 (ASC_CS_TYPE)0x0400
1754 #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
1755 #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
1756 #define CC_CHIP_RESET (uchar)0x80
1757 #define CC_SCSI_RESET (uchar)0x40
1758 #define CC_HALT (uchar)0x20
1759 #define CC_SINGLE_STEP (uchar)0x10
1760 #define CC_DMA_ABLE (uchar)0x08
1761 #define CC_TEST (uchar)0x04
1762 #define CC_BANK_ONE (uchar)0x02
1763 #define CC_DIAG (uchar)0x01
1764 #define ASC_1000_ID0W 0x04C1
1765 #define ASC_1000_ID0W_FIX 0x00C1
1766 #define ASC_1000_ID1B 0x25
1767 #define ASC_EISA_REV_IOP_MASK (0x0C83)
1768 #define ASC_EISA_PID_IOP_MASK (0x0C80)
1769 #define ASC_EISA_CFG_IOP_MASK (0x0C86)
1770 #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
1771 #define INS_HALTINT (ushort)0x6281
1772 #define INS_HALT (ushort)0x6280
1773 #define INS_SINT (ushort)0x6200
1774 #define INS_RFLAG_WTM (ushort)0x7380
1775 #define ASC_MC_SAVE_CODE_WSIZE 0x500
1776 #define ASC_MC_SAVE_DATA_WSIZE 0x40
1778 typedef struct asc_mc_saved {
1779 ushort data[ASC_MC_SAVE_DATA_WSIZE];
1780 ushort code[ASC_MC_SAVE_CODE_WSIZE];
1783 #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
1784 #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
1785 #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
1786 #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
1787 #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
1788 #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
1789 #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
1790 #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
1791 #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
1792 #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
1793 #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data));
1794 #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id));
1795 #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data);
1796 #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id));
1797 #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
1798 #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
1799 #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
1800 #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
1801 #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
1802 #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
1803 #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
1804 #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
1805 #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
1806 #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
1807 #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
1808 #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
1809 #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
1810 #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
1811 #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
1812 #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
1813 #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
1814 #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
1815 #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
1816 #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
1817 #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
1818 #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
1819 #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
1820 #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
1821 #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
1822 #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
1823 #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
1824 #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
1825 #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
1826 #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
1827 #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
1828 #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
1829 #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
1830 #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
1831 #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
1832 #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
1833 #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
1834 #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
1835 #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
1836 #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
1837 #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
1838 #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
1839 #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
1840 #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
1841 #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
1842 #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
1843 #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
1844 #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
1845 #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
1846 #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
1847 #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
1848 #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
1849 #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
1850 #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
1852 static int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg);
1853 static int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg);
1854 static void AscWaitEEPRead(void);
1855 static void AscWaitEEPWrite(void);
1856 static ushort AscReadEEPWord(PortAddr, uchar);
1857 static ushort AscWriteEEPWord(PortAddr, uchar, ushort);
1858 static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
1859 static int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort);
1860 static int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
1861 static int AscStartChip(PortAddr);
1862 static int AscStopChip(PortAddr);
1863 static void AscSetChipIH(PortAddr, ushort);
1864 static int AscIsChipHalted(PortAddr);
1865 static void AscAckInterrupt(PortAddr);
1866 static void AscDisableInterrupt(PortAddr);
1867 static void AscEnableInterrupt(PortAddr);
1868 static void AscSetBank(PortAddr, uchar);
1869 static int AscResetChipAndScsiBus(ASC_DVC_VAR *);
1871 static ushort AscGetIsaDmaChannel(PortAddr);
1872 static ushort AscSetIsaDmaChannel(PortAddr, ushort);
1873 static uchar AscSetIsaDmaSpeed(PortAddr, uchar);
1874 static uchar AscGetIsaDmaSpeed(PortAddr);
1875 #endif /* CONFIG_ISA */
1876 static uchar AscReadLramByte(PortAddr, ushort);
1877 static ushort AscReadLramWord(PortAddr, ushort);
1878 #if CC_VERY_LONG_SG_LIST
1879 static ASC_DCNT AscReadLramDWord(PortAddr, ushort);
1880 #endif /* CC_VERY_LONG_SG_LIST */
1881 static void AscWriteLramWord(PortAddr, ushort, ushort);
1882 static void AscWriteLramByte(PortAddr, ushort, uchar);
1883 static ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int);
1884 static void AscMemWordSetLram(PortAddr, ushort, ushort, int);
1885 static void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
1886 static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
1887 static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
1888 static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
1889 static ushort AscInitFromEEP(ASC_DVC_VAR *);
1890 static ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
1891 static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
1892 static int AscTestExternalLram(ASC_DVC_VAR *);
1893 static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
1894 static uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar);
1895 static void AscSetChipSDTR(PortAddr, uchar, uchar);
1896 static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar);
1897 static uchar AscAllocFreeQueue(PortAddr, uchar);
1898 static uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar);
1899 static int AscHostReqRiscHalt(PortAddr);
1900 static int AscStopQueueExe(PortAddr);
1901 static int AscSendScsiQueue(ASC_DVC_VAR *,
1902 ASC_SCSI_Q *scsiq, uchar n_q_required);
1903 static int AscPutReadyQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
1904 static int AscPutReadySgListQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
1905 static int AscSetChipSynRegAtID(PortAddr, uchar, uchar);
1906 static int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar);
1907 static ushort AscInitLram(ASC_DVC_VAR *);
1908 static ushort AscInitQLinkVar(ASC_DVC_VAR *);
1909 static int AscSetLibErrorCode(ASC_DVC_VAR *, ushort);
1910 static int AscIsrChipHalted(ASC_DVC_VAR *);
1911 static uchar _AscCopyLramScsiDoneQ(PortAddr, ushort,
1912 ASC_QDONE_INFO *, ASC_DCNT);
1913 static int AscIsrQDone(ASC_DVC_VAR *);
1915 static ushort AscGetEisaChipCfg(PortAddr);
1916 #endif /* CONFIG_ISA */
1917 static uchar AscGetChipScsiCtrl(PortAddr);
1918 static uchar AscSetChipScsiID(PortAddr, uchar);
1919 static uchar AscGetChipVersion(PortAddr, ushort);
1920 static ushort AscGetChipBusType(PortAddr);
1921 static ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
1922 static int AscFindSignature(PortAddr);
1923 static void AscToggleIRQAct(PortAddr);
1924 static uchar AscGetChipIRQ(PortAddr, ushort);
1925 static uchar AscSetChipIRQ(PortAddr, uchar, ushort);
1926 static ushort AscGetChipBiosAddress(PortAddr, ushort);
1927 static inline ulong DvcEnterCritical(void);
1928 static inline void DvcLeaveCritical(ulong);
1929 static ushort AscGetChipBiosAddress(PortAddr, ushort);
1930 static void DvcSleepMilliSecond(ASC_DCNT);
1931 static void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
1932 static void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
1933 static void DvcGetQinfo(PortAddr, ushort, uchar *, int);
1934 static ushort AscInitAsc1000Driver(ASC_DVC_VAR *);
1935 static void AscAsyncFix(ASC_DVC_VAR *, uchar, ASC_SCSI_INQUIRY *);
1936 static int AscTagQueuingSafe(ASC_SCSI_INQUIRY *);
1937 static void AscInquiryHandling(ASC_DVC_VAR *, uchar, ASC_SCSI_INQUIRY *);
1938 static int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *);
1939 static int AscISR(ASC_DVC_VAR *);
1940 static uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar, uchar);
1941 static int AscSgListToQueue(int);
1943 static void AscEnableIsaDma(uchar);
1944 #endif /* CONFIG_ISA */
1945 static ASC_DCNT AscGetMaxDmaCount(ushort);
1946 static const char *advansys_info(struct Scsi_Host *shost);
1949 * --- Adv Library Constants and Macros
1952 #define ADV_LIB_VERSION_MAJOR 5
1953 #define ADV_LIB_VERSION_MINOR 14
1956 * Define Adv Library required special types.
1960 * Portable Data Types
1962 * Any instance where a 32-bit long or pointer type is assumed
1963 * for precision or HW defined structures, the following define
1964 * types must be used. In Linux the char, short, and int types
1965 * are all consistent at 8, 16, and 32 bits respectively. Pointers
1966 * and long types are 64 bits on Alpha and UltraSPARC.
1968 #define ADV_PADDR __u32 /* Physical address data type. */
1969 #define ADV_VADDR __u32 /* Virtual address data type. */
1970 #define ADV_DCNT __u32 /* Unsigned Data count type. */
1971 #define ADV_SDCNT __s32 /* Signed Data count type. */
1974 * These macros are used to convert a virtual address to a
1975 * 32-bit value. This currently can be used on Linux Alpha
1976 * which uses 64-bit virtual address but a 32-bit bus address.
1977 * This is likely to break in the future, but doing this now
1978 * will give us time to change the HW and FW to handle 64-bit
1981 #define ADV_VADDR_TO_U32 virt_to_bus
1982 #define ADV_U32_TO_VADDR bus_to_virt
1984 #define AdvPortAddr void __iomem * /* Virtual memory address size */
1987 * Define Adv Library required memory access macros.
1989 #define ADV_MEM_READB(addr) readb(addr)
1990 #define ADV_MEM_READW(addr) readw(addr)
1991 #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
1992 #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
1993 #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
1995 #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
1998 * For wide boards a CDB length maximum of 16 bytes
2001 #define ADV_MAX_CDB_LEN 16
2004 * Define total number of simultaneous maximum element scatter-gather
2005 * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
2006 * maximum number of outstanding commands per wide host adapter. Each
2007 * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
2008 * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
2009 * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
2010 * structures or 255 scatter-gather elements.
2013 #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
2016 * Define Adv Library required maximum number of scatter-gather
2017 * elements per request.
2019 #define ADV_MAX_SG_LIST 255
2021 /* Number of SG blocks needed. */
2022 #define ADV_NUM_SG_BLOCK \
2023 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
2025 /* Total contiguous memory needed for SG blocks. */
2026 #define ADV_SG_TOTAL_MEM_SIZE \
2027 (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
2029 #define ADV_PAGE_SIZE PAGE_SIZE
2031 #define ADV_NUM_PAGE_CROSSING \
2032 ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
2034 #define ADV_EEP_DVC_CFG_BEGIN (0x00)
2035 #define ADV_EEP_DVC_CFG_END (0x15)
2036 #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
2037 #define ADV_EEP_MAX_WORD_ADDR (0x1E)
2039 #define ADV_EEP_DELAY_MS 100
2041 #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
2042 #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
2044 * For the ASC3550 Bit 13 is Termination Polarity control bit.
2045 * For later ICs Bit 13 controls whether the CIS (Card Information
2046 * Service Section) is loaded from EEPROM.
2048 #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
2049 #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
2053 * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
2054 * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
2055 * Function 0 will specify INT B.
2057 * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
2058 * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
2059 * Function 1 will specify INT A.
2061 #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
2063 typedef struct adveep_3550_config {
2064 /* Word Offset, Description */
2066 ushort cfg_lsw; /* 00 power up initialization */
2067 /* bit 13 set - Term Polarity Control */
2068 /* bit 14 set - BIOS Enable */
2069 /* bit 15 set - Big Endian Mode */
2070 ushort cfg_msw; /* 01 unused */
2071 ushort disc_enable; /* 02 disconnect enable */
2072 ushort wdtr_able; /* 03 Wide DTR able */
2073 ushort sdtr_able; /* 04 Synchronous DTR able */
2074 ushort start_motor; /* 05 send start up motor */
2075 ushort tagqng_able; /* 06 tag queuing able */
2076 ushort bios_scan; /* 07 BIOS device control */
2077 ushort scam_tolerant; /* 08 no scam */
2079 uchar adapter_scsi_id; /* 09 Host Adapter ID */
2080 uchar bios_boot_delay; /* power up wait */
2082 uchar scsi_reset_delay; /* 10 reset delay */
2083 uchar bios_id_lun; /* first boot device scsi id & lun */
2084 /* high nibble is lun */
2085 /* low nibble is scsi id */
2087 uchar termination; /* 11 0 - automatic */
2088 /* 1 - low off / high off */
2089 /* 2 - low off / high on */
2090 /* 3 - low on / high on */
2091 /* There is no low on / high off */
2093 uchar reserved1; /* reserved byte (not used) */
2095 ushort bios_ctrl; /* 12 BIOS control bits */
2096 /* bit 0 BIOS don't act as initiator. */
2097 /* bit 1 BIOS > 1 GB support */
2098 /* bit 2 BIOS > 2 Disk Support */
2099 /* bit 3 BIOS don't support removables */
2100 /* bit 4 BIOS support bootable CD */
2101 /* bit 5 BIOS scan enabled */
2102 /* bit 6 BIOS support multiple LUNs */
2103 /* bit 7 BIOS display of message */
2104 /* bit 8 SCAM disabled */
2105 /* bit 9 Reset SCSI bus during init. */
2107 /* bit 11 No verbose initialization. */
2108 /* bit 12 SCSI parity enabled */
2112 ushort ultra_able; /* 13 ULTRA speed able */
2113 ushort reserved2; /* 14 reserved */
2114 uchar max_host_qng; /* 15 maximum host queuing */
2115 uchar max_dvc_qng; /* maximum per device queuing */
2116 ushort dvc_cntl; /* 16 control bit for driver */
2117 ushort bug_fix; /* 17 control bit for bug fix */
2118 ushort serial_number_word1; /* 18 Board serial number word 1 */
2119 ushort serial_number_word2; /* 19 Board serial number word 2 */
2120 ushort serial_number_word3; /* 20 Board serial number word 3 */
2121 ushort check_sum; /* 21 EEP check sum */
2122 uchar oem_name[16]; /* 22 OEM name */
2123 ushort dvc_err_code; /* 30 last device driver error code */
2124 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
2125 ushort adv_err_addr; /* 32 last uc error address */
2126 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
2127 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
2128 ushort saved_adv_err_addr; /* 35 saved last uc error address */
2129 ushort num_of_err; /* 36 number of error */
2130 } ADVEEP_3550_CONFIG;
2132 typedef struct adveep_38C0800_config {
2133 /* Word Offset, Description */
2135 ushort cfg_lsw; /* 00 power up initialization */
2136 /* bit 13 set - Load CIS */
2137 /* bit 14 set - BIOS Enable */
2138 /* bit 15 set - Big Endian Mode */
2139 ushort cfg_msw; /* 01 unused */
2140 ushort disc_enable; /* 02 disconnect enable */
2141 ushort wdtr_able; /* 03 Wide DTR able */
2142 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
2143 ushort start_motor; /* 05 send start up motor */
2144 ushort tagqng_able; /* 06 tag queuing able */
2145 ushort bios_scan; /* 07 BIOS device control */
2146 ushort scam_tolerant; /* 08 no scam */
2148 uchar adapter_scsi_id; /* 09 Host Adapter ID */
2149 uchar bios_boot_delay; /* power up wait */
2151 uchar scsi_reset_delay; /* 10 reset delay */
2152 uchar bios_id_lun; /* first boot device scsi id & lun */
2153 /* high nibble is lun */
2154 /* low nibble is scsi id */
2156 uchar termination_se; /* 11 0 - automatic */
2157 /* 1 - low off / high off */
2158 /* 2 - low off / high on */
2159 /* 3 - low on / high on */
2160 /* There is no low on / high off */
2162 uchar termination_lvd; /* 11 0 - automatic */
2163 /* 1 - low off / high off */
2164 /* 2 - low off / high on */
2165 /* 3 - low on / high on */
2166 /* There is no low on / high off */
2168 ushort bios_ctrl; /* 12 BIOS control bits */
2169 /* bit 0 BIOS don't act as initiator. */
2170 /* bit 1 BIOS > 1 GB support */
2171 /* bit 2 BIOS > 2 Disk Support */
2172 /* bit 3 BIOS don't support removables */
2173 /* bit 4 BIOS support bootable CD */
2174 /* bit 5 BIOS scan enabled */
2175 /* bit 6 BIOS support multiple LUNs */
2176 /* bit 7 BIOS display of message */
2177 /* bit 8 SCAM disabled */
2178 /* bit 9 Reset SCSI bus during init. */
2180 /* bit 11 No verbose initialization. */
2181 /* bit 12 SCSI parity enabled */
2185 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
2186 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
2187 uchar max_host_qng; /* 15 maximum host queueing */
2188 uchar max_dvc_qng; /* maximum per device queuing */
2189 ushort dvc_cntl; /* 16 control bit for driver */
2190 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
2191 ushort serial_number_word1; /* 18 Board serial number word 1 */
2192 ushort serial_number_word2; /* 19 Board serial number word 2 */
2193 ushort serial_number_word3; /* 20 Board serial number word 3 */
2194 ushort check_sum; /* 21 EEP check sum */
2195 uchar oem_name[16]; /* 22 OEM name */
2196 ushort dvc_err_code; /* 30 last device driver error code */
2197 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
2198 ushort adv_err_addr; /* 32 last uc error address */
2199 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
2200 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
2201 ushort saved_adv_err_addr; /* 35 saved last uc error address */
2202 ushort reserved36; /* 36 reserved */
2203 ushort reserved37; /* 37 reserved */
2204 ushort reserved38; /* 38 reserved */
2205 ushort reserved39; /* 39 reserved */
2206 ushort reserved40; /* 40 reserved */
2207 ushort reserved41; /* 41 reserved */
2208 ushort reserved42; /* 42 reserved */
2209 ushort reserved43; /* 43 reserved */
2210 ushort reserved44; /* 44 reserved */
2211 ushort reserved45; /* 45 reserved */
2212 ushort reserved46; /* 46 reserved */
2213 ushort reserved47; /* 47 reserved */
2214 ushort reserved48; /* 48 reserved */
2215 ushort reserved49; /* 49 reserved */
2216 ushort reserved50; /* 50 reserved */
2217 ushort reserved51; /* 51 reserved */
2218 ushort reserved52; /* 52 reserved */
2219 ushort reserved53; /* 53 reserved */
2220 ushort reserved54; /* 54 reserved */
2221 ushort reserved55; /* 55 reserved */
2222 ushort cisptr_lsw; /* 56 CIS PTR LSW */
2223 ushort cisprt_msw; /* 57 CIS PTR MSW */
2224 ushort subsysvid; /* 58 SubSystem Vendor ID */
2225 ushort subsysid; /* 59 SubSystem ID */
2226 ushort reserved60; /* 60 reserved */
2227 ushort reserved61; /* 61 reserved */
2228 ushort reserved62; /* 62 reserved */
2229 ushort reserved63; /* 63 reserved */
2230 } ADVEEP_38C0800_CONFIG;
2232 typedef struct adveep_38C1600_config {
2233 /* Word Offset, Description */
2235 ushort cfg_lsw; /* 00 power up initialization */
2236 /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
2237 /* clear - Func. 0 INTA, Func. 1 INTB */
2238 /* bit 13 set - Load CIS */
2239 /* bit 14 set - BIOS Enable */
2240 /* bit 15 set - Big Endian Mode */
2241 ushort cfg_msw; /* 01 unused */
2242 ushort disc_enable; /* 02 disconnect enable */
2243 ushort wdtr_able; /* 03 Wide DTR able */
2244 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
2245 ushort start_motor; /* 05 send start up motor */
2246 ushort tagqng_able; /* 06 tag queuing able */
2247 ushort bios_scan; /* 07 BIOS device control */
2248 ushort scam_tolerant; /* 08 no scam */
2250 uchar adapter_scsi_id; /* 09 Host Adapter ID */
2251 uchar bios_boot_delay; /* power up wait */
2253 uchar scsi_reset_delay; /* 10 reset delay */
2254 uchar bios_id_lun; /* first boot device scsi id & lun */
2255 /* high nibble is lun */
2256 /* low nibble is scsi id */
2258 uchar termination_se; /* 11 0 - automatic */
2259 /* 1 - low off / high off */
2260 /* 2 - low off / high on */
2261 /* 3 - low on / high on */
2262 /* There is no low on / high off */
2264 uchar termination_lvd; /* 11 0 - automatic */
2265 /* 1 - low off / high off */
2266 /* 2 - low off / high on */
2267 /* 3 - low on / high on */
2268 /* There is no low on / high off */
2270 ushort bios_ctrl; /* 12 BIOS control bits */
2271 /* bit 0 BIOS don't act as initiator. */
2272 /* bit 1 BIOS > 1 GB support */
2273 /* bit 2 BIOS > 2 Disk Support */
2274 /* bit 3 BIOS don't support removables */
2275 /* bit 4 BIOS support bootable CD */
2276 /* bit 5 BIOS scan enabled */
2277 /* bit 6 BIOS support multiple LUNs */
2278 /* bit 7 BIOS display of message */
2279 /* bit 8 SCAM disabled */
2280 /* bit 9 Reset SCSI bus during init. */
2281 /* bit 10 Basic Integrity Checking disabled */
2282 /* bit 11 No verbose initialization. */
2283 /* bit 12 SCSI parity enabled */
2284 /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
2287 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
2288 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
2289 uchar max_host_qng; /* 15 maximum host queueing */
2290 uchar max_dvc_qng; /* maximum per device queuing */
2291 ushort dvc_cntl; /* 16 control bit for driver */
2292 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
2293 ushort serial_number_word1; /* 18 Board serial number word 1 */
2294 ushort serial_number_word2; /* 19 Board serial number word 2 */
2295 ushort serial_number_word3; /* 20 Board serial number word 3 */
2296 ushort check_sum; /* 21 EEP check sum */
2297 uchar oem_name[16]; /* 22 OEM name */
2298 ushort dvc_err_code; /* 30 last device driver error code */
2299 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
2300 ushort adv_err_addr; /* 32 last uc error address */
2301 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
2302 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
2303 ushort saved_adv_err_addr; /* 35 saved last uc error address */
2304 ushort reserved36; /* 36 reserved */
2305 ushort reserved37; /* 37 reserved */
2306 ushort reserved38; /* 38 reserved */
2307 ushort reserved39; /* 39 reserved */
2308 ushort reserved40; /* 40 reserved */
2309 ushort reserved41; /* 41 reserved */
2310 ushort reserved42; /* 42 reserved */
2311 ushort reserved43; /* 43 reserved */
2312 ushort reserved44; /* 44 reserved */
2313 ushort reserved45; /* 45 reserved */
2314 ushort reserved46; /* 46 reserved */
2315 ushort reserved47; /* 47 reserved */
2316 ushort reserved48; /* 48 reserved */
2317 ushort reserved49; /* 49 reserved */
2318 ushort reserved50; /* 50 reserved */
2319 ushort reserved51; /* 51 reserved */
2320 ushort reserved52; /* 52 reserved */
2321 ushort reserved53; /* 53 reserved */
2322 ushort reserved54; /* 54 reserved */
2323 ushort reserved55; /* 55 reserved */
2324 ushort cisptr_lsw; /* 56 CIS PTR LSW */
2325 ushort cisprt_msw; /* 57 CIS PTR MSW */
2326 ushort subsysvid; /* 58 SubSystem Vendor ID */
2327 ushort subsysid; /* 59 SubSystem ID */
2328 ushort reserved60; /* 60 reserved */
2329 ushort reserved61; /* 61 reserved */
2330 ushort reserved62; /* 62 reserved */
2331 ushort reserved63; /* 63 reserved */
2332 } ADVEEP_38C1600_CONFIG;
2337 #define ASC_EEP_CMD_DONE 0x0200
2338 #define ASC_EEP_CMD_DONE_ERR 0x0001
2341 #define EEP_CFG_WORD_BIG_ENDIAN 0x8000
2344 #define BIOS_CTRL_BIOS 0x0001
2345 #define BIOS_CTRL_EXTENDED_XLAT 0x0002
2346 #define BIOS_CTRL_GT_2_DISK 0x0004
2347 #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
2348 #define BIOS_CTRL_BOOTABLE_CD 0x0010
2349 #define BIOS_CTRL_MULTIPLE_LUN 0x0040
2350 #define BIOS_CTRL_DISPLAY_MSG 0x0080
2351 #define BIOS_CTRL_NO_SCAM 0x0100
2352 #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
2353 #define BIOS_CTRL_INIT_VERBOSE 0x0800
2354 #define BIOS_CTRL_SCSI_PARITY 0x1000
2355 #define BIOS_CTRL_AIPP_DIS 0x2000
2357 #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
2358 #define ADV_3550_IOLEN 0x40 /* I/O Port Range in bytes */
2360 #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
2361 #define ADV_38C0800_IOLEN 0x100 /* I/O Port Range in bytes */
2364 * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
2365 * a special 16K Adv Library and Microcode version. After the issue is
2366 * resolved, should restore 32K support.
2368 * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
2370 #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
2371 #define ADV_38C1600_IOLEN 0x100 /* I/O Port Range 256 bytes */
2372 #define ADV_38C1600_MEMLEN 0x1000 /* Memory Range 4KB bytes */
2375 * Byte I/O register address from base of 'iop_base'.
2377 #define IOPB_INTR_STATUS_REG 0x00
2378 #define IOPB_CHIP_ID_1 0x01
2379 #define IOPB_INTR_ENABLES 0x02
2380 #define IOPB_CHIP_TYPE_REV 0x03
2381 #define IOPB_RES_ADDR_4 0x04
2382 #define IOPB_RES_ADDR_5 0x05
2383 #define IOPB_RAM_DATA 0x06
2384 #define IOPB_RES_ADDR_7 0x07
2385 #define IOPB_FLAG_REG 0x08
2386 #define IOPB_RES_ADDR_9 0x09
2387 #define IOPB_RISC_CSR 0x0A
2388 #define IOPB_RES_ADDR_B 0x0B
2389 #define IOPB_RES_ADDR_C 0x0C
2390 #define IOPB_RES_ADDR_D 0x0D
2391 #define IOPB_SOFT_OVER_WR 0x0E
2392 #define IOPB_RES_ADDR_F 0x0F
2393 #define IOPB_MEM_CFG 0x10
2394 #define IOPB_RES_ADDR_11 0x11
2395 #define IOPB_GPIO_DATA 0x12
2396 #define IOPB_RES_ADDR_13 0x13
2397 #define IOPB_FLASH_PAGE 0x14
2398 #define IOPB_RES_ADDR_15 0x15
2399 #define IOPB_GPIO_CNTL 0x16
2400 #define IOPB_RES_ADDR_17 0x17
2401 #define IOPB_FLASH_DATA 0x18
2402 #define IOPB_RES_ADDR_19 0x19
2403 #define IOPB_RES_ADDR_1A 0x1A
2404 #define IOPB_RES_ADDR_1B 0x1B
2405 #define IOPB_RES_ADDR_1C 0x1C
2406 #define IOPB_RES_ADDR_1D 0x1D
2407 #define IOPB_RES_ADDR_1E 0x1E
2408 #define IOPB_RES_ADDR_1F 0x1F
2409 #define IOPB_DMA_CFG0 0x20
2410 #define IOPB_DMA_CFG1 0x21
2411 #define IOPB_TICKLE 0x22
2412 #define IOPB_DMA_REG_WR 0x23
2413 #define IOPB_SDMA_STATUS 0x24
2414 #define IOPB_SCSI_BYTE_CNT 0x25
2415 #define IOPB_HOST_BYTE_CNT 0x26
2416 #define IOPB_BYTE_LEFT_TO_XFER 0x27
2417 #define IOPB_BYTE_TO_XFER_0 0x28
2418 #define IOPB_BYTE_TO_XFER_1 0x29
2419 #define IOPB_BYTE_TO_XFER_2 0x2A
2420 #define IOPB_BYTE_TO_XFER_3 0x2B
2421 #define IOPB_ACC_GRP 0x2C
2422 #define IOPB_RES_ADDR_2D 0x2D
2423 #define IOPB_DEV_ID 0x2E
2424 #define IOPB_RES_ADDR_2F 0x2F
2425 #define IOPB_SCSI_DATA 0x30
2426 #define IOPB_RES_ADDR_31 0x31
2427 #define IOPB_RES_ADDR_32 0x32
2428 #define IOPB_SCSI_DATA_HSHK 0x33
2429 #define IOPB_SCSI_CTRL 0x34
2430 #define IOPB_RES_ADDR_35 0x35
2431 #define IOPB_RES_ADDR_36 0x36
2432 #define IOPB_RES_ADDR_37 0x37
2433 #define IOPB_RAM_BIST 0x38
2434 #define IOPB_PLL_TEST 0x39
2435 #define IOPB_PCI_INT_CFG 0x3A
2436 #define IOPB_RES_ADDR_3B 0x3B
2437 #define IOPB_RFIFO_CNT 0x3C
2438 #define IOPB_RES_ADDR_3D 0x3D
2439 #define IOPB_RES_ADDR_3E 0x3E
2440 #define IOPB_RES_ADDR_3F 0x3F
2443 * Word I/O register address from base of 'iop_base'.
2445 #define IOPW_CHIP_ID_0 0x00 /* CID0 */
2446 #define IOPW_CTRL_REG 0x02 /* CC */
2447 #define IOPW_RAM_ADDR 0x04 /* LA */
2448 #define IOPW_RAM_DATA 0x06 /* LD */
2449 #define IOPW_RES_ADDR_08 0x08
2450 #define IOPW_RISC_CSR 0x0A /* CSR */
2451 #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
2452 #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
2453 #define IOPW_RES_ADDR_10 0x10
2454 #define IOPW_SEL_MASK 0x12 /* SM */
2455 #define IOPW_RES_ADDR_14 0x14
2456 #define IOPW_FLASH_ADDR 0x16 /* FA */
2457 #define IOPW_RES_ADDR_18 0x18
2458 #define IOPW_EE_CMD 0x1A /* EC */
2459 #define IOPW_EE_DATA 0x1C /* ED */
2460 #define IOPW_SFIFO_CNT 0x1E /* SFC */
2461 #define IOPW_RES_ADDR_20 0x20
2462 #define IOPW_Q_BASE 0x22 /* QB */
2463 #define IOPW_QP 0x24 /* QP */
2464 #define IOPW_IX 0x26 /* IX */
2465 #define IOPW_SP 0x28 /* SP */
2466 #define IOPW_PC 0x2A /* PC */
2467 #define IOPW_RES_ADDR_2C 0x2C
2468 #define IOPW_RES_ADDR_2E 0x2E
2469 #define IOPW_SCSI_DATA 0x30 /* SD */
2470 #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
2471 #define IOPW_SCSI_CTRL 0x34 /* SC */
2472 #define IOPW_HSHK_CFG 0x36 /* HCFG */
2473 #define IOPW_SXFR_STATUS 0x36 /* SXS */
2474 #define IOPW_SXFR_CNTL 0x38 /* SXL */
2475 #define IOPW_SXFR_CNTH 0x3A /* SXH */
2476 #define IOPW_RES_ADDR_3C 0x3C
2477 #define IOPW_RFIFO_DATA 0x3E /* RFD */
2480 * Doubleword I/O register address from base of 'iop_base'.
2482 #define IOPDW_RES_ADDR_0 0x00
2483 #define IOPDW_RAM_DATA 0x04
2484 #define IOPDW_RES_ADDR_8 0x08
2485 #define IOPDW_RES_ADDR_C 0x0C
2486 #define IOPDW_RES_ADDR_10 0x10
2487 #define IOPDW_COMMA 0x14
2488 #define IOPDW_COMMB 0x18
2489 #define IOPDW_RES_ADDR_1C 0x1C
2490 #define IOPDW_SDMA_ADDR0 0x20
2491 #define IOPDW_SDMA_ADDR1 0x24
2492 #define IOPDW_SDMA_COUNT 0x28
2493 #define IOPDW_SDMA_ERROR 0x2C
2494 #define IOPDW_RDMA_ADDR0 0x30
2495 #define IOPDW_RDMA_ADDR1 0x34
2496 #define IOPDW_RDMA_COUNT 0x38
2497 #define IOPDW_RDMA_ERROR 0x3C
2499 #define ADV_CHIP_ID_BYTE 0x25
2500 #define ADV_CHIP_ID_WORD 0x04C1
2502 #define ADV_SC_SCSI_BUS_RESET 0x2000
2504 #define ADV_INTR_ENABLE_HOST_INTR 0x01
2505 #define ADV_INTR_ENABLE_SEL_INTR 0x02
2506 #define ADV_INTR_ENABLE_DPR_INTR 0x04
2507 #define ADV_INTR_ENABLE_RTA_INTR 0x08
2508 #define ADV_INTR_ENABLE_RMA_INTR 0x10
2509 #define ADV_INTR_ENABLE_RST_INTR 0x20
2510 #define ADV_INTR_ENABLE_DPE_INTR 0x40
2511 #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
2513 #define ADV_INTR_STATUS_INTRA 0x01
2514 #define ADV_INTR_STATUS_INTRB 0x02
2515 #define ADV_INTR_STATUS_INTRC 0x04
2517 #define ADV_RISC_CSR_STOP (0x0000)
2518 #define ADV_RISC_TEST_COND (0x2000)
2519 #define ADV_RISC_CSR_RUN (0x4000)
2520 #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
2522 #define ADV_CTRL_REG_HOST_INTR 0x0100
2523 #define ADV_CTRL_REG_SEL_INTR 0x0200
2524 #define ADV_CTRL_REG_DPR_INTR 0x0400
2525 #define ADV_CTRL_REG_RTA_INTR 0x0800
2526 #define ADV_CTRL_REG_RMA_INTR 0x1000
2527 #define ADV_CTRL_REG_RES_BIT14 0x2000
2528 #define ADV_CTRL_REG_DPE_INTR 0x4000
2529 #define ADV_CTRL_REG_POWER_DONE 0x8000
2530 #define ADV_CTRL_REG_ANY_INTR 0xFF00
2532 #define ADV_CTRL_REG_CMD_RESET 0x00C6
2533 #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
2534 #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
2535 #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
2536 #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
2538 #define ADV_TICKLE_NOP 0x00
2539 #define ADV_TICKLE_A 0x01
2540 #define ADV_TICKLE_B 0x02
2541 #define ADV_TICKLE_C 0x03
2543 #define ADV_SCSI_CTRL_RSTOUT 0x2000
2545 #define AdvIsIntPending(port) \
2546 (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
2549 * SCSI_CFG0 Register bit definitions
2551 #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
2552 #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
2553 #define EVEN_PARITY 0x1000 /* Select Even Parity */
2554 #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
2555 #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
2556 #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
2557 #define SCAM_EN 0x0080 /* Enable SCAM selection */
2558 #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
2559 #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
2560 #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
2561 #define OUR_ID 0x000F /* SCSI ID */
2564 * SCSI_CFG1 Register bit definitions
2566 #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
2567 #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
2568 #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
2569 #define FILTER_SEL 0x0C00 /* Filter Period Selection */
2570 #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
2571 #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
2572 #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
2573 #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
2574 #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
2575 #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
2576 #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
2577 #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
2578 #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
2579 #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
2580 #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
2583 * Addendum for ASC-38C0800 Chip
2585 * The ASC-38C1600 Chip uses the same definitions except that the
2586 * bus mode override bits [12:10] have been moved to byte register
2587 * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
2588 * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
2589 * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
2590 * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
2591 * and [1:0]. Bits [14], [7:6], [3:2] are unused.
2593 #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
2594 #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
2595 #define HVD 0x1000 /* HVD Device Detect */
2596 #define LVD 0x0800 /* LVD Device Detect */
2597 #define SE 0x0400 /* SE Device Detect */
2598 #define TERM_LVD 0x00C0 /* LVD Termination Bits */
2599 #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
2600 #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
2601 #define TERM_SE 0x0030 /* SE Termination Bits */
2602 #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
2603 #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
2604 #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
2605 #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
2606 #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
2607 #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
2608 #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
2609 #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
2611 #define CABLE_ILLEGAL_A 0x7
2612 /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
2614 #define CABLE_ILLEGAL_B 0xB
2615 /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
2618 * MEM_CFG Register bit definitions
2620 #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
2621 #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
2622 #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
2623 #define RAM_SZ_2KB 0x00 /* 2 KB */
2624 #define RAM_SZ_4KB 0x04 /* 4 KB */
2625 #define RAM_SZ_8KB 0x08 /* 8 KB */
2626 #define RAM_SZ_16KB 0x0C /* 16 KB */
2627 #define RAM_SZ_32KB 0x10 /* 32 KB */
2628 #define RAM_SZ_64KB 0x14 /* 64 KB */
2631 * DMA_CFG0 Register bit definitions
2633 * This register is only accessible to the host.
2635 #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
2636 #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
2637 #define FIFO_THRESH_16B 0x00 /* 16 bytes */
2638 #define FIFO_THRESH_32B 0x20 /* 32 bytes */
2639 #define FIFO_THRESH_48B 0x30 /* 48 bytes */
2640 #define FIFO_THRESH_64B 0x40 /* 64 bytes */
2641 #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
2642 #define FIFO_THRESH_96B 0x60 /* 96 bytes */
2643 #define FIFO_THRESH_112B 0x70 /* 112 bytes */
2644 #define START_CTL 0x0C /* DMA start conditions */
2645 #define START_CTL_TH 0x00 /* Wait threshold level (default) */
2646 #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
2647 #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
2648 #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
2649 #define READ_CMD 0x03 /* Memory Read Method */
2650 #define READ_CMD_MR 0x00 /* Memory Read */
2651 #define READ_CMD_MRL 0x02 /* Memory Read Long */
2652 #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
2655 * ASC-38C0800 RAM BIST Register bit definitions
2657 #define RAM_TEST_MODE 0x80
2658 #define PRE_TEST_MODE 0x40
2659 #define NORMAL_MODE 0x00
2660 #define RAM_TEST_DONE 0x10
2661 #define RAM_TEST_STATUS 0x0F
2662 #define RAM_TEST_HOST_ERROR 0x08
2663 #define RAM_TEST_INTRAM_ERROR 0x04
2664 #define RAM_TEST_RISC_ERROR 0x02
2665 #define RAM_TEST_SCSI_ERROR 0x01
2666 #define RAM_TEST_SUCCESS 0x00
2667 #define PRE_TEST_VALUE 0x05
2668 #define NORMAL_VALUE 0x00
2671 * ASC38C1600 Definitions
2673 * IOPB_PCI_INT_CFG Bit Field Definitions
2676 #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
2679 * Bit 1 can be set to change the interrupt for the Function to operate in
2680 * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
2681 * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
2682 * mode, otherwise the operating mode is undefined.
2684 #define TOTEMPOLE 0x02
2687 * Bit 0 can be used to change the Int Pin for the Function. The value is
2688 * 0 by default for both Functions with Function 0 using INT A and Function
2689 * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
2692 * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
2693 * value specified in the PCI Configuration Space.
2700 * Adv Library Status Definitions
2704 #define ADV_NOERROR 1
2705 #define ADV_SUCCESS 1
2707 #define ADV_ERROR (-1)
2710 * ADV_DVC_VAR 'warn_code' values
2712 #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
2713 #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
2714 #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
2715 #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080 /* PCI config space set error */
2716 #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
2718 #define ADV_MAX_TID 15 /* max. target identifier */
2719 #define ADV_MAX_LUN 7 /* max. logical unit number */
2722 * Error code values are set in ADV_DVC_VAR 'err_code'.
2724 #define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
2725 #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
2726 #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
2727 #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
2728 #define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
2729 #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
2730 #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
2731 #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
2732 #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
2733 #define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
2734 #define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
2735 #define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
2736 #define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
2737 #define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
2740 * Fixed locations of microcode operating variables.
2742 #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
2743 #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
2744 #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
2745 #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
2746 #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
2747 #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
2748 #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
2749 #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
2750 #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
2751 #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
2752 #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
2753 #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
2754 #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
2755 #define ASC_MC_CHIP_TYPE 0x009A
2756 #define ASC_MC_INTRB_CODE 0x009B
2757 #define ASC_MC_WDTR_ABLE 0x009C
2758 #define ASC_MC_SDTR_ABLE 0x009E
2759 #define ASC_MC_TAGQNG_ABLE 0x00A0
2760 #define ASC_MC_DISC_ENABLE 0x00A2
2761 #define ASC_MC_IDLE_CMD_STATUS 0x00A4
2762 #define ASC_MC_IDLE_CMD 0x00A6
2763 #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
2764 #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
2765 #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
2766 #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
2767 #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
2768 #define ASC_MC_SDTR_DONE 0x00B6
2769 #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
2770 #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
2771 #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
2772 #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
2773 #define ASC_MC_WDTR_DONE 0x0124
2774 #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
2775 #define ASC_MC_ICQ 0x0160
2776 #define ASC_MC_IRQ 0x0164
2777 #define ASC_MC_PPR_ABLE 0x017A
2780 * BIOS LRAM variable absolute offsets.
2782 #define BIOS_CODESEG 0x54
2783 #define BIOS_CODELEN 0x56
2784 #define BIOS_SIGNATURE 0x58
2785 #define BIOS_VERSION 0x5A
2788 * Microcode Control Flags
2790 * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
2791 * and handled by the microcode.
2793 #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
2794 #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
2797 * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
2799 #define HSHK_CFG_WIDE_XFR 0x8000
2800 #define HSHK_CFG_RATE 0x0F00
2801 #define HSHK_CFG_OFFSET 0x001F
2803 #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
2804 #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
2805 #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
2806 #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
2808 #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
2809 #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
2810 #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
2811 #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
2812 #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
2814 #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
2815 #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
2816 #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
2817 #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
2818 #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
2820 * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
2821 * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
2823 #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
2824 #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
2827 * All fields here are accessed by the board microcode and need to be
2830 typedef struct adv_carr_t {
2831 ADV_VADDR carr_va; /* Carrier Virtual Address */
2832 ADV_PADDR carr_pa; /* Carrier Physical Address */
2833 ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
2835 * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
2837 * next_vpa [3:1] Reserved Bits
2838 * next_vpa [0] Done Flag set in Response Queue.
2844 * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
2846 #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
2848 #define ASC_RQ_DONE 0x00000001
2849 #define ASC_RQ_GOOD 0x00000002
2850 #define ASC_CQ_STOPPER 0x00000000
2852 #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
2854 #define ADV_CARRIER_NUM_PAGE_CROSSING \
2855 (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
2856 (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
2858 #define ADV_CARRIER_BUFSIZE \
2859 ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
2862 * ASC_SCSI_REQ_Q 'a_flag' definitions
2864 * The Adv Library should limit use to the lower nibble (4 bits) of
2865 * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
2867 #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
2868 #define ADV_SCSIQ_DONE 0x02 /* request done */
2869 #define ADV_DONT_RETRY 0x08 /* don't do retry */
2871 #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
2872 #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
2873 #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
2876 * Adapter temporary configuration structure
2878 * This structure can be discarded after initialization. Don't add
2879 * fields here needed after initialization.
2881 * Field naming convention:
2883 * *_enable indicates the field enables or disables a feature. The
2884 * value of the field is never reset.
2886 typedef struct adv_dvc_cfg {
2887 ushort disc_enable; /* enable disconnection */
2888 uchar chip_version; /* chip version */
2889 uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
2890 ushort lib_version; /* Adv Library version number */
2891 ushort control_flag; /* Microcode Control Flag */
2892 ushort mcode_date; /* Microcode date */
2893 ushort mcode_version; /* Microcode version */
2894 ushort pci_slot_info; /* high byte device/function number */
2895 /* bits 7-3 device num., bits 2-0 function num. */
2896 /* low byte bus num. */
2897 ushort serial1; /* EEPROM serial number word 1 */
2898 ushort serial2; /* EEPROM serial number word 2 */
2899 ushort serial3; /* EEPROM serial number word 3 */
2900 struct device *dev; /* pointer to the pci dev structure for this board */
2904 struct adv_scsi_req_q;
2906 typedef void (*ADV_ISR_CALLBACK)
2907 (struct adv_dvc_var *, struct adv_scsi_req_q *);
2909 typedef void (*ADV_ASYNC_CALLBACK)
2910 (struct adv_dvc_var *, uchar);
2913 * Adapter operation variable structure.
2915 * One structure is required per host adapter.
2917 * Field naming convention:
2919 * *_able indicates both whether a feature should be enabled or disabled
2920 * and whether a device isi capable of the feature. At initialization
2921 * this field may be set, but later if a device is found to be incapable
2922 * of the feature, the field is cleared.
2924 typedef struct adv_dvc_var {
2925 AdvPortAddr iop_base; /* I/O port address */
2926 ushort err_code; /* fatal error code */
2927 ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
2928 ADV_ISR_CALLBACK isr_callback;
2929 ADV_ASYNC_CALLBACK async_callback;
2930 ushort wdtr_able; /* try WDTR for a device */
2931 ushort sdtr_able; /* try SDTR for a device */
2932 ushort ultra_able; /* try SDTR Ultra speed for a device */
2933 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
2934 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
2935 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
2936 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
2937 ushort tagqng_able; /* try tagged queuing with a device */
2938 ushort ppr_able; /* PPR message capable per TID bitmask. */
2939 uchar max_dvc_qng; /* maximum number of tagged commands per device */
2940 ushort start_motor; /* start motor command allowed */
2941 uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
2942 uchar chip_no; /* should be assigned by caller */
2943 uchar max_host_qng; /* maximum number of Q'ed command allowed */
2944 uchar irq_no; /* IRQ number */
2945 ushort no_scam; /* scam_tolerant of EEPROM */
2946 struct asc_board *drv_ptr; /* driver pointer to private structure */
2947 uchar chip_scsi_id; /* chip SCSI target ID */
2949 uchar bist_err_code;
2950 ADV_CARR_T *carrier_buf;
2951 ADV_CARR_T *carr_freelist; /* Carrier free list. */
2952 ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
2953 ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
2954 ushort carr_pending_cnt; /* Count of pending carriers. */
2956 * Note: The following fields will not be used after initialization. The
2957 * driver may discard the buffer after initialization is done.
2959 ADV_DVC_CFG *cfg; /* temporary configuration structure */
2962 #define NO_OF_SG_PER_BLOCK 15
2964 typedef struct asc_sg_block {
2968 uchar sg_cnt; /* Valid entries in block. */
2969 ADV_PADDR sg_ptr; /* Pointer to next sg block. */
2971 ADV_PADDR sg_addr; /* SG element address. */
2972 ADV_DCNT sg_count; /* SG element count. */
2973 } sg_list[NO_OF_SG_PER_BLOCK];
2977 * ADV_SCSI_REQ_Q - microcode request structure
2979 * All fields in this structure up to byte 60 are used by the microcode.
2980 * The microcode makes assumptions about the size and ordering of fields
2981 * in this structure. Do not change the structure definition here without
2982 * coordinating the change with the microcode.
2984 * All fields accessed by microcode must be maintained in little_endian
2987 typedef struct adv_scsi_req_q {
2988 uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
2990 uchar target_id; /* Device target identifier. */
2991 uchar target_lun; /* Device target logical unit number. */
2992 ADV_PADDR data_addr; /* Data buffer physical address. */
2993 ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
2994 ADV_PADDR sense_addr;
2998 uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
3000 uchar done_status; /* Completion status. */
3001 uchar scsi_status; /* SCSI status byte. */
3002 uchar host_status; /* Ucode host status. */
3003 uchar sg_working_ix;
3004 uchar cdb[12]; /* SCSI CDB bytes 0-11. */
3005 ADV_PADDR sg_real_addr; /* SG list physical address. */
3006 ADV_PADDR scsiq_rptr;
3007 uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
3008 ADV_VADDR scsiq_ptr;
3011 * End of microcode structure - 60 bytes. The rest of the structure
3012 * is used by the Adv Library and ignored by the microcode.
3015 ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
3016 char *vdata_addr; /* Data buffer virtual address. */
3018 uchar pad[2]; /* Pad out to a word boundary. */
3022 * Microcode idle loop commands
3024 #define IDLE_CMD_COMPLETED 0
3025 #define IDLE_CMD_STOP_CHIP 0x0001
3026 #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
3027 #define IDLE_CMD_SEND_INT 0x0004
3028 #define IDLE_CMD_ABORT 0x0008
3029 #define IDLE_CMD_DEVICE_RESET 0x0010
3030 #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
3031 #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
3032 #define IDLE_CMD_SCSIREQ 0x0080
3034 #define IDLE_CMD_STATUS_SUCCESS 0x0001
3035 #define IDLE_CMD_STATUS_FAILURE 0x0002
3038 * AdvSendIdleCmd() flag definitions.
3040 #define ADV_NOWAIT 0x01
3043 * Wait loop time out values.
3045 #define SCSI_WAIT_10_SEC 10UL /* 10 seconds */
3046 #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
3047 #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
3048 #define SCSI_MS_PER_SEC 1000UL /* milliseconds per second */
3049 #define SCSI_MAX_RETRY 10 /* retry count */
3051 #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
3052 #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
3053 #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
3054 #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
3056 #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
3059 * Device drivers must define the following functions.
3061 static inline ulong DvcEnterCritical(void);
3062 static inline void DvcLeaveCritical(ulong);
3063 static void DvcSleepMilliSecond(ADV_DCNT);
3064 static ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *,
3065 uchar *, ASC_SDCNT *, int);
3066 static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
3069 * Adv Library functions available to drivers.
3071 static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
3072 static int AdvISR(ADV_DVC_VAR *);
3073 static int AdvInitGetConfig(ADV_DVC_VAR *);
3074 static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
3075 static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
3076 static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
3077 static int AdvResetChipAndSB(ADV_DVC_VAR *);
3078 static int AdvResetSB(ADV_DVC_VAR *asc_dvc);
3081 * Internal Adv Library functions.
3083 static int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT);
3084 static void AdvInquiryHandling(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
3085 static int AdvInitFrom3550EEP(ADV_DVC_VAR *);
3086 static int AdvInitFrom38C0800EEP(ADV_DVC_VAR *);
3087 static int AdvInitFrom38C1600EEP(ADV_DVC_VAR *);
3088 static ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
3089 static void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
3090 static ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
3091 static void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
3092 static ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
3093 static void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
3094 static void AdvWaitEEPCmd(AdvPortAddr);
3095 static ushort AdvReadEEPWord(AdvPortAddr, int);
3097 /* Read byte from a register. */
3098 #define AdvReadByteRegister(iop_base, reg_off) \
3099 (ADV_MEM_READB((iop_base) + (reg_off)))
3101 /* Write byte to a register. */
3102 #define AdvWriteByteRegister(iop_base, reg_off, byte) \
3103 (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
3105 /* Read word (2 bytes) from a register. */
3106 #define AdvReadWordRegister(iop_base, reg_off) \
3107 (ADV_MEM_READW((iop_base) + (reg_off)))
3109 /* Write word (2 bytes) to a register. */
3110 #define AdvWriteWordRegister(iop_base, reg_off, word) \
3111 (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
3113 /* Write dword (4 bytes) to a register. */
3114 #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
3115 (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
3117 /* Read byte from LRAM. */
3118 #define AdvReadByteLram(iop_base, addr, byte) \
3120 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
3121 (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
3124 /* Write byte to LRAM. */
3125 #define AdvWriteByteLram(iop_base, addr, byte) \
3126 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
3127 ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
3129 /* Read word (2 bytes) from LRAM. */
3130 #define AdvReadWordLram(iop_base, addr, word) \
3132 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
3133 (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
3136 /* Write word (2 bytes) to LRAM. */
3137 #define AdvWriteWordLram(iop_base, addr, word) \
3138 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
3139 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
3141 /* Write little-endian double word (4 bytes) to LRAM */
3142 /* Because of unspecified C language ordering don't use auto-increment. */
3143 #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
3144 ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
3145 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
3146 cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
3147 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
3148 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
3149 cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
3151 /* Read word (2 bytes) from LRAM assuming that the address is already set. */
3152 #define AdvReadWordAutoIncLram(iop_base) \
3153 (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
3155 /* Write word (2 bytes) to LRAM assuming that the address is already set. */
3156 #define AdvWriteWordAutoIncLram(iop_base, word) \
3157 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
3160 * Define macro to check for Condor signature.
3162 * Evaluate to ADV_TRUE if a Condor chip is found the specified port
3163 * address 'iop_base'. Otherwise evalue to ADV_FALSE.
3165 #define AdvFindSignature(iop_base) \
3166 (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
3167 ADV_CHIP_ID_BYTE) && \
3168 (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
3169 ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
3172 * Define macro to Return the version number of the chip at 'iop_base'.
3174 * The second parameter 'bus_type' is currently unused.
3176 #define AdvGetChipVersion(iop_base, bus_type) \
3177 AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
3180 * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
3181 * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
3183 * If the request has not yet been sent to the device it will simply be
3184 * aborted from RISC memory. If the request is disconnected it will be
3185 * aborted on reselection by sending an Abort Message to the target ID.
3188 * ADV_TRUE(1) - Queue was successfully aborted.
3189 * ADV_FALSE(0) - Queue was not found on the active queue list.
3191 #define AdvAbortQueue(asc_dvc, scsiq) \
3192 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
3196 * Send a Bus Device Reset Message to the specified target ID.
3198 * All outstanding commands will be purged if sending the
3199 * Bus Device Reset Message is successful.
3202 * ADV_TRUE(1) - All requests on the target are purged.
3203 * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
3206 #define AdvResetDevice(asc_dvc, target_id) \
3207 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
3208 (ADV_DCNT) (target_id))
3211 * SCSI Wide Type definition.
3213 #define ADV_SCSI_BIT_ID_TYPE ushort
3216 * AdvInitScsiTarget() 'cntl_flag' options.
3218 #define ADV_SCAN_LUN 0x01
3219 #define ADV_CAPINFO_NOLUN 0x02
3222 * Convert target id to target id bit mask.
3224 #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
3227 * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
3230 #define QD_NO_STATUS 0x00 /* Request not completed yet. */
3231 #define QD_NO_ERROR 0x01
3232 #define QD_ABORTED_BY_HOST 0x02
3233 #define QD_WITH_ERROR 0x04
3235 #define QHSTA_NO_ERROR 0x00
3236 #define QHSTA_M_SEL_TIMEOUT 0x11
3237 #define QHSTA_M_DATA_OVER_RUN 0x12
3238 #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
3239 #define QHSTA_M_QUEUE_ABORTED 0x15
3240 #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
3241 #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
3242 #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
3243 #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
3244 #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
3245 #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
3246 #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
3247 /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
3248 #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
3249 #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
3250 #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
3251 #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
3252 #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
3253 #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
3254 #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
3255 #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
3256 #define QHSTA_M_WTM_TIMEOUT 0x41
3257 #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
3258 #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
3259 #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
3260 #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
3261 #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
3262 #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
3265 * Default EEPROM Configuration structure defined in a_init.c.
3267 static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config;
3268 static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config;
3269 static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config;
3272 * DvcGetPhyAddr() flag arguments
3274 #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
3275 #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
3276 #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
3277 #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
3278 #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
3279 #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
3281 /* Return the address that is aligned at the next doubleword >= to 'addr'. */
3282 #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
3283 #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
3284 #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
3287 * Total contiguous memory needed for driver SG blocks.
3289 * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
3290 * number of scatter-gather elements the driver supports in a
3294 #define ADV_SG_LIST_MAX_BYTE_SIZE \
3295 (sizeof(ADV_SG_BLOCK) * \
3296 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
3299 * Inquiry data structure and bitfield macros
3301 * Using bitfields to access the subchar data isn't portable across
3302 * endianness, so instead mask and shift. Only quantities of more
3303 * than 1 bit are shifted, since the others are just tested for true
3307 #define ADV_INQ_DVC_TYPE(inq) ((inq)->periph & 0x1f)
3308 #define ADV_INQ_QUALIFIER(inq) (((inq)->periph & 0xe0) >> 5)
3309 #define ADV_INQ_DVC_TYPE_MOD(inq) ((inq)->devtype & 0x7f)
3310 #define ADV_INQ_REMOVABLE(inq) ((inq)->devtype & 0x80)
3311 #define ADV_INQ_ANSI_VER(inq) ((inq)->ver & 0x07)
3312 #define ADV_INQ_ECMA_VER(inq) (((inq)->ver & 0x38) >> 3)
3313 #define ADV_INQ_ISO_VER(inq) (((inq)->ver & 0xc0) >> 6)
3314 #define ADV_INQ_RESPONSE_FMT(inq) ((inq)->byte3 & 0x0f)
3315 #define ADV_INQ_TERM_IO(inq) ((inq)->byte3 & 0x40)
3316 #define ADV_INQ_ASYNC_NOTIF(inq) ((inq)->byte3 & 0x80)
3317 #define ADV_INQ_SOFT_RESET(inq) ((inq)->flags & 0x01)
3318 #define ADV_INQ_CMD_QUEUE(inq) ((inq)->flags & 0x02)
3319 #define ADV_INQ_LINK_CMD(inq) ((inq)->flags & 0x08)
3320 #define ADV_INQ_SYNC(inq) ((inq)->flags & 0x10)
3321 #define ADV_INQ_WIDE16(inq) ((inq)->flags & 0x20)
3322 #define ADV_INQ_WIDE32(inq) ((inq)->flags & 0x40)
3323 #define ADV_INQ_REL_ADDR(inq) ((inq)->flags & 0x80)
3324 #define ADV_INQ_INFO_UNIT(inq) ((inq)->info & 0x01)
3325 #define ADV_INQ_QUICK_ARB(inq) ((inq)->info & 0x02)
3326 #define ADV_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
3329 uchar periph; /* peripheral device type [0:4] */
3330 /* peripheral qualifier [5:7] */
3331 uchar devtype; /* device type modifier (for SCSI I) [0:6] */
3332 /* RMB - removable medium bit [7] */
3333 uchar ver; /* ANSI approved version [0:2] */
3334 /* ECMA version [3:5] */
3335 /* ISO version [6:7] */
3336 uchar byte3; /* response data format [0:3] */
3341 /* reserved [4:5] */
3342 /* terminate I/O process bit (see 5.6.22) [6] */
3343 /* asynch. event notification (processor) [7] */
3344 uchar add_len; /* additional length */
3345 uchar res1; /* reserved */
3346 uchar res2; /* reserved */
3347 uchar flags; /* soft reset implemented [0] */
3348 /* command queuing [1] */
3350 /* linked command for this logical unit [3] */
3351 /* synchronous data transfer [4] */
3352 /* wide bus 16 bit data transfer [5] */
3353 /* wide bus 32 bit data transfer [6] */
3354 /* relative addressing mode [7] */
3355 uchar vendor_id[8]; /* vendor identification */
3356 uchar product_id[16]; /* product identification */
3357 uchar product_rev_level[4]; /* product revision level */
3358 uchar vendor_specific[20]; /* vendor specific */
3359 uchar info; /* information unit supported [0] */
3360 /* quick arbitrate supported [1] */
3361 /* clocking field [2:3] */
3362 /* reserved [4:7] */
3363 uchar res3; /* reserved */
3364 } ADV_SCSI_INQUIRY; /* 58 bytes */
3367 * --- Driver Constants and Macros
3370 /* Reference Scsi_Host hostdata */
3371 #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
3373 /* asc_board_t flags */
3374 #define ASC_HOST_IN_RESET 0x01
3375 #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
3376 #define ASC_SELECT_QUEUE_DEPTHS 0x08
3378 #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
3379 #define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
3381 #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
3383 #define ASC_INFO_SIZE 128 /* advansys_info() line size */
3385 #ifdef CONFIG_PROC_FS
3386 /* /proc/scsi/advansys/[0...] related definitions */
3387 #define ASC_PRTBUF_SIZE 2048
3388 #define ASC_PRTLINE_SIZE 160
3390 #define ASC_PRT_NEXT() \
3394 if (leftlen == 0) { \
3399 #endif /* CONFIG_PROC_FS */
3401 /* Asc Library return codes */
3404 #define ASC_NOERROR 1
3406 #define ASC_ERROR (-1)
3408 /* struct scsi_cmnd function return codes */
3409 #define STATUS_BYTE(byte) (byte)
3410 #define MSG_BYTE(byte) ((byte) << 8)
3411 #define HOST_BYTE(byte) ((byte) << 16)
3412 #define DRIVER_BYTE(byte) ((byte) << 24)
3415 * The following definitions and macros are OS independent interfaces to
3416 * the queue functions:
3417 * REQ - SCSI request structure
3418 * REQP - pointer to SCSI request structure
3419 * REQPTID(reqp) - reqp's target id
3420 * REQPNEXT(reqp) - reqp's next pointer
3421 * REQPNEXTP(reqp) - pointer to reqp's next pointer
3422 * REQPTIME(reqp) - reqp's time stamp value
3423 * REQTIMESTAMP() - system time stamp value
3425 typedef struct scsi_cmnd REQ, *REQP;
3426 #define REQPNEXT(reqp) ((REQP) ((reqp)->host_scribble))
3427 #define REQPNEXTP(reqp) ((REQP *) &((reqp)->host_scribble))
3428 #define REQPTID(reqp) ((reqp)->device->id)
3429 #define REQPTIME(reqp) ((reqp)->SCp.this_residual)
3430 #define REQTIMESTAMP() (jiffies)
3432 #define REQTIMESTAT(function, ascq, reqp, tid) \
3435 * If the request time stamp is less than the system time stamp, then \
3436 * maybe the system time stamp wrapped. Set the request time to zero.\
3438 if (REQPTIME(reqp) <= REQTIMESTAMP()) { \
3439 REQPTIME(reqp) = REQTIMESTAMP() - REQPTIME(reqp); \
3441 /* Indicate an error occurred with the assertion. */ \
3442 ASC_ASSERT(REQPTIME(reqp) <= REQTIMESTAMP()); \
3443 REQPTIME(reqp) = 0; \
3445 /* Handle first minimum time case without external initialization. */ \
3446 if (((ascq)->q_tot_cnt[tid] == 1) || \
3447 (REQPTIME(reqp) < (ascq)->q_min_tim[tid])) { \
3448 (ascq)->q_min_tim[tid] = REQPTIME(reqp); \
3449 ASC_DBG3(1, "%s: new q_min_tim[%d] %u\n", \
3450 (function), (tid), (ascq)->q_min_tim[tid]); \
3452 if (REQPTIME(reqp) > (ascq)->q_max_tim[tid]) { \
3453 (ascq)->q_max_tim[tid] = REQPTIME(reqp); \
3454 ASC_DBG3(1, "%s: new q_max_tim[%d] %u\n", \
3455 (function), tid, (ascq)->q_max_tim[tid]); \
3457 (ascq)->q_tot_tim[tid] += REQPTIME(reqp); \
3458 /* Reset the time stamp field. */ \
3459 REQPTIME(reqp) = 0; \
3462 /* asc_enqueue() flags */
3466 /* asc_dequeue_list() argument */
3467 #define ASC_TID_ALL (-1)
3469 /* Return non-zero, if the queue is empty. */
3470 #define ASC_QUEUE_EMPTY(ascq) ((ascq)->q_tidmask == 0)
3472 #ifndef ADVANSYS_STATS
3473 #define ASC_STATS(shost, counter)
3474 #define ASC_STATS_ADD(shost, counter, count)
3475 #else /* ADVANSYS_STATS */
3476 #define ASC_STATS(shost, counter) \
3477 (ASC_BOARDP(shost)->asc_stats.counter++)
3479 #define ASC_STATS_ADD(shost, counter, count) \
3480 (ASC_BOARDP(shost)->asc_stats.counter += (count))
3481 #endif /* ADVANSYS_STATS */
3483 #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
3485 /* If the result wraps when calculating tenths, return 0. */
3486 #define ASC_TENTHS(num, den) \
3487 (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
3488 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
3491 * Display a message to the console.
3493 #define ASC_PRINT(s) \
3495 printk("advansys: "); \
3499 #define ASC_PRINT1(s, a1) \
3501 printk("advansys: "); \
3502 printk((s), (a1)); \
3505 #define ASC_PRINT2(s, a1, a2) \
3507 printk("advansys: "); \
3508 printk((s), (a1), (a2)); \
3511 #define ASC_PRINT3(s, a1, a2, a3) \
3513 printk("advansys: "); \
3514 printk((s), (a1), (a2), (a3)); \
3517 #define ASC_PRINT4(s, a1, a2, a3, a4) \
3519 printk("advansys: "); \
3520 printk((s), (a1), (a2), (a3), (a4)); \
3523 #ifndef ADVANSYS_DEBUG
3525 #define ASC_DBG(lvl, s)
3526 #define ASC_DBG1(lvl, s, a1)
3527 #define ASC_DBG2(lvl, s, a1, a2)
3528 #define ASC_DBG3(lvl, s, a1, a2, a3)
3529 #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
3530 #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
3531 #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
3532 #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
3533 #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
3534 #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
3535 #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
3536 #define ASC_DBG_PRT_HEX(lvl, name, start, length)
3537 #define ASC_DBG_PRT_CDB(lvl, cdb, len)
3538 #define ASC_DBG_PRT_SENSE(lvl, sense, len)
3539 #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
3541 #else /* ADVANSYS_DEBUG */
3544 * Debugging Message Levels:
3546 * 1: High-Level Tracing
3547 * 2-N: Verbose Tracing
3550 #define ASC_DBG(lvl, s) \
3552 if (asc_dbglvl >= (lvl)) { \
3557 #define ASC_DBG1(lvl, s, a1) \
3559 if (asc_dbglvl >= (lvl)) { \
3560 printk((s), (a1)); \
3564 #define ASC_DBG2(lvl, s, a1, a2) \
3566 if (asc_dbglvl >= (lvl)) { \
3567 printk((s), (a1), (a2)); \
3571 #define ASC_DBG3(lvl, s, a1, a2, a3) \
3573 if (asc_dbglvl >= (lvl)) { \
3574 printk((s), (a1), (a2), (a3)); \
3578 #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
3580 if (asc_dbglvl >= (lvl)) { \
3581 printk((s), (a1), (a2), (a3), (a4)); \
3585 #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
3587 if (asc_dbglvl >= (lvl)) { \
3588 asc_prt_scsi_host(s); \
3592 #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
3594 if (asc_dbglvl >= (lvl)) { \
3595 asc_prt_scsi_cmnd(s); \
3599 #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
3601 if (asc_dbglvl >= (lvl)) { \
3602 asc_prt_asc_scsi_q(scsiqp); \
3606 #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
3608 if (asc_dbglvl >= (lvl)) { \
3609 asc_prt_asc_qdone_info(qdone); \
3613 #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
3615 if (asc_dbglvl >= (lvl)) { \
3616 asc_prt_adv_scsi_req_q(scsiqp); \
3620 #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
3622 if (asc_dbglvl >= (lvl)) { \
3623 asc_prt_hex((name), (start), (length)); \
3627 #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
3628 ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
3630 #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
3631 ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
3633 #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
3634 ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
3635 #endif /* ADVANSYS_DEBUG */
3637 #ifndef ADVANSYS_ASSERT
3638 #define ASC_ASSERT(a)
3639 #else /* ADVANSYS_ASSERT */
3641 #define ASC_ASSERT(a) \
3644 printk("ASC_ASSERT() Failure: file %s, line %d\n", \
3645 __FILE__, __LINE__); \
3649 #endif /* ADVANSYS_ASSERT */
3652 * --- Driver Structures
3655 #ifdef ADVANSYS_STATS
3657 /* Per board statistics structure */
3659 /* Driver Entrypoint Statistics */
3660 ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
3661 ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
3662 ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
3663 ADV_DCNT interrupt; /* # advansys_interrupt() calls */
3664 ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
3665 ADV_DCNT done; /* # calls to request's scsi_done function */
3666 ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
3667 ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
3668 ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
3669 /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
3670 ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
3671 ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
3672 ADV_DCNT exe_error; /* # ASC_ERROR returns. */
3673 ADV_DCNT exe_unknown; /* # unknown returns. */
3674 /* Data Transfer Statistics */
3675 ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
3676 ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
3677 ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
3678 ADV_DCNT sg_elem; /* # scatter-gather elements */
3679 ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
3681 #endif /* ADVANSYS_STATS */
3684 * Request queuing structure
3686 typedef struct asc_queue {
3687 ADV_SCSI_BIT_ID_TYPE q_tidmask; /* queue mask */
3688 REQP q_first[ADV_MAX_TID + 1]; /* first queued request */
3689 REQP q_last[ADV_MAX_TID + 1]; /* last queued request */
3690 #ifdef ADVANSYS_STATS
3691 short q_cur_cnt[ADV_MAX_TID + 1]; /* current queue count */
3692 short q_max_cnt[ADV_MAX_TID + 1]; /* maximum queue count */
3693 ADV_DCNT q_tot_cnt[ADV_MAX_TID + 1]; /* total enqueue count */
3694 ADV_DCNT q_tot_tim[ADV_MAX_TID + 1]; /* total time queued */
3695 ushort q_max_tim[ADV_MAX_TID + 1]; /* maximum time queued */
3696 ushort q_min_tim[ADV_MAX_TID + 1]; /* minimum time queued */
3697 #endif /* ADVANSYS_STATS */
3701 * Adv Library Request Structures
3703 * The following two structures are used to process Wide Board requests.
3705 * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
3706 * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
3707 * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
3708 * Mid-Level SCSI request structure.
3710 * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
3711 * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
3712 * up to 255 scatter-gather elements may be used per request or
3715 * Both structures must be 32 byte aligned.
3717 typedef struct adv_sgblk {
3718 ADV_SG_BLOCK sg_block; /* Sgblock structure. */
3719 uchar align[32]; /* Sgblock structure padding. */
3720 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
3723 typedef struct adv_req {
3724 ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
3725 uchar align[32]; /* Request structure padding. */
3726 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
3727 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
3728 struct adv_req *next_reqp; /* Next Request Structure. */
3732 * Structure allocated for each board.
3734 * This structure is allocated by scsi_host_alloc() at the end
3735 * of the 'Scsi_Host' structure starting at the 'hostdata'
3736 * field. It is guaranteed to be allocated from DMA-able memory.
3738 typedef struct asc_board {
3739 int id; /* Board Id */
3740 uint flags; /* Board flags */
3742 ASC_DVC_VAR asc_dvc_var; /* Narrow board */
3743 ADV_DVC_VAR adv_dvc_var; /* Wide board */
3746 ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
3747 ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
3749 ushort asc_n_io_port; /* Number I/O ports. */
3750 asc_queue_t active; /* Active command queue */
3751 asc_queue_t waiting; /* Waiting command queue */
3752 asc_queue_t done; /* Done command queue */
3753 ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
3754 struct scsi_device *device[ADV_MAX_TID + 1]; /* Mid-Level Scsi Device */
3755 ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
3756 ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
3757 ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
3759 ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
3760 ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
3761 ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
3762 ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
3764 ulong last_reset; /* Saved last reset time */
3765 spinlock_t lock; /* Board spinlock */
3766 /* /proc/scsi/advansys/[0...] */
3767 char *prtbuf; /* /proc print buffer */
3768 #ifdef ADVANSYS_STATS
3769 struct asc_stats asc_stats; /* Board statistics */
3770 #endif /* ADVANSYS_STATS */
3772 * The following fields are used only for Narrow Boards.
3774 /* The following three structures must be in DMA-able memory. */
3775 ASC_SCSI_REQ_Q scsireqq;
3776 ASC_CAP_INFO cap_info;
3777 ASC_SCSI_INQUIRY inquiry;
3778 uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
3780 * The following fields are used only for Wide Boards.
3782 void __iomem *ioremap_addr; /* I/O Memory remap address. */
3783 ushort ioport; /* I/O Port address. */
3784 ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
3785 adv_req_t *orig_reqp; /* adv_req_t memory block. */
3786 adv_req_t *adv_reqp; /* Request structures. */
3787 adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
3788 ushort bios_signature; /* BIOS Signature. */
3789 ushort bios_version; /* BIOS Version. */
3790 ushort bios_codeseg; /* BIOS Code Segment. */
3791 ushort bios_codelen; /* BIOS Code Segment Length. */
3794 /* Number of boards detected in system. */
3795 static int asc_board_count;
3797 /* Overrun buffer used by all narrow boards. */
3798 static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
3801 * Global structures required to issue a command.
3803 static ASC_SCSI_Q asc_scsi_q = { {0} };
3804 static ASC_SG_HEAD asc_sg_head = { 0 };
3806 #ifdef ADVANSYS_DEBUG
3807 static int asc_dbglvl = 3;
3808 #endif /* ADVANSYS_DEBUG */
3811 * --- Driver Function Prototypes
3813 * advansys.h contains function prototypes for functions global to Linux.
3816 static int advansys_slave_configure(struct scsi_device *);
3817 static void asc_scsi_done_list(struct scsi_cmnd *);
3818 static int asc_execute_scsi_cmnd(struct scsi_cmnd *);
3819 static int asc_build_req(asc_board_t *, struct scsi_cmnd *);
3820 static int adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **);
3821 static int adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int);
3822 static void asc_isr_callback(ASC_DVC_VAR *, ASC_QDONE_INFO *);
3823 static void adv_isr_callback(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
3824 static void adv_async_callback(ADV_DVC_VAR *, uchar);
3825 static void asc_enqueue(asc_queue_t *, REQP, int);
3826 static REQP asc_dequeue(asc_queue_t *, int);
3827 static REQP asc_dequeue_list(asc_queue_t *, REQP *, int);
3828 static int asc_rmqueue(asc_queue_t *, REQP);
3829 static void asc_execute_queue(asc_queue_t *);
3830 #ifdef CONFIG_PROC_FS
3831 static int asc_proc_copy(off_t, off_t, char *, int, char *, int);
3832 static int asc_prt_board_devices(struct Scsi_Host *, char *, int);
3833 static int asc_prt_adv_bios(struct Scsi_Host *, char *, int);
3834 static int asc_get_eeprom_string(ushort *serialnum, uchar *cp);
3835 static int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int);
3836 static int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int);
3837 static int asc_prt_driver_conf(struct Scsi_Host *, char *, int);
3838 static int asc_prt_asc_board_info(struct Scsi_Host *, char *, int);
3839 static int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
3840 static int asc_prt_line(char *, int, char *fmt, ...);
3841 #endif /* CONFIG_PROC_FS */
3843 /* Declaration for Asc Library internal functions referenced by driver. */
3844 static int AscFindSignature(PortAddr);
3845 static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
3847 /* Statistics function prototypes. */
3848 #ifdef ADVANSYS_STATS
3849 #ifdef CONFIG_PROC_FS
3850 static int asc_prt_board_stats(struct Scsi_Host *, char *, int);
3851 static int asc_prt_target_stats(struct Scsi_Host *, int, char *, int);
3852 #endif /* CONFIG_PROC_FS */
3853 #endif /* ADVANSYS_STATS */
3855 /* Debug function prototypes. */
3856 #ifdef ADVANSYS_DEBUG
3857 static void asc_prt_scsi_host(struct Scsi_Host *);
3858 static void asc_prt_scsi_cmnd(struct scsi_cmnd *);
3859 static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
3860 static void asc_prt_asc_dvc_var(ASC_DVC_VAR *);
3861 static void asc_prt_asc_scsi_q(ASC_SCSI_Q *);
3862 static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *);
3863 static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *);
3864 static void asc_prt_adv_dvc_var(ADV_DVC_VAR *);
3865 static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *);
3866 static void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *);
3867 static void asc_prt_hex(char *f, uchar *, int);
3868 #endif /* ADVANSYS_DEBUG */
3870 #ifdef CONFIG_PROC_FS
3872 * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
3874 * *buffer: I/O buffer
3875 * **start: if inout == FALSE pointer into buffer where user read should start
3876 * offset: current offset into a /proc/scsi/advansys/[0...] file
3877 * length: length of buffer
3878 * hostno: Scsi_Host host_no
3879 * inout: TRUE - user is writing; FALSE - user is reading
3881 * Return the number of bytes read from or written to a
3882 * /proc/scsi/advansys/[0...] file.
3884 * Note: This function uses the per board buffer 'prtbuf' which is
3885 * allocated when the board is initialized in advansys_detect(). The
3886 * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
3887 * used to write to the buffer. The way asc_proc_copy() is written
3888 * if 'prtbuf' is too small it will not be overwritten. Instead the
3889 * user just won't get all the available statistics.
3892 advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
3893 off_t offset, int length, int inout)
3895 asc_board_t *boardp;
3903 #ifdef ADVANSYS_STATS
3905 #endif /* ADVANSYS_STATS */
3907 ASC_DBG(1, "advansys_proc_info: begin\n");
3910 * User write not supported.
3912 if (inout == TRUE) {
3917 * User read of /proc/scsi/advansys/[0...] file.
3920 boardp = ASC_BOARDP(shost);
3922 /* Copy read data starting at the beginning of the buffer. */
3930 * Get board configuration information.
3932 * advansys_info() returns the board string from its own static buffer.
3934 cp = (char *)advansys_info(shost);
3937 /* Copy board information. */
3938 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
3942 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
3949 * Display Wide Board BIOS Information.
3951 if (ASC_WIDE_BOARD(boardp)) {
3952 cp = boardp->prtbuf;
3953 cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
3954 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
3956 asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
3961 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
3969 * Display driver information for each device attached to the board.
3971 cp = boardp->prtbuf;
3972 cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
3973 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
3974 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
3978 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
3985 * Display EEPROM configuration for the board.
3987 cp = boardp->prtbuf;
3988 if (ASC_NARROW_BOARD(boardp)) {
3989 cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
3991 cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
3993 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
3994 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
3998 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4005 * Display driver configuration and information for the board.
4007 cp = boardp->prtbuf;
4008 cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
4009 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4010 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4014 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4020 #ifdef ADVANSYS_STATS
4022 * Display driver statistics for the board.
4024 cp = boardp->prtbuf;
4025 cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
4026 ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
4027 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4031 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4038 * Display driver statistics for each target.
4040 for (tgt_id = 0; tgt_id <= ADV_MAX_TID; tgt_id++) {
4041 cp = boardp->prtbuf;
4042 cplen = asc_prt_target_stats(shost, tgt_id, cp,
4044 ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
4046 asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4051 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4057 #endif /* ADVANSYS_STATS */
4060 * Display Asc Library dynamic configuration information
4063 cp = boardp->prtbuf;
4064 if (ASC_NARROW_BOARD(boardp)) {
4065 cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
4067 cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
4069 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4070 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4074 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4080 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4084 #endif /* CONFIG_PROC_FS */
4089 * Return suitable for printing on the console with the argument
4090 * adapter's configuration information.
4092 * Note: The information line should not exceed ASC_INFO_SIZE bytes,
4093 * otherwise the static 'info' array will be overrun.
4095 static const char *advansys_info(struct Scsi_Host *shost)
4097 static char info[ASC_INFO_SIZE];
4098 asc_board_t *boardp;
4099 ASC_DVC_VAR *asc_dvc_varp;
4100 ADV_DVC_VAR *adv_dvc_varp;
4103 char *widename = NULL;
4105 boardp = ASC_BOARDP(shost);
4106 if (ASC_NARROW_BOARD(boardp)) {
4107 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
4108 ASC_DBG(1, "advansys_info: begin\n");
4109 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
4110 if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
4112 busname = "ISA PnP";
4116 /* Don't reference 'shost->n_io_port'; It may be truncated. */
4118 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
4119 ASC_VERSION, busname,
4120 (ulong)shost->io_port,
4121 (ulong)shost->io_port + boardp->asc_n_io_port -
4122 1, shost->irq, shost->dma_channel);
4124 if (asc_dvc_varp->bus_type & ASC_IS_VL) {
4126 } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
4128 } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
4129 if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
4130 == ASC_IS_PCI_ULTRA) {
4131 busname = "PCI Ultra";
4138 ("advansys_info: board %d: unknown bus type %d\n",
4139 boardp->id, asc_dvc_varp->bus_type);
4141 /* Don't reference 'shost->n_io_port'; It may be truncated. */
4143 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
4144 ASC_VERSION, busname,
4145 (ulong)shost->io_port,
4146 (ulong)shost->io_port + boardp->asc_n_io_port -
4151 * Wide Adapter Information
4153 * Memory-mapped I/O is used instead of I/O space to access
4154 * the adapter, but display the I/O Port range. The Memory
4155 * I/O address is displayed through the driver /proc file.
4157 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
4158 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
4159 iolen = ADV_3550_IOLEN;
4160 widename = "Ultra-Wide";
4161 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
4162 iolen = ADV_38C0800_IOLEN;
4163 widename = "Ultra2-Wide";
4165 iolen = ADV_38C1600_IOLEN;
4166 widename = "Ultra3-Wide";
4169 "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
4170 ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
4171 (ulong)adv_dvc_varp->iop_base + iolen - 1, shost->irq);
4173 ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
4174 ASC_DBG(1, "advansys_info: end\n");
4179 * advansys_queuecommand() - interrupt-driven I/O entrypoint.
4181 * This function always returns 0. Command return status is saved
4182 * in the 'scp' result field.
4185 advansys_queuecommand(struct scsi_cmnd *scp, void (*done) (struct scsi_cmnd *))
4187 struct Scsi_Host *shost;
4188 asc_board_t *boardp;
4190 struct scsi_cmnd *done_scp;
4192 shost = scp->device->host;
4193 boardp = ASC_BOARDP(shost);
4194 ASC_STATS(shost, queuecommand);
4196 /* host_lock taken by mid-level prior to call but need to protect */
4197 /* against own ISR */
4198 spin_lock_irqsave(&boardp->lock, flags);
4201 * Block new commands while handling a reset or abort request.
4203 if (boardp->flags & ASC_HOST_IN_RESET) {
4205 "advansys_queuecommand: scp 0x%lx blocked for reset request\n",
4207 scp->result = HOST_BYTE(DID_RESET);
4210 * Add blocked requests to the board's 'done' queue. The queued
4211 * requests will be completed at the end of the abort or reset
4214 asc_enqueue(&boardp->done, scp, ASC_BACK);
4215 spin_unlock_irqrestore(&boardp->lock, flags);
4220 * Attempt to execute any waiting commands for the board.
4222 if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
4224 "advansys_queuecommand: before asc_execute_queue() waiting\n");
4225 asc_execute_queue(&boardp->waiting);
4229 * Save the function pointer to Linux mid-level 'done' function
4230 * and attempt to execute the command.
4232 * If ASC_NOERROR is returned the request has been added to the
4233 * board's 'active' queue and will be completed by the interrupt
4236 * If ASC_BUSY is returned add the request to the board's per
4237 * target waiting list. This is the first time the request has
4238 * been tried. Add it to the back of the waiting list. It will be
4241 * If an error occurred, the request will have been placed on the
4242 * board's 'done' queue and must be completed before returning.
4244 scp->scsi_done = done;
4245 switch (asc_execute_scsi_cmnd(scp)) {
4249 asc_enqueue(&boardp->waiting, scp, ASC_BACK);
4253 done_scp = asc_dequeue_list(&boardp->done, NULL, ASC_TID_ALL);
4254 /* Interrupts could be enabled here. */
4255 asc_scsi_done_list(done_scp);
4258 spin_unlock_irqrestore(&boardp->lock, flags);
4266 * Reset the bus associated with the command 'scp'.
4268 * This function runs its own thread. Interrupts must be blocked but
4269 * sleeping is allowed and no locking other than for host structures is
4270 * required. Returns SUCCESS or FAILED.
4272 static int advansys_reset(struct scsi_cmnd *scp)
4274 struct Scsi_Host *shost;
4275 asc_board_t *boardp;
4276 ASC_DVC_VAR *asc_dvc_varp;
4277 ADV_DVC_VAR *adv_dvc_varp;
4279 struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
4280 struct scsi_cmnd *tscp, *new_last_scp;
4284 ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
4286 #ifdef ADVANSYS_STATS
4287 if (scp->device->host != NULL) {
4288 ASC_STATS(scp->device->host, reset);
4290 #endif /* ADVANSYS_STATS */
4292 if ((shost = scp->device->host) == NULL) {
4293 scp->result = HOST_BYTE(DID_ERROR);
4297 boardp = ASC_BOARDP(shost);
4299 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
4302 * Check for re-entrancy.
4304 spin_lock_irqsave(&boardp->lock, flags);
4305 if (boardp->flags & ASC_HOST_IN_RESET) {
4306 spin_unlock_irqrestore(&boardp->lock, flags);
4309 boardp->flags |= ASC_HOST_IN_RESET;
4310 spin_unlock_irqrestore(&boardp->lock, flags);
4312 if (ASC_NARROW_BOARD(boardp)) {
4316 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
4319 * Reset the chip and SCSI bus.
4321 ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
4322 status = AscInitAsc1000Driver(asc_dvc_varp);
4324 /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
4325 if (asc_dvc_varp->err_code) {
4327 ("advansys_reset: board %d: SCSI bus reset error: 0x%x\n",
4328 boardp->id, asc_dvc_varp->err_code);
4330 } else if (status) {
4332 ("advansys_reset: board %d: SCSI bus reset warning: 0x%x\n",
4333 boardp->id, status);
4336 ("advansys_reset: board %d: SCSI bus reset successful.\n",
4340 ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
4341 spin_lock_irqsave(&boardp->lock, flags);
4347 * If the suggest reset bus flags are set, then reset the bus.
4348 * Otherwise only reset the device.
4350 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
4353 * Reset the target's SCSI bus.
4355 ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
4356 switch (AdvResetChipAndSB(adv_dvc_varp)) {
4359 ("advansys_reset: board %d: SCSI bus reset successful.\n",
4365 ("advansys_reset: board %d: SCSI bus reset error.\n",
4370 spin_lock_irqsave(&boardp->lock, flags);
4371 (void)AdvISR(adv_dvc_varp);
4373 /* Board lock is held. */
4376 * Dequeue all board 'done' requests. A pointer to the last request
4377 * is returned in 'last_scp'.
4379 done_scp = asc_dequeue_list(&boardp->done, &last_scp, ASC_TID_ALL);
4382 * Dequeue all board 'active' requests for all devices and set
4383 * the request status to DID_RESET. A pointer to the last request
4384 * is returned in 'last_scp'.
4386 if (done_scp == NULL) {
4388 asc_dequeue_list(&boardp->active, &last_scp, ASC_TID_ALL);
4389 for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
4390 tscp->result = HOST_BYTE(DID_RESET);
4393 /* Append to 'done_scp' at the end with 'last_scp'. */
4394 ASC_ASSERT(last_scp != NULL);
4395 last_scp->host_scribble =
4396 (unsigned char *)asc_dequeue_list(&boardp->active,
4399 if (new_last_scp != NULL) {
4400 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
4401 for (tscp = REQPNEXT(last_scp); tscp;
4402 tscp = REQPNEXT(tscp)) {
4403 tscp->result = HOST_BYTE(DID_RESET);
4405 last_scp = new_last_scp;
4410 * Dequeue all 'waiting' requests and set the request status
4413 if (done_scp == NULL) {
4415 asc_dequeue_list(&boardp->waiting, &last_scp, ASC_TID_ALL);
4416 for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
4417 tscp->result = HOST_BYTE(DID_RESET);
4420 /* Append to 'done_scp' at the end with 'last_scp'. */
4421 ASC_ASSERT(last_scp != NULL);
4422 last_scp->host_scribble =
4423 (unsigned char *)asc_dequeue_list(&boardp->waiting,
4426 if (new_last_scp != NULL) {
4427 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
4428 for (tscp = REQPNEXT(last_scp); tscp;
4429 tscp = REQPNEXT(tscp)) {
4430 tscp->result = HOST_BYTE(DID_RESET);
4432 last_scp = new_last_scp;
4436 /* Save the time of the most recently completed reset. */
4437 boardp->last_reset = jiffies;
4439 /* Clear reset flag. */
4440 boardp->flags &= ~ASC_HOST_IN_RESET;
4441 spin_unlock_irqrestore(&boardp->lock, flags);
4444 * Complete all the 'done_scp' requests.
4446 if (done_scp != NULL) {
4447 asc_scsi_done_list(done_scp);
4450 ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
4456 * advansys_biosparam()
4458 * Translate disk drive geometry if the "BIOS greater than 1 GB"
4459 * support is enabled for a drive.
4461 * ip (information pointer) is an int array with the following definition:
4467 advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
4468 sector_t capacity, int ip[])
4470 asc_board_t *boardp;
4472 ASC_DBG(1, "advansys_biosparam: begin\n");
4473 ASC_STATS(sdev->host, biosparam);
4474 boardp = ASC_BOARDP(sdev->host);
4475 if (ASC_NARROW_BOARD(boardp)) {
4476 if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
4477 ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
4485 if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
4486 BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
4494 ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
4495 ASC_DBG(1, "advansys_biosparam: end\n");
4499 static struct scsi_host_template advansys_template = {
4500 .proc_name = "advansys",
4501 #ifdef CONFIG_PROC_FS
4502 .proc_info = advansys_proc_info,
4505 .info = advansys_info,
4506 .queuecommand = advansys_queuecommand,
4507 .eh_bus_reset_handler = advansys_reset,
4508 .bios_param = advansys_biosparam,
4509 .slave_configure = advansys_slave_configure,
4511 * Because the driver may control an ISA adapter 'unchecked_isa_dma'
4512 * must be set. The flag will be cleared in advansys_board_found
4513 * for non-ISA adapters.
4515 .unchecked_isa_dma = 1,
4517 * All adapters controlled by this driver are capable of large
4518 * scatter-gather lists. According to the mid-level SCSI documentation
4519 * this obviates any performance gain provided by setting
4520 * 'use_clustering'. But empirically while CPU utilization is increased
4521 * by enabling clustering, I/O throughput increases as well.
4523 .use_clustering = ENABLE_CLUSTERING,
4527 * --- Miscellaneous Driver Functions
4531 * First-level interrupt handler.
4533 * 'dev_id' is a pointer to the interrupting adapter's asc_board_t. Because
4534 * all boards are currently checked for interrupts on each interrupt, 'dev_id'
4535 * is not referenced. 'dev_id' could be used to identify an interrupt passed
4536 * to the AdvanSys driver which is for a device sharing an interrupt with
4537 * an AdvanSys adapter.
4539 static irqreturn_t advansys_interrupt(int irq, void *dev_id)
4541 unsigned long flags;
4542 struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
4543 struct scsi_cmnd *new_last_scp;
4544 struct Scsi_Host *shost = dev_id;
4545 asc_board_t *boardp = ASC_BOARDP(shost);
4546 irqreturn_t result = IRQ_NONE;
4548 ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
4549 spin_lock_irqsave(&boardp->lock, flags);
4550 if (ASC_NARROW_BOARD(boardp)) {
4554 if (AscIsIntPending(shost->io_port)) {
4555 result = IRQ_HANDLED;
4556 ASC_STATS(shost, interrupt);
4557 ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
4558 AscISR(&boardp->dvc_var.asc_dvc_var);
4564 ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
4565 if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
4566 result = IRQ_HANDLED;
4567 ASC_STATS(shost, interrupt);
4572 * Start waiting requests and create a list of completed requests.
4574 * If a reset request is being performed for the board, the reset
4575 * handler will complete pending requests after it has completed.
4577 if ((boardp->flags & ASC_HOST_IN_RESET) == 0) {
4578 ASC_DBG2(1, "advansys_interrupt: done_scp 0x%p, "
4579 "last_scp 0x%p\n", done_scp, last_scp);
4581 /* Start any waiting commands for the board. */
4582 if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
4583 ASC_DBG(1, "advansys_interrupt: before "
4584 "asc_execute_queue()\n");
4585 asc_execute_queue(&boardp->waiting);
4589 * Add to the list of requests that must be completed.
4591 * 'done_scp' will always be NULL on the first iteration of
4592 * this loop. 'last_scp' is set at the same time as 'done_scp'.
4594 if (done_scp == NULL) {
4595 done_scp = asc_dequeue_list(&boardp->done,
4596 &last_scp, ASC_TID_ALL);
4598 ASC_ASSERT(last_scp != NULL);
4599 last_scp->host_scribble =
4600 (unsigned char *)asc_dequeue_list(&boardp->
4604 if (new_last_scp != NULL) {
4605 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
4606 last_scp = new_last_scp;
4610 spin_unlock_irqrestore(&boardp->lock, flags);
4613 * If interrupts were enabled on entry, then they
4614 * are now enabled here.
4616 * Complete all requests on the done list.
4619 asc_scsi_done_list(done_scp);
4621 ASC_DBG(1, "advansys_interrupt: end\n");
4626 * Set the number of commands to queue per device for the
4627 * specified host adapter.
4629 static int advansys_slave_configure(struct scsi_device *device)
4631 asc_board_t *boardp;
4633 boardp = ASC_BOARDP(device->host);
4634 boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
4636 * Save a pointer to the device and set its initial/maximum
4637 * queue depth. Only save the pointer for a lun0 dev though.
4639 if (device->lun == 0)
4640 boardp->device[device->id] = device;
4641 if (device->tagged_supported) {
4642 if (ASC_NARROW_BOARD(boardp)) {
4643 scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
4644 boardp->dvc_var.asc_dvc_var.
4645 max_dvc_qng[device->id]);
4647 scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
4648 boardp->dvc_var.adv_dvc_var.
4652 scsi_adjust_queue_depth(device, 0, device->host->cmd_per_lun);
4655 "advansys_slave_configure: device 0x%lx, boardp 0x%lx, id %d, depth %d\n",
4656 (ulong)device, (ulong)boardp, device->id, device->queue_depth);
4661 * Complete all requests on the singly linked list pointed
4664 * Interrupts can be enabled on entry.
4666 static void asc_scsi_done_list(struct scsi_cmnd *scp)
4668 struct scsi_cmnd *tscp;
4670 ASC_DBG(2, "asc_scsi_done_list: begin\n");
4671 while (scp != NULL) {
4672 asc_board_t *boardp;
4675 ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp);
4676 tscp = REQPNEXT(scp);
4677 scp->host_scribble = NULL;
4679 boardp = ASC_BOARDP(scp->device->host);
4681 if (ASC_NARROW_BOARD(boardp))
4682 dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
4684 dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
4688 (struct scatterlist *)scp->request_buffer,
4689 scp->use_sg, scp->sc_data_direction);
4690 else if (scp->request_bufflen)
4691 dma_unmap_single(dev, scp->SCp.dma_handle,
4692 scp->request_bufflen,
4693 scp->sc_data_direction);
4695 ASC_STATS(scp->device->host, done);
4696 ASC_ASSERT(scp->scsi_done != NULL);
4698 scp->scsi_done(scp);
4702 ASC_DBG(2, "asc_scsi_done_list: done\n");
4707 * Execute a single 'Scsi_Cmnd'.
4709 * The function 'done' is called when the request has been completed.
4713 * host - board controlling device
4714 * device - device to send command
4715 * target - target of device
4716 * lun - lun of device
4717 * cmd_len - length of SCSI CDB
4718 * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
4719 * use_sg - if non-zero indicates scatter-gather request with use_sg elements
4721 * if (use_sg == 0) {
4722 * request_buffer - buffer address for request
4723 * request_bufflen - length of request buffer
4725 * request_buffer - pointer to scatterlist structure
4728 * sense_buffer - sense command buffer
4730 * result (4 bytes of an int):
4732 * 0 SCSI Status Byte Code
4733 * 1 SCSI One Byte Message Code
4735 * 3 Mid-Level Error Code
4737 * host driver fields:
4738 * SCp - Scsi_Pointer used for command processing status
4739 * scsi_done - used to save caller's done function
4740 * host_scribble - used for pointer to another struct scsi_cmnd
4742 * If this function returns ASC_NOERROR the request has been enqueued
4743 * on the board's 'active' queue and will be completed from the
4744 * interrupt handler.
4746 * If this function returns ASC_NOERROR the request has been enqueued
4747 * on the board's 'done' queue and must be completed by the caller.
4749 * If ASC_BUSY is returned the request will be enqueued by the
4750 * caller on the target's waiting queue and re-tried later.
4752 static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
4754 asc_board_t *boardp;
4755 ASC_DVC_VAR *asc_dvc_varp;
4756 ADV_DVC_VAR *adv_dvc_varp;
4757 ADV_SCSI_REQ_Q *adv_scsiqp;
4758 struct scsi_device *device;
4761 ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
4762 (ulong)scp, (ulong)scp->scsi_done);
4764 boardp = ASC_BOARDP(scp->device->host);
4765 device = boardp->device[scp->device->id];
4767 if (ASC_NARROW_BOARD(boardp)) {
4769 * Build and execute Narrow Board request.
4772 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
4775 * Build Asc Library request structure using the
4776 * global structures 'asc_scsi_req' and 'asc_sg_head'.
4778 * If an error is returned, then the request has been
4779 * queued on the board done queue. It will be completed
4782 * asc_build_req() can not return ASC_BUSY.
4784 if (asc_build_req(boardp, scp) == ASC_ERROR) {
4785 ASC_STATS(scp->device->host, build_error);
4790 * Execute the command. If there is no error, add the command
4791 * to the active queue.
4793 switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
4795 ASC_STATS(scp->device->host, exe_noerror);
4797 * Increment monotonically increasing per device successful
4798 * request counter. Wrapping doesn't matter.
4800 boardp->reqcnt[scp->device->id]++;
4801 asc_enqueue(&boardp->active, scp, ASC_BACK);
4803 "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
4807 * Caller will enqueue request on the target's waiting queue
4810 ASC_STATS(scp->device->host, exe_busy);
4814 ("asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
4815 boardp->id, asc_dvc_varp->err_code);
4816 ASC_STATS(scp->device->host, exe_error);
4817 scp->result = HOST_BYTE(DID_ERROR);
4818 asc_enqueue(&boardp->done, scp, ASC_BACK);
4822 ("asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() unknown, err_code 0x%x\n",
4823 boardp->id, asc_dvc_varp->err_code);
4824 ASC_STATS(scp->device->host, exe_unknown);
4825 scp->result = HOST_BYTE(DID_ERROR);
4826 asc_enqueue(&boardp->done, scp, ASC_BACK);
4831 * Build and execute Wide Board request.
4833 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
4836 * Build and get a pointer to an Adv Library request structure.
4838 * If the request is successfully built then send it below,
4839 * otherwise return with an error.
4841 switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
4844 "asc_execute_scsi_cmnd: adv_build_req ASC_NOERROR\n");
4848 "asc_execute_scsi_cmnd: adv_build_req ASC_BUSY\n");
4850 * If busy is returned the request has not been enqueued.
4851 * It will be enqueued by the caller on the target's waiting
4852 * queue and retried later.
4854 * The asc_stats fields 'adv_build_noreq' and 'adv_build_nosg'
4855 * count wide board busy conditions. They are updated in
4856 * adv_build_req and adv_get_sglist, respectively.
4861 * If an error is returned, then the request has been
4862 * queued on the board done queue. It will be completed
4867 "asc_execute_scsi_cmnd: adv_build_req ASC_ERROR\n");
4868 ASC_STATS(scp->device->host, build_error);
4873 * Execute the command. If there is no error, add the command
4874 * to the active queue.
4876 switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
4878 ASC_STATS(scp->device->host, exe_noerror);
4880 * Increment monotonically increasing per device successful
4881 * request counter. Wrapping doesn't matter.
4883 boardp->reqcnt[scp->device->id]++;
4884 asc_enqueue(&boardp->active, scp, ASC_BACK);
4886 "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
4890 * Caller will enqueue request on the target's waiting queue
4893 ASC_STATS(scp->device->host, exe_busy);
4897 ("asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
4898 boardp->id, adv_dvc_varp->err_code);
4899 ASC_STATS(scp->device->host, exe_error);
4900 scp->result = HOST_BYTE(DID_ERROR);
4901 asc_enqueue(&boardp->done, scp, ASC_BACK);
4905 ("asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() unknown, err_code 0x%x\n",
4906 boardp->id, adv_dvc_varp->err_code);
4907 ASC_STATS(scp->device->host, exe_unknown);
4908 scp->result = HOST_BYTE(DID_ERROR);
4909 asc_enqueue(&boardp->done, scp, ASC_BACK);
4914 ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
4919 * Build a request structure for the Asc Library (Narrow Board).
4921 * The global structures 'asc_scsi_q' and 'asc_sg_head' are
4922 * used to build the request.
4924 * If an error occurs, then queue the request on the board done
4925 * queue and return ASC_ERROR.
4927 static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
4929 struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
4932 * Mutually exclusive access is required to 'asc_scsi_q' and
4933 * 'asc_sg_head' until after the request is started.
4935 memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
4938 * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
4940 asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
4943 * Build the ASC_SCSI_Q request.
4945 * For narrow boards a CDB length maximum of 12 bytes
4948 if (scp->cmd_len > ASC_MAX_CDB_LEN) {
4950 ("asc_build_req: board %d: cmd_len %d > ASC_MAX_CDB_LEN %d\n",
4951 boardp->id, scp->cmd_len, ASC_MAX_CDB_LEN);
4952 scp->result = HOST_BYTE(DID_ERROR);
4953 asc_enqueue(&boardp->done, scp, ASC_BACK);
4956 asc_scsi_q.cdbptr = &scp->cmnd[0];
4957 asc_scsi_q.q2.cdb_len = scp->cmd_len;
4958 asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
4959 asc_scsi_q.q1.target_lun = scp->device->lun;
4960 asc_scsi_q.q2.target_ix =
4961 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
4962 asc_scsi_q.q1.sense_addr =
4963 cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
4964 asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
4967 * If there are any outstanding requests for the current target,
4968 * then every 255th request send an ORDERED request. This heuristic
4969 * tries to retain the benefit of request sorting while preventing
4970 * request starvation. 255 is the max number of tags or pending commands
4971 * a device may have outstanding.
4973 * The request count is incremented below for every successfully
4977 if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
4978 (boardp->reqcnt[scp->device->id] % 255) == 0) {
4979 asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
4981 asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
4985 * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
4988 if (scp->use_sg == 0) {
4990 * CDB request of single contiguous buffer.
4992 ASC_STATS(scp->device->host, cont_cnt);
4993 scp->SCp.dma_handle = scp->request_bufflen ?
4994 dma_map_single(dev, scp->request_buffer,
4995 scp->request_bufflen,
4996 scp->sc_data_direction) : 0;
4997 asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
4998 asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
4999 ASC_STATS_ADD(scp->device->host, cont_xfer,
5000 ASC_CEILING(scp->request_bufflen, 512));
5001 asc_scsi_q.q1.sg_queue_cnt = 0;
5002 asc_scsi_q.sg_head = NULL;
5005 * CDB scatter-gather request list.
5009 struct scatterlist *slp;
5011 slp = (struct scatterlist *)scp->request_buffer;
5013 dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
5015 if (use_sg > scp->device->host->sg_tablesize) {
5017 ("asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
5019 scp->device->host->sg_tablesize);
5020 dma_unmap_sg(dev, slp, scp->use_sg,
5021 scp->sc_data_direction);
5022 scp->result = HOST_BYTE(DID_ERROR);
5023 asc_enqueue(&boardp->done, scp, ASC_BACK);
5027 ASC_STATS(scp->device->host, sg_cnt);
5030 * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
5031 * structure to point to it.
5033 memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
5035 asc_scsi_q.q1.cntl |= QC_SG_HEAD;
5036 asc_scsi_q.sg_head = &asc_sg_head;
5037 asc_scsi_q.q1.data_cnt = 0;
5038 asc_scsi_q.q1.data_addr = 0;
5039 /* This is a byte value, otherwise it would need to be swapped. */
5040 asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
5041 ASC_STATS_ADD(scp->device->host, sg_elem,
5042 asc_sg_head.entry_cnt);
5045 * Convert scatter-gather list into ASC_SG_HEAD list.
5047 for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
5048 asc_sg_head.sg_list[sgcnt].addr =
5049 cpu_to_le32(sg_dma_address(slp));
5050 asc_sg_head.sg_list[sgcnt].bytes =
5051 cpu_to_le32(sg_dma_len(slp));
5052 ASC_STATS_ADD(scp->device->host, sg_xfer,
5053 ASC_CEILING(sg_dma_len(slp), 512));
5057 ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
5058 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
5064 * Build a request structure for the Adv Library (Wide Board).
5066 * If an adv_req_t can not be allocated to issue the request,
5067 * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
5069 * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
5070 * microcode for DMA addresses or math operations are byte swapped
5071 * to little-endian order.
5074 adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
5075 ADV_SCSI_REQ_Q **adv_scsiqpp)
5078 ADV_SCSI_REQ_Q *scsiqp;
5081 struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
5084 * Allocate an adv_req_t structure from the board to execute
5087 if (boardp->adv_reqp == NULL) {
5088 ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
5089 ASC_STATS(scp->device->host, adv_build_noreq);
5092 reqp = boardp->adv_reqp;
5093 boardp->adv_reqp = reqp->next_reqp;
5094 reqp->next_reqp = NULL;
5098 * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
5100 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
5103 * Initialize the structure.
5105 scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
5108 * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
5110 scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
5113 * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
5118 * Build the ADV_SCSI_REQ_Q request.
5122 * Set CDB length and copy it to the request structure.
5123 * For wide boards a CDB length maximum of 16 bytes
5126 if (scp->cmd_len > ADV_MAX_CDB_LEN) {
5128 ("adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
5129 boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
5130 scp->result = HOST_BYTE(DID_ERROR);
5131 asc_enqueue(&boardp->done, scp, ASC_BACK);
5134 scsiqp->cdb_len = scp->cmd_len;
5135 /* Copy first 12 CDB bytes to cdb[]. */
5136 for (i = 0; i < scp->cmd_len && i < 12; i++) {
5137 scsiqp->cdb[i] = scp->cmnd[i];
5139 /* Copy last 4 CDB bytes, if present, to cdb16[]. */
5140 for (; i < scp->cmd_len; i++) {
5141 scsiqp->cdb16[i - 12] = scp->cmnd[i];
5144 scsiqp->target_id = scp->device->id;
5145 scsiqp->target_lun = scp->device->lun;
5147 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
5148 scsiqp->sense_len = sizeof(scp->sense_buffer);
5151 * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
5155 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
5156 scsiqp->vdata_addr = scp->request_buffer;
5157 scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
5159 if (scp->use_sg == 0) {
5161 * CDB request of single contiguous buffer.
5163 reqp->sgblkp = NULL;
5164 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
5165 if (scp->request_bufflen) {
5166 scsiqp->vdata_addr = scp->request_buffer;
5167 scp->SCp.dma_handle =
5168 dma_map_single(dev, scp->request_buffer,
5169 scp->request_bufflen,
5170 scp->sc_data_direction);
5172 scsiqp->vdata_addr = NULL;
5173 scp->SCp.dma_handle = 0;
5175 scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
5176 scsiqp->sg_list_ptr = NULL;
5177 scsiqp->sg_real_addr = 0;
5178 ASC_STATS(scp->device->host, cont_cnt);
5179 ASC_STATS_ADD(scp->device->host, cont_xfer,
5180 ASC_CEILING(scp->request_bufflen, 512));
5183 * CDB scatter-gather request list.
5185 struct scatterlist *slp;
5188 slp = (struct scatterlist *)scp->request_buffer;
5190 dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
5192 if (use_sg > ADV_MAX_SG_LIST) {
5194 ("adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
5196 scp->device->host->sg_tablesize);
5197 dma_unmap_sg(dev, slp, scp->use_sg,
5198 scp->sc_data_direction);
5199 scp->result = HOST_BYTE(DID_ERROR);
5200 asc_enqueue(&boardp->done, scp, ASC_BACK);
5203 * Free the 'adv_req_t' structure by adding it back to the
5206 reqp->next_reqp = boardp->adv_reqp;
5207 boardp->adv_reqp = reqp;
5213 adv_get_sglist(boardp, reqp, scp,
5214 use_sg)) != ADV_SUCCESS) {
5216 * Free the adv_req_t structure by adding it back to the
5219 reqp->next_reqp = boardp->adv_reqp;
5220 boardp->adv_reqp = reqp;
5225 ASC_STATS(scp->device->host, sg_cnt);
5226 ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
5229 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
5230 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
5232 *adv_scsiqpp = scsiqp;
5238 * Build scatter-gather list for Adv Library (Wide Board).
5240 * Additional ADV_SG_BLOCK structures will need to be allocated
5241 * if the total number of scatter-gather elements exceeds
5242 * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
5243 * assumed to be physically contiguous.
5246 * ADV_SUCCESS(1) - SG List successfully created
5247 * ADV_ERROR(-1) - SG List creation failed
5250 adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
5253 adv_sgblk_t *sgblkp;
5254 ADV_SCSI_REQ_Q *scsiqp;
5255 struct scatterlist *slp;
5257 ADV_SG_BLOCK *sg_block, *prev_sg_block;
5258 ADV_PADDR sg_block_paddr;
5261 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
5262 slp = (struct scatterlist *)scp->request_buffer;
5263 sg_elem_cnt = use_sg;
5264 prev_sg_block = NULL;
5265 reqp->sgblkp = NULL;
5269 * Allocate a 'adv_sgblk_t' structure from the board free
5270 * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
5271 * (15) scatter-gather elements.
5273 if ((sgblkp = boardp->adv_sgblkp) == NULL) {
5274 ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
5275 ASC_STATS(scp->device->host, adv_build_nosg);
5278 * Allocation failed. Free 'adv_sgblk_t' structures already
5279 * allocated for the request.
5281 while ((sgblkp = reqp->sgblkp) != NULL) {
5282 /* Remove 'sgblkp' from the request list. */
5283 reqp->sgblkp = sgblkp->next_sgblkp;
5285 /* Add 'sgblkp' to the board free list. */
5286 sgblkp->next_sgblkp = boardp->adv_sgblkp;
5287 boardp->adv_sgblkp = sgblkp;
5291 /* Complete 'adv_sgblk_t' board allocation. */
5292 boardp->adv_sgblkp = sgblkp->next_sgblkp;
5293 sgblkp->next_sgblkp = NULL;
5296 * Get 8 byte aligned virtual and physical addresses for
5297 * the allocated ADV_SG_BLOCK structure.
5300 (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
5301 sg_block_paddr = virt_to_bus(sg_block);
5304 * Check if this is the first 'adv_sgblk_t' for the request.
5306 if (reqp->sgblkp == NULL) {
5307 /* Request's first scatter-gather block. */
5308 reqp->sgblkp = sgblkp;
5311 * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
5314 scsiqp->sg_list_ptr = sg_block;
5315 scsiqp->sg_real_addr =
5316 cpu_to_le32(sg_block_paddr);
5318 /* Request's second or later scatter-gather block. */
5319 sgblkp->next_sgblkp = reqp->sgblkp;
5320 reqp->sgblkp = sgblkp;
5323 * Point the previous ADV_SG_BLOCK structure to
5324 * the newly allocated ADV_SG_BLOCK structure.
5326 ASC_ASSERT(prev_sg_block != NULL);
5327 prev_sg_block->sg_ptr =
5328 cpu_to_le32(sg_block_paddr);
5332 for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
5333 sg_block->sg_list[i].sg_addr =
5334 cpu_to_le32(sg_dma_address(slp));
5335 sg_block->sg_list[i].sg_count =
5336 cpu_to_le32(sg_dma_len(slp));
5337 ASC_STATS_ADD(scp->device->host, sg_xfer,
5338 ASC_CEILING(sg_dma_len(slp), 512));
5340 if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
5341 sg_block->sg_cnt = i + 1;
5342 sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
5347 sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
5348 prev_sg_block = sg_block;
5355 * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
5357 * Interrupt callback function for the Narrow SCSI Asc Library.
5359 static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
5361 asc_board_t *boardp;
5362 struct scsi_cmnd *scp;
5363 struct Scsi_Host *shost;
5365 ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
5366 (ulong)asc_dvc_varp, (ulong)qdonep);
5367 ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
5370 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
5371 * command that has been completed.
5373 scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
5374 ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
5377 ASC_PRINT("asc_isr_callback: scp is NULL\n");
5380 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
5382 shost = scp->device->host;
5383 ASC_STATS(shost, callback);
5384 ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
5387 * If the request isn't found on the active queue, it may
5388 * have been removed to handle a reset request.
5389 * Display a message and return.
5391 boardp = ASC_BOARDP(shost);
5392 ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
5393 if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
5395 ("asc_isr_callback: board %d: scp 0x%lx not on active queue\n",
5396 boardp->id, (ulong)scp);
5401 * 'qdonep' contains the command's ending status.
5403 switch (qdonep->d3.done_stat) {
5405 ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
5409 * If an INQUIRY command completed successfully, then call
5410 * the AscInquiryHandling() function to set-up the device.
5412 if (scp->cmnd[0] == INQUIRY && scp->device->lun == 0 &&
5413 (scp->request_bufflen - qdonep->remain_bytes) >= 8) {
5414 AscInquiryHandling(asc_dvc_varp, scp->device->id & 0x7,
5415 (ASC_SCSI_INQUIRY *)scp->
5420 * Check for an underrun condition.
5422 * If there was no error and an underrun condition, then
5423 * then return the number of underrun bytes.
5425 if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
5426 qdonep->remain_bytes <= scp->request_bufflen) {
5428 "asc_isr_callback: underrun condition %u bytes\n",
5429 (unsigned)qdonep->remain_bytes);
5430 scp->resid = qdonep->remain_bytes;
5435 ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
5436 switch (qdonep->d3.host_stat) {
5437 case QHSTA_NO_ERROR:
5438 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
5440 "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
5441 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
5442 sizeof(scp->sense_buffer));
5444 * Note: The 'status_byte()' macro used by target drivers
5445 * defined in scsi.h shifts the status byte returned by
5446 * host drivers right by 1 bit. This is why target drivers
5447 * also use right shifted status byte definitions. For
5448 * instance target drivers use CHECK_CONDITION, defined to
5449 * 0x1, instead of the SCSI defined check condition value
5450 * of 0x2. Host drivers are supposed to return the status
5451 * byte as it is defined by SCSI.
5453 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
5454 STATUS_BYTE(qdonep->d3.scsi_stat);
5456 scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
5461 /* QHSTA error occurred */
5462 ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
5463 qdonep->d3.host_stat);
5464 scp->result = HOST_BYTE(DID_BAD_TARGET);
5469 case QD_ABORTED_BY_HOST:
5470 ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
5472 HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
5474 STATUS_BYTE(qdonep->d3.scsi_stat);
5478 ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
5479 qdonep->d3.done_stat);
5481 HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
5483 STATUS_BYTE(qdonep->d3.scsi_stat);
5488 * If the 'init_tidmask' bit isn't already set for the target and the
5489 * current request finished normally, then set the bit for the target
5490 * to indicate that a device is present.
5492 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
5493 qdonep->d3.done_stat == QD_NO_ERROR &&
5494 qdonep->d3.host_stat == QHSTA_NO_ERROR) {
5495 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
5499 * Because interrupts may be enabled by the 'struct scsi_cmnd' done
5500 * function, add the command to the end of the board's done queue.
5501 * The done function for the command will be called from
5502 * advansys_interrupt().
5504 asc_enqueue(&boardp->done, scp, ASC_BACK);
5510 * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
5512 * Callback function for the Wide SCSI Adv Library.
5514 static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
5516 asc_board_t *boardp;
5518 adv_sgblk_t *sgblkp;
5519 struct scsi_cmnd *scp;
5520 struct Scsi_Host *shost;
5523 ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
5524 (ulong)adv_dvc_varp, (ulong)scsiqp);
5525 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
5528 * Get the adv_req_t structure for the command that has been
5529 * completed. The adv_req_t structure actually contains the
5530 * completed ADV_SCSI_REQ_Q structure.
5532 reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
5533 ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
5535 ASC_PRINT("adv_isr_callback: reqp is NULL\n");
5540 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
5541 * command that has been completed.
5543 * Note: The adv_req_t request structure and adv_sgblk_t structure,
5544 * if any, are dropped, because a board structure pointer can not be
5548 ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
5551 ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
5554 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
5556 shost = scp->device->host;
5557 ASC_STATS(shost, callback);
5558 ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
5561 * If the request isn't found on the active queue, it may have been
5562 * removed to handle a reset request. Display a message and return.
5564 * Note: Because the structure may still be in use don't attempt
5565 * to free the adv_req_t and adv_sgblk_t, if any, structures.
5567 boardp = ASC_BOARDP(shost);
5568 ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
5569 if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
5571 ("adv_isr_callback: board %d: scp 0x%lx not on active queue\n",
5572 boardp->id, (ulong)scp);
5577 * 'done_status' contains the command's ending status.
5579 switch (scsiqp->done_status) {
5581 ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
5585 * Check for an underrun condition.
5587 * If there was no error and an underrun condition, then
5588 * then return the number of underrun bytes.
5590 resid_cnt = le32_to_cpu(scsiqp->data_cnt);
5591 if (scp->request_bufflen != 0 && resid_cnt != 0 &&
5592 resid_cnt <= scp->request_bufflen) {
5594 "adv_isr_callback: underrun condition %lu bytes\n",
5596 scp->resid = resid_cnt;
5601 ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
5602 switch (scsiqp->host_status) {
5603 case QHSTA_NO_ERROR:
5604 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
5606 "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
5607 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
5608 sizeof(scp->sense_buffer));
5610 * Note: The 'status_byte()' macro used by target drivers
5611 * defined in scsi.h shifts the status byte returned by
5612 * host drivers right by 1 bit. This is why target drivers
5613 * also use right shifted status byte definitions. For
5614 * instance target drivers use CHECK_CONDITION, defined to
5615 * 0x1, instead of the SCSI defined check condition value
5616 * of 0x2. Host drivers are supposed to return the status
5617 * byte as it is defined by SCSI.
5619 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
5620 STATUS_BYTE(scsiqp->scsi_status);
5622 scp->result = STATUS_BYTE(scsiqp->scsi_status);
5627 /* Some other QHSTA error occurred. */
5628 ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
5629 scsiqp->host_status);
5630 scp->result = HOST_BYTE(DID_BAD_TARGET);
5635 case QD_ABORTED_BY_HOST:
5636 ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
5638 HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
5642 ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
5643 scsiqp->done_status);
5645 HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
5650 * If the 'init_tidmask' bit isn't already set for the target and the
5651 * current request finished normally, then set the bit for the target
5652 * to indicate that a device is present.
5654 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
5655 scsiqp->done_status == QD_NO_ERROR &&
5656 scsiqp->host_status == QHSTA_NO_ERROR) {
5657 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
5661 * Because interrupts may be enabled by the 'struct scsi_cmnd' done
5662 * function, add the command to the end of the board's done queue.
5663 * The done function for the command will be called from
5664 * advansys_interrupt().
5666 asc_enqueue(&boardp->done, scp, ASC_BACK);
5669 * Free all 'adv_sgblk_t' structures allocated for the request.
5671 while ((sgblkp = reqp->sgblkp) != NULL) {
5672 /* Remove 'sgblkp' from the request list. */
5673 reqp->sgblkp = sgblkp->next_sgblkp;
5675 /* Add 'sgblkp' to the board free list. */
5676 sgblkp->next_sgblkp = boardp->adv_sgblkp;
5677 boardp->adv_sgblkp = sgblkp;
5681 * Free the adv_req_t structure used with the command by adding
5682 * it back to the board free list.
5684 reqp->next_reqp = boardp->adv_reqp;
5685 boardp->adv_reqp = reqp;
5687 ASC_DBG(1, "adv_isr_callback: done\n");
5693 * adv_async_callback() - Adv Library asynchronous event callback function.
5695 static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
5698 case ADV_ASYNC_SCSI_BUS_RESET_DET:
5700 * The firmware detected a SCSI Bus reset.
5703 "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
5706 case ADV_ASYNC_RDMA_FAILURE:
5708 * Handle RDMA failure by resetting the SCSI Bus and
5709 * possibly the chip if it is unresponsive. Log the error
5710 * with a unique code.
5712 ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
5713 AdvResetChipAndSB(adv_dvc_varp);
5716 case ADV_HOST_SCSI_BUS_RESET:
5718 * Host generated SCSI bus reset occurred.
5720 ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
5724 ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
5730 * Add a 'REQP' to the end of specified queue. Set 'tidmask'
5731 * to indicate a command is queued for the device.
5733 * 'flag' may be either ASC_FRONT or ASC_BACK.
5735 * 'REQPNEXT(reqp)' returns reqp's next pointer.
5737 static void asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
5741 ASC_DBG3(3, "asc_enqueue: ascq 0x%lx, reqp 0x%lx, flag %d\n",
5742 (ulong)ascq, (ulong)reqp, flag);
5743 ASC_ASSERT(reqp != NULL);
5744 ASC_ASSERT(flag == ASC_FRONT || flag == ASC_BACK);
5745 tid = REQPTID(reqp);
5746 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
5747 if (flag == ASC_FRONT) {
5748 reqp->host_scribble = (unsigned char *)ascq->q_first[tid];
5749 ascq->q_first[tid] = reqp;
5750 /* If the queue was empty, set the last pointer. */
5751 if (ascq->q_last[tid] == NULL) {
5752 ascq->q_last[tid] = reqp;
5754 } else { /* ASC_BACK */
5755 if (ascq->q_last[tid] != NULL) {
5756 ascq->q_last[tid]->host_scribble =
5757 (unsigned char *)reqp;
5759 ascq->q_last[tid] = reqp;
5760 reqp->host_scribble = NULL;
5761 /* If the queue was empty, set the first pointer. */
5762 if (ascq->q_first[tid] == NULL) {
5763 ascq->q_first[tid] = reqp;
5766 /* The queue has at least one entry, set its bit. */
5767 ascq->q_tidmask |= ADV_TID_TO_TIDMASK(tid);
5768 #ifdef ADVANSYS_STATS
5769 /* Maintain request queue statistics. */
5770 ascq->q_tot_cnt[tid]++;
5771 ascq->q_cur_cnt[tid]++;
5772 if (ascq->q_cur_cnt[tid] > ascq->q_max_cnt[tid]) {
5773 ascq->q_max_cnt[tid] = ascq->q_cur_cnt[tid];
5774 ASC_DBG2(2, "asc_enqueue: new q_max_cnt[%d] %d\n",
5775 tid, ascq->q_max_cnt[tid]);
5777 REQPTIME(reqp) = REQTIMESTAMP();
5778 #endif /* ADVANSYS_STATS */
5779 ASC_DBG1(3, "asc_enqueue: reqp 0x%lx\n", (ulong)reqp);
5784 * Return first queued 'REQP' on the specified queue for
5785 * the specified target device. Clear the 'tidmask' bit for
5786 * the device if no more commands are left queued for it.
5788 * 'REQPNEXT(reqp)' returns reqp's next pointer.
5790 static REQP asc_dequeue(asc_queue_t *ascq, int tid)
5794 ASC_DBG2(3, "asc_dequeue: ascq 0x%lx, tid %d\n", (ulong)ascq, tid);
5795 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
5796 if ((reqp = ascq->q_first[tid]) != NULL) {
5797 ASC_ASSERT(ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid));
5798 ascq->q_first[tid] = REQPNEXT(reqp);
5799 /* If the queue is empty, clear its bit and the last pointer. */
5800 if (ascq->q_first[tid] == NULL) {
5801 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
5802 ASC_ASSERT(ascq->q_last[tid] == reqp);
5803 ascq->q_last[tid] = NULL;
5805 #ifdef ADVANSYS_STATS
5806 /* Maintain request queue statistics. */
5807 ascq->q_cur_cnt[tid]--;
5808 ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
5809 REQTIMESTAT("asc_dequeue", ascq, reqp, tid);
5810 #endif /* ADVANSYS_STATS */
5812 ASC_DBG1(3, "asc_dequeue: reqp 0x%lx\n", (ulong)reqp);
5817 * Return a pointer to a singly linked list of all the requests queued
5818 * for 'tid' on the 'asc_queue_t' pointed to by 'ascq'.
5820 * If 'lastpp' is not NULL, '*lastpp' will be set to point to the
5821 * the last request returned in the singly linked list.
5823 * 'tid' should either be a valid target id or if it is ASC_TID_ALL,
5824 * then all queued requests are concatenated into one list and
5827 * Note: If 'lastpp' is used to append a new list to the end of
5828 * an old list, only change the old list last pointer if '*lastpp'
5829 * (or the function return value) is not NULL, i.e. use a temporary
5830 * variable for 'lastpp' and check its value after the function return
5831 * before assigning it to the list last pointer.
5833 * Unfortunately collecting queuing time statistics adds overhead to
5834 * the function that isn't inherent to the function's algorithm.
5836 static REQP asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
5841 ASC_DBG2(3, "asc_dequeue_list: ascq 0x%lx, tid %d\n", (ulong)ascq, tid);
5842 ASC_ASSERT((tid == ASC_TID_ALL) || (tid >= 0 && tid <= ADV_MAX_TID));
5845 * If 'tid' is not ASC_TID_ALL, return requests only for
5846 * the specified 'tid'. If 'tid' is ASC_TID_ALL, return all
5847 * requests for all tids.
5849 if (tid != ASC_TID_ALL) {
5850 /* Return all requests for the specified 'tid'. */
5851 if ((ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)) == 0) {
5852 /* List is empty; Set first and last return pointers to NULL. */
5853 firstp = lastp = NULL;
5855 firstp = ascq->q_first[tid];
5856 lastp = ascq->q_last[tid];
5857 ascq->q_first[tid] = ascq->q_last[tid] = NULL;
5858 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
5859 #ifdef ADVANSYS_STATS
5862 ascq->q_cur_cnt[tid] = 0;
5863 for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
5864 REQTIMESTAT("asc_dequeue_list", ascq,
5868 #endif /* ADVANSYS_STATS */
5871 /* Return all requests for all tids. */
5872 firstp = lastp = NULL;
5873 for (i = 0; i <= ADV_MAX_TID; i++) {
5874 if (ascq->q_tidmask & ADV_TID_TO_TIDMASK(i)) {
5875 if (firstp == NULL) {
5876 firstp = ascq->q_first[i];
5877 lastp = ascq->q_last[i];
5879 ASC_ASSERT(lastp != NULL);
5880 lastp->host_scribble =
5881 (unsigned char *)ascq->q_first[i];
5882 lastp = ascq->q_last[i];
5884 ascq->q_first[i] = ascq->q_last[i] = NULL;
5885 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(i);
5886 #ifdef ADVANSYS_STATS
5887 ascq->q_cur_cnt[i] = 0;
5888 #endif /* ADVANSYS_STATS */
5891 #ifdef ADVANSYS_STATS
5894 for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
5895 REQTIMESTAT("asc_dequeue_list", ascq, reqp,
5899 #endif /* ADVANSYS_STATS */
5904 ASC_DBG1(3, "asc_dequeue_list: firstp 0x%lx\n", (ulong)firstp);
5909 * Remove the specified 'REQP' from the specified queue for
5910 * the specified target device. Clear the 'tidmask' bit for the
5911 * device if no more commands are left queued for it.
5913 * 'REQPNEXT(reqp)' returns reqp's the next pointer.
5915 * Return ASC_TRUE if the command was found and removed,
5916 * otherwise return ASC_FALSE.
5918 static int asc_rmqueue(asc_queue_t *ascq, REQP reqp)
5922 int ret = ASC_FALSE;
5924 ASC_DBG2(3, "asc_rmqueue: ascq 0x%lx, reqp 0x%lx\n",
5925 (ulong)ascq, (ulong)reqp);
5926 ASC_ASSERT(reqp != NULL);
5928 tid = REQPTID(reqp);
5929 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
5932 * Handle the common case of 'reqp' being the first
5933 * entry on the queue.
5935 if (reqp == ascq->q_first[tid]) {
5937 ascq->q_first[tid] = REQPNEXT(reqp);
5938 /* If the queue is now empty, clear its bit and the last pointer. */
5939 if (ascq->q_first[tid] == NULL) {
5940 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
5941 ASC_ASSERT(ascq->q_last[tid] == reqp);
5942 ascq->q_last[tid] = NULL;
5944 } else if (ascq->q_first[tid] != NULL) {
5945 ASC_ASSERT(ascq->q_last[tid] != NULL);
5947 * Because the case of 'reqp' being the first entry has been
5948 * handled above and it is known the queue is not empty, if
5949 * 'reqp' is found on the queue it is guaranteed the queue will
5950 * not become empty and that 'q_first[tid]' will not be changed.
5952 * Set 'prevp' to the first entry, 'currp' to the second entry,
5953 * and search for 'reqp'.
5955 for (prevp = ascq->q_first[tid], currp = REQPNEXT(prevp);
5956 currp; prevp = currp, currp = REQPNEXT(currp)) {
5957 if (currp == reqp) {
5959 prevp->host_scribble =
5960 (unsigned char *)REQPNEXT(currp);
5961 reqp->host_scribble = NULL;
5962 if (ascq->q_last[tid] == reqp) {
5963 ascq->q_last[tid] = prevp;
5969 #ifdef ADVANSYS_STATS
5970 /* Maintain request queue statistics. */
5971 if (ret == ASC_TRUE) {
5972 ascq->q_cur_cnt[tid]--;
5973 REQTIMESTAT("asc_rmqueue", ascq, reqp, tid);
5975 ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
5976 #endif /* ADVANSYS_STATS */
5977 ASC_DBG2(3, "asc_rmqueue: reqp 0x%lx, ret %d\n", (ulong)reqp, ret);
5982 * Execute as many queued requests as possible for the specified queue.
5984 * Calls asc_execute_scsi_cmnd() to execute a REQP/struct scsi_cmnd.
5986 static void asc_execute_queue(asc_queue_t *ascq)
5988 ADV_SCSI_BIT_ID_TYPE scan_tidmask;
5992 ASC_DBG1(1, "asc_execute_queue: ascq 0x%lx\n", (ulong)ascq);
5994 * Execute queued commands for devices attached to
5995 * the current board in round-robin fashion.
5997 scan_tidmask = ascq->q_tidmask;
5999 for (i = 0; i <= ADV_MAX_TID; i++) {
6000 if (scan_tidmask & ADV_TID_TO_TIDMASK(i)) {
6001 if ((reqp = asc_dequeue(ascq, i)) == NULL) {
6002 scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
6004 if (asc_execute_scsi_cmnd
6005 ((struct scsi_cmnd *)reqp)
6007 scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
6009 * The request returned ASC_BUSY. Enqueue at the front of
6010 * target's waiting list to maintain correct ordering.
6012 asc_enqueue(ascq, reqp, ASC_FRONT);
6016 } while (scan_tidmask);
6020 #ifdef CONFIG_PROC_FS
6022 * asc_prt_board_devices()
6024 * Print driver information for devices attached to the board.
6026 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
6027 * cf. asc_prt_line().
6029 * Return the number of characters copied into 'cp'. No more than
6030 * 'cplen' characters will be copied to 'cp'.
6032 static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
6034 asc_board_t *boardp;
6041 boardp = ASC_BOARDP(shost);
6045 len = asc_prt_line(cp, leftlen,
6046 "\nDevice Information for AdvanSys SCSI Host %d:\n",
6050 if (ASC_NARROW_BOARD(boardp)) {
6051 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
6053 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
6056 len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
6058 for (i = 0; i <= ADV_MAX_TID; i++) {
6059 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
6060 len = asc_prt_line(cp, leftlen, " %X,", i);
6064 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
6071 * Display Wide Board BIOS Information.
6073 static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
6075 asc_board_t *boardp;
6079 ushort major, minor, letter;
6081 boardp = ASC_BOARDP(shost);
6085 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
6089 * If the BIOS saved a valid signature, then fill in
6090 * the BIOS code segment base address.
6092 if (boardp->bios_signature != 0x55AA) {
6093 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
6095 len = asc_prt_line(cp, leftlen,
6096 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
6098 len = asc_prt_line(cp, leftlen,
6099 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
6102 major = (boardp->bios_version >> 12) & 0xF;
6103 minor = (boardp->bios_version >> 8) & 0xF;
6104 letter = (boardp->bios_version & 0xFF);
6106 len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
6108 letter >= 26 ? '?' : letter + 'A');
6112 * Current available ROM BIOS release is 3.1I for UW
6113 * and 3.2I for U2W. This code doesn't differentiate
6114 * UW and U2W boards.
6116 if (major < 3 || (major <= 3 && minor < 1) ||
6117 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
6118 len = asc_prt_line(cp, leftlen,
6119 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
6121 len = asc_prt_line(cp, leftlen,
6122 "ftp://ftp.connectcom.net/pub\n");
6131 * Add serial number to information bar if signature AAh
6132 * is found in at bit 15-9 (7 bits) of word 1.
6134 * Serial Number consists fo 12 alpha-numeric digits.
6136 * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
6137 * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
6138 * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
6139 * 5 - Product revision (A-J) Word0: " "
6141 * Signature Word1: 15-9 (7 bits)
6142 * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
6143 * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
6145 * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
6147 * Note 1: Only production cards will have a serial number.
6149 * Note 2: Signature is most significant 7 bits (0xFE).
6151 * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
6153 static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
6157 if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
6161 * First word - 6 digits.
6165 /* Product type - 1st digit. */
6166 if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
6167 /* Product type is P=Prototype */
6172 /* Manufacturing location - 2nd digit. */
6173 *cp++ = 'A' + ((w & 0x1C00) >> 10);
6175 /* Product ID - 3rd, 4th digits. */
6177 *cp++ = '0' + (num / 100);
6179 *cp++ = '0' + (num / 10);
6181 /* Product revision - 5th digit. */
6182 *cp++ = 'A' + (num % 10);
6192 * If bit 15 of third word is set, then the
6193 * last digit of the year is greater than 7.
6195 if (serialnum[2] & 0x8000) {
6196 *cp++ = '8' + ((w & 0x1C0) >> 6);
6198 *cp++ = '0' + ((w & 0x1C0) >> 6);
6201 /* Week of year - 7th, 8th digits. */
6203 *cp++ = '0' + num / 10;
6210 w = serialnum[2] & 0x7FFF;
6212 /* Serial number - 9th digit. */
6213 *cp++ = 'A' + (w / 1000);
6215 /* 10th, 11th, 12th digits. */
6217 *cp++ = '0' + num / 100;
6219 *cp++ = '0' + num / 10;
6223 *cp = '\0'; /* Null Terminate the string. */
6229 * asc_prt_asc_board_eeprom()
6231 * Print board EEPROM configuration.
6233 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
6234 * cf. asc_prt_line().
6236 * Return the number of characters copied into 'cp'. No more than
6237 * 'cplen' characters will be copied to 'cp'.
6239 static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
6241 asc_board_t *boardp;
6242 ASC_DVC_VAR *asc_dvc_varp;
6249 int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
6250 #endif /* CONFIG_ISA */
6251 uchar serialstr[13];
6253 boardp = ASC_BOARDP(shost);
6254 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
6255 ep = &boardp->eep_config.asc_eep;
6260 len = asc_prt_line(cp, leftlen,
6261 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
6265 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
6268 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
6272 if (ep->adapter_info[5] == 0xBB) {
6273 len = asc_prt_line(cp, leftlen,
6274 " Default Settings Used for EEPROM-less Adapter.\n");
6277 len = asc_prt_line(cp, leftlen,
6278 " Serial Number Signature Not Present.\n");
6283 len = asc_prt_line(cp, leftlen,
6284 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
6285 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
6289 len = asc_prt_line(cp, leftlen,
6290 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
6293 len = asc_prt_line(cp, leftlen, " Target ID: ");
6295 for (i = 0; i <= ASC_MAX_TID; i++) {
6296 len = asc_prt_line(cp, leftlen, " %d", i);
6299 len = asc_prt_line(cp, leftlen, "\n");
6302 len = asc_prt_line(cp, leftlen, " Disconnects: ");
6304 for (i = 0; i <= ASC_MAX_TID; i++) {
6305 len = asc_prt_line(cp, leftlen, " %c",
6307 disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
6311 len = asc_prt_line(cp, leftlen, "\n");
6314 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
6316 for (i = 0; i <= ASC_MAX_TID; i++) {
6317 len = asc_prt_line(cp, leftlen, " %c",
6319 use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
6323 len = asc_prt_line(cp, leftlen, "\n");
6326 len = asc_prt_line(cp, leftlen, " Start Motor: ");
6328 for (i = 0; i <= ASC_MAX_TID; i++) {
6329 len = asc_prt_line(cp, leftlen, " %c",
6331 start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
6335 len = asc_prt_line(cp, leftlen, "\n");
6338 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
6340 for (i = 0; i <= ASC_MAX_TID; i++) {
6341 len = asc_prt_line(cp, leftlen, " %c",
6343 init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
6347 len = asc_prt_line(cp, leftlen, "\n");
6351 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
6352 len = asc_prt_line(cp, leftlen,
6353 " Host ISA DMA speed: %d MB/S\n",
6354 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
6357 #endif /* CONFIG_ISA */
6363 * asc_prt_adv_board_eeprom()
6365 * Print board EEPROM configuration.
6367 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
6368 * cf. asc_prt_line().
6370 * Return the number of characters copied into 'cp'. No more than
6371 * 'cplen' characters will be copied to 'cp'.
6373 static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
6375 asc_board_t *boardp;
6376 ADV_DVC_VAR *adv_dvc_varp;
6382 uchar serialstr[13];
6383 ADVEEP_3550_CONFIG *ep_3550 = NULL;
6384 ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
6385 ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
6388 ushort sdtr_speed = 0;
6390 boardp = ASC_BOARDP(shost);
6391 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
6392 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6393 ep_3550 = &boardp->eep_config.adv_3550_eep;
6394 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6395 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
6397 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
6403 len = asc_prt_line(cp, leftlen,
6404 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
6408 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6409 wordp = &ep_3550->serial_number_word1;
6410 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6411 wordp = &ep_38C0800->serial_number_word1;
6413 wordp = &ep_38C1600->serial_number_word1;
6416 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
6418 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
6422 len = asc_prt_line(cp, leftlen,
6423 " Serial Number Signature Not Present.\n");
6427 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6428 len = asc_prt_line(cp, leftlen,
6429 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
6430 ep_3550->adapter_scsi_id,
6431 ep_3550->max_host_qng, ep_3550->max_dvc_qng);
6433 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6434 len = asc_prt_line(cp, leftlen,
6435 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
6436 ep_38C0800->adapter_scsi_id,
6437 ep_38C0800->max_host_qng,
6438 ep_38C0800->max_dvc_qng);
6441 len = asc_prt_line(cp, leftlen,
6442 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
6443 ep_38C1600->adapter_scsi_id,
6444 ep_38C1600->max_host_qng,
6445 ep_38C1600->max_dvc_qng);
6448 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6449 word = ep_3550->termination;
6450 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6451 word = ep_38C0800->termination_lvd;
6453 word = ep_38C1600->termination_lvd;
6457 termstr = "Low Off/High Off";
6460 termstr = "Low Off/High On";
6463 termstr = "Low On/High On";
6467 termstr = "Automatic";
6471 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6472 len = asc_prt_line(cp, leftlen,
6473 " termination: %u (%s), bios_ctrl: 0x%x\n",
6474 ep_3550->termination, termstr,
6475 ep_3550->bios_ctrl);
6477 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6478 len = asc_prt_line(cp, leftlen,
6479 " termination: %u (%s), bios_ctrl: 0x%x\n",
6480 ep_38C0800->termination_lvd, termstr,
6481 ep_38C0800->bios_ctrl);
6484 len = asc_prt_line(cp, leftlen,
6485 " termination: %u (%s), bios_ctrl: 0x%x\n",
6486 ep_38C1600->termination_lvd, termstr,
6487 ep_38C1600->bios_ctrl);
6491 len = asc_prt_line(cp, leftlen, " Target ID: ");
6493 for (i = 0; i <= ADV_MAX_TID; i++) {
6494 len = asc_prt_line(cp, leftlen, " %X", i);
6497 len = asc_prt_line(cp, leftlen, "\n");
6500 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6501 word = ep_3550->disc_enable;
6502 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6503 word = ep_38C0800->disc_enable;
6505 word = ep_38C1600->disc_enable;
6507 len = asc_prt_line(cp, leftlen, " Disconnects: ");
6509 for (i = 0; i <= ADV_MAX_TID; i++) {
6510 len = asc_prt_line(cp, leftlen, " %c",
6511 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
6514 len = asc_prt_line(cp, leftlen, "\n");
6517 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6518 word = ep_3550->tagqng_able;
6519 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6520 word = ep_38C0800->tagqng_able;
6522 word = ep_38C1600->tagqng_able;
6524 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
6526 for (i = 0; i <= ADV_MAX_TID; i++) {
6527 len = asc_prt_line(cp, leftlen, " %c",
6528 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
6531 len = asc_prt_line(cp, leftlen, "\n");
6534 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6535 word = ep_3550->start_motor;
6536 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6537 word = ep_38C0800->start_motor;
6539 word = ep_38C1600->start_motor;
6541 len = asc_prt_line(cp, leftlen, " Start Motor: ");
6543 for (i = 0; i <= ADV_MAX_TID; i++) {
6544 len = asc_prt_line(cp, leftlen, " %c",
6545 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
6548 len = asc_prt_line(cp, leftlen, "\n");
6551 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6552 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
6554 for (i = 0; i <= ADV_MAX_TID; i++) {
6555 len = asc_prt_line(cp, leftlen, " %c",
6557 sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
6561 len = asc_prt_line(cp, leftlen, "\n");
6565 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6566 len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
6568 for (i = 0; i <= ADV_MAX_TID; i++) {
6569 len = asc_prt_line(cp, leftlen, " %c",
6571 ultra_able & ADV_TID_TO_TIDMASK(i))
6575 len = asc_prt_line(cp, leftlen, "\n");
6579 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6580 word = ep_3550->wdtr_able;
6581 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6582 word = ep_38C0800->wdtr_able;
6584 word = ep_38C1600->wdtr_able;
6586 len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
6588 for (i = 0; i <= ADV_MAX_TID; i++) {
6589 len = asc_prt_line(cp, leftlen, " %c",
6590 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
6593 len = asc_prt_line(cp, leftlen, "\n");
6596 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
6597 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
6598 len = asc_prt_line(cp, leftlen,
6599 " Synchronous Transfer Speed (Mhz):\n ");
6601 for (i = 0; i <= ADV_MAX_TID; i++) {
6605 sdtr_speed = adv_dvc_varp->sdtr_speed1;
6606 } else if (i == 4) {
6607 sdtr_speed = adv_dvc_varp->sdtr_speed2;
6608 } else if (i == 8) {
6609 sdtr_speed = adv_dvc_varp->sdtr_speed3;
6610 } else if (i == 12) {
6611 sdtr_speed = adv_dvc_varp->sdtr_speed4;
6613 switch (sdtr_speed & ADV_MAX_TID) {
6636 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
6639 len = asc_prt_line(cp, leftlen, "\n ");
6644 len = asc_prt_line(cp, leftlen, "\n");
6652 * asc_prt_driver_conf()
6654 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
6655 * cf. asc_prt_line().
6657 * Return the number of characters copied into 'cp'. No more than
6658 * 'cplen' characters will be copied to 'cp'.
6660 static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
6662 asc_board_t *boardp;
6668 boardp = ASC_BOARDP(shost);
6673 len = asc_prt_line(cp, leftlen,
6674 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
6678 len = asc_prt_line(cp, leftlen,
6679 " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
6680 shost->host_busy, shost->last_reset, shost->max_id,
6681 shost->max_lun, shost->max_channel);
6684 len = asc_prt_line(cp, leftlen,
6685 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
6686 shost->unique_id, shost->can_queue, shost->this_id,
6687 shost->sg_tablesize, shost->cmd_per_lun);
6690 len = asc_prt_line(cp, leftlen,
6691 " unchecked_isa_dma %d, use_clustering %d\n",
6692 shost->unchecked_isa_dma, shost->use_clustering);
6695 len = asc_prt_line(cp, leftlen,
6696 " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
6697 boardp->flags, boardp->last_reset, jiffies,
6698 boardp->asc_n_io_port);
6701 /* 'shost->n_io_port' may be truncated because it is only one byte. */
6702 len = asc_prt_line(cp, leftlen,
6703 " io_port 0x%x, n_io_port 0x%x\n",
6704 shost->io_port, shost->n_io_port);
6707 if (ASC_NARROW_BOARD(boardp)) {
6708 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
6710 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
6717 * asc_prt_asc_board_info()
6719 * Print dynamic board configuration information.
6721 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
6722 * cf. asc_prt_line().
6724 * Return the number of characters copied into 'cp'. No more than
6725 * 'cplen' characters will be copied to 'cp'.
6727 static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
6729 asc_board_t *boardp;
6737 int renegotiate = 0;
6739 boardp = ASC_BOARDP(shost);
6740 v = &boardp->dvc_var.asc_dvc_var;
6741 c = &boardp->dvc_cfg.asc_dvc_cfg;
6742 chip_scsi_id = c->chip_scsi_id;
6747 len = asc_prt_line(cp, leftlen,
6748 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
6752 len = asc_prt_line(cp, leftlen,
6753 " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
6754 c->chip_version, c->lib_version, c->lib_serial_no,
6758 len = asc_prt_line(cp, leftlen,
6759 " mcode_version 0x%x, err_code %u\n",
6760 c->mcode_version, v->err_code);
6763 /* Current number of commands waiting for the host. */
6764 len = asc_prt_line(cp, leftlen,
6765 " Total Command Pending: %d\n", v->cur_total_qng);
6768 len = asc_prt_line(cp, leftlen, " Command Queuing:");
6770 for (i = 0; i <= ASC_MAX_TID; i++) {
6771 if ((chip_scsi_id == i) ||
6772 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
6775 len = asc_prt_line(cp, leftlen, " %X:%c",
6778 use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
6782 len = asc_prt_line(cp, leftlen, "\n");
6785 /* Current number of commands waiting for a device. */
6786 len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
6788 for (i = 0; i <= ASC_MAX_TID; i++) {
6789 if ((chip_scsi_id == i) ||
6790 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
6793 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
6796 len = asc_prt_line(cp, leftlen, "\n");
6799 /* Current limit on number of commands that can be sent to a device. */
6800 len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
6802 for (i = 0; i <= ASC_MAX_TID; i++) {
6803 if ((chip_scsi_id == i) ||
6804 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
6807 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
6810 len = asc_prt_line(cp, leftlen, "\n");
6813 /* Indicate whether the device has returned queue full status. */
6814 len = asc_prt_line(cp, leftlen, " Command Queue Full:");
6816 for (i = 0; i <= ASC_MAX_TID; i++) {
6817 if ((chip_scsi_id == i) ||
6818 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
6821 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
6822 len = asc_prt_line(cp, leftlen, " %X:Y-%d",
6823 i, boardp->queue_full_cnt[i]);
6825 len = asc_prt_line(cp, leftlen, " %X:N", i);
6829 len = asc_prt_line(cp, leftlen, "\n");
6832 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
6834 for (i = 0; i <= ASC_MAX_TID; i++) {
6835 if ((chip_scsi_id == i) ||
6836 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
6839 len = asc_prt_line(cp, leftlen, " %X:%c",
6842 sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
6846 len = asc_prt_line(cp, leftlen, "\n");
6849 for (i = 0; i <= ASC_MAX_TID; i++) {
6850 uchar syn_period_ix;
6852 if ((chip_scsi_id == i) ||
6853 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
6854 ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
6858 len = asc_prt_line(cp, leftlen, " %X:", i);
6861 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
6862 len = asc_prt_line(cp, leftlen, " Asynchronous");
6866 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
6869 len = asc_prt_line(cp, leftlen,
6870 " Transfer Period Factor: %d (%d.%d Mhz),",
6871 v->sdtr_period_tbl[syn_period_ix],
6873 v->sdtr_period_tbl[syn_period_ix],
6880 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
6882 sdtr_data[i] & ASC_SYN_MAX_OFFSET);
6886 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
6887 len = asc_prt_line(cp, leftlen, "*\n");
6890 len = asc_prt_line(cp, leftlen, "\n");
6896 len = asc_prt_line(cp, leftlen,
6897 " * = Re-negotiation pending before next command.\n");
6905 * asc_prt_adv_board_info()
6907 * Print dynamic board configuration information.
6909 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
6910 * cf. asc_prt_line().
6912 * Return the number of characters copied into 'cp'. No more than
6913 * 'cplen' characters will be copied to 'cp'.
6915 static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
6917 asc_board_t *boardp;
6924 AdvPortAddr iop_base;
6925 ushort chip_scsi_id;
6929 ushort sdtr_able, wdtr_able;
6930 ushort wdtr_done, sdtr_done;
6932 int renegotiate = 0;
6934 boardp = ASC_BOARDP(shost);
6935 v = &boardp->dvc_var.adv_dvc_var;
6936 c = &boardp->dvc_cfg.adv_dvc_cfg;
6937 iop_base = v->iop_base;
6938 chip_scsi_id = v->chip_scsi_id;
6943 len = asc_prt_line(cp, leftlen,
6944 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
6948 len = asc_prt_line(cp, leftlen,
6949 " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
6951 AdvReadWordRegister(iop_base,
6952 IOPW_SCSI_CFG1) & CABLE_DETECT,
6956 len = asc_prt_line(cp, leftlen,
6957 " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
6958 c->chip_version, c->lib_version, c->mcode_date,
6962 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
6963 len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
6965 for (i = 0; i <= ADV_MAX_TID; i++) {
6966 if ((chip_scsi_id == i) ||
6967 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
6971 len = asc_prt_line(cp, leftlen, " %X:%c",
6973 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
6977 len = asc_prt_line(cp, leftlen, "\n");
6980 len = asc_prt_line(cp, leftlen, " Queue Limit:");
6982 for (i = 0; i <= ADV_MAX_TID; i++) {
6983 if ((chip_scsi_id == i) ||
6984 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
6988 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
6991 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
6994 len = asc_prt_line(cp, leftlen, "\n");
6997 len = asc_prt_line(cp, leftlen, " Command Pending:");
6999 for (i = 0; i <= ADV_MAX_TID; i++) {
7000 if ((chip_scsi_id == i) ||
7001 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
7005 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
7008 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
7011 len = asc_prt_line(cp, leftlen, "\n");
7014 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7015 len = asc_prt_line(cp, leftlen, " Wide Enabled:");
7017 for (i = 0; i <= ADV_MAX_TID; i++) {
7018 if ((chip_scsi_id == i) ||
7019 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
7023 len = asc_prt_line(cp, leftlen, " %X:%c",
7025 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
7029 len = asc_prt_line(cp, leftlen, "\n");
7032 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
7033 len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
7035 for (i = 0; i <= ADV_MAX_TID; i++) {
7036 if ((chip_scsi_id == i) ||
7037 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
7041 AdvReadWordLram(iop_base,
7042 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
7045 len = asc_prt_line(cp, leftlen, " %X:%d",
7046 i, (lramword & 0x8000) ? 16 : 8);
7049 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
7050 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
7051 len = asc_prt_line(cp, leftlen, "*");
7056 len = asc_prt_line(cp, leftlen, "\n");
7059 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7060 len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
7062 for (i = 0; i <= ADV_MAX_TID; i++) {
7063 if ((chip_scsi_id == i) ||
7064 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
7068 len = asc_prt_line(cp, leftlen, " %X:%c",
7070 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
7074 len = asc_prt_line(cp, leftlen, "\n");
7077 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
7078 for (i = 0; i <= ADV_MAX_TID; i++) {
7080 AdvReadWordLram(iop_base,
7081 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
7083 lramword &= ~0x8000;
7085 if ((chip_scsi_id == i) ||
7086 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
7087 ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
7091 len = asc_prt_line(cp, leftlen, " %X:", i);
7094 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
7095 len = asc_prt_line(cp, leftlen, " Asynchronous");
7099 asc_prt_line(cp, leftlen,
7100 " Transfer Period Factor: ");
7103 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
7105 asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
7107 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
7109 asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
7111 } else { /* 20 Mhz or below. */
7113 period = (((lramword >> 8) * 25) + 50) / 4;
7115 if (period == 0) { /* Should never happen. */
7117 asc_prt_line(cp, leftlen,
7121 len = asc_prt_line(cp, leftlen,
7123 period, 250 / period,
7130 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
7135 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
7136 len = asc_prt_line(cp, leftlen, "*\n");
7139 len = asc_prt_line(cp, leftlen, "\n");
7145 len = asc_prt_line(cp, leftlen,
7146 " * = Re-negotiation pending before next command.\n");
7156 * Copy proc information to a read buffer taking into account the current
7157 * read offset in the file and the remaining space in the read buffer.
7160 asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
7161 char *cp, int cplen)
7165 ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
7166 (unsigned)offset, (unsigned)advoffset, cplen);
7167 if (offset <= advoffset) {
7168 /* Read offset below current offset, copy everything. */
7169 cnt = min(cplen, leftlen);
7170 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
7171 (ulong)curbuf, (ulong)cp, cnt);
7172 memcpy(curbuf, cp, cnt);
7173 } else if (offset < advoffset + cplen) {
7174 /* Read offset within current range, partial copy. */
7175 cnt = (advoffset + cplen) - offset;
7176 cp = (cp + cplen) - cnt;
7177 cnt = min(cnt, leftlen);
7178 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
7179 (ulong)curbuf, (ulong)cp, cnt);
7180 memcpy(curbuf, cp, cnt);
7188 * If 'cp' is NULL print to the console, otherwise print to a buffer.
7190 * Return 0 if printing to the console, otherwise return the number of
7191 * bytes written to the buffer.
7193 * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
7194 * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
7196 static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
7200 char s[ASC_PRTLINE_SIZE];
7202 va_start(args, fmt);
7203 ret = vsprintf(s, fmt, args);
7204 ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
7209 ret = min(buflen, ret);
7210 memcpy(buf, s, ret);
7215 #endif /* CONFIG_PROC_FS */
7218 * --- Functions Required by the Asc Library
7222 * Delay for 'n' milliseconds. Don't use the 'jiffies'
7223 * global variable which is incremented once every 5 ms
7224 * from a timer interrupt, because this function may be
7225 * called when interrupts are disabled.
7227 static void DvcSleepMilliSecond(ADV_DCNT n)
7229 ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong)n);
7234 * Currently and inline noop but leave as a placeholder.
7235 * Leave DvcEnterCritical() as a noop placeholder.
7237 static inline ulong DvcEnterCritical(void)
7243 * Critical sections are all protected by the board spinlock.
7244 * Leave DvcLeaveCritical() as a noop placeholder.
7246 static inline void DvcLeaveCritical(ulong flags)
7253 * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
7255 * Calling/Exit State:
7259 * Output an ASC_SCSI_Q structure to the chip
7262 DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
7266 ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
7267 AscSetChipLramAddr(iop_base, s_addr);
7268 for (i = 0; i < 2 * words; i += 2) {
7269 if (i == 4 || i == 20) {
7272 outpw(iop_base + IOP_RAM_DATA,
7273 ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
7279 * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
7281 * Calling/Exit State:
7285 * Input an ASC_QDONE_INFO structure from the chip
7288 DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
7293 AscSetChipLramAddr(iop_base, s_addr);
7294 for (i = 0; i < 2 * words; i += 2) {
7298 word = inpw(iop_base + IOP_RAM_DATA);
7299 inbuf[i] = word & 0xff;
7300 inbuf[i + 1] = (word >> 8) & 0xff;
7302 ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
7306 * Return the BIOS address of the adapter at the specified
7307 * I/O port and with the specified bus type.
7309 static ushort __devinit AscGetChipBiosAddress(PortAddr iop_base, ushort bus_type)
7315 * The PCI BIOS is re-located by the motherboard BIOS. Because
7316 * of this the driver can not determine where a PCI BIOS is
7317 * loaded and executes.
7319 if (bus_type & ASC_IS_PCI) {
7323 if ((bus_type & ASC_IS_EISA) != 0) {
7324 cfg_lsw = AscGetEisaChipCfg(iop_base);
7326 bios_addr = (ushort)(ASC_BIOS_MIN_ADDR +
7327 (cfg_lsw * ASC_BIOS_BANK_SIZE));
7330 #endif /* CONFIG_ISA */
7332 cfg_lsw = AscGetChipCfgLsw(iop_base);
7335 * ISA PnP uses the top bit as the 32K BIOS flag
7337 if (bus_type == ASC_IS_ISAPNP) {
7341 bios_addr = (ushort)(((cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE) +
7347 * --- Functions Required by the Adv Library
7353 * Return the physical address of 'vaddr' and set '*lenp' to the
7354 * number of physically contiguous bytes that follow 'vaddr'.
7355 * 'flag' indicates the type of structure whose physical address
7356 * is being translated.
7358 * Note: Because Linux currently doesn't page the kernel and all
7359 * kernel buffers are physically contiguous, leave '*lenp' unchanged.
7362 DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
7363 uchar *vaddr, ADV_SDCNT *lenp, int flag)
7367 paddr = virt_to_bus(vaddr);
7370 "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
7371 (ulong)vaddr, (ulong)lenp, (ulong)*((ulong *)lenp),
7378 * --- Tracing and Debugging Functions
7381 #ifdef ADVANSYS_STATS
7382 #ifdef CONFIG_PROC_FS
7384 * asc_prt_board_stats()
7386 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
7387 * cf. asc_prt_line().
7389 * Return the number of characters copied into 'cp'. No more than
7390 * 'cplen' characters will be copied to 'cp'.
7392 static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
7397 struct asc_stats *s;
7398 asc_board_t *boardp;
7403 boardp = ASC_BOARDP(shost);
7404 s = &boardp->asc_stats;
7406 len = asc_prt_line(cp, leftlen,
7407 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
7411 len = asc_prt_line(cp, leftlen,
7412 " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
7413 s->queuecommand, s->reset, s->biosparam,
7417 len = asc_prt_line(cp, leftlen,
7418 " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
7419 s->callback, s->done, s->build_error,
7420 s->adv_build_noreq, s->adv_build_nosg);
7423 len = asc_prt_line(cp, leftlen,
7424 " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
7425 s->exe_noerror, s->exe_busy, s->exe_error,
7430 * Display data transfer statistics.
7432 if (s->cont_cnt > 0) {
7433 len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
7436 len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
7438 ASC_TENTHS(s->cont_xfer, 2));
7441 /* Contiguous transfer average size */
7442 len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
7443 (s->cont_xfer / 2) / s->cont_cnt,
7444 ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
7448 if (s->sg_cnt > 0) {
7450 len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
7451 s->sg_cnt, s->sg_elem);
7454 len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
7455 s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
7458 /* Scatter gather transfer statistics */
7459 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
7460 s->sg_elem / s->sg_cnt,
7461 ASC_TENTHS(s->sg_elem, s->sg_cnt));
7464 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
7465 (s->sg_xfer / 2) / s->sg_elem,
7466 ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
7469 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
7470 (s->sg_xfer / 2) / s->sg_cnt,
7471 ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
7476 * Display request queuing statistics.
7478 len = asc_prt_line(cp, leftlen,
7479 " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
7487 * asc_prt_target_stats()
7489 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
7490 * cf. asc_prt_line().
7492 * This is separated from asc_prt_board_stats because a full set
7493 * of targets will overflow ASC_PRTBUF_SIZE.
7495 * Return the number of characters copied into 'cp'. No more than
7496 * 'cplen' characters will be copied to 'cp'.
7499 asc_prt_target_stats(struct Scsi_Host *shost, int tgt_id, char *cp, int cplen)
7504 struct asc_stats *s;
7505 ushort chip_scsi_id;
7506 asc_board_t *boardp;
7507 asc_queue_t *active;
7508 asc_queue_t *waiting;
7513 boardp = ASC_BOARDP(shost);
7514 s = &boardp->asc_stats;
7516 active = &ASC_BOARDP(shost)->active;
7517 waiting = &ASC_BOARDP(shost)->waiting;
7519 if (ASC_NARROW_BOARD(boardp)) {
7520 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
7522 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
7525 if ((chip_scsi_id == tgt_id) ||
7526 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(tgt_id)) == 0)) {
7531 if (active->q_tot_cnt[tgt_id] > 0
7532 || waiting->q_tot_cnt[tgt_id] > 0) {
7533 len = asc_prt_line(cp, leftlen, " target %d\n", tgt_id);
7536 len = asc_prt_line(cp, leftlen,
7537 " active: cnt [cur %d, max %d, tot %u], time [min %d, max %d, avg %lu.%01lu]\n",
7538 active->q_cur_cnt[tgt_id],
7539 active->q_max_cnt[tgt_id],
7540 active->q_tot_cnt[tgt_id],
7541 active->q_min_tim[tgt_id],
7542 active->q_max_tim[tgt_id],
7543 (active->q_tot_cnt[tgt_id] ==
7548 (active->q_tot_cnt[tgt_id] ==
7549 0) ? 0 : ASC_TENTHS(active->
7557 len = asc_prt_line(cp, leftlen,
7558 " waiting: cnt [cur %d, max %d, tot %u], time [min %u, max %u, avg %lu.%01lu]\n",
7559 waiting->q_cur_cnt[tgt_id],
7560 waiting->q_max_cnt[tgt_id],
7561 waiting->q_tot_cnt[tgt_id],
7562 waiting->q_min_tim[tgt_id],
7563 waiting->q_max_tim[tgt_id],
7564 (waiting->q_tot_cnt[tgt_id] ==
7569 (waiting->q_tot_cnt[tgt_id] ==
7570 0) ? 0 : ASC_TENTHS(waiting->
7582 #endif /* CONFIG_PROC_FS */
7583 #endif /* ADVANSYS_STATS */
7585 #ifdef ADVANSYS_DEBUG
7587 * asc_prt_scsi_host()
7589 static void asc_prt_scsi_host(struct Scsi_Host *s)
7591 asc_board_t *boardp;
7593 boardp = ASC_BOARDP(s);
7595 printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
7596 printk(" host_busy %u, host_no %d, last_reset %d,\n",
7597 s->host_busy, s->host_no, (unsigned)s->last_reset);
7599 printk(" base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n",
7600 (ulong)s->base, (ulong)s->io_port, s->n_io_port, s->irq);
7602 printk(" dma_channel %d, this_id %d, can_queue %d,\n",
7603 s->dma_channel, s->this_id, s->can_queue);
7605 printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
7606 s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
7608 if (ASC_NARROW_BOARD(boardp)) {
7609 asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
7610 asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
7612 asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
7613 asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
7618 * asc_prt_scsi_cmnd()
7620 static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
7622 printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
7624 printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
7625 (ulong)s->device->host, (ulong)s->device, s->device->id,
7626 s->device->lun, s->device->channel);
7628 asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
7630 printk("sc_data_direction %u, resid %d\n",
7631 s->sc_data_direction, s->resid);
7633 printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
7635 printk(" serial_number 0x%x, retries %d, allowed %d\n",
7636 (unsigned)s->serial_number, s->retries, s->allowed);
7638 printk(" timeout_per_command %d\n", s->timeout_per_command);
7641 (" scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n",
7642 (ulong)s->scsi_done, (ulong)s->done, (ulong)s->host_scribble,
7645 printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
7649 * asc_prt_asc_dvc_var()
7651 static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
7653 printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
7656 (" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl %d,\n",
7657 h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
7660 (" bus_type %d, isr_callback 0x%lx, exe_callback 0x%lx, init_sdtr 0x%x,\n",
7661 h->bus_type, (ulong)h->isr_callback, (ulong)h->exe_callback,
7662 (unsigned)h->init_sdtr);
7665 (" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, chip_no 0x%x,\n",
7666 (unsigned)h->sdtr_done, (unsigned)h->use_tagged_qng,
7667 (unsigned)h->unit_not_ready, (unsigned)h->chip_no);
7670 (" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait %u,\n",
7671 (unsigned)h->queue_full_or_busy, (unsigned)h->start_motor,
7672 (unsigned)h->scsi_reset_wait);
7675 (" is_in_int %u, max_total_qng %u, cur_total_qng %u, in_critical_cnt %u,\n",
7676 (unsigned)h->is_in_int, (unsigned)h->max_total_qng,
7677 (unsigned)h->cur_total_qng, (unsigned)h->in_critical_cnt);
7680 (" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, pci_fix_asyn_xfer 0x%x,\n",
7681 (unsigned)h->last_q_shortage, (unsigned)h->init_state,
7682 (unsigned)h->no_scam, (unsigned)h->pci_fix_asyn_xfer);
7684 printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
7688 * asc_prt_asc_dvc_cfg()
7690 static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
7692 printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
7694 printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
7695 h->can_tagged_qng, h->cmd_qng_enabled);
7696 printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
7697 h->disc_enable, h->sdtr_enable);
7700 (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
7701 h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
7705 (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
7706 to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
7709 printk(" mcode_version %d, overrun_buf 0x%lx\n",
7710 h->mcode_version, (ulong)h->overrun_buf);
7714 * asc_prt_asc_scsi_q()
7716 static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
7721 printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
7724 (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
7725 q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
7729 (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
7730 (ulong)le32_to_cpu(q->q1.data_addr),
7731 (ulong)le32_to_cpu(q->q1.data_cnt),
7732 (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
7734 printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
7735 (ulong)q->cdbptr, q->q2.cdb_len,
7736 (ulong)q->sg_head, q->q1.sg_queue_cnt);
7740 printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
7741 printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
7743 for (i = 0; i < sgp->entry_cnt; i++) {
7744 printk(" [%u]: addr 0x%lx, bytes %lu\n",
7745 i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
7746 (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
7753 * asc_prt_asc_qdone_info()
7755 static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
7757 printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
7758 printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
7759 (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
7762 (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
7763 q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
7767 * asc_prt_adv_dvc_var()
7769 * Display an ADV_DVC_VAR structure.
7771 static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
7773 printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
7775 printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
7776 (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
7778 printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
7779 (ulong)h->isr_callback, (unsigned)h->sdtr_able,
7780 (unsigned)h->wdtr_able);
7782 printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
7783 (unsigned)h->start_motor,
7784 (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
7786 printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
7787 (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
7788 (ulong)h->carr_freelist);
7790 printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
7791 (ulong)h->icq_sp, (ulong)h->irq_sp);
7793 printk(" no_scam 0x%x, tagqng_able 0x%x\n",
7794 (unsigned)h->no_scam, (unsigned)h->tagqng_able);
7796 printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
7797 (unsigned)h->chip_scsi_id, (ulong)h->cfg);
7801 * asc_prt_adv_dvc_cfg()
7803 * Display an ADV_DVC_CFG structure.
7805 static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
7807 printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
7809 printk(" disc_enable 0x%x, termination 0x%x\n",
7810 h->disc_enable, h->termination);
7812 printk(" chip_version 0x%x, mcode_date 0x%x\n",
7813 h->chip_version, h->mcode_date);
7815 printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
7816 h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
7818 printk(" control_flag 0x%x, pci_slot_info 0x%x\n",
7819 h->control_flag, h->pci_slot_info);
7823 * asc_prt_adv_scsi_req_q()
7825 * Display an ADV_SCSI_REQ_Q structure.
7827 static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
7830 struct asc_sg_block *sg_ptr;
7832 printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
7834 printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
7835 q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
7837 printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
7838 q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
7840 printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
7841 (ulong)le32_to_cpu(q->data_cnt),
7842 (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
7845 (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
7846 q->cdb_len, q->done_status, q->host_status, q->scsi_status);
7848 printk(" sg_working_ix 0x%x, target_cmd %u\n",
7849 q->sg_working_ix, q->target_cmd);
7851 printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
7852 (ulong)le32_to_cpu(q->scsiq_rptr),
7853 (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
7855 /* Display the request's ADV_SG_BLOCK structures. */
7856 if (q->sg_list_ptr != NULL) {
7860 * 'sg_ptr' is a physical address. Convert it to a virtual
7861 * address by indexing 'sg_blk_cnt' into the virtual address
7862 * array 'sg_list_ptr'.
7864 * XXX - Assumes all SG physical blocks are virtually contiguous.
7867 &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
7868 asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
7869 if (sg_ptr->sg_ptr == 0) {
7878 * asc_prt_adv_sgblock()
7880 * Display an ADV_SG_BLOCK structure.
7882 static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
7886 printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
7887 (ulong)b, sgblockno);
7888 printk(" sg_cnt %u, sg_ptr 0x%lx\n",
7889 b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
7890 ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
7891 if (b->sg_ptr != 0) {
7892 ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
7894 for (i = 0; i < b->sg_cnt; i++) {
7895 printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
7896 i, (ulong)b->sg_list[i].sg_addr,
7897 (ulong)b->sg_list[i].sg_count);
7904 * Print hexadecimal output in 4 byte groupings 32 bytes
7905 * or 8 double-words per line.
7907 static void asc_prt_hex(char *f, uchar *s, int l)
7914 printk("%s: (%d bytes)\n", f, l);
7916 for (i = 0; i < l; i += 32) {
7918 /* Display a maximum of 8 double-words per line. */
7919 if ((k = (l - i) / 4) >= 8) {
7926 for (j = 0; j < k; j++) {
7927 printk(" %2.2X%2.2X%2.2X%2.2X",
7928 (unsigned)s[i + (j * 4)],
7929 (unsigned)s[i + (j * 4) + 1],
7930 (unsigned)s[i + (j * 4) + 2],
7931 (unsigned)s[i + (j * 4) + 3]);
7939 printk(" %2.2X", (unsigned)s[i + (j * 4)]);
7942 printk(" %2.2X%2.2X",
7943 (unsigned)s[i + (j * 4)],
7944 (unsigned)s[i + (j * 4) + 1]);
7947 printk(" %2.2X%2.2X%2.2X",
7948 (unsigned)s[i + (j * 4) + 1],
7949 (unsigned)s[i + (j * 4) + 2],
7950 (unsigned)s[i + (j * 4) + 3]);
7957 #endif /* ADVANSYS_DEBUG */
7960 * --- Asc Library Functions
7963 static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
7965 PortAddr eisa_cfg_iop;
7967 eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
7968 (PortAddr) (ASC_EISA_CFG_IOP_MASK);
7969 return (inpw(eisa_cfg_iop));
7972 static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
7976 if (AscGetChipScsiID(iop_base) == new_host_id) {
7977 return (new_host_id);
7979 cfg_lsw = AscGetChipCfgLsw(iop_base);
7981 cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
7982 AscSetChipCfgLsw(iop_base, cfg_lsw);
7983 return (AscGetChipScsiID(iop_base));
7986 static uchar __devinit AscGetChipScsiCtrl(PortAddr iop_base)
7990 AscSetBank(iop_base, 1);
7991 sc = inp(iop_base + IOP_REG_SC);
7992 AscSetBank(iop_base, 0);
7996 static uchar __devinit AscGetChipVersion(PortAddr iop_base, ushort bus_type)
7998 if ((bus_type & ASC_IS_EISA) != 0) {
8001 eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
8002 (PortAddr) ASC_EISA_REV_IOP_MASK;
8003 revision = inp(eisa_iop);
8004 return ((uchar)((ASC_CHIP_MIN_VER_EISA - 1) + revision));
8006 return (AscGetChipVerNo(iop_base));
8009 static ushort __devinit AscGetChipBusType(PortAddr iop_base)
8013 chip_ver = AscGetChipVerNo(iop_base);
8014 if ((chip_ver >= ASC_CHIP_MIN_VER_VL)
8015 && (chip_ver <= ASC_CHIP_MAX_VER_VL)
8017 if (((iop_base & 0x0C30) == 0x0C30)
8018 || ((iop_base & 0x0C50) == 0x0C50)
8020 return (ASC_IS_EISA);
8024 if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) &&
8025 (chip_ver <= ASC_CHIP_MAX_VER_ISA)) {
8026 if (chip_ver >= ASC_CHIP_MIN_VER_ISA_PNP) {
8027 return (ASC_IS_ISAPNP);
8029 return (ASC_IS_ISA);
8030 } else if ((chip_ver >= ASC_CHIP_MIN_VER_PCI) &&
8031 (chip_ver <= ASC_CHIP_MAX_VER_PCI)) {
8032 return (ASC_IS_PCI);
8038 AscLoadMicroCode(PortAddr iop_base,
8039 ushort s_addr, uchar *mcode_buf, ushort mcode_size)
8042 ushort mcode_word_size;
8043 ushort mcode_chksum;
8045 /* Write the microcode buffer starting at LRAM address 0. */
8046 mcode_word_size = (ushort)(mcode_size >> 1);
8047 AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
8048 AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
8050 chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
8051 ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
8052 mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
8053 (ushort)ASC_CODE_SEC_BEG,
8054 (ushort)((mcode_size -
8058 ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
8059 (ulong)mcode_chksum);
8060 AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
8061 AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
8065 static int AscFindSignature(PortAddr iop_base)
8069 ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
8070 iop_base, AscGetChipSignatureByte(iop_base));
8071 if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
8073 "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
8074 iop_base, AscGetChipSignatureWord(iop_base));
8075 sig_word = AscGetChipSignatureWord(iop_base);
8076 if ((sig_word == (ushort)ASC_1000_ID0W) ||
8077 (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
8084 static void __devinit AscToggleIRQAct(PortAddr iop_base)
8086 AscSetChipStatus(iop_base, CIW_IRQ_ACT);
8087 AscSetChipStatus(iop_base, 0);
8091 static uchar __devinit AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
8096 if ((bus_type & ASC_IS_EISA) != 0) {
8097 cfg_lsw = AscGetEisaChipCfg(iop_base);
8098 chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
8099 if ((chip_irq == 13) || (chip_irq > 15)) {
8104 if ((bus_type & ASC_IS_VL) != 0) {
8105 cfg_lsw = AscGetChipCfgLsw(iop_base);
8106 chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
8107 if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
8110 return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
8112 cfg_lsw = AscGetChipCfgLsw(iop_base);
8113 chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
8115 chip_irq += (uchar)2;
8116 return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
8119 static uchar __devinit
8120 AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
8124 if ((bus_type & ASC_IS_VL) != 0) {
8126 if ((irq_no < ASC_MIN_IRQ_NO)
8127 || (irq_no > ASC_MAX_IRQ_NO)) {
8130 irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
8133 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
8134 cfg_lsw |= (ushort)0x0010;
8135 AscSetChipCfgLsw(iop_base, cfg_lsw);
8136 AscToggleIRQAct(iop_base);
8137 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
8138 cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
8139 AscSetChipCfgLsw(iop_base, cfg_lsw);
8140 AscToggleIRQAct(iop_base);
8141 return (AscGetChipIRQ(iop_base, bus_type));
8143 if ((bus_type & (ASC_IS_ISA)) != 0) {
8146 irq_no -= (uchar)ASC_MIN_IRQ_NO;
8147 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
8148 cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
8149 AscSetChipCfgLsw(iop_base, cfg_lsw);
8150 return (AscGetChipIRQ(iop_base, bus_type));
8156 static void __devinit AscEnableIsaDma(uchar dma_channel)
8158 if (dma_channel < 4) {
8159 outp(0x000B, (ushort)(0xC0 | dma_channel));
8160 outp(0x000A, dma_channel);
8161 } else if (dma_channel < 8) {
8162 outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
8163 outp(0x00D4, (ushort)(dma_channel - 4));
8167 #endif /* CONFIG_ISA */
8169 static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
8175 ushort int_halt_code;
8176 ASC_SCSI_BIT_ID_TYPE scsi_busy;
8177 ASC_SCSI_BIT_ID_TYPE target_id;
8184 uchar q_cntl, tid_no;
8188 asc_board_t *boardp;
8190 ASC_ASSERT(asc_dvc->drv_ptr != NULL);
8191 boardp = asc_dvc->drv_ptr;
8193 iop_base = asc_dvc->iop_base;
8194 int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
8196 halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
8197 halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
8198 target_ix = AscReadLramByte(iop_base,
8199 (ushort)(halt_q_addr +
8200 (ushort)ASC_SCSIQ_B_TARGET_IX));
8202 AscReadLramByte(iop_base,
8203 (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
8204 tid_no = ASC_TIX_TO_TID(target_ix);
8205 target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
8206 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8207 asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
8211 if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
8212 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8213 AscSetChipSDTR(iop_base, 0, tid_no);
8214 boardp->sdtr_data[tid_no] = 0;
8216 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8218 } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
8219 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8220 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8221 boardp->sdtr_data[tid_no] = asyn_sdtr;
8223 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8225 } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
8227 AscMemWordCopyPtrFromLram(iop_base,
8230 sizeof(EXT_MSG) >> 1);
8232 if (ext_msg.msg_type == MS_EXTEND &&
8233 ext_msg.msg_req == MS_SDTR_CODE &&
8234 ext_msg.msg_len == MS_SDTR_LEN) {
8236 if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
8238 sdtr_accept = FALSE;
8239 ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
8241 if ((ext_msg.xfer_period <
8242 asc_dvc->sdtr_period_tbl[asc_dvc->
8243 host_init_sdtr_index])
8244 || (ext_msg.xfer_period >
8245 asc_dvc->sdtr_period_tbl[asc_dvc->
8247 sdtr_accept = FALSE;
8248 ext_msg.xfer_period =
8249 asc_dvc->sdtr_period_tbl[asc_dvc->
8250 host_init_sdtr_index];
8254 AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
8255 ext_msg.req_ack_offset);
8256 if ((sdtr_data == 0xFF)) {
8258 q_cntl |= QC_MSG_OUT;
8259 asc_dvc->init_sdtr &= ~target_id;
8260 asc_dvc->sdtr_done &= ~target_id;
8261 AscSetChipSDTR(iop_base, asyn_sdtr,
8263 boardp->sdtr_data[tid_no] = asyn_sdtr;
8266 if (ext_msg.req_ack_offset == 0) {
8268 q_cntl &= ~QC_MSG_OUT;
8269 asc_dvc->init_sdtr &= ~target_id;
8270 asc_dvc->sdtr_done &= ~target_id;
8271 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8273 if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
8275 q_cntl &= ~QC_MSG_OUT;
8276 asc_dvc->sdtr_done |= target_id;
8277 asc_dvc->init_sdtr |= target_id;
8278 asc_dvc->pci_fix_asyn_xfer &=
8281 AscCalSDTRData(asc_dvc,
8282 ext_msg.xfer_period,
8285 AscSetChipSDTR(iop_base, sdtr_data,
8287 boardp->sdtr_data[tid_no] = sdtr_data;
8290 q_cntl |= QC_MSG_OUT;
8291 AscMsgOutSDTR(asc_dvc,
8292 ext_msg.xfer_period,
8293 ext_msg.req_ack_offset);
8294 asc_dvc->pci_fix_asyn_xfer &=
8297 AscCalSDTRData(asc_dvc,
8298 ext_msg.xfer_period,
8301 AscSetChipSDTR(iop_base, sdtr_data,
8303 boardp->sdtr_data[tid_no] = sdtr_data;
8304 asc_dvc->sdtr_done |= target_id;
8305 asc_dvc->init_sdtr |= target_id;
8309 AscWriteLramByte(iop_base,
8310 (ushort)(halt_q_addr +
8311 (ushort)ASC_SCSIQ_B_CNTL),
8313 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8315 } else if (ext_msg.msg_type == MS_EXTEND &&
8316 ext_msg.msg_req == MS_WDTR_CODE &&
8317 ext_msg.msg_len == MS_WDTR_LEN) {
8319 ext_msg.wdtr_width = 0;
8320 AscMemWordCopyPtrToLram(iop_base,
8323 sizeof(EXT_MSG) >> 1);
8324 q_cntl |= QC_MSG_OUT;
8325 AscWriteLramByte(iop_base,
8326 (ushort)(halt_q_addr +
8327 (ushort)ASC_SCSIQ_B_CNTL),
8329 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8333 ext_msg.msg_type = MESSAGE_REJECT;
8334 AscMemWordCopyPtrToLram(iop_base,
8337 sizeof(EXT_MSG) >> 1);
8338 q_cntl |= QC_MSG_OUT;
8339 AscWriteLramByte(iop_base,
8340 (ushort)(halt_q_addr +
8341 (ushort)ASC_SCSIQ_B_CNTL),
8343 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8346 } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
8348 q_cntl |= QC_REQ_SENSE;
8350 if ((asc_dvc->init_sdtr & target_id) != 0) {
8352 asc_dvc->sdtr_done &= ~target_id;
8354 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
8355 q_cntl |= QC_MSG_OUT;
8356 AscMsgOutSDTR(asc_dvc,
8358 sdtr_period_tbl[(sdtr_data >> 4) &
8362 (uchar)(sdtr_data & (uchar)
8363 ASC_SYN_MAX_OFFSET));
8366 AscWriteLramByte(iop_base,
8367 (ushort)(halt_q_addr +
8368 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
8370 tag_code = AscReadLramByte(iop_base,
8371 (ushort)(halt_q_addr + (ushort)
8372 ASC_SCSIQ_B_TAG_CODE));
8374 if ((asc_dvc->pci_fix_asyn_xfer & target_id)
8375 && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
8378 tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
8379 | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
8382 AscWriteLramByte(iop_base,
8383 (ushort)(halt_q_addr +
8384 (ushort)ASC_SCSIQ_B_TAG_CODE),
8387 q_status = AscReadLramByte(iop_base,
8388 (ushort)(halt_q_addr + (ushort)
8389 ASC_SCSIQ_B_STATUS));
8390 q_status |= (QS_READY | QS_BUSY);
8391 AscWriteLramByte(iop_base,
8392 (ushort)(halt_q_addr +
8393 (ushort)ASC_SCSIQ_B_STATUS),
8396 scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
8397 scsi_busy &= ~target_id;
8398 AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
8400 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8402 } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
8404 AscMemWordCopyPtrFromLram(iop_base,
8407 sizeof(EXT_MSG) >> 1);
8409 if ((out_msg.msg_type == MS_EXTEND) &&
8410 (out_msg.msg_len == MS_SDTR_LEN) &&
8411 (out_msg.msg_req == MS_SDTR_CODE)) {
8413 asc_dvc->init_sdtr &= ~target_id;
8414 asc_dvc->sdtr_done &= ~target_id;
8415 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8416 boardp->sdtr_data[tid_no] = asyn_sdtr;
8418 q_cntl &= ~QC_MSG_OUT;
8419 AscWriteLramByte(iop_base,
8420 (ushort)(halt_q_addr +
8421 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
8422 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8424 } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
8426 scsi_status = AscReadLramByte(iop_base,
8427 (ushort)((ushort)halt_q_addr +
8429 ASC_SCSIQ_SCSI_STATUS));
8431 AscReadLramByte(iop_base,
8432 (ushort)((ushort)ASC_QADR_BEG +
8433 (ushort)target_ix));
8434 if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
8436 scsi_busy = AscReadLramByte(iop_base,
8437 (ushort)ASCV_SCSIBUSY_B);
8438 scsi_busy |= target_id;
8439 AscWriteLramByte(iop_base,
8440 (ushort)ASCV_SCSIBUSY_B, scsi_busy);
8441 asc_dvc->queue_full_or_busy |= target_id;
8443 if (scsi_status == SAM_STAT_TASK_SET_FULL) {
8444 if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
8446 asc_dvc->max_dvc_qng[tid_no] =
8449 AscWriteLramByte(iop_base,
8451 ASCV_MAX_DVC_QNG_BEG
8457 * Set the device queue depth to the number of
8458 * active requests when the QUEUE FULL condition
8461 boardp->queue_full |= target_id;
8462 boardp->queue_full_cnt[tid_no] =
8467 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8470 #if CC_VERY_LONG_SG_LIST
8471 else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
8475 uchar first_sg_wk_q_no;
8476 ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
8477 ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
8478 ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
8479 ushort sg_list_dwords;
8480 ushort sg_entry_cnt;
8484 q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
8485 if (q_no == ASC_QLINK_END) {
8489 q_addr = ASC_QNO_TO_QADDR(q_no);
8492 * Convert the request's SRB pointer to a host ASC_SCSI_REQ
8493 * structure pointer using a macro provided by the driver.
8494 * The ASC_SCSI_REQ pointer provides a pointer to the
8495 * host ASC_SG_HEAD structure.
8497 /* Read request's SRB pointer. */
8498 scsiq = (ASC_SCSI_Q *)
8499 ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
8502 ASC_SCSIQ_D_SRBPTR))));
8505 * Get request's first and working SG queue.
8507 sg_wk_q_no = AscReadLramByte(iop_base,
8509 ASC_SCSIQ_B_SG_WK_QP));
8511 first_sg_wk_q_no = AscReadLramByte(iop_base,
8513 ASC_SCSIQ_B_FIRST_SG_WK_QP));
8516 * Reset request's working SG queue back to the
8519 AscWriteLramByte(iop_base,
8521 (ushort)ASC_SCSIQ_B_SG_WK_QP),
8524 sg_head = scsiq->sg_head;
8527 * Set sg_entry_cnt to the number of SG elements
8528 * that will be completed on this interrupt.
8530 * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
8531 * SG elements. The data_cnt and data_addr fields which
8532 * add 1 to the SG element capacity are not used when
8533 * restarting SG handling after a halt.
8535 if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
8536 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
8539 * Keep track of remaining number of SG elements that will
8540 * need to be handled on the next interrupt.
8542 scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
8544 sg_entry_cnt = scsiq->remain_sg_entry_cnt;
8545 scsiq->remain_sg_entry_cnt = 0;
8549 * Copy SG elements into the list of allocated SG queues.
8551 * Last index completed is saved in scsiq->next_sg_index.
8553 next_qp = first_sg_wk_q_no;
8554 q_addr = ASC_QNO_TO_QADDR(next_qp);
8555 scsi_sg_q.sg_head_qp = q_no;
8556 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
8557 for (i = 0; i < sg_head->queue_cnt; i++) {
8558 scsi_sg_q.seq_no = i + 1;
8559 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
8560 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
8561 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
8563 * After very first SG queue RISC FW uses next
8564 * SG queue first element then checks sg_list_cnt
8565 * against zero and then decrements, so set
8566 * sg_list_cnt 1 less than number of SG elements
8569 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
8570 scsi_sg_q.sg_cur_list_cnt =
8571 ASC_SG_LIST_PER_Q - 1;
8574 * This is the last SG queue in the list of
8575 * allocated SG queues. If there are more
8576 * SG elements than will fit in the allocated
8577 * queues, then set the QCSG_SG_XFER_MORE flag.
8579 if (scsiq->remain_sg_entry_cnt != 0) {
8580 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
8582 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
8584 /* equals sg_entry_cnt * 2 */
8585 sg_list_dwords = sg_entry_cnt << 1;
8586 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
8587 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
8591 scsi_sg_q.q_no = next_qp;
8592 AscMemWordCopyPtrToLram(iop_base,
8593 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
8594 (uchar *)&scsi_sg_q,
8595 sizeof(ASC_SG_LIST_Q) >> 1);
8597 AscMemDWordCopyPtrToLram(iop_base,
8598 q_addr + ASC_SGQ_LIST_BEG,
8600 sg_list[scsiq->next_sg_index],
8603 scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
8606 * If the just completed SG queue contained the
8607 * last SG element, then no more SG queues need
8610 if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
8614 next_qp = AscReadLramByte(iop_base,
8617 q_addr = ASC_QNO_TO_QADDR(next_qp);
8621 * Clear the halt condition so the RISC will be restarted
8624 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8627 #endif /* CC_VERY_LONG_SG_LIST */
8632 _AscCopyLramScsiDoneQ(PortAddr iop_base,
8634 ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
8639 DvcGetQinfo(iop_base,
8640 q_addr + ASC_SCSIQ_DONE_INFO_BEG,
8642 (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
8644 _val = AscReadLramWord(iop_base,
8645 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
8646 scsiq->q_status = (uchar)_val;
8647 scsiq->q_no = (uchar)(_val >> 8);
8648 _val = AscReadLramWord(iop_base,
8649 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
8650 scsiq->cntl = (uchar)_val;
8651 sg_queue_cnt = (uchar)(_val >> 8);
8652 _val = AscReadLramWord(iop_base,
8654 (ushort)ASC_SCSIQ_B_SENSE_LEN));
8655 scsiq->sense_len = (uchar)_val;
8656 scsiq->extra_bytes = (uchar)(_val >> 8);
8659 * Read high word of remain bytes from alternate location.
8661 scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
8664 ASC_SCSIQ_W_ALT_DC1)))
8667 * Read low word of remain bytes from original location.
8669 scsiq->remain_bytes += AscReadLramWord(iop_base,
8670 (ushort)(q_addr + (ushort)
8671 ASC_SCSIQ_DW_REMAIN_XFER_CNT));
8673 scsiq->remain_bytes &= max_dma_count;
8674 return (sg_queue_cnt);
8677 static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
8686 ASC_SCSI_BIT_ID_TYPE scsi_busy;
8687 ASC_SCSI_BIT_ID_TYPE target_id;
8691 uchar cur_target_qng;
8692 ASC_QDONE_INFO scsiq_buf;
8693 ASC_QDONE_INFO *scsiq;
8695 ASC_ISR_CALLBACK asc_isr_callback;
8697 iop_base = asc_dvc->iop_base;
8698 asc_isr_callback = asc_dvc->isr_callback;
8700 scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
8701 done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
8702 q_addr = ASC_QNO_TO_QADDR(done_q_tail);
8703 next_qp = AscReadLramByte(iop_base,
8704 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
8705 if (next_qp != ASC_QLINK_END) {
8706 AscPutVarDoneQTail(iop_base, next_qp);
8707 q_addr = ASC_QNO_TO_QADDR(next_qp);
8708 sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
8709 asc_dvc->max_dma_count);
8710 AscWriteLramByte(iop_base,
8712 (ushort)ASC_SCSIQ_B_STATUS),
8714 q_status & (uchar)~(QS_READY |
8716 tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
8717 target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
8718 if ((scsiq->cntl & QC_SG_HEAD) != 0) {
8720 sg_list_qp = next_qp;
8721 for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
8722 sg_list_qp = AscReadLramByte(iop_base,
8726 sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
8727 if (sg_list_qp == ASC_QLINK_END) {
8728 AscSetLibErrorCode(asc_dvc,
8729 ASCQ_ERR_SG_Q_LINKS);
8730 scsiq->d3.done_stat = QD_WITH_ERROR;
8731 scsiq->d3.host_stat =
8732 QHSTA_D_QDONE_SG_LIST_CORRUPTED;
8733 goto FATAL_ERR_QDONE;
8735 AscWriteLramByte(iop_base,
8736 (ushort)(sg_q_addr + (ushort)
8737 ASC_SCSIQ_B_STATUS),
8740 n_q_used = sg_queue_cnt + 1;
8741 AscPutVarDoneQTail(iop_base, sg_list_qp);
8743 if (asc_dvc->queue_full_or_busy & target_id) {
8744 cur_target_qng = AscReadLramByte(iop_base,
8750 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
8751 scsi_busy = AscReadLramByte(iop_base, (ushort)
8753 scsi_busy &= ~target_id;
8754 AscWriteLramByte(iop_base,
8755 (ushort)ASCV_SCSIBUSY_B,
8757 asc_dvc->queue_full_or_busy &= ~target_id;
8760 if (asc_dvc->cur_total_qng >= n_q_used) {
8761 asc_dvc->cur_total_qng -= n_q_used;
8762 if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
8763 asc_dvc->cur_dvc_qng[tid_no]--;
8766 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
8767 scsiq->d3.done_stat = QD_WITH_ERROR;
8768 goto FATAL_ERR_QDONE;
8770 if ((scsiq->d2.srb_ptr == 0UL) ||
8771 ((scsiq->q_status & QS_ABORTED) != 0)) {
8773 } else if (scsiq->q_status == QS_DONE) {
8774 false_overrun = FALSE;
8775 if (scsiq->extra_bytes != 0) {
8776 scsiq->remain_bytes +=
8777 (ADV_DCNT)scsiq->extra_bytes;
8779 if (scsiq->d3.done_stat == QD_WITH_ERROR) {
8780 if (scsiq->d3.host_stat ==
8781 QHSTA_M_DATA_OVER_RUN) {
8783 cntl & (QC_DATA_IN | QC_DATA_OUT))
8785 scsiq->d3.done_stat =
8787 scsiq->d3.host_stat =
8789 } else if (false_overrun) {
8790 scsiq->d3.done_stat =
8792 scsiq->d3.host_stat =
8795 } else if (scsiq->d3.host_stat ==
8796 QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
8797 AscStopChip(iop_base);
8798 AscSetChipControl(iop_base,
8799 (uchar)(CC_SCSI_RESET
8801 DvcDelayNanoSecond(asc_dvc, 60000);
8802 AscSetChipControl(iop_base, CC_HALT);
8803 AscSetChipStatus(iop_base,
8804 CIW_CLR_SCSI_RESET_INT);
8805 AscSetChipStatus(iop_base, 0);
8806 AscSetChipControl(iop_base, 0);
8809 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
8810 (*asc_isr_callback) (asc_dvc, scsiq);
8812 if ((AscReadLramByte(iop_base,
8813 (ushort)(q_addr + (ushort)
8816 asc_dvc->unit_not_ready &= ~target_id;
8817 if (scsiq->d3.done_stat != QD_NO_ERROR) {
8818 asc_dvc->start_motor &=
8825 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
8827 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
8828 (*asc_isr_callback) (asc_dvc, scsiq);
8836 static int AscISR(ASC_DVC_VAR *asc_dvc)
8838 ASC_CS_TYPE chipstat;
8840 ushort saved_ram_addr;
8842 uchar saved_ctrl_reg;
8847 iop_base = asc_dvc->iop_base;
8848 int_pending = FALSE;
8850 if (AscIsIntPending(iop_base) == 0) {
8854 if (((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0)
8855 || (asc_dvc->isr_callback == 0)
8859 if (asc_dvc->in_critical_cnt != 0) {
8860 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
8863 if (asc_dvc->is_in_int) {
8864 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
8867 asc_dvc->is_in_int = TRUE;
8868 ctrl_reg = AscGetChipControl(iop_base);
8869 saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
8870 CC_SINGLE_STEP | CC_DIAG | CC_TEST));
8871 chipstat = AscGetChipStatus(iop_base);
8872 if (chipstat & CSW_SCSI_RESET_LATCH) {
8873 if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
8876 asc_dvc->sdtr_done = 0;
8877 saved_ctrl_reg &= (uchar)(~CC_HALT);
8878 while ((AscGetChipStatus(iop_base) &
8879 CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
8880 DvcSleepMilliSecond(100);
8882 AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
8883 AscSetChipControl(iop_base, CC_HALT);
8884 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
8885 AscSetChipStatus(iop_base, 0);
8886 chipstat = AscGetChipStatus(iop_base);
8889 saved_ram_addr = AscGetChipLramAddr(iop_base);
8890 host_flag = AscReadLramByte(iop_base,
8892 (uchar)(~ASC_HOST_FLAG_IN_ISR);
8893 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
8894 (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
8895 if ((chipstat & CSW_INT_PENDING)
8898 AscAckInterrupt(iop_base);
8900 if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
8901 if (AscIsrChipHalted(asc_dvc) == ERR) {
8902 goto ISR_REPORT_QDONE_FATAL_ERROR;
8904 saved_ctrl_reg &= (uchar)(~CC_HALT);
8907 ISR_REPORT_QDONE_FATAL_ERROR:
8908 if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
8910 AscIsrQDone(asc_dvc)) & 0x01) != 0) {
8915 AscIsrQDone(asc_dvc)) == 1) {
8918 } while (status == 0x11);
8920 if ((status & 0x80) != 0)
8924 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
8925 AscSetChipLramAddr(iop_base, saved_ram_addr);
8926 AscSetChipControl(iop_base, saved_ctrl_reg);
8927 asc_dvc->is_in_int = FALSE;
8928 return (int_pending);
8931 /* Microcode buffer is kept after initialization for error recovery. */
8932 static uchar _asc_mcode_buf[] = {
8933 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8934 0x00, 0x00, 0x00, 0x00,
8935 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
8936 0x00, 0x00, 0x00, 0x00,
8937 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8938 0x00, 0x00, 0x00, 0x00,
8939 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8940 0x00, 0x00, 0x00, 0x00,
8941 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05, 0x01, 0x00, 0x00, 0x00,
8942 0x00, 0xFF, 0x00, 0x00,
8943 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00,
8944 0x00, 0x00, 0x00, 0x00,
8945 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
8946 0x00, 0x00, 0x00, 0x00,
8947 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x88,
8948 0x00, 0x00, 0x00, 0x00,
8949 0x80, 0x73, 0x48, 0x04, 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73,
8950 0x03, 0x23, 0x36, 0x40,
8951 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
8952 0xC2, 0x00, 0x92, 0x80,
8953 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xDF, 0x23, 0x36, 0x60,
8954 0xB6, 0x00, 0x92, 0x80,
8955 0x4F, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00,
8956 0x92, 0x80, 0x80, 0x62,
8957 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
8958 0xCD, 0x04, 0x4D, 0x00,
8959 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23, 0x04, 0x61, 0x84, 0x01,
8960 0xE6, 0x84, 0xD2, 0xC1,
8961 0x80, 0x73, 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97,
8962 0xC6, 0x81, 0xC2, 0x88,
8963 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
8964 0x84, 0x97, 0x07, 0xA6,
8965 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x01, 0xDE,
8966 0xC2, 0x88, 0xCE, 0x00,
8967 0x69, 0x60, 0xCE, 0x00, 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01,
8968 0x80, 0x63, 0x07, 0xA6,
8969 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
8970 0x34, 0x01, 0x00, 0x33,
8971 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01, 0x04, 0xCA, 0x0D, 0x23,
8972 0x68, 0x98, 0x4D, 0x04,
8973 0x04, 0x85, 0x05, 0xD8, 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23,
8974 0xF8, 0x88, 0xFB, 0x23,
8975 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
8976 0x00, 0x33, 0x0A, 0x00,
8977 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01, 0x00, 0x33, 0x0B, 0x00,
8978 0xC2, 0x88, 0xCD, 0x04,
8979 0x36, 0x2D, 0x00, 0x33, 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81,
8980 0x06, 0xAB, 0x82, 0x01,
8981 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
8982 0x3C, 0x01, 0x00, 0x05,
8983 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6, 0x04, 0x23, 0xA0, 0x01,
8984 0x15, 0x23, 0xA1, 0x01,
8985 0xBE, 0x81, 0xFD, 0x23, 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00,
8986 0x06, 0x61, 0x00, 0xA0,
8987 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
8988 0xC2, 0x88, 0x06, 0x23,
8989 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01, 0x00, 0xA2, 0xD4, 0x01,
8990 0x57, 0x60, 0x00, 0xA0,
8991 0xDA, 0x01, 0xE6, 0x84, 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73,
8992 0x4B, 0x00, 0x06, 0x61,
8993 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
8994 0x4F, 0x00, 0x84, 0x97,
8995 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01, 0x4F, 0x00, 0x62, 0x97,
8996 0x48, 0x04, 0x84, 0x80,
8997 0xF0, 0x97, 0x00, 0x46, 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00,
8998 0x81, 0x73, 0x06, 0x29,
8999 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
9000 0x04, 0x98, 0xF0, 0x80,
9001 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02, 0x7C, 0x95, 0x06, 0xA6,
9002 0x34, 0x02, 0x03, 0xA6,
9003 0x4C, 0x04, 0x46, 0x82, 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96,
9004 0x46, 0x82, 0xFE, 0x95,
9005 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
9006 0x07, 0xA6, 0x5A, 0x02,
9007 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02, 0xC2, 0x88, 0x7C, 0x95,
9008 0x48, 0x82, 0x60, 0x96,
9009 0x48, 0x82, 0x04, 0x23, 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84,
9010 0x04, 0x01, 0x0C, 0xDC,
9011 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
9012 0x6F, 0x00, 0xA5, 0x01,
9013 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01, 0x24, 0x2B, 0x1C, 0x01,
9014 0x02, 0xA6, 0xAA, 0x02,
9015 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04,
9016 0x01, 0xA6, 0xB4, 0x02,
9017 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
9018 0x80, 0x63, 0x00, 0x43,
9019 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01, 0x0B, 0xDC, 0xE7, 0x23,
9020 0x04, 0x61, 0x84, 0x01,
9021 0x10, 0x31, 0x12, 0x35, 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F,
9022 0x00, 0x00, 0xEA, 0x82,
9023 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
9024 0x00, 0x33, 0x1F, 0x00,
9025 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39, 0x0E, 0x3D, 0x7E, 0x98,
9026 0xB6, 0x2D, 0x01, 0xA6,
9027 0x14, 0x03, 0x00, 0xA6, 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6,
9028 0x10, 0x03, 0x03, 0xA6,
9029 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
9030 0x7C, 0x95, 0xEE, 0x82,
9031 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42, 0x7E, 0x98, 0x64, 0xE4,
9032 0x04, 0x01, 0x2D, 0xC8,
9033 0x31, 0x05, 0x07, 0x01, 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01,
9034 0x05, 0x05, 0x86, 0x98,
9035 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
9036 0x3C, 0x04, 0x06, 0xA6,
9037 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33, 0x25, 0x00, 0xC2, 0x88,
9038 0x7C, 0x95, 0x32, 0x83,
9039 0x60, 0x96, 0x32, 0x83, 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05,
9040 0xEB, 0x04, 0x00, 0x33,
9041 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
9042 0xFF, 0xA2, 0x7A, 0x03,
9043 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83, 0x05, 0x05, 0x15, 0x01,
9044 0x00, 0xA2, 0x9A, 0x03,
9045 0xEC, 0x00, 0x6E, 0x00, 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00,
9046 0x01, 0xA6, 0x96, 0x03,
9047 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
9048 0xA4, 0x03, 0x00, 0xA6,
9049 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42, 0x01, 0xA6, 0xA4, 0x03,
9050 0x07, 0xA6, 0xB2, 0x03,
9051 0xD4, 0x83, 0x7C, 0x95, 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88,
9052 0xA8, 0x98, 0x80, 0x42,
9053 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
9054 0xC0, 0x83, 0x00, 0x33,
9055 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32, 0x80, 0x36, 0x04, 0x23,
9056 0xA0, 0x01, 0x12, 0x23,
9057 0xA1, 0x01, 0x10, 0x84, 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B,
9058 0x80, 0x67, 0x05, 0x23,
9059 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
9060 0x06, 0xA6, 0x0A, 0x04,
9061 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xF4, 0x83, 0x60, 0x96,
9062 0xF4, 0x83, 0x20, 0x84,
9063 0x07, 0xF0, 0x06, 0xA4, 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
9064 0x83, 0x03, 0x80, 0x63,
9065 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
9066 0x38, 0x04, 0x00, 0x33,
9067 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84, 0x60, 0x96, 0x20, 0x84,
9068 0x1D, 0x01, 0x06, 0xCC,
9069 0x00, 0x33, 0x00, 0x84, 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62,
9070 0xA2, 0x0D, 0x80, 0x63,
9071 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
9072 0x80, 0x63, 0xA3, 0x01,
9073 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2, 0x86, 0x04, 0x0A, 0xA0,
9074 0x76, 0x04, 0xE0, 0x00,
9075 0x00, 0x33, 0x1D, 0x00, 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00,
9076 0x00, 0x33, 0x1E, 0x00,
9077 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
9078 0x08, 0x23, 0x22, 0xA3,
9079 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04, 0x02, 0x23, 0x22, 0xA3,
9080 0xC4, 0x04, 0x42, 0x23,
9081 0xF8, 0x88, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23,
9082 0xF8, 0x88, 0x04, 0x98,
9083 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
9084 0x81, 0x62, 0xE8, 0x81,
9085 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE, 0x04, 0x98, 0xB4, 0x98,
9086 0x00, 0x33, 0x00, 0x81,
9087 0xC0, 0x20, 0x81, 0x62, 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23,
9088 0xF8, 0x88, 0x04, 0x23,
9089 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
9090 0xF4, 0x04, 0x00, 0x33,
9091 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC, 0x02, 0x23, 0xA2, 0x01,
9092 0x04, 0x23, 0xA0, 0x01,
9093 0x04, 0x98, 0x26, 0x95, 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00,
9094 0x00, 0xA3, 0x22, 0x05,
9095 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
9096 0x46, 0x97, 0xCD, 0x04,
9097 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01, 0x03, 0xDA, 0x80, 0x23,
9098 0x82, 0x01, 0x34, 0x85,
9099 0x02, 0x23, 0xA0, 0x01, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05,
9100 0x1D, 0x01, 0x04, 0xD6,
9101 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
9102 0x49, 0x00, 0x81, 0x01,
9103 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01, 0xF7, 0x04, 0x03, 0x01,
9104 0x49, 0x04, 0x80, 0x01,
9105 0xC9, 0x00, 0x00, 0x05, 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04,
9106 0x01, 0x23, 0xEA, 0x00,
9107 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
9108 0x07, 0xA4, 0xF8, 0x05,
9109 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85, 0x00, 0x33, 0x2D, 0x00,
9110 0xC2, 0x88, 0x04, 0xA0,
9111 0xB8, 0x05, 0x80, 0x63, 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61,
9112 0x00, 0xA2, 0xA4, 0x05,
9113 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
9114 0x62, 0x97, 0x04, 0x85,
9115 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85, 0x08, 0xA0, 0xBE, 0x05,
9116 0xF4, 0x85, 0x03, 0xA0,
9117 0xC4, 0x05, 0xF4, 0x85, 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63,
9118 0xCC, 0x86, 0x07, 0xA0,
9119 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
9120 0x80, 0x67, 0x80, 0x63,
9121 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23, 0x68, 0x98, 0x48, 0x23,
9122 0xF8, 0x88, 0x07, 0x23,
9123 0x80, 0x00, 0x06, 0x87, 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00,
9124 0x00, 0x63, 0x4A, 0x00,
9125 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
9126 0x07, 0x41, 0x83, 0x03,
9127 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33, 0x37, 0x00, 0xC2, 0x88,
9128 0x1D, 0x01, 0x01, 0xD6,
9129 0x20, 0x23, 0x63, 0x60, 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00,
9130 0x07, 0xA6, 0x7C, 0x05,
9131 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
9132 0x52, 0x00, 0x06, 0x61,
9133 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA, 0xC0, 0x23, 0x07, 0x41,
9134 0x00, 0x63, 0x1D, 0x01,
9135 0x04, 0xCC, 0x00, 0x33, 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23,
9136 0x07, 0x41, 0x00, 0x63,
9137 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
9138 0xDF, 0x00, 0x06, 0xA6,
9139 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x80, 0x63, 0x00, 0x33,
9140 0x00, 0x40, 0xC0, 0x20,
9141 0x81, 0x62, 0x00, 0x63, 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63,
9142 0x06, 0xA6, 0x94, 0x06,
9143 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
9144 0x40, 0x0E, 0x80, 0x63,
9145 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x40, 0x0E,
9146 0x80, 0x63, 0x00, 0x43,
9147 0x00, 0xA0, 0xA2, 0x06, 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05,
9148 0x80, 0x67, 0x40, 0x0E,
9149 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
9150 0x07, 0xA6, 0xD6, 0x06,
9151 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0x89, 0x00,
9152 0x0A, 0x2B, 0x07, 0xA6,
9153 0xE8, 0x06, 0x00, 0x33, 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2,
9154 0xF4, 0x06, 0xC0, 0x0E,
9155 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
9156 0x81, 0x62, 0x04, 0x01,
9157 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6,
9158 0x8C, 0x06, 0x00, 0x33,
9159 0x2C, 0x00, 0xC2, 0x88, 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03,
9160 0x80, 0x63, 0x06, 0xA6,
9161 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
9162 0x00, 0x00, 0x80, 0x67,
9163 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07, 0x07, 0xA6, 0x7C, 0x05,
9164 0xBF, 0x23, 0x04, 0x61,
9165 0x84, 0x01, 0xE6, 0x84, 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00,
9166 0x00, 0x01, 0xF2, 0x00,
9167 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
9168 0x80, 0x05, 0x81, 0x05,
9169 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x01, 0x01, 0xF1, 0x00,
9170 0x70, 0x00, 0x81, 0x01,
9171 0x70, 0x04, 0x71, 0x00, 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04,
9172 0x70, 0x00, 0x80, 0x01,
9173 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
9174 0xF1, 0x00, 0x70, 0x00,
9175 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01, 0x72, 0x00, 0x81, 0x01,
9176 0x71, 0x04, 0x70, 0x00,
9177 0x81, 0x01, 0x70, 0x04, 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05,
9178 0xA3, 0x01, 0xA2, 0x01,
9179 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
9180 0xC4, 0x07, 0x00, 0x33,
9181 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05, 0x04, 0x01, 0x11, 0xC8,
9182 0x48, 0x00, 0xB0, 0x01,
9183 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43,
9184 0x00, 0xA2, 0xE4, 0x07,
9185 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
9186 0x05, 0x05, 0x00, 0x63,
9187 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x80, 0x43,
9188 0x76, 0x08, 0x80, 0x02,
9189 0x77, 0x04, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
9190 0x00, 0x02, 0x00, 0xA0,
9191 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
9192 0x00, 0x63, 0xF3, 0x04,
9193 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43, 0xF4, 0x00, 0xCF, 0x40,
9194 0x00, 0xA2, 0x44, 0x08,
9195 0x74, 0x04, 0x02, 0x01, 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1,
9196 0x24, 0x08, 0x04, 0x98,
9197 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
9198 0x5A, 0x88, 0x02, 0x01,
9199 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95, 0x4A, 0x88, 0x75, 0x00,
9200 0x00, 0xA3, 0x64, 0x08,
9201 0x00, 0x05, 0x4E, 0x88, 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63,
9202 0x06, 0xA6, 0x76, 0x08,
9203 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
9204 0x00, 0x63, 0x38, 0x2B,
9205 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09, 0x31, 0x05, 0x92, 0x98,
9206 0x05, 0x05, 0xB2, 0x09,
9207 0x00, 0x63, 0x00, 0x32, 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63,
9208 0x80, 0x32, 0x80, 0x36,
9209 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
9210 0x40, 0x36, 0x40, 0x3A,
9211 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40, 0x00, 0xA0, 0xB4, 0x08,
9212 0x5D, 0x00, 0xFE, 0xC3,
9213 0x00, 0x63, 0x80, 0x73, 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73,
9214 0xFF, 0xFD, 0x80, 0x73,
9215 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
9216 0xA1, 0x23, 0xA1, 0x01,
9217 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77, 0x68, 0x00, 0x00, 0xA2,
9218 0x80, 0x00, 0x03, 0xC2,
9219 0xF1, 0xC7, 0x41, 0x23, 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23,
9220 0xA0, 0x01, 0xE6, 0x84,
9223 static ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
9224 static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
9226 #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
9227 static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
9246 static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
9249 ulong last_int_level;
9252 int disable_syn_offset_one_fix;
9255 ASC_EXE_CALLBACK asc_exe_callback;
9256 ushort sg_entry_cnt = 0;
9257 ushort sg_entry_cnt_minus_one = 0;
9264 ASC_SG_HEAD *sg_head;
9267 iop_base = asc_dvc->iop_base;
9268 sg_head = scsiq->sg_head;
9269 asc_exe_callback = asc_dvc->exe_callback;
9270 if (asc_dvc->err_code != 0)
9272 if (scsiq == (ASC_SCSI_Q *)0L) {
9273 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR);
9277 if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
9278 scsiq->q1.extra_bytes = 0;
9281 target_ix = scsiq->q2.target_ix;
9282 tid_no = ASC_TIX_TO_TID(target_ix);
9284 if (scsiq->cdbptr[0] == REQUEST_SENSE) {
9285 if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
9286 asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
9287 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
9288 AscMsgOutSDTR(asc_dvc,
9290 sdtr_period_tbl[(sdtr_data >> 4) &
9294 (uchar)(sdtr_data & (uchar)
9295 ASC_SYN_MAX_OFFSET));
9296 scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
9299 last_int_level = DvcEnterCritical();
9300 if (asc_dvc->in_critical_cnt != 0) {
9301 DvcLeaveCritical(last_int_level);
9302 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
9305 asc_dvc->in_critical_cnt++;
9306 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
9307 if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
9308 asc_dvc->in_critical_cnt--;
9309 DvcLeaveCritical(last_int_level);
9312 #if !CC_VERY_LONG_SG_LIST
9313 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
9314 asc_dvc->in_critical_cnt--;
9315 DvcLeaveCritical(last_int_level);
9318 #endif /* !CC_VERY_LONG_SG_LIST */
9319 if (sg_entry_cnt == 1) {
9320 scsiq->q1.data_addr =
9321 (ADV_PADDR)sg_head->sg_list[0].addr;
9322 scsiq->q1.data_cnt =
9323 (ADV_DCNT)sg_head->sg_list[0].bytes;
9324 scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
9326 sg_entry_cnt_minus_one = sg_entry_cnt - 1;
9328 scsi_cmd = scsiq->cdbptr[0];
9329 disable_syn_offset_one_fix = FALSE;
9330 if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
9331 !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
9332 if (scsiq->q1.cntl & QC_SG_HEAD) {
9334 for (i = 0; i < sg_entry_cnt; i++) {
9336 (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
9340 data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
9342 if (data_cnt != 0UL) {
9343 if (data_cnt < 512UL) {
9344 disable_syn_offset_one_fix = TRUE;
9346 for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
9349 _syn_offset_one_disable_cmd[i];
9350 if (disable_cmd == 0xFF) {
9353 if (scsi_cmd == disable_cmd) {
9354 disable_syn_offset_one_fix =
9362 if (disable_syn_offset_one_fix) {
9363 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
9364 scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
9365 ASC_TAG_FLAG_DISABLE_DISCONNECT);
9367 scsiq->q2.tag_code &= 0x27;
9369 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
9370 if (asc_dvc->bug_fix_cntl) {
9371 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
9372 if ((scsi_cmd == READ_6) ||
9373 (scsi_cmd == READ_10)) {
9375 (ADV_PADDR)le32_to_cpu(sg_head->
9377 [sg_entry_cnt_minus_one].
9379 (ADV_DCNT)le32_to_cpu(sg_head->
9381 [sg_entry_cnt_minus_one].
9384 (uchar)((ushort)addr & 0x0003);
9385 if ((extra_bytes != 0)
9389 ASC_TAG_FLAG_EXTRA_BYTES)
9391 scsiq->q2.tag_code |=
9392 ASC_TAG_FLAG_EXTRA_BYTES;
9393 scsiq->q1.extra_bytes =
9396 le32_to_cpu(sg_head->
9398 [sg_entry_cnt_minus_one].
9401 (ASC_DCNT) extra_bytes;
9404 [sg_entry_cnt_minus_one].
9406 cpu_to_le32(data_cnt);
9411 sg_head->entry_to_copy = sg_head->entry_cnt;
9412 #if CC_VERY_LONG_SG_LIST
9414 * Set the sg_entry_cnt to the maximum possible. The rest of
9415 * the SG elements will be copied when the RISC completes the
9416 * SG elements that fit and halts.
9418 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
9419 sg_entry_cnt = ASC_MAX_SG_LIST;
9421 #endif /* CC_VERY_LONG_SG_LIST */
9422 n_q_required = AscSgListToQueue(sg_entry_cnt);
9423 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
9424 (uint) n_q_required)
9425 || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
9427 AscSendScsiQueue(asc_dvc, scsiq,
9428 n_q_required)) == 1) {
9429 asc_dvc->in_critical_cnt--;
9430 if (asc_exe_callback != 0) {
9431 (*asc_exe_callback) (asc_dvc, scsiq);
9433 DvcLeaveCritical(last_int_level);
9438 if (asc_dvc->bug_fix_cntl) {
9439 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
9440 if ((scsi_cmd == READ_6) ||
9441 (scsi_cmd == READ_10)) {
9443 le32_to_cpu(scsiq->q1.data_addr) +
9444 le32_to_cpu(scsiq->q1.data_cnt);
9446 (uchar)((ushort)addr & 0x0003);
9447 if ((extra_bytes != 0)
9451 ASC_TAG_FLAG_EXTRA_BYTES)
9454 le32_to_cpu(scsiq->q1.
9456 if (((ushort)data_cnt & 0x01FF)
9458 scsiq->q2.tag_code |=
9459 ASC_TAG_FLAG_EXTRA_BYTES;
9460 data_cnt -= (ASC_DCNT)
9462 scsiq->q1.data_cnt =
9465 scsiq->q1.extra_bytes =
9473 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
9474 ((scsiq->q1.cntl & QC_URGENT) != 0)) {
9475 if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
9476 n_q_required)) == 1) {
9477 asc_dvc->in_critical_cnt--;
9478 if (asc_exe_callback != 0) {
9479 (*asc_exe_callback) (asc_dvc, scsiq);
9481 DvcLeaveCritical(last_int_level);
9486 asc_dvc->in_critical_cnt--;
9487 DvcLeaveCritical(last_int_level);
9492 AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
9501 iop_base = asc_dvc->iop_base;
9502 target_ix = scsiq->q2.target_ix;
9503 tid_no = ASC_TIX_TO_TID(target_ix);
9505 free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
9506 if (n_q_required > 1) {
9507 if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
9508 free_q_head, (uchar)
9510 != (uchar)ASC_QLINK_END) {
9511 asc_dvc->last_q_shortage = 0;
9512 scsiq->sg_head->queue_cnt = n_q_required - 1;
9513 scsiq->q1.q_no = free_q_head;
9514 if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
9515 free_q_head)) == 1) {
9516 AscPutVarFreeQHead(iop_base, next_qp);
9517 asc_dvc->cur_total_qng += (uchar)(n_q_required);
9518 asc_dvc->cur_dvc_qng[tid_no]++;
9522 } else if (n_q_required == 1) {
9523 if ((next_qp = AscAllocFreeQueue(iop_base,
9526 scsiq->q1.q_no = free_q_head;
9527 if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
9528 free_q_head)) == 1) {
9529 AscPutVarFreeQHead(iop_base, next_qp);
9530 asc_dvc->cur_total_qng++;
9531 asc_dvc->cur_dvc_qng[tid_no]++;
9539 static int AscSgListToQueue(int sg_list)
9543 n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
9544 if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
9546 return (n_sg_list_qs + 1);
9550 AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
9554 ASC_SCSI_BIT_ID_TYPE target_id;
9557 target_id = ASC_TIX_TO_TARGET_ID(target_ix);
9558 tid_no = ASC_TIX_TO_TID(target_ix);
9559 if ((asc_dvc->unit_not_ready & target_id) ||
9560 (asc_dvc->queue_full_or_busy & target_id)) {
9564 cur_used_qs = (uint) asc_dvc->cur_total_qng +
9565 (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
9567 cur_used_qs = (uint) asc_dvc->cur_total_qng +
9568 (uint) ASC_MIN_FREE_Q;
9570 if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
9571 cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
9572 if (asc_dvc->cur_dvc_qng[tid_no] >=
9573 asc_dvc->max_dvc_qng[tid_no]) {
9576 return (cur_free_qs);
9579 if ((n_qs > asc_dvc->last_q_shortage)
9580 && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
9581 asc_dvc->last_q_shortage = n_qs;
9587 static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
9592 uchar syn_period_ix;
9596 iop_base = asc_dvc->iop_base;
9597 if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
9598 ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
9599 tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
9600 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
9602 (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
9603 syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
9604 AscMsgOutSDTR(asc_dvc,
9605 asc_dvc->sdtr_period_tbl[syn_period_ix],
9607 scsiq->q1.cntl |= QC_MSG_OUT;
9609 q_addr = ASC_QNO_TO_QADDR(q_no);
9610 if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
9611 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
9613 scsiq->q1.status = QS_FREE;
9614 AscMemWordCopyPtrToLram(iop_base,
9615 q_addr + ASC_SCSIQ_CDB_BEG,
9616 (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
9618 DvcPutScsiQ(iop_base,
9619 q_addr + ASC_SCSIQ_CPY_BEG,
9620 (uchar *)&scsiq->q1.cntl,
9621 ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
9622 AscWriteLramWord(iop_base,
9623 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
9624 (ushort)(((ushort)scsiq->q1.
9625 q_no << 8) | (ushort)QS_READY));
9630 AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
9634 ASC_SG_HEAD *sg_head;
9635 ASC_SG_LIST_Q scsi_sg_q;
9636 ASC_DCNT saved_data_addr;
9637 ASC_DCNT saved_data_cnt;
9639 ushort sg_list_dwords;
9641 ushort sg_entry_cnt;
9645 iop_base = asc_dvc->iop_base;
9646 sg_head = scsiq->sg_head;
9647 saved_data_addr = scsiq->q1.data_addr;
9648 saved_data_cnt = scsiq->q1.data_cnt;
9649 scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
9650 scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
9651 #if CC_VERY_LONG_SG_LIST
9653 * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
9654 * then not all SG elements will fit in the allocated queues.
9655 * The rest of the SG elements will be copied when the RISC
9656 * completes the SG elements that fit and halts.
9658 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
9660 * Set sg_entry_cnt to be the number of SG elements that
9661 * will fit in the allocated SG queues. It is minus 1, because
9662 * the first SG element is handled above. ASC_MAX_SG_LIST is
9663 * already inflated by 1 to account for this. For example it
9664 * may be 50 which is 1 + 7 queues * 7 SG elements.
9666 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
9669 * Keep track of remaining number of SG elements that will
9670 * need to be handled from a_isr.c.
9672 scsiq->remain_sg_entry_cnt =
9673 sg_head->entry_cnt - ASC_MAX_SG_LIST;
9675 #endif /* CC_VERY_LONG_SG_LIST */
9677 * Set sg_entry_cnt to be the number of SG elements that
9678 * will fit in the allocated SG queues. It is minus 1, because
9679 * the first SG element is handled above.
9681 sg_entry_cnt = sg_head->entry_cnt - 1;
9682 #if CC_VERY_LONG_SG_LIST
9684 #endif /* CC_VERY_LONG_SG_LIST */
9685 if (sg_entry_cnt != 0) {
9686 scsiq->q1.cntl |= QC_SG_HEAD;
9687 q_addr = ASC_QNO_TO_QADDR(q_no);
9689 scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
9690 scsi_sg_q.sg_head_qp = q_no;
9691 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
9692 for (i = 0; i < sg_head->queue_cnt; i++) {
9693 scsi_sg_q.seq_no = i + 1;
9694 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
9695 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
9696 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
9698 scsi_sg_q.sg_list_cnt =
9700 scsi_sg_q.sg_cur_list_cnt =
9703 scsi_sg_q.sg_list_cnt =
9704 ASC_SG_LIST_PER_Q - 1;
9705 scsi_sg_q.sg_cur_list_cnt =
9706 ASC_SG_LIST_PER_Q - 1;
9709 #if CC_VERY_LONG_SG_LIST
9711 * This is the last SG queue in the list of
9712 * allocated SG queues. If there are more
9713 * SG elements than will fit in the allocated
9714 * queues, then set the QCSG_SG_XFER_MORE flag.
9716 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
9717 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
9719 #endif /* CC_VERY_LONG_SG_LIST */
9720 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
9721 #if CC_VERY_LONG_SG_LIST
9723 #endif /* CC_VERY_LONG_SG_LIST */
9724 sg_list_dwords = sg_entry_cnt << 1;
9726 scsi_sg_q.sg_list_cnt = sg_entry_cnt;
9727 scsi_sg_q.sg_cur_list_cnt =
9730 scsi_sg_q.sg_list_cnt =
9732 scsi_sg_q.sg_cur_list_cnt =
9737 next_qp = AscReadLramByte(iop_base,
9740 scsi_sg_q.q_no = next_qp;
9741 q_addr = ASC_QNO_TO_QADDR(next_qp);
9742 AscMemWordCopyPtrToLram(iop_base,
9743 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
9744 (uchar *)&scsi_sg_q,
9745 sizeof(ASC_SG_LIST_Q) >> 1);
9746 AscMemDWordCopyPtrToLram(iop_base,
9747 q_addr + ASC_SGQ_LIST_BEG,
9751 sg_index += ASC_SG_LIST_PER_Q;
9752 scsiq->next_sg_index = sg_index;
9755 scsiq->q1.cntl &= ~QC_SG_HEAD;
9757 sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
9758 scsiq->q1.data_addr = saved_data_addr;
9759 scsiq->q1.data_cnt = saved_data_cnt;
9764 AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
9768 if (AscHostReqRiscHalt(iop_base)) {
9769 sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
9770 AscStartChip(iop_base);
9776 static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
9778 ASC_SCSI_BIT_ID_TYPE org_id;
9782 AscSetBank(iop_base, 1);
9783 org_id = AscReadChipDvcID(iop_base);
9784 for (i = 0; i <= ASC_MAX_TID; i++) {
9785 if (org_id == (0x01 << i))
9788 org_id = (ASC_SCSI_BIT_ID_TYPE) i;
9789 AscWriteChipDvcID(iop_base, id);
9790 if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
9791 AscSetBank(iop_base, 0);
9792 AscSetChipSyn(iop_base, sdtr_data);
9793 if (AscGetChipSyn(iop_base) != sdtr_data) {
9799 AscSetBank(iop_base, 1);
9800 AscWriteChipDvcID(iop_base, org_id);
9801 AscSetBank(iop_base, 0);
9805 static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
9812 iop_base = asc_dvc->iop_base;
9814 AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
9815 (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
9818 i = ASC_MIN_ACTIVE_QNO;
9819 s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
9820 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
9822 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
9823 (uchar)(asc_dvc->max_total_qng));
9824 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
9827 s_addr += ASC_QBLK_SIZE;
9828 for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
9829 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
9831 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
9833 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
9836 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
9837 (uchar)ASC_QLINK_END);
9838 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
9839 (uchar)(asc_dvc->max_total_qng - 1));
9840 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
9841 (uchar)asc_dvc->max_total_qng);
9843 s_addr += ASC_QBLK_SIZE;
9844 for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
9845 i++, s_addr += ASC_QBLK_SIZE) {
9846 AscWriteLramByte(iop_base,
9847 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
9848 AscWriteLramByte(iop_base,
9849 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
9850 AscWriteLramByte(iop_base,
9851 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
9856 static ushort AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
9862 iop_base = asc_dvc->iop_base;
9863 AscPutRiscVarFreeQHead(iop_base, 1);
9864 AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
9865 AscPutVarFreeQHead(iop_base, 1);
9866 AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
9867 AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
9868 (uchar)((int)asc_dvc->max_total_qng + 1));
9869 AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
9870 (uchar)((int)asc_dvc->max_total_qng + 2));
9871 AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
9872 asc_dvc->max_total_qng);
9873 AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
9874 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9875 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
9876 AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
9877 AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
9878 AscPutQDoneInProgress(iop_base, 0);
9879 lram_addr = ASC_QADR_BEG;
9880 for (i = 0; i < 32; i++, lram_addr += 2) {
9881 AscWriteLramWord(iop_base, lram_addr, 0);
9886 static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
9888 if (asc_dvc->err_code == 0) {
9889 asc_dvc->err_code = err_code;
9890 AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
9897 AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
9900 uchar sdtr_period_index;
9903 iop_base = asc_dvc->iop_base;
9904 sdtr_buf.msg_type = MS_EXTEND;
9905 sdtr_buf.msg_len = MS_SDTR_LEN;
9906 sdtr_buf.msg_req = MS_SDTR_CODE;
9907 sdtr_buf.xfer_period = sdtr_period;
9908 sdtr_offset &= ASC_SYN_MAX_OFFSET;
9909 sdtr_buf.req_ack_offset = sdtr_offset;
9910 if ((sdtr_period_index =
9911 AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
9912 asc_dvc->max_sdtr_index) {
9913 AscMemWordCopyPtrToLram(iop_base,
9916 sizeof(EXT_MSG) >> 1);
9917 return ((sdtr_period_index << 4) | sdtr_offset);
9920 sdtr_buf.req_ack_offset = 0;
9921 AscMemWordCopyPtrToLram(iop_base,
9924 sizeof(EXT_MSG) >> 1);
9930 AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
9933 uchar sdtr_period_ix;
9935 sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
9936 if ((sdtr_period_ix > asc_dvc->max_sdtr_index)
9940 byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
9944 static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
9946 AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
9947 AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
9951 static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
9953 uchar *period_table;
9958 period_table = asc_dvc->sdtr_period_tbl;
9959 max_index = (int)asc_dvc->max_sdtr_index;
9960 min_index = (int)asc_dvc->host_init_sdtr_index;
9961 if ((syn_time <= period_table[max_index])) {
9962 for (i = min_index; i < (max_index - 1); i++) {
9963 if (syn_time <= period_table[i]) {
9967 return ((uchar)max_index);
9969 return ((uchar)(max_index + 1));
9973 static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
9979 q_addr = ASC_QNO_TO_QADDR(free_q_head);
9980 q_status = (uchar)AscReadLramByte(iop_base,
9982 ASC_SCSIQ_B_STATUS));
9983 next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
9984 if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
9987 return (ASC_QLINK_END);
9991 AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
9995 for (i = 0; i < n_free_q; i++) {
9996 if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
9998 return (ASC_QLINK_END);
10001 return (free_q_head);
10004 static int AscHostReqRiscHalt(PortAddr iop_base)
10008 uchar saved_stop_code;
10010 if (AscIsChipHalted(iop_base))
10012 saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
10013 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
10014 ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
10016 if (AscIsChipHalted(iop_base)) {
10020 DvcSleepMilliSecond(100);
10021 } while (count++ < 20);
10022 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
10026 static int AscStopQueueExe(PortAddr iop_base)
10030 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
10031 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
10032 ASC_STOP_REQ_RISC_STOP);
10034 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
10035 ASC_STOP_ACK_RISC_STOP) {
10038 DvcSleepMilliSecond(100);
10039 } while (count++ < 20);
10044 static void DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
10049 static void DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
10051 udelay((nano_sec + 999) / 1000);
10054 static int AscStartChip(PortAddr iop_base)
10056 AscSetChipControl(iop_base, 0);
10057 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
10063 static int AscStopChip(PortAddr iop_base)
10068 AscGetChipControl(iop_base) &
10069 (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
10070 AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
10071 AscSetChipIH(iop_base, INS_HALT);
10072 AscSetChipIH(iop_base, INS_RFLAG_WTM);
10073 if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
10079 static int AscIsChipHalted(PortAddr iop_base)
10081 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
10082 if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
10089 static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
10091 AscSetBank(iop_base, 1);
10092 AscWriteChipIH(iop_base, ins_code);
10093 AscSetBank(iop_base, 0);
10097 static void AscAckInterrupt(PortAddr iop_base)
10105 risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
10106 if (loop++ > 0x7FFF) {
10109 } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
10111 AscReadLramByte(iop_base,
10112 ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
10113 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
10114 (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
10115 AscSetChipStatus(iop_base, CIW_INT_ACK);
10117 while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
10118 AscSetChipStatus(iop_base, CIW_INT_ACK);
10123 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
10127 static void AscDisableInterrupt(PortAddr iop_base)
10131 cfg = AscGetChipCfgLsw(iop_base);
10132 AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
10136 static void AscEnableInterrupt(PortAddr iop_base)
10140 cfg = AscGetChipCfgLsw(iop_base);
10141 AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
10145 static void AscSetBank(PortAddr iop_base, uchar bank)
10149 val = AscGetChipControl(iop_base) &
10151 (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
10154 val |= CC_BANK_ONE;
10155 } else if (bank == 2) {
10156 val |= CC_DIAG | CC_BANK_ONE;
10158 val &= ~CC_BANK_ONE;
10160 AscSetChipControl(iop_base, val);
10164 static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
10169 iop_base = asc_dvc->iop_base;
10170 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
10172 DvcSleepMilliSecond(100);
10174 AscStopChip(iop_base);
10175 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
10176 DvcDelayNanoSecond(asc_dvc, 60000);
10177 AscSetChipIH(iop_base, INS_RFLAG_WTM);
10178 AscSetChipIH(iop_base, INS_HALT);
10179 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
10180 AscSetChipControl(iop_base, CC_HALT);
10181 DvcSleepMilliSecond(200);
10182 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
10183 AscSetChipStatus(iop_base, 0);
10184 return (AscIsChipHalted(iop_base));
10187 static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
10189 if (bus_type & ASC_IS_ISA)
10190 return (ASC_MAX_ISA_DMA_COUNT);
10191 else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
10192 return (ASC_MAX_VL_DMA_COUNT);
10193 return (ASC_MAX_PCI_DMA_COUNT);
10197 static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
10201 channel = AscGetChipCfgLsw(iop_base) & 0x0003;
10202 if (channel == 0x03)
10204 else if (channel == 0x00)
10206 return (channel + 4);
10209 static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
10214 if ((dma_channel >= 5) && (dma_channel <= 7)) {
10215 if (dma_channel == 7)
10218 value = dma_channel - 4;
10219 cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
10221 AscSetChipCfgLsw(iop_base, cfg_lsw);
10222 return (AscGetIsaDmaChannel(iop_base));
10227 static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
10229 speed_value &= 0x07;
10230 AscSetBank(iop_base, 1);
10231 AscWriteChipDmaSpeed(iop_base, speed_value);
10232 AscSetBank(iop_base, 0);
10233 return (AscGetIsaDmaSpeed(iop_base));
10236 static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
10240 AscSetBank(iop_base, 1);
10241 speed_value = AscReadChipDmaSpeed(iop_base);
10242 speed_value &= 0x07;
10243 AscSetBank(iop_base, 0);
10244 return (speed_value);
10246 #endif /* CONFIG_ISA */
10248 static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
10250 unsigned short warn_code = 0;
10252 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
10253 if (asc_dvc->err_code != 0)
10256 if (AscFindSignature(asc_dvc->iop_base)) {
10257 warn_code |= AscInitAscDvcVar(asc_dvc);
10258 warn_code |= AscInitFromEEP(asc_dvc);
10259 asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
10260 if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) {
10261 asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
10264 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
10266 return (warn_code);
10269 static ushort __devinit AscInitSetConfig(ASC_DVC_VAR *asc_dvc)
10271 ushort warn_code = 0;
10273 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
10274 if (asc_dvc->err_code != 0)
10276 if (AscFindSignature(asc_dvc->iop_base)) {
10277 warn_code |= AscInitFromAscDvcVar(asc_dvc);
10278 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
10280 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
10282 return (warn_code);
10285 static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
10291 iop_base = asc_dvc->iop_base;
10293 cfg_msw = AscGetChipCfgMsw(iop_base);
10294 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
10295 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
10296 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
10297 AscSetChipCfgMsw(iop_base, cfg_msw);
10299 if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
10300 asc_dvc->cfg->cmd_qng_enabled) {
10301 asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
10302 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
10304 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
10305 warn_code |= ASC_WARN_AUTO_CONFIG;
10307 if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
10308 if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
10309 != asc_dvc->irq_no) {
10310 asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
10314 if (asc_dvc->bus_type & ASC_IS_PCI) {
10315 struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
10317 AscSetChipCfgMsw(iop_base, cfg_msw);
10318 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
10320 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
10321 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
10322 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
10323 asc_dvc->bug_fix_cntl |=
10324 ASC_BUG_FIX_ASYN_USE_SYN;
10328 #endif /* CONFIG_PCI */
10329 if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
10330 if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
10331 == ASC_CHIP_VER_ASYN_BUG) {
10332 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
10335 if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
10336 asc_dvc->cfg->chip_scsi_id) {
10337 asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
10340 if (asc_dvc->bus_type & ASC_IS_ISA) {
10341 AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
10342 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
10344 #endif /* CONFIG_ISA */
10345 return (warn_code);
10348 static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
10353 iop_base = asc_dvc->iop_base;
10355 if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
10356 !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
10357 AscResetChipAndScsiBus(asc_dvc);
10358 DvcSleepMilliSecond((ASC_DCNT)
10359 ((ushort)asc_dvc->scsi_reset_wait * 1000));
10361 asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
10362 if (asc_dvc->err_code != 0)
10364 if (!AscFindSignature(asc_dvc->iop_base)) {
10365 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
10366 return (warn_code);
10368 AscDisableInterrupt(iop_base);
10369 warn_code |= AscInitLram(asc_dvc);
10370 if (asc_dvc->err_code != 0)
10372 ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
10373 (ulong)_asc_mcode_chksum);
10374 if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
10375 _asc_mcode_size) != _asc_mcode_chksum) {
10376 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
10377 return (warn_code);
10379 warn_code |= AscInitMicroCodeVar(asc_dvc);
10380 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
10381 AscEnableInterrupt(iop_base);
10382 return (warn_code);
10385 static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
10390 uchar chip_version;
10392 iop_base = asc_dvc->iop_base;
10394 asc_dvc->err_code = 0;
10395 if ((asc_dvc->bus_type &
10396 (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
10397 asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
10399 AscSetChipControl(iop_base, CC_HALT);
10400 AscSetChipStatus(iop_base, 0);
10401 asc_dvc->bug_fix_cntl = 0;
10402 asc_dvc->pci_fix_asyn_xfer = 0;
10403 asc_dvc->pci_fix_asyn_xfer_always = 0;
10404 /* asc_dvc->init_state initalized in AscInitGetConfig(). */
10405 asc_dvc->sdtr_done = 0;
10406 asc_dvc->cur_total_qng = 0;
10407 asc_dvc->is_in_int = 0;
10408 asc_dvc->in_critical_cnt = 0;
10409 asc_dvc->last_q_shortage = 0;
10410 asc_dvc->use_tagged_qng = 0;
10411 asc_dvc->no_scam = 0;
10412 asc_dvc->unit_not_ready = 0;
10413 asc_dvc->queue_full_or_busy = 0;
10414 asc_dvc->redo_scam = 0;
10416 asc_dvc->host_init_sdtr_index = 0;
10417 asc_dvc->cfg->can_tagged_qng = 0;
10418 asc_dvc->cfg->cmd_qng_enabled = 0;
10419 asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
10420 asc_dvc->init_sdtr = 0;
10421 asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
10422 asc_dvc->scsi_reset_wait = 3;
10423 asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
10424 asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
10425 asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
10426 asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
10427 asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
10428 asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
10429 asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
10430 ASC_LIB_VERSION_MINOR;
10431 chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
10432 asc_dvc->cfg->chip_version = chip_version;
10433 asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
10434 asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
10435 asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
10436 asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
10437 asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
10438 asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
10439 asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
10440 asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
10441 asc_dvc->max_sdtr_index = 7;
10442 if ((asc_dvc->bus_type & ASC_IS_PCI) &&
10443 (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
10444 asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
10445 asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
10446 asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
10447 asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
10448 asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
10449 asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
10450 asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
10451 asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
10452 asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
10453 asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
10454 asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
10455 asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
10456 asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
10457 asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
10458 asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
10459 asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
10460 asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
10461 asc_dvc->max_sdtr_index = 15;
10462 if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
10463 AscSetExtraControl(iop_base,
10464 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
10465 } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
10466 AscSetExtraControl(iop_base,
10467 (SEC_ACTIVE_NEGATE |
10468 SEC_ENABLE_FILTER));
10471 if (asc_dvc->bus_type == ASC_IS_PCI) {
10472 AscSetExtraControl(iop_base,
10473 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
10476 asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
10477 if (AscGetChipBusType(iop_base) == ASC_IS_ISAPNP) {
10478 AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
10479 asc_dvc->bus_type = ASC_IS_ISAPNP;
10482 if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
10483 asc_dvc->cfg->isa_dma_channel =
10484 (uchar)AscGetIsaDmaChannel(iop_base);
10486 #endif /* CONFIG_ISA */
10487 for (i = 0; i <= ASC_MAX_TID; i++) {
10488 asc_dvc->cur_dvc_qng[i] = 0;
10489 asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
10490 asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
10491 asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
10492 asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
10494 return (warn_code);
10497 static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
10499 ASCEEP_CONFIG eep_config_buf;
10500 ASCEEP_CONFIG *eep_config;
10504 ushort cfg_msw, cfg_lsw;
10508 iop_base = asc_dvc->iop_base;
10510 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
10511 AscStopQueueExe(iop_base);
10512 if ((AscStopChip(iop_base) == FALSE) ||
10513 (AscGetChipScsiCtrl(iop_base) != 0)) {
10514 asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
10515 AscResetChipAndScsiBus(asc_dvc);
10516 DvcSleepMilliSecond((ASC_DCNT)
10517 ((ushort)asc_dvc->scsi_reset_wait * 1000));
10519 if (AscIsChipHalted(iop_base) == FALSE) {
10520 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
10521 return (warn_code);
10523 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
10524 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
10525 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
10526 return (warn_code);
10528 eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
10529 cfg_msw = AscGetChipCfgMsw(iop_base);
10530 cfg_lsw = AscGetChipCfgLsw(iop_base);
10531 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
10532 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
10533 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
10534 AscSetChipCfgMsw(iop_base, cfg_msw);
10536 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
10537 ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
10541 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
10542 warn_code |= ASC_WARN_AUTO_CONFIG;
10543 if (asc_dvc->cfg->chip_version == 3) {
10544 if (eep_config->cfg_lsw != cfg_lsw) {
10545 warn_code |= ASC_WARN_EEPROM_RECOVER;
10546 eep_config->cfg_lsw =
10547 AscGetChipCfgLsw(iop_base);
10549 if (eep_config->cfg_msw != cfg_msw) {
10550 warn_code |= ASC_WARN_EEPROM_RECOVER;
10551 eep_config->cfg_msw =
10552 AscGetChipCfgMsw(iop_base);
10556 eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
10557 eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
10558 ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
10559 eep_config->chksum);
10560 if (chksum != eep_config->chksum) {
10561 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
10562 ASC_CHIP_VER_PCI_ULTRA_3050) {
10564 "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
10565 eep_config->init_sdtr = 0xFF;
10566 eep_config->disc_enable = 0xFF;
10567 eep_config->start_motor = 0xFF;
10568 eep_config->use_cmd_qng = 0;
10569 eep_config->max_total_qng = 0xF0;
10570 eep_config->max_tag_qng = 0x20;
10571 eep_config->cntl = 0xBFFF;
10572 ASC_EEP_SET_CHIP_ID(eep_config, 7);
10573 eep_config->no_scam = 0;
10574 eep_config->adapter_info[0] = 0;
10575 eep_config->adapter_info[1] = 0;
10576 eep_config->adapter_info[2] = 0;
10577 eep_config->adapter_info[3] = 0;
10578 eep_config->adapter_info[4] = 0;
10579 /* Indicate EEPROM-less board. */
10580 eep_config->adapter_info[5] = 0xBB;
10583 ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
10585 warn_code |= ASC_WARN_EEPROM_CHKSUM;
10588 asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
10589 asc_dvc->cfg->disc_enable = eep_config->disc_enable;
10590 asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
10591 asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
10592 asc_dvc->start_motor = eep_config->start_motor;
10593 asc_dvc->dvc_cntl = eep_config->cntl;
10594 asc_dvc->no_scam = eep_config->no_scam;
10595 asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
10596 asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
10597 asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
10598 asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
10599 asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
10600 asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
10601 if (!AscTestExternalLram(asc_dvc)) {
10602 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
10603 ASC_IS_PCI_ULTRA)) {
10604 eep_config->max_total_qng =
10605 ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
10606 eep_config->max_tag_qng =
10607 ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
10609 eep_config->cfg_msw |= 0x0800;
10611 AscSetChipCfgMsw(iop_base, cfg_msw);
10612 eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
10613 eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
10617 if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
10618 eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
10620 if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
10621 eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
10623 if (eep_config->max_tag_qng > eep_config->max_total_qng) {
10624 eep_config->max_tag_qng = eep_config->max_total_qng;
10626 if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
10627 eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
10629 asc_dvc->max_total_qng = eep_config->max_total_qng;
10630 if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
10631 eep_config->use_cmd_qng) {
10632 eep_config->disc_enable = eep_config->use_cmd_qng;
10633 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
10635 if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
10636 asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
10638 ASC_EEP_SET_CHIP_ID(eep_config,
10639 ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
10640 asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
10641 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
10642 !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
10643 asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
10646 for (i = 0; i <= ASC_MAX_TID; i++) {
10647 asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
10648 asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
10649 asc_dvc->cfg->sdtr_period_offset[i] =
10650 (uchar)(ASC_DEF_SDTR_OFFSET |
10651 (asc_dvc->host_init_sdtr_index << 4));
10653 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
10656 AscSetEEPConfig(iop_base, eep_config,
10657 asc_dvc->bus_type)) != 0) {
10659 ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
10663 ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
10666 return (warn_code);
10669 static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
10674 ASC_PADDR phy_addr;
10677 iop_base = asc_dvc->iop_base;
10679 for (i = 0; i <= ASC_MAX_TID; i++) {
10680 AscPutMCodeInitSDTRAtID(iop_base, i,
10681 asc_dvc->cfg->sdtr_period_offset[i]
10685 AscInitQLinkVar(asc_dvc);
10686 AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
10687 asc_dvc->cfg->disc_enable);
10688 AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
10689 ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
10691 /* Align overrun buffer on an 8 byte boundary. */
10692 phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
10693 phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
10694 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
10695 (uchar *)&phy_addr, 1);
10696 phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
10697 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
10698 (uchar *)&phy_size, 1);
10700 asc_dvc->cfg->mcode_date =
10701 AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
10702 asc_dvc->cfg->mcode_version =
10703 AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
10705 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
10706 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
10707 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
10708 return (warn_code);
10710 if (AscStartChip(iop_base) != 1) {
10711 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
10712 return (warn_code);
10715 return (warn_code);
10718 static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
10725 iop_base = asc_dvc->iop_base;
10727 q_addr = ASC_QNO_TO_QADDR(241);
10728 saved_word = AscReadLramWord(iop_base, q_addr);
10729 AscSetChipLramAddr(iop_base, q_addr);
10730 AscSetChipLramData(iop_base, 0x55AA);
10731 DvcSleepMilliSecond(10);
10732 AscSetChipLramAddr(iop_base, q_addr);
10733 if (AscGetChipLramData(iop_base) == 0x55AA) {
10735 AscWriteLramWord(iop_base, q_addr, saved_word);
10740 static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
10747 AscSetChipEEPCmd(iop_base, cmd_reg);
10748 DvcSleepMilliSecond(1);
10749 read_back = AscGetChipEEPCmd(iop_base);
10750 if (read_back == cmd_reg) {
10753 if (retry++ > ASC_EEP_MAX_RETRY) {
10759 static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
10766 AscSetChipEEPData(iop_base, data_reg);
10767 DvcSleepMilliSecond(1);
10768 read_back = AscGetChipEEPData(iop_base);
10769 if (read_back == data_reg) {
10772 if (retry++ > ASC_EEP_MAX_RETRY) {
10778 static void __devinit AscWaitEEPRead(void)
10780 DvcSleepMilliSecond(1);
10784 static void __devinit AscWaitEEPWrite(void)
10786 DvcSleepMilliSecond(20);
10790 static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
10795 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
10797 cmd_reg = addr | ASC_EEP_CMD_READ;
10798 AscWriteEEPCmdReg(iop_base, cmd_reg);
10800 read_wval = AscGetChipEEPData(iop_base);
10802 return (read_wval);
10805 static ushort __devinit
10806 AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
10810 read_wval = AscReadEEPWord(iop_base, addr);
10811 if (read_wval != word_val) {
10812 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
10814 AscWriteEEPDataReg(iop_base, word_val);
10816 AscWriteEEPCmdReg(iop_base,
10817 (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
10819 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
10821 return (AscReadEEPWord(iop_base, addr));
10823 return (read_wval);
10826 static ushort __devinit
10827 AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
10834 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
10837 wbuf = (ushort *)cfg_buf;
10839 /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
10840 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
10841 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
10844 if (bus_type & ASC_IS_VL) {
10845 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
10846 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
10848 cfg_beg = ASC_EEP_DVC_CFG_BEG;
10849 cfg_end = ASC_EEP_MAX_DVC_ADDR;
10851 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
10852 wval = AscReadEEPWord(iop_base, (uchar)s_addr);
10853 if (s_addr <= uchar_end_in_config) {
10855 * Swap all char fields - must unswap bytes already swapped
10856 * by AscReadEEPWord().
10858 *wbuf = le16_to_cpu(wval);
10860 /* Don't swap word field at the end - cntl field. */
10863 sum += wval; /* Checksum treats all EEPROM data as words. */
10866 * Read the checksum word which will be compared against 'sum'
10867 * by the caller. Word field already swapped.
10869 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
10873 static int __devinit
10874 AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
10883 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
10885 wbuf = (ushort *)cfg_buf;
10888 /* Write two config words; AscWriteEEPWord() will swap bytes. */
10889 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
10891 if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
10895 if (bus_type & ASC_IS_VL) {
10896 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
10897 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
10899 cfg_beg = ASC_EEP_DVC_CFG_BEG;
10900 cfg_end = ASC_EEP_MAX_DVC_ADDR;
10902 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
10903 if (s_addr <= uchar_end_in_config) {
10905 * This is a char field. Swap char fields before they are
10906 * swapped again by AscWriteEEPWord().
10908 word = cpu_to_le16(*wbuf);
10910 AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
10914 /* Don't swap word field at the end - cntl field. */
10916 AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
10920 sum += *wbuf; /* Checksum calculated from word values. */
10922 /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
10924 if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
10928 /* Read EEPROM back again. */
10929 wbuf = (ushort *)cfg_buf;
10931 * Read two config words; Byte-swapping done by AscReadEEPWord().
10933 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
10934 if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
10938 if (bus_type & ASC_IS_VL) {
10939 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
10940 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
10942 cfg_beg = ASC_EEP_DVC_CFG_BEG;
10943 cfg_end = ASC_EEP_MAX_DVC_ADDR;
10945 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
10946 if (s_addr <= uchar_end_in_config) {
10948 * Swap all char fields. Must unswap bytes already swapped
10949 * by AscReadEEPWord().
10952 le16_to_cpu(AscReadEEPWord
10953 (iop_base, (uchar)s_addr));
10955 /* Don't swap word field at the end - cntl field. */
10956 word = AscReadEEPWord(iop_base, (uchar)s_addr);
10958 if (*wbuf != word) {
10962 /* Read checksum; Byte swapping not needed. */
10963 if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
10969 static int __devinit
10970 AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
10977 if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
10981 if (++retry > ASC_EEP_MAX_RETRY) {
10989 AscAsyncFix(ASC_DVC_VAR *asc_dvc, uchar tid_no, ASC_SCSI_INQUIRY *inq)
10992 ASC_SCSI_BIT_ID_TYPE tid_bits;
10994 dvc_type = ASC_INQ_DVC_TYPE(inq);
10995 tid_bits = ASC_TIX_TO_TARGET_ID(tid_no);
10997 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN) {
10998 if (!(asc_dvc->init_sdtr & tid_bits)) {
10999 if ((dvc_type == TYPE_ROM) &&
11000 (strncmp(inq->vendor_id, "HP ", 3) == 0)) {
11001 asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
11003 asc_dvc->pci_fix_asyn_xfer |= tid_bits;
11004 if ((dvc_type == TYPE_PROCESSOR) ||
11005 (dvc_type == TYPE_SCANNER) ||
11006 (dvc_type == TYPE_ROM) || (dvc_type == TYPE_TAPE)) {
11007 asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
11010 if (asc_dvc->pci_fix_asyn_xfer & tid_bits) {
11011 AscSetRunChipSynRegAtID(asc_dvc->iop_base,
11013 ASYN_SDTR_DATA_FIX_PCI_REV_AB);
11020 static int AscTagQueuingSafe(ASC_SCSI_INQUIRY *inq)
11022 if ((inq->add_len >= 32) &&
11023 (strncmp(inq->vendor_id, "QUANTUM XP34301", 15) == 0) &&
11024 (strncmp(inq->product_rev_level, "1071", 4) == 0)) {
11031 AscInquiryHandling(ASC_DVC_VAR *asc_dvc, uchar tid_no, ASC_SCSI_INQUIRY *inq)
11033 ASC_SCSI_BIT_ID_TYPE tid_bit = ASC_TIX_TO_TARGET_ID(tid_no);
11034 ASC_SCSI_BIT_ID_TYPE orig_init_sdtr, orig_use_tagged_qng;
11036 orig_init_sdtr = asc_dvc->init_sdtr;
11037 orig_use_tagged_qng = asc_dvc->use_tagged_qng;
11039 asc_dvc->init_sdtr &= ~tid_bit;
11040 asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
11041 asc_dvc->use_tagged_qng &= ~tid_bit;
11043 if (ASC_INQ_RESPONSE_FMT(inq) >= 2 || ASC_INQ_ANSI_VER(inq) >= 2) {
11044 if ((asc_dvc->cfg->sdtr_enable & tid_bit) && ASC_INQ_SYNC(inq)) {
11045 asc_dvc->init_sdtr |= tid_bit;
11047 if ((asc_dvc->cfg->cmd_qng_enabled & tid_bit) &&
11048 ASC_INQ_CMD_QUEUE(inq)) {
11049 if (AscTagQueuingSafe(inq)) {
11050 asc_dvc->use_tagged_qng |= tid_bit;
11051 asc_dvc->cfg->can_tagged_qng |= tid_bit;
11055 if (orig_use_tagged_qng != asc_dvc->use_tagged_qng) {
11056 AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
11057 asc_dvc->cfg->disc_enable);
11058 AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
11059 asc_dvc->use_tagged_qng);
11060 AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
11061 asc_dvc->cfg->can_tagged_qng);
11063 asc_dvc->max_dvc_qng[tid_no] =
11064 asc_dvc->cfg->max_tag_qng[tid_no];
11065 AscWriteLramByte(asc_dvc->iop_base,
11066 (ushort)(ASCV_MAX_DVC_QNG_BEG + tid_no),
11067 asc_dvc->max_dvc_qng[tid_no]);
11069 if (orig_init_sdtr != asc_dvc->init_sdtr) {
11070 AscAsyncFix(asc_dvc, tid_no, inq);
11075 static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
11080 if (isodd_word(addr)) {
11081 AscSetChipLramAddr(iop_base, addr - 1);
11082 word_data = AscGetChipLramData(iop_base);
11083 byte_data = (uchar)((word_data >> 8) & 0xFF);
11085 AscSetChipLramAddr(iop_base, addr);
11086 word_data = AscGetChipLramData(iop_base);
11087 byte_data = (uchar)(word_data & 0xFF);
11089 return (byte_data);
11092 static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
11096 AscSetChipLramAddr(iop_base, addr);
11097 word_data = AscGetChipLramData(iop_base);
11098 return (word_data);
11101 #if CC_VERY_LONG_SG_LIST
11102 static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
11104 ushort val_low, val_high;
11105 ASC_DCNT dword_data;
11107 AscSetChipLramAddr(iop_base, addr);
11108 val_low = AscGetChipLramData(iop_base);
11109 val_high = AscGetChipLramData(iop_base);
11110 dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
11111 return (dword_data);
11113 #endif /* CC_VERY_LONG_SG_LIST */
11115 static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
11117 AscSetChipLramAddr(iop_base, addr);
11118 AscSetChipLramData(iop_base, word_val);
11122 static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
11126 if (isodd_word(addr)) {
11128 word_data = AscReadLramWord(iop_base, addr);
11129 word_data &= 0x00FF;
11130 word_data |= (((ushort)byte_val << 8) & 0xFF00);
11132 word_data = AscReadLramWord(iop_base, addr);
11133 word_data &= 0xFF00;
11134 word_data |= ((ushort)byte_val & 0x00FF);
11136 AscWriteLramWord(iop_base, addr, word_data);
11141 * Copy 2 bytes to LRAM.
11143 * The source data is assumed to be in little-endian order in memory
11144 * and is maintained in little-endian order when written to LRAM.
11147 AscMemWordCopyPtrToLram(PortAddr iop_base,
11148 ushort s_addr, uchar *s_buffer, int words)
11152 AscSetChipLramAddr(iop_base, s_addr);
11153 for (i = 0; i < 2 * words; i += 2) {
11155 * On a little-endian system the second argument below
11156 * produces a little-endian ushort which is written to
11157 * LRAM in little-endian order. On a big-endian system
11158 * the second argument produces a big-endian ushort which
11159 * is "transparently" byte-swapped by outpw() and written
11160 * in little-endian order to LRAM.
11162 outpw(iop_base + IOP_RAM_DATA,
11163 ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
11169 * Copy 4 bytes to LRAM.
11171 * The source data is assumed to be in little-endian order in memory
11172 * and is maintained in little-endian order when writen to LRAM.
11175 AscMemDWordCopyPtrToLram(PortAddr iop_base,
11176 ushort s_addr, uchar *s_buffer, int dwords)
11180 AscSetChipLramAddr(iop_base, s_addr);
11181 for (i = 0; i < 4 * dwords; i += 4) {
11182 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
11183 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
11189 * Copy 2 bytes from LRAM.
11191 * The source data is assumed to be in little-endian order in LRAM
11192 * and is maintained in little-endian order when written to memory.
11195 AscMemWordCopyPtrFromLram(PortAddr iop_base,
11196 ushort s_addr, uchar *d_buffer, int words)
11201 AscSetChipLramAddr(iop_base, s_addr);
11202 for (i = 0; i < 2 * words; i += 2) {
11203 word = inpw(iop_base + IOP_RAM_DATA);
11204 d_buffer[i] = word & 0xff;
11205 d_buffer[i + 1] = (word >> 8) & 0xff;
11210 static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
11216 for (i = 0; i < words; i++, s_addr += 2) {
11217 sum += AscReadLramWord(iop_base, s_addr);
11223 AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
11227 AscSetChipLramAddr(iop_base, s_addr);
11228 for (i = 0; i < words; i++) {
11229 AscSetChipLramData(iop_base, set_wval);
11235 * --- Adv Library Functions
11240 /* Microcode buffer is kept after initialization for error recovery. */
11241 static unsigned char _adv_asc3550_buf[] = {
11242 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
11243 0x01, 0x00, 0x48, 0xe4,
11244 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0x00, 0xfa, 0xff, 0xff,
11245 0x28, 0x0e, 0x9e, 0xe7,
11246 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7,
11247 0x55, 0xf0, 0x01, 0xf6,
11248 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
11249 0x00, 0xec, 0x85, 0xf0,
11250 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54, 0x00, 0xe6, 0x1e, 0xf0,
11251 0x86, 0xf0, 0xb4, 0x00,
11252 0x98, 0x57, 0xd0, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00,
11253 0xaa, 0x18, 0x02, 0x80,
11254 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
11255 0x00, 0x57, 0x01, 0xea,
11256 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x3e, 0x57, 0x00, 0x80,
11257 0x03, 0xe6, 0xb6, 0x00,
11258 0xc0, 0x00, 0x01, 0x01, 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12,
11259 0x02, 0x4a, 0xb9, 0x54,
11260 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
11261 0x3e, 0x00, 0x80, 0x00,
11262 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
11263 0x74, 0x01, 0x76, 0x01,
11264 0x78, 0x01, 0x62, 0x0a, 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13,
11265 0x4c, 0x1c, 0xbb, 0x55,
11266 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
11267 0x03, 0xf7, 0x06, 0xf7,
11268 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00, 0x00, 0x01, 0xb0, 0x08,
11269 0x30, 0x13, 0x64, 0x15,
11270 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c,
11271 0x04, 0xea, 0x5d, 0xf0,
11272 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
11273 0xcc, 0x00, 0x20, 0x01,
11274 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10, 0x0a, 0x12, 0x04, 0x13,
11275 0x40, 0x13, 0x30, 0x1c,
11276 0x00, 0x4e, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
11277 0x59, 0xf0, 0xa7, 0xf0,
11278 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
11279 0xa4, 0x00, 0xb5, 0x00,
11280 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xde, 0x03, 0x56, 0x0a,
11281 0x14, 0x0e, 0x02, 0x10,
11282 0x04, 0x10, 0x0a, 0x10, 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13,
11283 0x10, 0x15, 0x14, 0x15,
11284 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
11285 0x91, 0x44, 0x0a, 0x45,
11286 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55, 0xb0, 0x57, 0x01, 0x58,
11287 0x83, 0x59, 0x05, 0xe6,
11288 0x0b, 0xf0, 0x0c, 0xf0, 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8,
11289 0x02, 0xfa, 0x03, 0xfa,
11290 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
11291 0x9e, 0x00, 0xa8, 0x00,
11292 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01,
11293 0x7a, 0x01, 0xc0, 0x01,
11294 0xc2, 0x01, 0x7c, 0x02, 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08,
11295 0x69, 0x08, 0xba, 0x08,
11296 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
11297 0xf1, 0x10, 0x06, 0x12,
11298 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13, 0x42, 0x14, 0xd6, 0x14,
11299 0x8a, 0x15, 0xc6, 0x17,
11300 0xd2, 0x17, 0x6b, 0x18, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
11301 0x0e, 0x47, 0x48, 0x47,
11302 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
11303 0x14, 0x56, 0x77, 0x57,
11304 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90, 0x03, 0xa1, 0xfe, 0x9c,
11305 0xf0, 0x29, 0x02, 0xfe,
11306 0xb8, 0x0c, 0xff, 0x10, 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf,
11307 0xfe, 0x80, 0x01, 0xff,
11308 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
11309 0x00, 0xfe, 0x57, 0x24,
11310 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00, 0x00, 0x10, 0xff, 0x09,
11311 0x00, 0x00, 0xff, 0x08,
11312 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
11313 0xff, 0xff, 0xff, 0x0f,
11314 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
11315 0xfe, 0x04, 0xf7, 0xcf,
11316 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe, 0x04, 0xf7, 0xcf, 0x67,
11317 0x0b, 0x3c, 0x2a, 0xfe,
11318 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0,
11319 0xfe, 0xf0, 0x01, 0xfe,
11320 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
11321 0x02, 0xfe, 0xd4, 0x0c,
11322 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28,
11323 0x1c, 0x05, 0xfe, 0xa6,
11324 0x00, 0xfe, 0xd3, 0x12, 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48,
11325 0xf0, 0xfe, 0x86, 0x02,
11326 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
11327 0xfe, 0x46, 0xf0, 0xfe,
11328 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02, 0xfe, 0x43, 0xf0, 0xfe,
11329 0x44, 0x02, 0xfe, 0x44,
11330 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b,
11331 0xa0, 0x17, 0x06, 0x18,
11332 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
11333 0x1e, 0x1c, 0xfe, 0xe9,
11334 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xc7,
11335 0x0a, 0x6b, 0x01, 0x9e,
11336 0x02, 0x29, 0x14, 0x4d, 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b,
11337 0x01, 0x82, 0xfe, 0xbd,
11338 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
11339 0x58, 0x1c, 0x17, 0x06,
11340 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0x21,
11341 0xfe, 0x94, 0x02, 0xfe,
11342 0x5a, 0x1c, 0xea, 0xfe, 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97,
11343 0x01, 0xfe, 0x54, 0x0f,
11344 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
11345 0x69, 0x10, 0x17, 0x06,
11346 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d, 0x12, 0x20, 0xfe, 0x05,
11347 0xf6, 0xc7, 0x01, 0xfe,
11348 0x52, 0x16, 0x09, 0x4a, 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6,
11349 0x02, 0x29, 0x0a, 0x40,
11350 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
11351 0x58, 0x0a, 0x99, 0x01,
11352 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03, 0x01, 0xe6, 0x02, 0x29,
11353 0x2a, 0x46, 0xfe, 0x02,
11354 0xe8, 0x27, 0xf8, 0xfe, 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc,
11355 0x01, 0xfe, 0x07, 0x4b,
11356 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
11357 0xfe, 0x56, 0x03, 0xfe,
11358 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0, 0x9c, 0xfe, 0xef, 0x10,
11359 0xfe, 0x9f, 0xf0, 0xfe,
11360 0x64, 0x03, 0xeb, 0x0f, 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48,
11361 0x1c, 0xeb, 0x09, 0x04,
11362 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
11363 0x01, 0x0e, 0xac, 0x75,
11364 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2, 0xfe, 0x01, 0xf0, 0xd2,
11365 0xfe, 0x82, 0xf0, 0xfe,
11366 0x92, 0x03, 0xec, 0x11, 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25,
11367 0x32, 0x1f, 0xfe, 0xb4,
11368 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
11369 0x0a, 0xf0, 0xfe, 0x7a,
11370 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe, 0xf6, 0x04, 0x14, 0x2c,
11371 0x01, 0x33, 0x8f, 0xfe,
11372 0x66, 0x02, 0x02, 0xd1, 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8,
11373 0xf7, 0xfe, 0x48, 0x1c,
11374 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
11375 0x0a, 0xca, 0x01, 0x0e,
11376 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28, 0xfe, 0x10, 0x12, 0x14,
11377 0x2c, 0x01, 0x33, 0x8f,
11378 0xfe, 0x66, 0x02, 0x02, 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65,
11379 0xfe, 0x3c, 0x04, 0x1f,
11380 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
11381 0x12, 0x2b, 0xff, 0x02,
11382 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04, 0x2b, 0x01, 0x08, 0x1f,
11383 0x22, 0x30, 0x2e, 0xd5,
11384 0xfe, 0x4c, 0x44, 0xfe, 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c,
11385 0xfe, 0x4c, 0x54, 0x64,
11386 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
11387 0xfe, 0x2a, 0x13, 0x2f,
11388 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
11389 0xd3, 0xfa, 0xef, 0x86,
11390 0x09, 0x04, 0x1d, 0xfe, 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04,
11391 0x1d, 0xfe, 0x1c, 0x12,
11392 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
11393 0x70, 0x0c, 0x02, 0x22,
11394 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90, 0xf9, 0x03, 0x14, 0x92,
11395 0x01, 0x33, 0x02, 0x29,
11396 0xfe, 0x42, 0x5b, 0x67, 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87,
11397 0x80, 0xfe, 0x31, 0xe4,
11398 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
11399 0xfe, 0x70, 0x12, 0x49,
11400 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2, 0x00, 0x28, 0x16, 0xfe,
11401 0x80, 0x05, 0xfe, 0x31,
11402 0xe4, 0x6a, 0x49, 0x04, 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00,
11403 0x28, 0xfe, 0x42, 0x12,
11404 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
11405 0x11, 0xfe, 0xe3, 0x00,
11406 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05, 0xfe, 0x49, 0xf0, 0xfe,
11407 0x64, 0x05, 0x83, 0x24,
11408 0xfe, 0x21, 0x00, 0xa1, 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe,
11409 0x09, 0x48, 0x01, 0x08,
11410 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
11411 0x86, 0x24, 0x06, 0x12,
11412 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d, 0xfe, 0x22, 0x12, 0x47,
11413 0x01, 0xa7, 0x14, 0x92,
11414 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c,
11415 0x02, 0x22, 0x05, 0xfe,
11416 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
11417 0x47, 0x01, 0xa7, 0x26,
11418 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19, 0xfe, 0x02, 0x12, 0x5f,
11419 0x01, 0xfe, 0xaa, 0x14,
11420 0x1f, 0xfe, 0xfe, 0x05, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00,
11421 0x05, 0x50, 0xb4, 0x0c,
11422 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
11423 0x13, 0x01, 0xfe, 0x14,
11424 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48, 0xb7, 0x19, 0x13, 0x6c,
11425 0xff, 0x02, 0x00, 0x57,
11426 0x48, 0x8b, 0x1c, 0x3d, 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe,
11427 0x72, 0x06, 0x49, 0x04,
11428 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
11429 0x06, 0x11, 0x9a, 0x01,
11430 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4, 0x0c, 0x3f, 0x17, 0x06,
11431 0x01, 0xa7, 0xec, 0x72,
11432 0x70, 0x01, 0x6e, 0x87, 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32,
11433 0xfe, 0x0a, 0xf0, 0xfe,
11434 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
11435 0x8d, 0x81, 0x02, 0x22,
11436 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a, 0x01, 0x08, 0x15, 0x00,
11437 0x01, 0x08, 0x15, 0x00,
11438 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15,
11439 0x00, 0x02, 0xfe, 0x32,
11440 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
11441 0xfe, 0x1b, 0x00, 0x01,
11442 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
11443 0x08, 0x15, 0x06, 0x01,
11444 0x08, 0x15, 0x00, 0x02, 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe,
11445 0x9a, 0x81, 0x4b, 0x1d,
11446 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
11447 0x45, 0xfe, 0x32, 0x12,
11448 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0,
11449 0xfe, 0x32, 0x07, 0x8d,
11450 0x81, 0x8c, 0xfe, 0x5c, 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a,
11451 0x06, 0x15, 0x19, 0x02,
11452 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
11453 0x90, 0x77, 0xfe, 0xca,
11454 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a, 0x35, 0x1e, 0x20, 0x07,
11455 0x10, 0xfe, 0x0e, 0x12,
11456 0x74, 0xfe, 0x80, 0x80, 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe,
11457 0x83, 0xe7, 0xc4, 0xa1,
11458 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
11459 0x40, 0x12, 0x58, 0x01,
11460 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6,
11461 0x51, 0x83, 0xfb, 0xfe,
11462 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90,
11463 0xfe, 0x40, 0x50, 0xfe,
11464 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
11465 0xfe, 0x2a, 0x12, 0xfe,
11466 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x04, 0x4f,
11467 0x85, 0x01, 0xa8, 0xfe,
11468 0x1f, 0x80, 0x12, 0x58, 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56,
11469 0x18, 0x57, 0xfb, 0xfe,
11470 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
11471 0x0c, 0x39, 0x18, 0x3a,
11472 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35, 0x2a, 0x13, 0xfe, 0x4e,
11473 0x11, 0x65, 0xfe, 0x48,
11474 0x08, 0xfe, 0x9e, 0xf0, 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73,
11475 0xdd, 0xb8, 0xfe, 0x80,
11476 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
11477 0xfe, 0x7a, 0x08, 0x8d,
11478 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10, 0x15, 0x19, 0xfe, 0xc9,
11479 0x10, 0x61, 0x04, 0x06,
11480 0xfe, 0x10, 0x12, 0x61, 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68,
11481 0x12, 0xfe, 0x2e, 0x1c,
11482 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
11483 0x52, 0x12, 0xfe, 0x2c,
11484 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0xbe,
11485 0x08, 0xfe, 0x8a, 0x10,
11486 0xaa, 0xfe, 0xf3, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe,
11487 0x24, 0x0a, 0xab, 0xfe,
11488 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
11489 0x1c, 0x12, 0xb5, 0xfe,
11490 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x16, 0x9d, 0x05, 0xcb,
11491 0x1c, 0x06, 0x16, 0x9d,
11492 0xb8, 0x6d, 0xb9, 0x6d, 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b,
11493 0x14, 0x92, 0x01, 0x33,
11494 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
11495 0xfe, 0x74, 0x18, 0x1c,
11496 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01, 0xfe, 0x44, 0x0d, 0x3b,
11497 0x01, 0xe6, 0x1e, 0x27,
11498 0x74, 0x67, 0x1a, 0x02, 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a,
11499 0x09, 0x04, 0x6a, 0xfe,
11500 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
11501 0xfe, 0x83, 0x80, 0xfe,
11502 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x63,
11503 0x27, 0xfe, 0x40, 0x59,
11504 0xfe, 0xc1, 0x59, 0x77, 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18,
11505 0x7c, 0xbe, 0x54, 0xbf,
11506 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
11507 0x79, 0x56, 0x68, 0x57,
11508 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0x01, 0xa5,
11509 0xa2, 0x23, 0x0c, 0x7b,
11510 0x0c, 0x7c, 0x79, 0x56, 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19,
11511 0x16, 0xd7, 0x79, 0x39,
11512 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
11513 0xfe, 0x10, 0x58, 0xfe,
11514 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x02, 0x6d, 0x09, 0x04,
11515 0x19, 0x16, 0xd7, 0x09,
11516 0x04, 0xfe, 0xf7, 0x00, 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f,
11517 0xfe, 0x10, 0x90, 0xfe,
11518 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
11519 0x11, 0x9b, 0x09, 0x04,
11520 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a, 0x77, 0xfe, 0xc6, 0x08,
11521 0xfe, 0x0c, 0x58, 0xfe,
11522 0x8d, 0x58, 0x02, 0x6d, 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04,
11523 0x0b, 0xfe, 0x1a, 0x12,
11524 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
11525 0x14, 0x7a, 0x01, 0x33,
11526 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0xbe, 0x39,
11527 0xfe, 0xed, 0x19, 0xbf,
11528 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff,
11529 0x34, 0xfe, 0x74, 0x10,
11530 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
11531 0x84, 0x05, 0xcb, 0x1c,
11532 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00, 0x02, 0x5a, 0xfe, 0xd1,
11533 0xf0, 0xfe, 0xc4, 0x0a,
11534 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe,
11535 0xce, 0xf0, 0xfe, 0xca,
11536 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
11537 0x22, 0x00, 0x02, 0x5a,
11538 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe, 0x24, 0x00, 0x02, 0x5a,
11539 0xfe, 0xd0, 0xf0, 0xfe,
11540 0xec, 0x0a, 0x0f, 0x93, 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f,
11541 0x4c, 0xfe, 0x10, 0x10,
11542 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
11543 0x2a, 0x13, 0xfe, 0x4e,
11544 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0, 0xfe, 0x20, 0x0b, 0xb1,
11545 0x16, 0x32, 0x2a, 0x73,
11546 0xdd, 0xb8, 0x22, 0xb9, 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25,
11547 0x32, 0x8c, 0xfe, 0x48,
11548 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
11549 0xdb, 0x10, 0x11, 0xfe,
11550 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd, 0x7f, 0xfe, 0x89, 0xf0,
11551 0x22, 0x30, 0x2e, 0xd8,
11552 0xbc, 0x7d, 0xbd, 0x7f, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1,
11553 0x45, 0x0f, 0xfe, 0x42,
11554 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
11555 0x09, 0x04, 0x0b, 0xfe,
11556 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54, 0x12, 0x4b, 0xfe, 0x28,
11557 0x00, 0x21, 0xfe, 0xa6,
11558 0x0c, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00,
11559 0xfe, 0xe2, 0x10, 0x01,
11560 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
11561 0x01, 0x6f, 0x02, 0x29,
11562 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e, 0x0b, 0xfe, 0xb4, 0x10,
11563 0x01, 0x86, 0x3e, 0x0b,
11564 0xfe, 0xaa, 0x10, 0x01, 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3,
11565 0x3e, 0x0b, 0x0f, 0xfe,
11566 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
11567 0xe8, 0x59, 0x11, 0x2d,
11568 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02, 0xfe, 0x2a, 0x03, 0x09,
11569 0x04, 0x0b, 0x84, 0x3e,
11570 0x0b, 0x0f, 0x00, 0xfe, 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12,
11571 0x09, 0x04, 0x1b, 0xfe,
11572 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
11573 0x1c, 0x1c, 0xfe, 0x9d,
11574 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35, 0xfe, 0xa9, 0x10, 0x0f,
11575 0xfe, 0x15, 0x00, 0xfe,
11576 0x04, 0xe6, 0x0b, 0x5f, 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10,
11577 0x0f, 0xfe, 0x47, 0x00,
11578 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
11579 0xab, 0x70, 0x05, 0x6b,
11580 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b, 0xfe, 0x9d, 0x41, 0xfe,
11581 0x1c, 0x42, 0x59, 0x01,
11582 0xda, 0x02, 0x29, 0xea, 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31,
11583 0x00, 0x37, 0x97, 0x01,
11584 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
11585 0x1d, 0xfe, 0xce, 0x45,
11586 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47, 0x4b, 0x89, 0xfe, 0x75,
11587 0x57, 0x05, 0x51, 0xfe,
11588 0x98, 0x56, 0xfe, 0x38, 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48,
11589 0x46, 0x09, 0x04, 0x1d,
11590 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
11591 0x99, 0x01, 0x0e, 0xfe,
11592 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe, 0x2a, 0x03, 0x0a, 0x51,
11593 0xfe, 0xee, 0x14, 0xee,
11594 0x3e, 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad,
11595 0x13, 0x02, 0x29, 0x1e,
11596 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
11597 0xce, 0x1e, 0x2d, 0x47,
11598 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe, 0xec, 0x0d, 0x13, 0x06,
11599 0x12, 0x4d, 0x01, 0xfe,
11600 0xe2, 0x15, 0x05, 0xfe, 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe,
11601 0xf0, 0x0d, 0xfe, 0x02,
11602 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
11603 0xf6, 0xfe, 0x34, 0x01,
11604 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4, 0x0d, 0xfe, 0x18, 0x13,
11605 0xaf, 0xfe, 0x02, 0xea,
11606 0xce, 0x62, 0x7a, 0xfe, 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c,
11607 0x05, 0xfe, 0x38, 0x01,
11608 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
11609 0x0c, 0xfe, 0x62, 0x01,
11610 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11, 0x2d, 0x8a, 0x13, 0x06,
11611 0x03, 0x23, 0x03, 0x1e,
11612 0x4d, 0xfe, 0xf7, 0x12, 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe,
11613 0x71, 0x13, 0xfe, 0x24,
11614 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
11615 0xdc, 0xfe, 0x73, 0x57,
11616 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x5b, 0x57, 0xfe,
11617 0x80, 0x5d, 0x03, 0xfe,
11618 0x03, 0x57, 0xb6, 0x23, 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6,
11619 0x75, 0x03, 0x09, 0x04,
11620 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
11621 0xfe, 0x1e, 0x80, 0xe1,
11622 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe, 0x0e, 0x13, 0xfe, 0x0e,
11623 0x90, 0xa3, 0xfe, 0x3c,
11624 0x90, 0xfe, 0x30, 0xf4, 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82,
11625 0x16, 0x2f, 0x07, 0x2d,
11626 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
11627 0xe8, 0x11, 0xfe, 0xe9,
11628 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01, 0xfe, 0x14, 0x16, 0xfe,
11629 0x1e, 0x1c, 0xfe, 0x14,
11630 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01,
11631 0x09, 0x04, 0x4f, 0xfe,
11632 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
11633 0x40, 0x12, 0x20, 0x63,
11634 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x03, 0xfe, 0x08,
11635 0x1c, 0x05, 0xfe, 0xac,
11636 0x00, 0xfe, 0x06, 0x58, 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05,
11637 0xfe, 0xb0, 0x00, 0xfe,
11638 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
11639 0x24, 0x69, 0x12, 0xc9,
11640 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48, 0x5f, 0x17, 0x1d, 0xfe,
11641 0x90, 0x4d, 0xfe, 0x91,
11642 0x54, 0x21, 0xfe, 0x08, 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c,
11643 0xfe, 0x90, 0x4d, 0xfe,
11644 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
11645 0x46, 0x1e, 0x20, 0xed,
11646 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x32, 0x0f, 0xea,
11647 0x70, 0xfe, 0x14, 0x1c,
11648 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee,
11649 0xfe, 0x07, 0xe6, 0x1d,
11650 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
11651 0xfa, 0xef, 0xfe, 0x42,
11652 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a, 0x42, 0x01, 0x0e, 0xb0,
11653 0xfe, 0x36, 0x12, 0xf0,
11654 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
11655 0x3d, 0x75, 0x07, 0x10,
11656 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
11657 0x10, 0x07, 0x7e, 0x45,
11658 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03, 0xfe, 0x44, 0x58, 0x74,
11659 0xfe, 0x01, 0xec, 0x97,
11660 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76,
11661 0x27, 0x01, 0xda, 0xfe,
11662 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
11663 0xfe, 0x48, 0x12, 0x07,
11664 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30, 0x12, 0x07, 0xc2, 0x16,
11665 0xfe, 0x3e, 0x11, 0x07,
11666 0xfe, 0x23, 0x00, 0x16, 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8,
11667 0x11, 0x07, 0x19, 0xfe,
11668 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
11669 0x01, 0x08, 0x8c, 0x43,
11670 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01, 0xfe, 0x32, 0x0e, 0x11,
11671 0x7e, 0x02, 0x29, 0x2b,
11672 0x2f, 0x07, 0x9b, 0xfe, 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe,
11673 0xfc, 0x10, 0x09, 0x04,
11674 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
11675 0xc6, 0x10, 0x1e, 0x58,
11676 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77, 0xfe, 0x82, 0x0c, 0x0c,
11677 0x54, 0x18, 0x55, 0x23,
11678 0x0c, 0x7b, 0x0c, 0x7c, 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01,
11679 0xa5, 0xc0, 0x38, 0xc1,
11680 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
11681 0x05, 0xfa, 0x4e, 0xfe,
11682 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56,
11683 0x0c, 0x56, 0x18, 0x57,
11684 0x83, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe,
11685 0x00, 0x56, 0xfe, 0xa1,
11686 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
11687 0x58, 0xfe, 0x1f, 0x40,
11688 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x05, 0x56,
11689 0x31, 0x57, 0xfe, 0x44,
11690 0x50, 0xfe, 0xc6, 0x50, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe,
11691 0x8a, 0x50, 0x05, 0x39,
11692 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
11693 0x12, 0xcd, 0x02, 0x5b,
11694 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5, 0x07, 0x06, 0x21, 0x44,
11695 0x2f, 0x07, 0x9b, 0x21,
11696 0x5b, 0x01, 0x6e, 0x1c, 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79,
11697 0x39, 0x68, 0x3a, 0xfe,
11698 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
11699 0x51, 0xfe, 0x8e, 0x51,
11700 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19, 0x41, 0x02, 0x5b, 0x2b,
11701 0x01, 0x08, 0x25, 0x32,
11702 0x1f, 0xa2, 0x30, 0x2e, 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b,
11703 0x3b, 0x02, 0x44, 0x01,
11704 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
11705 0x01, 0x08, 0x1f, 0xa2,
11706 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x60, 0x05, 0xfe, 0x9c,
11707 0x00, 0x28, 0x84, 0x49,
11708 0x04, 0x19, 0x34, 0x9f, 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06,
11709 0x78, 0x3d, 0xfe, 0xda,
11710 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
11711 0x05, 0xc6, 0x28, 0x84,
11712 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8,
11713 0x14, 0xfe, 0x03, 0x17,
11714 0x05, 0x50, 0xb4, 0x0c, 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01,
11715 0xfe, 0xaa, 0x14, 0x02,
11716 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
11717 0x21, 0x44, 0x01, 0xfe,
11718 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14, 0xfe, 0xa4, 0x14, 0x87,
11719 0xfe, 0x4a, 0xf4, 0x0b,
11720 0x16, 0x44, 0xfe, 0x4a, 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a,
11721 0x85, 0x02, 0x5b, 0x05,
11722 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
11723 0xd8, 0x14, 0x02, 0x5c,
11724 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe, 0xe0, 0x12, 0x72, 0xf1,
11725 0x01, 0x08, 0x23, 0x72,
11726 0x03, 0x8f, 0xfe, 0xdc, 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca,
11727 0x12, 0x5e, 0x2b, 0x01,
11728 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
11729 0x1c, 0xfe, 0xff, 0x7f,
11730 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00,
11731 0x57, 0x48, 0x8b, 0x1c,
11732 0x3d, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02,
11733 0x00, 0x57, 0x48, 0x8b,
11734 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
11735 0x03, 0x0a, 0x50, 0x01,
11736 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c, 0x10, 0xff, 0x03, 0x00,
11737 0x54, 0xfe, 0x00, 0xf4,
11738 0x19, 0x48, 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe,
11739 0x03, 0x7c, 0x63, 0x27,
11740 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
11741 0xfe, 0x82, 0x4a, 0xfe,
11742 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01, 0xfe, 0x14, 0x18, 0xfe,
11743 0x42, 0x48, 0x5f, 0x60,
11744 0x89, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08,
11745 0x1f, 0xfe, 0xa2, 0x14,
11746 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
11747 0xcc, 0x12, 0x49, 0x04,
11748 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2, 0x4b, 0xc3, 0x64, 0xfe,
11749 0xe8, 0x13, 0x3b, 0x13,
11750 0x06, 0x17, 0xc3, 0x78, 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55,
11751 0xa1, 0xff, 0x02, 0x83,
11752 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
11753 0x13, 0x06, 0xfe, 0x56,
11754 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00, 0x8e, 0xe4, 0x0a, 0xfe,
11755 0x64, 0x00, 0x17, 0x93,
11756 0x13, 0x06, 0xfe, 0x28, 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe,
11757 0xc8, 0x00, 0x8e, 0xe4,
11758 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
11759 0x01, 0xba, 0xfe, 0x4e,
11760 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4, 0x94, 0xfe, 0x56, 0xf0,
11761 0xfe, 0x60, 0x14, 0xfe,
11762 0x04, 0xf4, 0x6c, 0xfe, 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01,
11763 0xfe, 0x22, 0x13, 0x1c,
11764 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
11765 0xfe, 0x9c, 0x14, 0xb7,
11766 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x19, 0xba,
11767 0xfe, 0x9c, 0x14, 0xb7,
11768 0x19, 0x83, 0x60, 0x23, 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06,
11769 0xfe, 0xb4, 0x56, 0xfe,
11770 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
11771 0xe5, 0x15, 0x0b, 0x01,
11772 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xe5, 0x72, 0xfe, 0x89,
11773 0x49, 0x01, 0x08, 0x03,
11774 0x15, 0x06, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6,
11775 0x15, 0x06, 0x01, 0x08,
11776 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
11777 0x4a, 0x01, 0x08, 0x03,
11778 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44, 0x13, 0xad, 0x12, 0xcc,
11779 0xfe, 0x49, 0xf4, 0x00,
11780 0x3b, 0x72, 0x9f, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01,
11781 0x08, 0x2f, 0x07, 0xfe,
11782 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
11783 0x01, 0x43, 0x1e, 0xcd,
11784 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03, 0x0a, 0x42, 0x01, 0x0e,
11785 0xed, 0x88, 0x07, 0x10,
11786 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a,
11787 0x80, 0x01, 0x0e, 0x88,
11788 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
11789 0x88, 0x03, 0x0a, 0x42,
11790 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x42, 0x01, 0x0e,
11791 0xfe, 0x80, 0x80, 0xf2,
11792 0xfe, 0x49, 0xe4, 0x10, 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51,
11793 0x01, 0x82, 0x03, 0x17,
11794 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
11795 0xfe, 0x24, 0x1c, 0xfe,
11796 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01, 0xfe, 0xfc, 0x16, 0xe0,
11797 0x91, 0x1d, 0x66, 0xfe,
11798 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe,
11799 0xda, 0x10, 0x17, 0x10,
11800 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
11801 0x05, 0xfe, 0x66, 0x01,
11802 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06,
11803 0xfe, 0x3c, 0x50, 0x66,
11804 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe,
11805 0x40, 0x16, 0xfe, 0xb6,
11806 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
11807 0x10, 0x71, 0xfe, 0x83,
11808 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x38, 0x90,
11809 0xfe, 0x62, 0x16, 0xfe,
11810 0x94, 0x14, 0xfe, 0x10, 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19,
11811 0xfe, 0x98, 0xe7, 0x00,
11812 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
11813 0xfe, 0x30, 0xbc, 0xfe,
11814 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
11815 0xc5, 0x90, 0xfe, 0x9a,
11816 0x16, 0xfe, 0x5c, 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe,
11817 0x42, 0x10, 0xfe, 0x02,
11818 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
11819 0xfe, 0x1d, 0xf7, 0x4f,
11820 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x91, 0x4f,
11821 0x47, 0xfe, 0x83, 0x58,
11822 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11,
11823 0xfe, 0xdd, 0x00, 0x63,
11824 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
11825 0x06, 0x37, 0x95, 0xa9,
11826 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17, 0x23, 0x03, 0xfe, 0x7e,
11827 0x18, 0x1c, 0x1a, 0x5d,
11828 0x13, 0x0d, 0x03, 0x71, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe,
11829 0xe1, 0x10, 0x78, 0x2c,
11830 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
11831 0x13, 0x3c, 0x8a, 0x0a,
11832 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
11833 0xe3, 0xfe, 0x00, 0xcc,
11834 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01,
11835 0x0e, 0xf2, 0x01, 0x6f,
11836 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
11837 0xf6, 0xfe, 0xd6, 0xf0,
11838 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c, 0xe7, 0x0b, 0x0f, 0xfe,
11839 0x15, 0x00, 0x59, 0x76,
11840 0x27, 0x01, 0xda, 0x17, 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35,
11841 0x11, 0x2d, 0x01, 0x6f,
11842 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
11843 0xc8, 0xfe, 0x48, 0x55,
11844 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73, 0x12, 0x98, 0x03, 0x0a,
11845 0x99, 0x01, 0x0e, 0xf0,
11846 0x0a, 0x40, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73,
11847 0x75, 0x03, 0x0a, 0x42,
11848 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
11849 0x0e, 0x73, 0x75, 0x03,
11850 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18, 0x05, 0xfe, 0x90, 0x00,
11851 0xfe, 0x3a, 0x45, 0x5b,
11852 0xfe, 0x4e, 0xe4, 0xc2, 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00,
11853 0xfe, 0x02, 0xe6, 0x1b,
11854 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
11855 0xfe, 0x94, 0x00, 0xfe,
11856 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe, 0x96, 0x00, 0xfe, 0x02,
11857 0xe6, 0x2c, 0xfe, 0x4e,
11858 0x45, 0xfe, 0x0c, 0x12, 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69,
11859 0x03, 0x07, 0x7a, 0xfe,
11860 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
11861 0x07, 0x1b, 0xfe, 0x5a,
11862 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26, 0x10, 0x07, 0x1a, 0x5d,
11863 0x24, 0x2c, 0xdc, 0x07,
11864 0x0b, 0x5d, 0x24, 0x93, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d,
11865 0x9f, 0xad, 0x03, 0x14,
11866 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
11867 0x03, 0x25, 0xfe, 0xca,
11868 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6, 0x18, 0x03, 0xff, 0x1a,
11872 static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
11873 static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
11875 /* Microcode buffer is kept after initialization for error recovery. */
11876 static unsigned char _adv_asc38C0800_buf[] = {
11877 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
11878 0x01, 0x00, 0x48, 0xe4,
11879 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19, 0x00, 0xfa, 0xff, 0xff,
11880 0x1c, 0x0f, 0x00, 0xf6,
11881 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6,
11882 0x09, 0xe7, 0x55, 0xf0,
11883 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
11884 0x18, 0xf4, 0x08, 0x00,
11885 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0, 0x82, 0x0d, 0x00, 0xe6,
11886 0x86, 0xf0, 0xb1, 0xf0,
11887 0x98, 0x57, 0x01, 0xfc, 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c,
11888 0x3c, 0x00, 0xbb, 0x00,
11889 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
11890 0xba, 0x13, 0x18, 0x40,
11891 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc, 0x3e, 0x00, 0x6c, 0x01,
11892 0x6e, 0x01, 0x74, 0x01,
11893 0x76, 0x01, 0xb9, 0x54, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00,
11894 0xc0, 0x00, 0x01, 0x01,
11895 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
11896 0x08, 0x12, 0x02, 0x4a,
11897 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4,
11898 0x5d, 0xf0, 0x02, 0xfa,
11899 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01,
11900 0x68, 0x01, 0x6a, 0x01,
11901 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
11902 0x06, 0x13, 0x4c, 0x1c,
11903 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x0c, 0x00,
11904 0x0f, 0x00, 0x47, 0x00,
11905 0xbe, 0x00, 0x00, 0x01, 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c,
11906 0x4e, 0x1c, 0x10, 0x44,
11907 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
11908 0x05, 0x00, 0x34, 0x00,
11909 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4a, 0x0b,
11910 0x42, 0x0c, 0x12, 0x0f,
11911 0x0c, 0x10, 0x22, 0x11, 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48,
11912 0x00, 0x4e, 0x42, 0x54,
11913 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
11914 0x59, 0xf0, 0xb8, 0xf0,
11915 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc, 0x05, 0xfc, 0x06, 0x00,
11916 0x19, 0x00, 0x33, 0x00,
11917 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00,
11918 0xe7, 0x00, 0xe2, 0x03,
11919 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
11920 0x12, 0x13, 0x24, 0x14,
11921 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17, 0x20, 0x1c, 0x34, 0x1c,
11922 0x36, 0x1c, 0x08, 0x44,
11923 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54,
11924 0x3a, 0x55, 0x83, 0x55,
11925 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
11926 0x0c, 0xf0, 0x04, 0xf8,
11927 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x9e, 0x00,
11928 0xa8, 0x00, 0xaa, 0x00,
11929 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01,
11930 0xc4, 0x01, 0xc6, 0x01,
11931 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
11932 0x68, 0x08, 0x69, 0x08,
11933 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f, 0x12, 0x10, 0x1a, 0x10,
11934 0xed, 0x10, 0xf1, 0x10,
11935 0x2a, 0x11, 0x06, 0x12, 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13,
11936 0x1e, 0x13, 0x46, 0x14,
11937 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
11938 0xca, 0x18, 0xe6, 0x19,
11939 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0xfe, 0x9c,
11940 0xf0, 0x2b, 0x02, 0xfe,
11941 0xac, 0x0d, 0xff, 0x10, 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6,
11942 0xfe, 0x84, 0x01, 0xff,
11943 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
11944 0x00, 0xfe, 0x57, 0x24,
11945 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00, 0x00, 0x11, 0xff, 0x09,
11946 0x00, 0x00, 0xff, 0x08,
11947 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
11948 0xff, 0xff, 0xff, 0x11,
11949 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
11950 0xfe, 0x04, 0xf7, 0xd6,
11951 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe, 0x04, 0xf7, 0xd6, 0x99,
11952 0x0a, 0x42, 0x2c, 0xfe,
11953 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0,
11954 0xfe, 0xf4, 0x01, 0xfe,
11955 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
11956 0x02, 0xfe, 0xc8, 0x0d,
11957 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28,
11958 0x1c, 0x03, 0xfe, 0xa6,
11959 0x00, 0xfe, 0xd3, 0x12, 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48,
11960 0xf0, 0xfe, 0x8a, 0x02,
11961 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
11962 0xfe, 0x46, 0xf0, 0xfe,
11963 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x43, 0xf0, 0xfe,
11964 0x48, 0x02, 0xfe, 0x44,
11965 0xf0, 0xfe, 0x4c, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a,
11966 0xaa, 0x18, 0x06, 0x14,
11967 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
11968 0x1e, 0x1c, 0xfe, 0xe9,
11969 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xce,
11970 0x09, 0x70, 0x01, 0xa8,
11971 0x02, 0x2b, 0x15, 0x59, 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70,
11972 0x01, 0x87, 0xfe, 0xbd,
11973 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
11974 0x58, 0x1c, 0x18, 0x06,
11975 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0x23,
11976 0xfe, 0x98, 0x02, 0xfe,
11977 0x5a, 0x1c, 0xf8, 0xfe, 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2,
11978 0x01, 0xfe, 0x48, 0x10,
11979 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
11980 0x69, 0x10, 0x18, 0x06,
11981 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43, 0x13, 0x20, 0xfe, 0x05,
11982 0xf6, 0xce, 0x01, 0xfe,
11983 0x4a, 0x17, 0x08, 0x54, 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe,
11984 0x82, 0x16, 0x02, 0x2b,
11985 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
11986 0xfe, 0x41, 0x58, 0x09,
11987 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe, 0x10, 0x03, 0x01, 0xfe,
11988 0x82, 0x16, 0x02, 0x2b,
11989 0x2c, 0x4f, 0xfe, 0x02, 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43,
11990 0xfe, 0x77, 0x57, 0xfe,
11991 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
11992 0xfe, 0x40, 0x1c, 0x1c,
11993 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x48,
11994 0x03, 0xfe, 0x11, 0xf0,
11995 0xa7, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10,
11996 0xfe, 0x11, 0x00, 0x02,
11997 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
11998 0x21, 0x22, 0xa3, 0xb7,
11999 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78, 0x01, 0xfe, 0xb4, 0x16,
12000 0x12, 0xd1, 0x1c, 0xd9,
12001 0xfe, 0x01, 0xf0, 0xd9, 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12,
12002 0xfe, 0xe4, 0x00, 0x27,
12003 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
12004 0x06, 0xf0, 0xfe, 0xc8,
12005 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a, 0x06, 0x02, 0x24, 0x03,
12006 0x70, 0x28, 0x17, 0xfe,
12007 0xfa, 0x04, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8,
12008 0xf9, 0x2c, 0x99, 0x19,
12009 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
12010 0x74, 0x01, 0xaf, 0x8c,
12011 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda, 0x09, 0xd1, 0x01, 0x0e,
12012 0x8d, 0x51, 0x64, 0x79,
12013 0x2a, 0x03, 0x70, 0x28, 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b,
12014 0xfe, 0x6a, 0x02, 0x02,
12015 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
12016 0xfe, 0x3c, 0x04, 0x3b,
12017 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2d, 0xff, 0x02,
12018 0x00, 0x10, 0x01, 0x0b,
12019 0x1d, 0xfe, 0xe4, 0x04, 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde,
12020 0xfe, 0x4c, 0x44, 0xfe,
12021 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
12022 0xda, 0x4f, 0x79, 0x2a,
12023 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62, 0x13, 0x08, 0x05, 0x1b,
12024 0xfe, 0x2a, 0x13, 0x32,
12025 0x07, 0x82, 0xfe, 0x52, 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c,
12026 0x54, 0x6b, 0xda, 0xfe,
12027 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
12028 0x08, 0x13, 0x32, 0x07,
12029 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x1c, 0x12, 0x15, 0x9d,
12030 0x08, 0x05, 0x06, 0x4d,
12031 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24,
12032 0x2d, 0x12, 0xfe, 0xe6,
12033 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
12034 0x02, 0x2b, 0xfe, 0x42,
12035 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57,
12036 0xfe, 0x87, 0x80, 0xfe,
12037 0x31, 0xe4, 0x5b, 0x08, 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80,
12038 0x07, 0x19, 0xfe, 0x7c,
12039 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
12040 0x17, 0xfe, 0x90, 0x05,
12041 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe, 0x56, 0x13, 0x03, 0xfe,
12042 0xa0, 0x00, 0x28, 0xfe,
12043 0x4e, 0x12, 0x67, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c,
12044 0x34, 0xfe, 0x89, 0x48,
12045 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
12046 0x12, 0xfe, 0xe3, 0x00,
12047 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05, 0xfe, 0x49, 0xf0, 0xfe,
12048 0x70, 0x05, 0x88, 0x25,
12049 0xfe, 0x21, 0x00, 0xab, 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe,
12050 0x09, 0x48, 0xff, 0x02,
12051 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
12052 0x08, 0x53, 0x05, 0xcb,
12053 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39, 0xfe, 0x27, 0x01, 0x08,
12054 0x05, 0x1b, 0xfe, 0x22,
12055 0x12, 0x41, 0x01, 0xb2, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe,
12056 0x0d, 0x00, 0x01, 0x36,
12057 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
12058 0x03, 0x5c, 0x28, 0xfe,
12059 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18, 0x06, 0x09, 0x06, 0x53,
12060 0x05, 0x1f, 0xfe, 0x02,
12061 0x12, 0x50, 0x01, 0xfe, 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5,
12062 0x01, 0x4b, 0x12, 0xfe,
12063 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
12064 0x12, 0x03, 0x45, 0x28,
12065 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01, 0xfe, 0x76, 0x19, 0xfe,
12066 0x43, 0x48, 0xc4, 0xcc,
12067 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4,
12068 0x6e, 0x41, 0x01, 0xb2,
12069 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
12070 0xfe, 0xcc, 0x15, 0x1d,
12071 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe, 0xe5, 0x00, 0x03,
12072 0x45, 0xc1, 0x0c, 0x45,
12073 0x18, 0x06, 0x01, 0xb2, 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe,
12074 0xe2, 0x00, 0x27, 0xdb,
12075 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
12076 0xfe, 0x06, 0xf0, 0xfe,
12077 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05, 0x0a, 0xfe, 0x2e, 0x12,
12078 0x16, 0x19, 0x01, 0x0b,
12079 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
12080 0xfe, 0x99, 0xa4, 0x01,
12081 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
12082 0x12, 0x08, 0x05, 0x1a,
12083 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
12084 0x0b, 0x16, 0x00, 0x01,
12085 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02,
12086 0xe2, 0x6c, 0x58, 0xbe,
12087 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
12088 0xfe, 0x09, 0x6f, 0xba,
12089 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d, 0x8b, 0x6c, 0x7f, 0x27,
12090 0xfe, 0x54, 0x07, 0x1c,
12091 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c,
12092 0x07, 0x02, 0x24, 0x01,
12093 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
12094 0x2c, 0x90, 0xfe, 0xae,
12095 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x54, 0x5a,
12096 0x37, 0x22, 0x20, 0x07,
12097 0x11, 0xfe, 0x0e, 0x12, 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a,
12098 0xfe, 0x06, 0x10, 0xfe,
12099 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
12100 0x37, 0x01, 0xb3, 0xb8,
12101 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe, 0x08, 0x50, 0xfe, 0x8a,
12102 0x50, 0xfe, 0x44, 0x51,
12103 0xfe, 0xc6, 0x51, 0x88, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e,
12104 0x14, 0x5f, 0xfe, 0x0c,
12105 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
12106 0x14, 0x3e, 0xfe, 0x4a,
12107 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
12108 0x90, 0x0c, 0x60, 0x14,
12109 0x61, 0x08, 0x05, 0x5b, 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62,
12110 0xfe, 0x44, 0x90, 0xfe,
12111 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
12112 0x0c, 0x5e, 0x14, 0x5f,
12113 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d, 0x14, 0x3e, 0x0c, 0x2e,
12114 0x14, 0x3c, 0x21, 0x0c,
12115 0x49, 0x0c, 0x63, 0x08, 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11,
12116 0x27, 0xdd, 0xfe, 0x9e,
12117 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
12118 0x9a, 0x08, 0xc6, 0xfe,
12119 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x94, 0x08,
12120 0x95, 0x86, 0x02, 0x24,
12121 0x01, 0x4b, 0xfe, 0xc9, 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05,
12122 0x06, 0xfe, 0x10, 0x12,
12123 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
12124 0x1c, 0x02, 0xfe, 0x18,
12125 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a, 0xfe, 0x7a, 0x12, 0xfe,
12126 0x2c, 0x1c, 0xfe, 0xaa,
12127 0xf0, 0xfe, 0xd2, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe,
12128 0xde, 0x09, 0xfe, 0xb7,
12129 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
12130 0xfe, 0xf1, 0x18, 0xfe,
12131 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe,
12132 0x14, 0x59, 0xfe, 0x95,
12133 0x59, 0x1c, 0x85, 0xfe, 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0,
12134 0xfe, 0xf0, 0x08, 0xb5,
12135 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
12136 0x0b, 0xb6, 0xfe, 0xbf,
12137 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe, 0x00, 0xfe, 0xfe, 0x1c,
12138 0x12, 0xc2, 0xfe, 0xd2,
12139 0xf0, 0x85, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e,
12140 0x06, 0x17, 0x85, 0xc5,
12141 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
12142 0x9d, 0x01, 0x36, 0x10,
12143 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10, 0x80, 0x02, 0x65, 0xfe,
12144 0x98, 0x80, 0xfe, 0x19,
12145 0xe4, 0x0a, 0xfe, 0x1a, 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18,
12146 0xfe, 0x44, 0x54, 0xbe,
12147 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
12148 0x02, 0x4a, 0x08, 0x05,
12149 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f, 0x14, 0x40, 0x9b, 0x2e,
12150 0x9c, 0x3c, 0xfe, 0x6c,
12151 0x18, 0xfe, 0xed, 0x18, 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f,
12152 0x3b, 0x40, 0x03, 0x49,
12153 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
12154 0x8f, 0xfe, 0xe3, 0x54,
12155 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0xfe, 0x37, 0xf0, 0xfe,
12156 0xda, 0x09, 0xfe, 0x8b,
12157 0xf0, 0xfe, 0x60, 0x09, 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa,
12158 0x0a, 0x3a, 0x49, 0x3b,
12159 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
12160 0xad, 0xfe, 0x01, 0x59,
12161 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a, 0xfe, 0x24, 0x0a, 0x3a,
12162 0x49, 0x8f, 0xfe, 0xe3,
12163 0x54, 0x57, 0x49, 0x7d, 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02,
12164 0x4a, 0x3a, 0x49, 0x3b,
12165 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
12166 0x02, 0x4a, 0x08, 0x05,
12167 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe, 0x66, 0x13, 0x22, 0x62,
12168 0xb7, 0xfe, 0x03, 0xa1,
12169 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
12170 0xfe, 0x86, 0x91, 0x6a,
12171 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
12172 0x61, 0x0c, 0x7f, 0x14,
12173 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8, 0x6a, 0x2a, 0x13, 0x62,
12174 0x9b, 0x2e, 0x9c, 0x3c,
12175 0x3a, 0x3f, 0x3b, 0x40, 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05,
12176 0xfa, 0x3c, 0x01, 0xef,
12177 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
12178 0xe4, 0x08, 0x05, 0x1f,
12179 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37,
12180 0x03, 0x5e, 0x29, 0x5f,
12181 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe,
12182 0xf4, 0x09, 0x08, 0x05,
12183 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
12184 0x81, 0x50, 0xfe, 0x10,
12185 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32, 0x07, 0xa6, 0x17, 0xfe,
12186 0x08, 0x09, 0x12, 0xa6,
12187 0x08, 0x05, 0x0a, 0xfe, 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe,
12188 0x08, 0x09, 0xfe, 0x0c,
12189 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
12190 0x08, 0x05, 0x0a, 0xfe,
12191 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xf4, 0xc2, 0xfe, 0xd1,
12192 0xf0, 0xe2, 0x15, 0x7e,
12193 0x01, 0x36, 0x10, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19,
12194 0x57, 0x3d, 0xfe, 0xed,
12195 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
12196 0x00, 0xff, 0x35, 0xfe,
12197 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6, 0x0b, 0xfe, 0x76, 0x18,
12198 0x1e, 0x19, 0x8a, 0x03,
12199 0xd2, 0x1e, 0x06, 0xfe, 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65,
12200 0xfe, 0xd1, 0xf0, 0xfe,
12201 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
12202 0x10, 0xfe, 0xce, 0xf0,
12203 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xca, 0x0b,
12204 0x10, 0xfe, 0x22, 0x00,
12205 0x02, 0x65, 0xfe, 0xcb, 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00,
12206 0x02, 0x65, 0xfe, 0xd0,
12207 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
12208 0x0b, 0x10, 0x58, 0xfe,
12209 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05, 0x1f, 0x4d, 0x10, 0xfe,
12210 0x12, 0x00, 0x2c, 0x0f,
12211 0xfe, 0x4e, 0x11, 0x27, 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14,
12212 0x0c, 0xbc, 0x17, 0x34,
12213 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
12214 0x0c, 0x1c, 0x34, 0x94,
12215 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6, 0xdc, 0x02, 0x24, 0x01,
12216 0x4b, 0xfe, 0xdb, 0x10,
12217 0x12, 0xfe, 0xe8, 0x00, 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe,
12218 0x89, 0xf0, 0x24, 0x33,
12219 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
12220 0x33, 0x31, 0xdf, 0xbc,
12221 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c, 0x06, 0xfe, 0x81, 0x49,
12222 0x17, 0xfe, 0x2c, 0x0d,
12223 0x08, 0x05, 0x0a, 0xfe, 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54,
12224 0x12, 0x55, 0xfe, 0x28,
12225 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
12226 0x44, 0xfe, 0x28, 0x00,
12227 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09, 0xa4, 0x01, 0xfe, 0x26,
12228 0x0f, 0x64, 0x12, 0x2f,
12229 0x01, 0x73, 0x02, 0x2b, 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44,
12230 0x0a, 0xfe, 0xb4, 0x10,
12231 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
12232 0xfe, 0x34, 0x46, 0xac,
12233 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96, 0x10, 0x08, 0x54, 0x0a,
12234 0x37, 0x01, 0xf5, 0x01,
12235 0xf6, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02,
12236 0xfe, 0x2e, 0x03, 0x08,
12237 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
12238 0x1a, 0xfe, 0x58, 0x12,
12239 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
12240 0xfe, 0x50, 0x0d, 0xfe,
12241 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37,
12242 0xfe, 0xa9, 0x10, 0x10,
12243 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
12244 0xfe, 0x13, 0x00, 0xfe,
12245 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41, 0x00, 0xaa, 0x10, 0xfe,
12246 0x24, 0x00, 0x8c, 0xb5,
12247 0xb6, 0x74, 0x03, 0x70, 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a,
12248 0xfe, 0x9d, 0x41, 0xfe,
12249 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
12250 0xb4, 0x15, 0xfe, 0x31,
12251 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02, 0xd7, 0x42, 0xfe, 0x06,
12252 0xec, 0xd0, 0xfc, 0x44,
12253 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47,
12254 0x4b, 0x91, 0xfe, 0x75,
12255 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
12256 0x0e, 0xfe, 0x44, 0x48,
12257 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09, 0x46, 0x01, 0x0e, 0x41,
12258 0xfe, 0x41, 0x58, 0x09,
12259 0xa4, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe,
12260 0x2e, 0x03, 0x09, 0x5d,
12261 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
12262 0xce, 0x47, 0xfe, 0xad,
12263 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x9e, 0x12, 0x21, 0x13,
12264 0x59, 0x13, 0x9f, 0x13,
12265 0xd5, 0x22, 0x2f, 0x41, 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe,
12266 0xe0, 0x0e, 0x0f, 0x06,
12267 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
12268 0x3a, 0x01, 0x56, 0xfe,
12269 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00, 0x66, 0xfe, 0x04, 0xec,
12270 0x20, 0x4f, 0xfe, 0x05,
12271 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe,
12272 0x48, 0xf4, 0x0d, 0xfe,
12273 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
12274 0x15, 0x1a, 0x39, 0xa0,
12275 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x1e, 0xfe, 0xf0, 0xff,
12276 0x0c, 0xfe, 0x60, 0x01,
12277 0x03, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25,
12278 0x06, 0x13, 0x2f, 0x12,
12279 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
12280 0x22, 0x9f, 0xb7, 0x13,
12281 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24, 0x1c, 0x15, 0x19, 0x39,
12282 0xa0, 0xb4, 0xfe, 0xd9,
12283 0x10, 0xc3, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04,
12284 0xc3, 0xfe, 0x03, 0xdc,
12285 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
12286 0xfe, 0x00, 0xcc, 0x04,
12287 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05, 0x58, 0xfe, 0x22, 0x13,
12288 0xfe, 0x1c, 0x80, 0x07,
12289 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae,
12290 0xfe, 0x0c, 0x90, 0xfe,
12291 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
12292 0x0a, 0xfe, 0x3c, 0x50,
12293 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f, 0xad, 0x01, 0xfe, 0xb4,
12294 0x16, 0x08, 0x05, 0x1b,
12295 0x4e, 0x01, 0xf5, 0x01, 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58,
12296 0xfe, 0x2c, 0x13, 0x01,
12297 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
12298 0x0c, 0xfe, 0x64, 0x01,
12299 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe, 0x12, 0x12, 0xfe, 0x03,
12300 0x80, 0x8d, 0xfe, 0x01,
12301 0xec, 0x20, 0xfe, 0x80, 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64,
12302 0x22, 0x20, 0xfb, 0x79,
12303 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
12304 0x03, 0xfe, 0xae, 0x00,
12306 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe,
12307 0xb2, 0x00, 0xfe, 0x09,
12308 0x58, 0xfe, 0x0a, 0x1c, 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c,
12309 0x45, 0x0f, 0x46, 0x52,
12310 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
12311 0x0f, 0x44, 0x11, 0x0f,
12312 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xe4,
12313 0x25, 0x11, 0x13, 0x20,
12314 0x7c, 0x6f, 0x4f, 0x22, 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14,
12315 0x56, 0xfe, 0xd6, 0xf0,
12316 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
12317 0x18, 0x1c, 0x04, 0x42,
12318 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b, 0xfe, 0xce, 0x47, 0xfe,
12319 0xf5, 0x13, 0x04, 0x01,
12320 0xb0, 0x7c, 0x6f, 0x4f, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
12321 0x13, 0x32, 0x07, 0x2f,
12322 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
12323 0x41, 0x48, 0xfe, 0x45,
12324 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78,
12325 0x07, 0x11, 0xac, 0x09,
12326 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07,
12327 0x82, 0x4e, 0xfe, 0x14,
12328 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
12329 0xfe, 0x01, 0xec, 0xa2,
12330 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1a, 0x79,
12331 0x2a, 0x01, 0xe3, 0xfe,
12332 0xdd, 0x10, 0x2c, 0xc7, 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a,
12333 0xfe, 0x48, 0x12, 0x07,
12334 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
12335 0xfe, 0x32, 0x12, 0x07,
12336 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17, 0xfe, 0x9c, 0x12, 0x07,
12337 0x1f, 0xfe, 0x12, 0x12,
12338 0x07, 0x00, 0x17, 0x24, 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b,
12339 0x94, 0x4b, 0x04, 0x2d,
12340 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
12341 0x32, 0x07, 0xa6, 0xfe,
12342 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe, 0xf0, 0x11, 0x08, 0x05,
12343 0x5a, 0xfe, 0x72, 0x12,
12344 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62,
12345 0xfe, 0x26, 0x13, 0x03,
12346 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
12347 0x0c, 0x7f, 0x0c, 0x80,
12348 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01, 0xef, 0x9b, 0x2e, 0x9c,
12349 0x3c, 0xfe, 0x04, 0x55,
12350 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe,
12351 0x91, 0x10, 0x03, 0x3f,
12352 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
12353 0x88, 0x9b, 0x2e, 0x9c,
12354 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
12355 0x56, 0x0c, 0x5e, 0x14,
12356 0x5f, 0x08, 0x05, 0x5a, 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40,
12357 0x03, 0x60, 0x29, 0x61,
12358 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
12359 0x50, 0xfe, 0xc6, 0x50,
12360 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x3d,
12361 0x29, 0x3e, 0xfe, 0x40,
12362 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72,
12363 0x2d, 0x01, 0x0b, 0x1d,
12364 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
12365 0x72, 0x01, 0xaf, 0x1e,
12366 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a, 0x3d, 0x3b, 0x3e, 0xfe,
12367 0x0a, 0x55, 0x35, 0xfe,
12368 0x8b, 0x55, 0x57, 0x3d, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51,
12369 0x02, 0x72, 0xfe, 0x19,
12370 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
12371 0x1d, 0xe8, 0x33, 0x31,
12372 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a, 0x4d, 0x02, 0x4c, 0x01,
12373 0x0b, 0x1c, 0x34, 0x1d,
12374 0xe8, 0x33, 0x31, 0xdf, 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8,
12375 0x33, 0x31, 0xfe, 0xe8,
12376 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
12377 0x05, 0x1f, 0x35, 0xa9,
12378 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06, 0x7c, 0x43, 0xfe, 0xda,
12379 0x14, 0x01, 0xaf, 0x8c,
12380 0xfe, 0x4b, 0x45, 0xee, 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a,
12381 0x03, 0x45, 0x28, 0x35,
12382 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
12383 0x03, 0x5c, 0xc1, 0x0c,
12384 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0x9e, 0x15, 0x02,
12385 0x89, 0x01, 0x0b, 0x1c,
12386 0x34, 0x1d, 0x4c, 0x33, 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1,
12387 0xfe, 0x42, 0x58, 0xf1,
12388 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
12389 0xf4, 0x06, 0xea, 0x32,
12390 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x67, 0x2d,
12391 0x01, 0x0b, 0x26, 0x89,
12392 0x01, 0xfe, 0xcc, 0x15, 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13,
12393 0x26, 0xfe, 0xd4, 0x13,
12394 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
12395 0x13, 0x1c, 0xfe, 0xd0,
12396 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01, 0x0b, 0xfe, 0xd5, 0x10,
12397 0x0f, 0x71, 0xff, 0x02,
12398 0x00, 0x57, 0x52, 0x93, 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe,
12399 0x00, 0x5c, 0x04, 0x0f,
12400 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
12401 0xfe, 0x00, 0x5c, 0x04,
12402 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x04, 0x0f, 0x71, 0xff,
12403 0x02, 0x00, 0x57, 0x52,
12404 0x93, 0xfe, 0x0b, 0x58, 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01,
12405 0x87, 0x04, 0xfe, 0x03,
12406 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
12407 0xfe, 0x00, 0x7d, 0xfe,
12408 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x6a, 0x2a, 0x0c, 0x5e,
12409 0x14, 0x5f, 0x57, 0x3f,
12410 0x7d, 0x40, 0x04, 0xdd, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83,
12411 0x5a, 0x8d, 0x04, 0x01,
12412 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
12413 0xfe, 0x96, 0x15, 0x33,
12414 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33, 0x31, 0xfe, 0xe8,
12415 0x0a, 0xfe, 0xc1, 0x59,
12416 0x03, 0xcd, 0x28, 0xfe, 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13,
12417 0x21, 0x69, 0x1a, 0xee,
12418 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
12419 0x30, 0xfe, 0x78, 0x10,
12420 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83, 0x55, 0x69, 0x19, 0xae,
12421 0x98, 0xfe, 0x30, 0x00,
12422 0x96, 0xf2, 0x18, 0x6d, 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed,
12423 0x98, 0xfe, 0x64, 0x00,
12424 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
12425 0x10, 0x69, 0x06, 0xfe,
12426 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2, 0x09, 0xfe, 0xc8, 0x00,
12427 0x18, 0x59, 0x0f, 0x06,
12428 0x88, 0x98, 0xfe, 0x90, 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe,
12429 0x43, 0xf4, 0x9f, 0xfe,
12430 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
12431 0x9e, 0xfe, 0xf3, 0x10,
12432 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e, 0x43, 0xec, 0xfe, 0x00,
12433 0x17, 0xfe, 0x4d, 0xe4,
12434 0x6e, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00,
12435 0x17, 0xfe, 0x4d, 0xe4,
12436 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
12437 0xf4, 0x00, 0xe9, 0x91,
12438 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x04, 0x51, 0x0f, 0x0a,
12439 0x04, 0x16, 0x06, 0x01,
12440 0x0b, 0x26, 0xf3, 0x16, 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01,
12441 0x0b, 0x26, 0xf3, 0x76,
12442 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
12443 0x16, 0x19, 0x01, 0x0b,
12444 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0xfe, 0x89, 0x49, 0x01,
12445 0x0b, 0x26, 0xb1, 0x76,
12446 0xfe, 0x89, 0x4a, 0x01, 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06,
12447 0xfe, 0x48, 0x13, 0xb8,
12448 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
12449 0xec, 0xfe, 0x27, 0x01,
12450 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x2e, 0x16, 0x32,
12451 0x07, 0xfe, 0xe3, 0x00,
12452 0xfe, 0x20, 0x13, 0x1d, 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b,
12453 0x22, 0xd4, 0x07, 0x06,
12454 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
12455 0x07, 0x11, 0xae, 0x09,
12456 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x84, 0x01,
12457 0x0e, 0x8e, 0xfe, 0x80,
12458 0xe7, 0x11, 0x07, 0x11, 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04,
12459 0x09, 0x48, 0x01, 0x0e,
12460 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
12461 0x80, 0xfe, 0x80, 0x4c,
12462 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c,
12463 0x09, 0x5d, 0x01, 0x87,
12464 0x04, 0x18, 0x11, 0x75, 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe,
12465 0x19, 0xde, 0xfe, 0x24,
12466 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
12467 0x17, 0xad, 0x9a, 0x1b,
12468 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04, 0xb9, 0x23, 0xfe, 0xde,
12469 0x16, 0xfe, 0xda, 0x10,
12470 0x18, 0x11, 0x75, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe,
12471 0x18, 0x58, 0x03, 0xfe,
12472 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
12473 0xf4, 0x06, 0xfe, 0x3c,
12474 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x1f,
12475 0x97, 0xfe, 0x38, 0x17,
12476 0xfe, 0xb6, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c,
12477 0x10, 0x18, 0x11, 0x75,
12478 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
12479 0x2e, 0x97, 0xfe, 0x5a,
12480 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c, 0x1a, 0xfe, 0xaf, 0x19,
12481 0xfe, 0x98, 0xe7, 0x00,
12482 0x04, 0xb9, 0x23, 0xfe, 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75,
12483 0xfe, 0x30, 0xbc, 0xfe,
12484 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
12485 0xcb, 0x97, 0xfe, 0x92,
12486 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x7e, 0x17, 0xfe,
12487 0x42, 0x10, 0xfe, 0x02,
12488 0xf6, 0x11, 0x75, 0xfe, 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe,
12489 0x03, 0xa1, 0xfe, 0x1d,
12490 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
12491 0x9a, 0x5b, 0x41, 0xfe,
12492 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x11, 0xfe, 0x81, 0xe7,
12493 0x11, 0x12, 0xfe, 0xdd,
12494 0x00, 0x6a, 0x2a, 0x04, 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8,
12495 0x17, 0x15, 0x06, 0x39,
12496 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
12497 0xfe, 0x7e, 0x18, 0x1e,
12498 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2, 0x1e, 0x06, 0xfe, 0xef,
12499 0x12, 0xfe, 0xe1, 0x10,
12500 0x7c, 0x6f, 0x4f, 0x32, 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42,
12501 0x13, 0x42, 0x92, 0x09,
12502 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
12503 0xf0, 0xfe, 0x00, 0xcc,
12504 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01,
12505 0x0e, 0xfe, 0x80, 0x4c,
12506 0x01, 0x73, 0xfe, 0x16, 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe,
12507 0x24, 0x12, 0xfe, 0x14,
12508 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
12509 0xe7, 0x0a, 0x10, 0xfe,
12510 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18, 0x06, 0x04, 0x42, 0x92,
12511 0x08, 0x54, 0x1b, 0x37,
12512 0x12, 0x2f, 0x01, 0x73, 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba,
12513 0x90, 0x3a, 0xce, 0x3b,
12514 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
12515 0x13, 0xa3, 0x04, 0x09,
12516 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46, 0x01, 0x0e, 0xfe, 0x49,
12517 0x44, 0x17, 0xfe, 0xe8,
12518 0x18, 0x77, 0x78, 0x04, 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09,
12519 0x5d, 0x01, 0xa8, 0x09,
12520 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
12521 0x1c, 0x19, 0x03, 0xfe,
12522 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xc9,
12523 0x6b, 0xfe, 0x2e, 0x19,
12524 0x03, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4,
12525 0xfe, 0x0b, 0x00, 0x6b,
12526 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
12527 0x08, 0x10, 0x03, 0xfe,
12528 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e, 0x45, 0xea, 0xba, 0xff,
12529 0x04, 0x68, 0x54, 0xe7,
12530 0x1e, 0x6e, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe,
12531 0x1a, 0xf4, 0xfe, 0x00,
12532 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
12533 0x04, 0x07, 0x7e, 0xfe,
12534 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
12535 0x07, 0x1a, 0xfe, 0x5a,
12536 0xf0, 0xfe, 0x92, 0x19, 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66,
12537 0x25, 0x6d, 0xe5, 0x07,
12538 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
12539 0xa9, 0xb8, 0x04, 0x15,
12540 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe, 0x81, 0x03, 0x83, 0xfe,
12541 0x40, 0x5c, 0x04, 0x1c,
12542 0xf7, 0xfe, 0x14, 0xf0, 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b,
12543 0xf7, 0xfe, 0x82, 0xf0,
12544 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
12547 static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
12548 static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
12550 /* Microcode buffer is kept after initialization for error recovery. */
12551 static unsigned char _adv_asc38C1600_buf[] = {
12552 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
12553 0x18, 0xe4, 0x01, 0x00,
12554 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13, 0x2e, 0x1e, 0x02, 0x00,
12555 0x07, 0x17, 0xc0, 0x5f,
12556 0x00, 0xfa, 0xff, 0xff, 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7,
12557 0x85, 0xf0, 0x86, 0xf0,
12558 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
12559 0x98, 0x57, 0x01, 0xe6,
12560 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4, 0x08, 0x00, 0xf0, 0x1d,
12561 0x38, 0x54, 0x32, 0xf0,
12562 0x10, 0x00, 0xc2, 0x0e, 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4,
12563 0x00, 0xe6, 0xb1, 0xf0,
12564 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
12565 0x06, 0x13, 0x0c, 0x1c,
12566 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc, 0xbc, 0x0e, 0xa2, 0x12,
12567 0xb9, 0x54, 0x00, 0x80,
12568 0x62, 0x0a, 0x5a, 0x12, 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56,
12569 0x03, 0xe6, 0x01, 0xea,
12570 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
12571 0x04, 0x13, 0xbb, 0x55,
12572 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4, 0x40, 0x00, 0xb6, 0x00,
12573 0xbb, 0x00, 0xc0, 0x00,
12574 0x00, 0x01, 0x01, 0x01, 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12,
12575 0x4c, 0x1c, 0x4e, 0x1c,
12576 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
12577 0x24, 0x01, 0x3c, 0x01,
12578 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01,
12579 0x78, 0x01, 0x7c, 0x01,
12580 0xc6, 0x0e, 0x0c, 0x10, 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c,
12581 0x6e, 0x1e, 0x02, 0x48,
12582 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
12583 0x03, 0xfc, 0x06, 0x00,
12584 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12, 0x18, 0x1a, 0x70, 0x1a,
12585 0x30, 0x1c, 0x38, 0x1c,
12586 0x10, 0x44, 0x00, 0x4c, 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea,
12587 0x5d, 0xf0, 0xa7, 0xf0,
12588 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
12589 0x33, 0x00, 0x34, 0x00,
12590 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01,
12591 0x79, 0x01, 0x3c, 0x09,
12592 0x68, 0x0d, 0x02, 0x10, 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13,
12593 0x40, 0x16, 0x50, 0x16,
12594 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
12595 0x05, 0xf0, 0x09, 0xf0,
12596 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7, 0x0a, 0x00, 0x9b, 0x00,
12597 0x9c, 0x00, 0xa4, 0x00,
12598 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08,
12599 0xe9, 0x09, 0x5c, 0x0c,
12600 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
12601 0x42, 0x1d, 0x08, 0x44,
12602 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x89, 0x48, 0x68, 0x54,
12603 0x83, 0x55, 0x83, 0x59,
12604 0x31, 0xe4, 0x02, 0xe6, 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0,
12605 0x4b, 0xf4, 0x04, 0xf8,
12606 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
12607 0xa8, 0x00, 0xaa, 0x00,
12608 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01, 0x26, 0x01, 0x60, 0x01,
12609 0x7a, 0x01, 0x82, 0x01,
12610 0xc8, 0x01, 0xca, 0x01, 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07,
12611 0x68, 0x08, 0x10, 0x0d,
12612 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
12613 0xf3, 0x10, 0x06, 0x12,
12614 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13, 0x10, 0x13, 0xfe, 0x9c,
12615 0xf0, 0x35, 0x05, 0xfe,
12616 0xec, 0x0e, 0xff, 0x10, 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8,
12617 0xfe, 0x88, 0x01, 0xff,
12618 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
12619 0x00, 0xfe, 0x57, 0x24,
12620 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00, 0x00, 0x1a, 0xff, 0x09,
12621 0x00, 0x00, 0xff, 0x08,
12622 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
12623 0xff, 0xff, 0xff, 0x13,
12624 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
12625 0xfe, 0x04, 0xf7, 0xe8,
12626 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe, 0x04, 0xf7, 0xe8, 0x7d,
12627 0x0d, 0x51, 0x37, 0xfe,
12628 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0,
12629 0xfe, 0xf8, 0x01, 0xfe,
12630 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
12631 0x05, 0xfe, 0x08, 0x0f,
12632 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05, 0xfe, 0x0e, 0x03, 0xfe,
12633 0x28, 0x1c, 0x03, 0xfe,
12634 0xa6, 0x00, 0xfe, 0xd1, 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe,
12635 0x48, 0xf0, 0xfe, 0x90,
12636 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
12637 0x02, 0xfe, 0x46, 0xf0,
12638 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60, 0x02, 0xfe, 0x43, 0xf0,
12639 0xfe, 0x4e, 0x02, 0xfe,
12640 0x44, 0xf0, 0xfe, 0x52, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c,
12641 0x0d, 0xa2, 0x1c, 0x07,
12642 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
12643 0x1c, 0xf5, 0xfe, 0x1e,
12644 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc,
12645 0xde, 0x0a, 0x81, 0x01,
12646 0xa3, 0x05, 0x35, 0x1f, 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a,
12647 0x81, 0x01, 0x5c, 0xfe,
12648 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
12649 0xfe, 0x58, 0x1c, 0x1c,
12650 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c, 0x02,
12651 0x2b, 0xfe, 0x9e, 0x02,
12652 0xfe, 0x5a, 0x1c, 0xfe, 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30,
12653 0x00, 0x47, 0xb8, 0x01,
12654 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
12655 0x1a, 0x31, 0xfe, 0x69,
12656 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0x01, 0xfe,
12657 0x1e, 0x1e, 0x20, 0x2c,
12658 0xfe, 0x05, 0xf6, 0xde, 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a,
12659 0x44, 0x15, 0x56, 0x51,
12660 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
12661 0x01, 0x18, 0x09, 0x00,
12662 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0x01,
12663 0x18, 0xfe, 0xc8, 0x54,
12664 0x7b, 0xfe, 0x1c, 0x03, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60,
12665 0xfe, 0x02, 0xe8, 0x30,
12666 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
12667 0xfe, 0xe4, 0x01, 0xfe,
12668 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40, 0x1c, 0x2a, 0xeb, 0xfe,
12669 0x26, 0xf0, 0xfe, 0x66,
12670 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe,
12671 0xef, 0x10, 0xfe, 0x9f,
12672 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
12673 0x70, 0x37, 0xfe, 0x48,
12674 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x26,
12675 0x21, 0xb9, 0xc7, 0x20,
12676 0xb9, 0x0a, 0x57, 0x01, 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15,
12677 0xe1, 0x2a, 0xeb, 0xfe,
12678 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
12679 0x15, 0xfe, 0xe4, 0x00,
12680 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe, 0xc6, 0x03, 0x01, 0x41,
12681 0xfe, 0x06, 0xf0, 0xfe,
12682 0xd6, 0x03, 0xaf, 0xa0, 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29,
12683 0x03, 0x81, 0x1e, 0x1b,
12684 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
12685 0xea, 0xfe, 0x46, 0x1c,
12686 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57,
12687 0xfe, 0x48, 0x1c, 0x75,
12688 0x01, 0xa6, 0x86, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a,
12689 0xe1, 0x01, 0x18, 0x77,
12690 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
12691 0x8f, 0xfe, 0x70, 0x02,
12692 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29, 0x2f, 0xfe, 0x4e, 0x04,
12693 0x16, 0xfe, 0x4a, 0x04,
12694 0x7e, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff,
12695 0x02, 0x00, 0x10, 0x01,
12696 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
12697 0xee, 0xfe, 0x4c, 0x44,
12698 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13, 0x34, 0xfe, 0x4c, 0x54,
12699 0x7b, 0xec, 0x60, 0x8d,
12700 0x30, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01,
12701 0x0c, 0x06, 0x28, 0xfe,
12702 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
12703 0x13, 0x34, 0xfe, 0x4c,
12704 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x54,
12705 0x13, 0x01, 0x0c, 0x06,
12706 0x28, 0xa5, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06,
12707 0x28, 0xf9, 0x1f, 0x7f,
12708 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
12709 0xfe, 0xa4, 0x0e, 0x05,
12710 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe, 0x1c, 0x90, 0x04, 0xfe,
12711 0x9c, 0x93, 0x3a, 0x0b,
12712 0x0e, 0x8b, 0x02, 0x1f, 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b,
12713 0x7d, 0x1d, 0xfe, 0x46,
12714 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
12715 0xfe, 0x87, 0x83, 0xfe,
12716 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x98,
12717 0x13, 0x0f, 0xfe, 0x20,
12718 0x80, 0x04, 0xfe, 0xa0, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84,
12719 0x12, 0x01, 0x38, 0x06,
12720 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
12721 0x05, 0xd0, 0x54, 0x01,
12722 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x1e, 0xfe,
12723 0x50, 0x12, 0x5e, 0xff,
12724 0x02, 0x00, 0x10, 0x2f, 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02,
12725 0x00, 0x10, 0x2f, 0xfe,
12726 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
12727 0x38, 0xfe, 0x4a, 0xf0,
12728 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba, 0x05, 0x71, 0x2e, 0xfe,
12729 0x21, 0x00, 0xf1, 0x2e,
12730 0xfe, 0x22, 0x00, 0xa2, 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00,
12731 0x10, 0x2f, 0xfe, 0xd0,
12732 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
12733 0x1c, 0x00, 0x4d, 0x01,
12734 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27, 0x01, 0x01, 0x0c, 0x06,
12735 0x28, 0xfe, 0x24, 0x12,
12736 0x3e, 0x01, 0x84, 0x1f, 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe,
12737 0x0d, 0x00, 0x01, 0x42,
12738 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
12739 0x03, 0xb6, 0x1e, 0xfe,
12740 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13, 0x3e, 0x01, 0x84, 0x17,
12741 0xfe, 0x72, 0x06, 0x0a,
12742 0x07, 0x01, 0x38, 0x06, 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56,
12743 0x19, 0x16, 0xfe, 0x68,
12744 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
12745 0x03, 0x9a, 0x1e, 0xfe,
12746 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13, 0x01, 0xc6, 0x09, 0x12,
12747 0x48, 0xfe, 0x92, 0x06,
12748 0x2e, 0x12, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13,
12749 0x58, 0xff, 0x02, 0x00,
12750 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
12751 0xfe, 0xea, 0x06, 0x01,
12752 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01, 0xfe, 0x84, 0x19, 0x16,
12753 0xfe, 0xe0, 0x06, 0x15,
12754 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07,
12755 0x01, 0x84, 0xfe, 0xae,
12756 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
12757 0x1e, 0xfe, 0x1a, 0x12,
12758 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
12759 0x43, 0x48, 0x62, 0x80,
12760 0xf0, 0x45, 0x0a, 0x95, 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24,
12761 0x36, 0xfe, 0x02, 0xf6,
12762 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
12763 0xd0, 0x0d, 0x17, 0xfe,
12764 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe, 0x90, 0x07, 0x26, 0x20,
12765 0x9e, 0x15, 0x82, 0x01,
12766 0x41, 0x15, 0xe2, 0x21, 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58,
12767 0x57, 0x10, 0xe6, 0x05,
12768 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
12769 0xfe, 0x9c, 0x32, 0x5f,
12770 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00, 0x2f, 0xed, 0x2a, 0x3c,
12771 0xfe, 0x0a, 0xf0, 0xfe,
12772 0xce, 0x07, 0xae, 0xfe, 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08,
12773 0xaf, 0xa0, 0x05, 0x29,
12774 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
12775 0x00, 0x01, 0x08, 0x14,
12776 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08,
12777 0x14, 0x00, 0x05, 0xfe,
12778 0xc6, 0x09, 0x01, 0x76, 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06,
12779 0x12, 0xfe, 0x30, 0x13,
12780 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
12781 0x01, 0x08, 0x14, 0x00,
12782 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00, 0x05, 0xef, 0x7c, 0x4a,
12783 0x78, 0x4f, 0x0f, 0xfe,
12784 0x9a, 0x81, 0x04, 0xfe, 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d,
12785 0x28, 0x48, 0xfe, 0x6c,
12786 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
12787 0x12, 0x53, 0x63, 0x4e,
12788 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe,
12789 0x6c, 0x08, 0xaf, 0xa0,
12790 0xae, 0xfe, 0x96, 0x08, 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24,
12791 0x05, 0xed, 0xfe, 0x9c,
12792 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
12793 0x1e, 0xfe, 0x99, 0x58,
12794 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe, 0x16, 0x09, 0x10, 0x6a,
12795 0x22, 0x6b, 0x01, 0x0c,
12796 0x61, 0x54, 0x44, 0x21, 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e,
12797 0x1e, 0x47, 0x2c, 0x7a,
12798 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
12799 0x01, 0x0c, 0x61, 0x65,
12800 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20, 0x6e, 0x01, 0xfe, 0x6a,
12801 0x16, 0xfe, 0x08, 0x50,
12802 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10,
12803 0x01, 0xfe, 0xce, 0x1e,
12804 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
12805 0x01, 0xfe, 0xfe, 0x1e,
12806 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b, 0x22, 0x4c, 0xfe, 0x8a,
12807 0x10, 0x01, 0x0c, 0x06,
12808 0x54, 0xfe, 0x50, 0x12, 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e,
12809 0x10, 0x6a, 0x22, 0x6b,
12810 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
12811 0xfe, 0x9f, 0x83, 0x33,
12812 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90, 0x04, 0xfe, 0xc4, 0x93,
12813 0x3a, 0x0b, 0xfe, 0xc6,
12814 0x90, 0x04, 0xfe, 0xc6, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d,
12815 0x01, 0xfe, 0xce, 0x1e,
12816 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
12817 0x04, 0xfe, 0xc0, 0x93,
12818 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2, 0x93, 0x79, 0x0b, 0x0e,
12819 0x10, 0x4b, 0x22, 0x4c,
12820 0x10, 0x64, 0x22, 0x34, 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe,
12821 0x4e, 0x11, 0x2f, 0xfe,
12822 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
12823 0x3c, 0x37, 0x88, 0xf5,
12824 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a, 0xd2, 0xfe, 0x1e, 0x0a,
12825 0xd3, 0xfe, 0x42, 0x0a,
12826 0xae, 0xfe, 0x12, 0x0a, 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0,
12827 0x05, 0x29, 0x01, 0x41,
12828 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
12829 0xfe, 0x14, 0x12, 0x01,
12830 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x74, 0x12, 0xfe,
12831 0x2e, 0x1c, 0x05, 0xfe,
12832 0x1a, 0x0c, 0x01, 0x76, 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41,
12833 0xfe, 0x2c, 0x1c, 0xfe,
12834 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
12835 0x92, 0x10, 0xc4, 0xf6,
12836 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe, 0x1a, 0x0c, 0xc5, 0xfe,
12837 0xe7, 0x10, 0xfe, 0x2b,
12838 0xf0, 0xbf, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12,
12839 0xac, 0xfe, 0xd2, 0xf0,
12840 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
12841 0x1b, 0xbf, 0xd4, 0x5b,
12842 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5, 0xfe, 0xa9, 0x10, 0x75,
12843 0x5e, 0x32, 0x1f, 0x7f,
12844 0x01, 0x42, 0x19, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98,
12845 0x05, 0x70, 0xfe, 0x74,
12846 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
12847 0x0f, 0x4d, 0x01, 0xfe,
12848 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05, 0x5b, 0x01, 0x0c, 0x06,
12849 0x0d, 0x2b, 0xfe, 0xe2,
12850 0x0b, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24,
12851 0xfe, 0x88, 0x13, 0x21,
12852 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
12853 0x83, 0x83, 0xfe, 0xc9,
12854 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42, 0x13, 0x0f, 0xfe, 0x04,
12855 0x91, 0x04, 0xfe, 0x84,
12856 0x93, 0xfe, 0xca, 0x57, 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93,
12857 0xfe, 0xcb, 0x57, 0x0b,
12858 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
12859 0x6a, 0x3b, 0x6b, 0x10,
12860 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01, 0xc2, 0xc8, 0x7a, 0x30,
12861 0x20, 0x6e, 0xdb, 0x64,
12862 0xdc, 0x34, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55,
12863 0xfe, 0x04, 0xfa, 0x64,
12864 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
12865 0x10, 0x98, 0x91, 0x6c,
12866 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x91,
12867 0x4b, 0x7e, 0x4c, 0x01,
12868 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10,
12869 0x58, 0xfe, 0x91, 0x58,
12870 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
12871 0x1b, 0x40, 0x01, 0x0c,
12872 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe, 0x8e, 0x1e, 0x4f, 0x0f,
12873 0xfe, 0x10, 0x90, 0x04,
12874 0xfe, 0x90, 0x93, 0x3a, 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93,
12875 0x79, 0x0b, 0x0e, 0xfe,
12876 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
12877 0x01, 0x0c, 0x06, 0x0d,
12878 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e, 0xfe, 0x6e, 0x0a, 0xfe,
12879 0x0c, 0x58, 0xfe, 0x8d,
12880 0x58, 0x05, 0x5b, 0x26, 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99,
12881 0x83, 0x33, 0x0b, 0x0e,
12882 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
12883 0x19, 0xfe, 0x19, 0x41,
12884 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef, 0x1f, 0x92, 0x01, 0x42,
12885 0x19, 0xfe, 0x44, 0x00,
12886 0xfe, 0x90, 0x10, 0xfe, 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda,
12887 0x4c, 0xfe, 0x0c, 0x51,
12888 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
12889 0x76, 0x10, 0xac, 0xfe,
12890 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x5d, 0x03,
12891 0xe3, 0x23, 0x07, 0xfe,
12892 0x08, 0x13, 0x19, 0xfe, 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe,
12893 0xcc, 0x0c, 0x1f, 0x92,
12894 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
12895 0x0c, 0xfe, 0x3e, 0x10,
12896 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe, 0x22, 0x00, 0x05, 0x70,
12897 0xfe, 0xcb, 0xf0, 0xfe,
12898 0xea, 0x0c, 0x19, 0xfe, 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe,
12899 0xf4, 0x0c, 0x19, 0x94,
12900 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
12901 0xfe, 0xcc, 0xf0, 0xef,
12902 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12, 0x00, 0x37, 0x13, 0xfe,
12903 0x4e, 0x11, 0x2f, 0xfe,
12904 0x16, 0x0d, 0xfe, 0x9e, 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b,
12905 0x3c, 0x37, 0x88, 0xf5,
12906 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
12907 0x2f, 0xfe, 0x3e, 0x0d,
12908 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0, 0xd4, 0x9f, 0xd5, 0x9f,
12909 0xd2, 0x9f, 0xd3, 0x9f,
12910 0x05, 0x29, 0x01, 0x41, 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4,
12911 0xc5, 0x75, 0xd7, 0x99,
12912 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
12913 0x9c, 0x2f, 0xfe, 0x8c,
12914 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01, 0x48, 0xa4, 0x19, 0xfe,
12915 0x42, 0x00, 0x05, 0x70,
12916 0x90, 0x07, 0xfe, 0x81, 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06,
12917 0x0d, 0xfe, 0x44, 0x13,
12918 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
12919 0xfe, 0xda, 0x0e, 0x0a,
12920 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe, 0x28, 0x00, 0xfe, 0xfa,
12921 0x10, 0x01, 0xfe, 0xf4,
12922 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40,
12923 0x15, 0x56, 0x01, 0x85,
12924 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
12925 0xcc, 0x10, 0x01, 0xa7,
12926 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f, 0xfe, 0x19, 0x82, 0x04,
12927 0xfe, 0x99, 0x83, 0xfe,
12928 0xcc, 0x47, 0x0b, 0x0e, 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe,
12929 0x43, 0x00, 0xfe, 0xa2,
12930 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
12931 0x00, 0x1d, 0x40, 0x15,
12932 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01, 0xfe, 0x9e, 0x1e, 0x05,
12933 0xfe, 0x3a, 0x03, 0x01,
12934 0x0c, 0x06, 0x0d, 0x5d, 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01,
12935 0x76, 0x06, 0x12, 0xfe,
12936 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
12937 0xfe, 0x9d, 0xf0, 0xfe,
12938 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x94, 0x0e, 0x01,
12939 0x0c, 0x61, 0x12, 0x44,
12940 0xfe, 0x9f, 0x10, 0x19, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f,
12941 0xfe, 0x2e, 0x10, 0x19,
12942 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
12943 0xfe, 0x41, 0x00, 0xa2,
12944 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75, 0x03, 0x81, 0x1e, 0x2b,
12945 0xea, 0x4f, 0xfe, 0x04,
12946 0xe6, 0x12, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05,
12947 0x35, 0xfe, 0x12, 0x1c,
12948 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
12949 0xfe, 0xd4, 0x11, 0x05,
12950 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e, 0x47, 0x46, 0x28, 0xfe,
12951 0xce, 0x45, 0x31, 0x51,
12952 0xfe, 0x06, 0xea, 0xe0, 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03,
12953 0x67, 0xfe, 0x98, 0x56,
12954 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
12955 0x0c, 0x06, 0x28, 0xfe,
12956 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe, 0x41, 0x58, 0x0a, 0xba,
12957 0xfe, 0xfa, 0x14, 0xfe,
12958 0x49, 0x54, 0xb0, 0xfe, 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67,
12959 0xfe, 0xe0, 0x14, 0xfe,
12960 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
12961 0xfe, 0xad, 0x13, 0x05,
12962 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12, 0x26, 0x20, 0x96, 0x20,
12963 0xe7, 0xfe, 0x08, 0x1c,
12964 0xfe, 0x7c, 0x19, 0xfe, 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe,
12965 0x48, 0x55, 0xa5, 0x3b,
12966 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
12967 0xf0, 0x1a, 0x03, 0xfe,
12968 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe, 0x1e, 0x10, 0xfe, 0x02,
12969 0xec, 0xe7, 0x53, 0x00,
12970 0x36, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
12971 0x01, 0xfe, 0x62, 0x1b,
12972 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
12973 0xea, 0xe7, 0x53, 0x92,
12974 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3, 0xfe, 0x2a, 0x10, 0x03,
12975 0xfe, 0x38, 0x01, 0x23,
12976 0xfe, 0xf0, 0xff, 0x10, 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62,
12977 0x01, 0x01, 0xfe, 0x1e,
12978 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
12979 0x26, 0x02, 0x21, 0x96,
12980 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13, 0x1f, 0x1d, 0x47, 0xb5,
12981 0xc3, 0xfe, 0xe1, 0x10,
12982 0xcf, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf,
12983 0xfe, 0x03, 0xdc, 0xfe,
12984 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
12985 0x00, 0xcc, 0x02, 0xfe,
12986 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13,
12987 0x0f, 0xfe, 0x1c, 0x80,
12988 0x04, 0xfe, 0x9c, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13,
12989 0x0f, 0xfe, 0x1e, 0x80,
12990 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
12991 0x1d, 0x80, 0x04, 0xfe,
12992 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c, 0x13, 0x01, 0xfe, 0xee,
12993 0x1e, 0xac, 0xfe, 0x14,
12994 0x13, 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e,
12995 0x1f, 0xfe, 0x30, 0xf4,
12996 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
12997 0x56, 0xfb, 0x01, 0xfe,
12998 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01, 0xfe, 0xf4, 0x1c, 0x01,
12999 0xfe, 0x00, 0x1d, 0x15,
13000 0xfe, 0xe9, 0x00, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe,
13001 0x22, 0x1b, 0xfe, 0x1e,
13002 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
13003 0x96, 0x90, 0x04, 0xfe,
13004 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64, 0x01, 0x22, 0xfe, 0x66,
13005 0x01, 0x01, 0x0c, 0x06,
13006 0x65, 0xf9, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b,
13007 0x0e, 0x77, 0xfe, 0x01,
13008 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
13009 0x21, 0x2c, 0xfe, 0x00,
13010 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe,
13011 0x06, 0x58, 0x03, 0xfe,
13012 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58,
13013 0x03, 0xfe, 0xb2, 0x00,
13014 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
13015 0x66, 0x10, 0x55, 0x10,
13016 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe, 0x90, 0x4d, 0xfe, 0x91,
13017 0x54, 0x2b, 0xfe, 0x88,
13018 0x11, 0x46, 0x1a, 0x13, 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe,
13019 0x91, 0x54, 0x2b, 0xfe,
13020 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
13021 0x00, 0x40, 0x8d, 0x2c,
13022 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xb2, 0x11, 0xfe,
13023 0x12, 0x1c, 0x75, 0xfe,
13024 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c,
13025 0x14, 0xfe, 0x0e, 0x47,
13026 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
13027 0xa7, 0x90, 0x34, 0x60,
13028 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0xfe, 0x02, 0x80,
13029 0x09, 0x56, 0xfe, 0x34,
13030 0x13, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48,
13031 0xfe, 0x45, 0x48, 0x01,
13032 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
13033 0x09, 0x1a, 0xa5, 0x0a,
13034 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85, 0xf2, 0x09, 0x9b, 0xa4,
13035 0xfe, 0x14, 0x56, 0xfe,
13036 0xd6, 0xf0, 0xfe, 0xec, 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01,
13037 0xec, 0xb8, 0xfe, 0x9e,
13038 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
13039 0xf4, 0xfe, 0xdd, 0x10,
13040 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee, 0x09, 0x12, 0xfe, 0x48,
13041 0x12, 0x09, 0x0d, 0xfe,
13042 0x56, 0x12, 0x09, 0x1d, 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4,
13043 0x13, 0x09, 0xfe, 0x23,
13044 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
13045 0x24, 0xfe, 0x12, 0x12,
13046 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42, 0xa1, 0x32, 0x01, 0x08,
13047 0xae, 0x41, 0x02, 0x32,
13048 0xfe, 0x62, 0x08, 0x0a, 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05,
13049 0x35, 0x32, 0x01, 0x43,
13050 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
13051 0x13, 0x01, 0x0c, 0x06,
13052 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe,
13053 0xe5, 0x55, 0xb0, 0xfe,
13054 0x4a, 0x13, 0x21, 0x6e, 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e,
13055 0xfe, 0xb6, 0x0e, 0x10,
13056 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
13057 0x88, 0x20, 0x6e, 0x01,
13058 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x04, 0x55, 0xfe, 0xa5,
13059 0x55, 0xfe, 0x04, 0xfa,
13060 0x64, 0xfe, 0x05, 0xfa, 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d,
13061 0xfe, 0x40, 0x56, 0xfe,
13062 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
13063 0x44, 0x55, 0xfe, 0xe5,
13064 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x10,
13065 0x68, 0x22, 0x69, 0x01,
13066 0x0c, 0x06, 0x54, 0xf9, 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b,
13067 0x6b, 0xfe, 0x2c, 0x50,
13068 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
13069 0x50, 0x03, 0x68, 0x3b,
13070 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x4b, 0x3b, 0x4c, 0xfe,
13071 0x40, 0x50, 0xfe, 0xc2,
13072 0x50, 0x05, 0x73, 0x2e, 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08,
13073 0x16, 0x3d, 0x27, 0x25,
13074 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
13075 0xa6, 0x23, 0x3f, 0x1b,
13076 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13, 0x91, 0x4b, 0x7e, 0x4c,
13077 0xfe, 0x0a, 0x55, 0x31,
13078 0xfe, 0x8b, 0x55, 0xd9, 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e,
13079 0x51, 0x05, 0x72, 0x01,
13080 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
13081 0x2a, 0x3c, 0x16, 0xc0,
13082 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d, 0x83, 0x2d, 0x7f, 0x1b,
13083 0xfe, 0x66, 0x15, 0x05,
13084 0x3d, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d,
13085 0x2b, 0x3d, 0x01, 0x08,
13086 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
13087 0xb6, 0x1e, 0x83, 0x01,
13088 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45, 0x2d, 0x00, 0xa4, 0x46,
13089 0x07, 0x90, 0x3f, 0x01,
13090 0xfe, 0xf8, 0x15, 0x01, 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13,
13091 0x01, 0x43, 0x09, 0x82,
13092 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
13093 0x05, 0x72, 0xfe, 0xc0,
13094 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x5e,
13095 0x32, 0x01, 0x08, 0x17,
13096 0x73, 0x01, 0xfe, 0x56, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16,
13097 0x3d, 0x27, 0x25, 0xbd,
13098 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
13099 0xe8, 0x14, 0x01, 0xa6,
13100 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe, 0x4a, 0xf4, 0x07, 0xfe,
13101 0x0e, 0x12, 0x01, 0x43,
13102 0x09, 0x82, 0x4e, 0x05, 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32,
13103 0x01, 0x08, 0x17, 0x73,
13104 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
13105 0x27, 0x25, 0xbd, 0x09,
13106 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b, 0xfe, 0xaa, 0x14, 0xfe,
13107 0xb6, 0x14, 0x86, 0xa8,
13108 0xb2, 0x0d, 0x1b, 0x3d, 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09,
13109 0x82, 0x4e, 0x05, 0x72,
13110 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
13111 0xfe, 0xc0, 0x19, 0x05,
13112 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17, 0xfe, 0xe2, 0x15, 0x5f,
13113 0xcc, 0x01, 0x08, 0x26,
13114 0x5f, 0x02, 0x8f, 0xfe, 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe,
13115 0xcc, 0x15, 0x5e, 0x32,
13116 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
13117 0xad, 0x23, 0xfe, 0xff,
13118 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02,
13119 0x00, 0x57, 0x52, 0xad,
13120 0x23, 0x3f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff,
13121 0x02, 0x00, 0x57, 0x52,
13122 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
13123 0x02, 0x13, 0x58, 0xff,
13124 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58, 0x02, 0x0a, 0x66, 0x01,
13125 0x5c, 0x0a, 0x55, 0x01,
13126 0x5c, 0x0a, 0x6f, 0x01, 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a,
13127 0xff, 0x03, 0x00, 0x54,
13128 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
13129 0x7c, 0x3a, 0x0b, 0x0e,
13130 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a, 0x19, 0xfe, 0xfb, 0x19,
13131 0xfe, 0x1a, 0xf7, 0x00,
13132 0xfe, 0x1b, 0xf7, 0x00, 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c,
13133 0xda, 0x6d, 0x02, 0xfe,
13134 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
13135 0x02, 0x01, 0xc6, 0xfe,
13136 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17, 0x27,
13137 0x25, 0xbe, 0x01, 0x08,
13138 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59,
13139 0x03, 0x9a, 0x1e, 0xfe,
13140 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
13141 0x48, 0xfe, 0x08, 0x17,
13142 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d, 0xb4, 0x7b, 0xfe, 0x26,
13143 0x17, 0x4d, 0x13, 0x07,
13144 0x1c, 0xb4, 0x90, 0x04, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1,
13145 0xff, 0x02, 0x83, 0x55,
13146 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
13147 0x17, 0x1c, 0x63, 0x13,
13148 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16, 0x13, 0xd6, 0xfe, 0x64,
13149 0x00, 0xb0, 0xfe, 0x80,
13150 0x17, 0x0a, 0xfe, 0x64, 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10,
13151 0x53, 0x07, 0xfe, 0x60,
13152 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
13153 0x00, 0x1c, 0x95, 0x13,
13154 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0x8c, 0x17, 0x45, 0xf3,
13155 0xfe, 0x43, 0xf4, 0x96,
13156 0xfe, 0x56, 0xf0, 0xfe, 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43,
13157 0xf4, 0x94, 0xf6, 0x8b,
13158 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
13159 0xda, 0x17, 0x62, 0x49,
13160 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x80,
13161 0x71, 0x50, 0x26, 0xfe,
13162 0x4d, 0xf4, 0x00, 0xf7, 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3,
13163 0x58, 0x02, 0x50, 0x13,
13164 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
13165 0x25, 0xbe, 0xfe, 0x03,
13166 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe9,
13167 0x0a, 0x01, 0x08, 0x16,
13168 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01,
13169 0x01, 0x08, 0x16, 0xa9,
13170 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
13171 0x08, 0x16, 0xa9, 0x27,
13172 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01, 0x03, 0xb6, 0x1e, 0x83,
13173 0x01, 0x38, 0x06, 0x24,
13174 0x31, 0xa2, 0x78, 0xf2, 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1,
13175 0x78, 0x03, 0x9a, 0x1e,
13176 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
13177 0xfe, 0x40, 0x5a, 0x23,
13178 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x49, 0x71, 0x8c,
13179 0x80, 0x48, 0xfe, 0xaa,
13180 0x18, 0x62, 0x80, 0xfe, 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01,
13181 0xfe, 0xac, 0x1d, 0xfe,
13182 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
13183 0x43, 0x48, 0x2d, 0x93,
13184 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe, 0x40, 0x10, 0x2d, 0xb4,
13185 0x36, 0xfe, 0x34, 0xf4,
13186 0x04, 0xfe, 0x34, 0x10, 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe,
13187 0x28, 0x10, 0xfe, 0xc0,
13188 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
13189 0x18, 0x45, 0xfe, 0x1c,
13190 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe, 0x0c,
13191 0x19, 0xfe, 0x04, 0xf4,
13192 0x58, 0xfe, 0x40, 0xf4, 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d,
13193 0x21, 0xfe, 0x7f, 0x01,
13194 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
13195 0x7e, 0x01, 0xfe, 0xc8,
13196 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01, 0xfe, 0x48, 0x45, 0xfa,
13197 0x21, 0xfe, 0x81, 0x01,
13198 0xfe, 0xc8, 0x44, 0x4e, 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50,
13199 0x13, 0x0d, 0x02, 0x14,
13200 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
13201 0xfe, 0x82, 0x19, 0x14,
13202 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f, 0xfe, 0x89, 0x49, 0x01,
13203 0x08, 0x02, 0x14, 0x07,
13204 0x01, 0x08, 0x17, 0xc1, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07,
13205 0x01, 0x08, 0x17, 0xc1,
13206 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
13207 0x08, 0x02, 0x50, 0x02,
13208 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f, 0x01, 0x08, 0x17, 0x74,
13209 0x14, 0x12, 0x01, 0x08,
13210 0x17, 0x74, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01,
13211 0x08, 0x17, 0x74, 0xfe,
13212 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
13213 0x74, 0x5f, 0xcc, 0x01,
13214 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c, 0x13, 0xc8, 0x20, 0xe4,
13215 0xfe, 0x49, 0xf4, 0x00,
13216 0x4d, 0x5f, 0xa1, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff,
13217 0x02, 0x00, 0x10, 0x2f,
13218 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
13219 0x16, 0xfe, 0x64, 0x1a,
13220 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09, 0x07, 0x5d, 0x01, 0x0c,
13221 0x61, 0x07, 0x44, 0x02,
13222 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12,
13223 0x13, 0x0a, 0x9d, 0x01,
13224 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
13225 0xfe, 0x80, 0xe7, 0x1a,
13226 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe, 0xb2, 0x16, 0xaa, 0x02,
13227 0x0a, 0x5a, 0x01, 0x18,
13228 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe,
13229 0x7e, 0x1e, 0xfe, 0x80,
13230 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
13231 0xfe, 0x80, 0x4c, 0x0a,
13232 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c, 0xe5, 0xfe, 0x18, 0xdf,
13233 0xfe, 0x19, 0xde, 0xfe,
13234 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe,
13235 0x2a, 0x1c, 0xfa, 0xb3,
13236 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
13237 0xf4, 0x1a, 0xfe, 0xfa,
13238 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x24,
13239 0xfe, 0x18, 0x58, 0x03,
13240 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f,
13241 0xfe, 0x30, 0xf4, 0x07,
13242 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
13243 0xf7, 0x24, 0xb1, 0xfe,
13244 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x26, 0x1b,
13245 0xfe, 0xba, 0x10, 0x1c,
13246 0x1a, 0x87, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
13247 0x1d, 0xf7, 0x54, 0xb1,
13248 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
13249 0xaf, 0x19, 0xfe, 0x98,
13250 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b, 0xfe, 0x8a, 0x10, 0x1c,
13251 0x1a, 0x87, 0x8b, 0x0f,
13252 0xfe, 0x30, 0x90, 0x04, 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58,
13253 0xfe, 0x32, 0x90, 0x04,
13254 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
13255 0x7c, 0x12, 0xfe, 0x0f,
13256 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6, 0x1b, 0xfe, 0x5e, 0x14,
13257 0x31, 0x02, 0xc9, 0x2b,
13258 0xfe, 0x96, 0x1b, 0x5c, 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe,
13259 0x6a, 0xfe, 0x19, 0xfe,
13260 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
13261 0x1b, 0xfe, 0x36, 0x14,
13262 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19,
13263 0xfe, 0x80, 0xe7, 0x1a,
13264 0xfe, 0x81, 0xe7, 0x1a, 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a,
13265 0x30, 0xfe, 0x12, 0x45,
13266 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
13267 0x39, 0xf0, 0x75, 0x26,
13268 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13, 0x11, 0x02, 0x87, 0x03,
13269 0xe3, 0x23, 0x07, 0xfe,
13270 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09,
13271 0x56, 0xfe, 0x3c, 0x13,
13272 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
13273 0x01, 0x18, 0xcb, 0xfe,
13274 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xfe, 0xb2, 0x16,
13275 0xfe, 0x00, 0xcc, 0xcb,
13276 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18,
13277 0xfe, 0x80, 0x4c, 0x01,
13278 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
13279 0x12, 0xfe, 0x14, 0x56,
13280 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d, 0x02, 0xfe, 0x9c, 0xe7,
13281 0x0d, 0x19, 0xfe, 0x15,
13282 0x00, 0x40, 0x8d, 0x30, 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06,
13283 0x83, 0xfe, 0x18, 0x80,
13284 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
13285 0x90, 0xfe, 0xba, 0x90,
13286 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31, 0xfe, 0xc9, 0x55, 0x02,
13287 0x21, 0xb9, 0x88, 0x20,
13288 0xb9, 0x02, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01,
13289 0x18, 0xfe, 0x49, 0x44,
13290 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
13291 0x1a, 0xa4, 0x0a, 0x67,
13292 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89, 0x02, 0xfe, 0x4e, 0xe4,
13293 0x1d, 0x7b, 0xfe, 0x52,
13294 0x1d, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe,
13295 0x4e, 0xe4, 0xdd, 0x7b,
13296 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
13297 0xfe, 0x4e, 0xe4, 0xfe,
13298 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe, 0x94, 0x00, 0xd1, 0x24,
13299 0xfe, 0x08, 0x10, 0x03,
13300 0xfe, 0x96, 0x00, 0xd1, 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04,
13301 0x68, 0x54, 0xfe, 0xf1,
13302 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
13303 0xfe, 0x1a, 0xf4, 0xfe,
13304 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa, 0x1d, 0x13, 0x1d, 0x02,
13305 0x09, 0x92, 0xfe, 0x5a,
13306 0xf0, 0xfe, 0xba, 0x1d, 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe,
13307 0x5a, 0xf0, 0xfe, 0xc8,
13308 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
13309 0x1a, 0x10, 0x09, 0x0d,
13310 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e, 0x95, 0xa1, 0xc8, 0x02,
13311 0x1f, 0x93, 0x01, 0x42,
13312 0xfe, 0x04, 0xfe, 0x99, 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e,
13313 0xfe, 0x14, 0xf0, 0x08,
13314 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
13315 0xfe, 0x82, 0xf0, 0xfe,
13316 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80, 0x83, 0x33, 0x0b, 0x0e,
13317 0x02, 0x0f, 0xfe, 0x18,
13318 0x80, 0x04, 0xfe, 0x98, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02,
13319 0x80, 0x04, 0xfe, 0x82,
13320 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
13321 0x83, 0x33, 0x0b, 0x0e,
13322 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b, 0x83, 0x33, 0x0b, 0x0e,
13323 0x02, 0x0f, 0xfe, 0x04,
13324 0x80, 0x04, 0xfe, 0x84, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80,
13325 0x80, 0x04, 0xfe, 0x80,
13326 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
13327 0xfe, 0x99, 0x83, 0xfe,
13328 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x83, 0x04, 0xfe, 0x86,
13329 0x83, 0xfe, 0xce, 0x47,
13330 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a,
13331 0x0b, 0x0e, 0x02, 0x0f,
13332 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
13333 0xfe, 0x08, 0x90, 0x04,
13334 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x8a, 0x90, 0x04,
13335 0xfe, 0x8a, 0x93, 0x79,
13336 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a,
13337 0x0b, 0x0e, 0x02, 0x0f,
13338 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
13339 0xfe, 0x3c, 0x90, 0x04,
13340 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b, 0x0f, 0xfe, 0x03, 0x80,
13341 0x04, 0xfe, 0x83, 0x83,
13342 0x33, 0x0b, 0x77, 0x0e, 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
13345 static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
13346 static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
13350 * EEPROM Configuration.
13352 * All drivers should use this structure to set the default EEPROM
13353 * configuration. The BIOS now uses this structure when it is built.
13354 * Additional structure information can be found in a_condor.h where
13355 * the structure is defined.
13357 * The *_Field_IsChar structs are needed to correct for endianness.
13358 * These values are read from the board 16 bits at a time directly
13359 * into the structs. Because some fields are char, the values will be
13360 * in the wrong order. The *_Field_IsChar tells when to flip the
13361 * bytes. Data read and written to PCI memory is automatically swapped
13362 * on big-endian platforms so char fields read as words are actually being
13363 * unswapped on big-endian platforms.
13365 static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
13366 ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
13367 0x0000, /* cfg_msw */
13368 0xFFFF, /* disc_enable */
13369 0xFFFF, /* wdtr_able */
13370 0xFFFF, /* sdtr_able */
13371 0xFFFF, /* start_motor */
13372 0xFFFF, /* tagqng_able */
13373 0xFFFF, /* bios_scan */
13374 0, /* scam_tolerant */
13375 7, /* adapter_scsi_id */
13376 0, /* bios_boot_delay */
13377 3, /* scsi_reset_delay */
13378 0, /* bios_id_lun */
13379 0, /* termination */
13381 0xFFE7, /* bios_ctrl */
13382 0xFFFF, /* ultra_able */
13384 ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
13385 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
13388 0, /* serial_number_word1 */
13389 0, /* serial_number_word2 */
13390 0, /* serial_number_word3 */
13392 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
13393 , /* oem_name[16] */
13394 0, /* dvc_err_code */
13395 0, /* adv_err_code */
13396 0, /* adv_err_addr */
13397 0, /* saved_dvc_err_code */
13398 0, /* saved_adv_err_code */
13399 0, /* saved_adv_err_addr */
13403 static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
13406 0, /* -disc_enable */
13409 0, /* start_motor */
13410 0, /* tagqng_able */
13412 0, /* scam_tolerant */
13413 1, /* adapter_scsi_id */
13414 1, /* bios_boot_delay */
13415 1, /* scsi_reset_delay */
13416 1, /* bios_id_lun */
13417 1, /* termination */
13420 0, /* ultra_able */
13422 1, /* max_host_qng */
13423 1, /* max_dvc_qng */
13426 0, /* serial_number_word1 */
13427 0, /* serial_number_word2 */
13428 0, /* serial_number_word3 */
13430 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
13431 , /* oem_name[16] */
13432 0, /* dvc_err_code */
13433 0, /* adv_err_code */
13434 0, /* adv_err_addr */
13435 0, /* saved_dvc_err_code */
13436 0, /* saved_adv_err_code */
13437 0, /* saved_adv_err_addr */
13441 static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
13442 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
13443 0x0000, /* 01 cfg_msw */
13444 0xFFFF, /* 02 disc_enable */
13445 0xFFFF, /* 03 wdtr_able */
13446 0x4444, /* 04 sdtr_speed1 */
13447 0xFFFF, /* 05 start_motor */
13448 0xFFFF, /* 06 tagqng_able */
13449 0xFFFF, /* 07 bios_scan */
13450 0, /* 08 scam_tolerant */
13451 7, /* 09 adapter_scsi_id */
13452 0, /* bios_boot_delay */
13453 3, /* 10 scsi_reset_delay */
13454 0, /* bios_id_lun */
13455 0, /* 11 termination_se */
13456 0, /* termination_lvd */
13457 0xFFE7, /* 12 bios_ctrl */
13458 0x4444, /* 13 sdtr_speed2 */
13459 0x4444, /* 14 sdtr_speed3 */
13460 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
13461 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
13462 0, /* 16 dvc_cntl */
13463 0x4444, /* 17 sdtr_speed4 */
13464 0, /* 18 serial_number_word1 */
13465 0, /* 19 serial_number_word2 */
13466 0, /* 20 serial_number_word3 */
13467 0, /* 21 check_sum */
13468 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
13469 , /* 22-29 oem_name[16] */
13470 0, /* 30 dvc_err_code */
13471 0, /* 31 adv_err_code */
13472 0, /* 32 adv_err_addr */
13473 0, /* 33 saved_dvc_err_code */
13474 0, /* 34 saved_adv_err_code */
13475 0, /* 35 saved_adv_err_addr */
13476 0, /* 36 reserved */
13477 0, /* 37 reserved */
13478 0, /* 38 reserved */
13479 0, /* 39 reserved */
13480 0, /* 40 reserved */
13481 0, /* 41 reserved */
13482 0, /* 42 reserved */
13483 0, /* 43 reserved */
13484 0, /* 44 reserved */
13485 0, /* 45 reserved */
13486 0, /* 46 reserved */
13487 0, /* 47 reserved */
13488 0, /* 48 reserved */
13489 0, /* 49 reserved */
13490 0, /* 50 reserved */
13491 0, /* 51 reserved */
13492 0, /* 52 reserved */
13493 0, /* 53 reserved */
13494 0, /* 54 reserved */
13495 0, /* 55 reserved */
13496 0, /* 56 cisptr_lsw */
13497 0, /* 57 cisprt_msw */
13498 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
13499 PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
13500 0, /* 60 reserved */
13501 0, /* 61 reserved */
13502 0, /* 62 reserved */
13503 0 /* 63 reserved */
13506 static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
13507 0, /* 00 cfg_lsw */
13508 0, /* 01 cfg_msw */
13509 0, /* 02 disc_enable */
13510 0, /* 03 wdtr_able */
13511 0, /* 04 sdtr_speed1 */
13512 0, /* 05 start_motor */
13513 0, /* 06 tagqng_able */
13514 0, /* 07 bios_scan */
13515 0, /* 08 scam_tolerant */
13516 1, /* 09 adapter_scsi_id */
13517 1, /* bios_boot_delay */
13518 1, /* 10 scsi_reset_delay */
13519 1, /* bios_id_lun */
13520 1, /* 11 termination_se */
13521 1, /* termination_lvd */
13522 0, /* 12 bios_ctrl */
13523 0, /* 13 sdtr_speed2 */
13524 0, /* 14 sdtr_speed3 */
13525 1, /* 15 max_host_qng */
13526 1, /* max_dvc_qng */
13527 0, /* 16 dvc_cntl */
13528 0, /* 17 sdtr_speed4 */
13529 0, /* 18 serial_number_word1 */
13530 0, /* 19 serial_number_word2 */
13531 0, /* 20 serial_number_word3 */
13532 0, /* 21 check_sum */
13533 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
13534 , /* 22-29 oem_name[16] */
13535 0, /* 30 dvc_err_code */
13536 0, /* 31 adv_err_code */
13537 0, /* 32 adv_err_addr */
13538 0, /* 33 saved_dvc_err_code */
13539 0, /* 34 saved_adv_err_code */
13540 0, /* 35 saved_adv_err_addr */
13541 0, /* 36 reserved */
13542 0, /* 37 reserved */
13543 0, /* 38 reserved */
13544 0, /* 39 reserved */
13545 0, /* 40 reserved */
13546 0, /* 41 reserved */
13547 0, /* 42 reserved */
13548 0, /* 43 reserved */
13549 0, /* 44 reserved */
13550 0, /* 45 reserved */
13551 0, /* 46 reserved */
13552 0, /* 47 reserved */
13553 0, /* 48 reserved */
13554 0, /* 49 reserved */
13555 0, /* 50 reserved */
13556 0, /* 51 reserved */
13557 0, /* 52 reserved */
13558 0, /* 53 reserved */
13559 0, /* 54 reserved */
13560 0, /* 55 reserved */
13561 0, /* 56 cisptr_lsw */
13562 0, /* 57 cisprt_msw */
13563 0, /* 58 subsysvid */
13564 0, /* 59 subsysid */
13565 0, /* 60 reserved */
13566 0, /* 61 reserved */
13567 0, /* 62 reserved */
13568 0 /* 63 reserved */
13571 static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
13572 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
13573 0x0000, /* 01 cfg_msw */
13574 0xFFFF, /* 02 disc_enable */
13575 0xFFFF, /* 03 wdtr_able */
13576 0x5555, /* 04 sdtr_speed1 */
13577 0xFFFF, /* 05 start_motor */
13578 0xFFFF, /* 06 tagqng_able */
13579 0xFFFF, /* 07 bios_scan */
13580 0, /* 08 scam_tolerant */
13581 7, /* 09 adapter_scsi_id */
13582 0, /* bios_boot_delay */
13583 3, /* 10 scsi_reset_delay */
13584 0, /* bios_id_lun */
13585 0, /* 11 termination_se */
13586 0, /* termination_lvd */
13587 0xFFE7, /* 12 bios_ctrl */
13588 0x5555, /* 13 sdtr_speed2 */
13589 0x5555, /* 14 sdtr_speed3 */
13590 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
13591 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
13592 0, /* 16 dvc_cntl */
13593 0x5555, /* 17 sdtr_speed4 */
13594 0, /* 18 serial_number_word1 */
13595 0, /* 19 serial_number_word2 */
13596 0, /* 20 serial_number_word3 */
13597 0, /* 21 check_sum */
13598 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
13599 , /* 22-29 oem_name[16] */
13600 0, /* 30 dvc_err_code */
13601 0, /* 31 adv_err_code */
13602 0, /* 32 adv_err_addr */
13603 0, /* 33 saved_dvc_err_code */
13604 0, /* 34 saved_adv_err_code */
13605 0, /* 35 saved_adv_err_addr */
13606 0, /* 36 reserved */
13607 0, /* 37 reserved */
13608 0, /* 38 reserved */
13609 0, /* 39 reserved */
13610 0, /* 40 reserved */
13611 0, /* 41 reserved */
13612 0, /* 42 reserved */
13613 0, /* 43 reserved */
13614 0, /* 44 reserved */
13615 0, /* 45 reserved */
13616 0, /* 46 reserved */
13617 0, /* 47 reserved */
13618 0, /* 48 reserved */
13619 0, /* 49 reserved */
13620 0, /* 50 reserved */
13621 0, /* 51 reserved */
13622 0, /* 52 reserved */
13623 0, /* 53 reserved */
13624 0, /* 54 reserved */
13625 0, /* 55 reserved */
13626 0, /* 56 cisptr_lsw */
13627 0, /* 57 cisprt_msw */
13628 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
13629 PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
13630 0, /* 60 reserved */
13631 0, /* 61 reserved */
13632 0, /* 62 reserved */
13633 0 /* 63 reserved */
13636 static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
13637 0, /* 00 cfg_lsw */
13638 0, /* 01 cfg_msw */
13639 0, /* 02 disc_enable */
13640 0, /* 03 wdtr_able */
13641 0, /* 04 sdtr_speed1 */
13642 0, /* 05 start_motor */
13643 0, /* 06 tagqng_able */
13644 0, /* 07 bios_scan */
13645 0, /* 08 scam_tolerant */
13646 1, /* 09 adapter_scsi_id */
13647 1, /* bios_boot_delay */
13648 1, /* 10 scsi_reset_delay */
13649 1, /* bios_id_lun */
13650 1, /* 11 termination_se */
13651 1, /* termination_lvd */
13652 0, /* 12 bios_ctrl */
13653 0, /* 13 sdtr_speed2 */
13654 0, /* 14 sdtr_speed3 */
13655 1, /* 15 max_host_qng */
13656 1, /* max_dvc_qng */
13657 0, /* 16 dvc_cntl */
13658 0, /* 17 sdtr_speed4 */
13659 0, /* 18 serial_number_word1 */
13660 0, /* 19 serial_number_word2 */
13661 0, /* 20 serial_number_word3 */
13662 0, /* 21 check_sum */
13663 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
13664 , /* 22-29 oem_name[16] */
13665 0, /* 30 dvc_err_code */
13666 0, /* 31 adv_err_code */
13667 0, /* 32 adv_err_addr */
13668 0, /* 33 saved_dvc_err_code */
13669 0, /* 34 saved_adv_err_code */
13670 0, /* 35 saved_adv_err_addr */
13671 0, /* 36 reserved */
13672 0, /* 37 reserved */
13673 0, /* 38 reserved */
13674 0, /* 39 reserved */
13675 0, /* 40 reserved */
13676 0, /* 41 reserved */
13677 0, /* 42 reserved */
13678 0, /* 43 reserved */
13679 0, /* 44 reserved */
13680 0, /* 45 reserved */
13681 0, /* 46 reserved */
13682 0, /* 47 reserved */
13683 0, /* 48 reserved */
13684 0, /* 49 reserved */
13685 0, /* 50 reserved */
13686 0, /* 51 reserved */
13687 0, /* 52 reserved */
13688 0, /* 53 reserved */
13689 0, /* 54 reserved */
13690 0, /* 55 reserved */
13691 0, /* 56 cisptr_lsw */
13692 0, /* 57 cisprt_msw */
13693 0, /* 58 subsysvid */
13694 0, /* 59 subsysid */
13695 0, /* 60 reserved */
13696 0, /* 61 reserved */
13697 0, /* 62 reserved */
13698 0 /* 63 reserved */
13702 * Initialize the ADV_DVC_VAR structure.
13704 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
13706 * For a non-fatal error return a warning code. If there are no warnings
13707 * then 0 is returned.
13709 static int __devinit AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
13711 unsigned short warn_code = 0;
13712 AdvPortAddr iop_base = asc_dvc->iop_base;
13713 struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
13717 asc_dvc->err_code = 0;
13720 * Save the state of the PCI Configuration Command Register
13721 * "Parity Error Response Control" Bit. If the bit is clear (0),
13722 * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
13723 * DMA parity errors.
13725 asc_dvc->cfg->control_flag = 0;
13726 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
13727 if ((cmd & PCI_COMMAND_PARITY) == 0)
13728 asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
13730 asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
13731 ADV_LIB_VERSION_MINOR;
13732 asc_dvc->cfg->chip_version =
13733 AdvGetChipVersion(iop_base, asc_dvc->bus_type);
13735 ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
13736 (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
13737 (ushort)ADV_CHIP_ID_BYTE);
13739 ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
13740 (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
13741 (ushort)ADV_CHIP_ID_WORD);
13744 * Reset the chip to start and allow register writes.
13746 if (AdvFindSignature(iop_base) == 0) {
13747 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
13751 * The caller must set 'chip_type' to a valid setting.
13753 if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
13754 asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
13755 asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
13756 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
13763 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
13764 ADV_CTRL_REG_CMD_RESET);
13765 DvcSleepMilliSecond(100);
13766 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
13767 ADV_CTRL_REG_CMD_WR_IO_REG);
13769 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
13770 status = AdvInitFrom38C1600EEP(asc_dvc);
13771 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
13772 status = AdvInitFrom38C0800EEP(asc_dvc);
13774 status = AdvInitFrom3550EEP(asc_dvc);
13776 warn_code |= status;
13783 * Initialize the ASC-3550.
13785 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
13787 * For a non-fatal error return a warning code. If there are no warnings
13788 * then 0 is returned.
13790 * Needed after initialization for error recovery.
13792 static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
13794 AdvPortAddr iop_base;
13802 int adv_asc3550_expanded_size;
13804 ADV_DCNT contig_len;
13805 ADV_SDCNT buf_size;
13806 ADV_PADDR carr_paddr;
13810 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
13811 ushort wdtr_able = 0, sdtr_able, tagqng_able;
13812 uchar max_cmd[ADV_MAX_TID + 1];
13814 /* If there is already an error, don't continue. */
13815 if (asc_dvc->err_code != 0) {
13820 * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
13822 if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
13823 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
13828 iop_base = asc_dvc->iop_base;
13831 * Save the RISC memory BIOS region before writing the microcode.
13832 * The BIOS may already be loaded and using its RISC LRAM region
13833 * so its region must be saved and restored.
13835 * Note: This code makes the assumption, which is currently true,
13836 * that a chip reset does not clear RISC LRAM.
13838 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
13839 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
13844 * Save current per TID negotiated values.
13846 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
13847 ushort bios_version, major, minor;
13850 bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
13851 major = (bios_version >> 12) & 0xF;
13852 minor = (bios_version >> 8) & 0xF;
13853 if (major < 3 || (major == 3 && minor == 1)) {
13854 /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
13855 AdvReadWordLram(iop_base, 0x120, wdtr_able);
13857 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
13860 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
13861 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
13862 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
13863 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
13868 * Load the Microcode
13870 * Write the microcode image to RISC memory starting at address 0.
13872 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
13873 /* Assume the following compressed format of the microcode buffer:
13875 * 254 word (508 byte) table indexed by byte code followed
13876 * by the following byte codes:
13879 * 00: Emit word 0 in table.
13880 * 01: Emit word 1 in table.
13882 * FD: Emit word 253 in table.
13885 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
13886 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
13889 for (i = 253 * 2; i < _adv_asc3550_size; i++) {
13890 if (_adv_asc3550_buf[i] == 0xff) {
13891 for (j = 0; j < _adv_asc3550_buf[i + 1]; j++) {
13892 AdvWriteWordAutoIncLram(iop_base, (((ushort)
13901 } else if (_adv_asc3550_buf[i] == 0xfe) {
13902 AdvWriteWordAutoIncLram(iop_base, (((ushort)
13903 _adv_asc3550_buf[i +
13906 _adv_asc3550_buf[i +
13911 AdvWriteWordAutoIncLram(iop_base, (((ushort)
13912 _adv_asc3550_buf[(_adv_asc3550_buf[i] * 2) + 1] << 8) | _adv_asc3550_buf[_adv_asc3550_buf[i] * 2]));
13918 * Set 'word' for later use to clear the rest of memory and save
13919 * the expanded mcode size.
13922 adv_asc3550_expanded_size = word;
13925 * Clear the rest of ASC-3550 Internal RAM (8KB).
13927 for (; word < ADV_3550_MEMSIZE; word += 2) {
13928 AdvWriteWordAutoIncLram(iop_base, 0);
13932 * Verify the microcode checksum.
13935 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
13937 for (word = 0; word < adv_asc3550_expanded_size; word += 2) {
13938 sum += AdvReadWordAutoIncLram(iop_base);
13941 if (sum != _adv_asc3550_chksum) {
13942 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
13947 * Restore the RISC memory BIOS region.
13949 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
13950 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
13955 * Calculate and write the microcode code checksum to the microcode
13956 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
13958 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
13959 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
13961 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
13962 for (word = begin_addr; word < end_addr; word += 2) {
13963 code_sum += AdvReadWordAutoIncLram(iop_base);
13965 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
13968 * Read and save microcode version and date.
13970 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
13971 asc_dvc->cfg->mcode_date);
13972 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
13973 asc_dvc->cfg->mcode_version);
13976 * Set the chip type to indicate the ASC3550.
13978 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
13981 * If the PCI Configuration Command Register "Parity Error Response
13982 * Control" Bit was clear (0), then set the microcode variable
13983 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
13984 * to ignore DMA parity errors.
13986 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
13987 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
13988 word |= CONTROL_FLAG_IGNORE_PERR;
13989 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
13993 * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
13994 * threshold of 128 bytes. This register is only accessible to the host.
13996 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
13997 START_CTL_EMFU | READ_CMD_MRM);
14000 * Microcode operating variables for WDTR, SDTR, and command tag
14001 * queuing will be set in AdvInquiryHandling() based on what a
14002 * device reports it is capable of in Inquiry byte 7.
14004 * If SCSI Bus Resets have been disabled, then directly set
14005 * SDTR and WDTR from the EEPROM configuration. This will allow
14006 * the BIOS and warm boot to work without a SCSI bus hang on
14007 * the Inquiry caused by host and target mismatched DTR values.
14008 * Without the SCSI Bus Reset, before an Inquiry a device can't
14009 * be assumed to be in Asynchronous, Narrow mode.
14011 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
14012 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
14013 asc_dvc->wdtr_able);
14014 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
14015 asc_dvc->sdtr_able);
14019 * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
14020 * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
14021 * bitmask. These values determine the maximum SDTR speed negotiated
14024 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
14025 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
14026 * without determining here whether the device supports SDTR.
14028 * 4-bit speed SDTR speed name
14029 * =========== ===============
14030 * 0000b (0x0) SDTR disabled
14031 * 0001b (0x1) 5 Mhz
14032 * 0010b (0x2) 10 Mhz
14033 * 0011b (0x3) 20 Mhz (Ultra)
14034 * 0100b (0x4) 40 Mhz (LVD/Ultra2)
14035 * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
14036 * 0110b (0x6) Undefined
14038 * 1111b (0xF) Undefined
14041 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
14042 if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
14043 /* Set Ultra speed for TID 'tid'. */
14044 word |= (0x3 << (4 * (tid % 4)));
14046 /* Set Fast speed for TID 'tid'. */
14047 word |= (0x2 << (4 * (tid % 4)));
14049 if (tid == 3) { /* Check if done with sdtr_speed1. */
14050 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
14052 } else if (tid == 7) { /* Check if done with sdtr_speed2. */
14053 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
14055 } else if (tid == 11) { /* Check if done with sdtr_speed3. */
14056 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
14058 } else if (tid == 15) { /* Check if done with sdtr_speed4. */
14059 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
14065 * Set microcode operating variable for the disconnect per TID bitmask.
14067 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
14068 asc_dvc->cfg->disc_enable);
14071 * Set SCSI_CFG0 Microcode Default Value.
14073 * The microcode will set the SCSI_CFG0 register using this value
14074 * after it is started below.
14076 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
14077 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
14078 asc_dvc->chip_scsi_id);
14081 * Determine SCSI_CFG1 Microcode Default Value.
14083 * The microcode will set the SCSI_CFG1 register using this value
14084 * after it is started below.
14087 /* Read current SCSI_CFG1 Register value. */
14088 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
14091 * If all three connectors are in use, return an error.
14093 if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
14094 (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
14095 asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
14100 * If the internal narrow cable is reversed all of the SCSI_CTRL
14101 * register signals will be set. Check for and return an error if
14102 * this condition is found.
14104 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
14105 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
14110 * If this is a differential board and a single-ended device
14111 * is attached to one of the connectors, return an error.
14113 if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
14114 asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
14119 * If automatic termination control is enabled, then set the
14120 * termination value based on a table listed in a_condor.h.
14122 * If manual termination was specified with an EEPROM setting
14123 * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
14124 * is ready to be 'ored' into SCSI_CFG1.
14126 if (asc_dvc->cfg->termination == 0) {
14128 * The software always controls termination by setting TERM_CTL_SEL.
14129 * If TERM_CTL_SEL were set to 0, the hardware would set termination.
14131 asc_dvc->cfg->termination |= TERM_CTL_SEL;
14133 switch (scsi_cfg1 & CABLE_DETECT) {
14134 /* TERM_CTL_H: on, TERM_CTL_L: on */
14141 asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
14144 /* TERM_CTL_H: on, TERM_CTL_L: off */
14150 asc_dvc->cfg->termination |= TERM_CTL_H;
14153 /* TERM_CTL_H: off, TERM_CTL_L: off */
14161 * Clear any set TERM_CTL_H and TERM_CTL_L bits.
14163 scsi_cfg1 &= ~TERM_CTL;
14166 * Invert the TERM_CTL_H and TERM_CTL_L bits and then
14167 * set 'scsi_cfg1'. The TERM_POL bit does not need to be
14168 * referenced, because the hardware internally inverts
14169 * the Termination High and Low bits if TERM_POL is set.
14171 scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
14174 * Set SCSI_CFG1 Microcode Default Value
14176 * Set filter value and possibly modified termination control
14177 * bits in the Microcode SCSI_CFG1 Register Value.
14179 * The microcode will set the SCSI_CFG1 register using this value
14180 * after it is started below.
14182 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
14183 FLTR_DISABLE | scsi_cfg1);
14186 * Set MEM_CFG Microcode Default Value
14188 * The microcode will set the MEM_CFG register using this value
14189 * after it is started below.
14191 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
14194 * ASC-3550 has 8KB internal memory.
14196 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
14197 BIOS_EN | RAM_SZ_8KB);
14200 * Set SEL_MASK Microcode Default Value
14202 * The microcode will set the SEL_MASK register using this value
14203 * after it is started below.
14205 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
14206 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
14209 * Build carrier freelist.
14211 * Driver must have already allocated memory and set 'carrier_buf'.
14213 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
14215 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
14216 asc_dvc->carr_freelist = NULL;
14217 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
14218 buf_size = ADV_CARRIER_BUFSIZE;
14220 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
14225 * Get physical address of the carrier 'carrp'.
14227 contig_len = sizeof(ADV_CARR_T);
14229 cpu_to_le32(DvcGetPhyAddr
14230 (asc_dvc, NULL, (uchar *)carrp,
14231 (ADV_SDCNT *)&contig_len,
14232 ADV_IS_CARRIER_FLAG));
14234 buf_size -= sizeof(ADV_CARR_T);
14237 * If the current carrier is not physically contiguous, then
14238 * maybe there was a page crossing. Try the next carrier aligned
14241 if (contig_len < sizeof(ADV_CARR_T)) {
14246 carrp->carr_pa = carr_paddr;
14247 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
14250 * Insert the carrier at the beginning of the freelist.
14253 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
14254 asc_dvc->carr_freelist = carrp;
14258 while (buf_size > 0);
14261 * Set-up the Host->RISC Initiator Command Queue (ICQ).
14264 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
14265 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
14268 asc_dvc->carr_freelist = (ADV_CARR_T *)
14269 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
14272 * The first command issued will be placed in the stopper carrier.
14274 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
14277 * Set RISC ICQ physical address start value.
14279 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
14282 * Set-up the RISC->Host Initiator Response Queue (IRQ).
14284 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
14285 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
14288 asc_dvc->carr_freelist = (ADV_CARR_T *)
14289 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
14292 * The first command completed by the RISC will be placed in
14295 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
14296 * completed the RISC will set the ASC_RQ_STOPPER bit.
14298 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
14301 * Set RISC IRQ physical address start value.
14303 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
14304 asc_dvc->carr_pending_cnt = 0;
14306 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
14307 (ADV_INTR_ENABLE_HOST_INTR |
14308 ADV_INTR_ENABLE_GLOBAL_INTR));
14310 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
14311 AdvWriteWordRegister(iop_base, IOPW_PC, word);
14313 /* finally, finally, gentlemen, start your engine */
14314 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
14317 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
14318 * Resets should be performed. The RISC has to be running
14319 * to issue a SCSI Bus Reset.
14321 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
14323 * If the BIOS Signature is present in memory, restore the
14324 * BIOS Handshake Configuration Table and do not perform
14325 * a SCSI Bus Reset.
14327 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
14330 * Restore per TID negotiated values.
14332 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
14333 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
14334 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
14336 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
14337 AdvWriteByteLram(iop_base,
14338 ASC_MC_NUMBER_OF_MAX_CMD + tid,
14342 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
14343 warn_code = ASC_WARN_BUSRESET_ERROR;
14352 * Initialize the ASC-38C0800.
14354 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
14356 * For a non-fatal error return a warning code. If there are no warnings
14357 * then 0 is returned.
14359 * Needed after initialization for error recovery.
14361 static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
14363 AdvPortAddr iop_base;
14371 int adv_asc38C0800_expanded_size;
14373 ADV_DCNT contig_len;
14374 ADV_SDCNT buf_size;
14375 ADV_PADDR carr_paddr;
14380 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
14381 ushort wdtr_able, sdtr_able, tagqng_able;
14382 uchar max_cmd[ADV_MAX_TID + 1];
14384 /* If there is already an error, don't continue. */
14385 if (asc_dvc->err_code != 0) {
14390 * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
14392 if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
14393 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
14398 iop_base = asc_dvc->iop_base;
14401 * Save the RISC memory BIOS region before writing the microcode.
14402 * The BIOS may already be loaded and using its RISC LRAM region
14403 * so its region must be saved and restored.
14405 * Note: This code makes the assumption, which is currently true,
14406 * that a chip reset does not clear RISC LRAM.
14408 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
14409 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
14414 * Save current per TID negotiated values.
14416 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
14417 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
14418 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
14419 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
14420 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
14425 * RAM BIST (RAM Built-In Self Test)
14427 * Address : I/O base + offset 0x38h register (byte).
14428 * Function: Bit 7-6(RW) : RAM mode
14429 * Normal Mode : 0x00
14430 * Pre-test Mode : 0x40
14431 * RAM Test Mode : 0x80
14433 * Bit 4(RO) : Done bit
14434 * Bit 3-0(RO) : Status
14435 * Host Error : 0x08
14436 * Int_RAM Error : 0x04
14437 * RISC Error : 0x02
14438 * SCSI Error : 0x01
14441 * Note: RAM BIST code should be put right here, before loading the
14442 * microcode and after saving the RISC memory BIOS region.
14448 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
14449 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
14450 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
14451 * to NORMAL_MODE, return an error too.
14453 for (i = 0; i < 2; i++) {
14454 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
14455 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
14456 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
14457 if ((byte & RAM_TEST_DONE) == 0
14458 || (byte & 0x0F) != PRE_TEST_VALUE) {
14459 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
14463 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
14464 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
14465 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
14467 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
14473 * LRAM Test - It takes about 1.5 ms to run through the test.
14475 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
14476 * If Done bit not set or Status not 0, save register byte, set the
14477 * err_code, and return an error.
14479 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
14480 DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
14482 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
14483 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
14484 /* Get here if Done bit not set or Status not 0. */
14485 asc_dvc->bist_err_code = byte; /* for BIOS display message */
14486 asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
14490 /* We need to reset back to normal mode after LRAM test passes. */
14491 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
14494 * Load the Microcode
14496 * Write the microcode image to RISC memory starting at address 0.
14499 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
14501 /* Assume the following compressed format of the microcode buffer:
14503 * 254 word (508 byte) table indexed by byte code followed
14504 * by the following byte codes:
14507 * 00: Emit word 0 in table.
14508 * 01: Emit word 1 in table.
14510 * FD: Emit word 253 in table.
14513 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
14514 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
14517 for (i = 253 * 2; i < _adv_asc38C0800_size; i++) {
14518 if (_adv_asc38C0800_buf[i] == 0xff) {
14519 for (j = 0; j < _adv_asc38C0800_buf[i + 1]; j++) {
14520 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14521 _adv_asc38C0800_buf
14524 _adv_asc38C0800_buf
14529 } else if (_adv_asc38C0800_buf[i] == 0xfe) {
14530 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14531 _adv_asc38C0800_buf
14534 _adv_asc38C0800_buf[i
14540 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14541 _adv_asc38C0800_buf[(_adv_asc38C0800_buf[i] * 2) + 1] << 8) | _adv_asc38C0800_buf[_adv_asc38C0800_buf[i] * 2]));
14547 * Set 'word' for later use to clear the rest of memory and save
14548 * the expanded mcode size.
14551 adv_asc38C0800_expanded_size = word;
14554 * Clear the rest of ASC-38C0800 Internal RAM (16KB).
14556 for (; word < ADV_38C0800_MEMSIZE; word += 2) {
14557 AdvWriteWordAutoIncLram(iop_base, 0);
14561 * Verify the microcode checksum.
14564 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
14566 for (word = 0; word < adv_asc38C0800_expanded_size; word += 2) {
14567 sum += AdvReadWordAutoIncLram(iop_base);
14569 ASC_DBG2(1, "AdvInitAsc38C0800Driver: word %d, i %d\n", word, i);
14572 "AdvInitAsc38C0800Driver: sum 0x%lx, _adv_asc38C0800_chksum 0x%lx\n",
14573 (ulong)sum, (ulong)_adv_asc38C0800_chksum);
14575 if (sum != _adv_asc38C0800_chksum) {
14576 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
14581 * Restore the RISC memory BIOS region.
14583 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
14584 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
14589 * Calculate and write the microcode code checksum to the microcode
14590 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
14592 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
14593 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
14595 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
14596 for (word = begin_addr; word < end_addr; word += 2) {
14597 code_sum += AdvReadWordAutoIncLram(iop_base);
14599 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
14602 * Read microcode version and date.
14604 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
14605 asc_dvc->cfg->mcode_date);
14606 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
14607 asc_dvc->cfg->mcode_version);
14610 * Set the chip type to indicate the ASC38C0800.
14612 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
14615 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
14616 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
14617 * cable detection and then we are able to read C_DET[3:0].
14619 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
14620 * Microcode Default Value' section below.
14622 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
14623 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
14624 scsi_cfg1 | DIS_TERM_DRV);
14627 * If the PCI Configuration Command Register "Parity Error Response
14628 * Control" Bit was clear (0), then set the microcode variable
14629 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
14630 * to ignore DMA parity errors.
14632 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
14633 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
14634 word |= CONTROL_FLAG_IGNORE_PERR;
14635 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
14639 * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
14640 * bits for the default FIFO threshold.
14642 * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
14644 * For DMA Errata #4 set the BC_THRESH_ENB bit.
14646 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
14647 BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
14651 * Microcode operating variables for WDTR, SDTR, and command tag
14652 * queuing will be set in AdvInquiryHandling() based on what a
14653 * device reports it is capable of in Inquiry byte 7.
14655 * If SCSI Bus Resets have been disabled, then directly set
14656 * SDTR and WDTR from the EEPROM configuration. This will allow
14657 * the BIOS and warm boot to work without a SCSI bus hang on
14658 * the Inquiry caused by host and target mismatched DTR values.
14659 * Without the SCSI Bus Reset, before an Inquiry a device can't
14660 * be assumed to be in Asynchronous, Narrow mode.
14662 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
14663 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
14664 asc_dvc->wdtr_able);
14665 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
14666 asc_dvc->sdtr_able);
14670 * Set microcode operating variables for DISC and SDTR_SPEED1,
14671 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
14672 * configuration values.
14674 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
14675 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
14676 * without determining here whether the device supports SDTR.
14678 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
14679 asc_dvc->cfg->disc_enable);
14680 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
14681 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
14682 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
14683 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
14686 * Set SCSI_CFG0 Microcode Default Value.
14688 * The microcode will set the SCSI_CFG0 register using this value
14689 * after it is started below.
14691 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
14692 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
14693 asc_dvc->chip_scsi_id);
14696 * Determine SCSI_CFG1 Microcode Default Value.
14698 * The microcode will set the SCSI_CFG1 register using this value
14699 * after it is started below.
14702 /* Read current SCSI_CFG1 Register value. */
14703 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
14706 * If the internal narrow cable is reversed all of the SCSI_CTRL
14707 * register signals will be set. Check for and return an error if
14708 * this condition is found.
14710 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
14711 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
14716 * All kind of combinations of devices attached to one of four connectors
14717 * are acceptable except HVD device attached. For example, LVD device can
14718 * be attached to SE connector while SE device attached to LVD connector.
14719 * If LVD device attached to SE connector, it only runs up to Ultra speed.
14721 * If an HVD device is attached to one of LVD connectors, return an error.
14722 * However, there is no way to detect HVD device attached to SE connectors.
14724 if (scsi_cfg1 & HVD) {
14725 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
14730 * If either SE or LVD automatic termination control is enabled, then
14731 * set the termination value based on a table listed in a_condor.h.
14733 * If manual termination was specified with an EEPROM setting then
14734 * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready to
14735 * be 'ored' into SCSI_CFG1.
14737 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
14738 /* SE automatic termination control is enabled. */
14739 switch (scsi_cfg1 & C_DET_SE) {
14740 /* TERM_SE_HI: on, TERM_SE_LO: on */
14744 asc_dvc->cfg->termination |= TERM_SE;
14747 /* TERM_SE_HI: on, TERM_SE_LO: off */
14749 asc_dvc->cfg->termination |= TERM_SE_HI;
14754 if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
14755 /* LVD automatic termination control is enabled. */
14756 switch (scsi_cfg1 & C_DET_LVD) {
14757 /* TERM_LVD_HI: on, TERM_LVD_LO: on */
14761 asc_dvc->cfg->termination |= TERM_LVD;
14764 /* TERM_LVD_HI: off, TERM_LVD_LO: off */
14771 * Clear any set TERM_SE and TERM_LVD bits.
14773 scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
14776 * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
14778 scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
14781 * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE bits
14782 * and set possibly modified termination control bits in the Microcode
14783 * SCSI_CFG1 Register Value.
14785 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
14788 * Set SCSI_CFG1 Microcode Default Value
14790 * Set possibly modified termination control and reset DIS_TERM_DRV
14791 * bits in the Microcode SCSI_CFG1 Register Value.
14793 * The microcode will set the SCSI_CFG1 register using this value
14794 * after it is started below.
14796 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
14799 * Set MEM_CFG Microcode Default Value
14801 * The microcode will set the MEM_CFG register using this value
14802 * after it is started below.
14804 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
14807 * ASC-38C0800 has 16KB internal memory.
14809 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
14810 BIOS_EN | RAM_SZ_16KB);
14813 * Set SEL_MASK Microcode Default Value
14815 * The microcode will set the SEL_MASK register using this value
14816 * after it is started below.
14818 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
14819 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
14822 * Build the carrier freelist.
14824 * Driver must have already allocated memory and set 'carrier_buf'.
14826 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
14828 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
14829 asc_dvc->carr_freelist = NULL;
14830 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
14831 buf_size = ADV_CARRIER_BUFSIZE;
14833 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
14838 * Get physical address for the carrier 'carrp'.
14840 contig_len = sizeof(ADV_CARR_T);
14842 cpu_to_le32(DvcGetPhyAddr
14843 (asc_dvc, NULL, (uchar *)carrp,
14844 (ADV_SDCNT *)&contig_len,
14845 ADV_IS_CARRIER_FLAG));
14847 buf_size -= sizeof(ADV_CARR_T);
14850 * If the current carrier is not physically contiguous, then
14851 * maybe there was a page crossing. Try the next carrier aligned
14854 if (contig_len < sizeof(ADV_CARR_T)) {
14859 carrp->carr_pa = carr_paddr;
14860 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
14863 * Insert the carrier at the beginning of the freelist.
14866 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
14867 asc_dvc->carr_freelist = carrp;
14871 while (buf_size > 0);
14874 * Set-up the Host->RISC Initiator Command Queue (ICQ).
14877 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
14878 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
14881 asc_dvc->carr_freelist = (ADV_CARR_T *)
14882 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
14885 * The first command issued will be placed in the stopper carrier.
14887 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
14890 * Set RISC ICQ physical address start value.
14891 * carr_pa is LE, must be native before write
14893 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
14896 * Set-up the RISC->Host Initiator Response Queue (IRQ).
14898 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
14899 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
14902 asc_dvc->carr_freelist = (ADV_CARR_T *)
14903 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
14906 * The first command completed by the RISC will be placed in
14909 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
14910 * completed the RISC will set the ASC_RQ_STOPPER bit.
14912 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
14915 * Set RISC IRQ physical address start value.
14917 * carr_pa is LE, must be native before write *
14919 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
14920 asc_dvc->carr_pending_cnt = 0;
14922 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
14923 (ADV_INTR_ENABLE_HOST_INTR |
14924 ADV_INTR_ENABLE_GLOBAL_INTR));
14926 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
14927 AdvWriteWordRegister(iop_base, IOPW_PC, word);
14929 /* finally, finally, gentlemen, start your engine */
14930 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
14933 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
14934 * Resets should be performed. The RISC has to be running
14935 * to issue a SCSI Bus Reset.
14937 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
14939 * If the BIOS Signature is present in memory, restore the
14940 * BIOS Handshake Configuration Table and do not perform
14941 * a SCSI Bus Reset.
14943 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
14946 * Restore per TID negotiated values.
14948 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
14949 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
14950 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
14952 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
14953 AdvWriteByteLram(iop_base,
14954 ASC_MC_NUMBER_OF_MAX_CMD + tid,
14958 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
14959 warn_code = ASC_WARN_BUSRESET_ERROR;
14968 * Initialize the ASC-38C1600.
14970 * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
14972 * For a non-fatal error return a warning code. If there are no warnings
14973 * then 0 is returned.
14975 * Needed after initialization for error recovery.
14977 static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
14979 AdvPortAddr iop_base;
14987 int adv_asc38C1600_expanded_size;
14989 ADV_DCNT contig_len;
14990 ADV_SDCNT buf_size;
14991 ADV_PADDR carr_paddr;
14996 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
14997 ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
14998 uchar max_cmd[ASC_MAX_TID + 1];
15000 /* If there is already an error, don't continue. */
15001 if (asc_dvc->err_code != 0) {
15006 * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
15008 if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
15009 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
15014 iop_base = asc_dvc->iop_base;
15017 * Save the RISC memory BIOS region before writing the microcode.
15018 * The BIOS may already be loaded and using its RISC LRAM region
15019 * so its region must be saved and restored.
15021 * Note: This code makes the assumption, which is currently true,
15022 * that a chip reset does not clear RISC LRAM.
15024 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
15025 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
15030 * Save current per TID negotiated values.
15032 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
15033 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
15034 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
15035 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
15036 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
15037 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
15042 * RAM BIST (Built-In Self Test)
15044 * Address : I/O base + offset 0x38h register (byte).
15045 * Function: Bit 7-6(RW) : RAM mode
15046 * Normal Mode : 0x00
15047 * Pre-test Mode : 0x40
15048 * RAM Test Mode : 0x80
15050 * Bit 4(RO) : Done bit
15051 * Bit 3-0(RO) : Status
15052 * Host Error : 0x08
15053 * Int_RAM Error : 0x04
15054 * RISC Error : 0x02
15055 * SCSI Error : 0x01
15058 * Note: RAM BIST code should be put right here, before loading the
15059 * microcode and after saving the RISC memory BIOS region.
15065 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
15066 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
15067 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
15068 * to NORMAL_MODE, return an error too.
15070 for (i = 0; i < 2; i++) {
15071 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
15072 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15073 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15074 if ((byte & RAM_TEST_DONE) == 0
15075 || (byte & 0x0F) != PRE_TEST_VALUE) {
15076 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15080 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15081 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15082 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
15084 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15090 * LRAM Test - It takes about 1.5 ms to run through the test.
15092 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
15093 * If Done bit not set or Status not 0, save register byte, set the
15094 * err_code, and return an error.
15096 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
15097 DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
15099 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15100 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
15101 /* Get here if Done bit not set or Status not 0. */
15102 asc_dvc->bist_err_code = byte; /* for BIOS display message */
15103 asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
15107 /* We need to reset back to normal mode after LRAM test passes. */
15108 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15111 * Load the Microcode
15113 * Write the microcode image to RISC memory starting at address 0.
15116 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15119 * Assume the following compressed format of the microcode buffer:
15121 * 254 word (508 byte) table indexed by byte code followed
15122 * by the following byte codes:
15125 * 00: Emit word 0 in table.
15126 * 01: Emit word 1 in table.
15128 * FD: Emit word 253 in table.
15131 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
15132 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
15135 for (i = 253 * 2; i < _adv_asc38C1600_size; i++) {
15136 if (_adv_asc38C1600_buf[i] == 0xff) {
15137 for (j = 0; j < _adv_asc38C1600_buf[i + 1]; j++) {
15138 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15139 _adv_asc38C1600_buf
15142 _adv_asc38C1600_buf
15147 } else if (_adv_asc38C1600_buf[i] == 0xfe) {
15148 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15149 _adv_asc38C1600_buf
15152 _adv_asc38C1600_buf[i
15158 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15159 _adv_asc38C1600_buf[(_adv_asc38C1600_buf[i] * 2) + 1] << 8) | _adv_asc38C1600_buf[_adv_asc38C1600_buf[i] * 2]));
15165 * Set 'word' for later use to clear the rest of memory and save
15166 * the expanded mcode size.
15169 adv_asc38C1600_expanded_size = word;
15172 * Clear the rest of ASC-38C1600 Internal RAM (32KB).
15174 for (; word < ADV_38C1600_MEMSIZE; word += 2) {
15175 AdvWriteWordAutoIncLram(iop_base, 0);
15179 * Verify the microcode checksum.
15182 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15184 for (word = 0; word < adv_asc38C1600_expanded_size; word += 2) {
15185 sum += AdvReadWordAutoIncLram(iop_base);
15188 if (sum != _adv_asc38C1600_chksum) {
15189 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
15194 * Restore the RISC memory BIOS region.
15196 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
15197 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
15202 * Calculate and write the microcode code checksum to the microcode
15203 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
15205 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
15206 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
15208 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
15209 for (word = begin_addr; word < end_addr; word += 2) {
15210 code_sum += AdvReadWordAutoIncLram(iop_base);
15212 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
15215 * Read microcode version and date.
15217 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
15218 asc_dvc->cfg->mcode_date);
15219 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
15220 asc_dvc->cfg->mcode_version);
15223 * Set the chip type to indicate the ASC38C1600.
15225 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
15228 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
15229 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
15230 * cable detection and then we are able to read C_DET[3:0].
15232 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
15233 * Microcode Default Value' section below.
15235 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15236 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
15237 scsi_cfg1 | DIS_TERM_DRV);
15240 * If the PCI Configuration Command Register "Parity Error Response
15241 * Control" Bit was clear (0), then set the microcode variable
15242 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
15243 * to ignore DMA parity errors.
15245 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
15246 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15247 word |= CONTROL_FLAG_IGNORE_PERR;
15248 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15252 * If the BIOS control flag AIPP (Asynchronous Information
15253 * Phase Protection) disable bit is not set, then set the firmware
15254 * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
15255 * AIPP checking and encoding.
15257 if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
15258 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15259 word |= CONTROL_FLAG_ENABLE_AIPP;
15260 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15264 * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
15265 * and START_CTL_TH [3:2].
15267 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
15268 FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
15271 * Microcode operating variables for WDTR, SDTR, and command tag
15272 * queuing will be set in AdvInquiryHandling() based on what a
15273 * device reports it is capable of in Inquiry byte 7.
15275 * If SCSI Bus Resets have been disabled, then directly set
15276 * SDTR and WDTR from the EEPROM configuration. This will allow
15277 * the BIOS and warm boot to work without a SCSI bus hang on
15278 * the Inquiry caused by host and target mismatched DTR values.
15279 * Without the SCSI Bus Reset, before an Inquiry a device can't
15280 * be assumed to be in Asynchronous, Narrow mode.
15282 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
15283 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
15284 asc_dvc->wdtr_able);
15285 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
15286 asc_dvc->sdtr_able);
15290 * Set microcode operating variables for DISC and SDTR_SPEED1,
15291 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
15292 * configuration values.
15294 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
15295 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
15296 * without determining here whether the device supports SDTR.
15298 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
15299 asc_dvc->cfg->disc_enable);
15300 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
15301 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
15302 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
15303 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
15306 * Set SCSI_CFG0 Microcode Default Value.
15308 * The microcode will set the SCSI_CFG0 register using this value
15309 * after it is started below.
15311 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
15312 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
15313 asc_dvc->chip_scsi_id);
15316 * Calculate SCSI_CFG1 Microcode Default Value.
15318 * The microcode will set the SCSI_CFG1 register using this value
15319 * after it is started below.
15321 * Each ASC-38C1600 function has only two cable detect bits.
15322 * The bus mode override bits are in IOPB_SOFT_OVER_WR.
15324 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15327 * If the cable is reversed all of the SCSI_CTRL register signals
15328 * will be set. Check for and return an error if this condition is
15331 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
15332 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
15337 * Each ASC-38C1600 function has two connectors. Only an HVD device
15338 * can not be connected to either connector. An LVD device or SE device
15339 * may be connected to either connecor. If an SE device is connected,
15340 * then at most Ultra speed (20 Mhz) can be used on both connectors.
15342 * If an HVD device is attached, return an error.
15344 if (scsi_cfg1 & HVD) {
15345 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
15350 * Each function in the ASC-38C1600 uses only the SE cable detect and
15351 * termination because there are two connectors for each function. Each
15352 * function may use either LVD or SE mode. Corresponding the SE automatic
15353 * termination control EEPROM bits are used for each function. Each
15354 * function has its own EEPROM. If SE automatic control is enabled for
15355 * the function, then set the termination value based on a table listed
15358 * If manual termination is specified in the EEPROM for the function,
15359 * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
15360 * ready to be 'ored' into SCSI_CFG1.
15362 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
15363 /* SE automatic termination control is enabled. */
15364 switch (scsi_cfg1 & C_DET_SE) {
15365 /* TERM_SE_HI: on, TERM_SE_LO: on */
15369 asc_dvc->cfg->termination |= TERM_SE;
15373 if (ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) == 0) {
15374 /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
15376 /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
15377 asc_dvc->cfg->termination |= TERM_SE_HI;
15384 * Clear any set TERM_SE bits.
15386 scsi_cfg1 &= ~TERM_SE;
15389 * Invert the TERM_SE bits and then set 'scsi_cfg1'.
15391 scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
15394 * Clear Big Endian and Terminator Polarity bits and set possibly
15395 * modified termination control bits in the Microcode SCSI_CFG1
15398 * Big Endian bit is not used even on big endian machines.
15400 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
15403 * Set SCSI_CFG1 Microcode Default Value
15405 * Set possibly modified termination control bits in the Microcode
15406 * SCSI_CFG1 Register Value.
15408 * The microcode will set the SCSI_CFG1 register using this value
15409 * after it is started below.
15411 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
15414 * Set MEM_CFG Microcode Default Value
15416 * The microcode will set the MEM_CFG register using this value
15417 * after it is started below.
15419 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
15422 * ASC-38C1600 has 32KB internal memory.
15424 * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
15425 * out a special 16K Adv Library and Microcode version. After the issue
15426 * resolved, we should turn back to the 32K support. Both a_condor.h and
15427 * mcode.sas files also need to be updated.
15429 * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
15430 * BIOS_EN | RAM_SZ_32KB);
15432 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
15433 BIOS_EN | RAM_SZ_16KB);
15436 * Set SEL_MASK Microcode Default Value
15438 * The microcode will set the SEL_MASK register using this value
15439 * after it is started below.
15441 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
15442 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
15445 * Build the carrier freelist.
15447 * Driver must have already allocated memory and set 'carrier_buf'.
15450 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
15452 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
15453 asc_dvc->carr_freelist = NULL;
15454 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
15455 buf_size = ADV_CARRIER_BUFSIZE;
15457 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
15462 * Get physical address for the carrier 'carrp'.
15464 contig_len = sizeof(ADV_CARR_T);
15466 cpu_to_le32(DvcGetPhyAddr
15467 (asc_dvc, NULL, (uchar *)carrp,
15468 (ADV_SDCNT *)&contig_len,
15469 ADV_IS_CARRIER_FLAG));
15471 buf_size -= sizeof(ADV_CARR_T);
15474 * If the current carrier is not physically contiguous, then
15475 * maybe there was a page crossing. Try the next carrier aligned
15478 if (contig_len < sizeof(ADV_CARR_T)) {
15483 carrp->carr_pa = carr_paddr;
15484 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
15487 * Insert the carrier at the beginning of the freelist.
15490 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
15491 asc_dvc->carr_freelist = carrp;
15495 while (buf_size > 0);
15498 * Set-up the Host->RISC Initiator Command Queue (ICQ).
15500 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
15501 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15504 asc_dvc->carr_freelist = (ADV_CARR_T *)
15505 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
15508 * The first command issued will be placed in the stopper carrier.
15510 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
15513 * Set RISC ICQ physical address start value. Initialize the
15514 * COMMA register to the same value otherwise the RISC will
15515 * prematurely detect a command is available.
15517 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
15518 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
15519 le32_to_cpu(asc_dvc->icq_sp->carr_pa));
15522 * Set-up the RISC->Host Initiator Response Queue (IRQ).
15524 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
15525 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15528 asc_dvc->carr_freelist = (ADV_CARR_T *)
15529 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
15532 * The first command completed by the RISC will be placed in
15535 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
15536 * completed the RISC will set the ASC_RQ_STOPPER bit.
15538 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
15541 * Set RISC IRQ physical address start value.
15543 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
15544 asc_dvc->carr_pending_cnt = 0;
15546 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
15547 (ADV_INTR_ENABLE_HOST_INTR |
15548 ADV_INTR_ENABLE_GLOBAL_INTR));
15549 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
15550 AdvWriteWordRegister(iop_base, IOPW_PC, word);
15552 /* finally, finally, gentlemen, start your engine */
15553 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
15556 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
15557 * Resets should be performed. The RISC has to be running
15558 * to issue a SCSI Bus Reset.
15560 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
15562 * If the BIOS Signature is present in memory, restore the
15563 * per TID microcode operating variables.
15565 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
15568 * Restore per TID negotiated values.
15570 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
15571 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
15572 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
15573 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
15575 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
15576 AdvWriteByteLram(iop_base,
15577 ASC_MC_NUMBER_OF_MAX_CMD + tid,
15581 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
15582 warn_code = ASC_WARN_BUSRESET_ERROR;
15591 * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
15592 * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
15593 * all of this is done.
15595 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
15597 * For a non-fatal error return a warning code. If there are no warnings
15598 * then 0 is returned.
15600 * Note: Chip is stopped on entry.
15602 static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
15604 AdvPortAddr iop_base;
15606 ADVEEP_3550_CONFIG eep_config;
15609 iop_base = asc_dvc->iop_base;
15614 * Read the board's EEPROM configuration.
15616 * Set default values if a bad checksum is found.
15618 if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
15619 warn_code |= ASC_WARN_EEPROM_CHKSUM;
15622 * Set EEPROM default values.
15624 for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++) {
15625 *((uchar *)&eep_config + i) =
15626 *((uchar *)&Default_3550_EEPROM_Config + i);
15630 * Assume the 6 byte board serial number that was read
15631 * from EEPROM is correct even if the EEPROM checksum
15634 eep_config.serial_number_word3 =
15635 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
15637 eep_config.serial_number_word2 =
15638 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
15640 eep_config.serial_number_word1 =
15641 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
15643 AdvSet3550EEPConfig(iop_base, &eep_config);
15646 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
15647 * EEPROM configuration that was read.
15649 * This is the mapping of EEPROM fields to Adv Library fields.
15651 asc_dvc->wdtr_able = eep_config.wdtr_able;
15652 asc_dvc->sdtr_able = eep_config.sdtr_able;
15653 asc_dvc->ultra_able = eep_config.ultra_able;
15654 asc_dvc->tagqng_able = eep_config.tagqng_able;
15655 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
15656 asc_dvc->max_host_qng = eep_config.max_host_qng;
15657 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
15658 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
15659 asc_dvc->start_motor = eep_config.start_motor;
15660 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
15661 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
15662 asc_dvc->no_scam = eep_config.scam_tolerant;
15663 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
15664 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
15665 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
15668 * Set the host maximum queuing (max. 253, min. 16) and the per device
15669 * maximum queuing (max. 63, min. 4).
15671 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
15672 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
15673 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
15674 /* If the value is zero, assume it is uninitialized. */
15675 if (eep_config.max_host_qng == 0) {
15676 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
15678 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
15682 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
15683 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
15684 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
15685 /* If the value is zero, assume it is uninitialized. */
15686 if (eep_config.max_dvc_qng == 0) {
15687 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
15689 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
15694 * If 'max_dvc_qng' is greater than 'max_host_qng', then
15695 * set 'max_dvc_qng' to 'max_host_qng'.
15697 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
15698 eep_config.max_dvc_qng = eep_config.max_host_qng;
15702 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
15703 * values based on possibly adjusted EEPROM values.
15705 asc_dvc->max_host_qng = eep_config.max_host_qng;
15706 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
15709 * If the EEPROM 'termination' field is set to automatic (0), then set
15710 * the ADV_DVC_CFG 'termination' field to automatic also.
15712 * If the termination is specified with a non-zero 'termination'
15713 * value check that a legal value is set and set the ADV_DVC_CFG
15714 * 'termination' field appropriately.
15716 if (eep_config.termination == 0) {
15717 asc_dvc->cfg->termination = 0; /* auto termination */
15719 /* Enable manual control with low off / high off. */
15720 if (eep_config.termination == 1) {
15721 asc_dvc->cfg->termination = TERM_CTL_SEL;
15723 /* Enable manual control with low off / high on. */
15724 } else if (eep_config.termination == 2) {
15725 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
15727 /* Enable manual control with low on / high on. */
15728 } else if (eep_config.termination == 3) {
15729 asc_dvc->cfg->termination =
15730 TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
15733 * The EEPROM 'termination' field contains a bad value. Use
15734 * automatic termination instead.
15736 asc_dvc->cfg->termination = 0;
15737 warn_code |= ASC_WARN_EEPROM_TERMINATION;
15745 * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
15746 * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
15747 * all of this is done.
15749 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
15751 * For a non-fatal error return a warning code. If there are no warnings
15752 * then 0 is returned.
15754 * Note: Chip is stopped on entry.
15756 static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
15758 AdvPortAddr iop_base;
15760 ADVEEP_38C0800_CONFIG eep_config;
15762 uchar tid, termination;
15763 ushort sdtr_speed = 0;
15765 iop_base = asc_dvc->iop_base;
15770 * Read the board's EEPROM configuration.
15772 * Set default values if a bad checksum is found.
15774 if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
15775 eep_config.check_sum) {
15776 warn_code |= ASC_WARN_EEPROM_CHKSUM;
15779 * Set EEPROM default values.
15781 for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++) {
15782 *((uchar *)&eep_config + i) =
15783 *((uchar *)&Default_38C0800_EEPROM_Config + i);
15787 * Assume the 6 byte board serial number that was read
15788 * from EEPROM is correct even if the EEPROM checksum
15791 eep_config.serial_number_word3 =
15792 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
15794 eep_config.serial_number_word2 =
15795 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
15797 eep_config.serial_number_word1 =
15798 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
15800 AdvSet38C0800EEPConfig(iop_base, &eep_config);
15803 * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
15804 * EEPROM configuration that was read.
15806 * This is the mapping of EEPROM fields to Adv Library fields.
15808 asc_dvc->wdtr_able = eep_config.wdtr_able;
15809 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
15810 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
15811 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
15812 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
15813 asc_dvc->tagqng_able = eep_config.tagqng_able;
15814 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
15815 asc_dvc->max_host_qng = eep_config.max_host_qng;
15816 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
15817 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
15818 asc_dvc->start_motor = eep_config.start_motor;
15819 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
15820 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
15821 asc_dvc->no_scam = eep_config.scam_tolerant;
15822 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
15823 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
15824 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
15827 * For every Target ID if any of its 'sdtr_speed[1234]' bits
15828 * are set, then set an 'sdtr_able' bit for it.
15830 asc_dvc->sdtr_able = 0;
15831 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
15833 sdtr_speed = asc_dvc->sdtr_speed1;
15834 } else if (tid == 4) {
15835 sdtr_speed = asc_dvc->sdtr_speed2;
15836 } else if (tid == 8) {
15837 sdtr_speed = asc_dvc->sdtr_speed3;
15838 } else if (tid == 12) {
15839 sdtr_speed = asc_dvc->sdtr_speed4;
15841 if (sdtr_speed & ADV_MAX_TID) {
15842 asc_dvc->sdtr_able |= (1 << tid);
15848 * Set the host maximum queuing (max. 253, min. 16) and the per device
15849 * maximum queuing (max. 63, min. 4).
15851 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
15852 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
15853 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
15854 /* If the value is zero, assume it is uninitialized. */
15855 if (eep_config.max_host_qng == 0) {
15856 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
15858 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
15862 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
15863 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
15864 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
15865 /* If the value is zero, assume it is uninitialized. */
15866 if (eep_config.max_dvc_qng == 0) {
15867 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
15869 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
15874 * If 'max_dvc_qng' is greater than 'max_host_qng', then
15875 * set 'max_dvc_qng' to 'max_host_qng'.
15877 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
15878 eep_config.max_dvc_qng = eep_config.max_host_qng;
15882 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
15883 * values based on possibly adjusted EEPROM values.
15885 asc_dvc->max_host_qng = eep_config.max_host_qng;
15886 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
15889 * If the EEPROM 'termination' field is set to automatic (0), then set
15890 * the ADV_DVC_CFG 'termination' field to automatic also.
15892 * If the termination is specified with a non-zero 'termination'
15893 * value check that a legal value is set and set the ADV_DVC_CFG
15894 * 'termination' field appropriately.
15896 if (eep_config.termination_se == 0) {
15897 termination = 0; /* auto termination for SE */
15899 /* Enable manual control with low off / high off. */
15900 if (eep_config.termination_se == 1) {
15903 /* Enable manual control with low off / high on. */
15904 } else if (eep_config.termination_se == 2) {
15905 termination = TERM_SE_HI;
15907 /* Enable manual control with low on / high on. */
15908 } else if (eep_config.termination_se == 3) {
15909 termination = TERM_SE;
15912 * The EEPROM 'termination_se' field contains a bad value.
15913 * Use automatic termination instead.
15916 warn_code |= ASC_WARN_EEPROM_TERMINATION;
15920 if (eep_config.termination_lvd == 0) {
15921 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
15923 /* Enable manual control with low off / high off. */
15924 if (eep_config.termination_lvd == 1) {
15925 asc_dvc->cfg->termination = termination;
15927 /* Enable manual control with low off / high on. */
15928 } else if (eep_config.termination_lvd == 2) {
15929 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
15931 /* Enable manual control with low on / high on. */
15932 } else if (eep_config.termination_lvd == 3) {
15933 asc_dvc->cfg->termination = termination | TERM_LVD;
15936 * The EEPROM 'termination_lvd' field contains a bad value.
15937 * Use automatic termination instead.
15939 asc_dvc->cfg->termination = termination;
15940 warn_code |= ASC_WARN_EEPROM_TERMINATION;
15948 * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
15949 * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
15950 * all of this is done.
15952 * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
15954 * For a non-fatal error return a warning code. If there are no warnings
15955 * then 0 is returned.
15957 * Note: Chip is stopped on entry.
15959 static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
15961 AdvPortAddr iop_base;
15963 ADVEEP_38C1600_CONFIG eep_config;
15965 uchar tid, termination;
15966 ushort sdtr_speed = 0;
15968 iop_base = asc_dvc->iop_base;
15973 * Read the board's EEPROM configuration.
15975 * Set default values if a bad checksum is found.
15977 if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
15978 eep_config.check_sum) {
15979 warn_code |= ASC_WARN_EEPROM_CHKSUM;
15982 * Set EEPROM default values.
15984 for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++) {
15986 && ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) !=
15989 * Set Function 1 EEPROM Word 0 MSB
15991 * Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11)
15994 * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and
15995 * old Mac system booting problem. The Expansion ROM must
15996 * be disabled in Function 1 for these systems.
15999 *((uchar *)&eep_config + i) =
16001 ((uchar *)&Default_38C1600_EEPROM_Config
16005 (((ADV_EEPROM_BIOS_ENABLE |
16006 ADV_EEPROM_INTAB) >> 8) & 0xFF)));
16009 * Set the INTAB (bit 11) if the GPIO 0 input indicates
16010 * the Function 1 interrupt line is wired to INTA.
16012 * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
16013 * 1 - Function 1 interrupt line wired to INT A.
16014 * 0 - Function 1 interrupt line wired to INT B.
16016 * Note: Adapter boards always have Function 0 wired to INTA.
16017 * Put all 5 GPIO bits in input mode and then read
16018 * their input values.
16020 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL,
16022 if (AdvReadByteRegister
16023 (iop_base, IOPB_GPIO_DATA) & 0x01) {
16024 /* Function 1 interrupt wired to INTA; Set EEPROM bit. */
16025 *((uchar *)&eep_config + i) |=
16026 ((ADV_EEPROM_INTAB >> 8) & 0xFF);
16029 *((uchar *)&eep_config + i) =
16030 *((uchar *)&Default_38C1600_EEPROM_Config
16036 * Assume the 6 byte board serial number that was read
16037 * from EEPROM is correct even if the EEPROM checksum
16040 eep_config.serial_number_word3 =
16041 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
16043 eep_config.serial_number_word2 =
16044 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
16046 eep_config.serial_number_word1 =
16047 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
16049 AdvSet38C1600EEPConfig(iop_base, &eep_config);
16053 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
16054 * EEPROM configuration that was read.
16056 * This is the mapping of EEPROM fields to Adv Library fields.
16058 asc_dvc->wdtr_able = eep_config.wdtr_able;
16059 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
16060 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
16061 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
16062 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
16063 asc_dvc->ppr_able = 0;
16064 asc_dvc->tagqng_able = eep_config.tagqng_able;
16065 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
16066 asc_dvc->max_host_qng = eep_config.max_host_qng;
16067 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16068 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
16069 asc_dvc->start_motor = eep_config.start_motor;
16070 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
16071 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
16072 asc_dvc->no_scam = eep_config.scam_tolerant;
16075 * For every Target ID if any of its 'sdtr_speed[1234]' bits
16076 * are set, then set an 'sdtr_able' bit for it.
16078 asc_dvc->sdtr_able = 0;
16079 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
16081 sdtr_speed = asc_dvc->sdtr_speed1;
16082 } else if (tid == 4) {
16083 sdtr_speed = asc_dvc->sdtr_speed2;
16084 } else if (tid == 8) {
16085 sdtr_speed = asc_dvc->sdtr_speed3;
16086 } else if (tid == 12) {
16087 sdtr_speed = asc_dvc->sdtr_speed4;
16089 if (sdtr_speed & ASC_MAX_TID) {
16090 asc_dvc->sdtr_able |= (1 << tid);
16096 * Set the host maximum queuing (max. 253, min. 16) and the per device
16097 * maximum queuing (max. 63, min. 4).
16099 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
16100 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16101 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
16102 /* If the value is zero, assume it is uninitialized. */
16103 if (eep_config.max_host_qng == 0) {
16104 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16106 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
16110 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
16111 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16112 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
16113 /* If the value is zero, assume it is uninitialized. */
16114 if (eep_config.max_dvc_qng == 0) {
16115 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16117 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
16122 * If 'max_dvc_qng' is greater than 'max_host_qng', then
16123 * set 'max_dvc_qng' to 'max_host_qng'.
16125 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
16126 eep_config.max_dvc_qng = eep_config.max_host_qng;
16130 * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
16131 * values based on possibly adjusted EEPROM values.
16133 asc_dvc->max_host_qng = eep_config.max_host_qng;
16134 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16137 * If the EEPROM 'termination' field is set to automatic (0), then set
16138 * the ASC_DVC_CFG 'termination' field to automatic also.
16140 * If the termination is specified with a non-zero 'termination'
16141 * value check that a legal value is set and set the ASC_DVC_CFG
16142 * 'termination' field appropriately.
16144 if (eep_config.termination_se == 0) {
16145 termination = 0; /* auto termination for SE */
16147 /* Enable manual control with low off / high off. */
16148 if (eep_config.termination_se == 1) {
16151 /* Enable manual control with low off / high on. */
16152 } else if (eep_config.termination_se == 2) {
16153 termination = TERM_SE_HI;
16155 /* Enable manual control with low on / high on. */
16156 } else if (eep_config.termination_se == 3) {
16157 termination = TERM_SE;
16160 * The EEPROM 'termination_se' field contains a bad value.
16161 * Use automatic termination instead.
16164 warn_code |= ASC_WARN_EEPROM_TERMINATION;
16168 if (eep_config.termination_lvd == 0) {
16169 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
16171 /* Enable manual control with low off / high off. */
16172 if (eep_config.termination_lvd == 1) {
16173 asc_dvc->cfg->termination = termination;
16175 /* Enable manual control with low off / high on. */
16176 } else if (eep_config.termination_lvd == 2) {
16177 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
16179 /* Enable manual control with low on / high on. */
16180 } else if (eep_config.termination_lvd == 3) {
16181 asc_dvc->cfg->termination = termination | TERM_LVD;
16184 * The EEPROM 'termination_lvd' field contains a bad value.
16185 * Use automatic termination instead.
16187 asc_dvc->cfg->termination = termination;
16188 warn_code |= ASC_WARN_EEPROM_TERMINATION;
16196 * Read EEPROM configuration into the specified buffer.
16198 * Return a checksum based on the EEPROM configuration read.
16200 static ushort __devinit
16201 AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
16203 ushort wval, chksum;
16206 ushort *charfields;
16208 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
16209 wbuf = (ushort *)cfg_buf;
16212 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
16213 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
16214 wval = AdvReadEEPWord(iop_base, eep_addr);
16215 chksum += wval; /* Checksum is calculated from word values. */
16216 if (*charfields++) {
16217 *wbuf = le16_to_cpu(wval);
16222 /* Read checksum word. */
16223 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
16227 /* Read rest of EEPROM not covered by the checksum. */
16228 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
16229 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
16230 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
16231 if (*charfields++) {
16232 *wbuf = le16_to_cpu(*wbuf);
16239 * Read EEPROM configuration into the specified buffer.
16241 * Return a checksum based on the EEPROM configuration read.
16243 static ushort __devinit
16244 AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
16246 ushort wval, chksum;
16249 ushort *charfields;
16251 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
16252 wbuf = (ushort *)cfg_buf;
16255 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
16256 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
16257 wval = AdvReadEEPWord(iop_base, eep_addr);
16258 chksum += wval; /* Checksum is calculated from word values. */
16259 if (*charfields++) {
16260 *wbuf = le16_to_cpu(wval);
16265 /* Read checksum word. */
16266 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
16270 /* Read rest of EEPROM not covered by the checksum. */
16271 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
16272 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
16273 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
16274 if (*charfields++) {
16275 *wbuf = le16_to_cpu(*wbuf);
16282 * Read EEPROM configuration into the specified buffer.
16284 * Return a checksum based on the EEPROM configuration read.
16286 static ushort __devinit
16287 AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
16289 ushort wval, chksum;
16292 ushort *charfields;
16294 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
16295 wbuf = (ushort *)cfg_buf;
16298 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
16299 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
16300 wval = AdvReadEEPWord(iop_base, eep_addr);
16301 chksum += wval; /* Checksum is calculated from word values. */
16302 if (*charfields++) {
16303 *wbuf = le16_to_cpu(wval);
16308 /* Read checksum word. */
16309 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
16313 /* Read rest of EEPROM not covered by the checksum. */
16314 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
16315 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
16316 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
16317 if (*charfields++) {
16318 *wbuf = le16_to_cpu(*wbuf);
16325 * Read the EEPROM from specified location
16327 static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
16329 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
16330 ASC_EEP_CMD_READ | eep_word_addr);
16331 AdvWaitEEPCmd(iop_base);
16332 return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
16336 * Wait for EEPROM command to complete
16338 static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
16342 for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
16343 if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
16344 ASC_EEP_CMD_DONE) {
16347 DvcSleepMilliSecond(1);
16349 if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
16357 * Write the EEPROM from 'cfg_buf'.
16360 AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
16363 ushort addr, chksum;
16364 ushort *charfields;
16366 wbuf = (ushort *)cfg_buf;
16367 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
16370 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
16371 AdvWaitEEPCmd(iop_base);
16374 * Write EEPROM from word 0 to word 20.
16376 for (addr = ADV_EEP_DVC_CFG_BEGIN;
16377 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
16380 if (*charfields++) {
16381 word = cpu_to_le16(*wbuf);
16385 chksum += *wbuf; /* Checksum is calculated from word values. */
16386 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
16387 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
16388 ASC_EEP_CMD_WRITE | addr);
16389 AdvWaitEEPCmd(iop_base);
16390 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
16394 * Write EEPROM checksum at word 21.
16396 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
16397 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
16398 AdvWaitEEPCmd(iop_base);
16403 * Write EEPROM OEM name at words 22 to 29.
16405 for (addr = ADV_EEP_DVC_CTL_BEGIN;
16406 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
16409 if (*charfields++) {
16410 word = cpu_to_le16(*wbuf);
16414 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
16415 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
16416 ASC_EEP_CMD_WRITE | addr);
16417 AdvWaitEEPCmd(iop_base);
16419 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
16420 AdvWaitEEPCmd(iop_base);
16425 * Write the EEPROM from 'cfg_buf'.
16428 AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
16431 ushort *charfields;
16432 ushort addr, chksum;
16434 wbuf = (ushort *)cfg_buf;
16435 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
16438 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
16439 AdvWaitEEPCmd(iop_base);
16442 * Write EEPROM from word 0 to word 20.
16444 for (addr = ADV_EEP_DVC_CFG_BEGIN;
16445 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
16448 if (*charfields++) {
16449 word = cpu_to_le16(*wbuf);
16453 chksum += *wbuf; /* Checksum is calculated from word values. */
16454 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
16455 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
16456 ASC_EEP_CMD_WRITE | addr);
16457 AdvWaitEEPCmd(iop_base);
16458 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
16462 * Write EEPROM checksum at word 21.
16464 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
16465 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
16466 AdvWaitEEPCmd(iop_base);
16471 * Write EEPROM OEM name at words 22 to 29.
16473 for (addr = ADV_EEP_DVC_CTL_BEGIN;
16474 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
16477 if (*charfields++) {
16478 word = cpu_to_le16(*wbuf);
16482 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
16483 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
16484 ASC_EEP_CMD_WRITE | addr);
16485 AdvWaitEEPCmd(iop_base);
16487 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
16488 AdvWaitEEPCmd(iop_base);
16493 * Write the EEPROM from 'cfg_buf'.
16496 AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
16499 ushort *charfields;
16500 ushort addr, chksum;
16502 wbuf = (ushort *)cfg_buf;
16503 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
16506 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
16507 AdvWaitEEPCmd(iop_base);
16510 * Write EEPROM from word 0 to word 20.
16512 for (addr = ADV_EEP_DVC_CFG_BEGIN;
16513 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
16516 if (*charfields++) {
16517 word = cpu_to_le16(*wbuf);
16521 chksum += *wbuf; /* Checksum is calculated from word values. */
16522 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
16523 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
16524 ASC_EEP_CMD_WRITE | addr);
16525 AdvWaitEEPCmd(iop_base);
16526 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
16530 * Write EEPROM checksum at word 21.
16532 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
16533 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
16534 AdvWaitEEPCmd(iop_base);
16539 * Write EEPROM OEM name at words 22 to 29.
16541 for (addr = ADV_EEP_DVC_CTL_BEGIN;
16542 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
16545 if (*charfields++) {
16546 word = cpu_to_le16(*wbuf);
16550 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
16551 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
16552 ASC_EEP_CMD_WRITE | addr);
16553 AdvWaitEEPCmd(iop_base);
16555 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
16556 AdvWaitEEPCmd(iop_base);
16562 * AdvExeScsiQueue() - Send a request to the RISC microcode program.
16564 * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
16565 * add the carrier to the ICQ (Initiator Command Queue), and tickle the
16566 * RISC to notify it a new command is ready to be executed.
16568 * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
16569 * set to SCSI_MAX_RETRY.
16571 * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
16572 * for DMA addresses or math operations are byte swapped to little-endian
16576 * ADV_SUCCESS(1) - The request was successfully queued.
16577 * ADV_BUSY(0) - Resource unavailable; Retry again after pending
16578 * request completes.
16579 * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
16582 static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
16584 ulong last_int_level;
16585 AdvPortAddr iop_base;
16587 ADV_PADDR req_paddr;
16588 ADV_CARR_T *new_carrp;
16590 ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */
16593 * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
16595 if (scsiq->target_id > ADV_MAX_TID) {
16596 scsiq->host_status = QHSTA_M_INVALID_DEVICE;
16597 scsiq->done_status = QD_WITH_ERROR;
16601 iop_base = asc_dvc->iop_base;
16603 last_int_level = DvcEnterCritical();
16606 * Allocate a carrier ensuring at least one carrier always
16607 * remains on the freelist and initialize fields.
16609 if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
16610 DvcLeaveCritical(last_int_level);
16613 asc_dvc->carr_freelist = (ADV_CARR_T *)
16614 ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
16615 asc_dvc->carr_pending_cnt++;
16618 * Set the carrier to be a stopper by setting 'next_vpa'
16619 * to the stopper value. The current stopper will be changed
16620 * below to point to the new stopper.
16622 new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
16625 * Clear the ADV_SCSI_REQ_Q done flag.
16627 scsiq->a_flag &= ~ADV_SCSIQ_DONE;
16629 req_size = sizeof(ADV_SCSI_REQ_Q);
16630 req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
16631 (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
16633 ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
16634 ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
16636 /* Wait for assertion before making little-endian */
16637 req_paddr = cpu_to_le32(req_paddr);
16639 /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
16640 scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
16641 scsiq->scsiq_rptr = req_paddr;
16643 scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
16645 * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
16646 * order during initialization.
16648 scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
16651 * Use the current stopper to send the ADV_SCSI_REQ_Q command to
16652 * the microcode. The newly allocated stopper will become the new
16655 asc_dvc->icq_sp->areq_vpa = req_paddr;
16658 * Set the 'next_vpa' pointer for the old stopper to be the
16659 * physical address of the new stopper. The RISC can only
16660 * follow physical addresses.
16662 asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
16665 * Set the host adapter stopper pointer to point to the new carrier.
16667 asc_dvc->icq_sp = new_carrp;
16669 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
16670 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
16672 * Tickle the RISC to tell it to read its Command Queue Head pointer.
16674 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
16675 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
16677 * Clear the tickle value. In the ASC-3550 the RISC flag
16678 * command 'clr_tickle_a' does not work unless the host
16679 * value is cleared.
16681 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
16684 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
16686 * Notify the RISC a carrier is ready by writing the physical
16687 * address of the new carrier stopper to the COMMA register.
16689 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
16690 le32_to_cpu(new_carrp->carr_pa));
16693 DvcLeaveCritical(last_int_level);
16695 return ADV_SUCCESS;
16699 * Reset SCSI Bus and purge all outstanding requests.
16702 * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
16703 * ADV_FALSE(0) - Microcode command failed.
16704 * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
16705 * may be hung which requires driver recovery.
16707 static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
16712 * Send the SCSI Bus Reset idle start idle command which asserts
16713 * the SCSI Bus Reset signal.
16715 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
16716 if (status != ADV_TRUE) {
16721 * Delay for the specified SCSI Bus Reset hold time.
16723 * The hold time delay is done on the host because the RISC has no
16724 * microsecond accurate timer.
16726 DvcDelayMicroSecond(asc_dvc, (ushort)ASC_SCSI_RESET_HOLD_TIME_US);
16729 * Send the SCSI Bus Reset end idle command which de-asserts
16730 * the SCSI Bus Reset signal and purges any pending requests.
16732 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
16733 if (status != ADV_TRUE) {
16737 DvcSleepMilliSecond((ADV_DCNT)asc_dvc->scsi_reset_wait * 1000);
16743 * Reset chip and SCSI Bus.
16746 * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
16747 * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
16749 static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
16752 ushort wdtr_able, sdtr_able, tagqng_able;
16753 ushort ppr_able = 0;
16754 uchar tid, max_cmd[ADV_MAX_TID + 1];
16755 AdvPortAddr iop_base;
16758 iop_base = asc_dvc->iop_base;
16761 * Save current per TID negotiated values.
16763 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
16764 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
16765 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
16766 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
16768 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
16769 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
16770 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
16775 * Force the AdvInitAsc3550/38C0800Driver() function to
16776 * perform a SCSI Bus Reset by clearing the BIOS signature word.
16777 * The initialization functions assumes a SCSI Bus Reset is not
16778 * needed if the BIOS signature word is present.
16780 AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
16781 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
16784 * Stop chip and reset it.
16786 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
16787 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
16788 DvcSleepMilliSecond(100);
16789 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
16790 ADV_CTRL_REG_CMD_WR_IO_REG);
16793 * Reset Adv Library error code, if any, and try
16794 * re-initializing the chip.
16796 asc_dvc->err_code = 0;
16797 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
16798 status = AdvInitAsc38C1600Driver(asc_dvc);
16799 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
16800 status = AdvInitAsc38C0800Driver(asc_dvc);
16802 status = AdvInitAsc3550Driver(asc_dvc);
16805 /* Translate initialization return value to status value. */
16809 status = ADV_FALSE;
16813 * Restore the BIOS signature word.
16815 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
16818 * Restore per TID negotiated values.
16820 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
16821 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
16822 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
16823 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
16825 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
16826 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
16827 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
16835 * Adv Library Interrupt Service Routine
16837 * This function is called by a driver's interrupt service routine.
16838 * The function disables and re-enables interrupts.
16840 * When a microcode idle command is completed, the ADV_DVC_VAR
16841 * 'idle_cmd_done' field is set to ADV_TRUE.
16843 * Note: AdvISR() can be called when interrupts are disabled or even
16844 * when there is no hardware interrupt condition present. It will
16845 * always check for completed idle commands and microcode requests.
16846 * This is an important feature that shouldn't be changed because it
16847 * allows commands to be completed from polling mode loops.
16850 * ADV_TRUE(1) - interrupt was pending
16851 * ADV_FALSE(0) - no interrupt was pending
16853 static int AdvISR(ADV_DVC_VAR *asc_dvc)
16855 AdvPortAddr iop_base;
16858 ADV_CARR_T *free_carrp;
16859 ADV_VADDR irq_next_vpa;
16861 ADV_SCSI_REQ_Q *scsiq;
16863 flags = DvcEnterCritical();
16865 iop_base = asc_dvc->iop_base;
16867 /* Reading the register clears the interrupt. */
16868 int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
16870 if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
16871 ADV_INTR_STATUS_INTRC)) == 0) {
16872 DvcLeaveCritical(flags);
16877 * Notify the driver of an asynchronous microcode condition by
16878 * calling the ADV_DVC_VAR.async_callback function. The function
16879 * is passed the microcode ASC_MC_INTRB_CODE byte value.
16881 if (int_stat & ADV_INTR_STATUS_INTRB) {
16884 AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
16886 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
16887 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
16888 if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
16889 asc_dvc->carr_pending_cnt != 0) {
16890 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
16892 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
16893 AdvWriteByteRegister(iop_base,
16900 if (asc_dvc->async_callback != 0) {
16901 (*asc_dvc->async_callback) (asc_dvc, intrb_code);
16906 * Check if the IRQ stopper carrier contains a completed request.
16908 while (((irq_next_vpa =
16909 le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
16911 * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
16912 * The RISC will have set 'areq_vpa' to a virtual address.
16914 * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
16915 * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
16916 * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
16917 * in AdvExeScsiQueue().
16919 scsiq = (ADV_SCSI_REQ_Q *)
16920 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
16923 * Request finished with good status and the queue was not
16924 * DMAed to host memory by the firmware. Set all status fields
16925 * to indicate good status.
16927 if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
16928 scsiq->done_status = QD_NO_ERROR;
16929 scsiq->host_status = scsiq->scsi_status = 0;
16930 scsiq->data_cnt = 0L;
16934 * Advance the stopper pointer to the next carrier
16935 * ignoring the lower four bits. Free the previous
16938 free_carrp = asc_dvc->irq_sp;
16939 asc_dvc->irq_sp = (ADV_CARR_T *)
16940 ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
16942 free_carrp->next_vpa =
16943 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
16944 asc_dvc->carr_freelist = free_carrp;
16945 asc_dvc->carr_pending_cnt--;
16947 ASC_ASSERT(scsiq != NULL);
16948 target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
16951 * Clear request microcode control flag.
16956 * If the command that completed was a SCSI INQUIRY and
16957 * LUN 0 was sent the command, then process the INQUIRY
16958 * command information for the device.
16960 * Note: If data returned were either VPD or CmdDt data,
16961 * don't process the INQUIRY command information for
16962 * the device, otherwise may erroneously set *_able bits.
16964 if (scsiq->done_status == QD_NO_ERROR &&
16965 scsiq->cdb[0] == INQUIRY &&
16966 scsiq->target_lun == 0 &&
16967 (scsiq->cdb[1] & ADV_INQ_RTN_VPD_AND_CMDDT)
16968 == ADV_INQ_RTN_STD_INQUIRY_DATA) {
16969 AdvInquiryHandling(asc_dvc, scsiq);
16973 * Notify the driver of the completed request by passing
16974 * the ADV_SCSI_REQ_Q pointer to its callback function.
16976 scsiq->a_flag |= ADV_SCSIQ_DONE;
16977 (*asc_dvc->isr_callback) (asc_dvc, scsiq);
16979 * Note: After the driver callback function is called, 'scsiq'
16980 * can no longer be referenced.
16982 * Fall through and continue processing other completed
16987 * Disable interrupts again in case the driver inadvertently
16988 * enabled interrupts in its callback function.
16990 * The DvcEnterCritical() return value is ignored, because
16991 * the 'flags' saved when AdvISR() was first entered will be
16992 * used to restore the interrupt flag on exit.
16994 (void)DvcEnterCritical();
16996 DvcLeaveCritical(flags);
17001 * Send an idle command to the chip and wait for completion.
17003 * Command completion is polled for once per microsecond.
17005 * The function can be called from anywhere including an interrupt handler.
17006 * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
17007 * functions to prevent reentrancy.
17010 * ADV_TRUE - command completed successfully
17011 * ADV_FALSE - command failed
17012 * ADV_ERROR - command timed out
17015 AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
17016 ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
17018 ulong last_int_level;
17021 AdvPortAddr iop_base;
17023 last_int_level = DvcEnterCritical();
17025 iop_base = asc_dvc->iop_base;
17028 * Clear the idle command status which is set by the microcode
17029 * to a non-zero value to indicate when the command is completed.
17030 * The non-zero result is one of the IDLE_CMD_STATUS_* values
17031 * defined in a_advlib.h.
17033 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
17036 * Write the idle command value after the idle command parameter
17037 * has been written to avoid a race condition. If the order is not
17038 * followed, the microcode may process the idle command before the
17039 * parameters have been written to LRAM.
17041 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
17042 cpu_to_le32(idle_cmd_parameter));
17043 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
17046 * Tickle the RISC to tell it to process the idle command.
17048 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
17049 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
17051 * Clear the tickle value. In the ASC-3550 the RISC flag
17052 * command 'clr_tickle_b' does not work unless the host
17053 * value is cleared.
17055 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
17058 /* Wait for up to 100 millisecond for the idle command to timeout. */
17059 for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
17060 /* Poll once each microsecond for command completion. */
17061 for (j = 0; j < SCSI_US_PER_MSEC; j++) {
17062 AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
17065 DvcLeaveCritical(last_int_level);
17068 DvcDelayMicroSecond(asc_dvc, (ushort)1);
17072 ASC_ASSERT(0); /* The idle command should never timeout. */
17073 DvcLeaveCritical(last_int_level);
17078 * Inquiry Information Byte 7 Handling
17080 * Handle SCSI Inquiry Command information for a device by setting
17081 * microcode operating variables that affect WDTR, SDTR, and Tag
17084 static void AdvInquiryHandling(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
17086 AdvPortAddr iop_base;
17088 ADV_SCSI_INQUIRY *inq;
17093 * AdvInquiryHandling() requires up to INQUIRY information Byte 7
17096 * If less than 8 bytes of INQUIRY information were requested or less
17097 * than 8 bytes were transferred, then return. cdb[4] is the request
17098 * length and the ADV_SCSI_REQ_Q 'data_cnt' field is set by the
17099 * microcode to the transfer residual count.
17102 if (scsiq->cdb[4] < 8 ||
17103 (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) < 8) {
17107 iop_base = asc_dvc->iop_base;
17108 tid = scsiq->target_id;
17110 inq = (ADV_SCSI_INQUIRY *) scsiq->vdata_addr;
17113 * WDTR, SDTR, and Tag Queuing cannot be enabled for old devices.
17115 if (ADV_INQ_RESPONSE_FMT(inq) < 2 && ADV_INQ_ANSI_VER(inq) < 2) {
17119 * INQUIRY Byte 7 Handling
17121 * Use a device's INQUIRY byte 7 to determine whether it
17122 * supports WDTR, SDTR, and Tag Queuing. If the feature
17123 * is enabled in the EEPROM and the device supports the
17124 * feature, then enable it in the microcode.
17127 tidmask = ADV_TID_TO_TIDMASK(tid);
17132 * If the EEPROM enabled WDTR for the device and the device
17133 * supports wide bus (16 bit) transfers, then turn on the
17134 * device's 'wdtr_able' bit and write the new value to the
17137 if ((asc_dvc->wdtr_able & tidmask) && ADV_INQ_WIDE16(inq)) {
17138 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
17139 if ((cfg_word & tidmask) == 0) {
17140 cfg_word |= tidmask;
17141 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
17145 * Clear the microcode "SDTR negotiation" and "WDTR
17146 * negotiation" done indicators for the target to cause
17147 * it to negotiate with the new setting set above.
17148 * WDTR when accepted causes the target to enter
17149 * asynchronous mode, so SDTR must be negotiated.
17151 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE,
17153 cfg_word &= ~tidmask;
17154 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE,
17156 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE,
17158 cfg_word &= ~tidmask;
17159 AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE,
17165 * Synchronous Transfers
17167 * If the EEPROM enabled SDTR for the device and the device
17168 * supports synchronous transfers, then turn on the device's
17169 * 'sdtr_able' bit. Write the new value to the microcode.
17171 if ((asc_dvc->sdtr_able & tidmask) && ADV_INQ_SYNC(inq)) {
17172 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
17173 if ((cfg_word & tidmask) == 0) {
17174 cfg_word |= tidmask;
17175 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
17179 * Clear the microcode "SDTR negotiation" done indicator
17180 * for the target to cause it to negotiate with the new
17181 * setting set above.
17183 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE,
17185 cfg_word &= ~tidmask;
17186 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE,
17191 * If the Inquiry data included enough space for the SPI-3
17192 * Clocking field, then check if DT mode is supported.
17194 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600 &&
17195 (scsiq->cdb[4] >= 57 ||
17196 (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) >= 57)) {
17198 * PPR (Parallel Protocol Request) Capable
17200 * If the device supports DT mode, then it must be PPR capable.
17201 * The PPR message will be used in place of the SDTR and WDTR
17202 * messages to negotiate synchronous speed and offset, transfer
17203 * width, and protocol options.
17205 if (ADV_INQ_CLOCKING(inq) & ADV_INQ_CLOCKING_DT_ONLY) {
17206 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE,
17207 asc_dvc->ppr_able);
17208 asc_dvc->ppr_able |= tidmask;
17209 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE,
17210 asc_dvc->ppr_able);
17215 * If the EEPROM enabled Tag Queuing for the device and the
17216 * device supports Tag Queueing, then turn on the device's
17217 * 'tagqng_enable' bit in the microcode and set the microcode
17218 * maximum command count to the ADV_DVC_VAR 'max_dvc_qng'
17221 * Tag Queuing is disabled for the BIOS which runs in polled
17222 * mode and would see no benefit from Tag Queuing. Also by
17223 * disabling Tag Queuing in the BIOS devices with Tag Queuing
17224 * bugs will at least work with the BIOS.
17226 if ((asc_dvc->tagqng_able & tidmask) && ADV_INQ_CMD_QUEUE(inq)) {
17227 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
17228 cfg_word |= tidmask;
17229 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
17232 AdvWriteByteLram(iop_base,
17233 ASC_MC_NUMBER_OF_MAX_CMD + tid,
17234 asc_dvc->max_dvc_qng);
17239 static int __devinit
17240 advansys_wide_init_chip(asc_board_t *boardp, ADV_DVC_VAR *adv_dvc_varp)
17243 adv_req_t *reqp = NULL;
17246 int warn_code, err_code;
17249 * Allocate buffer carrier structures. The total size
17250 * is about 4 KB, so allocate all at once.
17252 boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
17253 ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
17255 if (!boardp->carrp)
17256 goto kmalloc_failed;
17259 * Allocate up to 'max_host_qng' request structures for the Wide
17260 * board. The total size is about 16 KB, so allocate all at once.
17261 * If the allocation fails decrement and try again.
17263 for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
17264 reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
17266 ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
17267 "bytes %lu\n", reqp, req_cnt,
17268 (ulong)sizeof(adv_req_t) * req_cnt);
17275 goto kmalloc_failed;
17277 boardp->orig_reqp = reqp;
17280 * Allocate up to ADV_TOT_SG_BLOCK request structures for
17281 * the Wide board. Each structure is about 136 bytes.
17283 boardp->adv_sgblkp = NULL;
17284 for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
17285 sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
17290 sgp->next_sgblkp = boardp->adv_sgblkp;
17291 boardp->adv_sgblkp = sgp;
17295 ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
17296 sg_cnt, sizeof(adv_sgblk_t),
17297 (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
17299 if (!boardp->adv_sgblkp)
17300 goto kmalloc_failed;
17302 adv_dvc_varp->carrier_buf = boardp->carrp;
17305 * Point 'adv_reqp' to the request structures and
17306 * link them together.
17309 reqp[req_cnt].next_reqp = NULL;
17310 for (; req_cnt > 0; req_cnt--) {
17311 reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
17313 boardp->adv_reqp = &reqp[0];
17315 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
17316 ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
17317 warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
17318 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
17319 ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
17321 warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
17323 ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
17325 warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
17327 err_code = adv_dvc_varp->err_code;
17329 if (warn_code || err_code) {
17330 ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
17331 " error 0x%x\n", boardp->id, warn_code, err_code);
17337 ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
17338 "failed\n", boardp->id);
17339 err_code = ADV_ERROR;
17344 static void advansys_wide_free_mem(asc_board_t *boardp)
17346 kfree(boardp->carrp);
17347 boardp->carrp = NULL;
17348 kfree(boardp->orig_reqp);
17349 boardp->orig_reqp = boardp->adv_reqp = NULL;
17350 while (boardp->adv_sgblkp) {
17351 adv_sgblk_t *sgp = boardp->adv_sgblkp;
17352 boardp->adv_sgblkp = sgp->next_sgblkp;
17357 static struct Scsi_Host *__devinit
17358 advansys_board_found(int iop, struct device *dev, int bus_type)
17360 struct Scsi_Host *shost;
17361 struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
17362 asc_board_t *boardp;
17363 ASC_DVC_VAR *asc_dvc_varp = NULL;
17364 ADV_DVC_VAR *adv_dvc_varp = NULL;
17367 ADV_PADDR pci_memory_address;
17368 int warn_code, err_code;
17374 * Register the adapter, get its configuration, and
17377 ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
17378 shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
17383 /* Initialize private per board data */
17384 boardp = ASC_BOARDP(shost);
17385 memset(boardp, 0, sizeof(asc_board_t));
17386 boardp->id = asc_board_count++;
17388 /* Initialize spinlock. */
17389 spin_lock_init(&boardp->lock);
17392 * Handle both narrow and wide boards.
17394 * If a Wide board was detected, set the board structure
17395 * wide board flag. Set-up the board structure based on
17399 if (bus_type == ASC_IS_PCI &&
17400 (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
17401 pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
17402 pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
17403 boardp->flags |= ASC_IS_WIDE_BOARD;
17405 #endif /* CONFIG_PCI */
17407 if (ASC_NARROW_BOARD(boardp)) {
17408 ASC_DBG(1, "advansys_board_found: narrow board\n");
17409 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
17410 asc_dvc_varp->bus_type = bus_type;
17411 asc_dvc_varp->drv_ptr = boardp;
17412 asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
17413 asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
17414 asc_dvc_varp->iop_base = iop;
17415 asc_dvc_varp->isr_callback = asc_isr_callback;
17417 ASC_DBG(1, "advansys_board_found: wide board\n");
17418 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
17419 adv_dvc_varp->drv_ptr = boardp;
17420 adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
17421 adv_dvc_varp->isr_callback = adv_isr_callback;
17422 adv_dvc_varp->async_callback = adv_async_callback;
17424 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
17425 ASC_DBG(1, "advansys_board_found: ASC-3550\n");
17426 adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
17427 } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
17428 ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
17429 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
17431 ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
17432 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
17434 #endif /* CONFIG_PCI */
17437 * Map the board's registers into virtual memory for
17438 * PCI slave access. Only memory accesses are used to
17439 * access the board's registers.
17441 * Note: The PCI register base address is not always
17442 * page aligned, but the address passed to ioremap()
17443 * must be page aligned. It is guaranteed that the
17444 * PCI register base address will not cross a page
17447 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
17448 iolen = ADV_3550_IOLEN;
17449 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
17450 iolen = ADV_38C0800_IOLEN;
17452 iolen = ADV_38C1600_IOLEN;
17455 pci_memory_address = pci_resource_start(pdev, 1);
17457 "advansys_board_found: pci_memory_address: 0x%lx\n",
17458 (ulong)pci_memory_address);
17459 if ((boardp->ioremap_addr =
17460 ioremap(pci_memory_address & PAGE_MASK, PAGE_SIZE)) == 0) {
17462 ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
17463 boardp->id, pci_memory_address, iolen);
17466 ASC_DBG1(1, "advansys_board_found: ioremap_addr: 0x%lx\n",
17467 (ulong)boardp->ioremap_addr);
17468 adv_dvc_varp->iop_base = (AdvPortAddr)
17469 (boardp->ioremap_addr +
17470 (pci_memory_address - (pci_memory_address & PAGE_MASK)));
17471 ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
17472 adv_dvc_varp->iop_base);
17473 #endif /* CONFIG_PCI */
17476 * Even though it isn't used to access wide boards, other
17477 * than for the debug line below, save I/O Port address so
17478 * that it can be reported.
17480 boardp->ioport = iop;
17483 "advansys_board_found: iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
17484 (ushort)inp(iop + 1), (ushort)inpw(iop));
17487 #ifdef CONFIG_PROC_FS
17489 * Allocate buffer for printing information from
17490 * /proc/scsi/advansys/[0...].
17492 boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
17493 if (!boardp->prtbuf) {
17494 ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
17495 "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
17498 #endif /* CONFIG_PROC_FS */
17500 if (ASC_NARROW_BOARD(boardp)) {
17501 asc_dvc_varp->cfg->dev = dev;
17503 * Set the board bus type and PCI IRQ before
17504 * calling AscInitGetConfig().
17506 switch (asc_dvc_varp->bus_type) {
17509 shost->unchecked_isa_dma = TRUE;
17513 shost->unchecked_isa_dma = FALSE;
17517 shost->unchecked_isa_dma = FALSE;
17518 share_irq = IRQF_SHARED;
17520 #endif /* CONFIG_ISA */
17523 shost->irq = asc_dvc_varp->irq_no = pdev->irq;
17524 asc_dvc_varp->cfg->pci_slot_info =
17525 ASC_PCI_MKID(pdev->bus->number,
17526 PCI_SLOT(pdev->devfn),
17527 PCI_FUNC(pdev->devfn));
17528 shost->unchecked_isa_dma = FALSE;
17529 share_irq = IRQF_SHARED;
17531 #endif /* CONFIG_PCI */
17534 ("advansys_board_found: board %d: unknown adapter type: %d\n",
17535 boardp->id, asc_dvc_varp->bus_type);
17536 shost->unchecked_isa_dma = TRUE;
17541 adv_dvc_varp->cfg->dev = dev;
17543 * For Wide boards set PCI information before calling
17544 * AdvInitGetConfig().
17547 shost->irq = adv_dvc_varp->irq_no = pdev->irq;
17548 adv_dvc_varp->cfg->pci_slot_info =
17549 ASC_PCI_MKID(pdev->bus->number,
17550 PCI_SLOT(pdev->devfn),
17551 PCI_FUNC(pdev->devfn));
17552 shost->unchecked_isa_dma = FALSE;
17553 share_irq = IRQF_SHARED;
17554 #endif /* CONFIG_PCI */
17558 * Read the board configuration.
17560 if (ASC_NARROW_BOARD(boardp)) {
17562 * NOTE: AscInitGetConfig() may change the board's
17563 * bus_type value. The bus_type value should no
17564 * longer be used. If the bus_type field must be
17565 * referenced only use the bit-wise AND operator "&".
17567 ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
17568 switch (ret = AscInitGetConfig(asc_dvc_varp)) {
17569 case 0: /* No error */
17571 case ASC_WARN_IO_PORT_ROTATE:
17573 ("AscInitGetConfig: board %d: I/O port address modified\n",
17576 case ASC_WARN_AUTO_CONFIG:
17578 ("AscInitGetConfig: board %d: I/O port increment switch enabled\n",
17581 case ASC_WARN_EEPROM_CHKSUM:
17583 ("AscInitGetConfig: board %d: EEPROM checksum error\n",
17586 case ASC_WARN_IRQ_MODIFIED:
17588 ("AscInitGetConfig: board %d: IRQ modified\n",
17591 case ASC_WARN_CMD_QNG_CONFLICT:
17593 ("AscInitGetConfig: board %d: tag queuing enabled w/o disconnects\n",
17598 ("AscInitGetConfig: board %d: unknown warning: 0x%x\n",
17602 if ((err_code = asc_dvc_varp->err_code) != 0) {
17604 ("AscInitGetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
17606 asc_dvc_varp->init_state, asc_dvc_varp->err_code);
17609 ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
17610 if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
17612 ("AdvInitGetConfig: board %d: warning: 0x%x\n",
17615 if ((err_code = adv_dvc_varp->err_code) != 0) {
17617 ("AdvInitGetConfig: board %d error: err_code 0x%x\n",
17618 boardp->id, adv_dvc_varp->err_code);
17623 goto err_free_proc;
17626 * Save the EEPROM configuration so that it can be displayed
17627 * from /proc/scsi/advansys/[0...].
17629 if (ASC_NARROW_BOARD(boardp)) {
17634 * Set the adapter's target id bit in the 'init_tidmask' field.
17636 boardp->init_tidmask |=
17637 ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
17640 * Save EEPROM settings for the board.
17642 ep = &boardp->eep_config.asc_eep;
17644 ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
17645 ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
17646 ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
17647 ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
17648 ep->start_motor = asc_dvc_varp->start_motor;
17649 ep->cntl = asc_dvc_varp->dvc_cntl;
17650 ep->no_scam = asc_dvc_varp->no_scam;
17651 ep->max_total_qng = asc_dvc_varp->max_total_qng;
17652 ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
17653 /* 'max_tag_qng' is set to the same value for every device. */
17654 ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
17655 ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
17656 ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
17657 ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
17658 ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
17659 ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
17660 ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
17663 * Modify board configuration.
17665 ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
17666 switch (ret = AscInitSetConfig(asc_dvc_varp)) {
17667 case 0: /* No error. */
17669 case ASC_WARN_IO_PORT_ROTATE:
17671 ("AscInitSetConfig: board %d: I/O port address modified\n",
17674 case ASC_WARN_AUTO_CONFIG:
17676 ("AscInitSetConfig: board %d: I/O port increment switch enabled\n",
17679 case ASC_WARN_EEPROM_CHKSUM:
17681 ("AscInitSetConfig: board %d: EEPROM checksum error\n",
17684 case ASC_WARN_IRQ_MODIFIED:
17686 ("AscInitSetConfig: board %d: IRQ modified\n",
17689 case ASC_WARN_CMD_QNG_CONFLICT:
17691 ("AscInitSetConfig: board %d: tag queuing w/o disconnects\n",
17696 ("AscInitSetConfig: board %d: unknown warning: 0x%x\n",
17700 if (asc_dvc_varp->err_code != 0) {
17702 ("AscInitSetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
17704 asc_dvc_varp->init_state, asc_dvc_varp->err_code);
17705 goto err_free_proc;
17709 * Finish initializing the 'Scsi_Host' structure.
17711 /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
17712 if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
17713 shost->irq = asc_dvc_varp->irq_no;
17716 ADVEEP_3550_CONFIG *ep_3550;
17717 ADVEEP_38C0800_CONFIG *ep_38C0800;
17718 ADVEEP_38C1600_CONFIG *ep_38C1600;
17721 * Save Wide EEP Configuration Information.
17723 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
17724 ep_3550 = &boardp->eep_config.adv_3550_eep;
17726 ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
17727 ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
17728 ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
17729 ep_3550->termination = adv_dvc_varp->cfg->termination;
17730 ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
17731 ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
17732 ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
17733 ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
17734 ep_3550->ultra_able = adv_dvc_varp->ultra_able;
17735 ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
17736 ep_3550->start_motor = adv_dvc_varp->start_motor;
17737 ep_3550->scsi_reset_delay =
17738 adv_dvc_varp->scsi_reset_wait;
17739 ep_3550->serial_number_word1 =
17740 adv_dvc_varp->cfg->serial1;
17741 ep_3550->serial_number_word2 =
17742 adv_dvc_varp->cfg->serial2;
17743 ep_3550->serial_number_word3 =
17744 adv_dvc_varp->cfg->serial3;
17745 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
17746 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
17748 ep_38C0800->adapter_scsi_id =
17749 adv_dvc_varp->chip_scsi_id;
17750 ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
17751 ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
17752 ep_38C0800->termination_lvd =
17753 adv_dvc_varp->cfg->termination;
17754 ep_38C0800->disc_enable =
17755 adv_dvc_varp->cfg->disc_enable;
17756 ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
17757 ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
17758 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
17759 ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
17760 ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
17761 ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
17762 ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
17763 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
17764 ep_38C0800->start_motor = adv_dvc_varp->start_motor;
17765 ep_38C0800->scsi_reset_delay =
17766 adv_dvc_varp->scsi_reset_wait;
17767 ep_38C0800->serial_number_word1 =
17768 adv_dvc_varp->cfg->serial1;
17769 ep_38C0800->serial_number_word2 =
17770 adv_dvc_varp->cfg->serial2;
17771 ep_38C0800->serial_number_word3 =
17772 adv_dvc_varp->cfg->serial3;
17774 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
17776 ep_38C1600->adapter_scsi_id =
17777 adv_dvc_varp->chip_scsi_id;
17778 ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
17779 ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
17780 ep_38C1600->termination_lvd =
17781 adv_dvc_varp->cfg->termination;
17782 ep_38C1600->disc_enable =
17783 adv_dvc_varp->cfg->disc_enable;
17784 ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
17785 ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
17786 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
17787 ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
17788 ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
17789 ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
17790 ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
17791 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
17792 ep_38C1600->start_motor = adv_dvc_varp->start_motor;
17793 ep_38C1600->scsi_reset_delay =
17794 adv_dvc_varp->scsi_reset_wait;
17795 ep_38C1600->serial_number_word1 =
17796 adv_dvc_varp->cfg->serial1;
17797 ep_38C1600->serial_number_word2 =
17798 adv_dvc_varp->cfg->serial2;
17799 ep_38C1600->serial_number_word3 =
17800 adv_dvc_varp->cfg->serial3;
17804 * Set the adapter's target id bit in the 'init_tidmask' field.
17806 boardp->init_tidmask |=
17807 ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
17810 * Finish initializing the 'Scsi_Host' structure.
17812 shost->irq = adv_dvc_varp->irq_no;
17816 * Channels are numbered beginning with 0. For AdvanSys one host
17817 * structure supports one channel. Multi-channel boards have a
17818 * separate host structure for each channel.
17820 shost->max_channel = 0;
17821 if (ASC_NARROW_BOARD(boardp)) {
17822 shost->max_id = ASC_MAX_TID + 1;
17823 shost->max_lun = ASC_MAX_LUN + 1;
17825 shost->io_port = asc_dvc_varp->iop_base;
17826 boardp->asc_n_io_port = ASC_IOADR_GAP;
17827 shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
17829 /* Set maximum number of queues the adapter can handle. */
17830 shost->can_queue = asc_dvc_varp->max_total_qng;
17832 shost->max_id = ADV_MAX_TID + 1;
17833 shost->max_lun = ADV_MAX_LUN + 1;
17836 * Save the I/O Port address and length even though
17837 * I/O ports are not used to access Wide boards.
17838 * Instead the Wide boards are accessed with
17839 * PCI Memory Mapped I/O.
17841 shost->io_port = iop;
17842 boardp->asc_n_io_port = iolen;
17844 shost->this_id = adv_dvc_varp->chip_scsi_id;
17846 /* Set maximum number of queues the adapter can handle. */
17847 shost->can_queue = adv_dvc_varp->max_host_qng;
17851 * 'n_io_port' currently is one byte.
17853 * Set a value to 'n_io_port', but never referenced it because
17854 * it may be truncated.
17856 shost->n_io_port = boardp->asc_n_io_port <= 255 ?
17857 boardp->asc_n_io_port : 255;
17860 * Following v1.3.89, 'cmd_per_lun' is no longer needed
17861 * and should be set to zero.
17863 * But because of a bug introduced in v1.3.89 if the driver is
17864 * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
17865 * SCSI function 'allocate_device' will panic. To allow the driver
17866 * to work as a module in these kernels set 'cmd_per_lun' to 1.
17868 * Note: This is wrong. cmd_per_lun should be set to the depth
17869 * you want on untagged devices always.
17872 shost->cmd_per_lun = 1;
17874 shost->cmd_per_lun = 0;
17878 * Set the maximum number of scatter-gather elements the
17879 * adapter can handle.
17881 if (ASC_NARROW_BOARD(boardp)) {
17883 * Allow two commands with 'sg_tablesize' scatter-gather
17884 * elements to be executed simultaneously. This value is
17885 * the theoretical hardware limit. It may be decreased
17888 shost->sg_tablesize =
17889 (((asc_dvc_varp->max_total_qng - 2) / 2) *
17890 ASC_SG_LIST_PER_Q) + 1;
17892 shost->sg_tablesize = ADV_MAX_SG_LIST;
17896 * The value of 'sg_tablesize' can not exceed the SCSI
17897 * mid-level driver definition of SG_ALL. SG_ALL also
17898 * must not be exceeded, because it is used to define the
17899 * size of the scatter-gather table in 'struct asc_sg_head'.
17901 if (shost->sg_tablesize > SG_ALL) {
17902 shost->sg_tablesize = SG_ALL;
17905 ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
17907 /* BIOS start address. */
17908 if (ASC_NARROW_BOARD(boardp)) {
17909 shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
17910 asc_dvc_varp->bus_type);
17913 * Fill-in BIOS board variables. The Wide BIOS saves
17914 * information in LRAM that is used by the driver.
17916 AdvReadWordLram(adv_dvc_varp->iop_base,
17917 BIOS_SIGNATURE, boardp->bios_signature);
17918 AdvReadWordLram(adv_dvc_varp->iop_base,
17919 BIOS_VERSION, boardp->bios_version);
17920 AdvReadWordLram(adv_dvc_varp->iop_base,
17921 BIOS_CODESEG, boardp->bios_codeseg);
17922 AdvReadWordLram(adv_dvc_varp->iop_base,
17923 BIOS_CODELEN, boardp->bios_codelen);
17926 "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
17927 boardp->bios_signature, boardp->bios_version);
17930 "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
17931 boardp->bios_codeseg, boardp->bios_codelen);
17934 * If the BIOS saved a valid signature, then fill in
17935 * the BIOS code segment base address.
17937 if (boardp->bios_signature == 0x55AA) {
17939 * Convert x86 realmode code segment to a linear
17940 * address by shifting left 4.
17942 shost->base = ((ulong)boardp->bios_codeseg << 4);
17949 * Register Board Resources - I/O Port, DMA, IRQ
17952 /* Register DMA Channel for Narrow boards. */
17953 shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
17955 if (ASC_NARROW_BOARD(boardp)) {
17956 /* Register DMA channel for ISA bus. */
17957 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
17958 shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
17959 ret = request_dma(shost->dma_channel, "advansys");
17962 ("advansys_board_found: board %d: request_dma() %d failed %d\n",
17963 boardp->id, shost->dma_channel, ret);
17964 goto err_free_proc;
17966 AscEnableIsaDma(shost->dma_channel);
17969 #endif /* CONFIG_ISA */
17971 /* Register IRQ Number. */
17972 ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
17974 ret = request_irq(shost->irq, advansys_interrupt, share_irq,
17975 "advansys", shost);
17978 if (ret == -EBUSY) {
17980 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
17981 boardp->id, shost->irq);
17982 } else if (ret == -EINVAL) {
17984 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
17985 boardp->id, shost->irq);
17988 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
17989 boardp->id, shost->irq, ret);
17995 * Initialize board RISC chip and enable interrupts.
17997 if (ASC_NARROW_BOARD(boardp)) {
17998 ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
17999 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
18000 err_code = asc_dvc_varp->err_code;
18002 if (warn_code || err_code) {
18004 ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
18006 asc_dvc_varp->init_state, warn_code, err_code);
18009 err_code = advansys_wide_init_chip(boardp, adv_dvc_varp);
18013 goto err_free_wide_mem;
18015 ASC_DBG_PRT_SCSI_HOST(2, shost);
18017 ret = scsi_add_host(shost, dev);
18019 goto err_free_wide_mem;
18021 scsi_scan_host(shost);
18025 advansys_wide_free_mem(boardp);
18026 free_irq(shost->irq, shost);
18028 if (shost->dma_channel != NO_ISA_DMA)
18029 free_dma(shost->dma_channel);
18031 kfree(boardp->prtbuf);
18033 if (boardp->ioremap_addr)
18034 iounmap(boardp->ioremap_addr);
18036 scsi_host_put(shost);
18041 * advansys_release()
18043 * Release resources allocated for a single AdvanSys adapter.
18045 static int advansys_release(struct Scsi_Host *shost)
18047 asc_board_t *boardp;
18049 ASC_DBG(1, "advansys_release: begin\n");
18050 scsi_remove_host(shost);
18051 boardp = ASC_BOARDP(shost);
18052 free_irq(shost->irq, shost);
18053 if (shost->dma_channel != NO_ISA_DMA) {
18054 ASC_DBG(1, "advansys_release: free_dma()\n");
18055 free_dma(shost->dma_channel);
18057 if (ASC_WIDE_BOARD(boardp)) {
18058 iounmap(boardp->ioremap_addr);
18059 advansys_wide_free_mem(boardp);
18061 kfree(boardp->prtbuf);
18062 scsi_host_put(shost);
18063 ASC_DBG(1, "advansys_release: end\n");
18067 static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
18068 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
18069 0x0210, 0x0230, 0x0250, 0x0330
18072 static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
18074 PortAddr iop_base = _asc_def_iop_base[id];
18075 struct Scsi_Host *shost;
18077 if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
18078 ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
18082 ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
18083 if (!AscFindSignature(iop_base))
18085 if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
18088 shost = advansys_board_found(iop_base, dev, ASC_IS_ISA);
18092 dev_set_drvdata(dev, shost);
18096 release_region(iop_base, ASC_IOADR_GAP);
18100 static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
18102 int ioport = _asc_def_iop_base[id];
18103 advansys_release(dev_get_drvdata(dev));
18104 release_region(ioport, ASC_IOADR_GAP);
18108 static struct isa_driver advansys_isa_driver = {
18109 .probe = advansys_isa_probe,
18110 .remove = __devexit_p(advansys_isa_remove),
18112 .owner = THIS_MODULE,
18113 .name = "advansys",
18117 static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
18119 PortAddr iop_base = _asc_def_iop_base[id];
18120 struct Scsi_Host *shost;
18122 if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
18123 ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
18127 ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
18128 if (!AscFindSignature(iop_base))
18131 * I don't think this condition can actually happen, but the old
18132 * driver did it, and the chances of finding a VLB setup in 2007
18133 * to do testing with is slight to none.
18135 if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
18138 shost = advansys_board_found(iop_base, dev, ASC_IS_VL);
18142 dev_set_drvdata(dev, shost);
18146 release_region(iop_base, ASC_IOADR_GAP);
18150 static struct isa_driver advansys_vlb_driver = {
18151 .probe = advansys_vlb_probe,
18152 .remove = __devexit_p(advansys_isa_remove),
18154 .owner = THIS_MODULE,
18155 .name = "advansys",
18159 static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
18165 MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
18168 * EISA is a little more tricky than PCI; each EISA device may have two
18169 * channels, and this driver is written to make each channel its own Scsi_Host
18171 struct eisa_scsi_data {
18172 struct Scsi_Host *host[2];
18175 static int __devinit advansys_eisa_probe(struct device *dev)
18179 struct eisa_device *edev = to_eisa_device(dev);
18180 struct eisa_scsi_data *data;
18183 data = kzalloc(sizeof(*data), GFP_KERNEL);
18186 ioport = edev->base_addr + 0xc30;
18189 for (i = 0; i < 2; i++, ioport += 0x20) {
18190 if (!request_region(ioport, ASC_IOADR_GAP, "advansys")) {
18191 printk(KERN_WARNING "Region %x-%x busy\n", ioport,
18192 ioport + ASC_IOADR_GAP - 1);
18195 if (!AscFindSignature(ioport)) {
18196 release_region(ioport, ASC_IOADR_GAP);
18201 * I don't know why we need to do this for EISA chips, but
18202 * not for any others. It looks to be equivalent to
18203 * AscGetChipCfgMsw, but I may have overlooked something,
18204 * so I'm not converting it until I get an EISA board to
18208 data->host[i] = advansys_board_found(ioport, dev, ASC_IS_EISA);
18209 if (data->host[i]) {
18212 release_region(ioport, ASC_IOADR_GAP);
18219 dev_set_drvdata(dev, data);
18226 static __devexit int advansys_eisa_remove(struct device *dev)
18229 struct eisa_scsi_data *data = dev_get_drvdata(dev);
18231 for (i = 0; i < 2; i++) {
18233 struct Scsi_Host *shost = data->host[i];
18236 ioport = shost->io_port;
18237 advansys_release(shost);
18238 release_region(ioport, ASC_IOADR_GAP);
18245 static struct eisa_driver advansys_eisa_driver = {
18246 .id_table = advansys_eisa_table,
18248 .name = "advansys",
18249 .probe = advansys_eisa_probe,
18250 .remove = __devexit_p(advansys_eisa_remove),
18254 /* PCI Devices supported by this driver */
18255 static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
18256 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
18257 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18258 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
18259 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18260 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
18261 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18262 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
18263 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18264 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
18265 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18266 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
18267 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18271 MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
18273 static void __devinit advansys_set_latency(struct pci_dev *pdev)
18275 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
18276 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
18277 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
18280 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
18281 if (latency < 0x20)
18282 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
18286 static int __devinit
18287 advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
18290 struct Scsi_Host *shost;
18292 err = pci_enable_device(pdev);
18295 err = pci_request_regions(pdev, "advansys");
18297 goto disable_device;
18298 pci_set_master(pdev);
18299 advansys_set_latency(pdev);
18301 if (pci_resource_len(pdev, 0) == 0)
18304 ioport = pci_resource_start(pdev, 0);
18305 shost = advansys_board_found(ioport, &pdev->dev, ASC_IS_PCI);
18310 pci_set_drvdata(pdev, shost);
18315 pci_release_regions(pdev);
18317 pci_disable_device(pdev);
18322 static void __devexit advansys_pci_remove(struct pci_dev *pdev)
18324 advansys_release(pci_get_drvdata(pdev));
18325 pci_release_regions(pdev);
18326 pci_disable_device(pdev);
18329 static struct pci_driver advansys_pci_driver = {
18330 .name = "advansys",
18331 .id_table = advansys_pci_tbl,
18332 .probe = advansys_pci_probe,
18333 .remove = __devexit_p(advansys_pci_remove),
18336 static int __init advansys_init(void)
18340 error = isa_register_driver(&advansys_isa_driver,
18341 ASC_IOADR_TABLE_MAX_IX);
18345 error = isa_register_driver(&advansys_vlb_driver,
18346 ASC_IOADR_TABLE_MAX_IX);
18348 goto unregister_isa;
18350 error = eisa_driver_register(&advansys_eisa_driver);
18352 goto unregister_vlb;
18354 error = pci_register_driver(&advansys_pci_driver);
18356 goto unregister_eisa;
18361 eisa_driver_unregister(&advansys_eisa_driver);
18363 isa_unregister_driver(&advansys_vlb_driver);
18365 isa_unregister_driver(&advansys_isa_driver);
18370 static void __exit advansys_exit(void)
18372 pci_unregister_driver(&advansys_pci_driver);
18373 eisa_driver_unregister(&advansys_eisa_driver);
18374 isa_unregister_driver(&advansys_vlb_driver);
18375 isa_unregister_driver(&advansys_isa_driver);
18378 module_init(advansys_init);
18379 module_exit(advansys_exit);
18381 MODULE_LICENSE("GPL");