1 /*        $NetBSD: custom.h,v 1.12 2002/04/25 09:20:27 aymeric Exp $  */
2 
3 /*
4  * Mach Operating System
5  * Copyright (c) 1992 Carnegie Mellon University
6  * All Rights Reserved.
7  *
8  * Permission to use, copy, modify and distribute this software and its
9  * documentation is hereby granted, provided that both the copyright
10  * notice and this permission notice appear in all copies of the
11  * software, derivative works or modified versions, and any portions
12  * thereof, and that both notices appear in supporting documentation.
13  *
14  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17  *
18  * Carnegie Mellon requests users of this software to return to
19  *
20  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
21  *  School of Computer Science
22  *  Carnegie Mellon University
23  *  Pittsburgh PA 15213-3890
24  *
25  * any improvements or extensions that they make and grant Carnegie Mellon
26  * the rights to redistribute these changes.
27  */
28 
29 /*
30  * This is a rewrite (retype) of the Amiga's custom chip register map, based
31  * on the Hardware Reference Manual.  It is NOT based on the Amiga's
32  * hardware/custom.h.
33  */
34 
35 #ifndef _AMIGA_CUSTOM_
36 #define _AMIGA_CUSTOM_
37 
38 #ifndef _LOCORE
39 struct Custom {
40     /*** read-only registers ***/
41           unsigned short zz1;
42           unsigned short dmaconr;
43           unsigned short vposr;
44           unsigned short vhposr;
45           unsigned short zz2;
46           unsigned short joy0dat;
47           unsigned short joy1dat;
48           unsigned short clxdat;
49           unsigned short adkconr;
50           unsigned short pot0dat;
51           unsigned short pot1dat;
52           unsigned short potgor;
53           unsigned short serdatr;
54           unsigned short dskbytr;
55           unsigned short intenar;
56           unsigned short intreqr;
57 
58           /*** write-only registers ***/
59 
60           /* disk */
61           void *dskpt;
62           unsigned short dsklen;
63 
64           unsigned short zz3[2];
65           unsigned short vposw;
66           unsigned short vhposw;
67           unsigned short copcon;
68           unsigned short serdat;
69           unsigned short serper;
70           unsigned short potgo;
71           unsigned short joytest;
72           unsigned short zz4[4];
73 
74           /* blitter */
75           unsigned short bltcon0;
76           unsigned short bltcon1;
77           unsigned short bltafwm;
78           unsigned short bltalwm;
79           void *bltcpt;
80           void *bltbpt;
81           void *bltapt;
82           void *bltdpt;
83           unsigned short bltsize;
84           unsigned short zz5[3];
85           unsigned short bltcmod;
86           unsigned short bltbmod;
87           unsigned short bltamod;
88           unsigned short bltdmod;
89           unsigned short zz6[4];
90           unsigned short bltcdat;
91           unsigned short bltbdat;
92           unsigned short bltadat;
93           unsigned short zz7[3];
94           unsigned short deniseid;
95 
96           /* more disk */
97           unsigned short dsksync;
98 
99     /* copper */
100           union {
101                     void *cp;
102                     struct {
103                               unsigned short ch, cl;
104                     } cs;
105           } _cop1lc;
106 #define cop1lc      _cop1lc.cp
107 #define cop1lch     _cop1lc.cs.ch
108 #define cop1lcl     _cop1lc.cs.cl
109           union {
110                     void *cp;
111                     struct {
112                               unsigned short ch;
113                               unsigned short cl;
114                     } cs;
115           } _cop2lc;
116 #define cop2lc      _cop2lc.cp
117 #define cop2lch     _cop2lc.cs.ch
118 #define cop2lcl     _cop2lc.cs.cl
119           unsigned short copjmp1;
120           unsigned short copjmp2;
121           unsigned short copins;
122 
123           /* display parameters */
124           unsigned short diwstrt;
125           unsigned short diwstop;
126           unsigned short ddfstrt;
127           unsigned short ddfstop;
128 
129           /* control registers */
130           unsigned short dmacon;
131           unsigned short clxcon;
132           unsigned short intena;
133           unsigned short intreq;
134 
135           /* audio */
136           unsigned short adkcon;
137           struct Audio {
138                     void *lc;
139                     unsigned short len;
140                     unsigned short per;
141                     unsigned short vol;
142                     unsigned short zz[3];
143           } aud[4];
144 
145           /* display */
146           union {
147                     void *bp[6];
148                     struct {
149                               unsigned short bph;
150                               unsigned short bpl;
151                     } bs[6];
152           } _bplpt;
153 #define bplpt       _bplpt.bp
154 #define bplptl(n)   _bplpt.bs[n].bpl
155 #define bplpth(n)   _bplpt.bs[n].bph
156 
157           unsigned short zz8[4];
158           unsigned short bplcon0;
159           unsigned short bplcon1;
160           unsigned short bplcon2;
161           unsigned short zz9;
162           unsigned short bpl1mod;
163           unsigned short bpl2mod;
164           unsigned short zz10[2+6+2];
165 
166           /* sprites */
167           void *sprpt[8];
168           struct Sprite {
169                     unsigned short pos;
170                     unsigned short ctl;
171                     unsigned short data;
172                     unsigned short datb;
173           } spr[8];
174 
175           unsigned short color[32];
176           unsigned short htotal;
177           unsigned short hsstop;
178           unsigned short hbstrt;
179           unsigned short hbstop;
180           unsigned short vtotal;
181           unsigned short vsstop;
182           unsigned short vbstrt;
183           unsigned short vbstop;
184           unsigned short sprhstrt;
185           unsigned short sprhstop;
186           unsigned short bplhstrt;
187           unsigned short bplhstop;
188           unsigned short hhposw;
189           unsigned short hhposr;
190           unsigned short beamcon0;
191           unsigned short hsstrt;
192           unsigned short vsstrt;
193           unsigned short hcenter;
194           unsigned short diwhigh;       /* 1e4 */
195           unsigned short padf3[11];
196           unsigned short fmode;
197 };
198 #endif
199 
200 
201 /* Custom chips as seen by the kernel */
202 #ifdef _KERNEL
203 #ifndef _LOCORE
204 extern vaddr_t CUSTOMADDR, CUSTOMbase;
205 #define CUSTOMBASE  (0x00DFF000)        /* now just offset rel to zorro2 */
206 #endif
207 #define custom (*((volatile struct Custom *)CUSTOMbase))
208 #endif
209 
210 /* This is used for making copper lists.  */
211 #define CUSTOM_OFS(field) ((long)&((struct Custom*)0)->field)
212 
213 /* Bit definitions for dmacon and dmaconr */
214 #define DMAB_SETCLR     15
215 #define DMAB_BLTDONE    14
216 #define DMAB_BLTNZERO   13
217 #define DMAB_BLITHOG    10
218 #define DMAB_MASTER     9
219 #define DMAB_RASTER     8
220 #define DMAB_COPPER     7
221 #define DMAB_BLITTER    6
222 #define DMAB_SPRITE     5
223 #define DMAB_DISK       4
224 #define DMAB_AUD3       3
225 #define DMAB_AUD2       2
226 #define DMAB_AUD1       1
227 #define DMAB_AUD0       0
228 
229 #define DMAF_SETCLR     (1<<DMAB_SETCLR)
230 #define DMAF_BLTDONE    (1<<DMAB_BLTDONE)
231 #define DMAF_BLTNZERO   (1<<DMAB_BLTNZERO)
232 #define DMAF_BLITHOG    (1<<DMAB_BLITHOG)
233 #define DMAF_MASTER     (1<<DMAB_MASTER)
234 #define DMAF_RASTER     (1<<DMAB_RASTER)
235 #define DMAF_COPPER     (1<<DMAB_COPPER)
236 #define DMAF_BLITTER    (1<<DMAB_BLITTER)
237 #define DMAF_SPRITE     (1<<DMAB_SPRITE)
238 #define DMAF_DISK       (1<<DMAB_DISK)
239 #define DMAF_AUD3       (1<<DMAB_AUD3)
240 #define DMAF_AUD2       (1<<DMAB_AUD2)
241 #define DMAF_AUD1       (1<<DMAB_AUD1)
242 #define DMAF_AUD0       (1<<DMAB_AUD0)
243 
244 
245 
246 /* Bit definitions for intena, intenar, intreq, and intreqr */
247 #define INTB_SETCLR     15
248 #define INTB_INTEN      14
249 #define INTB_EXTER      13
250 #define INTB_DSKSYNC    12
251 #define INTB_RBF        11
252 #define INTB_AUD3       10
253 #define INTB_AUD2       9
254 #define INTB_AUD1       8
255 #define INTB_AUD0       7
256 #define INTB_BLIT       6
257 #define INTB_VERTB      5
258 #define INTB_COPER      4
259 #define INTB_PORTS      3
260 #define INTB_SOFTINT    2
261 #define INTB_DSKBLK     1
262 #define INTB_TBE        0
263 
264 #define INTF_SETCLR     (1<<INTB_SETCLR)
265 #define INTF_INTEN      (1<<INTB_INTEN)
266 #define INTF_EXTER      (1<<INTB_EXTER)
267 #define INTF_DSKSYNC    (1<<INTB_DSKSYNC)
268 #define INTF_RBF        (1<<INTB_RBF)
269 #define INTF_AUD3       (1<<INTB_AUD3)
270 #define INTF_AUD2       (1<<INTB_AUD2)
271 #define INTF_AUD1       (1<<INTB_AUD1)
272 #define INTF_AUD0       (1<<INTB_AUD0)
273 #define INTF_BLIT       (1<<INTB_BLIT)
274 #define INTF_VERTB      (1<<INTB_VERTB)
275 #define INTF_COPER      (1<<INTB_COPER)
276 #define INTF_PORTS      (1<<INTB_PORTS)
277 #define INTF_SOFTINT    (1<<INTB_SOFTINT)
278 #define INTF_DSKBLK     (1<<INTB_DSKBLK)
279 #define INTF_TBE        (1<<INTB_TBE)
280 
281 /* Bit definitions for adkcon, adkconr */
282 #define ADKB_SETCLR   15
283 #define ADKB_PRECOMP1 14
284 #define ADKB_PRECOMP0 13
285 #define ADKB_MFMPREC  12
286 #define ADKB_UARTBRK  11
287 #define ADKB_WORDSYNC 10
288 #define ADKB_MSBSYNC  9
289 #define ADKB_FAST     8
290 
291 #define ADKF_SETCLR     (1<<ADKB_SETCLR)
292 #define ADKF_PRECOMP1 (1<<ADKB_PRECOMP1)
293 #define ADKF_PRECOMP0 (1<<ADKB_PRECOMP0)
294 #define ADKF_MFMPREC  (1<<ADKB_MFMPREC)
295 #define ADKF_UARTBRK  (1<<ADKB_UARTBRK)
296 #define ADKF_WORDSYNC (1<<ADKB_WORDSYNC)
297 #define ADKF_MSBSYNC  (1<<ADKB_MSBSYNC)
298 #define ADKF_FAST     (1<<ADKB_FAST)
299 
300 #endif /* _AMIGA_CUSTOM_ */
301