1999-06-24 03:33:30 +00:00
|
|
|
/*-
|
2017-11-27 14:52:40 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2000-03-08 16:16:31 +00:00
|
|
|
* Copyright (c) 1999,2000 Jonathan Lemon
|
1999-06-24 03:33:30 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1999-06-24 03:33:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* software structures for the Compaq RAID controller
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _IDAVAR_H
|
2004-01-13 11:28:21 +00:00
|
|
|
#define _IDAVAR_H
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2004-01-13 11:28:21 +00:00
|
|
|
#define ida_inb(ida, port) \
|
2012-08-27 17:24:07 +00:00
|
|
|
bus_read_1((ida)->regs, port)
|
2004-01-13 11:28:21 +00:00
|
|
|
#define ida_inw(ida, port) \
|
2012-08-27 17:24:07 +00:00
|
|
|
bus_read_2((ida)->regs, port)
|
2004-01-13 11:28:21 +00:00
|
|
|
#define ida_inl(ida, port) \
|
2012-08-27 17:24:07 +00:00
|
|
|
bus_read_4((ida)->regs, port)
|
2000-03-08 16:16:31 +00:00
|
|
|
|
2004-01-13 11:28:21 +00:00
|
|
|
#define ida_outb(ida, port, val) \
|
2012-08-27 17:24:07 +00:00
|
|
|
bus_write_1((ida)->regs, port, val)
|
2004-01-13 11:28:21 +00:00
|
|
|
#define ida_outw(ida, port, val) \
|
2012-08-27 17:24:07 +00:00
|
|
|
bus_write_2((ida)->regs, port, val)
|
2004-01-13 11:28:21 +00:00
|
|
|
#define ida_outl(ida, port, val) \
|
2012-08-27 17:24:07 +00:00
|
|
|
bus_write_4((ida)->regs, port, val)
|
2000-03-08 16:16:31 +00:00
|
|
|
|
1999-06-24 03:33:30 +00:00
|
|
|
struct ida_hdr {
|
|
|
|
u_int8_t drive; /* logical drive */
|
|
|
|
u_int8_t priority; /* block priority */
|
|
|
|
u_int16_t size; /* size of request, in words */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ida_req {
|
|
|
|
u_int16_t next; /* offset of next request */
|
|
|
|
u_int8_t command; /* command */
|
|
|
|
u_int8_t error; /* return error code */
|
|
|
|
u_int32_t blkno; /* block number */
|
|
|
|
u_int16_t bcount; /* block count */
|
|
|
|
u_int8_t sgcount; /* number of scatter/gather entries */
|
|
|
|
u_int8_t spare; /* reserved */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ida_sgb {
|
|
|
|
u_int32_t length; /* length of S/G segment */
|
|
|
|
u_int32_t addr; /* physical address of block */
|
|
|
|
};
|
|
|
|
|
2004-01-13 11:28:21 +00:00
|
|
|
#define IDA_NSEG 32 /* maximum number of segments */
|
1999-06-24 03:33:30 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* right now, this structure totals 276 bytes.
|
|
|
|
*/
|
|
|
|
struct ida_hardware_qcb {
|
|
|
|
struct ida_hdr hdr; /* 4 */
|
|
|
|
struct ida_req req; /* 12 */
|
|
|
|
struct ida_sgb seg[IDA_NSEG]; /* 256 */
|
2005-04-13 05:06:57 +00:00
|
|
|
struct ida_qcb *qcb; /* 4 - qcb backpointer */
|
1999-06-24 03:33:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
QCB_FREE = 0x0000,
|
|
|
|
QCB_ACTIVE = 0x0001, /* waiting for completion */
|
2012-08-27 17:24:07 +00:00
|
|
|
QCB_TIMEDOUT = 0x0002,
|
1999-06-24 03:33:30 +00:00
|
|
|
} qcb_state;
|
|
|
|
|
|
|
|
#define DMA_DATA_IN 0x0001
|
|
|
|
#define DMA_DATA_OUT 0x0002
|
2004-01-13 11:28:21 +00:00
|
|
|
#define IDA_COMMAND 0x0004
|
|
|
|
#define DMA_DATA_TRANSFER (DMA_DATA_IN | DMA_DATA_OUT)
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2004-01-13 11:28:21 +00:00
|
|
|
#define IDA_QCB_MAX 256
|
|
|
|
#define IDA_CONTROLLER 0 /* drive "number" for controller */
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2012-08-27 17:24:07 +00:00
|
|
|
struct ida_softc;
|
|
|
|
|
1999-06-24 03:33:30 +00:00
|
|
|
struct ida_qcb {
|
|
|
|
struct ida_hardware_qcb *hwqcb;
|
2012-08-27 17:24:07 +00:00
|
|
|
struct ida_softc *ida;
|
1999-06-24 03:33:30 +00:00
|
|
|
qcb_state state;
|
|
|
|
short flags;
|
|
|
|
union {
|
2000-05-26 02:09:24 +00:00
|
|
|
STAILQ_ENTRY(ida_qcb) stqe;
|
|
|
|
SLIST_ENTRY(ida_qcb) sle;
|
1999-06-24 03:33:30 +00:00
|
|
|
} link;
|
|
|
|
bus_dmamap_t dmamap;
|
2000-03-08 16:16:31 +00:00
|
|
|
bus_addr_t hwqcb_busaddr;
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio *buf; /* bio associated with qcb */
|
2012-08-27 17:24:07 +00:00
|
|
|
int error;
|
1999-06-24 03:33:30 +00:00
|
|
|
};
|
|
|
|
|
2000-03-08 16:16:31 +00:00
|
|
|
struct ida_access {
|
|
|
|
int (*fifo_full)(struct ida_softc *);
|
|
|
|
void (*submit)(struct ida_softc *, struct ida_qcb *);
|
|
|
|
bus_addr_t (*done)(struct ida_softc *);
|
|
|
|
int (*int_pending)(struct ida_softc *);
|
|
|
|
void (*int_enable)(struct ida_softc *, int);
|
|
|
|
};
|
|
|
|
|
1999-06-24 03:33:30 +00:00
|
|
|
/*
|
2005-04-13 05:06:57 +00:00
|
|
|
* flags for the controller
|
1999-06-24 03:33:30 +00:00
|
|
|
*/
|
2004-01-13 11:28:21 +00:00
|
|
|
#define IDA_ATTACHED 0x01 /* attached */
|
|
|
|
#define IDA_FIRMWARE 0x02 /* firmware must be started */
|
|
|
|
#define IDA_INTERRUPTS 0x04 /* interrupts enabled */
|
2012-08-27 17:24:07 +00:00
|
|
|
#define IDA_QFROZEN 0x08 /* request queue frozen */
|
1999-06-24 03:33:30 +00:00
|
|
|
|
|
|
|
struct ida_softc {
|
|
|
|
device_t dev;
|
2004-12-14 17:45:30 +00:00
|
|
|
|
|
|
|
struct callout ch;
|
2004-06-16 09:47:26 +00:00
|
|
|
struct cdev *ida_dev_t;
|
1999-06-24 03:33:30 +00:00
|
|
|
|
|
|
|
int regs_res_type;
|
|
|
|
int regs_res_id;
|
|
|
|
struct resource *regs;
|
|
|
|
|
|
|
|
int irq_res_type;
|
|
|
|
struct resource *irq;
|
|
|
|
void *ih;
|
|
|
|
|
2012-08-27 17:24:07 +00:00
|
|
|
struct mtx lock;
|
|
|
|
struct intr_config_hook ich;
|
1999-06-24 03:33:30 +00:00
|
|
|
|
|
|
|
/* various DMA tags */
|
|
|
|
bus_dma_tag_t parent_dmat;
|
|
|
|
bus_dma_tag_t buffer_dmat;
|
|
|
|
|
|
|
|
bus_dma_tag_t hwqcb_dmat;
|
|
|
|
bus_dmamap_t hwqcb_dmamap;
|
|
|
|
bus_addr_t hwqcb_busaddr;
|
|
|
|
|
|
|
|
bus_dma_tag_t sg_dmat;
|
|
|
|
|
|
|
|
int flags;
|
|
|
|
|
2004-12-14 17:45:30 +00:00
|
|
|
int qactive;
|
|
|
|
|
1999-06-24 03:33:30 +00:00
|
|
|
struct ida_hardware_qcb *hwqcbs; /* HW QCB array */
|
|
|
|
struct ida_qcb *qcbs; /* kernel QCB array */
|
2000-05-26 02:09:24 +00:00
|
|
|
SLIST_HEAD(, ida_qcb) free_qcbs;
|
|
|
|
STAILQ_HEAD(, ida_qcb) qcb_queue;
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio_queue_head bio_queue;
|
2000-03-08 16:16:31 +00:00
|
|
|
|
|
|
|
struct ida_access cmd;
|
1999-06-24 03:33:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* drive flags
|
|
|
|
*/
|
2004-01-13 11:28:21 +00:00
|
|
|
#define DRV_WRITEPROT 0x0001
|
1999-06-24 03:33:30 +00:00
|
|
|
|
2000-04-22 06:28:03 +00:00
|
|
|
struct idad_softc {
|
1999-06-24 03:33:30 +00:00
|
|
|
device_t dev;
|
|
|
|
struct ida_softc *controller;
|
2004-02-18 21:36:53 +00:00
|
|
|
struct disk *disk;
|
2000-07-27 22:24:44 +00:00
|
|
|
int drive; /* per controller */
|
|
|
|
int unit; /* global */
|
1999-06-24 03:33:30 +00:00
|
|
|
int cylinders;
|
|
|
|
int heads;
|
|
|
|
int sectors;
|
|
|
|
int secsize;
|
|
|
|
int secperunit;
|
|
|
|
int flags;
|
|
|
|
};
|
|
|
|
|
2000-03-08 16:16:31 +00:00
|
|
|
struct ida_board {
|
|
|
|
u_int32_t board;
|
|
|
|
char *desc;
|
|
|
|
struct ida_access *accessor;
|
2001-01-09 14:49:41 +00:00
|
|
|
int flags;
|
2000-03-08 16:16:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int ida_detach(device_t dev);
|
1999-06-24 03:33:30 +00:00
|
|
|
extern struct ida_softc *ida_alloc(device_t dev, struct resource *regs,
|
|
|
|
int regs_type, int regs_id, bus_dma_tag_t parent_dmat);
|
|
|
|
extern void ida_free(struct ida_softc *ida);
|
2016-05-11 17:38:09 +00:00
|
|
|
extern int ida_setup(struct ida_softc *ida);
|
1999-06-24 03:33:30 +00:00
|
|
|
extern int ida_command(struct ida_softc *ida, int command, void *data,
|
2001-02-26 22:25:30 +00:00
|
|
|
int datasize, int drive, u_int32_t pblkno, int flags);
|
2000-04-15 05:54:02 +00:00
|
|
|
extern void ida_submit_buf(struct ida_softc *ida, struct bio *bp);
|
1999-06-24 03:33:30 +00:00
|
|
|
extern void ida_intr(void *data);
|
|
|
|
|
2000-04-22 06:28:03 +00:00
|
|
|
extern void idad_intr(struct bio *bp);
|
1999-06-24 03:33:30 +00:00
|
|
|
|
|
|
|
#endif /* _IDAVAR_H */
|