1 /* $NetBSD: podulebus_machdep.h,v 1.5 2012/05/10 10:27:10 skrll Exp $ */
2 
3 /*
4  * Copyright (c) 1995 Mark Brinicombe.
5  * Copyright (c) 1995 Brini.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *        This product includes software developed by Brini.
19  * 4. The name of the company nor the name of the author may be used to
20  *    endorse or promote products derived from this software without specific
21  *    prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  * RiscBSD kernel project
36  *
37  * podulebus.h
38  *
39  * Podule bus header file
40  *
41  * Created      : 26/04/95
42  */
43 
44 #include <sys/param.h>
45 #include <sys/bus.h>
46 #include <machine/io.h>
47 
48 /* Define the structure used to describe a podule */
49 
50 #define PODULE_DESCRIPTION_LENGTH       63
51 
52 typedef struct {
53           /* The podule header, read from the on board ROM */
54 
55           u_char flags0;
56           u_char flags1;
57           u_char reserved;
58           u_short product;
59           u_short manufacturer;
60           u_char country;
61           u_int irq_addr;
62           u_int irq_mask;
63           u_int fiq_addr;
64           u_int fiq_mask;
65 
66           /* The base addresses for this podule */
67 
68           u_int fast_base;
69           u_int medium_base;
70           u_int slow_base;
71           u_int sync_base;
72           u_int mod_base;
73           u_int easi_base;
74 
75           /* Flags */
76 
77           int podulenum;
78           int slottype;
79           int attached;
80 
81           /* Other info */
82 
83           char description[PODULE_DESCRIPTION_LENGTH + 1];
84           u_int (*read_rom)(u_int, int);
85 
86           /* podule specific information provided by podulebus */
87 
88           int interrupt;
89 
90           int dma_channel;
91           int dma_interrupt;
92 } podule_t;
93 
94 #define PODULE_FLAGS_CD       0x01
95 #define PODULE_FLAGS_IS       0x02
96 
97 #define SLOT_NONE 0x00
98 #define SLOT_POD  0x01
99 #define SLOT_NET  0x02
100 
101 typedef   int       podulebus_intr_handle_t;
102 
103 #define podulebus_attach_args podule_attach_args
104 
105 struct podule_attach_args {
106           podule_t *pa_podule;                    /* podule descriptor */
107           int pa_podule_number;                   /* podule number */
108           int pa_slottype;              /* podule slot type */
109           bus_space_tag_t pa_iot;                 /* bus space tag */
110 
111 #define pa_easi_t   pa_iot
112 #define pa_mod_t    pa_iot
113 #define pa_fast_t   pa_iot
114 #define pa_medium_t pa_iot
115 #define pa_slow_t   pa_iot
116 #define pa_sync_t   pa_iot
117 
118 #define pa_easi_base          pa_podule->easi_base
119 #define pa_mod_base pa_podule->mod_base
120 #define pa_fast_base          pa_podule->fast_base
121 #define pa_medium_base        pa_podule->medium_base
122 #define pa_slow_base          pa_podule->slow_base
123 #define pa_sync_base          pa_podule->sync_base
124 
125           podulebus_intr_handle_t pa_ih;          /* interrupt handle */
126 
127 #define pa_manufacturer       pa_podule->manufacturer
128 #define pa_product  pa_podule->product
129 #define pa_descr    pa_podule->description
130 };
131 
132 /* Useful macros */
133 
134 /* EASI space cycle control */
135 
136 
137 #define IS_PODULE(pa, man, prod)        \
138           (pa->pa_manufacturer == man && pa->pa_product == prod)
139 
140 
141 
142 #define EASI_CYCLE_TYPE_A     0x00
143 #define EASI_CYCLE_TYPE_C     0x01
144 #define set_easi_cycle_type(podule, type) \
145           IOMD_WRITE_BYTE(IOMD_ECTCR, (IOMD_READ_BYTE(IOMD_ECTCR) & ~(1 << podule)) | (1 << type))
146 
147 #ifdef _KERNEL
148 
149 /* Array of podule structures, one per possible podule */
150 
151 extern podule_t podules[MAX_PODULES + MAX_NETSLOTS];
152 
153 int matchpodule(struct podule_attach_args *pa,
154     int manufacturer, int product, int required_slot);
155 
156 void netslot_ea(uint8_t *buffer);
157 
158 extern void *podulebus_irq_establish(podulebus_intr_handle_t, int,
159     int (*)(void *), void *, struct evcnt *);
160 extern void podulebus_shift_tag(bus_space_tag_t, u_int,
161     bus_space_tag_t *);
162 
163 /* Used internally by the podulebus code */
164 extern void netslotscan(device_t);
165 extern void poduleexamine(podule_t *, device_t, int);
166 
167 #endif
168 
169 /* End of podulebus.h */
170