dioreg.h revision 1.4 1 /* $NetBSD: dioreg.h,v 1.4 1997/10/09 09:06:52 jtc 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 FOUNDATION OR CONTRIBUTORS
34 * BE 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 * Base of DIO-II select codes.
93 */
94 #define DIOII_SCBASE 132
95
96 /*
97 * Macro that returns true if a select code lies within
98 * the select code `hole'.
99 */
100 #define DIO_INHOLE(scode) ((scode) >= 32 && (scode) < 132)
101
102 /*
103 * Macros to determine if device is DIO or DIO-II.
104 */
105 #define DIO_ISDIO(scode) ((scode) >= 0 && (scode) < 32)
106 #define DIO_ISDIOII(scode) ((scode) >= DIOII_SCBASE && (scode) < 256)
107
108 /*
109 * Macro to determine if device is a framebuffer, given the
110 * primary id of the device. We key off this to determine if
111 * we should look at secondary id and ignore interrupt level.
112 */
113 #define DIO_ISFRAMEBUFFER(id) \
114 ((id) == DIO_DEVICE_ID_FRAMEBUFFER)
115
116 /*
117 * Macro to extract primary and decondary device ids, given
118 * the base address of the device.
119 */
120 #define DIO_ID(base) \
121 (*((u_int8_t *)((u_long)(base) + DIO_IDOFF)))
122 #define DIO_SECID(base) \
123 (*((u_int8_t *)((u_long)(base) + DIO_SECIDOFF)))
124
125 /*
126 * Macro to extract the interrupt level, given the
127 * base address of the device.
128 */
129 #define DIO_IPL(base) \
130 ((((*((u_int8_t *)((u_long)(base) + DIO_IPLOFF))) >> 4) & 0x03) + 3)
131
132 /*
133 * Macro to compute the size of a DIO-II device's address
134 * space, given the base address of the device.
135 */
136 #define DIOII_SIZE(base) \
137 ((int)((*((u_int8_t *)((u_long)(base) + DIOII_SIZEOFF)) + 1) \
138 * 0x100000))
139
140 /*
141 * Given a select code and device base address, compute
142 * the size of the DIO/DIO-II device.
143 */
144 #define DIO_SIZE(scode, base) \
145 (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
146