First import
[xorg_rtime.git] / xorg-server-1.4 / hw / kdrive / src / vga.h
blob0615d52563e30192fce7f3d1b3e6d0fa0894e79f
1 /*
2 * Copyright © 1999 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #ifndef _VGA_H_
24 #define _VGA_H_
26 typedef unsigned long VGA32;
27 typedef unsigned short VGA16;
28 typedef unsigned char VGA8;
29 typedef int VGABOOL;
30 typedef volatile VGA8 VGAVOL8;
32 #define VGATRUE 1
33 #define VGAFALSE 0
35 typedef struct _vgaReg {
36 VGA16 id;
37 VGA8 base;
38 VGA8 len;
39 } VgaReg;
41 #define VGA_REG_NONE 0xffff
42 #define VGA_REG_END VGA_REG_NONE, 0, 0
44 typedef struct _vgaValue {
45 VGA8 save;
46 VGA8 cur;
47 VGA16 flags;
48 } VgaValue;
50 #define VGA_VALUE_VALID 1 /* value ever fetched */
51 #define VGA_VALUE_MODIFIED 2 /* value ever changed */
52 #define VGA_VALUE_DIRTY 4 /* value needs syncing */
53 #define VGA_VALUE_SAVED 8 /* value preserved */
55 typedef enum _vgaAccess {
56 VgaAccessMem, VgaAccessIo, VgaAccessIndMem, VgaAccessIndIo,
57 VgaAccessDone
58 } VgaAccess;
60 typedef struct _vgaMap {
61 VgaAccess access;
62 VGA32 port;
63 VGA8 addr; /* for Ind access; addr offset from port */
64 VGA8 value; /* for Ind access; value offset from port */
65 VGA8 index; /* for Ind access; index value */
66 } VgaMap;
68 #define VGA_UNLOCK_FIXED 1 /* dont save current value */
69 #define VGA_UNLOCK_LOCK 2 /* execute only on relock */
70 #define VGA_UNLOCK_UNLOCK 4 /* execute only on unlock */
72 typedef struct _vgaSave {
73 VGA16 first;
74 VGA16 last;
75 } VgaSave;
77 #define VGA_SAVE_END VGA_REG_NONE, VGA_REG_NONE
79 typedef struct _vgaCard {
80 void (*map) (struct _vgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write);
81 void *closure;
82 int max;
83 VgaValue *values;
84 VgaSave *saves;
85 } VgaCard;
87 VGA8
88 VgaInb (VGA16 r);
90 void
91 VgaOutb (VGA8 v, VGA16 r);
93 VGA8
94 VgaReadMemb (VGA32 addr);
96 void
97 VgaWriteMemb (VGA8 v, VGA32 addr);
99 void
100 VgaSetImm (VgaCard *card, VgaReg *reg, VGA32 value);
102 VGA32
103 VgaGetImm (VgaCard *card, VgaReg *reg);
105 void
106 VgaSet (VgaCard *card, VgaReg *reg, VGA32 value);
108 VGA32
109 VgaGet (VgaCard *card, VgaReg *reg);
111 void
112 VgaFlush (VgaCard *card);
114 void
115 VgaFill (VgaCard *card, VGA16 low, VGA16 high);
117 void
118 VgaPreserve (VgaCard *card);
120 void
121 VgaInvalidate (VgaCard *card);
123 void
124 VgaRestore (VgaCard *card);
126 void
127 VgaFinish (VgaCard *card);
129 void
130 VgaFlushReg (VgaCard *card, VgaReg *reg);
132 VGA8
133 VgaFetch (VgaCard *card, VGA16 id);
135 void
136 VgaStore (VgaCard *card, VGA16 id, VGA8 value);
138 VGA8
139 _VgaFetchInd (VGA16 port, VGA8 reg);
141 void
142 _VgaStoreInd (VGA16 port, VGA8 reg, VGA8 value);
144 #endif /* _VGA_H_ */