Subversion Repositories shark

Rev

Rev 80 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 pj 1
 
2
/* SVGAlib, Copyright 1993 Harm Hanemaayer */
3
/* VGAlib version 1.2 - (c) 1993 Tommy Frandsen */
4
/* partially copyrighted (C) 1993 by Hartmut Schirmer */
5
 
6
/* Internal definitions. */
7
 
8
#ifndef _LIBVGA_H
9
#define _LIBVGA_H
10
 
11
#include <string.h>
12
 
13
#include <stdint.h>
80 pj 14
#include "ll/sys/cdefs.h"
15
 
16
__BEGIN_DECLS
17
 
54 pj 18
//typedef unsigned int CARD32;
19
//typedef unsigned short CARD16;
20
//typedef unsigned char CARD8;
21
 
22
/* --------------------- Macro definitions shared by library modules */
23
 
24
/* VGA index register ports */
25
#define CRT_IC  0x3D4           /* CRT Controller Index - color emulation */
26
#define CRT_IM  0x3B4           /* CRT Controller Index - mono emulation */
27
#define ATT_IW  0x3C0           /* Attribute Controller Index & Data Write Register */
28
#define GRA_I   0x3CE           /* Graphics Controller Index */
29
#define SEQ_I   0x3C4           /* Sequencer Index */
30
#define PEL_IW  0x3C8           /* PEL Write Index */
31
#define PEL_IR  0x3C7           /* PEL Read Index */
32
 
33
/* VGA data register ports */
34
#define CRT_DC  0x3D5           /* CRT Controller Data Register - color emulation */
35
#define CRT_DM  0x3B5           /* CRT Controller Data Register - mono emulation */
36
#define ATT_R   0x3C1           /* Attribute Controller Data Read Register */
37
#define GRA_D   0x3CF           /* Graphics Controller Data Register */
38
#define SEQ_D   0x3C5           /* Sequencer Data Register */
39
#define MIS_R   0x3CC           /* Misc Output Read Register */
40
#define MIS_W   0x3C2           /* Misc Output Write Register */
41
#define IS1_RC  0x3DA           /* Input Status Register 1 - color emulation */
42
#define IS1_RM  0x3BA           /* Input Status Register 1 - mono emulation */
43
#define PEL_D   0x3C9           /* PEL Data Register */
44
#define PEL_MSK 0x3C6           /* PEL mask register */
45
 
46
/* 8514/MACH regs we need outside of the mach32 driver.. */
47
#define PEL8514_D       0x2ED
48
#define PEL8514_IW      0x2EC
49
#define PEL8514_IR      0x2EB
50
#define PEL8514_MSK     0x2EA
51
 
52
/* EGA-specific registers */
53
 
54
#define GRA_E0  0x3CC           /* Graphics enable processor 0 */
55
#define GRA_E1  0x3CA           /* Graphics enable processor 1 */
56
 
57
/* standard VGA indexes max counts */
58
#define CRT_C   24              /* 24 CRT Controller Registers */
59
#define ATT_C   21              /* 21 Attribute Controller Registers */
60
#define GRA_C   9               /* 9  Graphics Controller Registers */
61
#define SEQ_C   5               /* 5  Sequencer Registers */
62
#define MIS_C   1               /* 1  Misc Output Register */
63
 
64
/* VGA registers saving indexes */
65
#define CRT     0               /* CRT Controller Registers start */
66
#define ATT     (CRT+CRT_C)     /* Attribute Controller Registers start */
67
#define GRA     (ATT+ATT_C)     /* Graphics Controller Registers start */
68
#define SEQ     (GRA+GRA_C)     /* Sequencer Registers */
69
#define MIS     (SEQ+SEQ_C)     /* General Registers */
70
#define EXT     (MIS+MIS_C)     /* SVGA Extended Registers */
71
 
72
/* Shorthands for chipset (driver) specific calls */
73
#define chipset_saveregs __svgalib_driverspecs->saveregs
74
#define chipset_setregs __svgalib_driverspecs->setregs
75
#define chipset_unlock __svgalib_driverspecs->unlock
76
#define chipset_test __svgalib_driverspecs->test
77
#define chipset_setpage __svgalib_driverspecs->__svgalib_setpage
78
#define chipset_setmode __svgalib_driverspecs->setmode
79
#define chipset_modeavailable __svgalib_driverspecs->modeavailable
80
#define chipset_getmodeinfo __svgalib_driverspecs->getmodeinfo
81
#define chipset_cursor __svgalib_driverspecs->cursor
82
 
83
/* Shorthands for internal variables and functions */
84
#define CI      __svgalib_cur_info
85
#define SM      __svgalib_sparse_mem
86
#define GM      __svgalib_graph_mem
87
#define CM      __svgalib_cur_mode
88
#define VMEM    __svgalib_videomemoryused
89
#define DREP    __svgalib_driver_report
90
#define CRITICAL __svgalib_critical
91
#define COL     __svgalib_cur_color
92
#define CHIPSET __svgalib_chipset
93
#define SCREENON __svgalib_screenon
94
#define MODEX   __svgalib_modeX
95
#define MODEFLAGS __svgalib_modeflags
96
#define infotable __svgalib_infotable
97
 
98
#define SVGADRV          2
99
#define STDVGADRV        1
100
#define STDVGAMODE(mode) (chipset_modeavailable(mode) == STDVGADRV)
101
#define SVGAMODE(mode)   (chipset_modeavailable(mode) == SVGADRV)
102
 
103
#define GRAPH_BASE 0xA0000
104
#define FONT_BASE  0xA0000
105
#define GRAPH_SIZE 0x10000
106
#define FONT_SIZE  (0x2000 * 4) /* 2.0.x kernel can use 2 512 char. fonts */
107
#define GPLANE16   G640x350x16
108
 
109
/* graphics mode information */
110
struct info {
111
    int xdim;
112
    int ydim;
113
    int colors;
114
    int xbytes;
115
    int bytesperpixel;
116
};
117
 
118
/* --------------------- Variable definitions shared by library modules */
119
 
120
#define BANKED_POINTER __svgalib_banked_pointer
121
#define LINEAR_POINTER __svgalib_linear_pointer
122
#define MMIO_POINTER __svgalib_mmio_pointer
123
 
124
extern int __svgalib_CRT_I;             /* current CRT index register address */
125
extern int __svgalib_CRT_D;             /* current CRT data register address */
126
extern int __svgalib_IS1_R;             /* current input status register address */
127
extern uint8_t * BANKED_POINTER, * LINEAR_POINTER;
128
extern uint8_t *MMIO_POINTER;
129
extern uint8_t *SPARSE_MMIO;
130
extern unsigned long __svgalib_banked_mem_base, __svgalib_banked_mem_size;
131
extern unsigned long __svgalib_mmio_base, __svgalib_mmio_size;
132
extern unsigned long __svgalib_linear_mem_base, __svgalib_linear_mem_size;
133
extern unsigned long __svgalib_mmio_base, __svgalib_mmio_size;
134
extern struct info CI;          /* current video parameters */
135
extern int COL;                 /* current color            */
136
extern int CM;                  /* current video mode       */
137
extern struct info infotable[];
138
extern int SCREENON;            /* screen visible if != 0 */
139
extern unsigned long __svgalib_graph_base;
140
extern unsigned char *GM;       /* graphics memory frame */
141
extern int MODEX;               /* TRUE after vga_setmodeX() */
142
extern int MODEFLAGS;           /* copy of flags of current modeinfo->flags */
143
 
144
extern int __svgalib_mem_fd;
145
extern int __svgalib_tty_fd;
146
extern int __svgalib_nosigint;
147
extern int __svgalib_mouse_fd;
148
extern int __svgalib_kbd_fd;
149
extern int __svgalib_runinbackground;
150
extern int __svgalib_vgacolormode;
151
 
152
extern unsigned char __svgalib_novga;
153
extern unsigned char __svgalib_textprog;
154
extern unsigned char __svgalib_secondary;
155
extern unsigned char __svgalib_emulatepage;
156
extern unsigned char __svgalib_novccontrol;
157
extern unsigned char __svgalib_m_ignore_dx;
158
extern unsigned char __svgalib_m_ignore_dy;
159
extern unsigned char __svgalib_m_ignore_dz;
160
 
161
extern char *__joystick_devicenames[4];
162
 
163
extern int __svgalib_cursor_status;
164
 
165
/* --------------------- Function definitions shared by library modules */
166
 
167
extern int (*__svgalib_inmisc)(void);
168
extern void (*__svgalib_outmisc)(int);
169
extern int (*__svgalib_incrtc)(int);
170
extern void (*__svgalib_outcrtc)(int,int);
171
extern int (*__svgalib_inseq)(int);
172
extern void (*__svgalib_outseq)(int,int);
173
extern int  (*__svgalib_ingra)(int);
174
extern void (*__svgalib_outgra)(int,int);
175
extern int  (*__svgalib_inatt)(int);
176
extern void (*__svgalib_outatt)(int,int);
177
extern void (*__svgalib_attscreen)(int);
178
extern void (*__svgalib_inpal)(int,int*,int*,int*);
179
extern void (*__svgalib_outpal)(int,int,int,int);
180
extern int (*__svgalib_inis1)(void);
181
 
182
extern int __svgalib_setregs(const unsigned char *regs);
183
extern int __svgalib_saveregs(unsigned char *regs);
184
extern void __svgalib_dumpregs(const unsigned char regs[], int n);
185
extern void __svgalib_get_perm(void);
186
extern int __svgalib_getchipset(int set_chipset);
187
extern int __svgalib_name2number(char *modename);
188
extern void __svgalib_delay(void);
189
extern int __svgalib_addmode(int xdim, int ydim, int cols, int xbytes, int bytespp);
190
extern void __svgalib_waitvtactive(void);
191
extern void __svgalib_open_devconsole(void);
192
extern void (*__svgalib_mouse_eventhandler) (int, int, int, int, int, int, int);
193
extern void (*__svgalib_keyboard_eventhandler) (int, int);
194
extern void __joystick_flip_vc(int acquire);
195
extern char *__svgalib_TextProg_argv[16]; /* should be enough */
196
extern char *__svgalib_TextProg;
197
extern int __svgalib_VESA_savebitmap;
198
extern int __svgalib_VESA_textmode;
199
extern unsigned char __svgalib_vesatext;
200
extern int __svgalib_mapkeyname(const char *keyname);
201
extern void __svgalib_mouse_update_keymap(void);
202
extern int __svgalib_vgacolor(void);
203
extern void __svgalib_cursor_restore(void);
204
extern void map_mmio(void);
205
extern void map_mem(void);
206
extern void map_linear(unsigned long, unsigned long);
207
extern void unmap_linear(unsigned long);
208
extern void __svgalib_emul_setpage(int);
209
 
210
#if 0 
211
/* remove this part ? */
212
extern void __svgalib_releasevt_signal(int n);
213
extern void __svgalib_acquirevt_signal(int n);
214
#endif
215
 
216
#define gr_readb(off)           (((volatile uint8_t *)GM)[(off)])
217
#define gr_readw(off)           (*(volatile uint16_t*)((GM)+(off)))
218
#define gr_readl(off)           (*(volatile uint32_t*)((GM)+(off)))
219
#define gr_writeb(v,off)        (GM[(off)] = (v))
220
#define gr_writew(v,off)        (*(uint16_t*)((GM)+(off)) = (v))
221
#define gr_writel(v,off)        (*(uint32_t*)((GM)+(off)) = (v))
222
 
223
extern void port_out(int value, int port);
224
extern void port_outw(int value, int port);
225
extern void port_outl(int value, int port);
226
extern void port_rep_outb(unsigned char* string, int length, int port);
227
 
228
extern int port_in(int port);
229
extern int port_inw(int port);
230
extern int port_inl(int port);
231
 
232
/* Note that the arguments of outb/w are reversed compared with the */
233
/* kernel sources. The XFree86 drivers also use this format. */
234
#undef inb
235
#undef inw
236
#undef inl
237
#undef outb
238
#undef outw
239
#undef outl
240
 
241
#define inb port_in
242
#define inw port_inw
243
#define inl port_inl
244
#define outb(port, value) port_out(value, port)
245
#define outw(port, value) port_outw(value, port)
246
#define outl(port, value) port_outl(value, port)
247
 
248
/* Background things */
249
 
250
extern unsigned char *__svgalib_give_graph_red(void);
251
extern unsigned char *__svgalib_give_graph_green(void);
252
extern unsigned char *__svgalib_give_graph_blue(void);
253
 
254
#define zero_sa_mask(maskptr) memset(maskptr, 0, sizeof(sigset_t))
255
 
256
#if 1
257
 
258
#define SVGALIB_ACQUIRE_SIG SIGUSR2
259
#define SVGALIB_RELEASE_SIG SIGUSR1
260
 
261
#else
262
 
263
#define SVGALIB_ACQUIRE_SIG SIGUNUSED
264
#define SVGALIB_RELEASE_SIG SIGPROF
265
 
266
#endif
267
 
268
//#define DEBUG_TRACE
269
 
270
#ifdef DEBUG_TRACE
81 giacomo 271
#define DTP(x) cprintf x
54 pj 272
#else
273
#define DTP(x)
274
#endif
275
 
276
#ifdef DEBUG
81 giacomo 277
#define DPRINTF cprintf
54 pj 278
#else
81 giacomo 279
#define DPRINTF
54 pj 280
#endif
281
 
80 pj 282
__END_DECLS
283
 
54 pj 284
#endif /* _LIBVGA_H */
285