Home | History | Annotate | Line # | Download | only in ic
cacreg.h revision 1.2
      1  1.2  ad /*	$NetBSD: cacreg.h,v 1.2 2000/03/20 18:48:34 ad Exp $	*/
      2  1.1  ad 
      3  1.1  ad /*-
      4  1.1  ad  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  1.1  ad  * All rights reserved.
      6  1.1  ad  *
      7  1.1  ad  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  ad  * by Andy Doran.
      9  1.1  ad  *
     10  1.1  ad  * Redistribution and use in source and binary forms, with or without
     11  1.1  ad  * modification, are permitted provided that the following conditions
     12  1.1  ad  * are met:
     13  1.1  ad  * 1. Redistributions of source code must retain the above copyright
     14  1.1  ad  *    notice, this list of conditions and the following disclaimer.
     15  1.1  ad  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  ad  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  ad  *    documentation and/or other materials provided with the distribution.
     18  1.1  ad  * 3. All advertising materials mentioning features or use of this software
     19  1.1  ad  *    must display the following acknowledgement:
     20  1.1  ad  *        This product includes software developed by the NetBSD
     21  1.1  ad  *        Foundation, Inc. and its contributors.
     22  1.1  ad  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1  ad  *    contributors may be used to endorse or promote products derived
     24  1.1  ad  *    from this software without specific prior written permission.
     25  1.1  ad  *
     26  1.1  ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1  ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1  ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1  ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1  ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1  ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1  ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1  ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1  ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1  ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1  ad  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  ad  */
     38  1.1  ad 
     39  1.1  ad /*-
     40  1.1  ad  * Copyright (c) 1999 Jonathan Lemon
     41  1.1  ad  * All rights reserved.
     42  1.1  ad  *
     43  1.1  ad  * Redistribution and use in source and binary forms, with or without
     44  1.1  ad  * modification, are permitted provided that the following conditions
     45  1.1  ad  * are met:
     46  1.1  ad  * 1. Redistributions of source code must retain the above copyright
     47  1.1  ad  *    notice, this list of conditions and the following disclaimer.
     48  1.1  ad  * 2. Redistributions in binary form must reproduce the above copyright
     49  1.1  ad  *    notice, this list of conditions and the following disclaimer in the
     50  1.1  ad  *    documentation and/or other materials provided with the distribution.
     51  1.1  ad  *
     52  1.1  ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     53  1.1  ad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54  1.1  ad  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55  1.1  ad  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     56  1.1  ad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57  1.1  ad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58  1.1  ad  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59  1.1  ad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60  1.1  ad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61  1.1  ad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62  1.1  ad  * SUCH DAMAGE.
     63  1.1  ad  *
     64  1.1  ad  * FreeBSD: src/sys/dev/ida/idareg.h,v 1.2 1999/08/28 00:41:55 peter Exp
     65  1.1  ad  */
     66  1.1  ad 
     67  1.1  ad #ifndef _IC_CACREG_H_
     68  1.1  ad #define _IC_CACREG_H_
     69  1.1  ad 
     70  1.1  ad #define cac_inl(sc, port) \
     71  1.1  ad 	bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, port)
     72  1.1  ad #define cac_outl(sc, port, val) \
     73  1.1  ad 	bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, port, val)
     74  1.1  ad 
     75  1.1  ad /* Board register offsets */
     76  1.1  ad #define CAC_REG_CMD_FIFO	0x04
     77  1.1  ad #define CAC_REG_DONE_FIFO	0x08
     78  1.1  ad #define CAC_REG_INT_MASK	0x0C
     79  1.1  ad #define CAC_REG_STATUS		0x10
     80  1.1  ad #define CAC_REG_INT_PENDING	0x14
     81  1.1  ad 
     82  1.1  ad #define CAC_42REG_CMD_FIFO	0x40
     83  1.1  ad #define CAC_42REG_DONE_FIFO	0x44
     84  1.1  ad #define CAC_42REG_INT_MASK	0x34
     85  1.1  ad #define CAC_42REG_STATUS	0x30
     86  1.1  ad #define CAC_42REG_INT_PENDING	0x08
     87  1.1  ad 
     88  1.1  ad /* Interrupt mask values */
     89  1.1  ad #define CAC_INT_DISABLE		0x00
     90  1.1  ad #define CAC_INT_ENABLE		0x01
     91  1.1  ad 
     92  1.1  ad /* Command types */
     93  1.1  ad #define	CAC_CMD_GET_LOG_DRV_INFO	0x10
     94  1.1  ad #define	CAC_CMD_GET_CTRL_INFO		0x11
     95  1.1  ad #define	CAC_CMD_SENSE_DRV_STATUS	0x12
     96  1.1  ad #define	CAC_CMD_START_RECOVERY		0x13
     97  1.1  ad #define	CAC_CMD_GET_PHYS_DRV_INFO	0x15
     98  1.1  ad #define	CAC_CMD_BLINK_DRV_LEDS		0x16
     99  1.1  ad #define	CAC_CMD_SENSE_DRV_LEDS		0x17
    100  1.1  ad #define	CAC_CMD_GET_LOG_DRV_EXT		0x18
    101  1.1  ad #define	CAC_CMD_GET_CTRL_INFO		0x11
    102  1.1  ad #define CAC_CMD_READ			0x20
    103  1.1  ad #define CAC_CMD_WRITE			0x30
    104  1.1  ad #define CAC_CMD_WRITE_MEDIA		0x31
    105  1.1  ad #define CAC_CMD_GET_CONFIG		0x50
    106  1.1  ad #define CAC_CMD_SET_CONFIG		0x51
    107  1.1  ad #define CAC_CMD_FLUSH_CACHE		0xc2
    108  1.1  ad 
    109  1.1  ad /* Return status codes */
    110  1.1  ad #define CAC_RET_SOFT_ERROR		0x02
    111  1.1  ad #define CAC_RET_HARD_ERROR		0x04
    112  1.1  ad #define CAC_RET_CMD_REJECTED		0x14
    113  1.1  ad 
    114  1.1  ad struct cac_drive_info {
    115  1.2  ad 	u_int16_t	secsize;
    116  1.2  ad 	u_int32_t	secperunit;
    117  1.2  ad 	u_int16_t	ncylinders;
    118  1.2  ad 	u_int8_t	nheads;
    119  1.2  ad 	u_int8_t	signature;
    120  1.2  ad 	u_int8_t	psectors;
    121  1.2  ad 	u_int16_t	wprecomp;
    122  1.2  ad 	u_int8_t	max_acc;
    123  1.2  ad 	u_int8_t	control;
    124  1.2  ad 	u_int16_t	pcylinders;
    125  1.2  ad 	u_int8_t	ptracks;
    126  1.2  ad 	u_int16_t	landing_zone;
    127  1.2  ad 	u_int8_t	nsectors;
    128  1.2  ad 	u_int8_t	checksum;
    129  1.2  ad 	u_int8_t	mirror;
    130  1.2  ad } __attribute__((__packed__));
    131  1.1  ad 
    132  1.1  ad struct cac_controller_info {
    133  1.2  ad 	u_int8_t	num_drvs;
    134  1.2  ad 	u_int32_t	signature;
    135  1.2  ad 	u_int8_t	firm_rev[4];
    136  1.2  ad } __attribute__((__packed__));
    137  1.1  ad 
    138  1.1  ad struct cac_hdr {
    139  1.1  ad 	u_int8_t	drive;		/* logical drive */
    140  1.1  ad 	u_int8_t	priority;	/* block priority */
    141  1.1  ad 	u_int16_t	size;		/* size of request, in words */
    142  1.2  ad } __attribute__((__packed__));
    143  1.1  ad 
    144  1.1  ad struct cac_req {
    145  1.1  ad 	u_int16_t	next;		/* offset of next request */
    146  1.1  ad 	u_int8_t	command;	/* command */
    147  1.1  ad 	u_int8_t	error;		/* return error code */
    148  1.1  ad 	u_int32_t	blkno;		/* block number */
    149  1.1  ad 	u_int16_t	bcount;		/* block count */
    150  1.1  ad 	u_int8_t	sgcount;	/* number of scatter/gather entries */
    151  1.1  ad 	u_int8_t	reserved;	/* reserved */
    152  1.2  ad } __attribute__((__packed__));
    153  1.1  ad 
    154  1.1  ad struct cac_sgb {
    155  1.1  ad 	u_int32_t	length;		/* length of S/G segment */
    156  1.1  ad 	u_int32_t	addr;		/* physical address of block */
    157  1.2  ad } __attribute__((__packed__));
    158  1.1  ad 
    159  1.1  ad /*
    160  1.1  ad  * Stupid macros to deal with alignment/endianness issues.
    161  1.1  ad  */
    162  1.1  ad 
    163  1.1  ad #define CAC_GET1(x)							\
    164  1.1  ad 	(((u_char *)&(x))[0])
    165  1.1  ad #define CAC_GET2(x)							\
    166  1.1  ad 	(((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8))
    167  1.1  ad #define CAC_GET4(x)							\
    168  1.1  ad 	((((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8)) |		\
    169  1.1  ad 	(((u_char *)&(x))[0] << 16 | (((u_char *)&(x))[1] << 24)))
    170  1.1  ad 
    171  1.1  ad #endif	/* !_IC_CACREG_H_ */
    172