OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [mw/] [src/] [drivers/] [vgaplan4.h] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
3
 *
4
 * Header file for EGA/VGA 16 color 4 planes screen driver
5
 * Added functions for Hercules access
6
 *
7
 */
8
#define SLOWVGA         0        /* =1 for outb rather than outw instructions*/
9
 
10
#ifdef __PACIFIC__
11
#define HAVEBLIT        0
12
#else
13
#define HAVEBLIT        1       /* =0 to exclude blitting in vgaplan4 drivers*/
14
#endif
15
 
16
#if UNIX & !ELKS
17
#define HAVEFARPTR      1
18
#define FAR
19
#endif
20
 
21
#if LINUX
22
#ifdef __GLIBC__
23
#include <sys/io.h>             /* for outb def's, requires -O */
24
#else
25
#include <asm/io.h>             /* for outb def's on 2.3.x*/
26
#endif
27
#include <unistd.h>
28
#define HAVEFARPTR      1
29
#define FAR
30
#define HAVEIOPERM      1       /* has ioperm() system call*/
31
#endif
32
 
33
#if MSDOS
34
#define HAVEFARPTR      1       /* compiler has _far extension*/
35
#ifdef __PACIFIC__
36
#include <dos.h>
37
#define FAR             far
38
#else
39
#define FAR             _far
40
#endif
41
#endif
42
 
43
#if __rtems__
44
#define HAVEFARPTR      1
45
#define FAR
46
#include <i386_io.h>
47
#endif
48
 
49
#if MSDOS | ELKS
50
/* make far ptr*/
51
#define MK_FP(seg,ofs)  ((FARADDR)(((unsigned long)(seg) << 16) | (unsigned)(ofs)))
52
#define EGA_BASE        MK_FP(0xa000, 0)
53
#else
54
#define EGA_BASE        ((unsigned char *)0xa0000)
55
#endif
56
 
57
#if HAVEFARPTR
58
/* far ptr access to screen*/
59
typedef volatile unsigned char FAR * FARADDR;
60
 
61
#if _MINIX
62
/* get byte at address*/
63
extern unsigned char GETBYTE_FP(FARADDR);
64
 
65
/* put byte at address*/
66
extern void PUTBYTE_FP(FARADDR,unsigned char);
67
 
68
/* read-modify-write at address*/
69
extern void RMW_FP(FARADDR);
70
#else
71
/* get byte at address*/
72
#define GETBYTE_FP(addr)        (*(FARADDR)(addr))
73
 
74
/* put byte at address*/
75
#define PUTBYTE_FP(addr,val)    ((*(FARADDR)(addr)) = (val))
76
 
77
/* read-modify-write at address*/
78
#define RMW_FP(addr)            ((*(FARADDR)(addr)) |= 1)
79
 
80
/* or byte at address*/
81
#define ORBYTE_FP(addr,val)     ((*(FARADDR)(addr)) |= (val))
82
 
83
/* and byte at address*/
84
#define ANDBYTE_FP(addr,val)    ((*(FARADDR)(addr)) &= (val))
85
#endif
86
#else
87
 
88
/* for bcc with no _far extension*/
89
typedef unsigned long   FARADDR;
90
 
91
/* get byte at address*/
92
extern unsigned char GETBYTE_FP(FARADDR);
93
 
94
/* put byte at address*/
95
extern void PUTBYTE_FP(FARADDR,unsigned char);
96
 
97
/* read-modify-write at address*/
98
extern void RMW_FP(FARADDR);
99
 
100
/* or byte at address*/
101
extern void ORBYTE_FP(FARADDR,unsigned char);
102
 
103
/* and byte at address*/
104
extern void ANDBYTE_FP(FARADDR,unsigned char);
105
#endif
106
 
107
 
108
#if MSDOS
109
#define outb(val,port)  outp(port,val)
110
#endif
111
 
112
#if ELKS
113
#define outb(val,port)  outportb(port,val)
114
#define outw(val,port)  outport(port,val)
115
 
116
extern int  inportb(int port);
117
extern void outportb(int port,unsigned char data);
118
extern void outport(int port,int data);
119
#endif
120
 
121
/* external routines*/
122
FARADDR         int10(int ax,int bx);
123
 
124
/* external routines implementing planar ega/vga access*/
125
 
126
/* vgaplan4.c portable C, asmplan4.s asm, or ELKS asm elkplan4.c driver*/
127
int             ega_init(PSD psd);
128
void            ega_drawpixel(PSD psd,unsigned int x,unsigned int y,
129
                        MWPIXELVAL c);
130
MWPIXELVAL      ega_readpixel(PSD psd,unsigned int x,unsigned int y);
131
void            ega_drawhorzline(PSD psd,unsigned int x1,unsigned int x2,
132
                        unsigned int y,MWPIXELVAL c);
133
void            ega_drawvertline(PSD psd,unsigned int x,unsigned int y1,
134
                        unsigned int y2, MWPIXELVAL c);
135
#if HAVEBLIT
136
/* memplan4.c*/
137
void            ega_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w,
138
                        MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
139
#endif
140
 
141
/* vgainit.c - direct hw init*/
142
void            ega_hwinit(void);
143
void            ega_hwterm(void);
144
 
145
#if _MINIX
146
#define outb(v, p)      outb(p, v)
147
#define outw(v, p)      outw(p, v)
148
#endif
149
 
150
#if SLOWVGA
151
/* use outb rather than outw instructions for older, slower VGA's*/
152
 
153
/* Program the Set/Reset Register for drawing in color COLOR for write
154
   mode 0. */
155
#define set_color(c)            { outb (0, 0x3ce); outb (c, 0x3cf); }
156
 
157
/* Set the Enable Set/Reset Register. */
158
#define set_enable_sr(mask) { outb (1, 0x3ce); outb (mask, 0x3cf); }
159
 
160
/* Select the Bit Mask Register on the Graphics Controller. */
161
#define select_mask()           { outb (8, 0x3ce); }
162
 
163
/* Program the Bit Mask Register to affect only the pixels selected in
164
   MASK.  The Bit Mask Register must already have been selected with
165
   select_mask (). */
166
#define set_mask(mask)          { outb (mask, 0x3cf); }
167
 
168
#define select_and_set_mask(mask) { outb (8, 0x3ce); outb (mask, 0x3cf); }
169
 
170
/* Set the Data Rotate Register.  Bits 0-2 are rotate count, bits 3-4
171
   are logical operation (0=NOP, 1=AND, 2=OR, 3=XOR). */
172
#define set_op(op)              { outb (3, 0x3ce); outb (op, 0x3cf); }
173
 
174
/* Set the Memory Plane Write Enable register. */
175
#define set_write_planes(mask) { outb (2, 0x3c4); outb (mask, 0x3c5); }
176
 
177
/* Set the Read Map Select register. */
178
#define set_read_plane(plane)   { outb (4, 0x3ce); outb (plane, 0x3cf); }
179
 
180
/* Set the Graphics Mode Register.  The write mode is in bits 0-1, the
181
   read mode is in bit 3. */
182
#define set_mode(mode)          { outb (5, 0x3ce); outb (mode, 0x3cf); }
183
 
184
#else /* !SLOWVGA*/
185
/* use outw rather than outb instructions for new VGAs*/
186
 
187
/* Program the Set/Reset Register for drawing in color COLOR for write
188
   mode 0. */
189
#define set_color(c)            { outw ((c)<<8, 0x3ce); }
190
 
191
/* Set the Enable Set/Reset Register. */
192
#define set_enable_sr(mask)     { outw (1|((mask)<<8), 0x3ce); }
193
 
194
/* Select the Bit Mask Register on the Graphics Controller. */
195
#define select_mask()           { outb (8, 0x3ce); }
196
 
197
/* Program the Bit Mask Register to affect only the pixels selected in
198
   MASK.  The Bit Mask Register must already have been selected with
199
   select_mask (). */
200
#define set_mask(mask)          { outb (mask, 0x3cf); }
201
 
202
#define select_and_set_mask(mask) { outw (8|((mask)<<8), 0x3ce); }
203
 
204
/* Set the Data Rotate Register.  Bits 0-2 are rotate count, bits 3-4
205
   are logical operation (0=NOP, 1=AND, 2=OR, 3=XOR). */
206
#define set_op(op)              { outw (3|((op)<<8), 0x3ce); }
207
 
208
/* Set the Memory Plane Write Enable register. */
209
#define set_write_planes(mask) { outw (2|((mask)<<8), 0x3c4); }
210
 
211
/* Set the Read Map Select register. */
212
#define set_read_plane(plane)   { outw (4|((plane)<<8), 0x3ce); }
213
 
214
/* Set the Graphics Mode Register.  The write mode is in bits 0-1, the
215
   read mode is in bit 3. */
216
#define set_mode(mode)          { outw (5|((mode)<<8), 0x3ce); }
217
 
218
#endif /* SLOWVGA*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.