Deleted Added
sdiff udiff text old ( 56926 ) new ( 59082 )
full compact
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 $
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
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
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
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 *
732adv_alloc(int unit, bus_space_tag_t tag, bus_space_handle_t bsh)
733{
734 struct adv_softc *adv;
735
736 if (unit >= NADV) {
737 printf("adv: unit number (%d) too high\n", unit);
738 return NULL;
739 }
740
741 /*
742 * Allocate a storage area for us
743 */
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);
757 advsoftcs[unit] = adv;
758 adv->unit = unit;
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 }
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 ---