⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 megaraid.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 5 页
字号:
/*=================================================================== * *                    Linux MegaRAID device driver * * Copyright 2001  American Megatrends Inc. * *              This program is free software; you can redistribute it and/or *              modify it under the terms of the GNU General Public License *              as published by the Free Software Foundation; either version *              2 of the License, or (at your option) any later version. * * Version : v1.18 (Oct 11, 2001) * * Description: Linux device driver for LSI Logic MegaRAID controller * * Supported controllers: MegaRAID 418, 428, 438, 466, 762, 467, 471, 490 *                                      493. * History: * * Version 0.90: *     Original source contributed by Dell; integrated it into the kernel and *     cleaned up some things.  Added support for 438/466 controllers. * Version 0.91: *     Aligned mailbox area on 16-byte boundary. *     Added schedule() at the end to properly clean up. *     Made improvements for conformity to linux driver standards. * * Version 0.92: *     Added support for 2.1 kernels. *         Reads from pci_dev struct, so it's not dependent on pcibios. *         Added some missing virt_to_bus() translations. *     Added support for SMP. *         Changed global cli()'s to spinlocks for 2.1, and simulated *          spinlocks for 2.0. *     Removed setting of SA_INTERRUPT flag when requesting Irq. * * Version 0.92ac: *     Small changes to the comments/formatting. Plus a couple of *      added notes. Returned to the authors. No actual code changes *      save printk levels. *     8 Oct 98        Alan Cox <alan.cox@linux.org> * *     Merged with 2.1.131 source tree. *     12 Dec 98       K. Baranowski <kgb@knm.org.pl> * * Version 0.93: *     Added support for vendor specific ioctl commands (M_RD_IOCTL_CMD+xxh) *     Changed some fields in MEGARAID struct to better values. *     Added signature check for Rp controllers under 2.0 kernels *     Changed busy-wait loop to be time-based *     Fixed SMP race condition in isr *     Added kfree (sgList) on release *     Added #include linux/version.h to megaraid.h for hosts.h *     Changed max_id to represent max logical drives instead of targets. * * Version 0.94: *     Got rid of some excess locking/unlocking *     Fixed slight memory corruption problem while memcpy'ing into mailbox *     Changed logical drives to be reported as luns rather than targets *     Changed max_id to 16 since it is now max targets/chan again. *     Improved ioctl interface for upcoming megamgr * * Version 0.95: *     Fixed problem of queueing multiple commands to adapter; *       still has some strange problems on some setups, so still *       defaults to single.  To enable parallel commands change *       #define MULTI_IO in megaraid.h *     Changed kmalloc allocation to be done in beginning. *     Got rid of C++ style comments * * Version 0.96: *     762 fully supported. * * Version 0.97: *     Changed megaraid_command to use wait_queue. * * Version 1.00: *     Checks to see if an irq occurred while in isr, and runs through *       routine again. *     Copies mailbox to temp area before processing in isr *     Added barrier() in busy wait to fix volatility bug *     Uses separate list for freed Scbs, keeps track of cmd state *     Put spinlocks around entire queue function for now... *     Full multi-io commands working stablely without previous problems *     Added skipXX LILO option for Madrona motherboard support * * Version 1.01: *     Fixed bug in mega_cmd_done() for megamgr control commands, *       the host_byte in the result code from the scsi request to *       scsi midlayer is set to DID_BAD_TARGET when adapter's *       returned codes are 0xF0 and 0xF4. * * Version 1.02: *     Fixed the tape drive bug by extending the adapter timeout value *       for passthrough command to 60 seconds in mega_build_cmd(). * * Version 1.03: *    Fixed Madrona support. *    Changed the adapter timeout value from 60 sec in 1.02 to 10 min *      for bigger and slower tape drive. *    Added driver version printout at driver loadup time * * Version 1.04 *    Added code for 40 ld FW support. *    Added new ioctl command 0x81 to support NEW_READ/WRITE_CONFIG with *      data area greater than 4 KB, which is the upper bound for data *      tranfer through scsi_ioctl interface. *    The additional 32 bit field for 64bit address in the newly defined *      mailbox64 structure is set to 0 at this point. * * Version 1.05 *    Changed the queing implementation for handling SCBs and completed *      commands. *    Added spinlocks in the interrupt service routine to enable the driver *      function in the SMP environment. *    Fixed the problem of unnecessary aborts in the abort entry point, which *      also enables the driver to handle large amount of I/O requests for *      long duration of time. * Version 1.06 *              Intel Release * Version 1.07 *    Removed the usage of uaccess.h file for kernel versions less than *    2.0.36, as this file is not present in those versions. * * Version 108 *    Modified mega_ioctl so that 40LD megamanager would run *    Made some changes for 2.3.XX compilation , esp wait structures *    Code merge between 1.05 and 1.06 . *    Bug fixed problem with ioctl interface for concurrency between *    8ld and 40ld firwmare *    Removed the flawed semaphore logic for handling new config command *    Added support for building own scatter / gather list for big user *    mode buffers *    Added /proc file system support ,so that information is available in *    human readable format * * Version 1a08 *    Changes for IA64 kernels. Checked for CONFIG_PROC_FS flag * * Version 1b08 *    Include file changes. * Version 1b08b *    Change PCI ID value for the 471 card, use #defines when searching *    for megaraid cards. * * Version 1.10 * *      I) Changes made to make following ioctl commands work in 0x81 interface *              a)DCMD_DELETE_LOGDRV *              b)DCMD_GET_DISK_CONFIG *              c)DCMD_DELETE_DRIVEGROUP *              d)NC_SUBOP_ENQUIRY3 *              e)DCMD_CHANGE_LDNO *              f)DCMD_CHANGE_LOOPID *              g)DCMD_FC_READ_NVRAM_CONFIG *      h)DCMD_WRITE_CONFIG *      II) Added mega_build_kernel_sg function *  III)Firmware flashing option added * * Version 1.10a * *      I)Dell updates included in the source code. *              Note:   This change is not tested due to the unavailability of IA64 kernel *      and it is in the #ifdef DELL_MODIFICATION macro which is not defined * * Version 1.10b * *      I)In M_RD_IOCTL_CMD_NEW command the wrong way of copying the data *    to the user address corrected * * Version 1.10c * *      I) DCMD_GET_DISK_CONFIG opcode updated for the firmware changes. * * Version 1.11 *      I)  Version number changed from 1.10c to 1.11 *  II) DCMD_WRITE_CONFIG(0x0D) command in the driver changed from *      scatter/gather list mode to direct pointer mode.. *     Fixed bug of undesirably detecting HP onboard controllers which *       are disabled. * *      Version 1.12 (Sep 21, 2000) * *     I. Changes have been made for Dynamic DMA mapping in IA64 platform. *                To enable all these changes define M_RD_DYNAMIC_DMA_SUPPORT in megaraid.h *        II. Got rid of windows mode comments *       III. Removed unwanted code segments *    IV. Fixed bug of HP onboard controller information (commented with *                 MEGA_HP_FIX) * *      Version 1a12 *      I.      reboot notifier and new ioctl changes ported from 1c09 * *      Version 1b12 *      I.      Changes in new ioctl interface routines ( Nov 06, 2000 ) * *      Version 1c12 *      I.      Changes in new ioctl interface routines ( Nov 07, 2000 ) * *      Version 1d12 *      I.      Compilation error under kernel 2.4.0 for 32-bit machine in mega_ioctl * *      Version 1e12, 1f12 *      1.  Fixes for pci_map_single, pci_alloc_consistent along with mailbox *          alignment * *	Version 1.13beta *	Added Support for Full 64bit address space support. If firmware *	supports 64bit, it goes to 64 bit mode even on x86 32bit  *	systems. Data Corruption Issues while running on test9 kernel *	on IA64 systems. This issue not seen on test11 on x86 system * *	Version 1.13c *	1. Resolved Memory Leak when using M_RD_IOCTL_CMD interface *	2. Resolved Queuing problem when MailBox Blocks *	3. Added unregister_reboot_notifier support *  *	Version 1.13d *	Experimental changes in interfacing with the controller in ISR * *	Version 1.13e *	Fixed Broken 2.2.XX compilation changes + misc changes * *	Version 1.13f to 1.13i *	misc changes + code clean up *	Cleaned up the ioctl code and added set_mbox_xfer_addr() *	Support for START_DEV (6) * 	 *	Version 1.13j *	Moved some code to megaraid.h file, replaced some hard coded values  *      with respective macros. Changed some functions to static * *	Version 1.13k *	Only some idendation correction to 1.13j  * *	Version 1.13l , 1.13m, 1.13n, 1.13o *	Minor Identation changes + misc changes * *	Version 1.13q *	Paded the new uioctl_t MIMD structure for maintaining alignment  *	and size across 32 / 64 bit platforms *	Changed the way MIMD IOCTL interface used virt_to_bus() to use pci *	memory location * *	Version 1.13r *	2.4.xx SCSI Changes. * *	Version 1.13s *	Stats counter fixes *	Temporary fix for some 64 bit firmwares in 2.4.XX kernels * *	Version	1.13t *	Support for 64bit version of READ/WRITE/VIEW DISK CONFIG * *	Version 1.14 *	Did away with MEGADEV_IOCTL flag. It is now standard part of driver *	without need for a special #define flag *	Disabled old scsi ioctl path for kernel versions > 2.3.xx. This is due *	to the nature in which the new scsi code queues a new scsi command to  *	controller during SCSI IO Completion *	Driver now checks for sub-system vendor id before taking ownership of *	the controller * *	Version 1.14a *	Added Host re-ordering * *	Version 1.14b *	Corrected some issue which caused the older cards not to work *	 *	Version 1.14c *	IOCTL changes for not handling the non-64bit firmwares under 2.4.XX *	kernel * *	Version 1.14d *	Fixed Various MIMD Synchronization Issues *	 *	Version 1.14e *	Fixed the error handling during card initialization * *	Version 1.14f *	Multiple invocations of mimd phase I ioctl stalls the cpu. Replaced *	spinlock with semaphore(mutex) * *	Version 1.14g *	Fixed running out of scbs issues while running MIMD apps under heavy IO * *	Version 1.14g-ac - 02/03/01 *	Reformatted to Linux format so I could compare to old one and cross *	check bug fixes *	Re fixed the assorted missing 'static' cases *	Removed some unneeded version checks *	Cleaned up some of the VERSION checks in the code *	Left 2.0 support but removed 2.1.x support. *	Collected much of the compat glue into one spot * *	Version 1.14g-ac2 - 22/03/01 *	Fixed a non obvious dereference after free in the driver unload path * *	Version 1.14i *	changes for making 32bit application run on IA64 * *	Version 1.14j *	Tue Mar 13 14:27:54 EST 2001 - AM *	Changes made in the driver to be able to run applications if the *	system has memory >4GB. * * *	Version 1.14k *	Thu Mar 15 18:38:11 EST 2001 - AM * *	Firmware version check removed if subsysid==0x1111 and *	subsysvid==0x1111, since its not yet initialized. * *	changes made to correctly calculate the base in mega_findCard. * *	Driver informational messages now appear on the console as well as *	with dmesg * *	Older ioctl interface is returned failure on newer(2.4.xx) kernels. * *	Inclusion of "modversions.h" is still a debatable question. It is *	included anyway with this release. * *	Version 1.14l *	Mon Mar 19 17:39:46 EST 2001 - AM * *	Assorted changes to remove compilation error in 1.14k when compiled *	with kernel < 2.4.0 * *	Version 1.14m *	Tue Mar 27 12:09:22 EST 2001 - AM * *	Added support for extended CDBs ( > 10 bytes ) and OBDR ( One Button *	Disaster Recovery ) feature. * * *	Version 1.14n *	Tue Apr 10 14:28:13 EDT 2001 - AM * *	"modeversions.h" is no longer included in the code. *	2.4.xx style mutex initialization used for older kernels also * *	Version 1.14o *	Wed Apr 18 17:47:26 EDT 2001 - PJ * *	Before returning status for 'inquiry', we first check if request buffer *	is SG list, and then return appropriate status * *	Version 1.14p *	Wed Apr 25 13:44:48 EDT 2001 - PJ * *	SCSI result made appropriate in case of check conditions for extended *	passthru commands * *	Do not support lun >7 for physically accessed devices  * *	 *	Version 1.15 *	Thu Apr 19 09:38:38 EDT 2001 - AM * *	1.14l rollover to 1.15 - merged with main trunk after 1.15d * *	Version 1.15b *  Wed May 16 20:10:01 EDT 2001 - AM * *	"modeversions.h" is no longer included in the code. *	2.4.xx style mutex initialization used for older kernels also *	Brought in-sync with Alan's changes in 2.4.4 *	Note: 1.15a is on OBDR branch(main trunk), and is not merged with yet. * * Version 1.15c * Mon May 21 23:10:42 EDT 2001 - AM * * ioctl interface uses 2.4.x conforming pci dma calls * similar calls used for older kernels * * Version 1.15d * Wed May 30 17:30:41 EDT 2001 - AM * * NULL is not a valid first argument for pci_alloc_consistent() on * IA64(2.4.3-2.10.1). Code shuffling done in ioctl interface to get * "pci_dev" before making calls to pci interface routines. * * Version 1.16pre * Fri Jun  1 19:40:48 EDT 2001 - AM * * 1.14p and 1.15d merged * ROMB support added * * Version 1.16-pre1 * Mon Jun  4 15:01:01 EDT 2001 - AM * * Non-ROMB firmware do no DMA support 0xA9 command. Value 0xFF * (all channels are raid ) is chosen for those firmware. * * Version 1.16-pre2 * Mon Jun 11 18:15:31 EDT 2001 - AM * * Changes for boot from any logical drive * * Version 1.16 * Tue Jun 26 18:07:02 EDT 2001 - AM * * branched at 1.14p * * Check added for HP 1M/2M controllers if having firmware H.01.07 or * H.01.08. If found, disable 64 bit support since these firmware have * limitations for 64 bit addressing * * * Version 1.17 * Thu Jul 12 11:14:09 EDT 2001 - AM * * 1.16pre2 and 1.16 merged. * * init_MUTEX and init_MUTEX_LOCKED are defined in 2.2.19. Pre-processor * statements are added for them * * Linus's 2.4.7pre3 kernel introduces a new field 'max_sectors' in Scsi_Host * structure, to improve IO performance. * * * Version 1.17a * Fri Jul 13 18:44:01 EDT 2001 - AM * * Starting from kernel 2.4.x, LUN is not < 8 - following SCSI-III. So to have * our current formula working to calculate logical drive number, return * failure for LUN > 7 * * * Version 1.17b * Mon Jul 30 19:24:02 EDT 2001 - AM * * Added support for random deletion of logical drives * * Version 1.17c * Tue Sep 25 09:37:49 EDT 2001 - Atul Mukker <atulm@lsil.com> * * With single and dual channel controllers, some virtaul channels are * displayed negative. * * Version 1.17a-ac * Mon Aug 6 14:59:29 BST 2001 - "Michael Johnson" <johnsom@home.com> * * Make the HP print formatting and check for buggy firmware runtime not * ifdef dependant. * * * Version 1.17d * Thu Oct 11 10:48:45 EDT 2001 - Atul Mukker <atulm@lsil.com> * * Driver 1.17c oops when loaded without controller. * * Special case for "use_sg == 1" removed while building the scatter gather * list. * * Version 1.18 * Thu Oct 11 15:02:53 EDT 2001 - Atul Mukker <atulm@lsil.com> * * References to AMI have been changed to LSI Logic. * * * BUGS: *     Some older 2.1 kernels (eg. 2.1.90) have a bug in pci.c that *     fails to detect the controller as a pci device on the system. * *     Timeout period for upper scsi layer, i.e. SD_TIMEOUT in *     /drivers/scsi/sd.c, is too short for this controller. SD_TIMEOUT *     value must be increased to (30 * HZ) otherwise false timeouts *     will occur in the upper layer. * *     Never set skip_id. The existing PCI code the megaraid uses fails *     to properly check the vendor subid in some cases. Setting this then *     makes it steal other i960's and crashes some boxes * *     Far too many ifdefs for versions. * *===================================================================*/#include <linux/config.h>#include <linux/version.h>#include <linux/module.h>#include <linux/types.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/kernel.h>#include <linux/ioport.h>#include <linux/fcntl.h>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -