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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [drivers/] [scr_bios.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
/*
2
 * Copyright (c) 1999, 2000, 2002 Greg Haerr <greg@censoft.com>
3
 *
4
 * EGA/VGA 16 color 4 planes Screen Driver, direct hardware or bios
5
 *      If HWINIT 1 is #defined, the file vgainit.c is
6
 *      used to provide non-bios direct hw initialization of the VGA
7
 *      chipset.  Otherwise, this driver uses int10 bios to
8
 *      set/reset graphics/text modes.
9
 *
10
 *      If ROMFONT is #defined, the file romfont.c is used to
11
 *      draw all fonts, afte the bios is called to
12
 *      get the address of the ROM character font which
13
 *      is used for the character bitmaps.  Otherwise, the
14
 *      file genfont.c is used to draw linked in fonts, without
15
 *      consulting the bios.
16
 *
17
 *      All other access to the hardware is controlled through this driver.
18
 *
19
 *      Blitting enabled with #define HAVEBLIT in vgaplan4.h
20
 *
21
 *      This driver links with one of two other files, vgaplan4.c,
22
 *      the portable VGA 4 planes 16 color driver, or asmplan4.s, which
23
 *      is 8086 assembly language for speed.  This file itself
24
 *      doesn't know about any planar or packed arrangement, relying soley
25
 *      on the following external routines for all graphics drawing:
26
 *              ega_init, ega_drawpixel, ega_readpixel,
27
 *              ega_drawhorzline, ega_drawvertline
28
 *
29
 *      All text/font drawing code is based on the above routines and
30
 *      the included entry points for getting the ROM bitmap data.
31
 *
32
 *      If the environment variable EGAMODE is set, the driver implements
33
 *      the EGA 640x350 (mode 10h) resolution, otherwise 640x480 (mode 12h)
34
 *      graphics mode is set.
35
 *
36
 *      The environment variable CHARHEIGHT if set will set the assumed rom
37
 *      font character height, which defaults to 14.
38
 *
39
 */
40
#if _MINIX
41
#include <fcntl.h>
42
#include <unistd.h>
43
#include <string.h>
44
#include <ibm/int86.h>
45
#include <sys/ioctl.h>
46
#define HWINIT          0        /* =1 for non-bios direct hardware init*/
47
#define ROMFONT         0        /* =0 no bios rom fonts available*/
48
#else
49
#ifdef __rtems__
50
#define HWINIT          1       /* =1 for non-bios direct hardware init*/
51
#define ROMFONT         0        /* =0 no bios rom fonts available*/
52
#else
53
#ifdef __ECOS
54
#define HWINIT      1
55
#define ROMFONT     0
56
#else
57
#define HWINIT          0        /* =1 for non-bios direct hardware init*/
58
#define ROMFONT         1       /* =1 uses PC rom fonts */
59
#endif
60
#endif
61
#endif
62
 
63
#if ELKS
64
#include <linuxmt/ntty.h>
65
#endif
66
#include <stdio.h>
67
#include <stdlib.h>
68
#include "device.h"
69
#include "vgaplan4.h"
70
#if ROMFONT
71
#include "romfont.h"
72
#else
73
#include "genfont.h"
74
#endif
75
#include "genmem.h"
76
#include "fb.h"
77
 
78
/* VGA driver entry points*/
79
static PSD  VGA_open(PSD psd);
80
static void VGA_close(PSD psd);
81
#if _MINIX
82
static void VGA_getscreeninfo(PSD psd,PMWSCREENINFO psi);
83
#else
84
static void VGA_getscreeninfo(PSD psd,PMWSCREENINFO psi);;
85
#endif
86
static void VGA_setpalette(PSD psd,int first,int count,MWPALENTRY *pal);
87
static MWBOOL VGA_mapmemgc(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,
88
                int linelen,int size,void *addr);
89
static void NULL_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w,
90
                MWCOORD h, PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op) {}
91
static PSD  NULL_allocatememgc(PSD psd) { return NULL; }
92
static MWBOOL NULL_mapmemgc(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,
93
                        int linelen,int size,void *addr) { return 0; }
94
static void NULL_freememgc(PSD mempsd) {}
95
 
96
SCREENDEVICE    scrdev = {
97
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL,
98
        VGA_open,
99
        VGA_close,
100
        VGA_getscreeninfo,
101
        VGA_setpalette,
102
        ega_drawpixel,
103
        ega_readpixel,
104
        ega_drawhorzline,
105
        ega_drawvertline,
106
        gen_fillrect,
107
#if ROMFONT
108
        pcrom_fonts,
109
#else
110
        gen_fonts,
111
#endif
112
#if HAVEBLIT
113
        ega_blit,               /* Blit*/
114
#else
115
        NULL_blit,              /* Blit*/
116
#endif
117
        NULL,                   /* PreSelect*/
118
        NULL,                   /* DrawArea*/
119
        NULL,                   /* SetIOPermissions*/
120
        gen_allocatememgc,
121
        VGA_mapmemgc,
122
        gen_freememgc
123
};
124
 
125
/* operating mode*/
126
static MWBOOL VGAMODE = TRUE;   /* ega or vga screen rows*/
127
 
128
/* int10 functions*/
129
#define FNGR640x480     0x0012  /* function for graphics mode 640x480x16*/
130
#define FNGR640x350     0x0010  /* function for graphics mode 640x350x16*/
131
#define FNTEXT          0x0003  /* function for 80x25 text mode*/
132
 
133
#if _MINIX
134
FARADDR int10(int mode, int z)
135
{
136
int fd;
137
struct mio_int86 mint86;
138
 
139
   fd = open("/dev/mem", O_RDONLY);
140
   memset(&mint86, 0, sizeof(mint86));
141
   ioctl(fd, MIOCINT86, &mint86);
142
   mint86.reg86.b.intno = 0x10;
143
   mint86.reg86.b.al = mode & 0xFF;
144
   ioctl(fd, MIOCINT86, &mint86);
145
   close(fd);
146
}
147
#endif
148
 
149
static PSD
150
VGA_open(PSD psd)
151
{
152
#if _MINIX
153
int s;
154
struct mio_ldt86 mldt86;
155
struct segdesc_s {              /* segment descriptor for protected mode */
156
        u16_t limit_low;
157
        u16_t base_low;
158
        u8_t base_middle;
159
        u8_t access;                  /* |P|DL|1|X|E|R|A| */
160
        u8_t granularity;             /* |G|X|0|A|LIMT| */
161
        u8_t base_high;
162
} *dp;
163
int fd;
164
unsigned long vidmem = 0xA0000;
165
 
166
        fd = open("/dev/mem", O_RDONLY);
167
        dp = (struct segdesc_s *) mldt86.entry;
168
        mldt86.idx = 1;
169
        s = ioctl(fd, MIOCGLDT86, &mldt86);
170
        dp->limit_low    = 0xFFFF;
171
        dp->base_low     = (vidmem >>  0) & 0xFFFF;
172
        dp->base_middle  = (vidmem >> 16) & 0xFF;
173
        dp->base_high    = (vidmem >> 24) & 0xFF;
174
        dp->granularity |= 0x80;
175
        mldt86.idx = 2;
176
        s = ioctl(fd, MIOCSLDT86, &mldt86);
177
        close(fd);
178
#endif
179
        /* setup operating mode from environment variable*/
180
        if(getenv("EGAMODE"))
181
                VGAMODE = FALSE;
182
        else VGAMODE = TRUE;
183
 
184
#if ELKS
185
        /* disallow console switching while in graphics mode*/
186
        if(ioctl(0, DCGET_GRAPH) != 0)
187
                return NULL;
188
#endif
189
 
190
#if HWINIT
191
        /* enter graphics mode*/
192
        ega_hwinit();
193
#else
194
        /* init bios graphics mode*/
195
        int10(VGAMODE? FNGR640x480: FNGR640x350, 0);
196
#endif
197
 
198
        /* init driver variables depending on ega/vga mode*/
199
        psd->xres = psd->xvirtres = 640;
200
        psd->yres = psd->yvirtres = VGAMODE? 480: 350;
201
        psd->planes = 4;
202
        psd->bpp = 4;
203
        psd->ncolors = 16;
204
        psd->pixtype = MWPF_PALETTE;
205
#if HAVEBLIT
206
        psd->flags = PSF_SCREEN | PSF_HAVEBLIT;
207
#else
208
        psd->flags = PSF_SCREEN;
209
#endif
210
 
211
        /* init planes driver (sets psd->addr and psd->linelen)*/
212
        ega_init(psd);
213
 
214
#if ROMFONT
215
        /* init pc rom font routines*/
216
        pcrom_init(psd);
217
#endif
218
#if 0
219
        ROM_CHAR_HEIGHT = VGAMODE? 16: 14;
220
#endif
221
        /* FIXME: add palette code*/
222
        return psd;
223
}
224
 
225
static void
226
VGA_close(PSD psd)
227
{
228
#if ELKS
229
        /* allow console switching again*/
230
        ioctl(0, DCREL_GRAPH);
231
#endif
232
#if HWINIT
233
        ega_hwterm();
234
#else
235
        /* init bios 80x25 text mode*/
236
        int10(FNTEXT, 0);
237
#endif
238
}
239
 
240
static void
241
VGA_getscreeninfo(PSD psd,PMWSCREENINFO psi)
242
{
243
        psi->rows = psd->yvirtres;
244
        psi->cols = psd->xvirtres;
245
        psi->planes = psd->planes;
246
        psi->bpp = psd->bpp;
247
        psi->ncolors = psd->ncolors;
248
        psi->pixtype = psd->pixtype;
249
        psi->fonts = NUMBER_FONTS;
250
 
251
        if(VGAMODE) {
252
                /* VGA 640x480*/
253
                psi->xdpcm = 27;        /* assumes screen width of 24 cm*/
254
                psi->ydpcm = 27;        /* assumes screen height of 18 cm*/
255
        } else {
256
                /* EGA 640x350*/
257
                psi->xdpcm = 27;        /* assumes screen width of 24 cm*/
258
                psi->ydpcm = 19;        /* assumes screen height of 18 cm*/
259
        }
260
 
261
#if ETA4000
262
        /* SVGA 800x600*/
263
        psi->xdpcm = 33;                /* assumes screen width of 24 cm*/
264
        psi->ydpcm = 33;                /* assumes screen height of 18 cm*/
265
#endif
266
}
267
 
268
static void
269
VGA_setpalette(PSD psd,int first,int count,MWPALENTRY *pal)
270
{
271
        /* not yet implemented, std 16 color palette assumed*/
272
}
273
 
274
#if HAVEBLIT
275
/* initialize memory device with passed parms, and select suitable fb driver*/
276
static MWBOOL
277
VGA_mapmemgc(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,int linelen,
278
        int size,void *addr)
279
{
280
        extern SUBDRIVER memplan4;
281
 
282
        /* initialize mem screen driver*/
283
        initmemgc(mempsd, w, h, planes, bpp, linelen, size, addr);
284
 
285
        /* set and initialize subdriver into mem screen driver*/
286
        if (!set_subdriver(mempsd, &memplan4, TRUE))
287
                return 0;
288
 
289
        return 1;
290
}
291
#endif

powered by: WebSVN 2.1.0

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