Deleted Added
full compact
advansys.c (56926) advansys.c (59082)
1/*
2 * Generic driver for the Advanced Systems Inc. SCSI controllers
3 * Product specific probe and attach routines can be found in:
4 *
5 * i386/isa/adv_isa.c ABP5140, ABP542, ABP5150, ABP842, ABP852
6 * i386/eisa/adv_eisa.c ABP742, ABP752
7 * pci/adv_pci.c ABP920, ABP930, ABP930U, ABP930UA, ABP940, ABP940U,
8 * ABP940UA, ABP950, ABP960, ABP960U, ABP960UA,

--- 18 unchanged lines hidden (view full) ---

27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
1/*
2 * Generic driver for the Advanced Systems Inc. SCSI controllers
3 * Product specific probe and attach routines can be found in:
4 *
5 * i386/isa/adv_isa.c ABP5140, ABP542, ABP5150, ABP842, ABP852
6 * i386/eisa/adv_eisa.c ABP742, ABP752
7 * pci/adv_pci.c ABP920, ABP930, ABP930U, ABP930UA, ABP940, ABP940U,
8 * ABP940UA, ABP950, ABP960, ABP960U, ABP960UA,

--- 18 unchanged lines hidden (view full) ---

27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * $FreeBSD: head/sys/dev/advansys/advansys.c 56926 2000-02-01 00:43:58Z gibbs $
35 * $FreeBSD: head/sys/dev/advansys/advansys.c 59082 2000-04-07 11:32:42Z nyan $
36 */
37/*
38 * Ported from:
39 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
40 *
41 * Copyright (c) 1995-1997 Advanced System Products, Inc.
42 * All Rights Reserved.
43 *

--- 7 unchanged lines hidden (view full) ---

51#include <sys/systm.h>
52#include <sys/malloc.h>
53#include <sys/buf.h>
54#include <sys/kernel.h>
55
56#include <machine/bus_pio.h>
57#include <machine/bus.h>
58#include <machine/clock.h>
36 */
37/*
38 * Ported from:
39 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
40 *
41 * Copyright (c) 1995-1997 Advanced System Products, Inc.
42 * All Rights Reserved.
43 *

--- 7 unchanged lines hidden (view full) ---

51#include <sys/systm.h>
52#include <sys/malloc.h>
53#include <sys/buf.h>
54#include <sys/kernel.h>
55
56#include <machine/bus_pio.h>
57#include <machine/bus.h>
58#include <machine/clock.h>
59#include <machine/resource.h>
60#include <sys/bus.h>
61#include <sys/rman.h>
59
60#include <cam/cam.h>
61#include <cam/cam_ccb.h>
62#include <cam/cam_sim.h>
63#include <cam/cam_xpt_sim.h>
64#include <cam/cam_xpt_periph.h>
65#include <cam/cam_debug.h>
66
67#include <cam/scsi/scsi_all.h>
68#include <cam/scsi/scsi_message.h>
69
70#include <vm/vm.h>
71#include <vm/vm_param.h>
72#include <vm/pmap.h>
73
74#include <dev/advansys/advansys.h>
75
62
63#include <cam/cam.h>
64#include <cam/cam_ccb.h>
65#include <cam/cam_sim.h>
66#include <cam/cam_xpt_sim.h>
67#include <cam/cam_xpt_periph.h>
68#include <cam/cam_debug.h>
69
70#include <cam/scsi/scsi_all.h>
71#include <cam/scsi/scsi_message.h>
72
73#include <vm/vm.h>
74#include <vm/vm_param.h>
75#include <vm/pmap.h>
76
77#include <dev/advansys/advansys.h>
78
76u_long adv_unit;
77
78static void adv_action(struct cam_sim *sim, union ccb *ccb);
79static void adv_execute_ccb(void *arg, bus_dma_segment_t *dm_segs,
80 int nsegments, int error);
81static void adv_poll(struct cam_sim *sim);
82static void adv_run_doneq(struct adv_softc *adv);
83static struct adv_ccb_info *
84 adv_alloc_ccb_info(struct adv_softc *adv);
85static void adv_destroy_ccb_info(struct adv_softc *adv,
86 struct adv_ccb_info *cinfo);
87static __inline struct adv_ccb_info *
88 adv_get_ccb_info(struct adv_softc *adv);
89static __inline void adv_free_ccb_info(struct adv_softc *adv,
90 struct adv_ccb_info *cinfo);
91static __inline void adv_set_state(struct adv_softc *adv, adv_state state);
92static __inline void adv_clear_state(struct adv_softc *adv, union ccb* ccb);
93static void adv_clear_state_really(struct adv_softc *adv, union ccb* ccb);
94
79static void adv_action(struct cam_sim *sim, union ccb *ccb);
80static void adv_execute_ccb(void *arg, bus_dma_segment_t *dm_segs,
81 int nsegments, int error);
82static void adv_poll(struct cam_sim *sim);
83static void adv_run_doneq(struct adv_softc *adv);
84static struct adv_ccb_info *
85 adv_alloc_ccb_info(struct adv_softc *adv);
86static void adv_destroy_ccb_info(struct adv_softc *adv,
87 struct adv_ccb_info *cinfo);
88static __inline struct adv_ccb_info *
89 adv_get_ccb_info(struct adv_softc *adv);
90static __inline void adv_free_ccb_info(struct adv_softc *adv,
91 struct adv_ccb_info *cinfo);
92static __inline void adv_set_state(struct adv_softc *adv, adv_state state);
93static __inline void adv_clear_state(struct adv_softc *adv, union ccb* ccb);
94static void adv_clear_state_really(struct adv_softc *adv, union ccb* ccb);
95
95struct adv_softc *advsoftcs[NADV]; /* XXX Config should handle this */
96
97static __inline struct adv_ccb_info *
98adv_get_ccb_info(struct adv_softc *adv)
99{
100 struct adv_ccb_info *cinfo;
101 int opri;
102
103 opri = splcam();
104 if ((cinfo = SLIST_FIRST(&adv->free_ccb_infos)) != NULL) {

--- 619 unchanged lines hidden (view full) ---

724 ccb->ccb_h.status |= CAM_CMD_TIMEOUT;
725 adv_reset_bus(adv, /*initiate_reset*/TRUE);
726 }
727 adv_start_execution(adv);
728 splx(s);
729}
730
731struct adv_softc *
96static __inline struct adv_ccb_info *
97adv_get_ccb_info(struct adv_softc *adv)
98{
99 struct adv_ccb_info *cinfo;
100 int opri;
101
102 opri = splcam();
103 if ((cinfo = SLIST_FIRST(&adv->free_ccb_infos)) != NULL) {

--- 619 unchanged lines hidden (view full) ---

723 ccb->ccb_h.status |= CAM_CMD_TIMEOUT;
724 adv_reset_bus(adv, /*initiate_reset*/TRUE);
725 }
726 adv_start_execution(adv);
727 splx(s);
728}
729
730struct adv_softc *
732adv_alloc(int unit, bus_space_tag_t tag, bus_space_handle_t bsh)
731adv_alloc(device_t dev, bus_space_tag_t tag, bus_space_handle_t bsh)
733{
732{
734 struct adv_softc *adv;
735
736 if (unit >= NADV) {
737 printf("adv: unit number (%d) too high\n", unit);
738 return NULL;
739 }
733 struct adv_softc *adv = device_get_softc(dev);
740
741 /*
742 * Allocate a storage area for us
743 */
734
735 /*
736 * Allocate a storage area for us
737 */
744 if (advsoftcs[unit]) {
745 printf("adv%d: memory already allocated\n", unit);
746 return NULL;
747 }
748
749 adv = malloc(sizeof(struct adv_softc), M_DEVBUF, M_NOWAIT);
750 if (!adv) {
751 printf("adv%d: cannot malloc!\n", unit);
752 return NULL;
753 }
754 bzero(adv, sizeof(struct adv_softc));
755 LIST_INIT(&adv->pending_ccbs);
756 SLIST_INIT(&adv->free_ccb_infos);
738 LIST_INIT(&adv->pending_ccbs);
739 SLIST_INIT(&adv->free_ccb_infos);
757 advsoftcs[unit] = adv;
758 adv->unit = unit;
740 adv->dev = dev;
741 adv->unit = device_get_unit(dev);
759 adv->tag = tag;
760 adv->bsh = bsh;
761
762 return(adv);
763}
764
765void
766adv_free(struct adv_softc *adv)

--- 19 unchanged lines hidden (view full) ---

786 bus_dma_tag_destroy(adv->buffer_dmat);
787 case 2:
788 bus_dma_tag_destroy(adv->parent_dmat);
789 case 1:
790 free(adv->ccb_infos, M_DEVBUF);
791 case 0:
792 break;
793 }
742 adv->tag = tag;
743 adv->bsh = bsh;
744
745 return(adv);
746}
747
748void
749adv_free(struct adv_softc *adv)

--- 19 unchanged lines hidden (view full) ---

769 bus_dma_tag_destroy(adv->buffer_dmat);
770 case 2:
771 bus_dma_tag_destroy(adv->parent_dmat);
772 case 1:
773 free(adv->ccb_infos, M_DEVBUF);
774 case 0:
775 break;
776 }
794 free(adv, M_DEVBUF);
795}
796
797int
798adv_init(struct adv_softc *adv)
799{
800 struct adv_eeprom_config eeprom_config;
801 int checksum, i;
802 int max_sync;

--- 646 unchanged lines hidden ---
777}
778
779int
780adv_init(struct adv_softc *adv)
781{
782 struct adv_eeprom_config eeprom_config;
783 int checksum, i;
784 int max_sync;

--- 646 unchanged lines hidden ---