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