1 /* $NetBSD: dioreg.h,v 1.8 2011/03/06 14:51:21 tsutsui 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 * 23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 /* 37 * Register definitions for the DIO and DIO-II bus. 38 */ 39 40 /* 41 * DIO/DIO-II device registers, offsets from base of device. All 42 * registers are 8-bit. 43 */ 44 #define DIO_IDOFF 0x01 /* primary device id */ 45 #define DIO_IPLOFF 0x03 /* interrupt level */ 46 #define DIO_SECIDOFF 0x15 /* secondary device id */ 47 #define DIOII_SIZEOFF 0x101 /* device size */ 48 49 /* 50 * System physical addresses of some `special' DIO devices. 51 */ 52 #define DIO_IHPIBADDR 0x478000 /* internal HP-IB; select code 7 */ 53 54 /* 55 * DIO ranges from select codes 0-63 at physical addresses given by: 56 * 0x600000 + (sc - 32) * 0x10000 57 * DIO cards are addressed in the range 0-31 [0x600000-0x800000) for 58 * their control space and the remaining areas, [0x200000-0x400000) and 59 * [0x800000-0x1000000), are for additional space required by a card; 60 * e.g. a display framebuffer. 61 * 62 * DIO-II ranges from select codes 132-255 at physical addresses given by: 63 * 0x1000000 + (sc - 132) * 0x400000 64 * The address range of DIO-II space is thus [0x1000000-0x20000000). 65 * 66 * DIO/DIO-II space is too large to map in its entirety, instead devices 67 * are mapped into kernel virtual address space allocated from a range 68 * of EIOMAPSIZE pages (vmparam.h) starting at ``extiobase''. 69 */ 70 #define DIO_BASE 0x600000 /* start of DIO space */ 71 #define DIO_END 0x1000000 /* end of DIO space */ 72 #define DIO_DEVSIZE 0x10000 /* size of a DIO device */ 73 74 #define DIOII_BASE 0x01000000 /* start of DIO-II space */ 75 #define DIOII_END 0x20000000 /* end of DIO-II space */ 76 #define DIOII_DEVSIZE 0x00400000 /* size of a DIO-II device */ 77 78 /* 79 * Find the highest select code for a given machine; HP320 doesn't 80 * have DIO-II. 81 */ 82 #define DIO_SCMAX(machineid) ((machineid) == HP_320 ? 32 : 256) 83 84 /* 85 * Base of DIO-II select codes. 86 */ 87 #define DIOII_SCBASE 132 88 89 /* 90 * Macro that returns true if a select code lies within 91 * the select code `hole'. 92 */ 93 #define DIO_INHOLE(scode) ((scode) >= 32 && (scode) < 132) 94 95 /* 96 * Macros to determine if device is DIO or DIO-II. 97 */ 98 #define DIO_ISDIO(scode) ((scode) >= 0 && (scode) < 32) 99 #define DIO_ISDIOII(scode) ((scode) >= DIOII_SCBASE && (scode) < 256) 100 101 /* 102 * Macro to determine if device is a framebuffer, given the 103 * primary id of the device. We key off this to determine if 104 * we should look at secondary id and ignore interrupt level. 105 */ 106 #define DIO_ISFRAMEBUFFER(id) \ 107 ((id) == DIO_DEVICE_ID_FRAMEBUFFER) 108 109 /* 110 * Macro to extract primary and decondary device ids, given 111 * the base address of the device. 112 */ 113 #define DIO_ID(base) \ 114 (*((uint8_t *)((u_long)(base) + DIO_IDOFF))) 115 #define DIO_SECID(base) \ 116 (*((uint8_t *)((u_long)(base) + DIO_SECIDOFF))) 117 118 /* 119 * Macro to extract the interrupt level, given the 120 * base address of the device. 121 */ 122 #define DIO_IPL(base) \ 123 ((((*((uint8_t *)((u_long)(base) + DIO_IPLOFF))) >> 4) & 0x03) + 3) 124 125 /* 126 * Macro to compute the size of a DIO-II device's address 127 * space, given the base address of the device. 128 */ 129 #define DIOII_SIZE(base) \ 130 ((int)((*((uint8_t *)((u_long)(base) + DIOII_SIZEOFF)) + 1) \ 131 * 0x100000)) 132 133 /* 134 * Given a select code and device base address, compute 135 * the size of the DIO/DIO-II device. 136 */ 137 #define DIO_SIZE(scode, base) \ 138 (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE) 139