Home | History | Annotate | Line # | Download | only in dev
dioreg.h revision 1.1
      1 /*	$NetBSD: dioreg.h,v 1.1 1996/12/17 08:41:04 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe.
      9  *
     10  * Portions of this file are derived from software contributed to Berkeley
     11  * by the Systems Programming Group of the University of Utah Computer
     12  * Science Department.
     13  *
     14  * Redistribution and use in source and binary forms, with or without
     15  * modification, are permitted provided that the following conditions
     16  * are met:
     17  * 1. Redistributions of source code must retain the above copyright
     18  *    notice, this list of conditions and the following disclaimer.
     19  * 2. Redistributions in binary form must reproduce the above copyright
     20  *    notice, this list of conditions and the following disclaimer in the
     21  *    documentation and/or other materials provided with the distribution.
     22  * 3. All advertising materials mentioning features or use of this software
     23  *    must display the following acknowledgement:
     24  *        This product includes software developed by the NetBSD
     25  *        Foundation, Inc. and its contributors.
     26  * 4. Neither the name of The NetBSD Foundation nor the names of its
     27  *    contributors may be used to endorse or promote products derived
     28  *    from this software without specific prior written permission.
     29  *
     30  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     31  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     32  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     33  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
     34  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     35  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     36  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     37  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     38  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     39  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     40  * POSSIBILITY OF SUCH DAMAGE.
     41  */
     42 
     43 /*
     44  * Register definitions for the DIO and DIO-II bus.
     45  */
     46 
     47 /*
     48  * DIO/DIO-II device registers, offsets from base of device.  All
     49  * registers are 8-bit.
     50  */
     51 #define	DIO_IDOFF		0x01	/* primary device id */
     52 #define	DIO_IPLOFF		0x03	/* interrupt level */
     53 #define DIO_SECIDOFF		0x15	/* secondary device id */
     54 #define	DIOII_SIZEOFF		0x101	/* device size */
     55 
     56 /*
     57  * System physical addresses of some `special' DIO devices.
     58  */
     59 #define	DIO_IHPIBADDR		0x478000 /* internal HP-IB; select code 7 */
     60 
     61 /*
     62  * DIO ranges from select codes 0-63 at physical addresses given by:
     63  *	0x600000 + (sc - 32) * 0x10000
     64  * DIO cards are addressed in the range 0-31 [0x600000-0x800000) for
     65  * their control space and the remaining areas, [0x200000-0x400000) and
     66  * [0x800000-0x1000000), are for additional space required by a card;
     67  * e.g. a display framebuffer.
     68  *
     69  * DIO-II ranges from select codes 132-255 at physical addresses given by:
     70  *	0x1000000 + (sc - 132) * 0x400000
     71  * The address range of DIO-II space is thus [0x1000000-0x20000000).
     72  *
     73  * DIO/DIO-II space is too large to map in its entirety, instead devices
     74  * are mapped into kernel virtual address space allocated from a range
     75  * of EIOMAPSIZE pages (vmparam.h) starting at ``extiobase''.
     76  */
     77 #define	DIO_BASE		0x600000	/* start of DIO space */
     78 #define	DIO_END			0x1000000	/* end of DIO space */
     79 #define	DIO_DEVSIZE		0x10000		/* size of a DIO device */
     80 
     81 #define	DIOII_BASE		0x01000000	/* start of DIO-II space */
     82 #define	DIOII_END		0x20000000	/* end of DIO-II space */
     83 #define	DIOII_DEVSIZE		0x00400000	/* size of a DIO-II device */
     84 
     85 /*
     86  * Find the highest select code for a given machine; HP320 doesn't
     87  * have DIO-II.
     88  */
     89 #define	DIO_SCMAX(machineid)	((machineid) == HP_320 ? 32 : 256)
     90 
     91 /*
     92  * Macro that returns true if a select code lies within
     93  * the select code `hole'.
     94  */
     95 #define	DIO_INHOLE(scode)	((scode) >= 32 && (scode) < 132)
     96 
     97 /*
     98  * Macros to determine if device is DIO or DIO-II.
     99  */
    100 #define	DIO_ISDIO(scode)	((scode) >= 0 && (scode) < 32)
    101 #define	DIO_ISDIOII(scode)	((scode) >= 132 && (scode) < 256)
    102 
    103 /*
    104  * Macro to determine if device is a framebuffer, given the
    105  * primary id of the device.  We key off this to determine if
    106  * we should look at secondary id and ignore interrupt level.
    107  */
    108 #define	DIO_ISFRAMEBUFFER(id)		\
    109 	((id) == DIO_DEVICE_ID_FRAMEBUFFER)
    110 
    111 /*
    112  * Macro to extract primary and decondary device ids, given
    113  * the base address of the device.
    114  */
    115 #define	DIO_ID(base)			\
    116 	(*((u_int8_t *)((u_long)(base) + DIO_IDOFF)))
    117 #define	DIO_SECID(base)			\
    118 	(*((u_int8_t *)((u_long)(base) + DIO_SECIDOFF)))
    119 
    120 /*
    121  * Macro to extract the interrupt level, given the
    122  * base address of the device.
    123  */
    124 #define	DIO_IPL(base)			\
    125 	((((*((u_int8_t *)((u_long)(base) + DIO_IPLOFF))) >> 4) & 0x03) + 3)
    126 
    127 /*
    128  * Macro to compute the size of a DIO-II device's address
    129  * space, given the base address of the device.
    130  */
    131 #define DIOII_SIZE(base)		\
    132 	((int)((*((u_int8_t *)((u_long)(base) + DIOII_SIZEOFF)) + 1)	\
    133 	    * 0x100000))
    134 
    135 /*
    136  * Given a select code and device base address, compute
    137  * the size of the DIO/DIO-II device.
    138  */
    139 #define	DIO_SIZE(scode, base)		\
    140 	(DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
    141