xref: /386bsd/usr/X386/lib/Server/drivers/vgaBank.h (revision a2142627)
1 /* $XFree86: mit/server/ddx/x386/vga256/vga/vgaBank.h,v 1.12 1993/03/27 09:05:54 dawes Exp $ */
2 /*
3  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and its
6  * documentation for any purpose is hereby granted without fee, provided that
7  * the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of Thomas Roell not be used in
10  * advertising or publicity pertaining to distribution of the software without
11  * specific, written prior permission.  Thomas Roell makes no representations
12  * about the suitability of this software for any purpose.  It is provided
13  * "as is" without express or implied warranty.
14  *
15  * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17  * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21  * PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author:  Thomas Roell, roell@informatik.tu-muenchen.de
24  *
25  * $Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vgaBank.h,v 1.1 1991/06/02 22:36:37 root Exp $
26  */
27 
28 #ifndef VGA_BANK_H
29 #define VGA_BANK_H
30 
31 extern void *vgaReadBottom;
32 extern void *vgaReadTop;
33 extern void *vgaWriteBottom;
34 extern void *vgaWriteTop;
35 extern Bool vgaReadFlag, vgaWriteFlag;
36 extern void *writeseg;
37 
38 extern void * vgaSetReadWrite();
39 extern void * vgaReadWriteNext();
40 extern void * vgaReadWritePrev();
41 extern void * vgaSetRead();
42 extern void * vgaReadNext();
43 extern void * vgaReadPrev();
44 extern void * vgaSetWrite();
45 extern void * vgaWriteNext();
46 extern void * vgaWritePrev();
47 extern void vgaSaveBank();
48 extern void vgaRestoreBank();
49 extern void vgaPushRead();
50 extern void vgaPopRead();
51 
52 
53 extern int vgaSegmentMask;
54 
55 extern void SpeedUpComputeNext(
56 #if NeedFunctionPrototypes
57     unsigned,
58     unsigned
59 #endif
60 );
61 
62 extern void SpeedUpComputePrev(
63 #if NeedFunctionPrototypes
64     unsigned,
65     unsigned
66 #endif
67 );
68 
69 extern unsigned SpeedUpRowsNext[];
70 extern unsigned SpeedUpRowsPrev[];
71 
72 
73 #ifdef __386BSD__
74 #define VGABASE 0xFF000000
75 #else
76 #define VGABASE 0xF0000000
77 #endif
78 
79 /* Clear these first -- since they are defined in mfbcustom.h */
80 #undef CHECKSCREEN
81 #undef SETRWF
82 #undef CHECKRWOF
83 #undef CHECKRWUF
84 #undef BANK_FLAG
85 #undef BANK_FLAG_BOTH
86 #undef SETR
87 #undef SETW
88 #undef SETRW
89 #undef CHECKRO
90 #undef CHECKWO
91 #undef CHECKRWO
92 #undef CHECKRU
93 #undef CHECKWU
94 #undef CHECKRWU
95 #undef NEXTR
96 #undef NEXTW
97 #undef PREVR
98 #undef PREVW
99 #undef SAVE_BANK
100 #undef RESTORE_BANK
101 #undef PUSHR
102 #undef POPR
103 
104 #define CHECKSCREEN(x) (((unsigned long)x >= VGABASE) ? TRUE : FALSE)
105 #define SETRWF(f,x) { if(f) x = vgaSetReadWrite(x); }
106 #define CHECKRWOF(f,x) { if(f && ((void *)x >= vgaWriteTop)) \
107 			  x = vgaReadWriteNext(x); }
108 #define CHECKRWUF(f,x) { if(f && ((void *)x < vgaWriteBottom)) \
109 			  x = vgaReadWritePrev(x); }
110 #define BANK_FLAG(a) \
111   vgaWriteFlag = (((unsigned long)a >= VGABASE) ? TRUE : FALSE); \
112   vgaReadFlag = FALSE;
113 
114 #define BANK_FLAG_BOTH(a,b) \
115   vgaReadFlag = (((unsigned long)a >= VGABASE) ? TRUE : FALSE); \
116   vgaWriteFlag  = (((unsigned long)b >= VGABASE) ? TRUE : FALSE);
117 
118 #define SETR(x)  { if(vgaReadFlag) x = vgaSetRead(x); }
119 #define SETW(x)  { if(vgaWriteFlag) x = vgaSetWrite(x); }
120 #define SETRW(x) { if(vgaWriteFlag) x = vgaSetReadWrite(x); }
121 #define CHECKRO(x) { if(vgaReadFlag && ((void *)x >= vgaReadTop)) \
122 			 x = vgaReadNext(x); }
123 #define CHECKRU(x) { if(vgaReadFlag && ((void *)x < vgaReadBottom)) \
124 			 x = vgaReadPrev(x); }
125 #define CHECKWO(x) { if(vgaWriteFlag && ((void *)x >= vgaWriteTop)) \
126 			 x = vgaWriteNext(x); }
127 #define CHECKWU(x) { if(vgaWriteFlag && ((void *)x < vgaWriteBottom)) \
128 			 x = vgaWritePrev(x); }
129 #define CHECKRWO(x) { if(vgaWriteFlag && ((void *)x >= vgaWriteTop)) \
130 			  x = vgaReadWriteNext(x); }
131 #define CHECKRWU(x) { if(vgaWriteFlag && ((void *)x < vgaWriteBottom)) \
132 			  x = vgaReadWritePrev(x); }
133 
134 #define NEXTR(x) { x = vgaReadNext(x);}
135 #define NEXTW(x) { x = vgaWriteNext(x); }
136 #define PREVR(x) { x = vgaReadPrev(x); }
137 #define PREVW(x) { x = vgaWritePrev(x); }
138 
139 #define SAVE_BANK()     { if (vgaWriteFlag) vgaSaveBank(); }
140 #define RESTORE_BANK()  { if (vgaWriteFlag) vgaRestoreBank(); }
141 
142 #define PUSHR()         { if(vgaWriteFlag) vgaPushRead(); }
143 #define POPR()          { if(vgaWriteFlag) vgaPopRead(); }
144 
145 
146 #endif /* VGA_BANK_H */
147